Ruby4Skype 0.2.3 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,22 @@
1
+ require 'skypeapi'
2
+
3
+ describe SkypeAPI::Profile do
4
+ before :all do
5
+ SkypeAPI.init
6
+ SkypeAPI.start_messageloop
7
+ SkypeAPI.attach_wait
8
+ end
9
+
10
+ after :all do
11
+ SkypeAPI.close
12
+ end
13
+
14
+ before(:each) do
15
+ @profile = Profile.new
16
+ end
17
+
18
+ it "should desc" do
19
+ # TODO
20
+ end
21
+ end
22
+
@@ -0,0 +1,25 @@
1
+ # To change this template, choose Tools | Templates
2
+ # and open the template in the editor.
3
+
4
+ require 'skypeapi'
5
+
6
+ describe SkypeAPI::User do
7
+ before :all do
8
+ SkypeAPI.init
9
+ SkypeAPI.start_messageloop
10
+ SkypeAPI.attach_wait
11
+ end
12
+
13
+ after :all do
14
+ SkypeAPI.close
15
+ end
16
+
17
+ before(:each) do
18
+ @user = User.new
19
+ end
20
+
21
+ it "should desc" do
22
+ # TODO
23
+ end
24
+ end
25
+
@@ -0,0 +1,528 @@
1
+ require 'matcher_be_boolean'
2
+ require 'skypeapi'
3
+ require 'timeout'
4
+
5
+ describe SkypeAPI do
6
+ it "VERSION should 0.3.1" do
7
+ SkypeAPI::VERSION.to_s.should == '0.3.1'
8
+ end
9
+
10
+ it "should init and attach and close" do
11
+ SkypeAPI.init
12
+ SkypeAPI.attach_wait
13
+ SkypeAPI.close
14
+ end
15
+
16
+ it "should more time attach and close" do
17
+ 10.times do
18
+ SkypeAPI.init
19
+ timeout(3){ SkypeAPI.attach_wait }
20
+ SkypeAPI.close
21
+ end
22
+ end
23
+
24
+ it "user(handle) should be instance of SkypeAPI::User" do
25
+ SkypeAPI.user('hoge').should be_instance_of SkypeAPI::User
26
+ end
27
+
28
+ describe 'when attached' do
29
+ before :each do
30
+ SkypeAPI.init
31
+ SkypeAPI.attach_wait
32
+ end
33
+
34
+ after :each do
35
+ SkypeAPI.close
36
+ end
37
+
38
+ it "SkypeAPI::Chat should create.send_message" do
39
+ SkypeAPI::Chat.create('echo123').send_message('hoge test')
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+
46
+ describe SkypeAPI, 'general methods' do
47
+ before :all do
48
+ SkypeAPI.init
49
+ SkypeAPI.attach_wait
50
+ end
51
+
52
+ after :all do
53
+ SkypeAPI.close
54
+ end
55
+
56
+ it "ping should be true" do
57
+ SkypeAPI.ping.should be_true
58
+ end
59
+
60
+ it "get_skype_version should match \d\.\d\.\d\.\d" do
61
+ SkypeAPI.getSkypeVersion.should match /\d+\.\d+.\d+.\d+/
62
+ end
63
+
64
+ it "get_current_user_handle should be instance of String and not be empty" do
65
+ SkypeAPI.getCurrentUserHandle.should be_instance_of String
66
+ SkypeAPI.getCurrentUserHandle.should_not be_empty
67
+ end
68
+
69
+ it "get_user_status should match /^(UNKNOWN)|(ONLINE)|(OFFLINE)|(SKYPEME)|(AWAY)|(NA)|(DND)|(INVISIBLE)|(LOGGEDOUT)$/" do
70
+ SkypeAPI.getUserStatus.should match /^(UNKNOWN)|(ONLINE)|(OFFLINE)|(SKYPEME)|(AWAY)|(NA)|(DND)|(INVISIBLE)|(LOGGEDOUT)$/
71
+ end
72
+
73
+ it "set_user_status(s) should == s" do
74
+ s = SkypeAPI.getUserStatus
75
+ SkypeAPI.setUserStatus(s).should == s
76
+ end
77
+
78
+ it "get_privilege should be boolean" do
79
+ ['SkypeOut','SkypeIn','VOICEMAIL'].each do |user_privilege|
80
+ SkypeAPI.getPrivilege(user_privilege).should be_boolean
81
+ end
82
+ end
83
+
84
+ it "get_predictive_dialer_country should be instance of String and size 2" do
85
+ pdCountry = SkypeAPI.getPredictiveDialerCountry
86
+ pdCountry.should be_instance_of String
87
+ pdCountry.size.should == 2
88
+ end
89
+
90
+ it "get_connstatus should match (OFFLINE)|(CONNECTING)|(PAUSING)|(ONLINE)" do
91
+ SkypeAPI.getConnstatus.should match /^(OFFLINE)|(CONNECTING)|(PAUSING)|(ONLINE)$/
92
+ end
93
+
94
+ describe "device and file methods" do
95
+ it "get_adudio_in should be instance of String and not be empty" do
96
+ SkypeAPI.getAudioIn.should be_instance_of String
97
+ SkypeAPI.getAudioIn.should_not be_empty
98
+ end
99
+
100
+ it "set_audio_in(device) should device" do
101
+ device = SkypeAPI.getAudioIn
102
+ SkypeAPI.setAudioIn(device).should == device
103
+ end
104
+
105
+ it "get_adudio_out should be instance of String and not be empty" do
106
+ SkypeAPI.getAudioOut.should be_instance_of String
107
+ SkypeAPI.getAudioOut.should_not be_empty
108
+ end
109
+
110
+ it "set_audio_out(device) should device" do
111
+ device = SkypeAPI.getAudioOut
112
+ SkypeAPI.setAudioOut(device).should == device
113
+ end
114
+
115
+ it "get_ringer should be instance of String and not be empty" do
116
+ SkypeAPI.getRinger.should be_instance_of String
117
+ SkypeAPI.getRinger.should_not be_empty
118
+ end
119
+
120
+ it "set_ringer(device) should device" do
121
+ pending "SET RINGER speaker => ERROR 50 cannot set device"
122
+ device = SkypeAPI.getRinger
123
+ SkypeAPI.setRinger(device).should == device
124
+ end
125
+
126
+ it "get_mute should be boolean" do
127
+ SkypeAPI.getMute.should be_boolean
128
+ end
129
+
130
+ it "set_mute(flag) should flag" do
131
+ flag = SkypeAPI.getMute
132
+ SkypeAPI.setMute(flag).should == flag
133
+ end
134
+
135
+ def prepare_avator &block
136
+ path = File.dirname(File.expand_path(__FILE__ )) << '/skype_avatar.jpg'
137
+ violated "exist #{path}" if test(?e, path)
138
+ block.call path
139
+ File.delete path
140
+ end
141
+
142
+ it "get_avator(path) should be nil and save jpg file" do
143
+ prepare_avator do |path|
144
+ SkypeAPI.getAvatar(path).should be_nil
145
+ test(?e, path).should be_true
146
+ end
147
+ end
148
+
149
+ it "set_avator(path) should path" do
150
+ prepare_avator do |path|
151
+ SkypeAPI.getAvatar(path)
152
+ test(?e, path).should be_true
153
+ SkypeAPI.setAvatar(path).should == path
154
+ end
155
+ end
156
+
157
+ it "get_ringtone should be instance of String and not be empty" do
158
+ SkypeAPI.getRingtone.should be_instance_of String
159
+ SkypeAPI.getRingtone.should_not be_empty
160
+ end
161
+
162
+ it "set_ringtone(rt) should rt" do
163
+ pending "SET RINGTONE 1 call_in: => ERROR 111 SET File not found"
164
+ rt = SkypeAPI.getRingtone
165
+ SkypeAPI.setRingtone(rt).should rt
166
+ end
167
+
168
+ it "get_rigtone_status should be boolean" do
169
+ SkypeAPI.getRingtoneStatus.should be_boolean
170
+ end
171
+
172
+ it "set_rigtone_status(flag) should flag" do
173
+ flag = SkypeAPI.getRingtoneStatus
174
+ SkypeAPI.setRingtoneStatus(flag).should == flag
175
+ end
176
+
177
+ it "get_pc_bspeaker should be boolean" do
178
+ SkypeAPI.getPCSpeaker.should be_boolean
179
+ end
180
+
181
+ it "set_pc_speaker(flag) should flag" do
182
+ flag = SkypeAPI.getPCSpeaker
183
+ SkypeAPI.setPCSpeaker(flag).should == flag
184
+ end
185
+
186
+ it "get_agc should be boolean" do
187
+ SkypeAPI.getAGC.should be_boolean
188
+ end
189
+
190
+ it "set_agc(flag) should boolean" do
191
+ flag = SkypeAPI.getAGC
192
+ SkypeAPI.setAGC(flag).should == flag
193
+ end
194
+
195
+ it "get_aec should be boolean" do
196
+ SkypeAPI.getAEC.should be_boolean
197
+ end
198
+
199
+ it "set_aec(flag) should boolean" do
200
+ flag = SkypeAPI.getAEC
201
+ SkypeAPI.setAEC(flag).should == flag
202
+ end
203
+
204
+ it "reset_idle_timer.should be true" do
205
+ SkypeAPI.resetIdleTimer.should be_true
206
+ end
207
+
208
+ it "get_auto_away should be boolean" do
209
+ SkypeAPI.getAutoAway.should be_boolean
210
+ end
211
+
212
+ it "set_auto_away(flag) should flag" do
213
+ flag = SkypeAPI.getAutoAway
214
+ SkypeAPI.setAutoAway(flag).should == flag
215
+ end
216
+
217
+ it "get_video_in should be instance of String and not be empty" do
218
+ SkypeAPI.getVideoIn.should be_instance_of String
219
+ end
220
+
221
+ it "set_video_in(string) should string" do
222
+ string =SkypeAPI.getVideoIn
223
+ SkypeAPI.setVideoIn(string) == string
224
+ end
225
+ end
226
+
227
+ describe "UI methods" do
228
+ before{pending 'uzai'}
229
+
230
+ it "should focus" do
231
+ SkypeAPI.focus.should be_true
232
+ end
233
+
234
+ it "should minimize" do
235
+ SkypeAPI.minimize.should be_true
236
+ end
237
+
238
+ it "get_window_status should match /(NORMAL)|(MINIMIZED)|(MAXIMIZED)|(HIDDEN)/" do
239
+ SkypeAPI.getWindowState.should match /(NORMAL)|(MINIMIZED)|(MAXIMIZED)|(HIDDEN)/
240
+ end
241
+
242
+ it "set_window_status(string) should string" do
243
+ SkypeAPI.setWindowState('NORMAL').should == 'NORMAL'
244
+ end
245
+
246
+ it "should open_video_test" do
247
+ SkypeAPI.openVideoTest.should be_true
248
+ end
249
+
250
+ it "should open_video_mail" do
251
+ pending
252
+ #assert_equal SkypeAPI.openVoiceMail(1)
253
+ #IDが、、、後で調べる。
254
+ end
255
+
256
+ it "should open_add_friend(handle or user)" do
257
+ SkypeAPI.openAddAFriend('echo123').should be_true
258
+ SkypeAPI.openAddAFriend(SkypeAPI.user('echo123')).should be_true
259
+ end
260
+
261
+ it "should open_im(user, msg)" do
262
+ SkypeAPI.openIM('echo123','this is a test').should be_true
263
+ end
264
+
265
+ it "should open_chat(chat)" do
266
+ chat = SkypeAPI::Chat.create 'echo123'
267
+ SkypeAPI.openChat(chat).should be_true
268
+ end
269
+
270
+ it "should open_file_transfer(path,*user)" do
271
+ SkypeAPI.openFileTransfer(nil,SkypeAPI.user('kashi.9')).should be_true
272
+ end
273
+
274
+ it "should profile_live_tab" do
275
+ SkypeAPI.openLiveTab.should be_true
276
+ end
277
+
278
+ it "should open_profile" do
279
+ SkypeAPI.openProfile.should be_true
280
+ end
281
+
282
+ it "should open_user_info(user)" do
283
+ SkypeAPI.openUserInfo('echo123').should be_true
284
+ end
285
+
286
+ it "should open_conference" do
287
+ SkypeAPI.openConference.should be_true
288
+ end
289
+
290
+ it "should open_search" do
291
+ SkypeAPI.openSearch.should be_true
292
+ end
293
+
294
+ it "should open_options(nil|'general'|'privacy'|'notifications'|'soundalerts'|'sounddevices'|'hotkeys'|'connection'|'voicemail'|'callforward'|'video'|'advanced')" do
295
+ [nil,'general','privacy','notifications','soundalerts','sounddevices','hotkeys','connection','voicemail','callforward','video','advanced'].each do |page|
296
+ SkypeAPI.openOptions(page).should be_true
297
+ end
298
+ end
299
+
300
+ it "should open_call_history" do
301
+ SkypeAPI.openCallHistory.should be_true
302
+ end
303
+
304
+ it "should open_contancts" do
305
+ SkypeAPI.openContacts.should be_true
306
+ end
307
+
308
+ it "should open_dialpad" do
309
+ SkypeAPI.openDialPad.should be_true
310
+ end
311
+
312
+ it "should open_send_contancts" do
313
+ SkypeAPI.openSendContacts('hogehoge_001','hogehoge_002').should be_true
314
+ end
315
+
316
+ it "should open_blocked_users" do
317
+ SkypeAPI.openBlockedUsers.should be_true
318
+ end
319
+
320
+ it "should open_import_contancts" do
321
+ SkypeAPI.openImportContacts.should be_true
322
+ end
323
+
324
+ it "should open_getting_started" do
325
+ SkypeAPI.openGettingStarted.should be_true
326
+ end
327
+
328
+ it "should open_authorization" do
329
+ SkypeAPI.openAuthorization('hogehoge_1000'.should be_true)
330
+ end
331
+
332
+ it "should btn_pressed_released" do
333
+ 9.times do |i|
334
+ SkypeAPI.BTNPressed(i).should be_true
335
+ sleep 0.5
336
+ SkypeAPI.BTNReleased(i).should be_true
337
+ end
338
+ end
339
+
340
+ it "get_contacts_focused should be instance of SkypeAPI::User" do
341
+ SkypeAPI.getContactsFocused.should be_instance_of SkypeAPI::User
342
+ end
343
+
344
+ it "get_ui_langualge should be instance of String and sieze 2" do
345
+ SkypeAPI.getUILanguage.should be_instance_of String
346
+ SkypeAPI.getUILanguage.size.should == 2
347
+ end
348
+
349
+ it "set_ui_langualge(string) should string" do
350
+ uil = SkypeAPI.getUILanguage
351
+ SkypeAPI.setUILanguage(uil).should == uil
352
+ end
353
+
354
+ it "get_wall_paper should be instance of String" do
355
+ SkypeAPI.getWallPaper.should be_instance_of String
356
+ end
357
+
358
+ it "set_wall_paper(string) should string" do
359
+ string = SkypeAPI.getWallPaper
360
+ SkypeAPI.setWallPaper(string).should == string
361
+ end
362
+
363
+ it "get_silent_mode should be boolean" do
364
+ SkypeAPI.getSilentMode.should be_boolean
365
+ end
366
+
367
+ it "set_silent_mode(flag) should flag" do
368
+ silent_mode = SkypeAPI.getSilentMode
369
+ SkypeAPI.setSilentMode(silent_mode).should == silent_mode
370
+ end
371
+
372
+ end
373
+
374
+ describe "search methods" do
375
+
376
+ it "search_frinends each should be instance of SkypeAPI::User" do
377
+ SkypeAPI.searchFriends.each do |user|
378
+ user.should be_instance_of SkypeAPI::User
379
+ end
380
+ end
381
+
382
+ it "search_users(String) each should be instance of SkypeAPI::User" do
383
+ SkypeAPI.searchUsers('echo123').each do |user|
384
+ user.should be_instance_of SkypeAPI::User
385
+ end
386
+ end
387
+
388
+ it "search_calls(String or User?) each should be instance of SkypeAPI::Call" do
389
+ SkypeAPI.searchCalls('echo123').each do |call|
390
+ call.should be_instance_of SkypeAPI::Call
391
+ end
392
+ end
393
+
394
+ it "search_active_calls each should be instance of SkypeAPI::Call" do
395
+ SkypeAPI.searchActiveCalls.each do |call|
396
+ call.should be_instance_of SkypeAPI::Call
397
+ end
398
+ end
399
+
400
+ it "search_missed_calls each should be instance of SkypeAPI::Call" do
401
+ SkypeAPI.searchMissedCalls.each do |call|
402
+ call.should be_instance_of SkypeAPI::Call
403
+ end
404
+ end
405
+
406
+ it "search_smss should each should be instance of SkypeAPI::SMS" do
407
+ SkypeAPI.searchSMSs.each do |sms|
408
+ sms.should be_instance_of SkypeAPI::SMS
409
+ end
410
+ end
411
+
412
+ it "search_missed_smss should each should be instance of SkypeAPI::Call" do
413
+ SkypeAPI.searchMissedSMSs.each do |call|
414
+ call.should be_instance_of SkypeAPI::Call
415
+ end
416
+ end
417
+
418
+ it "search_voice_mail should each should be instance of SkypeAPI::Call" do
419
+ SkypeAPI.searchVoiceMails.each do |call|
420
+ call.should be_instance_of SkypeAPI::Call
421
+ end
422
+ end
423
+
424
+ it "search_missed_voice_mail should each should be instance of SkypeAPI::VoiceMail" do
425
+ SkypeAPI.searchMissedVoiceMails.each do |vm|
426
+ vm.should be_instance_of SkypeAPI::VoiceMail
427
+ end
428
+ end
429
+
430
+ #OBS
431
+ #it "search_messages should" do
432
+ # SkypeAPI.searchMessages('skypeapitester').each do |msg|
433
+ # assert_instance_of(SkypeAPI::Message, msg)
434
+ # end
435
+ #end
436
+
437
+ it "search_missed_messages should each should be instance of SkypeAPI::Message" do
438
+ SkypeAPI.searchMissedMessages.each do |msg|
439
+ msg.should be_instance_of SkypeAPI::Message
440
+ end
441
+ end
442
+
443
+ it "search_chats should each should be instance of SkypeAPI::Chat" do
444
+ SkypeAPI.searchChats().each do |chat|
445
+ chat.should be_instance_of SkypeAPI::Chat
446
+ end
447
+ end
448
+
449
+ it "search_active_chats should each should be instance of SkypeAPI::Chat" do
450
+ SkypeAPI.searchActiveChats().each do |chat|
451
+ chat.should be_instance_of SkypeAPI::Chat
452
+ end
453
+ end
454
+
455
+ it "search_missed_chats should each should be instance of SkypeAPI::Chat" do
456
+ SkypeAPI.searchMissedChats.each do |chat|
457
+ chat.should be_instance_of SkypeAPI::Chat
458
+ end
459
+ end
460
+
461
+ it "search_recent_chats should each should be instance of SkypeAPI::Chat" do
462
+ SkypeAPI.searchRecentChats().each do |chat|
463
+ chat.should be_instance_of SkypeAPI::Chat
464
+ end
465
+ end
466
+
467
+ it "search_bookmarked_chats should each should be instance of SkypeAPI::Chat" do
468
+ SkypeAPI.searchBookMarkedChats().each do |chat|
469
+ chat.should be_instance_of SkypeAPI::Chat
470
+ end
471
+ end
472
+
473
+ it "search_chat_messages should each should be instance of SkypeAPI::ChatMessage" do
474
+ SkypeAPI.searchChatMessages('echo123').each do |chat_message|
475
+ chat_message.should be_instance_of SkypeAPI::ChatMessage
476
+ end
477
+ end
478
+
479
+ it "search_missed_chat_messages should each should be instance of SkypeAPI::ChatMessage" do
480
+ SkypeAPI.searchMissedChatMessages().each do |chat_message|
481
+ chat_message.should be_instance_of SkypeAPI::ChatMessage
482
+ end
483
+ end
484
+
485
+ it "search_users_waiting_my_authorization should each should be instance of SkypeAPI::User" do
486
+ SkypeAPI.searchUsersWaitingMyAuthorization.each do |user|
487
+ user.should be_instance_of SkypeAPI::User
488
+ end
489
+ end
490
+
491
+ it "search_groups should each should be instance of SkypeAPI::Group" do
492
+ SkypeAPI.searchGroups('ALL').each do |group|
493
+ group.should be_instance_of SkypeAPI::Group
494
+ end
495
+ end
496
+
497
+ it "search_file_transfers should each should be instance of SkypeAPI::FileTransfer" do
498
+ SkypeAPI.searchFileTransfers().each do |file_transfer|
499
+ file_transfer.should be_instance_of SkypeAPI::FileTransfer
500
+ end
501
+ end
502
+
503
+ it "search_active_file_transfers should each should be instance of SkypeAPI::FileTransfer" do
504
+ SkypeAPI.searchActiveFileTransfers().each do |file_transfer|
505
+ file_transfer.should be_instance_of SkypeAPI::FileTransfer
506
+ end
507
+ end
508
+
509
+ end
510
+
511
+ describe 'clear history methods' do
512
+ before do
513
+ pending "I do not want clear"
514
+ end
515
+
516
+ it "clear_chat_history should be_true" do
517
+ SkypeAPI.clearChatHistory.should be_true
518
+ end
519
+
520
+ it "clear_voice_mail_history should be true" do
521
+ SkypeAPI.clearVoiceMailHistory.should be_true
522
+ end
523
+
524
+ it "clear_call_history('ALL') should be true" do
525
+ SkypeAPI.clearCallHistory('ALL').should be_true
526
+ end
527
+ end
528
+ end