Ruby4Skype 0.3.1 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/README +95 -7
  2. data/Rakefile +3 -3
  3. data/lib/{skypeapi.rb → skype.rb} +102 -89
  4. data/lib/{skypeapi → skype}/application.rb +5 -5
  5. data/lib/{skypeapi → skype}/call.rb +9 -9
  6. data/lib/{skypeapi → skype}/chat.rb +176 -176
  7. data/lib/{skypeapi → skype}/chatmember.rb +31 -31
  8. data/lib/{skypeapi → skype}/chatmessage.rb +9 -9
  9. data/lib/{skypeapi → skype}/error.rb +1 -1
  10. data/lib/{skypeapi → skype}/event.rb +2 -2
  11. data/lib/{skypeapi → skype}/filetransfer.rb +2 -2
  12. data/lib/{skypeapi → skype}/group.rb +8 -8
  13. data/lib/{skypeapi → skype}/menuitem.rb +4 -4
  14. data/lib/{skypeapi → skype}/message.rb +1 -1
  15. data/lib/{skypeapi → skype}/object.rb +16 -15
  16. data/lib/{skypeapi → skype}/os/etc.rb +35 -9
  17. data/lib/skype/os/linux.rb +115 -0
  18. data/lib/skype/os/linux.rb~ +117 -0
  19. data/lib/skype/os/mac.rb +217 -0
  20. data/lib/{skypeapi → skype}/os/notifier.rb +1 -1
  21. data/lib/skype/os/timer.rb +108 -0
  22. data/lib/{skypeapi → skype}/os/window_event_queue.rb +16 -16
  23. data/lib/{skypeapi → skype}/os/window_messagehandler.rb +12 -12
  24. data/lib/{skypeapi → skype}/os/windows.rb +10 -10
  25. data/lib/{skypeapi → skype}/profile.rb +3 -3
  26. data/lib/{skypeapi → skype}/sharefunctions.rb +6 -6
  27. data/lib/{skypeapi → skype}/sms.rb +3 -3
  28. data/lib/{skypeapi → skype}/user.rb +1 -1
  29. data/lib/{skypeapi → skype}/version.rb +2 -2
  30. data/lib/{skypeapi → skype}/voicemail.rb +4 -4
  31. data/spec/{skypeapi → skype}/application_spec.rb +13 -15
  32. data/spec/{skypeapi → skype}/chat_spec.rb +75 -77
  33. data/spec/{skypeapi → skype}/chatmember_spec.rb +13 -13
  34. data/spec/{skypeapi → skype}/chatmessage_spec.rb +12 -13
  35. data/spec/skype/event_spec.rb +33 -0
  36. data/spec/{skypeapi → skype}/filetransfer_spec.rb +10 -11
  37. data/spec/skype/group_spec.rb +15 -0
  38. data/spec/{skypeapi → skype}/menuitem_spec.rb +11 -9
  39. data/spec/skype/os/linux_spec.rb +59 -0
  40. data/spec/skype/os/linux_spec.rb~ +58 -0
  41. data/spec/{skypeapi → skype}/os/windows_spec.rb +8 -8
  42. data/spec/skype/profile_spec.rb +24 -0
  43. data/spec/skype/user_spec.rb +25 -0
  44. data/spec/skype_spec.rb +530 -0
  45. metadata +44 -40
  46. data/lib/skypeapi/os/linux.rb +0 -110
  47. data/lib/skypeapi/os/mac.rb +0 -98
  48. data/spec/skypeapi/event_spec.rb +0 -31
  49. data/spec/skypeapi/group_spec.rb +0 -16
  50. data/spec/skypeapi/profile_spec.rb +0 -22
  51. data/spec/skypeapi/user_spec.rb +0 -25
  52. data/spec/skypeapi_spec.rb +0 -528
data/README CHANGED
@@ -1,14 +1,102 @@
1
- = SkypeAPI
1
+ = Skype
2
2
 
3
+ ==install
4
+
5
+ gem install Ruby4Skype
6
+
7
+ require swin.so at Windows.
8
+
9
+ require rubycocoa at Mac.
10
+ Not work at OSX 10.6 Snow Leopard.Because Skype.framework not contains 64bit binary.
11
+ You need copy /Application/Skype/Contnet/Frameworks/Skype.framework to /Library/Frameworks/Skype.framework
12
+ Some methods not work.
13
+
14
+ ##require dbus or rbus at Linux.
15
+
16
+ Ruby4Skype support Windows and Mac now.
3
17
  ==sample
