Ruby4Skype 0.2.3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/LICENSE +3 -0
  2. data/README +14 -0
  3. data/Rakefile +67 -0
  4. data/lib/skypeapi.rb +570 -509
  5. data/lib/skypeapi/application.rb +79 -77
  6. data/lib/skypeapi/call.rb +243 -230
  7. data/lib/skypeapi/chat.rb +162 -172
  8. data/lib/skypeapi/chatmember.rb +26 -28
  9. data/lib/skypeapi/chatmessage.rb +81 -65
  10. data/lib/skypeapi/error.rb +8 -0
  11. data/lib/skypeapi/event.rb +25 -26
  12. data/lib/skypeapi/filetransfer.rb +47 -28
  13. data/lib/skypeapi/group.rb +72 -73
  14. data/lib/skypeapi/menuitem.rb +44 -44
  15. data/lib/skypeapi/message.rb +39 -41
  16. data/lib/skypeapi/object.rb +246 -82
  17. data/lib/skypeapi/os/etc.rb +48 -98
  18. data/lib/skypeapi/os/mac.rb +92 -4
  19. data/lib/skypeapi/os/notifier.rb +31 -0
  20. data/lib/skypeapi/os/window_event_queue.rb +198 -0
  21. data/lib/skypeapi/os/window_messagehandler.rb +120 -0
  22. data/lib/skypeapi/os/windows.rb +170 -306
  23. data/lib/skypeapi/profile.rb +190 -120
  24. data/lib/skypeapi/sharefunctions.rb +31 -23
  25. data/lib/skypeapi/sms.rb +87 -67
  26. data/lib/skypeapi/user.rb +159 -99
  27. data/lib/skypeapi/version.rb +3 -3
  28. data/lib/skypeapi/voicemail.rb +59 -52
  29. data/spec/matcher_be_boolean.rb +10 -0
  30. data/spec/skypeapi/application_spec.rb +76 -0
  31. data/spec/skypeapi/chat_spec.rb +356 -0
  32. data/spec/skypeapi/chatmember_spec.rb +42 -0
  33. data/spec/skypeapi/chatmessage_spec.rb +89 -0
  34. data/spec/skypeapi/event_spec.rb +31 -0
  35. data/spec/skypeapi/filetransfer_spec.rb +67 -0
  36. data/spec/skypeapi/group_spec.rb +16 -0
  37. data/spec/skypeapi/menuitem_spec.rb +37 -0
  38. data/spec/skypeapi/os/windows_spec.rb +305 -0
  39. data/spec/skypeapi/profile_spec.rb +22 -0
  40. data/spec/skypeapi/user_spec.rb +25 -0
  41. data/spec/skypeapi_spec.rb +528 -0
  42. metadata +32 -12
  43. data/lib/skypeapi/os/timer.rb +0 -108
data/LICENSE ADDED
@@ -0,0 +1,3 @@
1
+ == SkypeAPI
2
+ BSD License
3
+
data/README ADDED
@@ -0,0 +1,14 @@
1
+ = SkypeAPI
2
+
3
+ ==sample
4
+ require 'skypeapi'
5
+
6
+ SkypeAPI.init
7
+ SkypeAPI.start_messageloop
8
+ SkypeAPI::ChatMessage.set_notify do |chatmessage, property, value|
9
+ if property == :status and value == 'RECEIVED'
10
+ chatmessage.get_chat.send_message chatmessage.get_body
11
+ end
12
+ end
13
+ SkypeAPI.attach_wait
14
+ sleep
data/Rakefile ADDED
@@ -0,0 +1,67 @@
1
+ #
2
+ # To change this template, choose Tools | Templates
3
+ # and open the template in the editor.
4
+
5
+
6
+ require 'rubygems'
7
+ require 'rake'
8
+ require 'rake/clean'
9
+ require 'rake/gempackagetask'
10
+ #require 'rake/rdoctask'
11
+ require 'hanna/rdoctask'
12
+
13
+
14
+ require 'rake/testtask'
15
+ require 'spec/rake/spectask'
16
+
17
+ spec = Gem::Specification.new do |s|
18
+ s.name = 'Ruby4Skype'
19
+ s.version = '0.3.1'
20
+ s.has_rdoc = true
21
+ s.extra_rdoc_files = ['README', 'LICENSE']
22
+ s.summary = 'SkypeAPI wrapper'
23
+ s.description = s.summary
24
+ s.author = 'bopper'
25
+ s.email = 'bopper123@gmail.com'
26
+ s.homepage = 'http://rubyforge.org/projects/skyperapper/'
27
+ s.rubyforge_project = "Ruby4Skype"
28
+ # s.executables = ['your_executable_here']
29
+ s.files = %w(LICENSE README Rakefile) + Dir.glob("{lib,spec}/**/*")
30
+ s.require_path = "lib"
31
+ # s.bindir = "bin"
32
+ end
33
+
34
+ Rake::GemPackageTask.new(spec) do |p|
35
+ p.gem_spec = spec
36
+ p.need_tar = true
37
+ p.need_zip = true
38
+ end
39
+
40
+ Rake::RDocTask.new do |rdoc|
41
+ #files =['README', 'LICENSE', 'lib/**/*.rb']
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
+ files = ['README','LICENSE']
44
+ files << ['lib/skypeapi.rb']
45
+ files << ['lib/skypeapi/*.rb']
46
+ rdoc.rdoc_files.add(files)
47
+ rdoc.main = "README" # page to start on
48
+ rdoc.title = "SkypeAPI Docs"
49
+ rdoc.rdoc_dir = 'doc' # rdoc output folder
50
+ rdoc.options << '--line-numbers'
51
+ rdoc.options << '-c UTF-8'
52
+ rdoc.options << '--inline-source'
53
+ rdoc.options << '--template=hanna'
54
+ end
55
+
56
+ Rake::TestTask.new do |t|
57
+ t.test_files = FileList['test/**/*.rb']
58
+ end
59
+
60
+ Spec::Rake::SpecTask.new do |t|
61
+ t.spec_files = FileList['spec/**/*.rb']
62
+ end
63
+
64
+ #desc "Publish to RubyForge"
65
+ #task :rubyforge => [:rdoc] do
66
+ # Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, 'bopper').upload
67
+ #end
data/lib/skypeapi.rb CHANGED
@@ -1,5 +1,5 @@
1
- require "forwardable.rb"
2
- require "skypeapi/sharefunctions.rb"
1
+ require "forwardable"
2
+ require 'skypeapi/os/notifier'
3
3
  require "skypeapi/object.rb"
