• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Ruby GTK3移行後のメインリポジトリ


Commit MetaInfo

修訂f3a285c88cb27e5b805166739d86d35ac8f7242e (tree)
時間2015-05-23 21:35:15
作者Shyouzou Sugitani <shy@user...>
CommiterShyouzou Sugitani

Log Message

assorted fixes(24)

Change Summary

差異

--- a/lib/ninix/balloon.rb
+++ b/lib/ninix/balloon.rb
@@ -938,9 +938,9 @@ module Balloon
938938 while 1
939939 i += 1
940940 s = message[0, i] + '... (' + sender + ')'
941- @sstp_layout.set_text(s, -1)
941+ @sstp_layout.set_text(s)
942942 message_width, message_height = \
943- @sstp_layout.get_pixel_size()
943+ @sstp_layout.pixel_size
944944 if message_width > w
945945 break
946946 end
@@ -1105,8 +1105,8 @@ module Balloon
11051105 if l == i
11061106 mw = @sstp_surface.width
11071107 mh = @sstp_surface.height
1108- @layout.set_text(@text_buffer[i][0, c], -1)
1109- text_w, text_h = @layout.get_pixel_size()
1108+ @layout.set_text(@text_buffer[i][0, c])
1109+ text_w, text_h = @layout.pixel_size
11101110 mx = x + text_w
11111111 my = y + (@font_height + @line_space) / 2
11121112 my = my - mh / 2
@@ -1144,36 +1144,36 @@ module Balloon
11441144 if sl == el
11451145 markup = set_markup(n, @text_buffer[n][0, sn])
11461146 @layout.set_markup(markup, -1)
1147- text_w, text_h = @layout.get_pixel_size()
1147+ text_w, text_h = @layout.pixel_size
11481148 x += text_w
11491149 markup = set_markup(n, @text_buffer[n][sn, en])
11501150 @layout.set_markup(markup, -1)
1151- text_w, text_h = @layout.get_pixel_size()
1151+ text_w, text_h = @layout.pixel_size
11521152 w = text_w
11531153 start = sn
11541154 end_ = en
11551155 elsif n == sl
11561156 markup = set_markup(n, @text_buffer[n][0, sn])
11571157 @layout.set_markup(markup, -1)
1158- text_w, text_h = @layout.get_pixel_size()
1158+ text_w, text_h = @layout.pixel_size
11591159 x += text_w
11601160 markup = set_markup(n, @text_buffer[n][sn, @text_buffer.length])
11611161 @layout.set_markup(markup, -1)
1162- text_w, text_h = @layout.get_pixel_size()
1162+ text_w, text_h = @layout.pixel_size
11631163 w = text_w
11641164 start = sn
11651165 end_ = @text_buffer[n].length
11661166 elsif n == el
11671167 markup = set_markup(n, @text_buffer[n][0, en])
11681168 @layout.set_markup(markup, -1)
1169- text_w, text_h = @layout.get_pixel_size()
1169+ text_w, text_h = @layout.pixel_size
11701170 w = text_w
11711171 start = 0
11721172 end_ = en
11731173 else
11741174 markup = set_markup(n, @text_buffer[n])
11751175 @layout.set_markup(markup, -1)
1176- text_w, text_h = @layout.get_pixel_size()
1176+ text_w, text_h = @layout.pixel_size
11771177 w = text_w
11781178 start = 0
11791179 end_ = @text_buffer[n].length
@@ -1208,7 +1208,7 @@ module Balloon
12081208 if n == sl
12091209 markup = set_markup(n, @text_buffer[n][0, sn])
12101210 @layout.set_markup(markup, -1)
1211- text_w, text_h = @layout.get_pixel_size()
1211+ text_w, text_h = @layout.pixel_size
12121212 x += text_w
12131213 end
12141214 if n == sl and n == el
@@ -1219,7 +1219,7 @@ module Balloon
12191219 markup = set_markup(n, @text_buffer[n])
12201220 end
12211221 @layout.set_markup(markup, -1)
1222- text_w, text_h = @layout.get_pixel_size()
1222+ text_w, text_h = @layout.pixel_size
12231223 w = text_w
12241224 if x <= px and px < x + w and y <= py and py < y + h
12251225 new_selection = i
@@ -1469,8 +1469,8 @@ module Balloon
14691469 i = 1
14701470 while 1
14711471 space = '\u3000' * i ## FIXME
1472- @layout.set_text(space, -1)
1473- text_w, text_h = @layout.get_pixel_size()
1472+ @layout.set_text(space)
1473+ text_w, text_h = @layout.pixel_size
14741474 if text_w > w
14751475 break
14761476 else
@@ -1559,8 +1559,8 @@ module Balloon
15591559 if l == line
15601560 mw = @sstp_surface.width
15611561 mh = @sstp_surface.height
1562- @layout.set_text(@text_buffer[l][0, c], -1)
1563- text_w, text_h = @layout.get_pixel_size()
1562+ @layout.set_text(@text_buffer[l][0, c])
1563+ text_w, text_h = @layout.pixel_size
15641564 mx = x + text_w
15651565 my = y + (@font_height + @line_space) / 2
15661566 my = my - mh / 2
--- a/lib/ninix/sakura.rb
+++ b/lib/ninix/sakura.rb
@@ -1804,7 +1804,7 @@ module Sakura
18041804 event, script, sender, @sstp_handle, \
18051805 host, show_sstp_marker, use_translator, \
18061806 @sstp_entry_db, @sstp_request_handler = \
1807- script_queue.shift
1807+ @script_queue.shift
18081808 if @cantalk
18091809 if show_sstp_marker
18101810 @balloon.show_sstp_message(sender, host)
--- a/lib/ninix/sstp.rb
+++ b/lib/ninix/sstp.rb
@@ -21,6 +21,7 @@ require "ninix/sstplib"
2121 module SSTP
2222
2323 class SSTPServer < SSTPLib::AsynchronousSSTPServer
24+ attr_reader :socket
2425
2526 def initialize(address)
2627 @parent = nil
@@ -41,9 +42,9 @@ module SSTP
4142 @parent = parent
4243 end
4344
44- def handle_request(event_type, event, *arglist, **argdict)
45+ def handle_request(event_type, event, *arglist)
4546 if @parent != nil
46- @parent.handle_request(event_type, event, *arglist, **argdict)
47+ @parent.handle_request(event_type, event, *arglist)
4748 end
4849 end
4950
@@ -93,7 +94,7 @@ module SSTP
9394 end
9495
9596 def close
96- socket.close()
97+ # NOP
9798 end
9899 end
99100
@@ -183,6 +184,7 @@ module SSTP
183184 end
184185
185186 def handle_notify(version)
187+ script_odict = {}
186188 if not check_decoder()
187189 return
188190 end
@@ -239,7 +241,7 @@ module SSTP
239241 if not local_request()
240242 parser = Script::Parser.new
241243 nodes = []
242- while 1
244+ while true
243245 begin
244246 nodes.concat(parser.parse(script))
245247 rescue #except ninix.script.ParserError as e:
--- a/lib/ninix/sstplib.rb
+++ b/lib/ninix/sstplib.rb
@@ -109,11 +109,11 @@ module SSTPLib
109109 if not match
110110 @equestline = '-'
111111 send_error(400, :message => 'Bad Request ' + requestline.to_s)
112- return 0
112+ return false
113113 end
114114 @command, @version = match[1, 2]
115115 @headers = parse_headers()
116- return 1
116+ return true
117117 end
118118
119119 def handle(line)
--- a/lib/ninix_main.rb
+++ b/lib/ninix_main.rb
@@ -197,16 +197,19 @@ module Ninix_Main
197197 @parent = parent
198198 end
199199
200- def handle_request(event_type, event, *arglist, **argdict)
200+ def handle_request(event_type, event, *arglist)
201201 #assert ['GET', 'NOTIFY'].include?(event_type)
202202 handlers = {
203203 }
204- handler = handlers.get(event, getattr(self, event, nil))
205- if handler == nil
206- result = self.request_parent(
207- event_type, event, *arglist, **argdict)
204+ if not handlers.include?(event)
205+ if SSTPControler.method_defined?(event)
206+ result = method(event).call(*arglist)
207+ else
208+ result = @parent.handle_request(
209+ event_type, event, *arglist)
210+ end
208211 else
209- result = handler(*arglist, **argdict)
212+ result = method(handlers[event]).call(*arglist)
210213 end
211214 if event_type == 'GET'
212215 return result
@@ -251,19 +254,19 @@ module Ninix_Main
251254 end
252255 event, script_odict, sender, handle, address, \
253256 show_sstp_marker, use_translator, \
254- entry_db, request_handler = @__sstp_queue.pop(0)
257+ entry_db, request_handler = @__sstp_queue.shift
255258 working = (event != nil)
256259 break_flag = false
257260 for if_ghost in script_odict.keys()
258- if if_ghost and request_parent('GET', 'if_ghost', if_ghost, :working => working)
259- request_parent('NOTIFY', 'select_current_sakura', :if_ghost => if_ghost)
261+ if not if_ghost.empty? and @parent.handle_request('GET', 'if_ghost', if_ghost, :working => working)
262+ @parent.handle_request('NOTIFY', 'select_current_sakura', :if_ghost => if_ghost)
260263 default_script = script_odict[if_ghost]
261264 break_flag = true
262265 break
263266 end
264267 end
265268 if not break_flag
266- if request_parent('GET', 'get_preference', 'allowembryo') == 0
269+ if @parent.handle_request('GET', 'get_preference', 'allowembryo') == 0
267270 if event == nil
268271 if request_handler
269272 request_handler.send_response(420) # Refuse
@@ -280,7 +283,7 @@ module Ninix_Main
280283 end
281284 end
282285 if event != nil
283- script = request_parent('GET', 'get_event_response', event)
286+ script = @parent.handle_request('GET', 'get_event_response', event)
284287 else
285288 script = nil
286289 end
@@ -294,7 +297,7 @@ module Ninix_Main
294297 return
295298 end
296299 set_sstp_flag(sender)
297- request_parent(
300+ @parent.handle_request(
298301 'NOTIFY', 'enqueue_script',
299302 event, script, sender, handle, address,
300303 show_sstp_marker, use_translator, :db => entry_db,
@@ -303,15 +306,21 @@ module Ninix_Main
303306 end
304307
305308 def receive_sstp_request
306- begin
307- for sstp_server in self.sstp_servers
308- sstp_server.handle_request()
309+ for sstp_server in @sstp_servers
310+ begin
311+ socket = sstp_server.accept_nonblock
312+ rescue
313+ next
314+ #rescue # except socket.error as e:
315+ #code, message = e.args
316+ #logging.error('socket.error: {0} ({1:d})'.format(message, code))
317+ #rescue # except ValueError: # may happen when ninix is terminated
318+ #return
309319 end
310- rescue # except socket.error as e:
311- #code, message = e.args
312- #logging.error('socket.error: {0} ({1:d})'.format(message, code))
313- rescue # except ValueError: # may happen when ninix is terminated
314- return
320+ handler = SSTP::SSTPRequestHandler.new(sstp_server, socket)
321+ buffer = socket.gets
322+ handler.handle(buffer)
323+ socket.close
315324 end
316325 end
317326
@@ -331,14 +340,14 @@ module Ninix_Main
331340 def start_servers
332341 for port in @sstp_port
333342 begin
334- server = SSTP.SSTPServer.new(port)
343+ server = SSTP::SSTPServer.new(port)
335344 rescue # except socket.error as e:
336345 #code, message = e.args
337346 #logging.warning(
338347 # 'Port {0:d}: {1} (ignored)'.format(port, message))
339348 next
340349 end
341- server.set_responsible(self.handle_request)
350+ server.set_responsible(self)
342351 @sstp_servers << server
343352 #logging.info('Serving SSTP on port {0:d}'.format(port))
344353 end
@@ -544,7 +553,7 @@ module Ninix_Main
544553 if plugin_module == nil
545554 return
546555 end
547- port = self.request_parent('GET', 'get_sstp_port')
556+ port = @parent.handle_request('GET', 'get_sstp_port')
548557 queue = multiprocessing.JoinableQueue()
549558 if not @data.include?(plugin_dir)
550559 @data[plugin_dir] = load_data(plugin_dir)
@@ -1269,7 +1278,7 @@ module Ninix_Main
12691278 instance_list = []
12701279 for value in @ghosts.values()
12711280 if value.instance != nil
1272- instance_list << value
1281+ instance_list << value.instance
12731282 end
12741283 end
12751284 for sakura in instance_list