4
- require 'skypeapi'
5
-
6
- SkypeAPI.init
7
- SkypeAPI.start_messageloop
8
- SkypeAPI::ChatMessage.set_notify do |chatmessage, property, value|
18
+ require 'rubygems'
19
+ require 'Skype'
20
+
21
+ Skype.init 'application_name'
22
+ Skype.start_messageloop
23
+ Skype::ChatMessage.set_notify do |chatmessage, property, value|
9
24
  if property == :status and value == 'RECEIVED'
10
25
  chatmessage.get_chat.send_message chatmessage.get_body
11
26
  end
12
27
  end
13
- SkypeAPI.attach_wait
28
+ Skype.attach_wait
14
29
  sleep
30
+
31
+ ==method and object
32
+ Ruby4Skype is same Skype API methods and objects.
33
+
34
+ https://developer.skype.com/Docs/ApiDoc/FrontPage
35
+
36
+ ===method
37
+ ex.
38
+
39
+ CHAT CREATE [<target>, <target>*] -> Skype::Chat.create *targets
40
+
41
+ https://developer.skype.com/Docs/ApiDoc/CHAT_CREATE
42
+
43
+ GET object property
44
+
45
+ https://developer.skype.com/Docs/ApiDoc/src#PROPERTIES_OBJECT
46
+
47
+ Skype::User.get_fullname
48
+
49
+ ===Skype Objects
50
+ https://developer.skype.com/Docs/ApiDoc/Objects
51
+
52
+ USER -> Skype::User
53
+
54
+ PROFILE -> Skype::Profile
55
+
56
+ CALL -> Skype::Call
57
+
58
+ MESSAGE -> Skype::Message (obsolete)
59
+
60
+ CHAT -> Skype::Chat
61
+
62
+ CHATMEMBER -> Skype::ChatMember
63
+
64
+ CHATMESSAGE -> Skype::ChatMessage
65
+
66
+ VOICEMAIL -> Skype::VoiceMail (none test)
67
+
68
+ SMS -> Skype::SMS (none test)
69
+
70
+ APPLICATION -> Skype::Application (none test)
71
+
72
+ GROUP -> Skype::Group (broken)
73
+
74
+ FILETRANSFER -> Skype::FileTransfer
75
+
76
+ ==notification
77
+ When Skype change property, callback is called.
78
+ Property is symbol of method name get_xxx.
79
+ ===general property
80
+ Skype.set_notify{|property, value| }
81
+ ===objects property
82
+ Skype::ChatMessage.set_notify{|instance, property, value|}
83
+ ===specify property
84
+ Skype::ChatMessage.set_notify(:status){|instance, value|}
85
+ ===specify property and value
86
+ Skype::ChatMessage.set_notify(:status, 'RECEIVED'){|instance|}
87
+
88
+ ==messageloop
89
+ ===messageloop run with new thread.
90
+
91
+ Skype.start_messageloop
92
+
93
+ ===or messageloop run with current thread.
94
+
95
+ Skype.messageloop
96
+
97
+ ===or message polling
98
+
99
+ loop do
100
+ Skype.messgepolling
101
+ sleep 0.123
102
+ end
data/Rakefile CHANGED
@@ -16,7 +16,7 @@ require 'spec/rake/spectask'
16
16
 
17
17
  spec = Gem::Specification.new do |s|
18
18
  s.name = 'Ruby4Skype'
19
- s.version = '0.3.1'
19
+ s.version = '0.4.1'
20
20
  s.has_rdoc = true
21
21
  s.extra_rdoc_files = ['README', 'LICENSE']
22
22
  s.summary = 'SkypeAPI wrapper'
@@ -41,8 +41,8 @@ Rake::RDocTask.new do |rdoc|
41
41
  #files =['README', 'LICENSE', 'lib/**/*.rb']