4
4
  require "skypeapi/version.rb"
5
5
  require "skypeapi/user.rb"
@@ -17,564 +17,625 @@ require "skypeapi/filetransfer.rb"
17
17
  require "skypeapi/event.rb"
18
18
  require "skypeapi/menuitem.rb"
19
19
  require "skypeapi/os/etc.rb"
20
+ require 'skypeapi/error'
20
21
 
21
- class SkypeAPIError < StandardError
22
- class Attach < SkypeAPIError; end
23
- class API < SkypeAPIError; end
24
- class NotImprement < SkypeAPIError; end
25
- end
26
22
 
27
23
  module SkypeAPI
28
- include SkypeAPI::Object
29
- extend Notify
30
- extend Get
31
- extend SkypeAPI::ShareFunctions
24
+ extend AbstractObject::Notify
25
+ extend AbstractObject::Get
26
+ extend AbstractObject::Invokers
27
+ extend AbstractObject::Parser
32
28
 
33
- P2M = Hash.new{|hash,key| hash[key] = key}
34
- V2O = Hash.new
29
+ #P2M = Hash.new{|hash,key| hash[key] = key}
30
+ #V2O = Hash.new
31
+
32
+ @property2symbol = Hash.new{|hash,key| hash[key] = key}
33
+ @property2callback = Hash.new
35
34
 
36
- def self.init os=RUBY_PLATFORM.downcase
37
- unless @inited
38
- case os
39
- when /(mswin(?!ce))|(mingw)|(cygwin)|(bccwin)/
40
- require 'skypeapi/os/windows.rb'
41
- @os = SkypeAPI::OS::Windows.new
42
- when /(mac)|(darwin)/
43
- require 'skypeapi/os/mac.rb'
44
- @os = SkypeAPI::OS::Mac.new
45
- when /(linux)/
46
- require 'skypeapi/os/linux.rb'
47
- @os = SkypeAPI::OS::Linux.new
35
+ class << self
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
48
85
  else
49
- raise SkypeAPIError::NotImplementError,"#{os} is unknown or not support OS"
86
+ #raise SkypeAPI::Error('init at onece')
50
87
  end
