[packages/ruby-vnc] add ruby fixes from veewee

glen glen at pld-linux.org
Mon May 13 15:37:58 CEST 2013


commit 6930fb1b54520e4eb9922cd34f7a3838b7048052
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Mon May 13 16:37:14 2013 +0300

    add ruby fixes from veewee

 ruby-vnc.spec |   3 ++
 veewee.patch  | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 133 insertions(+)
---
diff --git a/ruby-vnc.spec b/ruby-vnc.spec
index ef8279c..b015725 100644
--- a/ruby-vnc.spec
+++ b/ruby-vnc.spec
@@ -7,6 +7,7 @@ License:	MIT
 Group:		Development/Languages
 Source0:	https://ruby-vnc.googlecode.com/files/%{name}-%{version}.tgz
 # Source0-md5:	91fd3ee9d6528bb777dcd11db46795b2
+Patch0:		veewee.patch
 URL:		http://code.google.com/p/ruby-vnc
 BuildRequires:	rpm-rubyprov
 BuildRequires:	rpmbuild(macros) >= 1.656
@@ -20,6 +21,8 @@ servers.
 
 %prep
 %setup -q -n %{gem_name}-%{version}
+%undos -f rb
+%patch0 -p1
 
 %install
 rm -rf $RPM_BUILD_ROOT
diff --git a/veewee.patch b/veewee.patch
new file mode 100644
index 0000000..3a114e9
--- /dev/null
+++ b/veewee.patch
@@ -0,0 +1,130 @@
+--- vnc-1.0.1/lib/net/vnc.rb	2011-09-16 02:52:21.000000000 +0300
++++ veewee-0.3.7/lib/net/vnc.rb	2013-01-10 12:02:14.000000000 +0200
+@@ -47,31 +47,33 @@
+ 
+ 			def refresh
+ 				packet = 0.chr * 6
+-				packet[0] = 5
+-				packet[1] = button
++				packet[0] = 5.chr
++				packet[1] = button.chr
+ 				packet[2, 2] = [x].pack 'n'
+ 				packet[4, 2] = [y].pack 'n'
+ 				@vnc.socket.write packet
+ 			end
+ 		end
+ 
+-		BASE_PORT = 5900
+-		CHALLENGE_SIZE = 16
++		BASE_PORT = 5900 if BASE_PORT.nil?
++		CHALLENGE_SIZE = 16 if CHALLENGE_SIZE.nil?
+ 		DEFAULT_OPTIONS = {
+ 			:shared => false,
+ 			:wait => 0.1
+-		}
++    } if DEFAULT_OPTIONS.nil?
+ 
++    if KEY_MAP.nil?
+ 		keys_file = File.dirname(__FILE__) + '/../../data/keys.yaml'
+ 		KEY_MAP = YAML.load_file(keys_file).inject({}) { |h, (k, v)| h.update k.to_sym => v }
+ 		def KEY_MAP.[] key
+ 			super or raise ArgumentError.new('Invalid key name - %s' % key)
+ 		end
++    end
+ 
+ 		attr_reader :server, :display, :options, :socket, :pointer
+ 
+ 		def initialize display=':0', options={}
+-			@server = 'localhost'
++			@server = '127.0.0.1'
+ 			if display =~ /^(.*)(:\d+)$/
+ 				@server, display = $1, $2
+ 			end
+@@ -147,17 +149,50 @@
+ 		# this types +text+ on the server
+ 		def type text, options={}
+ 			packet = 0.chr * 8
+-			packet[0] = 4
++			packet[0] = 4.chr
+ 			text.split(//).each do |char|
+ 				packet[7] = char[0]
+-				packet[1] = 1
++				packet[1] = 1.chr
+ 				socket.write packet
+-				packet[1] = 0
++				packet[1] = 0.chr
+ 				socket.write packet
+ 			end
+ 			wait options
+ 		end
+ 
++    SHIFTED_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+{}|:"<>?'
++    KEY_PRESS_CHARS = {
++      "\n" => :return,
++      "\t" => :tab
++    }
++
++    # This types +text+ on the server, but it holds the shift key down when necessary.
++    # It will also execute key_press for tabs and returns.
++    def type_string text, options={}
++      shift_key_down = nil
++
++      text.each_char do |char|
++        key_to_press = KEY_PRESS_CHARS[char]
++        unless key_to_press.nil?
++          key_press key_to_press
++        else
++          key_needs_shift = SHIFTED_CHARS.include? char
++
++          if shift_key_down.nil? || shift_key_down != key_needs_shift
++            if key_needs_shift
++              key_down :shift
++            else
++              key_up :shift
++            end
++          end
++
++          type char
++          shift_key_down = key_needs_shift
++        end
++      end
++      wait options
++    end
++
+ 		# this takes an array of keys, and successively holds each down then lifts them up in
+ 		# reverse order.
+ 		# FIXME: should wait. can't recurse in that case.
+@@ -191,20 +226,20 @@
+ 
+ 		def key_down which, options={}
+ 			packet = 0.chr * 8
+-			packet[0] = 4
++			packet[0] = 4.chr
+ 			key_code = get_key_code which
+ 			packet[4, 4] = [key_code].pack('N')
+-			packet[1] = 1
++			packet[1] = 1.chr
+ 			socket.write packet
+ 			wait options
+ 		end
+ 
+ 		def key_up which, options={}
+ 			packet = 0.chr * 8
+-			packet[0] = 4
++			packet[0] = 4.chr
+ 			key_code = get_key_code which
+ 			packet[4, 4] = [key_code].pack('N')
+-			packet[1] = 0
++			packet[1] = 0.chr
+ 			socket.write packet
+ 			wait options
+ 		end
+@@ -217,7 +252,7 @@
+ 
+ 		BUTTON_MAP = {
+ 			:left => 0
+-		}
++		} if BUTTON_MAP.nil?
+ 
+ 		def button_press button=:left, options={}
+ 			begin
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/ruby-vnc.git/commitdiff/6930fb1b54520e4eb9922cd34f7a3838b7048052



More information about the pld-cvs-commit mailing list