42
42
  #files =['README', 'LICENSE', 'lib/skypeapi/os/windows.rb', 'lib/skypeapi/chat.rb', 'lib/skypeapi/chatmessage.rb','lib/skypeapi/chatmember.rb','lib/skypeapi/user.rb','lib/skypeapi/version.rb', 'lib/skypeapi/call.rb','lib/skypeapi/application.rb']
43
43
  files = ['README','LICENSE']
44
- files << ['lib/skypeapi.rb']
45
- files << ['lib/skypeapi/*.rb']
44
+ files << ['lib/skype.rb']
45
+ files << ['lib/skype/*.rb']
46
46
  rdoc.rdoc_files.add(files)
47
47
  rdoc.main = "README" # page to start on
48
48
  rdoc.title = "SkypeAPI Docs"
@@ -1,26 +1,26 @@
1
1
  require "forwardable"
2
- require 'skypeapi/os/notifier'
3
- require "skypeapi/object.rb"
4
- require "skypeapi/version.rb"
5
- require "skypeapi/user.rb"
6
- require "skypeapi/profile.rb"
7
- require "skypeapi/call.rb"
8
- require "skypeapi/message.rb"
9
- require "skypeapi/chat.rb"
10
- require "skypeapi/chatmessage.rb"
11
- require "skypeapi/chatmember.rb"
12
- require "skypeapi/voicemail.rb"
13
- require "skypeapi/sms.rb"
14
- require "skypeapi/application.rb"
15
- require "skypeapi/group.rb"
16
- require "skypeapi/filetransfer.rb"
17
- require "skypeapi/event.rb"
18
- require "skypeapi/menuitem.rb"
19
- require "skypeapi/os/etc.rb"
20
- require 'skypeapi/error'
21
-
22
-
23
- module SkypeAPI
2
+ require 'skype/os/notifier'
3
+ require "skype/object.rb"
4
+ require "skype/version.rb"
5
+ require "skype/user.rb"
6
+ require "skype/profile.rb"
7
+ require "skype/call.rb"
8
+ require "skype/message.rb"
9
+ require "skype/chat.rb"
10
+ require "skype/chatmessage.rb"
11
+ require "skype/chatmember.rb"
12
+ require "skype/voicemail.rb"
13
+ require "skype/sms.rb"
14
+ require "skype/application.rb"
15
+ require "skype/group.rb"
16
+ require "skype/filetransfer.rb"
17
+ require "skype/event.rb"
18
+ require "skype/menuitem.rb"
19
+ require "skype/os/etc.rb"
20
+ require 'skype/error'
21
+
22
+
23
+ module Skype
24
24
  extend AbstractObject::Notify
25
25
  extend AbstractObject::Get
26
26
  extend AbstractObject::Invokers
@@ -34,59 +34,63 @@ module SkypeAPI
34
34
 
35
35
  class << self
36
36
 
37
- def init os=RUBY_PLATFORM.downcase
38
- unless @inited
39
- case os
40
- when /(mswin(?!ce))|(mingw)|(cygwin)|(bccwin)/
41
- require 'skypeapi/os/windows.rb'
42
- @os = SkypeAPI::OS::Windows.new
43
- when /(mac)|(darwin)/
44
- require 'skypeapi/os/mac.rb'
45
- @os = SkypeAPI::OS::Mac.new
46
- when /(linux)/
47
- require 'skypeapi/os/linux.rb'
48
- @os = SkypeAPI::OS::Linux.new
49
- else
50
- raise SkypeAPI::NotImplementError.new("#{os} is unknown or not support OS")
51
- end
52
-
53
- self.class.extend Forwardable
54
- self.class.def_delegators(:@os,
55
- :invoke,
56
- :add_event,
57
- :del_event,
58
- :get_event,
59
- :exist_event?,
60
- :attach,
61
- :attach_wait,
62
- :polling,
63
- :start_messageloop,
64
- :messgeloop,
65
- :close
66
- )
67
- class << self
68
- alias addEvent add_event
69
- alias setEvent add_event
70
- alias delEvent del_event
71
- alias getEvent get_event
72
- alias existEvent? exist_event?
73
- alias attachWait attach_wait
74
- end
75
-
76
- @notify = Hash.new
77
- #@os.add_notify nil, method(:notified)
78
-
79
- @notifier = SkypeAPI::OS::Notifier.new
80
- @os.set_notify_selector @notifier.method(:fire)
81
- @notifier.add nil, method(:notified)
82
- objectsInit
83
-
84
- #@inited = true
37
+ def init app_name, os=RUBY_PLATFORM.downcase
38
+ case os
39
+ when /(mswin(?!ce))|(mingw)|(cygwin)|(bccwin)/
40
+ require 'skype/os/windows.rb'
41
+ init_os Skype::OS::Windows, app_name
42
+ when /(mac)|(darwin)/
43
+ require 'skype/os/mac.rb'
44
+ init_os Skype::OS::Mac, app_name
45
+ when /(linux)/
46
+ require 'skype/os/linux.rb'
47
+ init_os Skype::OS::Linux, app_name
85
48
  else