51
-
52
- #SkypeAPI縺ッ繝「繧ク繝・繝シ繝ォ縺ョ縺溘a縺ォ縲√ョ繝ェ繧イ繝シ繧ソ繝シ縺ァ繧ッ繝ゥ繧ケ繝。繧ス繝・ラ縺ィ縺励※螳夂セゥ縲・
53
- #SkypeAPI逶エ荳九・繝。繧ス繝・ラ縺ッ蜈ィ縺ヲ繧ッ繝ゥ繧ケ繝。繧ス繝・ラ縺ェ縺ョ縺ァ繧「繧ッ繧サ繧ケ蜿ッ閭ス.
54
- self.class.extend Forwardable
55
- self.class.def_delegators(:@os,
56
- :invoke,
57
- :add_event,
58
- :del_event,
59
- :get_event,
60
- :exist_event?,
61
- :attach,
62
- :attach_wait,
63
- :polling,
64
- :wait,
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
- #螟門・逕ィ縲・
77
- #self.class.__send__(:define_method, :os, Proc.new{@os})
78
-
79
- @notify = Hash.new
80
- @os.add_notify nil, method(:notified)
81
- objectsInit
82
-
83
- @inited = true
84
- else
85
- #raise SkypeAPIError,'init at onece'
86
88
  end
87
- end
88
-
89
- def self.new
90
- init
91
- self
92
- end
93
-
94
- def self.os
95
- @os
96
- end
97
-
98
- def self.notified msg
99
- skypeProperty = nil
100
- propertyReg = '(?:' + [
101
- 'CONTACTS FOCUSED',
102
- 'RINGTONE 1 STATUS',
103
- 'RINGTONE 1',
104
- '[^ ]+'
105
- ].join(')|(?:') + ')'
106
-
107
- if msg =~ /^(#{propertyReg}) (.+)$/m
108
- skypeProperty = $1; value = $2
109
- property = self::P2M[skypeProperty].to_s.downcase.to_sym if self::P2M[skypeProperty].class == Symbol
110
- value = self::V2O[skypeProperty].call value if self::V2O[skypeProperty]
89
+
90
+ def new
91
+ init
92
+ self
93
+ end
94
+
95
+ def os
96
+ @os
97
+ end
98
+
99
+ def notified msg
100
+ skypeProperty = nil
101
+ propertyReg = '(?:' + [
102
+ 'CONTACTS FOCUSED',
103
+ 'RINGTONE 1 STATUS',
104
+ 'RINGTONE 1',
105
+ '[^ ]+'
106
+ ].join(')|(?:') + ')'
111
107
 
112
- if @notify[nil]
113
- @notify[nil][nil].call property, value if @notify[nil][nil]
114
- @notify[nil][value].call property if @notify[nil][value]
108
+ if msg =~ /^(#{propertyReg}) (.+)$/m
109
+ skypeProperty = $1; value = $2
110
+ #property = self::P2M[skypeProperty].to_s.downcase.to_sym if self::P2M[skypeProperty].class == Symbol
111
+ #value = self::V2O[skypeProperty].call value if self::V2O[skypeProperty]
112
+ property = @property2symbol[skypeProperty].to_s.downcase.to_sym if @property2symbol[skypeProperty].class == Symbol
113
+ value = @property2callback[skypeProperty].call value if @property2callback[skypeProperty]
114
+
115
+ if @notify[nil]
116
+ @notify[nil][nil].call property, value if @notify[nil][nil]
117
+ @notify[nil][value].call property if @notify[nil][value]
118
+ end
119
+ if @notify[property]
120
+ @notify[property][nil].call value if @notify[property][nil]
121
+ @notify[property][value].call if @notify[property][value]
122
+ end
115
123
  end
116
- if @notify[property]
117
- @notify[property][nil].call value if @notify[property][nil]
118
- @notify[property][value].call if @notify[property][value]
124
+ end
125
+
126
+ 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|
128
+ #@os.add_notify /^#{klass::OBJECT_NAME} (.+)$/m, klass.method(:notified)
129
+ @notifier.add /^#{klass::OBJECT_NAME} (.+)$/m, klass.method(:notified)
119
130
  end
120
131
  end
132
+
133
+ def user(id) SkypeAPI::User.new(id) ; end
134
+
135
+ def call(id) SkypeAPI::Call.new(id) ; end
136
+
137
+ #def Profile() SkypeAPI::Profile.new nil ; end
138
+
139
+ #def profile() SkypeAPI::Profile.new nil ; end
140
+
141
+ def chat(id) SkypeAPI::Chat.new(id) ; end
142
+
143
+ def chatMessage(id) SkypeAPI::ChatMessage.new(id) ; end
144
+
145
+ def chatMember(id) SkypeAPI::ChatMember.new(id) ; end
146
+
147
+ #def message(id) SkypeAPI::Message.new(id) ; end
148
+
149
+ def voiceMail(id) SkypeAPI::VoiceMail.new(id) ; end
150
+
151
+ def sms(id) SkypeAPI::SMS.new(id) ; end
152
+
153
+ def app(id) SkypeAPI::Application.new(id) ; end
154
+
155
+ def group(id) SkypeAPI::Group.new(id) ; end
156
+
157
+ def fileTransfer(id) SkypeAPI::FileTransfer.new(id) ; end
158
+
159
+ def event(id) SkypeAPI::Event.new(id) ; end
160
+
161
+ def menuItem(id) SkypeAPI::MenuItem.new(id) ; end
162
+
121
163
  end
122
-
123
- def self.objectsInit
124
- [User,Profile,Call,Message,Chat,ChatMessage,ChatMember,VoiceMail,SMS,Application,Group,FileTransfer,Event,MenuItem].each do |klass|
125
- @os.add_notify /^#{klass::OBJECT_NAME} (.+)$/m, klass.method(:notified)
164
+
165
+ class << self
166
+ #@property2symbol = Hash.new{|hash,key| hash[key] = key}
167
+ #@property2callback = Hash.new
168
+ attr_reader :property2symbol, :property2callback
169
+
170
+ #General
171
+ extend AbstractObject::Get
172
+
173
+ def get_skype_version() invoke_get("SKYPEVERSION") end
174
+ def_parser(:skype_version,"SKYPEVERSION")
175
+ alias getSkypeVersion get_skype_version
176
+
177
+ def get_current_user_handle() invoke_get("CURRENTUSERHANDLE") end
178
+ def_parser(:current_user_handle,"CURRENTUSERHANDLE")
179
+ alias getCurrentUserHandle get_current_user_handle
180
+
181
+ def get_user_status() invoke_get("USERSTATUS") end
182
+ def_parser(:user_status,"USERSTATUS")
183
+ alias getUserStatus get_user_status
184
+
185
+ # privilege SkypeOut | SkypeIn | VoiceMail
186
+ def get_privilege(privilege) parse :privilege, invoke_get("PRIVILEGE #{privilege}") end
187
+ def_parser(:privilege){|str| str._flag}
188
+ alias getPrivilege get_privilege
189
+
190
+ def set_user_status(status) invoke_set("USERSTATUS", status) end
191
+ alias setUserStatus set_user_status
192
+
193
+ def get_predictive_dialer_country() invoke_get("PREDICTIVE_DIALER_COUNTRY") end
194
+ def_parser(:predictive_dialer_country)
195
+ alias getPredictiveDialerCountry get_predictive_dialer_country
196
+
197
+ def get_connstatus() invoke_get("CONNSTATUS") end
198
+ def_parser(:connstatus)
199
+ alias getConnstatus get_connstatus
200
+
201
+ def get_audio_in() invoke_get("AUDIO_IN") end
202
+ def_parser(:audio_in)
203
+ alias getAudioIn get_audio_in
204
+
205
+ def set_audio_in(device) invoke_set "AUDIO_IN", device end
206
+ alias setAudioIn set_audio_in
207
+
208
+ def get_audio_out() invoke_get("AUDIO_OUT") end
209
+ def_parser(:audio_out)
210
+ alias getAudioOut get_audio_out
211
+
212
+ def set_audio_out(device) invoke_set "AUDIO_OUT", device ; end
213
+ alias setAudioOut set_audio_out
214
+
215
+ def get_ringer() invoke_get("RINGER") end
216
+ def_parser(:ringer)
217
+ alias getRinger get_ringer
218
+
219
+ def set_ringer(device) invoke_set("RINGER", device) ; end
220
+ alias setRinger set_ringer
221
+
222
+ def get_mute() parse :mute, invoke_get("MUTE") end
223
+ def_parser(:mute){|str| str._flag}
224
+ alias getMute get_mute
225
+
226
+ def set_mute(flag) parse :mute, invoke_set("MUTE", flag._swi) ;end
227
+ alias setMute set_mute
228
+
229
+ def get_avatar(filePath, num=1) invoke_get("AVATAR #{num} #{filePath}") end
230
+ alias getAvatar get_avatar
231
+
232
+ def set_avatar(filePath, idx="", num=1)
233
+ invoke_set("AVATAR", "#{num} #{filePath}#{idx.empty? ? '' : ':'+idx.to_s}").split(' ')[1..-1].join(' ')
126
234
  end
127
- end
128
-
129
- def self.User() User ;end
130
-
131
- def self.user(id) User.new(id) ; end
132
-
133
- def self.Call() Call ; end
134
-
135
- def self.call(id) Call.new(id) ; end
136
-
137
- def self.Profile() Profile.new nil ; end
138
-
139
- def self.profile() Profile.new nil ; end
140
-
141
- def self.Chat() Chat ; end
142
-
143
- def self.chat(id) Chat.new(id) ; end
144
-
145
- def self.ChatMessage() ChatMessage ; end
146
-
147
- def self.chatMessage(id) ChatMessage.new(id) ; end
148
-
149
- def self.ChatMember() ChatMember ; end
150
-
151
- def self.chatMember(id) ChatMember.new(id) ; end
152
-
153
- def self.Message() Message ; end
154
-
155
- def self.message(id) Message.new(id) ; end
156
-
157
- def self.VoiceMail() VoiceMail ; end
158
-
159
- def self.voiceMail(id)VoiceMail.new(id) ; end
160
-
161
- def self.SMS() SMS ; end
162
-
163
- def self.sms(id) SMS.new(id) ; end
164
-
165
- def self.Application() Application ; end
166
-
167
- def self.application(id) Application.new(id) ; end
168
-
169
- def self.Group() Group ; end
170
-
171
- def self.group(id) Group.new(id) ; end
235
+ alias setAvatar set_avatar
172
236
 
173
- def self.FileTransfer() FileTransfer ; end
174
-
175
- def self.fileTransfer(id) FileTransfer.new(id) ; end
176
-
177
- def self.Event() Event ; end
178
-
179
- def self.event(id) Event.new(id) ; end
180
-
181
- def self.MenuItem() MenuItem ; end
182
-
183
- def self.menuItem(id) MenuItem.new(id) ; end
184
-
185
- #General
186
-
187
- getter :SkypeVersion, 'SKYPEVERSION'
188
-
189
- getter :CurrentUserHandle, 'CURRENTUSERHANDLE'
190
-
191
- getter :UserStatus, 'USERSTATUS'
192
-
193
- def self.setUserStatus(status) invoke_set "USERSTATUS", status ; end
194
-
195
- def self.getPrivilege(privilege) invoke_get("PRIVILEGE #{privilege}")._flag ; end
196
- notice :Privilege, 'PRIVILEGE'
197
- # privilege SkypeOut | SkypeIn | VoiceMail
198
-
199
- getter :PredictiveDialerCountry, 'PREDICTIVE_DIALER_COUNTRY'
200
-
201
- getter :Connstatus, 'CONNSTATUS'
202
-
203
- getter :AudioIn, 'AUDIO_IN'
204
-
205
- def self.setAudioIn(device) invoke_set "AUDIO_IN", device ; end
206
-
207
- getter :AudioOut, 'AUDIO_OUT'
208
-
209
- def self.setAudioOut(device) invoke_set "AUDIO_OUT", device ; end
210
-
211
- getter :Ringer, 'RINGER'
212
-
213
- def self.setRinger(device) invoke_set("RINGER", device) ; end
214
-
215
- getter :Mute, 'MUTE' do |str|
216
- str._flag
217
- end
218
-
219
- def self.setMute(flag) invoke_set("MUTE", flag._swi) ;end
220
-
221
- def self.getAvatar(filePath, num=1) invoke_get("AVATAR #{num} #{filePath}") ; end
222
- notice :Avator, 'AVATOR'
223
- #?
224
-
225
- def self.setAvatar(filePath, idx="", num=1)
226
- invoke_set("AVATAR", "#{num} #{filePath}#{idx.empty? ? '' : ':'+idx.to_s}").split(' ')[1]
227
- end
228
-
229
- def self.getRingtone(id=1) invoke_get("RINGTONE #{id}") ; end
230
-
231
- def self.setRingtone(filePath, idx="", id=1) invoke_set("RINGTONE","#{id} #{filePath}:#{idx}") ; end
232
-
233
- notice :Ringtone, "RINGTONE 1" do |str|
234
- num, file = str.split(' ',2)
235
- return num.to_i, file
236
- end
237
- #?
238
-
239
- def self.getRingtoneStatus(id=1)
240
- invoke("GET RINGTONE #{id} STATUS") =~ /RINGTONE #{id} ((ON)|(OFF))/
241
- $2._flag
242
- end
243
-
244
- notice :RingtoneStatus, "RINGTONE 1 STATUS" do |str|
245
- str._flag
246
- end
247
- #?
237
+ def get_ringtone(id=1) invoke_get("RINGTONE #{id}") end
238
+ def_parser(:ringtone, "RINGTONE 1")
239
+ alias getRingtone get_ringtone
240
+
241
+ def set_ringtone(filePath, idx="", id=1) invoke_set("RINGTONE","#{id} #{filePath}:#{idx}") end
242
+ alias setRingtone set_ringtone
243
+
244
+ def get_ringtone_status(id=1)
245
+ invoke("GET RINGTONE #{id} STATUS") =~ /RINGTONE #{id} ((ON)|(OFF))/
246
+ $2._flag
247
+ end
248
+ def_parser(:ringtone_status, "RINGTONE 1 STATUS" ){|str| str._flag}
249
+ alias getRingtoneStatus get_ringtone_status
250
+
251
+ def set_ringtone_status(flag, id=1)
252
+ invoke("SET RINGTONE #{id} STATUS #{flag._swi}") =~ /RINGTONE #{id} ((ON)|(OFF))/
253
+ $2._flag
254
+ end
255
+ alias setRingtoneStatus set_ringtone_status
256
+
257
+ def get_pc_speaker() parse :pc_speaker, invoke_get('PCSPEAKER') end
258
+ def_parser(:pc_speaker, 'PCSPEAKER'){|str| str._flag}
259
+ alias getPCSpeaker get_pc_speaker
260
+
261
+ def set_pc_speaker(flag) parse :pc_speaker, invoke_set("PCSPEAKER", flag._swi) ; end
262
+ alias setPCSpeaker set_pc_speaker
248
263
 
249
- def self.setRingtoneStatus(flag, id=1)
250
- invoke("SET RINGTONE #{id} STATUS #{flag._swi}") =~ /RINGTONE #{id} ((ON)|(OFF))/
251
- $2._flag
252
- end
264
+ def get_agc() parse :agc, invoke_get("AGC") end
265
+ def_parser(:agc){|str| str._flag}
266
+ alias getAGC get_agc
267
+
268
+ def set_agc(flag) parse :agc, invoke_set("AGC", flag._swi) end
269
+ alias setAGC set_agc
270
+
271
+ def get_aec() parse :aec, invoke_get("AEC") end
272
+ def_parser(:aec){|str| str._flag}
273
+ alias getAEC get_aec
274
+
275
+ def set_aec(flag) parse :aec, invoke_set("AEC", flag._swi) end
276
+ alias setAEC set_aec
277
+
278
+ #notice?
279
+ def reset_idle_timer() invoke("RESETIDLETIMER") == "RESETIDLETIMER" end
280
+ def_parser :reset_idle_timer, 'RESETIDLETIMER'
281
+ alias resetIdleTimer reset_idle_timer
282
+
283
+ def get_auto_away() parse :auto_away, invoke_get("AUTOAWAY") end
284
+ def_parser(:auto_away,"AUTOAWAY"){|str| str._flag}
285
+ alias getAutoAway get_auto_away
286
+
287
+ def set_auto_away(flag) parse :auto_away, invoke_set('AUTOAWAY', flag._swi) end
288
+ alias setAutoAway set_auto_away
289
+
290
+ def get_video_in() invoke_get("VIDEO_IN") end
291
+ def_parser(:video_in)
292
+ alias getVideoIn get_video_in
293
+
294
+ def set_video_in(device) invoke_set("VIDEO_IN", device) end
295
+ alias setVideoIn set_video_in
253
296
 
254
- getter :PCSpeaker, 'PCSPEAKER' do |str|
255
- str._flag
256
- end
257
-
258
- def self.setPCSpeaker(flag) invoke_set("PCSPEAKER", flag._swi) ; end
259
-
260
- getter :AGC, 'AGC' do |str|
261
- str._flag
262
- end
263
-
264
- def self.setAGC(flag) invoke_set("AGC", flag._swi) ; end
265
-
266
- getter :AEC, 'AEC' do |str|
267
- str._flag
268
- end
269
-
270
- def self.setAEC(flag) invoke_set("AEC", flag._swi) ; end
271
-
272
- def self.resetIdleTimer() invoke("RESETIDLETIMER") == "RESETIDLETIMER" ; end
273
- notice :ResetIdleTimer, 'RESETIDLETIMER' #?
274
-
275
- getter :AutoAway ,'AUTOAWAY' do |str|
276
- str._flag
277
- end
278
-
279
- def self.setAutoAway(flag) invoke_set('AUTOAWAY', flag._swi) ; end
280
-
281
- getter :VideoIn, 'VIDEO_IN'
282
-
283
- def self.setVideoIn(device) invoke_set("VIDEO_IN", device) ; end
284
-
285
- def self.ping waitLimit=nil
286
- if waitLimit
287
- invoke_block "PING", waitLimit
288
- else
297
+ def ping
289
298
  invoke("PING") == "PONG"
290
299
  end
291
- end
292
-
293
- #UserInterFace
294
- def self.focus() invoke('FOCUS') == 'FOCUS' ; end
295
-
296
- def self.minimize() invoke('MINIMIZE') == 'MINIMIZE' ; end
297
-
298
- getter :WindowState, 'WINDOWSTATE'
299
-
300
- def self.setWindowState(state) invoke_set("WINDOWSTATE", state); end
301
-
302
- def self.open prop, *value
303
- "OPEN #{prop} #{value.join(' ')}".rstrip == invoke("OPEN #{prop} #{value.join(' ')}".rstrip)
304
- end
305
-
306
- def self.openVideoTest id=''
307
- open 'VIDEOTEST', id
308
- end
309
-
310
- def self.openVoiceMail id
311
- open 'VOICEMAIL', id
312
- end
313
-
314
- def self.openAddAFriend user=''
315
- open 'ADDAFRIEND', user.to_s
316
- end
317
-
318
- def self.openIM user, msg=''
319
- open 'IM', user.to_s, msg
320
- end
321
-
322
- def self.openChat chat
323
- open 'CHAT', chat
324
- end
325
-
326
- def self.openFileTransfer path=nil, *users
327
- open 'FILETRANSFER', "#{users.join(', ')}",path ? "IN #{path}" : ''
328
- end
329
-
330
- def self.openLiveTab
331
- open 'LIVETAB'
332
- end
333
-
334
- def self.openProfile
335
- open 'PROFILE'
336
- end
337
-
338
- def self.openUserInfo user
339
- open 'USERINFO', user.to_s
340
- end
341
-
342
- def self.openConference
343
- open 'CONFERENCE'
344
- end
345
-
346
- def self.openSearch
347
- open 'SEARCH'
348
- end
349
-
350
- def self.openOptions page=''
351
- open 'OPTIONS', page
352
- end
353
-
354
- def self.openCallHistory
355
- open 'CALLHISTORY'
356
- end
357
-
358
- def self.openContacts
359
- open 'CONTACTS'
360
- end
361
-
362
- def self.openDialPad
363
- open 'DIALPAD'
364
- end
300
+
301
+ #UserInterFace
302
+
303
+ def focus() invoke('FOCUS') == 'FOCUS' end
304
+
305
+ def minimize() invoke('MINIMIZE') == 'MINIMIZE' end
306
+
307
+ def get_window_state() invoke_get("WINDOWSTATE") end
308
+ def_parser(:window_state,"WINDOWSTATE")
309
+ alias getWindowState get_window_state
310
+
311
+ def set_window_state(state) invoke_set("WINDOWSTATE", state) end
312
+ alias setWindowState set_window_state
313
+
314
+ def open prop, *value
315
+ begin
316
+ "OPEN #{prop} #{value.join(' ')}".rstrip == invoke("OPEN #{prop} #{value.join(' ')}".rstrip)
317
+ rescue => e
318
+ e.backtrace.shift
319
+ raise e
320
+ end
321
+ end
322
+
323
+ def openVideoTest id=''
324
+ open 'VIDEOTEST', id
325
+ end
326
+ alias open_video_test openVideoTest
327
+
328
+ def openVoiceMail id
329
+ open 'VOICEMAIL', id
330
+ end
331
+ alias open_voice_mail openVoiceMail
332
+
333
+ def openAddAFriend user=''
334
+ open 'ADDAFRIEND', user.to_s
335
+ end
336
+ alias open_add_a_friend openAddAFriend
337
+
338
+ def openIM user, msg=''
339
+ open 'IM', user.to_s, msg
340
+ end
341
+ alias open_im openIM
342
+
343
+ def openChat chat
344
+ open 'CHAT', chat
345
+ end
346
+ alias open_chat openChat
347
+
348
+ def openFileTransfer path=nil, *users
349
+ open 'FILETRANSFER', "#{users.join(', ')}",path ? "IN #{path}" : ''
350
+ end
351
+ alias open_file_trasfer openFileTransfer
352
+
353
+ def openLiveTab
354
+ open 'LIVETAB'
355
+ end
356
+ alias open_live_tab openLiveTab
357
+
358
+ def openProfile
359
+ open 'PROFILE'
360
+ end
361
+ alias open_profile openProfile
362
+
363
+ def openUserInfo user
364
+ open 'USERINFO', user.to_s
365
+ end
366
+ alias open_user_info openUserInfo
367
+
368
+ def openConference
369
+ open 'CONFERENCE'
370
+ end
371
+ alias open_conference openConference
372
+
373
+ def openSearch
374
+ open 'SEARCH'
375
+ end
376
+ alias open_search openSearch
377
+
378
+ def openOptions page=''
379
+ open 'OPTIONS', page
380
+ end
381
+ alias open_options openOptions
382
+
383
+ def openCallHistory
384
+ open 'CALLHISTORY'
385
+ end
386
+ alias open_call_history openCallHistory
387
+
388
+ def openContacts
389
+ open 'CONTACTS'
390
+ end
391
+ alias open_contancts openContacts
392
+
393
+ def openDialPad
394
+ open 'DIALPAD'
395
+ end
396
+ alias open_dial_pad openDialPad
397
+
398
+ def openSendContacts *users
399
+ open 'SENDCONTACTS', users.join(' ')
400
+ end
401
+ alias open_send_contancts openSendContacts
402
+
403
+ def openBlockedUsers
404
+ open 'BLOCKEDUSERS'
405
+ end
406
+ alias open_blocked_users openBlockedUsers
407
+
408
+ def openImportContacts
409
+ open 'IMPORTCONTACTS'
410
+ end
411
+ alias open_import_contacts openImportContacts
412
+
413
+ def openGettingStarted
414
+ open 'GETTINGSTARTED'
415
+ end
416
+ alias open_getting_started openGettingStarted
417
+
418
+ def openAuthorization user
419
+ open 'AUTHORIZATION', user
420
+ end
421
+ alias open_authorization openAuthorization
422
+
423
+ def BTNPressed key
424
+ invoke_echo "BTN_PRESSED #{key}"
425
+ end
426
+ alias btnp_presse BTNPressed
427
+
428
+ def BTNReleased key
429
+ invoke_echo "BTN_RELEASED #{key}"
430
+ end
431
+ alias btn_released BTNReleased
432
+
433
+ def get_contacts_focused() parse :contacts_focused, invoke_get("CONTACTS_FOCUSED") end
434
+ def_parser(:contacts_focused){|str| SkypeAPI::User.new str}
435
+ alias getContactsFocused get_contacts_focused
365
436
 
366
- def self.openSendContacts *users
367
- open 'SENDCONTACTS', users.join(' ')
368
- end
437
+ def get_ui_language() invoke_get("UI_LANGUAGE") end
438
+ def_parser(:ui_language,"UI_LANGUAGE")
439
+ alias getUILanguage get_ui_language
369
440
 
370
- def self.openBlockedUsers
371
- open 'BLOCKEDUSERS'
372
- end
441
+ def set_ui_language(lang) invoke_set("UI_LANGUAGE", lang) end
442
+ alias setUILanguage set_ui_language
443
+
444
+ def get_wallpaper() invoke_get("WALLPAPER") end
445
+ def_parser(:wallpaper)
446
+ alias getWallPaper get_wallpaper
373
447
 
374
- def self.openImportContacts
375
- open 'IMPORTCONTACTS'
376
- end
448
+ def set_wallpaper(filePath) invoke_set('WALLPAPER', filePath) end
449
+ alias setWallpaper set_wallpaper
450
+
451
+ def get_silent_mode() parse :silent_mode, invoke_get("SILENT_MODE") end
452
+ def_parser(:silent_mode){|str| str._flag}
453
+ alias getSilentMode get_silent_mode
377
454
 
378
- def self.openGettingStarted
379
- open 'GETTINGSTARTED'
380
- end
381
-
382
- def self.openAuthorization user
383
- open 'AUTHORIZATION', user
384
- end
385
-
386
- def self.BTNPressed key
387
- invoke_echo "BTN_PRESSED #{key}"
388
- end
389
-
390
- def self.BTNReleased key
391
- invoke_echo "BTN_RELEASED #{key}"
392
- end
393
-
394
- getter :ContactsFocused, 'CONTACTS_FOCUSED' do |str|
395
- user str
396
- end
397
- #nitify?
398
-
399
- getter :UILanguage, 'UI_LANGUAGE'
400
-
401
- def self.setUILanguage(lang) invoke_set("UI_LANGUAGE", lang); end
402
-
403
- getter :WallPaper, 'WALLPAPER'
404
-
405
- def self.setWallPaper(filePath) invoke_set('WALLPAPER', filePath) ; end
406
-
407
- getter :SilentMode, 'SILENT_MODE' do |str|
408
- str._flag
409
- end
455
+ def set_silent_mode(flag) parse :silent_mode, invoke_set('SILENT_MODE', flag._swi) end
456
+ alias setSilentMode set_silent_mode
410
457
 
411
- def self.setSilentMode(flag) invoke_set('SILENT_MODE', flag._swi) ; end
458
+ #Search
412
459
 
413
- #Search
414
-
415
- def self.search prop, preffix=prop, val=''
416
- ret = invoke "SEARCH #{prop} #{val}"
417
- ret =~ /^#{preffix} (.+)$/
418
- if $1
419
- $1.split(', ')
420
- else
421
- []
460
+ def search prop, preffix=prop, val=''
461
+ ret = invoke "SEARCH #{prop} #{val}"
462
+ ret =~ /^#{preffix} (.+)$/
463
+ if $1
464
+ $1.split(', ')
465
+ else
466
+ []
467
+ end
422
468
  end
423
- end
424
-
425
- def self.searchFriends
426
- search('FRIENDS','USERS').map do |handle|
427
- user(handle)
469
+
470
+ def searchFriends
471
+ search('FRIENDS','USERS').map do |handle|
472
+ user(handle)
473
+ end
428
474
  end
429
- end
430
-
431
- def self.searchUsers target
432
- search('USERS','USERS',target).map do |handle|
433
- user(handle)
475
+
476
+ def searchUsers target
477
+ search('USERS','USERS',target).map do |handle|
478
+ user(handle)
479
+ end
434
480
  end
435
- end
436
-
437
- def self.searchCalls target
438
- search('CALLS','CALLS',target).map do |id|
439
- call(id)
481
+
482
+ def searchCalls target
483
+ search('CALLS','CALLS',target).map do |id|
484
+ call(id)
485
+ end
440
486
  end
441
- end
442
-
443
- def self.searchActiveCalls
444
- search('ACTIVECALLS','CALLS').map do |id|
445
- call(id)
487
+
488
+ def searchActiveCalls
489
+ search('ACTIVECALLS','CALLS').map do |id|
490
+ call(id)
491
+ end
446
492
  end
447
- end
448
-
449
- def self.searchMissedCalls
450
- search('MISSEDCALLS','CALLS').map do |id|
451
- call(id)
493
+
494
+ def searchMissedCalls
495
+ search('MISSEDCALLS','CALLS').map do |id|
496
+ call(id)
497
+ end
452
498
  end
453
- end
454
-
455
- def self.searchSMSs
456
- search('SMSS').map do |id|
457
- sms(id)
499
+
500
+ def searchSMSs
501
+ search('SMSS').map do |id|
502
+ sms(id)
503
+ end
458
504
  end
459
- end
460
-
461
- def self.searchMissedSMSs
462
- search('MISSEDSMSS','SMSS').map do |id|
463
- sms(id)
505
+
506
+ def searchMissedSMSs
507
+ search('MISSEDSMSS','SMSS').map do |id|
508
+ sms(id)
509
+ end
464
510
  end
465
- end
466
-
467
- def self.searchVoiceMails
468
- search('VOICEMAILS').map do |id|
469
- voiceMail(id)
511
+
512
+ def searchVoiceMails
513
+ search('VOICEMAILS').map do |id|
514
+ voiceMail(id)
515
+ end
470
516
  end
471
- end
472
517
 
473
- def self.searchMissedVoiceMails
474
- search('MISSEDVOICEMAILS','VOICEMAILS').map do |id|
475
- voiceMail id
518
+ def searchMissedVoiceMails
519
+ search('MISSEDVOICEMAILS','VOICEMAILS').map do |id|
520
+ voiceMail id
521
+ end
522
+ end
523
+
524
+ def searchMessages(target='')
525
+ search('MESSAGES', 'MESSAGES', target).map do |id|
526
+ message id
527
+ end
476
528
  end
477
- end
478
529
 
479
- def self.searchMessages(target='')
480
- search('MESSAGES', 'MESSAGES', target).map do |id|
481
- message id
530
+ def searchMissedMessages
531
+ search('MISSEDMESSAGES','MESSAGES').map do |id|
532
+ message id
533
+ end
482
534
  end
483
- end
484
-
485
- def self.searchMissedMessages
486
- search('MISSEDMESSAGES','MESSAGES').map do |id|
487
- message id
535
+
536
+ def searchChats
537
+ search('CHATS').map do |id|
538
+ chat id
539
+ end
488
540
  end
489
- end
490
-
491
- def self.searchChats
492
- search('CHATS').map do |id|
493
- chat id
541
+
542
+ def searchActiveChats
543
+ search('ACTIVECHATS','CHATS').map do |id|
544
+ chat id
545
+ end
494
546
  end
495
- end
496
-
497
- def self.searchActiveChats
498
- search('ACTIVECHATS','CHATS').map do |id|
499
- chat id
547
+
548
+ def searchMissedChats
549
+ search('MISSEDCHATS','CHATS').map do |id|
550
+ chat id
551
+ end
500
552
  end
501
- end
502
-
503
- def self.searchMissedChats
504
- search('MISSEDCHATS','CHATS').map do |id|
505
- chat id
553
+
554
+ def searchRecentChats
555
+ search('RECENTCHATS','CHATS').map do |id|
556
+ chat id
557
+ end
506
558
  end
507
- end
508
-
509
- def self.searchRecentChats
510
- search('RECENTCHATS','CHATS').map do |id|
511
- chat id
559
+
560
+ def searchBookMarkedChats
561
+ search('BOOKMARKEDCHATS','CHATS').map do |id|
562
+ chat id
563
+ end
512
564
  end
513
- end
514
-
515
- def self.searchBookMarkedChats
516
- search('BOOKMARKEDCHATS','CHATS').map do |id|
517
- chat id
565
+
566
+ def searchChatMessages target=''
567
+ search('CHATMESSAGES','CHATMESSAGES', target).map do |id|
568
+ chatMessage id
569
+ end
518
570
  end
519
- end
520
-
521
- def self.searchChatMessages target=''
522
- search('CHATMESSAGES','CHATMESSAGES', target).map do |id|
523
- chatMessage id
571
+
572
+ def searchMissedChatMessages
573
+ search('MISSEDCHATMESSAGES','CHATMESSAGES').map do |id|
574
+ chatMessage id
575
+ end
524
576
  end
525
- end
526
-
527
- def self.searchMissedChatMessages
528
- search('MISSEDCHATMESSAGES','CHATMESSAGES').map do |id|
529
- chatMessage id
577
+
578
+ def searchUsersWaitingMyAuthorization
579
+ search('USERSWAITINGMYAUTHORIZATION','USERS').map do |handle|
580
+ user handle
581
+ end
530
582
  end
531
- end
532
-
533
- def self.searchUsersWaitingMyAuthorization
534
- search('USERSWAITINGMYAUTHORIZATION','USERS').map do |handle|
535
- user handle
583
+
584
+ def searchGroups type=''
585
+ search('GROUPS','GROUPS',type).map do |id|
586
+ group id
587
+ end
536
588
  end
537
- end
538
-
539
- def self.searchGroups type=''
540
- search('GROUPS','GROUPS',type).map do |id|
541
- group id
589
+
590
+ def searchFileTransfers
591
+ search('FILETRANSFERS').map do |id|
592
+ fileTransfer id
593
+ end
542
594
  end
543
- end
544
-
545
- def self.searchFileTransfers
546
- search('FILETRANSFERS').map do |id|
547
- fileTransfer id
595
+
596
+ def searchActiveFileTransfers
597
+ search('ACTIVEFILETRANSFERS','FILETRANSFERS').map do |id|
598
+ fileTransfer id
599
+ end
548
600
  end
549
- end
601
+
602
+ alias search_friends searchFriends
603
+ alias search_users searchUsers
604
+ alias search_calls searchCalls
605
+ alias search_active_calls searchActiveCalls
606
+ alias search_missed_calls searchMissedCalls
607
+ alias search_smss searchSMSs
608
+ alias search_missed_smss searchMissedSMSs
609
+ alias search_voice_mails searchVoiceMails
610
+ alias search_missed_voice_mails searchMissedVoiceMails
611
+ alias search_messages searchMessages
612
+ alias search_missed_messages searchMissedMessages
613
+ alias search_chats searchChats
614
+ alias search_active_chats searchActiveChats
615
+ alias search_missed_chats searchMissedChats
616
+ alias search_recent_chats searchRecentChats
617
+ alias search_book_marked_chats searchBookMarkedChats
618
+ alias search_chat_messages searchChatMessages
619
+ alias search_missed_chat_messages searchMissedChatMessages
620
+ alias search_users_waiting_my_authorization searchUsersWaitingMyAuthorization
621
+ alias search_groups searchGroups
622
+ alias search_file_transfers searchFileTransfers
623
+ alias search_active_file_transfers searchActiveFileTransfers
624
+
625
+ #History
550
626
 
551
- def self.searchActiveFileTransfers
552
- search('ACTIVEFILETRANSFERS','FILETRANSFERS').map do |id|
553
- fileTransfer id
627
+ def clearChatHistory() invoke('CLEAR CHATHISTORY') == 'CLEAR CHATHISTORY' ; end
628
+
629
+ def clearVoiceMailHistory() invoke('CLEAR VOICEMAILHISTORY') == 'CLEAR VOICEMAILHISTORY' ; end
630
+
631
+ def clearCallHistory(type, handle='')
632
+ invoke("CLEAR CALLHISTORY #{type} #{handle}") == "CLEAR CALLHISTORY #{type} #{handle}".rstrip
554
633
  end
555
- end
556
-
557
- #History
558
-
559
- def self.clearChatHistory() invoke('CLEAR CHATHISTORY') == 'CLEAR CHATHISTORY' ; end
634
+ alias clear_chat_history clearChatHistory
635
+ alias clear_voice_mail_history clearVoiceMailHistory
636
+ alias clear_call_history clearCallHistory
560
637
 
561
- def self.clearVoiceMailHistory() invoke('CLEAR VOICEMAILHISTORY') == 'CLEAR VOICEMAILHISTORY' ; end
562
-
563
- def self.clearCallHistory(type, handle='')
564
- invoke("CLEAR CALLHISTORY #{type} #{handle}") == "CLEAR CALLHISTORY #{type} #{handle}".rstrip
638
+ def_parser :call_history_changed, 'CALLHISTORYCHANGED'
639
+ def_parser :im_history_changed, 'IMHISTORYCHANGED'
565
640
  end
566
-
567
- notice :CallHistoryChanged, 'CALLHISTORYCHANGED'
568
- notice :IMHistoryChanged, 'IMHISTORYCHANGED'
569
-
570
- #private :notified, :open, :search
571
- #obs
572
-
573
- #def openApplication appName
574
- # return A2A.new(appName,self)
575
- #end
576
-
577
- #def openExtendApplication appName
578
- # return A2AEx.new(appName,self)
579
- #end
580
641
  end