Ruby GTK3移行後のメインリポジトリ
修訂 | eef9739562994265a5048384b2229731395e5465 (tree) |
---|---|
時間 | 2017-03-25 19:55:45 |
作者 | Shyouzou Sugitani <shy@user...> |
Commiter | Shyouzou Sugitani |
coding style cleanup and misc fixes
@@ -1,3 +1,8 @@ | ||
1 | +Sat March 25 2017 Shyouzou Sugitani <shy@users.osdn.me> | |
2 | + * Copyrightを2017年に更新した. | |
3 | + * Rubyらしいコーディングスタイルへの修正. | |
4 | + * HolonとMemeクラスを拡張. | |
5 | + | |
1 | 6 | Sun December 11 2016 Shyouzou Sugitani <shy@users.osdn.me> |
2 | 7 | * Rubyらしいコーディングスタイルへの修正. |
3 | 8 | * Makotoクラスのテストをtest-makoto.rbに移動. |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
4 | -# Copyright (C) 2004-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2004-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
7 | 7 | # under the terms of the GNU General Public License (version 2) as |
@@ -2,7 +2,7 @@ | ||
2 | 2 | # |
3 | 3 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
4 | 4 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
5 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | 6 | # Copyright (C) 2003 by Shun-ichi TAHARA <jado@flowernet.gr.jp> |
7 | 7 | # |
8 | 8 | # This program is free software; you can redistribute it and/or modify it |
@@ -16,15 +16,18 @@ | ||
16 | 16 | require "gtk3" |
17 | 17 | |
18 | 18 | require_relative "pix" |
19 | - | |
19 | +require_relative "metamagic" | |
20 | 20 | |
21 | 21 | module Balloon |
22 | 22 | |
23 | - class Balloon | |
23 | + class Balloon < MetaMagic::Holon | |
24 | 24 | attr_accessor :window, :user_interaction |
25 | 25 | |
26 | 26 | def initialize |
27 | - @parent = nil | |
27 | + super("") # FIXME | |
28 | + @handlers = { | |
29 | + 'reset_user_interaction' => 'reset_user_interaction', | |
30 | + } | |
28 | 31 | @synchronized = [] |
29 | 32 | @user_interaction = false |
30 | 33 | @window = [] |
@@ -42,24 +45,6 @@ module Balloon | ||
42 | 45 | @passwordinputbox.set_responsible(self) |
43 | 46 | end |
44 | 47 | |
45 | - def set_responsible(parent) | |
46 | - @parent = parent | |
47 | - end | |
48 | - | |
49 | - def handle_request(event_type, event, *arglist) | |
50 | - fail "assert" unless ['GET', 'NOTIFY'].include?(event_type) | |
51 | - handlers = { | |
52 | - 'reset_user_interaction' => 'reset_user_interaction', | |
53 | - } | |
54 | - unless handlers.include?(event) | |
55 | - result = @parent.handle_request( | |
56 | - event_type, event, *arglist) | |
57 | - else | |
58 | - result = method(handlers[event]).call(*arglist) | |
59 | - end | |
60 | - return result if event_type == 'GET' | |
61 | - end | |
62 | - | |
63 | 48 | def reset_user_interaction |
64 | 49 | @user_interaction = false |
65 | 50 | end |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # communicate.rb - ghost-to-ghost communication mechanism |
4 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or modify it |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
4 | -# Copyright (C) 2003-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2003-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
7 | 7 | # under the terms of the GNU General Public License (version 2) as |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # dll.rb - a pseudo DLL (SHIORI/SAORI API support) module for ninix |
4 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or modify it |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # aya.rb - an aya.dll compatible Shiori module for ninix |
4 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or modify it |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # aya5.rb - an aya.dll(Ver.5) compatible Shiori module for ninix |
4 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or modify it |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # bln.rb - a easyballoon compatible Saori module for ninix |
4 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
7 | 7 | # under the terms of the GNU General Public License (version 2) as |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # gomi.rb - a gomi.dll compatible Saori module for ninix |
4 | -# Copyright (C) 2012-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2012-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
7 | 7 | # under the terms of the GNU General Public License (version 2) as |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # hanayu.rb - a "花柚" compatible Saori module for ninix |
4 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or modify it |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # httpc.rb - a HTTPC compatible Saori module for ninix |
4 | -# Copyright (C) 2011-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2011-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
7 | 7 | # under the terms of the GNU General Public License (version 2) as |
@@ -3,7 +3,7 @@ | ||
3 | 3 | # kawari.rb - a "華和梨" compatible Shiori module for ninix |
4 | 4 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
5 | 5 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
6 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
7 | 7 | # Copyright (C) 2003 by Shun-ichi TAHARA <jado@flowernet.gr.jp> |
8 | 8 | # |
9 | 9 | # This program is free software; you can redistribute it and/or modify it |
@@ -2,7 +2,7 @@ | ||
2 | 2 | # |
3 | 3 | # kawari8.rb - a (Real) 華和梨 loader for ninix |
4 | 4 | # Copyright (C) 2002, 2003 by ABE Hideaki <abe-xx@eos.dricas.com> |
5 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.sourceforge.jp> | |
5 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.sourceforge.jp> | |
6 | 6 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
7 | 7 | # |
8 | 8 | # This program is free software; you can redistribute it and/or modify it |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # mciaudio.rb - a MCIAUDIO compatible Saori module for ninix |
4 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or modify it |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # mciaudior.rb - a MCIAUDIOR compatible Saori module for ninix |
4 | -# Copyright (C) 2003-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2003-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # Copyright (C) 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or modify it |
@@ -3,7 +3,7 @@ | ||
3 | 3 | # misaka.rb - a "美坂" compatible Shiori module for ninix |
4 | 4 | # Copyright (C) 2002 by Tamito KAJIYAMA |
5 | 5 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
6 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
7 | 7 | # |
8 | 8 | # This program is free software; you can redistribute it and/or modify it |
9 | 9 | # under the terms of the GNU General Public License (version 2) as |
@@ -3,7 +3,7 @@ | ||
3 | 3 | # niseshiori.rb - a "偽栞" compatible Shiori module for ninix |
4 | 4 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
5 | 5 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
6 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
7 | 7 | # Copyright (C) 2003 by Shun-ichi TAHARA <jado@flowernet.gr.jp> |
8 | 8 | # |
9 | 9 | # This program is free software; you can redistribute it and/or modify it |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # osuwari.rb - a Osuwari compatible Saori module for ninix |
4 | -# Copyright (C) 2006-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2006-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
7 | 7 | # under the terms of the GNU General Public License (version 2) as |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # saori_cpuid.rb - a saori_cpuid compatible Saori module for ninix |
4 | -# Copyright (C) 2003-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2003-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
7 | 7 | # under the terms of the GNU General Public License (version 2) as |
@@ -3,7 +3,7 @@ | ||
3 | 3 | # satori.rb - a "里々" compatible Shiori module for ninix |
4 | 4 | # Copyright (C) 2002 by Tamito KAJIYAMA |
5 | 5 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
6 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
7 | 7 | # Copyright (C) 2003, 2004 by Shun-ichi TAHARA <jado@flowernet.gr.jp> |
8 | 8 | # |
9 | 9 | # This program is free software; you can redistribute it and/or modify it |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # ssu.rb - a ssu compatible Saori module for ninix |
4 | -# Copyright (C) 2003-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2003-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
7 | 7 | # under the terms of the GNU General Public License (version 2) as |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # textcopy.rb - a TEXTCOPY compatible Saori module for ninix |
4 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or modify it |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # wmove.rb - a wmove.dll compatible Saori module for ninix |
4 | -# Copyright (C) 2003-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2003-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
7 | 7 | # under the terms of the GNU General Public License (version 2) as |
@@ -2,7 +2,7 @@ | ||
2 | 2 | # |
3 | 3 | # yaya.rb - a (Real) YAYA loader for ninix |
4 | 4 | # Copyright (C) 2004 by linjian |
5 | -# Copyright (C) 2004-2016 by Shyouzou Sugitani <shy@users.sourceforge.jp> | |
5 | +# Copyright (C) 2004-2017 by Shyouzou Sugitani <shy@users.sourceforge.jp> | |
6 | 6 | # Copyright (C) 2011 by henryhu |
7 | 7 | # |
8 | 8 | # This program is free software; you can redistribute it and/or modify it |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
4 | -# Copyright (C) 2004-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2004-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
7 | 7 | # under the terms of the GNU General Public License (version 2) as |
@@ -2,7 +2,7 @@ | ||
2 | 2 | # |
3 | 3 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
4 | 4 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
5 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or modify it |
8 | 8 | # under the terms of the GNU General Public License (version 2) as |
@@ -3,7 +3,7 @@ | ||
3 | 3 | # install.rb - an installer module for ninix |
4 | 4 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
5 | 5 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
6 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
7 | 7 | # Copyright (C) 2003 by Shun-ichi TAHARA <jado@flowernet.gr.jp> |
8 | 8 | # |
9 | 9 | # This program is free software; you can redistribute it and/or modify it |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # Copyright (C) 2002 by Tamito KAJIYAMA |
4 | -# Copyright (C) 2003-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2003-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
7 | 7 | # under the terms of the GNU General Public License (version 2) as |
@@ -1,6 +1,6 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | -# Copyright (C) 2004-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
3 | +# Copyright (C) 2004-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | 4 | # |
5 | 5 | # This program is free software; you can redistribute it and/or modify it |
6 | 6 | # under the terms of the GNU General Public License (version 2) as |
@@ -1,6 +1,6 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | -# Copyright (C) 2011-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
3 | +# Copyright (C) 2011-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | 4 | # |
5 | 5 | # This program is free software; you can redistribute it and/or modify it |
6 | 6 | # under the terms of the GNU General Public License (version 2) as |
@@ -1,6 +1,6 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | -# Copyright (C) 2015, 2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
3 | +# Copyright (C) 2015-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | 4 | # |
5 | 5 | # This program is free software; you can redistribute it and/or modify it |
6 | 6 | # under the terms of the GNU General Public License (version 2) as |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
4 | -# Copyright (C) 2004-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2004-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
7 | 7 | # under the terms of the GNU General Public License (version 2) as |
@@ -1,6 +1,6 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | -# Copyright (C) 2003-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
3 | +# Copyright (C) 2003-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | 4 | # Copyright (C) 2003 by Shun-ichi TAHARA <jado@flowernet.gr.jp> |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # metamagic.rb - unknown unknowns |
4 | -# Copyright (C) 2011-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2011-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
7 | 7 | # under the terms of the GNU General Public License (version 2) as |
@@ -19,6 +19,27 @@ module MetaMagic | ||
19 | 19 | @key = key |
20 | 20 | @baseinfo = nil |
21 | 21 | @menuitem = nil |
22 | + @parent = nil | |
23 | + @handlers = {} | |
24 | + end | |
25 | + | |
26 | + def set_responsible(parent) | |
27 | + @parent = parent | |
28 | + end | |
29 | + | |
30 | + def handle_request(event_type, event, *arglist) | |
31 | + fail "assert" unless ['GET', 'NOTIFY'].include?(event_type) | |
32 | + unless @handlers.include?(event) | |
33 | + if self.class.method_defined?(event) | |
34 | + result = method(event).call(*arglist) | |
35 | + else | |
36 | + result = @parent.handle_request( | |
37 | + event_type, event, *arglist) | |
38 | + end | |
39 | + else | |
40 | + result = method(@handlers[event]).call(*arglist) | |
41 | + end | |
42 | + return result if event_type == 'GET' | |
22 | 43 | end |
23 | 44 | |
24 | 45 | def create_menuitem(data) |
@@ -62,8 +83,28 @@ module MetaMagic | ||
62 | 83 | @baseinfo = nil |
63 | 84 | @menuitem = nil |
64 | 85 | @instance = nil |
86 | + @parent = nil | |
87 | + end | |
88 | + | |
89 | + def set_responsible(parent) | |
90 | + @parent = parent | |
65 | 91 | end |
66 | 92 | |
93 | + def handle_request(event_type, event, *arglist) | |
94 | + fail "assert" unless ['GET', 'NOTIFY'].include?(event_type) | |
95 | + unless @handlers.include?(event) | |
96 | + if self.class.method_defined?(event) | |
97 | + result = method(event).call(*arglist) | |
98 | + else | |
99 | + result = @parent.handle_request( | |
100 | + event_type, event, *arglist) | |
101 | + end | |
102 | + else | |
103 | + result = method(@handlers[event]).call(*arglist) | |
104 | + end | |
105 | + return result if event_type == 'GET' | |
106 | + end | |
107 | + | |
67 | 108 | def create_menuitem(data) |
68 | 109 | nil |
69 | 110 | end |
@@ -1,6 +1,6 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | -# Copyright (C) 2004-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
3 | +# Copyright (C) 2004-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | 4 | # |
5 | 5 | # This program is free software; you can redistribute it and/or modify it |
6 | 6 | # under the terms of the GNU General Public License (version 2) as |
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | 3 | # Copyright (C) 2001-2004 by MATSUMURA Namihiko <nie@counterghost.net> |
4 | -# Copyright (C) 2004-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | +# Copyright (C) 2004-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
7 | 7 | # under the terms of the GNU General Public License (version 2) as |
@@ -1,6 +1,6 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | -# Copyright (C) 2003-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
3 | +# Copyright (C) 2003-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | 4 | # |
5 | 5 | # This program is free software; you can redistribute it and/or modify it |
6 | 6 | # under the terms of the GNU General Public License (version 2) as |
@@ -2,7 +2,7 @@ | ||
2 | 2 | # |
3 | 3 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
4 | 4 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
5 | -# Copyright (C) 2004-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | +# Copyright (C) 2004-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | 6 | # Copyright (C) 2003-2005 by Shun-ichi TAHARA <jado@flowernet.gr.jp> |
7 | 7 | # |
8 | 8 | # This program is free software; you can redistribute it and/or modify it |
@@ -2,7 +2,7 @@ | ||
2 | 2 | # |
3 | 3 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
4 | 4 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
5 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | 6 | # Copyright (C) 2003 by Shun-ichi TAHARA <jado@flowernet.gr.jp> |
7 | 7 | # |
8 | 8 | # This program is free software; you can redistribute it and/or modify it |
@@ -40,11 +40,6 @@ module Sakura | ||
40 | 40 | |
41 | 41 | def initialize(key) |
42 | 42 | super(key) |
43 | - @parent = nil | |
44 | - end | |
45 | - | |
46 | - def set_responsible(parent) | |
47 | - @parent = parent | |
48 | 43 | end |
49 | 44 | |
50 | 45 | def create_menuitem(data) |
@@ -66,7 +61,7 @@ module Sakura | ||
66 | 61 | end |
67 | 62 | end |
68 | 63 | |
69 | - class Sakura | |
64 | + class Sakura < MetaMagic::Holon | |
70 | 65 | attr_reader :key, :cantalk, :last_script |
71 | 66 | |
72 | 67 | include GetText |
@@ -88,7 +83,10 @@ module Sakura | ||
88 | 83 | FROM_GHOST = 2 |
89 | 84 | |
90 | 85 | def initialize |
91 | - @parent = nil | |
86 | + super("") # FIXME | |
87 | + @handlers = { | |
88 | + 'lock_repaint' => "get_lock_repaint" | |
89 | + } | |
92 | 90 | @sstp_handle = nil |
93 | 91 | @sstp_entry_db = nil |
94 | 92 | @sstp_request_handler = nil |
@@ -160,28 +158,6 @@ module Sakura | ||
160 | 158 | @reload_event = nil |
161 | 159 | end |
162 | 160 | |
163 | - def set_responsible(parent) | |
164 | - @parent = parent | |
165 | - end | |
166 | - | |
167 | - def handle_request(event_type, event, *arglist) | |
168 | - fail "assert" unless ['GET', 'NOTIFY'].include?(event_type) | |
169 | - handlers = { | |
170 | - 'lock_repaint' => "get_lock_repaint" | |
171 | - } | |
172 | - unless handlers.include?(event) | |
173 | - if Sakura.method_defined?(event) | |
174 | - result = method(event).call(*arglist) | |
175 | - else | |
176 | - result = @parent.handle_request( | |
177 | - event_type, event, *arglist) | |
178 | - end | |
179 | - else | |
180 | - result = method(handlers[event]).call(*arglist) | |
181 | - end | |
182 | - return result if event_type == 'GET' | |
183 | - end | |
184 | - | |
185 | 161 | def get_lock_repaint(*args) |
186 | 162 | @lock_repaint |
187 | 163 | end |
@@ -2076,7 +2052,7 @@ module Sakura | ||
2076 | 2052 | def __yen__b(args) |
2077 | 2053 | begin |
2078 | 2054 | filename, x, y = expand_meta(args[0]).split(',', 3) |
2079 | - rescue ArgumentError | |
2055 | + rescue ArgumentError ## FIXME: no exception in Ruby | |
2080 | 2056 | filename, param = expand_meta(args[0]).split(',', 2) |
2081 | 2057 | raise "assert" unless param == 'inline' |
2082 | 2058 | x, y = 0, 0 ## FIXME |
@@ -2380,6 +2356,7 @@ module Sakura | ||
2380 | 2356 | 'NOTIFY', 'select_ghost_by_name', self, args[2], :event => 0) |
2381 | 2357 | end |
2382 | 2358 | elsif args[0, 2] == ['call', 'ghost'] and argc > 2 |
2359 | + ## FIXME: 'random', 'lastinstalled'対応 | |
2383 | 2360 | key = @parent.handle_request('GET', 'find_ghost_by_name', args[2]) |
2384 | 2361 | unless key.nil? |
2385 | 2362 | @parent.handle_request('NOTIFY', 'start_sakura_cb', key, :caller => self) |
@@ -2470,7 +2447,7 @@ module Sakura | ||
2470 | 2447 | when '!stayontop' |
2471 | 2448 | @surface.window_stayontop(false) |
2472 | 2449 | end |
2473 | - elsif args[0, 2] == ['set', 'trayicon'] and argc > 2 | |
2450 | + elsif args[0, 2] == ['set', 'trayicon'] and argc > 2 ## FIXME: tasktrayicon | |
2474 | 2451 | path = File.join(get_prefix(), args[2]) |
2475 | 2452 | if File.exist?(path) |
2476 | 2453 | @status_icon.set_from_file(path) # XXX |
@@ -2604,9 +2581,9 @@ module Sakura | ||
2604 | 2581 | elsif args[0] == '*' |
2605 | 2582 | @balloon.append_sstp_marker(@script_side) |
2606 | 2583 | elsif args[0] == 'quicksession' and argc > 1 |
2607 | - if args[1] == 'true' | |
2584 | + if args[1] == 'true' ## FIXME: '1'でも可 | |
2608 | 2585 | @quick_session = true |
2609 | - elsif args[1] == 'false' | |
2586 | + elsif args[1] == 'false' ## FIXME: '0'でも可 | |
2610 | 2587 | @quick_session = false |
2611 | 2588 | else |
2612 | 2589 | #pass ## FIXME |
@@ -2,7 +2,7 @@ | ||
2 | 2 | # |
3 | 3 | # script.rb - a Sakura Script parser |
4 | 4 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
5 | -# Copyright (C) 2004-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | +# Copyright (C) 2004-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or modify it |
8 | 8 | # under the terms of the GNU General Public License (version 2) as |
@@ -2,7 +2,7 @@ | ||
2 | 2 | # |
3 | 3 | # Copyright (C) 2002 by Tamito KAJIYAMA |
4 | 4 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
5 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or modify it |
8 | 8 | # under the terms of the GNU General Public License (version 2) as |
@@ -14,17 +14,18 @@ | ||
14 | 14 | |
15 | 15 | require "gtk3" |
16 | 16 | |
17 | +require_relative "metamagic" | |
17 | 18 | require_relative "logging" |
18 | 19 | |
19 | 20 | module Seriko |
20 | 21 | |
21 | - class Controller | |
22 | + class Controller < MetaMagic::Holon | |
22 | 23 | |
23 | 24 | DEFAULT_FPS = 30.0 # current default |
24 | 25 | |
25 | 26 | def initialize(seriko) |
27 | + super("") # FIXME | |
26 | 28 | @seriko = seriko |
27 | - @parent = nil | |
28 | 29 | @exclusive_actor = nil |
29 | 30 | @base_id = nil |
30 | 31 | @timeout_id = nil |
@@ -38,10 +39,6 @@ module Seriko | ||
38 | 39 | @dirty = true |
39 | 40 | end |
40 | 41 | |
41 | - def set_responsible(parent) | |
42 | - @parent = parent | |
43 | - end | |
44 | - | |
45 | 42 | def set_base_id(window, surface_id) |
46 | 43 | case surface_id |
47 | 44 | when '-2' |
@@ -131,12 +128,16 @@ module Seriko | ||
131 | 128 | end |
132 | 129 | |
133 | 130 | def remove_overlay(actor) |
134 | - @dirty = true if @overlays.delete(actor) | |
131 | + @dirty = true unless @overlays.delete(actor).nil? | |
135 | 132 | end |
136 | 133 | |
137 | 134 | def add_overlay(window, actor, surface_id, x, y, method) |
138 | - terminate(window) if surface_id == '-2' | |
139 | - if ['-1', '-2'].include?(surface_id) | |
135 | + case surface_id | |
136 | + when '-2' | |
137 | + terminate(window) | |
138 | + remove_overlay(actor) | |
139 | + return | |
140 | + when '-1' | |
140 | 141 | remove_overlay(actor) |
141 | 142 | return |
142 | 143 | end |
@@ -2,7 +2,7 @@ | ||
2 | 2 | # |
3 | 3 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
4 | 4 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
5 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or modify it |
8 | 8 | # under the terms of the GNU General Public License (version 2) as |
@@ -52,7 +52,7 @@ module SSTP | ||
52 | 52 | def send_response(code, data: nil) |
53 | 53 | begin |
54 | 54 | @request_handler.send_response(code) |
55 | - @request_handler.write(data) if not data.nil? # FIXME | |
55 | + @request_handler.write(data) unless data.nil? # FIXME | |
56 | 56 | @request_handler.shutdown(Socket::SHUT_WR) # XXX |
57 | 57 | rescue |
58 | 58 | #pass |
@@ -62,7 +62,7 @@ module SSTP | ||
62 | 62 | |
63 | 63 | def send_answer(value) |
64 | 64 | charset = @request_handler.get_charset |
65 | - answer = [value.encode(charset, :invalid => :replace, :undef => :replace), "\r\n\r\n"].join("") | |
65 | + answer = "#{value.encode(charset, :invalid => :replace, :undef => :replace)}\r\n\r\n" | |
66 | 66 | send_response(200, :data => answer) # OK |
67 | 67 | end |
68 | 68 |
@@ -87,11 +87,10 @@ module SSTP | ||
87 | 87 | class SSTPRequestHandler < SSTPLib::BaseSSTPRequestHandler |
88 | 88 | |
89 | 89 | def handle(line) |
90 | - if not @server.handle_request('GET', 'get_sakura_cantalk') | |
91 | - @error = @version = nil | |
92 | - if not parse_request(line) | |
93 | - return | |
94 | - end | |
90 | + unless @server.handle_request('GET', 'get_sakura_cantalk') | |
91 | + @error = nil | |
92 | + @version = nil | |
93 | + return unless parse_request(line) | |
95 | 94 | send_error(512) |
96 | 95 | else |
97 | 96 | super(line) |
@@ -120,32 +119,24 @@ module SSTP | ||
120 | 119 | end |
121 | 120 | |
122 | 121 | def handle_send(version) |
123 | - if not check_decoder() | |
124 | - return | |
125 | - end | |
122 | + return unless check_decoder() | |
126 | 123 | sender = get_sender() |
127 | - if sender.nil? | |
128 | - return | |
129 | - end | |
130 | - if version == 1.3 | |
124 | + return if sender.nil? | |
125 | + case version | |
126 | + when 1.3 | |
131 | 127 | handle = get_handle() |
132 | - if handle.nil? | |
133 | - return | |
134 | - end | |
128 | + return if handle.nil? | |
135 | 129 | else |
136 | 130 | handle = nil |
137 | 131 | end |
138 | 132 | script_odict = get_script_odict() |
139 | - if script_odict.nil? | |
140 | - return | |
141 | - end | |
142 | - if [1.0, 1.1].include?(version) | |
133 | + return if script_odict.nil? | |
134 | + case version | |
135 | + when 1.0, 1.1 | |
143 | 136 | entry_db = nil |
144 | - elsif [1.2, 1.3, 1.4].include?(version) | |
137 | + when 1.2, 1.3, 1.4 | |
145 | 138 | entry_db = get_entry_db() |
146 | - if entry_db.nil? | |
147 | - return | |
148 | - end | |
139 | + return if entry_db.nil? | |
149 | 140 | end |
150 | 141 | enqueue_request(sender, nil, handle, script_odict, entry_db) |
151 | 142 | end |
@@ -161,28 +152,19 @@ module SSTP | ||
161 | 152 | |
162 | 153 | def handle_notify(version) |
163 | 154 | script_odict = {} |
164 | - if not check_decoder() | |
165 | - return | |
166 | - end | |
155 | + return unless check_decoder() | |
167 | 156 | sender = get_sender() |
168 | - if sender.nil? | |
169 | - return | |
170 | - end | |
157 | + return if sender.nil? | |
171 | 158 | event = get_event() |
172 | - if event.nil? | |
173 | - return | |
174 | - end | |
175 | - if version == 1.0 | |
159 | + return if event.nil? | |
160 | + case version | |
161 | + when 1.0 | |
176 | 162 | entry_db = nil |
177 | - elsif version == 1.1 | |
163 | + when 1.1 | |
178 | 164 | script_odict = get_script_odict() |
179 | - if script_odict.nil? | |
180 | - return | |
181 | - end | |
165 | + return if script_odict.nil? | |
182 | 166 | entry_db = get_entry_db() |
183 | - if entry_db.nil? | |
184 | - return | |
185 | - end | |
167 | + return if entry_db.nil? | |
186 | 168 | end |
187 | 169 | enqueue_request(sender, event, nil, script_odict, entry_db) |
188 | 170 | end |
@@ -214,7 +196,7 @@ module SSTP | ||
214 | 196 | PROHIBITED_TAGS = ['\j', '\-', '\+', '\_+', '\!', '\8', '\_v', '\C'] |
215 | 197 | |
216 | 198 | def check_script(script) |
217 | - if not local_request() | |
199 | + unless local_request() | |
218 | 200 | parser = Script::Parser.new |
219 | 201 | nodes = [] |
220 | 202 | while true |
@@ -227,11 +209,11 @@ module SSTP | ||
227 | 209 | break |
228 | 210 | end |
229 | 211 | end |
230 | - for node in nodes | |
231 | - if node[0] == Script::SCRIPT_TAG and \ | |
232 | - PROHIBITED_TAGS.include?(node[1]) | |
212 | + nodes.each do |node| | |
213 | + next unless node[0] == Script::SCRIPT_TAG | |
214 | + if PROHIBITED_TAGS.include?(node[1]) | |
233 | 215 | send_response(400) # Bad Request |
234 | - log_error('Script: tag ' + node[1].to_s + ' not allowed') | |
216 | + log_error("Script: tag #{node[1]} not allowed") | |
235 | 217 | return true |
236 | 218 | end |
237 | 219 | end |
@@ -242,25 +224,19 @@ module SSTP | ||
242 | 224 | def get_script_odict |
243 | 225 | script_odict = {} # Ordered Hash |
244 | 226 | if_ghost = nil |
245 | - for item in @headers | |
246 | - name, value = item | |
247 | - if name != 'Script' | |
248 | - if name == ('IfGhost') | |
249 | - if_ghost = value | |
250 | - else | |
251 | - if_ghost = nil | |
252 | - end | |
227 | + @headers.each do |name, value| | |
228 | + case name | |
229 | + when 'IfGhost' | |
230 | + if_ghost = value | |
231 | + when 'Script' | |
232 | + # nop | |
233 | + else | |
234 | + if_ghost = nil | |
253 | 235 | next |
254 | 236 | end |
255 | 237 | script = value.to_s |
256 | - if check_script(script) | |
257 | - return | |
258 | - end | |
259 | - if if_ghost.nil? | |
260 | - script_odict[''] = script | |
261 | - else | |
262 | - script_odict[if_ghost] = script | |
263 | - end | |
238 | + return if check_script(script) | |
239 | + script_odict[if_ghost || ''] = script | |
264 | 240 | if_ghost = nil |
265 | 241 | end |
266 | 242 | return script_odict |
@@ -268,50 +244,36 @@ module SSTP | ||
268 | 244 | |
269 | 245 | def get_entry_db |
270 | 246 | entry_db = EntryDB::EntryDatabase.new |
271 | - for item in @headers | |
272 | - key, value = item | |
273 | - if key == "Entry" | |
274 | - entry = value.split(',', 2) | |
275 | - if entry.length != 2 | |
276 | - send_response(400) # Bad Request | |
277 | - return nil | |
278 | - end | |
279 | - entry_db.add(entry[0].strip(), entry[1].strip()) | |
247 | + @headers.each do |key, value| | |
248 | + next unless key == "Entry" | |
249 | + entry = value.split(',', 2) | |
250 | + if entry.length != 2 | |
251 | + send_response(400) # Bad Request | |
252 | + return nil | |
280 | 253 | end |
254 | + entry_db.add(entry[0].strip(), entry[1].strip()) | |
281 | 255 | end |
282 | 256 | return entry_db |
283 | 257 | end |
284 | 258 | |
285 | 259 | def get_event |
286 | - if not @headers.assoc("Event").nil? | |
287 | - event = @headers.reverse.assoc("Event")[1] | |
288 | - else | |
289 | - event = nil | |
290 | - end | |
260 | + event = @headers.reverse.assoc("Event")&.at(1) | |
291 | 261 | if event.nil? |
292 | 262 | send_response(400) # Bad Request |
293 | 263 | log_error('Event: header field not found') |
294 | 264 | return nil |
295 | 265 | end |
296 | 266 | buf = [event] |
297 | - for i in 0..7 | |
298 | - key = ['Reference', i.to_s].join("") | |
299 | - if not @headers.assoc(key).nil? | |
300 | - value = @headers.reverse.assoc(key)[1] | |
301 | - else | |
302 | - value = nil | |
303 | - end | |
267 | + (0..7).each do |i| | |
268 | + key = "Reference#{i}" | |
269 | + value = @headers.reverse.assoc(key)&.at(1) | |
304 | 270 | buf << value |
305 | 271 | end |
306 | 272 | return buf |
307 | 273 | end |
308 | 274 | |
309 | 275 | def get_sender |
310 | - if not @headers.assoc('Sender').nil? | |
311 | - sender = @headers.reverse.assoc('Sender')[1] | |
312 | - else | |
313 | - sender = nil | |
314 | - end | |
276 | + sender = @headers.reverse.assoc('Sender')&.at(1) | |
315 | 277 | if sender.nil? |
316 | 278 | send_response(400) # Bad Request |
317 | 279 | log_error('Sender: header field not found') |
@@ -321,11 +283,7 @@ module SSTP | ||
321 | 283 | end |
322 | 284 | |
323 | 285 | def get_handle |
324 | - if not @headers.assoc("HWnd").nil? | |
325 | - path = @headers.assoc("HWnd")[1] | |
326 | - else | |
327 | - path = nil | |
328 | - end | |
286 | + path = @headers.assoc("HWnd")&.at(1) | |
329 | 287 | if path.nil? |
330 | 288 | send_response(400) # Bad Request |
331 | 289 | log_error('HWnd: header field not found') |
@@ -347,40 +305,27 @@ module SSTP | ||
347 | 305 | end |
348 | 306 | |
349 | 307 | def get_charset |
350 | - if not @headers.assoc('Charset').nil? | |
351 | - charset = @headers.reverse.assoc('Charset')[1] # XXX | |
352 | - else | |
353 | - charset = 'Shift_JIS' | |
354 | - end | |
355 | - return charset | |
308 | + @headers.reverse.assoc('Charset')&.at(1) || 'Shift_JIS' # XXX | |
356 | 309 | end |
357 | 310 | |
358 | 311 | def check_decoder |
359 | - if not @headers.assoc('Charset').nil? | |
360 | - charset = @headers.reverse.assoc('Charset')[1] # XXX | |
361 | - else | |
362 | - charset = 'Shift_JIS' | |
363 | - end | |
364 | - if not Encoding.name_list.include?(charset) | |
365 | - send_response(420, :data => 'Refuse (unsupported charset)') | |
366 | - log_error('Unsupported charset ' + charset.to_s) | |
367 | - else | |
368 | - return true | |
369 | - end | |
312 | + charset = get_charset | |
313 | + return true if Encoding.name_list.include?(charset) | |
314 | + send_response(420, :data => 'Refuse (unsupported charset)') | |
315 | + log_error("Unsupported charset #{charset}") | |
370 | 316 | return false |
371 | 317 | end |
372 | 318 | |
373 | 319 | def get_options |
374 | 320 | show_sstp_marker = use_translator = true |
375 | - if not @headers.assoc("Option").nil? | |
376 | - options = @headers.reverse.assoc("Option")[1].split(",", 0) | |
377 | - for option in options | |
378 | - option = option.strip() | |
379 | - if option == 'nodescript' and local_request() | |
380 | - show_sstp_marker = false | |
381 | - elsif option == 'notranslate' | |
382 | - use_translator = false | |
383 | - end | |
321 | + options = (@headers.reverse.assoc("Option")&.at(1) || "").split(",", 0) | |
322 | + options.each do |option| | |
323 | + option = option.strip() | |
324 | + case option | |
325 | + when 'nodescript' | |
326 | + show_sstp_marker = false if local_request() | |
327 | + when 'notranslate' | |
328 | + use_translator = false | |
384 | 329 | end |
385 | 330 | end |
386 | 331 | return show_sstp_marker, use_translator |
@@ -401,11 +346,10 @@ module SSTP | ||
401 | 346 | end |
402 | 347 | |
403 | 348 | def do_EXECUTE_1_3 |
404 | - if not local_request() | |
349 | + unless local_request() | |
405 | 350 | sock_domain, remote_port, remote_hostname, remote_ip = @fp.peeraddr |
406 | 351 | send_response(420) |
407 | - log_error( | |
408 | - 'Unauthorized EXECUTE/1.3 request from ' + remote_hostname) | |
352 | + log_error("Unauthorized EXECUTE/1.3 request from #{remote_hostname}") | |
409 | 353 | return |
410 | 354 | end |
411 | 355 | handle_command() |
@@ -420,66 +364,62 @@ module SSTP | ||
420 | 364 | end |
421 | 365 | |
422 | 366 | def handle_command |
423 | - if not check_decoder() | |
424 | - return | |
425 | - end | |
367 | + return unless check_decoder() | |
426 | 368 | sender = get_sender() |
427 | - if sender.nil? | |
428 | - return | |
429 | - end | |
369 | + return if sender.nil? | |
430 | 370 | command = get_command() |
431 | - if not @headers.assoc('Charset').nil? | |
432 | - charset = @headers.reverse.assoc('Charset')[1] # XXX | |
433 | - else | |
434 | - charset = 'Shift_JIS' | |
435 | - end | |
371 | + charset = get_charset | |
436 | 372 | charset = charset.to_s |
437 | - if command.nil? | |
373 | + case command | |
374 | + when nil | |
438 | 375 | return |
439 | - elsif command == 'getname' | |
376 | + when 'getname' | |
440 | 377 | send_response(200) |
441 | 378 | name = @server.handle_request('GET', 'get_ghost_name') |
442 | - @fp.write([name.encode(charset, :invalid => :replace, :undef => :replace), | |
443 | - "\r\n"].join("")) | |
379 | + @fp.write(name.encode( | |
380 | + charset, :invalid => :replace, :undef => :replace)) | |
444 | 381 | @fp.write("\r\n") |
445 | - elsif command == 'getversion' | |
382 | + @fp.write("\r\n") | |
383 | + when 'getversion' | |
446 | 384 | send_response(200) |
447 | - @fp.write(["ninix-aya ", | |
448 | - Version.VERSION.encode(charset, :invalid => :replace, :undef => :replace), | |
449 | - "\r\n"].join("")) | |
385 | + @fp.write("ninix-aya ") | |
386 | + @fp.write(Version.VERSION.encode( | |
387 | + charset, :invalid => :replace, :undef => :replace)) | |
388 | + @fp.write("\r\n") | |
450 | 389 | @fp.write("\r\n") |
451 | - elsif command == 'quiet' | |
390 | + when 'quiet' | |
452 | 391 | send_response(200) |
453 | 392 | @server.handle_request('NOTIFY', 'keep_silence', true) |
454 | - elsif command == 'restore' | |
393 | + when 'restore' | |
455 | 394 | send_response(200) |
456 | 395 | @server.handle_request('NOTIFY', 'keep_silence', false) |
457 | - elsif command == 'getnames' | |
396 | + when 'getnames' | |
458 | 397 | send_response(200) |
459 | 398 | for name in @server.handle_request('GET', 'get_ghost_names') |
460 | - @fp.write( | |
461 | - [name.encode(charset, :invalid => :replace, :undef => :replace), "\r\n"].join("")) | |
399 | + @fp.write(name.encode( | |
400 | + charset, :invalid => :replace, :undef => :replace)) | |
401 | + @fp.write("\r\n") | |
462 | 402 | end |
463 | 403 | @fp.write("\r\n") |
464 | - elsif command == 'checkqueue' | |
404 | + when 'checkqueue' | |
465 | 405 | send_response(200) |
466 | 406 | count, total = @server.handle_request( |
467 | 407 | 'GET', 'check_request_queue', sender) |
468 | - @fp.write([count.to_s.encode(charset, :invalid => :replace, :undef => :replace), "\r\n"].join("")) | |
469 | - @fp.write([total.to_s.encode(charset, :invalid => :replace, :undef => :replace), "\r\n"].join("")) | |
408 | + @fp.write(count.to_s.encode( | |
409 | + charset, :invalid => :replace, :undef => :replace)) | |
410 | + @fp.write("\r\n") | |
411 | + @fp.write(total.to_s.encode( | |
412 | + charset, :invalid => :replace, :undef => :replace)) | |
413 | + @fp.write("\r\n") | |
470 | 414 | @fp.write("\r\n") |
471 | 415 | else |
472 | 416 | send_response(501) # Not Implemented |
473 | - log_error('Not Implemented (' + command + ')') | |
417 | + log_error("Not Implemented (#{command})") | |
474 | 418 | end |
475 | 419 | end |
476 | 420 | |
477 | 421 | def get_command |
478 | - if @headers.assoc('Command') | |
479 | - command = @headers.reverse.assoc('Command')[1] | |
480 | - else | |
481 | - command = nil | |
482 | - end | |
422 | + command = @headers.reverse.assoc('Command')&.at(1) | |
483 | 423 | if command.nil? |
484 | 424 | send_response(400) # Bad Request |
485 | 425 | log_error('Command: header field not found') |
@@ -489,17 +429,11 @@ module SSTP | ||
489 | 429 | end |
490 | 430 | |
491 | 431 | def do_COMMUNICATE_1_1 |
492 | - if not check_decoder() | |
493 | - return | |
494 | - end | |
432 | + return unless check_decoder() | |
495 | 433 | sender = get_sender() |
496 | - if sender.nil? | |
497 | - return | |
498 | - end | |
434 | + return if sender.nil? | |
499 | 435 | sentence = get_sentence() |
500 | - if sentence.nil? | |
501 | - return | |
502 | - end | |
436 | + return if sentence.nil? | |
503 | 437 | send_response(200) # OK |
504 | 438 | @server.handle_request( |
505 | 439 | 'NOTIFY', 'enqueue_event', 'OnCommunicate', sender, sentence) |
@@ -507,11 +441,7 @@ module SSTP | ||
507 | 441 | end |
508 | 442 | |
509 | 443 | def get_sentence |
510 | - if @headers.assoc("Sentence") | |
511 | - sentence = @headers.reverse.assoc("Sentence")[1] | |
512 | - else | |
513 | - sentence = nil | |
514 | - end | |
444 | + sentence = @headers.reverse.assoc("Sentence")&.at(1) | |
515 | 445 | if sentence.nil? |
516 | 446 | send_response(400) # Bad Request |
517 | 447 | log_error('Sentence: header field not found') |
@@ -3,7 +3,7 @@ | ||
3 | 3 | # sstplib.rb - an SSTP library module in Ruby |
4 | 4 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
5 | 5 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
6 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
7 | 7 | # |
8 | 8 | # This program is free software; you can redistribute it and/or modify it |
9 | 9 | # under the terms of the GNU General Public License (version 2) as |
@@ -40,71 +40,41 @@ module SSTPLib | ||
40 | 40 | end |
41 | 41 | |
42 | 42 | def parse_headers() |
43 | - if @fp.nil? | |
44 | - return | |
45 | - end | |
46 | - headers = [] | |
47 | - while true | |
48 | - line = @fp.readline() | |
49 | - if line.strip.empty? | |
50 | - break | |
51 | - end | |
52 | - if line.end_with?("\r\n") | |
53 | - line = line[0..-3] | |
54 | - elsif line.end_with?("\n") | |
55 | - line = line[0..-2] | |
56 | - end | |
57 | - headers << line | |
58 | - end | |
43 | + return if @fp.nil? | |
59 | 44 | message = [] |
60 | - for h in headers | |
61 | - if h.include?(":") | |
62 | - key, value = h.split(":", 2) | |
63 | - message << [key, value.strip] | |
64 | - end | |
65 | - end | |
66 | - if not message.assoc("Charset").nil? | |
67 | - charset = message.reverse.assoc("Charset")[1] # XXX | |
68 | - else | |
69 | - charset = "Shift_JIS" | |
45 | + while line = @fp.gets | |
46 | + break if line.strip.empty? | |
47 | + line = line.chomp | |
48 | + next unless line.include?(":") | |
49 | + key, value = line.split(":", 2) | |
50 | + message << [key, value.strip] | |
70 | 51 | end |
71 | - new_list = [] | |
72 | - for item in message | |
73 | - key, value = item | |
74 | - new_list << [key, value.force_encoding(charset).encode("UTF-8", :invalid => :replace, :undef => :replace)] | |
75 | - end | |
76 | - message = new_list | |
77 | - return message | |
52 | + charset = message.reverse.assoc("Charset")&.at(1) || "Shift_JIS" # XXX | |
53 | + message.each {|k, v| v.force_encoding(charset).encode!("UTF-8", :invalid => :replace, :undef => :replace) } | |
78 | 54 | end |
79 | 55 | |
80 | 56 | def parse_request(requestline) |
81 | 57 | requestline = requestline.encode('Shift_JIS', :invalid => :replace, :undef => :replace) |
82 | - if requestline.end_with?("\r\n") | |
83 | - requestline = requestline[0..-3] | |
84 | - elsif requestline.end_with?("\n") | |
85 | - requestline = requestline[0..-2] | |
86 | - end | |
58 | + requestline = requestline.chomp | |
87 | 59 | @requestline = requestline |
88 | 60 | re_requestsyntax = Regexp.new('\A([A-Z]+) SSTP/([0-9]\\.[0-9])\z') |
89 | 61 | match = re_requestsyntax.match(requestline) |
90 | 62 | if match.nil? |
91 | 63 | @equestline = '-' |
92 | - send_error(400, :message => 'Bad Request ' + requestline.to_s) | |
64 | + send_error(400, :message => "Bad Request #{requestline}") | |
93 | 65 | return false |
94 | 66 | end |
95 | 67 | @command, @version = match[1, 2] |
96 | - @headers = parse_headers() | |
68 | + @headers = parse_headers | |
97 | 69 | return true |
98 | 70 | end |
99 | 71 | |
100 | 72 | def handle(line) |
101 | 73 | @error = @version = nil |
102 | - if not parse_request(line) | |
103 | - return | |
104 | - end | |
74 | + return unless parse_request(line) | |
105 | 75 | name = ("do_#{@command}_#{@version[0]}_#{@version[2]}") |
106 | 76 | begin |
107 | - method(name).call() | |
77 | + method(name).call | |
108 | 78 | rescue |
109 | 79 | send_error( |
110 | 80 | 501, |
@@ -121,20 +91,20 @@ module SSTPLib | ||
121 | 91 | |
122 | 92 | def send_response(code, message: nil) |
123 | 93 | log_request(code, :message => message) |
124 | - @fp.write("SSTP/" + (@version or "1.0") + " " + code.to_i.to_s + " " + RESPONSES[code] + "\r\n\r\n") | |
94 | + @fp.write("SSTP/#{(@version or "1.0")} #{code} #{RESPONSES[code]}\r\n\r\n") | |
125 | 95 | end |
126 | 96 | |
127 | 97 | def log_error(message) |
128 | - Logging::Logging.error('[' + timestamp + '] ' + message + '\n') | |
98 | + Logging::Logging.error("[#{timestamp}] #{message}\n") | |
129 | 99 | end |
130 | 100 | |
131 | 101 | def log_request(code, message: nil) |
132 | 102 | if @requestline == '-' |
133 | 103 | request = @requestline |
134 | 104 | else |
135 | - request = ['"', @requestline, '"'].join("") | |
105 | + request = "\"#{@requestline}\"" | |
136 | 106 | end |
137 | - Logging::Logging.info(client_hostname + ' [' + timestamp + '] ' + request + ' ' + code.to_s + ' ' + (message or RESPONSES[code]) + "\n") | |
107 | + Logging::Logging.info("#{client_hostname} [#{timestamp}] #{request} #{code} #{(message or RESPONSES[code])}\n") | |
138 | 108 | end |
139 | 109 | |
140 | 110 | def client_hostname |
@@ -147,12 +117,7 @@ module SSTPLib | ||
147 | 117 | end |
148 | 118 | |
149 | 119 | def timestamp |
150 | - month_names = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', | |
151 | - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] | |
152 | - t = Time.now.localtime | |
153 | - m = month_names[t.month - 1] | |
154 | - return sprintf('%02d/%s/%d:%02d:%02d:%02d %+05d', | |
155 | - t.day, m, t.year, t.hour, t.min, t.sec, t.utc_offset / 36) | |
120 | + Time.now.localtime.strftime("%d/%b/%Y:%H:%M:%S %z") | |
156 | 121 | end |
157 | 122 | end |
158 | 123 | end |
@@ -2,7 +2,7 @@ | ||
2 | 2 | # |
3 | 3 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
4 | 4 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
5 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | 6 | # Copyright (C) 2003 by Shun-ichi TAHARA <jado@flowernet.gr.jp> |
7 | 7 | # |
8 | 8 | # This program is free software; you can redistribute it and/or modify it |
@@ -18,40 +18,24 @@ require "gtk3" | ||
18 | 18 | require_relative "keymap" |
19 | 19 | require_relative "pix" |
20 | 20 | require_relative "seriko" |
21 | +require_relative "metamagic" | |
21 | 22 | require_relative "logging" |
22 | 23 | |
23 | 24 | module Surface |
24 | 25 | |
25 | - class Surface | |
26 | + class Surface < MetaMagic::Holon | |
26 | 27 | attr_reader :name, :prefix, :window |
27 | 28 | |
28 | 29 | def initialize |
30 | + super("") # FIXME | |
29 | 31 | @window = [] |
30 | 32 | @desc = nil |
31 | 33 | @mikire = 0 |
32 | 34 | @kasanari = 0 |
33 | 35 | @key_press_count = 0 |
34 | - end | |
35 | - | |
36 | - def set_responsible(parent) | |
37 | - @parent = parent | |
38 | - end | |
39 | - | |
40 | - def handle_request(event_type, event, *arglist) | |
41 | - fail "assert" unless ['GET', 'NOTIFY'].include?(event_type) | |
42 | - handlers = { | |
36 | + @handlers = { | |
43 | 37 | 'stick_window' => 'window_stick', |
44 | 38 | } |
45 | - if handlers.include?(event) | |
46 | - result = handlers[event].call # no argument | |
47 | - else | |
48 | - if Surface.method_defined?(event) | |
49 | - result = method(event).call(*arglist) | |
50 | - else | |
51 | - result = @parent.handle_request(event_type, event, *arglist) | |
52 | - end | |
53 | - end | |
54 | - return result if event_type == 'GET' | |
55 | 39 | end |
56 | 40 | |
57 | 41 | def finalize |
@@ -516,9 +500,7 @@ module Surface | ||
516 | 500 | end |
517 | 501 | |
518 | 502 | def reset_surface |
519 | - for window in @window | |
520 | - window.reset_surface() | |
521 | - end | |
503 | + @window.map {|window| window.reset_surface } | |
522 | 504 | end |
523 | 505 | |
524 | 506 | def set_surface_default(side) |
@@ -892,15 +874,16 @@ module Surface | ||
892 | 874 | end |
893 | 875 | end |
894 | 876 | |
895 | - class SurfaceWindow | |
877 | + class SurfaceWindow < MetaMagic::Holon | |
896 | 878 | attr_reader :bind |
897 | 879 | |
898 | 880 | def initialize(window, side, desc, surface_alias, surface_info, tooltips, |
899 | 881 | surfaces, seriko, region, mayuna, bind, default_id, maxsize) |
882 | + super("") # FIXME | |
883 | + @handlers = {} | |
900 | 884 | @window = window |
901 | 885 | @maxsize = maxsize |
902 | 886 | @side = side |
903 | - @parent = nil | |
904 | 887 | @desc = desc |
905 | 888 | @alias = surface_alias |
906 | 889 | @tooltips = tooltips |
@@ -997,27 +980,6 @@ module Surface | ||
997 | 980 | Gdk.Visual.get_best_depth(), scrn_w, scrn_h) |
998 | 981 | end |
999 | 982 | |
1000 | - def set_responsible(parent) | |
1001 | - @parent = parent | |
1002 | - end | |
1003 | - | |
1004 | - def handle_request(event_type, event, *arglist) | |
1005 | - fail "assert" unless ['GET', 'NOTIFY'].include?(event_type) | |
1006 | - handlers = { | |
1007 | - } | |
1008 | - if handlers.include?(event) | |
1009 | - result = handlers[event].call # no argument | |
1010 | - else | |
1011 | - if SurfaceWindow.method_defined?(event) | |
1012 | - result = method(event).call(*arglist) | |
1013 | - else | |
1014 | - result = @parent.handle_request(event_type, event, *arglist) | |
1015 | - end | |
1016 | - end | |
1017 | - return result if event_type == 'GET' | |
1018 | - end | |
1019 | - | |
1020 | - @property | |
1021 | 983 | def direction |
1022 | 984 | @__direction |
1023 | 985 | end |
@@ -2,7 +2,7 @@ | ||
2 | 2 | # |
3 | 3 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
4 | 4 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
5 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or modify it |
8 | 8 | # under the terms of the GNU General Public License (version 2) as |
@@ -1,6 +1,6 @@ | ||
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # |
3 | -# Copyright (C) 2005-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
3 | +# Copyright (C) 2005-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
4 | 4 | # |
5 | 5 | # This program is free software; you can redistribute it and/or modify it |
6 | 6 | # under the terms of the GNU General Public License (version 2) as |
@@ -38,7 +38,7 @@ module Version | ||
38 | 38 | .concat('\_q') |
39 | 39 | .concat('Copyright (c) 2001, 2002 Tamito KAJIYAMA\n') |
40 | 40 | .concat('Copyright (c) 2002-2006 MATSUMURA Namihiko\n') |
41 | - .concat('Copyright (c) 2002-2016 Shyouzou Sugitani\n') | |
41 | + .concat('Copyright (c) 2002-2017 Shyouzou Sugitani\n') | |
42 | 42 | .concat('Copyright (c) 2002, 2003 ABE Hideaki\n') |
43 | 43 | .concat('Copyright (c) 2003-2005 Shun-ichi TAHARA\e') |
44 | 44 | end |
@@ -2,7 +2,7 @@ | ||
2 | 2 | # |
3 | 3 | # Copyright (C) 2001, 2002 by Tamito KAJIYAMA |
4 | 4 | # Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net> |
5 | -# Copyright (C) 2002-2016 by Shyouzou Sugitani <shy@users.osdn.me> | |
5 | +# Copyright (C) 2002-2017 by Shyouzou Sugitani <shy@users.osdn.me> | |
6 | 6 | # Copyright (C) 2003-2005 by Shun-ichi TAHARA <jado@flowernet.gr.jp> |
7 | 7 | # |
8 | 8 | # This program is free software; you can redistribute it and/or modify it |
@@ -39,7 +39,7 @@ module Ninix_Main | ||
39 | 39 | bindtextdomain("ninix-aya") |
40 | 40 | |
41 | 41 | def self.handleException(exception) |
42 | - message = ("Uncaught exception (" + exception.class.to_s + ")\n" + exception.backtrace.join("\n")) | |
42 | + message = ("Uncaught exception (#{exception.class})\n" + exception.backtrace.join("\n")) | |
43 | 43 | Logging::Logging.error(message) |
44 | 44 | response_id = 1 |
45 | 45 | dialog = Gtk::MessageDialog.new( |
@@ -260,11 +260,9 @@ module Ninix_Main | ||
260 | 260 | buffer = socket.gets |
261 | 261 | handler.handle(buffer) |
262 | 262 | rescue SocketError => e |
263 | - Logging::Logging.error( | |
264 | - 'socket.error: ' + e.message) | |
263 | + Logging::Logging.error("socket.error: #{e.message}") | |
265 | 264 | rescue SystemCallError => e |
266 | - Logging::Logging.error( | |
267 | - 'socket.error: ' + e.message + ' (' + e.errno.to_s + ')') | |
265 | + Logging::Logging.error("socket.error: #{e.message} (#{e.errno})") | |
268 | 266 | rescue # may happen when ninix is terminated |
269 | 267 | return |
270 | 268 | end |
@@ -287,13 +285,12 @@ module Ninix_Main | ||
287 | 285 | begin |
288 | 286 | server = SSTP::SSTPServer.new(port) |
289 | 287 | rescue SystemCallError => e |
290 | - Logging::Logging.warning( | |
291 | - 'Port ' + port.to_s + ': ' + e.message + ' (ignored)') | |
288 | + Logging::Logging.warning("Port #{port}: #{e.message} (ignored)") | |
292 | 289 | next |
293 | 290 | end |
294 | 291 | server.set_responsible(self) |
295 | 292 | @sstp_servers << server |
296 | - Logging::Logging.info('Serving SSTP on port ' + port.to_s) | |
293 | + Logging::Logging.info("Serving SSTP on port #{port}") | |
297 | 294 | end |
298 | 295 | end |
299 | 296 | end |
@@ -844,9 +841,9 @@ module Ninix_Main | ||
844 | 841 | end |
845 | 842 | # load ghost |
846 | 843 | @current_sakura = default_sakura |
847 | - ##for i, name in enumerate(self.get_ghost_names()): | |
848 | - ## Logging::Logging.info( | |
849 | - ## 'GHOST(' + i.to_s +'): ' + name) | |
844 | + ##for i, name in enumerate(get_ghost_names()) | |
845 | + ## Logging::Logging.info("GHOST(#{i}): #{name}") | |
846 | + ##end | |
850 | 847 | start_sakura(@current_sakura, :init => true, :abend => @abend) |
851 | 848 | end |
852 | 849 |