86
- #raise SkypeAPI::Error('init at onece')
49
+ raise Skype::NotImplementError.new("#{os} is unknown or not support OS")
50
+ end
51
+ @notify = Hash.new
52
+ init_notifier
53
+ end
54
+
55
+ def init_os os_class, app_name
56
+ @os = os_class.new app_name
57
+ forward_os_methods
58
+ end
59
+
60
+ def forward_os_methods
61
+ self.class.extend Forwardable
62
+ self.class.def_delegators(:@os,
63
+ :invoke,
64
+ :add_event,
65
+ :del_event,
66
+ :get_event,
67
+ :exist_event?,
68
+ :attach,
69
+ :attach_wait,
70
+ :polling,
71
+ :start_messageloop,
72
+ :messageloop,
73
+ :messagepolling,
74
+ :close
75
+ )
76
+ class << self
77
+ alias addEvent add_event
78
+ alias setEvent add_event
79
+ alias delEvent del_event
80
+ alias getEvent get_event
81
+ alias existEvent? exist_event?
82
+ alias attachWait attach_wait
87
83
  end
88
84
  end
89
85
 
86
+ def init_notifier
87
+ @notifier = Skype::OS::Notifier.new
88
+ @os.set_notify_selector @notifier.method(:fire)
89
+ @notifier.add nil, method(:notified)
90
+ objectsInit
91
+ end
92
+ private :init_os, :forward_os_methods, :init_notifier
93
+
90
94
  def new
91
95
  init
92
96
  self
@@ -124,41 +128,41 @@ module SkypeAPI
124
128
  end
125
129
 
126
130
  def objectsInit
127
- [SkypeAPI::User,SkypeAPI::Profile,SkypeAPI::Call,SkypeAPI::Message,SkypeAPI::Chat,SkypeAPI::ChatMessage,SkypeAPI::ChatMember,SkypeAPI::VoiceMail,SkypeAPI::SMS,SkypeAPI::Application,SkypeAPI::Group,SkypeAPI::FileTransfer,SkypeAPI::Event,SkypeAPI::MenuItem].each do |klass|
131
+ [Skype::User,Skype::Profile,Skype::Call,Skype::Message,Skype::Chat,Skype::ChatMessage,Skype::ChatMember,Skype::VoiceMail,Skype::SMS,Skype::Application,Skype::Group,Skype::FileTransfer,Skype::Event,Skype::MenuItem].each do |klass|
128
132
  #@os.add_notify /^#{klass::OBJECT_NAME} (.+)$/m, klass.method(:notified)
129
133
  @notifier.add /^#{klass::OBJECT_NAME} (.+)$/m, klass.method(:notified)
130
134
  end
131
135
  end
132
136
 
133
- def user(id) SkypeAPI::User.new(id) ; end
137
+ def user(id) Skype::User.new(id) ; end
134
138
 
135
- def call(id) SkypeAPI::Call.new(id) ; end
139
+ def call(id) Skype::Call.new(id) ; end
136
140
 
137
- #def Profile() SkypeAPI::Profile.new nil ; end
141
+ #def Profile() Skype::Profile.new nil ; end
138
142
 
139
- #def profile() SkypeAPI::Profile.new nil ; end
143
+ #def profile() Skype::Profile.new nil ; end
140
144
 
141
- def chat(id) SkypeAPI::Chat.new(id) ; end
145
+ def chat(id) Skype::Chat.new(id) ; end
142
146
 
143
- def chatMessage(id) SkypeAPI::ChatMessage.new(id) ; end
147
+ def chatMessage(id) Skype::ChatMessage.new(id) ; end
144
148
 
145
- def chatMember(id) SkypeAPI::ChatMember.new(id) ; end
149
+ def chatMember(id) Skype::ChatMember.new(id) ; end
146
150
 
147
- #def message(id) SkypeAPI::Message.new(id) ; end
151
+ #def message(id) Skype::Message.new(id) ; end
148
152
 
149
- def voiceMail(id) SkypeAPI::VoiceMail.new(id) ; end
153
+ def voiceMail(id) Skype::VoiceMail.new(id) ; end
150
154
 
151
- def sms(id) SkypeAPI::SMS.new(id) ; end
155
+ def sms(id) Skype::SMS.new(id) ; end
152
156
 
153
- def app(id) SkypeAPI::Application.new(id) ; end
157
+ def app(id) Skype::Application.new(id) ; end
154
158
 
155
- def group(id) SkypeAPI::Group.new(id) ; end
159
+ def group(id) Skype::Group.new(id) ; end
156
160
 
157
- def fileTransfer(id) SkypeAPI::FileTransfer.new(id) ; end
161
+ def fileTransfer(id) Skype::FileTransfer.new(id) ; end
158
162
 
159
- def event(id) SkypeAPI::Event.new(id) ; end
163
+ def event(id) Skype::Event.new(id) ; end
160
164
 
161
- def menuItem(id) SkypeAPI::MenuItem.new(id) ; end
165
+ def menuItem(id) Skype::MenuItem.new(id) ; end
162
166
 
163
167
  end
164
168
 
@@ -281,7 +285,16 @@ module SkypeAPI
281
285
  alias resetIdleTimer reset_idle_timer
282
286
 
283
287
  def get_auto_away() parse :auto_away, invoke_get("AUTOAWAY") end
284
- def_parser(:auto_away,"AUTOAWAY"){|str| str._flag}
288
+ def_parser(:auto_away,"AUTOAWAY"){|str|
289
+ case str
290
+ when /ON/
291
+ true
292
+ when /OFF/
293
+ false
294
+ else
295
+ str
296
+ end
297
+ }
285
298
  alias getAutoAway get_auto_away
286
299
 
287
300
  def set_auto_away(flag) parse :auto_away, invoke_set('AUTOAWAY', flag._swi) end
@@ -431,7 +444,7 @@ module SkypeAPI
431
444
  alias btn_released BTNReleased
432
445
 
433
446
  def get_contacts_focused() parse :contacts_focused, invoke_get("CONTACTS_FOCUSED") end
434
- def_parser(:contacts_focused){|str| SkypeAPI::User.new str}
447
+ def_parser(:contacts_focused){|str| Skype::User.new str}
435
448
  alias getContactsFocused get_contacts_focused
436
449
 
437
450
  def get_ui_language() invoke_get("UI_LANGUAGE") end
@@ -1,10 +1,10 @@
1
- module SkypeAPI
1
+ module Skype
2
2
  class Application < AbstractObject
3
3
  class Stream
4
4
  def initialize app, streamString
5
5
  @app = app
6
6
  @id = streamString
7
- @user = SkypeAPI.user(@id.split(':')[0])
7
+ @user = Skype.user(@id.split(':')[0])
8
8
  end
9
9
 
10
10
  def to_s
@@ -35,11 +35,11 @@ module SkypeAPI
35
35
  OBJECT_NAME = "APPLICATION"
36
36
 
37
37
  def get_connectable() parse :connectable, invoke_get("CONNECTABLE") end
38
- def_parser(:connectable){|str| str.split(' ').collect{|i| SkypeAPI.user(i)}}
38
+ def_parser(:connectable){|str| str.split(' ').collect{|i| Skype.user(i)}}
39
39
  alias getConnectable get_connectable
40
40
 
41
41
  def get_connecting() parse :connecting, invoke_get("CONNECTING") end
42
- def_parser(:connecting){|str| str.split(' ').collect{|i| SkypeAPI.user(i)}}
42
+ def_parser(:connecting){|str| str.split(' ').collect{|i| Skype.user(i)}}
43
43
  alias getConnecting get_connecting
44
44
 
45
45
  def get_streams() parse :streams, invoke_get("STREAMS") end
@@ -66,7 +66,7 @@ module SkypeAPI
66
66
 
67
67
  def_parser(:datagram){|str|
68
68
  user,data = str.split(' ',2)
69
- [SkypeAPI.user(user), data]
69
+ [Skype.user(user), data]
70
70
  }
71
71
 
72
72
  def self.create appName
@@ -1,10 +1,10 @@
1
- module SkypeAPI
1
+ module Skype
2
2
  class Call < AbstractObject
3
3
  OBJECT_NAME = "CALL"
4
4
 
5
5
  def self.create *targets
6
- res = (SkypeAPI.invoke_one "CALL " + targets.join(", "),"CALL").split(" ")
7
- #return SkypeAPI::Call.new(res[0]),res[2]
6
+ res = (Skype.invoke_one "CALL " + targets.join(", "),"CALL").split(" ")
7
+ #return Skype::Call.new(res[0]),res[2]
8
8
  new res[0]
9
9
  end
10
10
 
@@ -13,7 +13,7 @@ module SkypeAPI
13
13
  alias getTimestamp get_timestamp
14
14
 
15
15
  def get_partner() parse :partner, invoke_get("PARTNER_HANDLE") end
16
- def_parser(:partner,'PARTNER_HANDLE'){|str| SkypeAPI::User.new str}
16
+ def_parser(:partner,'PARTNER_HANDLE'){|str| Skype::User.new str}
17
17
  alias getPartner get_partner
18
18
 
19
19
  def get_partner_dispname() invoke_get("PARTNER_DISPNAME") end
@@ -74,7 +74,7 @@ module SkypeAPI
74
74
  #?CALL 59 CONF_PARTICIPANT 1 echo123 INCOMING_P2P INPROGRESS Echo Test Service .
75
75
  def_parser(:conf_participant, 'CONF_PARTICIPANT'){|str|
76
76
  res = str.split(' ')
77
- res[1] = SkypeAPI::User.new res[1] if res[1]
77
+ res[1] = Skype::User.new res[1] if res[1]
78
78
  res
79
79
  }
80
80
 
@@ -82,7 +82,7 @@ module SkypeAPI
82
82
  def get_conf_participant num
83
83
  str = invoke_get "CONF_PARTICIPANT #{num}"
84
84
  res = str.split(' ')
85
- res[0] = SkypeAPI::User.new res[0]
85
+ res[0] = Skype::User.new res[0]
86
86
  res
87
87
  end
88
88
  alias getConfParticipant get_conf_participant
@@ -124,7 +124,7 @@ module SkypeAPI
124
124
  alias getVAAInputStatus get_vaa_input_status
125
125
 
126
126
  def get_forwarded_by() parse :forwarded_by, invoke_get("FORWARDED_BY") end
127
- def_parser(:forwarded_by){|str| (str.empty? or str == '?') ? nil : SkypeAPI::User.new(str)}
127
+ def_parser(:forwarded_by){|str| (str.empty? or str == '?') ? nil : Skype::User.new(str)}
128
128
  alias getForwardedBy get_forwarded_by
129
129
 
130
130
  def get_transfer_active?() parse :transfer_active, invoke_get("TRANSFER_ACTIVE") end
@@ -136,11 +136,11 @@ module SkypeAPI
136
136
  alias getTransferStatus get_transfer_status
137
137
 
138
138
  def get_transferred_by() parse :transferred_by, invoke_get("TRANSFERRED_BY") end
139
- def_parser(:transferred_by){|str| str.empty? ? nil : SkypeAPI::User.new(str)}
139
+ def_parser(:transferred_by){|str| str.empty? ? nil : Skype::User.new(str)}
140
140
  alias getTransferredBy get_transferred_by
141
141
 
142
142
  def get_transferred_to() parse :transferred_to, invoke_get("TRANSFERRED_TO") end
143
- def_parser(:transferred_to){|str| str.empty? ? nil : SkypeAPI::User.new(str)}
143
+ def_parser(:transferred_to){|str| str.empty? ? nil : Skype::User.new(str)}
144
144
  alias getTransferredTo get_transferred_to
145
145
 
146
146
  def get_can_transfer user