Ruby4Skype 0.2.1 → 0.2.2
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.
- data/lib/skypeapi/application.rb +19 -333
- data/lib/skypeapi/call.rb +20 -21
- data/lib/skypeapi/chat.rb +33 -34
- data/lib/skypeapi/chatmessage.rb +6 -6
- data/lib/skypeapi/event.rb +1 -1
- data/lib/skypeapi/filetransfer.rb +2 -2
- data/lib/skypeapi/group.rb +11 -11
- data/lib/skypeapi/menuitem.rb +10 -10
- data/lib/skypeapi/object.rb +12 -3
- data/lib/skypeapi/os.rb +32 -16
- data/lib/skypeapi/profile.rb +33 -38
- data/lib/skypeapi/sms.rb +1 -1
- data/lib/skypeapi/user.rb +10 -10
- data/lib/skypeapi/version.rb +9 -0
- data/lib/skypeapi/voicemail.rb +1 -1
- data/lib/skypeapi.rb +31 -29
- metadata +3 -2
data/lib/skypeapi/application.rb
CHANGED
@@ -8,27 +8,27 @@ module SkypeAPI
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def to_s
|
11
|
-
@
|
11
|
+
@id
|
12
12
|
end
|
13
13
|
|
14
14
|
def user
|
15
15
|
@user
|
16
16
|
end
|
17
17
|
|
18
|
-
def write
|
19
|
-
@app.write self, cmd
|
18
|
+
def write msg
|
19
|
+
@app.write self, cmd
|
20
20
|
end
|
21
21
|
|
22
|
-
def datagram
|
23
|
-
@app.datagram self, cmd
|
22
|
+
def datagram msg, &block
|
23
|
+
@app.datagram self, cmd
|
24
24
|
end
|
25
25
|
|
26
|
-
def read
|
27
|
-
@app.read self
|
26
|
+
def read
|
27
|
+
@app.read self
|
28
28
|
end
|
29
29
|
|
30
|
-
def disconnect
|
31
|
-
@app.disconnect self
|
30
|
+
def disconnect
|
31
|
+
@app.disconnect self
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -44,7 +44,7 @@ module SkypeAPI
|
|
44
44
|
end
|
45
45
|
|
46
46
|
getter :Streams, 'STREAMS' do |str|
|
47
|
-
str.split(' ').collect{|
|
47
|
+
str.split(' ').collect{|streamID| Stream.new(self, streamID)}
|
48
48
|
end
|
49
49
|
|
50
50
|
getter :Received, 'RECEIVED' do |str|
|
@@ -61,8 +61,8 @@ module SkypeAPI
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
def self.create
|
65
|
-
app = new
|
64
|
+
def self.create appName
|
65
|
+
app = new appName
|
66
66
|
app.create
|
67
67
|
app
|
68
68
|
end
|
@@ -71,21 +71,21 @@ module SkypeAPI
|
|
71
71
|
sendEcho "CREATE APPLICATION #{@id}"
|
72
72
|
end
|
73
73
|
|
74
|
-
def connect
|
75
|
-
sendEcho "ALTER APPLICATION #{@id} CONNECT #{
|
74
|
+
def connect user
|
75
|
+
sendEcho "ALTER APPLICATION #{@id} CONNECT #{user}"
|
76
76
|
end
|
77
77
|
|
78
|
-
def write stream,
|
79
|
-
sendAlter "WRITE", "#{stream} #{
|
78
|
+
def write stream, msg
|
79
|
+
sendAlter "WRITE", "#{stream} #{msg}"
|
80
80
|
end
|
81
81
|
|
82
|
-
def datagram stream,
|
83
|
-
sendAlter "DATAGRAM", "#{stream} #{
|
82
|
+
def datagram stream, msg
|
83
|
+
sendAlter "DATAGRAM", "#{stream} #{msg}"
|
84
84
|
end
|
85
85
|
|
86
86
|
def read stream
|
87
87
|
res = sendCMD "ALTER APPLICATION #{@id} READ #{stream}"
|
88
|
-
res =~ /^ALTER APPLICATION #{@id} READ #{stream} (.*)$/
|
88
|
+
res =~ /^ALTER APPLICATION #{@id} READ #{stream} (.*)$/m
|
89
89
|
$1
|
90
90
|
end
|
91
91
|
|
@@ -97,319 +97,5 @@ module SkypeAPI
|
|
97
97
|
sendEcho "DELETE APPLICATION #{@id}"
|
98
98
|
end
|
99
99
|
end
|
100
|
-
|
101
|
-
class A2A
|
102
|
-
extend Forwardable
|
103
|
-
include SkypeAPI::ShareFunctions
|
104
|
-
def initialize appName,base
|
105
|
-
@appName = appName
|
106
|
-
@eventListener = Hash.new
|
107
|
-
@base = base
|
108
|
-
@base.addNotify /^APPLICATION #{@appName} (.+)$/,method(:receiv)
|
109
|
-
end
|
110
|
-
|
111
|
-
def_delegators :@base, :sendCMD, :sendCallBack,:sendBlock,:addNotify,:delNotify
|
112
|
-
#:attach, :wait,:polling, :attached, :attached=, :received, :received=, :sent, :sent=
|
113
|
-
|
114
|
-
def getConnectable
|
115
|
-
sendSplit "GET APPLICATION #{@appName} CONNECTABLE","APPLICATION #{@appName} CONNECTABLE"
|
116
|
-
end
|
117
|
-
def getConnecting
|
118
|
-
sendSplit "GET APPLICATION #{@appName} CONNECTING","APPLICATION #{@appName} CONNECTING"
|
119
|
-
end
|
120
|
-
def getStreams
|
121
|
-
sendSplit "GET APPLICATION #{@appName} STREAMS","APPLICATION #{@appName} STREAMS"
|
122
|
-
end
|
123
|
-
def getReceived
|
124
|
-
streamByte2hash sendSplit("GET APPLICATION #{@appName} RECEIVED","APPLICATION #{@appName} RECEIVED")
|
125
|
-
end
|
126
|
-
def getSending
|
127
|
-
streamByte2hash sendSplit("GET APPLICATION #{@appName} SENDING","APPLICATION #{@appName} SENDING")
|
128
|
-
end
|
129
|
-
def create
|
130
|
-
sendEcho "CREATE APPLICATION #{@appName}"
|
131
|
-
end
|
132
|
-
def connect handle
|
133
|
-
sendEcho "ALTER APPLICATION #{@appName} CONNECT #{handle}"
|
134
|
-
end
|
135
|
-
def write stream, cmd, &block
|
136
|
-
if block_given?
|
137
|
-
sendCMD("ALTER APPLICATION #{@appName} WRITE #{stream} #{cmd}",&block)
|
138
|
-
else
|
139
|
-
sendEcho "ALTER APPLICATION #{@appName} WRITE #{stream} #{cmd}"
|
140
|
-
end
|
141
|
-
end
|
142
|
-
def datagram stream, cmd
|
143
|
-
sendEcho "ALTER APPLICATION #{@appName} DATAGRAM #{stream} #{cmd}"
|
144
|
-
end
|
145
|
-
def read stream, &block
|
146
|
-
if block_given?
|
147
|
-
sendCMD "ALTER APPLICATION #{@appName} READ #{stream}" do |res|
|
148
|
-
res =~ /^ALTER APPLICATION #{@appName} READ #{stream} (.*)$/m
|
149
|
-
block.call $1
|
150
|
-
end
|
151
|
-
else
|
152
|
-
sendCMD "ALTER APPLICATION #{@appName} READ #{stream}"
|
153
|
-
end
|
154
|
-
end
|
155
|
-
def disconnect stream
|
156
|
-
sendEcho "ALTER APPLICATION #{@appName} DISCONNECT #{stream}"
|
157
|
-
end
|
158
|
-
def delete
|
159
|
-
sendEcho "DELETE APPLICATION #{@appName}"
|
160
|
-
delNotify /^APPLICATION #{appName} (.+)$/
|
161
|
-
end
|
162
|
-
|
163
|
-
def onEvent name,cb=Proc.new
|
164
|
-
@eventListener[name] = cb
|
165
|
-
end
|
166
|
-
|
167
|
-
def receiv res
|
168
|
-
case res
|
169
|
-
when /^CONNECTING (.+)$/m
|
170
|
-
@eventListener[:connecting].call $1.split(" ") if @eventListener[:connecting]
|
171
|
-
when /^STREAMS (.+)$/m
|
172
|
-
@eventListener[:connected].call $1.split(" ") if @eventListener[:connected]
|
173
|
-
when /^RECEIVED (.+)$/m
|
174
|
-
@eventListener[:received].call streamByte2hash($1.split(" ")) if @eventListener[:received]
|
175
|
-
when /^READ (.+?) (.+)$/m
|
176
|
-
@eventListener[:read].call $1, $2 if @eventListener[:read]
|
177
|
-
when /^DATAGRAM (.+?) (.+)$/m
|
178
|
-
@eventListener[:datagram].call $1, $2 if @eventListener[:datagram]
|
179
|
-
when /^SENDING (.+?)$/m
|
180
|
-
@eventListener[:sending].call streamByte2hash($1.split(" ")) if @eventListener[:sending]
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
private
|
185
|
-
def streamByte2hash arr
|
186
|
-
ret = Hash.new do |hash,key|
|
187
|
-
hash[key] = 0
|
188
|
-
end
|
189
|
-
arr.each do |streamByte|
|
190
|
-
streamByte = streamByte.split "="
|
191
|
-
ret[streamByte[0]] = streamByte[1].to_i
|
192
|
-
end
|
193
|
-
return ret
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
class A2AEx < A2A
|
198
|
-
TRANS_LIMIT = 65000
|
199
|
-
SPLIT_LIMIT = 65000-2
|
200
|
-
|
201
|
-
extend Forwardable
|
202
|
-
include SkypeAPI::ShareFunctions
|
203
|
-
def initialize appName,base
|
204
|
-
super
|
205
|
-
@handle2stream = Hash.new
|
206
|
-
@sndBuffer = Hash.new do |hash,key|
|
207
|
-
hash[key] = Array.new
|
208
|
-
end
|
209
|
-
@rcvBuffer = Hash.new do |hash,key|
|
210
|
-
hash[key] = Array.new
|
211
|
-
end
|
212
|
-
@created = false
|
213
|
-
end
|
214
|
-
|
215
|
-
attr_reader :created, :sndBuffer, :rcvBuffer
|
216
|
-
|
217
|
-
def getStreams
|
218
|
-
streams = super
|
219
|
-
streamTreat streams
|
220
|
-
return @handle2stream.keys
|
221
|
-
end
|
222
|
-
|
223
|
-
def getConnection
|
224
|
-
@handle2stream.keys
|
225
|
-
end
|
226
|
-
|
227
|
-
def create
|
228
|
-
super
|
229
|
-
@created = true
|
230
|
-
end
|
231
|
-
|
232
|
-
def connect handles=getConnection
|
233
|
-
handles = [handles] unless handles.class == Array
|
234
|
-
handles.each do |handle|
|
235
|
-
super handle
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
def connectAndWait handles
|
240
|
-
waitFlag = false
|
241
|
-
@base.addNotify /^APPLICATION #{@appName} CONNECTING $/,(Proc.new do
|
242
|
-
waitFlag = true
|
243
|
-
end)
|
244
|
-
handles = [handles] unless handles.class == Array
|
245
|
-
handles.each do |handle|
|
246
|
-
sendCMD "ALTER APPLICATION #{@appName} CONNECT #{handle}"
|
247
|
-
end
|
248
|
-
|
249
|
-
startTime = Time.now
|
250
|
-
i = 0
|
251
|
-
loop do
|
252
|
-
@base.polling
|
253
|
-
break if waitFlag or Time.now - startTime > 3
|
254
|
-
sleep 0.001
|
255
|
-
i+=1
|
256
|
-
end
|
257
|
-
@base.delNotify /^APPLICATION #{@appName} CONNECTING $/
|
258
|
-
end
|
259
|
-
|
260
|
-
def disconnect handles=getStreams
|
261
|
-
handles = [handles] unless handles.class == Array
|
262
|
-
handles.each do |h|
|
263
|
-
begin
|
264
|
-
super @handle2stream[h]
|
265
|
-
@handle2stream.delete h
|
266
|
-
rescue =>e
|
267
|
-
p e
|
268
|
-
end
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
def transmit cmd, handles=getConnecting
|
273
|
-
handles = [handles] unless handles == Array
|
274
|
-
handles.each do |handle|
|
275
|
-
if cmd.size > SPLIT_LIMIT
|
276
|
-
tmp = Array.new
|
277
|
-
while cmd.size > SPLIT_LIMIT
|
278
|
-
tmp.push cmd[0,SPLIT_LIMIT] + "D"
|
279
|
-
cmd = cmd[SPLIT_LIMIT,cmd.length]
|
280
|
-
end
|
281
|
-
tmp.push cmd
|
282
|
-
cmd = tmp
|
283
|
-
else
|
284
|
-
cmd = [cmd]
|
285
|
-
end
|
286
|
-
handle = [handle] unless handle.class == Array
|
287
|
-
handle.each do |h|
|
288
|
-
@sndBuffer[h].concat cmd
|
289
|
-
end
|
290
|
-
end
|
291
|
-
end
|
292
|
-
|
293
|
-
def polling
|
294
|
-
if @created
|
295
|
-
f = false
|
296
|
-
@sndBuffer.each_value do |buffer|
|
297
|
-
if buffer.length > 0
|
298
|
-
f = true
|
299
|
-
break
|
300
|
-
end
|
301
|
-
end
|
302
|
-
if f
|
303
|
-
h2b = getSending
|
304
|
-
streams = Hash.new
|
305
|
-
@sndBuffer.each do |handle,buffer|
|
306
|
-
if @handle2stream[handle]
|
307
|
-
while buffer.length > 0
|
308
|
-
if buffer[0].size + h2b[handle] < TRANS_LIMIT
|
309
|
-
h2b[handle] += buffer[0].size
|
310
|
-
write handle,buffer.shift do |res|
|
311
|
-
#do nothing
|
312
|
-
end
|
313
|
-
else
|
314
|
-
break
|
315
|
-
end
|
316
|
-
end
|
317
|
-
end
|
318
|
-
end
|
319
|
-
end
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
|
-
def read handle, &block
|
324
|
-
handle = @handle2stream[handle]
|
325
|
-
unless handle
|
326
|
-
raise SkypeAPIError, "Read Error nonConnecting #{handle}"
|
327
|
-
else
|
328
|
-
super
|
329
|
-
end
|
330
|
-
end
|
331
|
-
|
332
|
-
def write handle, cmd, &block
|
333
|
-
stream = @handle2stream[handle]
|
334
|
-
unless stream
|
335
|
-
raise SkypeAPIError,"Write Error nonConnecting #{handle} #{cmd}"
|
336
|
-
else
|
337
|
-
super stream, cmd, &block
|
338
|
-
end
|
339
|
-
end
|
340
|
-
|
341
|
-
def datagram handle, cmd
|
342
|
-
handle = @handle2stream[handle]
|
343
|
-
super
|
344
|
-
end
|
345
|
-
|
346
|
-
private :write, :datagram, :read
|
347
|
-
|
348
|
-
def receiv res
|
349
|
-
case res
|
350
|
-
when /^CONNECTING (.*)$/m
|
351
|
-
@eventListener[:connecting].call $1.split(" ") if @eventListener[:connecting]
|
352
|
-
when /^STREAMS (.*)$/m
|
353
|
-
streams = $1.split " "
|
354
|
-
streamTreat streams
|
355
|
-
@eventListener[:connected].call @handle2stream.keys if @eventListener[:connected]
|
356
|
-
when /^RECEIVED (.+)$/m
|
357
|
-
res = $1
|
358
|
-
res.split(" ").each do |info|
|
359
|
-
stream = info.split("=")[0]
|
360
|
-
byte = info.split("=")[1]
|
361
|
-
handle = info.split(":")[0]
|
362
|
-
read handle do |content|
|
363
|
-
if content and not content.empty?
|
364
|
-
if content.size > SPLIT_LIMIT
|
365
|
-
@rcvBuffer[handle].push content[0,content.size-1]
|
366
|
-
else
|
367
|
-
if @rcvBuffer.length > 0
|
368
|
-
@rcvBuffer[handle].push content
|
369
|
-
tmp = @rcvBuffer[handle].join ""
|
370
|
-
@rcvBuffer[handle].clear
|
371
|
-
@eventListener[:read].call handle, tmp if @eventListener[:read]
|
372
|
-
else
|
373
|
-
@eventListener[:read].call handle, content if @eventListener[:read]
|
374
|
-
end
|
375
|
-
end
|
376
|
-
end
|
377
|
-
end
|
378
|
-
end
|
379
|
-
@eventListener[:received].call streamByte2hash(res.split(" ")) if @eventListener[:received] and res
|
380
|
-
when /^READ (.+?) (.+)$/m
|
381
|
-
#@eventListener[:read].call $1.split(":")[0], $2 if @eventListener[:read]
|
382
|
-
when /^DATAGRAM (.+?) (.+)$/m
|
383
|
-
@eventListener[:datagram].call $1.split(":")[0], $2 if @eventListener[:datagram]
|
384
|
-
when /^SENDING (.+?)$/m
|
385
|
-
@eventListener[:sending].call streamByte2hash($1.split(" ")) if @eventListener[:sending]
|
386
|
-
end
|
387
|
-
end
|
388
|
-
|
389
|
-
private
|
390
|
-
def streamTreat streams
|
391
|
-
@handle2stream.each do |handle,stream|
|
392
|
-
unless streams.include? stream
|
393
|
-
@sndBuffer[handle].clear
|
394
|
-
@rcvBuffer[handle].clear
|
395
|
-
end
|
396
|
-
end
|
397
|
-
@handle2stream.clear
|
398
|
-
streams.each do |st|
|
399
|
-
@handle2stream[st.split(":")[0]] = st
|
400
|
-
end
|
401
|
-
end
|
402
|
-
|
403
|
-
def streamByte2hash arr
|
404
|
-
ret = Hash.new do |hash, key|
|
405
|
-
hash[key] = 0
|
406
|
-
end
|
407
|
-
arr.each do |streamByte|
|
408
|
-
streamByte = streamByte.split "="
|
409
|
-
ret[streamByte[0].split(":")[0]] = streamByte[1].to_i
|
410
|
-
end
|
411
|
-
return ret
|
412
|
-
end
|
413
|
-
end
|
414
100
|
end
|
415
101
|
end
|
data/lib/skypeapi/call.rb
CHANGED
@@ -4,14 +4,13 @@ module SkypeAPI
|
|
4
4
|
OBJECT_NAME = "CALL"
|
5
5
|
|
6
6
|
def self.create *targets
|
7
|
-
targets = targets[0] if targets[0].class == Array
|
8
7
|
res = (@@skypeApi.sendOne "CALL " + targets.join(", "),"CALL").split(" ")
|
9
8
|
#return @@skypeApi.call(res[0]),res[2]
|
10
9
|
new res[0]
|
11
10
|
end
|
12
11
|
|
13
12
|
getter :Timestamp, 'TIMESTAMP' do |str|
|
14
|
-
str.to_i
|
13
|
+
if str.empty? then nil else Time.at(str.to_i) end
|
15
14
|
end
|
16
15
|
getter :Partner, 'PARTNER_HANDLE' do |str|
|
17
16
|
@@skypeApi.user str
|
@@ -45,10 +44,10 @@ module SkypeAPI
|
|
45
44
|
res
|
46
45
|
end
|
47
46
|
#?
|
48
|
-
def getConfParticipant
|
49
|
-
str = sendGet "CONF_PARTICIPANT #{
|
47
|
+
def getConfParticipant num
|
48
|
+
str = sendGet "CONF_PARTICIPANT #{num}"
|
50
49
|
array = self::V2O[:ConfParticipant].call str
|
51
|
-
array.unshift
|
50
|
+
array.unshift num.to_s
|
52
51
|
array
|
53
52
|
end
|
54
53
|
|
@@ -82,16 +81,16 @@ module SkypeAPI
|
|
82
81
|
getter :TransferredBy, 'TRANSFERRED_BY'
|
83
82
|
getter :TransferredTo, 'TRANSFERRED_TO'
|
84
83
|
|
84
|
+
def getCanTransfer user
|
85
|
+
res = sendGet "CAN_TRANSFER #{user}"
|
86
|
+
V2O[:CanTransffer].call(user.to_s + ' ' + res)
|
87
|
+
end
|
85
88
|
notice :CanTransffer, 'CAN_TRANSFER' do |str|
|
86
89
|
res = str.split ' '
|
87
90
|
res[0] = @@skypeApi.user res[0]
|
88
91
|
res[1] = res[1]._flag
|
89
92
|
res
|
90
93
|
end
|
91
|
-
def getCanTransfer user
|
92
|
-
res = sendGet "CAN_TRANSFER #{user}"
|
93
|
-
V2O[:CanTransffer].call(user.to_s + ' ' + res)
|
94
|
-
end
|
95
94
|
|
96
95
|
getter :Seen, "SEEN" do |str|
|
97
96
|
str._flag
|
@@ -127,12 +126,12 @@ module SkypeAPI
|
|
127
126
|
setStatus "FINISHED"
|
128
127
|
end
|
129
128
|
|
130
|
-
def setDTMF
|
131
|
-
sendSet "DTMF #{
|
129
|
+
def setDTMF number
|
130
|
+
sendSet "DTMF #{number}"
|
132
131
|
end
|
133
132
|
|
134
|
-
def setJoinConference
|
135
|
-
sendSet "JOIN_CONFERENCE",
|
133
|
+
def setJoinConference masterCall
|
134
|
+
sendSet "JOIN_CONFERENCE", masterCall.to_s
|
136
135
|
end
|
137
136
|
|
138
137
|
def setStartVideoSend
|
@@ -171,8 +170,8 @@ module SkypeAPI
|
|
171
170
|
sendAlter "END", val
|
172
171
|
end
|
173
172
|
|
174
|
-
def dtmf
|
175
|
-
sendAlter "DTMF",
|
173
|
+
def dtmf number
|
174
|
+
sendAlter "DTMF", number
|
176
175
|
end
|
177
176
|
|
178
177
|
def transfer *users
|
@@ -199,16 +198,16 @@ module SkypeAPI
|
|
199
198
|
sendAlter"STOP_VIDEO_RECEIVE"
|
200
199
|
end
|
201
200
|
|
202
|
-
def setInput
|
203
|
-
sendAlter "SET_INPUT",
|
201
|
+
def setInput device
|
202
|
+
sendAlter "SET_INPUT", device
|
204
203
|
end
|
205
204
|
|
206
|
-
def setOutput
|
207
|
-
sendAlter "SET_INPUT",
|
205
|
+
def setOutput device
|
206
|
+
sendAlter "SET_INPUT", device
|
208
207
|
end
|
209
208
|
|
210
|
-
def setCaptureMic
|
211
|
-
sendAlter "SET_CAPUTURE_MIC",
|
209
|
+
def setCaptureMic device
|
210
|
+
sendAlter "SET_CAPUTURE_MIC", device
|
212
211
|
end
|
213
212
|
|
214
213
|
|
data/lib/skypeapi/chat.rb
CHANGED
@@ -3,9 +3,30 @@ module SkypeAPI
|
|
3
3
|
class Chat < AbstractObject
|
4
4
|
OBJECT_NAME = "CHAT"
|
5
5
|
|
6
|
+
def self.create *users
|
7
|
+
retVal = @@skypeApi.sendCMD "CHAT CREATE #{users.join(', ')}"
|
8
|
+
retVal =~ /^CHAT ([^ ]+) STATUS (.+)$/
|
9
|
+
chatID, status = $1, $2
|
10
|
+
return @@skypeApi.chat(chatID)#, status
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.findUsingBlob blob
|
14
|
+
retVal = @@skypeApi.sendCMD "CHAT FINDUSINGBLOB #{blob}"
|
15
|
+
retVal =~ /^CHAT ([^ ]+) STATUS (.+)$/
|
16
|
+
chatID, status = $1, $2
|
17
|
+
return @@skypeApi.chat(chatID)#, status
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.createUsingBlob blob
|
21
|
+
retVal = @@skypeApi.sendCMD "CHAT CREATEUSINGBLOB #{blob}"
|
22
|
+
retVal =~ /^CHAT ([^ ]+) STATUS (.+)$/
|
23
|
+
chatID, status = $1, $2
|
24
|
+
return @@skypeApi.chat(chatID)#, status
|
25
|
+
end
|
26
|
+
|
6
27
|
getter :Name, 'NAME'
|
7
28
|
getter :Timestamp, 'TIMESTAMP' do |str|
|
8
|
-
str.to_i
|
29
|
+
if str.empty? then nil else Time.at(str.to_i) end
|
9
30
|
end
|
10
31
|
getter :Adder, 'ADDER' do |str|
|
11
32
|
str.empty? ? nil : @@skypeApi.user(str)
|
@@ -61,7 +82,7 @@ module SkypeAPI
|
|
61
82
|
end
|
62
83
|
end
|
63
84
|
getter :ActivityTimestamp, 'ACTIVITY_TIMESTAMP' do |str|
|
64
|
-
str.to_i
|
85
|
+
if str.empty? then nil else Time.at(str.to_i) end
|
65
86
|
end
|
66
87
|
getter :Type, 'TYPE'
|
67
88
|
getter :MyStatus, 'MYSTATUS'
|
@@ -72,29 +93,7 @@ module SkypeAPI
|
|
72
93
|
@@skypeApi.user handle
|
73
94
|
end
|
74
95
|
end
|
75
|
-
|
76
|
-
|
77
|
-
def self.create *users
|
78
|
-
retVal = @@skypeApi.sendCMD "CHAT CREATE #{users.join(', ')}"
|
79
|
-
retVal =~ /^CHAT ([^ ]+) STATUS (.+)$/
|
80
|
-
chatID, status = $1, $2
|
81
|
-
return @@skypeApi.chat(chatID)#, status
|
82
|
-
end
|
83
|
-
|
84
|
-
def self.findUsingBlob blob
|
85
|
-
retVal = @@skypeApi.sendCMD "CHAT FINDUSINGBLOB #{blob}"
|
86
|
-
retVal =~ /^CHAT ([^ ]+) STATUS (.+)$/
|
87
|
-
chatID, status = $1, $2
|
88
|
-
return @@skypeApi.chat(chatID)#, status
|
89
|
-
end
|
90
|
-
|
91
|
-
def self.createUsingBlob blob
|
92
|
-
retVal = @@skypeApi.sendCMD "CHAT CREATEUSINGBLOB #{blob}"
|
93
|
-
retVal =~ /^CHAT ([^ ]+) STATUS (.+)$/
|
94
|
-
chatID, status = $1, $2
|
95
|
-
return @@skypeApi.chat(chatID)#, status
|
96
|
-
end
|
97
|
-
|
96
|
+
|
98
97
|
#���[
|
99
98
|
#def open
|
100
99
|
# retVal = sendCMD "OPEN CHAT #{@id}"
|
@@ -102,16 +101,16 @@ module SkypeAPI
|
|
102
101
|
# return @@skypeApi.chat($1)
|
103
102
|
#end
|
104
103
|
|
105
|
-
def setTopic
|
106
|
-
sendAlter "SETTOPIC",
|
104
|
+
def setTopic topic
|
105
|
+
sendAlter "SETTOPIC", topic
|
107
106
|
end
|
108
107
|
|
109
|
-
def setTopicXML
|
110
|
-
sendAlter "SETTOPICXML",
|
108
|
+
def setTopicXML topic
|
109
|
+
sendAlter "SETTOPICXML", topic
|
111
110
|
end
|
112
111
|
|
113
|
-
def addMembers *
|
114
|
-
sendAlter "ADDMEMBERS",
|
112
|
+
def addMembers *members
|
113
|
+
sendAlter "ADDMEMBERS", members.join(', ')
|
115
114
|
end
|
116
115
|
|
117
116
|
def leave
|
@@ -135,8 +134,8 @@ module SkypeAPI
|
|
135
134
|
sendAlter "CLEARRECENTMESSAGES"
|
136
135
|
end
|
137
136
|
|
138
|
-
def setAlertString
|
139
|
-
sendAlter "SETALERTSTRING",
|
137
|
+
def setAlertString string
|
138
|
+
sendAlter "SETALERTSTRING", string
|
140
139
|
end
|
141
140
|
|
142
141
|
def acceptadd
|
@@ -148,7 +147,7 @@ module SkypeAPI
|
|
148
147
|
end
|
149
148
|
|
150
149
|
|
151
|
-
def setPassword
|
150
|
+
def setPassword(password,passwordHint='')
|
152
151
|
sendAlter "SETPASSWORD", password + ' ' + passwordHint
|
153
152
|
end
|
154
153
|
|
data/lib/skypeapi/chatmessage.rb
CHANGED
@@ -3,8 +3,8 @@ module SkypeAPI
|
|
3
3
|
class ChatMessage < AbstractObject
|
4
4
|
OBJECT_NAME = "CHATMESSAGE"
|
5
5
|
|
6
|
-
def self.create
|
7
|
-
res = @@skypeApi.sendCMD "CHATMESSAGE #{
|
6
|
+
def self.create chat ,msg
|
7
|
+
res = @@skypeApi.sendCMD "CHATMESSAGE #{chat} #{msg}"
|
8
8
|
if res =~ /^CHATMESSAGE (\d+) STATUS (.+)$/
|
9
9
|
return @@skypeApi.chatMessage($1)#, $2
|
10
10
|
else
|
@@ -14,7 +14,7 @@ module SkypeAPI
|
|
14
14
|
|
15
15
|
getter :Body, 'BODY'
|
16
16
|
getter :Timestamp, 'TIMESTAMP' do |str|
|
17
|
-
str.to_i
|
17
|
+
if str.empty? then nil else Time.at(str.to_i) end
|
18
18
|
end
|
19
19
|
getter :Partner, 'PARTNER_HANDLE' do |str|
|
20
20
|
@@skypeApi.user str
|
@@ -39,10 +39,10 @@ module SkypeAPI
|
|
39
39
|
str._flag
|
40
40
|
end
|
41
41
|
getter :EditedBy, 'EDITED_BY' do |str|
|
42
|
-
str.empty?
|
42
|
+
if str.empty? then nil else @@skypeApi.user(str) end
|
43
43
|
end
|
44
44
|
getter :EditedTimestamp, 'EDITED_TIMESTAMP' do |str|
|
45
|
-
str.to_i
|
45
|
+
if str.empty? then nil else Time.at(str.to_i) end
|
46
46
|
end
|
47
47
|
getter :Options, 'OPTIONS' do |str|
|
48
48
|
str.to_i
|
@@ -58,7 +58,7 @@ module SkypeAPI
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
def setBody
|
61
|
+
def setBody(text) sendSet('BODY',text._str); end
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
data/lib/skypeapi/event.rb
CHANGED
@@ -11,10 +11,10 @@ module SkypeAPI
|
|
11
11
|
end
|
12
12
|
getter :PartnerDispname, 'PARTNER_DISPNAME'
|
13
13
|
getter :StartTime, 'STARTTIME' do |str|
|
14
|
-
str.to_i
|
14
|
+
if str.empty? then nil else Time.at(str.to_i) end
|
15
15
|
end
|
16
16
|
getter :FinishTime, 'FINISHTIME' do |str|
|
17
|
-
str.to_i
|
17
|
+
if str.empty? then nil else Time.at(str.to_i) end
|
18
18
|
end
|
19
19
|
getter :FilePath, 'FILEPATH'
|
20
20
|
getter :FileSize, 'FILESIZE' do |str|
|
data/lib/skypeapi/group.rb
CHANGED
@@ -3,14 +3,14 @@ module SkypeAPI
|
|
3
3
|
class Group < AbstractObject
|
4
4
|
OBJECT_NAME = "GROUP"
|
5
5
|
|
6
|
-
def self.create
|
7
|
-
@@skypeApi.sendCMD("CREATE GROUP #{
|
6
|
+
def self.create displayName
|
7
|
+
@@skypeApi.sendCMD("CREATE GROUP #{displayName}")
|
8
8
|
group = nil
|
9
9
|
tmp = nil
|
10
|
-
if @@skypeApi.Group.notify[:displayname] and @@skypeApi.Group.notify[:displayname][
|
11
|
-
tmp = @@skypeApi.Group.notify[:displayname][
|
10
|
+
if @@skypeApi.Group.notify[:displayname] and @@skypeApi.Group.notify[:displayname][displayName]
|
11
|
+
tmp = @@skypeApi.Group.notify[:displayname][displayName]
|
12
12
|
end
|
13
|
-
@@skypeApi.Group.setNotify :DisplayName,
|
13
|
+
@@skypeApi.Group.setNotify :DisplayName, displayName do |g|
|
14
14
|
group = g
|
15
15
|
end
|
16
16
|
until group
|
@@ -18,10 +18,10 @@ module SkypeAPI
|
|
18
18
|
sleep 0.0123
|
19
19
|
end
|
20
20
|
if tmp
|
21
|
-
@@skypeApi.Group.setNotify :DisplayName,
|
21
|
+
@@skypeApi.Group.setNotify :DisplayName, displayName, tmp
|
22
22
|
tmp.call group
|
23
23
|
else
|
24
|
-
@@skypeApi.Group.notify[:displayname][
|
24
|
+
@@skypeApi.Group.notify[:displayname][displayName] = nil
|
25
25
|
end
|
26
26
|
group
|
27
27
|
#ThreadSafe ����ς��낤�Ȃ��B�B�B
|
@@ -48,8 +48,8 @@ module SkypeAPI
|
|
48
48
|
str._flag
|
49
49
|
end
|
50
50
|
|
51
|
-
def setDisplayName
|
52
|
-
sendSet "DISPLAYNAME",
|
51
|
+
def setDisplayName dispname
|
52
|
+
sendSet "DISPLAYNAME", dispname
|
53
53
|
end
|
54
54
|
|
55
55
|
def delete
|
@@ -64,8 +64,8 @@ module SkypeAPI
|
|
64
64
|
sendAlter "REMOVEUSER", user
|
65
65
|
end
|
66
66
|
|
67
|
-
def share
|
68
|
-
sendAlter "Share",
|
67
|
+
def share msg=''
|
68
|
+
sendAlter "Share", msg
|
69
69
|
end
|
70
70
|
|
71
71
|
def accept
|
data/lib/skypeapi/menuitem.rb
CHANGED
@@ -4,7 +4,7 @@ module SkypeAPI
|
|
4
4
|
OBJECT_NAME = 'MENU_ITEM'
|
5
5
|
|
6
6
|
def self.create h, block=Proc.new
|
7
|
-
raise ArgumentError unless h[:id] and h[:context] and h[:
|
7
|
+
raise ArgumentError unless h[:id] and h[:context] and h[:caption]
|
8
8
|
#id, context, caption, hint=nil, icon=nil, enabled=nil, enableMultipleContacts=nil, &block
|
9
9
|
res = @@skypeApi.sendCMD "CREATE MENU_ITEM #{h[:id]} CONTEXT #{h[:context]} CAPTION #{h[:caption]}#{h[:hint].nil? ? '' : " HINT #{h[:hint]}"}#{h[:icon].nil? ? '' : " ICON #{h[:icon]}"}#{h[:enable].nil? ? '' : " ENABLED #{h[:enabled]}"}#{h[:enableMultipleContacts].nil? ? '' : " ENABLE_MULTIPLE_CONTACTS #{h[:enableMultipleContacts]}"}"
|
10
10
|
res == "MENU_ITEM #{h[:id]} CREATED"
|
@@ -45,19 +45,19 @@ module SkypeAPI
|
|
45
45
|
res == "DELETE MENU_ITEM #{@id}"
|
46
46
|
end
|
47
47
|
|
48
|
-
def setCaption
|
49
|
-
res = sendCMD "SET MENU_ITEM #{@id} CAPTION #{
|
50
|
-
res == "MENU_ITEM #{@id} CAPTION \"#{
|
48
|
+
def setCaption caption
|
49
|
+
res = sendCMD "SET MENU_ITEM #{@id} CAPTION #{caption}"
|
50
|
+
res == "MENU_ITEM #{@id} CAPTION \"#{caption}\""
|
51
51
|
end
|
52
52
|
|
53
|
-
def setHint
|
54
|
-
res = sendCMD "SET MENU_ITEM #{@id} HINT #{
|
55
|
-
res == "MENU_ITEM #{@id} HINT \"#{
|
53
|
+
def setHint hint
|
54
|
+
res = sendCMD "SET MENU_ITEM #{@id} HINT #{hint}"
|
55
|
+
res == "MENU_ITEM #{@id} HINT \"#{hint}\""
|
56
56
|
end
|
57
57
|
|
58
|
-
def setEnabled
|
59
|
-
res = sendCMD "SET MENU_ITEM #{@id} ENABLED #{
|
60
|
-
res == "MENU_ITEM #{@id} ENABLED #{
|
58
|
+
def setEnabled flag
|
59
|
+
res = sendCMD "SET MENU_ITEM #{@id} ENABLED #{flag._str}"
|
60
|
+
res == "MENU_ITEM #{@id} ENABLED #{flag._str}"
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
data/lib/skypeapi/object.rb
CHANGED
@@ -40,6 +40,11 @@ module SkypeAPI
|
|
40
40
|
str = sendGet skypeProperty
|
41
41
|
callBack ? callBack.call(str) : str
|
42
42
|
end
|
43
|
+
|
44
|
+
#code4doc
|
45
|
+
#className = (defined? self::OBJECT_NAME) ? self::OBJECT_NAME : ''#'SkypeAPI'
|
46
|
+
#puts "'" + className + "::" + 'get' + methodName.to_s + "',"
|
47
|
+
|
43
48
|
self::P2M[skypeProperty] = methodName.to_sym
|
44
49
|
self::V2O[skypeProperty] = callBack if callBack
|
45
50
|
end
|
@@ -69,8 +74,10 @@ module SkypeAPI
|
|
69
74
|
#Class P2M
|
70
75
|
#Instance P2M �ŃA�N�Z�X�B
|
71
76
|
def self.inherited sub
|
72
|
-
|
73
|
-
|
77
|
+
if self == AbstractObject
|
78
|
+
sub.const_set :P2M, Hash.new{|hash,key| hash[key] = key}
|
79
|
+
sub.const_set :V2O, Hash.new
|
80
|
+
end
|
74
81
|
sub.instance_variable_set :@notify, Hash.new
|
75
82
|
end
|
76
83
|
|
@@ -100,7 +107,9 @@ module SkypeAPI
|
|
100
107
|
return @@instance[self][id]
|
101
108
|
else
|
102
109
|
instance = super id
|
103
|
-
instance.instance_variable_set
|
110
|
+
instance.instance_variable_set(:@notify, Hash.new do |h,k|
|
111
|
+
h[k] = Hash.new
|
112
|
+
end)
|
104
113
|
@@instance[self][id] = instance
|
105
114
|
return instance
|
106
115
|
end
|
data/lib/skypeapi/os.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module SkypeAPI
|
2
2
|
module OS
|
3
3
|
module Share
|
4
|
-
WAIT_CMD_LIMIT =
|
4
|
+
WAIT_CMD_LIMIT = 30.0 #sec
|
5
5
|
PING_CYCLE = 30.0 #sec
|
6
6
|
PING_LIMIT = 10.0 # < PING_CYCLE
|
7
|
+
SLEEP_INTERVAL = 0.001
|
7
8
|
|
8
9
|
def sendCMD cmd,method=nil,&block
|
9
10
|
if method
|
@@ -62,7 +63,8 @@ module SkypeAPI
|
|
62
63
|
end
|
63
64
|
end
|
64
65
|
#Thread.pass
|
65
|
-
sleep
|
66
|
+
sleep SLEEP_INTERVAL
|
67
|
+
#sleep 0.00123
|
66
68
|
#sleep 0.000001
|
67
69
|
#sleep 0.01
|
68
70
|
end
|
@@ -75,6 +77,7 @@ module SkypeAPI
|
|
75
77
|
end
|
76
78
|
while flag
|
77
79
|
polling
|
80
|
+
sleep SLEEP_INTERVAL
|
78
81
|
#sleep 0.0123
|
79
82
|
end
|
80
83
|
end
|
@@ -141,33 +144,37 @@ module SkypeAPI
|
|
141
144
|
end
|
142
145
|
|
143
146
|
def pushQueue res
|
147
|
+
@queue.push(proc{doEvent(:received, res.chop)}) if existEvent? :received
|
148
|
+
|
144
149
|
if res =~ /^(#(\d+?) )?(.+?)\000$/m
|
145
150
|
if $2
|
146
151
|
if @callBack[$2.to_i]
|
147
152
|
cb = @callBack[$2.to_i]
|
148
153
|
val = $3
|
149
|
-
@
|
154
|
+
if @singleThread
|
155
|
+
@sent = proc{cb.call val}
|
156
|
+
else
|
157
|
+
@queue.push(proc{cb.call val})
|
158
|
+
end
|
150
159
|
@callBack.delete($2.to_i)
|
151
160
|
end
|
152
|
-
cmd = "#" + $2 + " " + $3
|
153
161
|
else
|
154
162
|
cmd = $3
|
155
163
|
flag = false
|
156
164
|
@notify.each do |reg,action|
|
157
165
|
if cmd =~ reg
|
158
|
-
|
159
|
-
@queue.push(proc{action.call(
|
166
|
+
tmp = $1
|
167
|
+
@queue.push(proc{action.call(tmp)})
|
160
168
|
flag = true
|
161
169
|
end
|
162
170
|
end
|
171
|
+
|
163
172
|
unless flag
|
164
173
|
action = @notify[nil]
|
165
174
|
@queue.push(proc{action.call(cmd)})
|
166
175
|
end
|
167
176
|
end
|
168
177
|
end
|
169
|
-
|
170
|
-
@queue.push(proc{doEvent(:received, cmd)}) if existEvent? :received
|
171
178
|
end
|
172
179
|
|
173
180
|
def queueProcess
|
@@ -177,8 +184,19 @@ module SkypeAPI
|
|
177
184
|
@pingTime = Time.now
|
178
185
|
end
|
179
186
|
|
180
|
-
|
181
|
-
|
187
|
+
if @singleThread
|
188
|
+
if @sent == nil
|
189
|
+
while e = @queue.shift
|
190
|
+
e.call
|
191
|
+
end
|
192
|
+
elsif(@sent.class == Proc)
|
193
|
+
@sent.call
|
194
|
+
@sent = nil
|
195
|
+
end
|
196
|
+
else
|
197
|
+
while e = @queue.shift
|
198
|
+
e.call
|
199
|
+
end
|
182
200
|
end
|
183
201
|
end
|
184
202
|
|
@@ -203,7 +221,7 @@ module SkypeAPI
|
|
203
221
|
raise SkypeAPIError::TimeOut
|
204
222
|
end
|
205
223
|
i+=1
|
206
|
-
sleep
|
224
|
+
sleep SLEEP_INTERVAL
|
207
225
|
end
|
208
226
|
rescue SkypeAPIError::Reconnect,SkypeAPIError::TimeOut
|
209
227
|
unless existEvent? :reconnect
|
@@ -249,6 +267,7 @@ module SkypeAPI
|
|
249
267
|
@event = Hash.new do |h,k|
|
250
268
|
h[k] = Array.new
|
251
269
|
end
|
270
|
+
@singleThread = true
|
252
271
|
|
253
272
|
addEvent :reconnect do
|
254
273
|
flag = true
|
@@ -284,28 +303,23 @@ module SkypeAPI
|
|
284
303
|
@queue.push Proc.new{@skypeAPI.sendCMD "PROTOCOL 9999"}
|
285
304
|
@queue.push Proc.new{@skypeAPI.doEvent(:attach,:success)}
|
286
305
|
@queue.push Proc.new{@skypeAPI.doEvent(:attached)}
|
287
|
-
sMsg.retval = 1
|
288
306
|
when SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
|
289
307
|
@queue.push Proc.new{@skypeAPI.doEvent(:attach,:authorize)}
|
290
308
|
@queue.push Proc.new{@skypeAPI.doEvent(:pendingAuthorization)}
|
291
|
-
sMsg.retval = 1
|
292
309
|
when SKYPECONTROLAPI_ATTACH_REFUSED:
|
293
310
|
unless @skypeAPI.existEvent? :attach
|
294
311
|
raise SkypeAPIError::Attach,"Refused"
|
295
312
|
else
|
296
313
|
@queue.push Proc.new{@skypeAPI.doEvent(:attach,:refused)}
|
297
314
|
end
|
298
|
-
sMsg.retval = 1
|
299
315
|
when SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE:
|
300
316
|
unless @skypeAPI.existEvent? :attach
|
301
317
|
raise SkypeAPIError::Attach,"Not available."
|
302
318
|
else
|
303
319
|
@queue.push Proc.new{@skypeAPI.doEvent(:attach,:notAvailable)}
|
304
320
|
end
|
305
|
-
sMsg.retval = 1
|
306
321
|
when SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
|
307
322
|
@queue.push Proc.new{@skypeAPI.doEvent(:apiAvailable)}
|
308
|
-
sMsg.retval = 1
|
309
323
|
else
|
310
324
|
unless @skypeAPI.existEvent? :attach
|
311
325
|
raise SkypeAPIError::Attach,"Skype API attach unknown message"
|
@@ -313,6 +327,7 @@ module SkypeAPI
|
|
313
327
|
@queue.push Proc.new{@skypeAPI.doEvent(:attach,:unkown)}
|
314
328
|
end
|
315
329
|
end
|
330
|
+
sMsg.retval = 1
|
316
331
|
#return true
|
317
332
|
when WM_COPYDATA
|
318
333
|
if sMsg.wParam == @hSkypeAPIWindowHandle
|
@@ -367,6 +382,7 @@ module SkypeAPI
|
|
367
382
|
|
368
383
|
cmd = '#' + @sendCount.to_s + ' ' + cmd
|
369
384
|
@wmBuffer[@sendCount] = cmd
|
385
|
+
@sent = true if @singleThread
|
370
386
|
pCopyData = @wmHandler.application.arg2cstructStr("LLS",0,@wmBuffer[@sendCount].length+1,@wmBuffer[@sendCount])
|
371
387
|
unless PostMessage.call(@wmHandler.hWnd, WM_USER_MSG, @wmHandler.hSkypeAPIWindowHandle, pCopyData)
|
372
388
|
@wmHandler.instance_variable_set :@hSkypeAPIWindowHandle,nil
|
data/lib/skypeapi/profile.rb
CHANGED
@@ -3,7 +3,9 @@ module SkypeAPI
|
|
3
3
|
class Profile < AbstractObject
|
4
4
|
OBJECT_NAME = "PROFILE"
|
5
5
|
|
6
|
-
|
6
|
+
def initialize(id=nil)
|
7
|
+
super nil
|
8
|
+
end
|
7
9
|
|
8
10
|
def self.notified msg
|
9
11
|
if msg =~ /^([^ ]+) (.*)$/m
|
@@ -73,51 +75,44 @@ module SkypeAPI
|
|
73
75
|
str.split(', ')
|
74
76
|
end
|
75
77
|
|
76
|
-
def setFullname(
|
77
|
-
def setBirthday(
|
78
|
-
val =
|
78
|
+
def setFullname(name) sendSet('FULLNAME', name); end
|
79
|
+
def setBirthday(dateOrYear, month=nil, day=nil)
|
80
|
+
val = dateOrYear.class == Date ? dateOrYear.strftime('%Y%m%d') : sprintf("%04d%02d%02d",dateOrYear,month,day)
|
79
81
|
sendSet('BIRTHDAY', val)
|
80
82
|
end
|
81
|
-
def setSex(
|
82
|
-
def setLanguages(*
|
83
|
-
|
84
|
-
val = val[0].join(' ')
|
85
|
-
else
|
86
|
-
val = val.join(' ')
|
87
|
-
end
|
88
|
-
sendSet('LANGUAGES', val)
|
83
|
+
def setSex(sex) sendSet('SEX', sex); end
|
84
|
+
def setLanguages(*langs)
|
85
|
+
sendSet('LANGUAGES', langs.join(' '))
|
89
86
|
end
|
90
|
-
def setCountry(
|
87
|
+
def setCountry(iso) sendSet('COUNTRY', iso); end
|
91
88
|
#def setIpcountry(val) sendSet('IPCOUNTRY', val); end
|
92
|
-
def setProvince
|
93
|
-
def setCity
|
94
|
-
def setPhoneHome
|
95
|
-
def setPhoneOffice
|
96
|
-
def setPhoneMobile
|
97
|
-
def setHomepage
|
98
|
-
def setAbout
|
99
|
-
def setMoodText
|
100
|
-
def setRichMoodText
|
101
|
-
def setTimezone
|
102
|
-
def setCallApplyCF
|
103
|
-
sendSet('CALL_APPLY_CF',
|
104
|
-
end
|
105
|
-
def setCallNoanswerTimeout
|
106
|
-
def setCallForwardRules(*
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
89
|
+
def setProvince(province) sendSet('PROVINCE', province); end
|
90
|
+
def setCity(city) sendSet('CITY', city); end
|
91
|
+
def setPhoneHome(numbers) sendSet('PHONE_HOME', numbers); end
|
92
|
+
def setPhoneOffice(numbers) sendSet('PHONE_OFFICE', numbers); end
|
93
|
+
def setPhoneMobile(numbers) sendSet('PHONE_MOBILE', numbers); end
|
94
|
+
def setHomepage(url) sendSet('HOMEPAGE', url); end
|
95
|
+
def setAbout(text) sendSet('ABOUT', text); end
|
96
|
+
def setMoodText(text) sendSet('MOOD_TEXT', text); end
|
97
|
+
def setRichMoodText(text) sendSet('RICH_MOOD_TEXT', text); end
|
98
|
+
def setTimezone(timezone) sendSet('TIMEZONE', timezone); end
|
99
|
+
def setCallApplyCF(flag)
|
100
|
+
sendSet('CALL_APPLY_CF', flag._str)
|
101
|
+
end
|
102
|
+
def setCallNoanswerTimeout(sec) sendSet('CALL_NOANSWER_TIMEOUT', sec); end
|
103
|
+
def setCallForwardRules(*rules)
|
104
|
+
if rules[0] == nil
|
105
|
+
sendSet('CALL_FORWARD_RULES', '')
|
106
|
+
else
|
107
|
+
rules.map! do |rule|
|
111
108
|
rule.join ','
|
112
109
|
end
|
113
|
-
|
114
|
-
sendSet('CALL_FORWARD_RULES',
|
115
|
-
else
|
116
|
-
sendSet('CALL_FORWARD_RULES', '')
|
110
|
+
rules = rules.join ' '
|
111
|
+
sendSet('CALL_FORWARD_RULES', rules)
|
117
112
|
end
|
118
113
|
end
|
119
|
-
def setCallSendToVM
|
120
|
-
sendSet('CALL_SEND_TO_VM',
|
114
|
+
def setCallSendToVM(flag)
|
115
|
+
sendSet('CALL_SEND_TO_VM', flag._str)
|
121
116
|
end
|
122
117
|
end
|
123
118
|
end
|
data/lib/skypeapi/sms.rb
CHANGED
@@ -28,7 +28,7 @@ module SkypeAPI
|
|
28
28
|
getter :FailureReason, 'FAILUREREASON'
|
29
29
|
getter :FailedUnseen?, 'IS_FAILED_UNSEEN'
|
30
30
|
getter :Timestamp, 'TIMESTAMP' do |str|
|
31
|
-
str.to_i
|
31
|
+
if str.empty? then nil else Time.at(str.to_i) end
|
32
32
|
end
|
33
33
|
getter :Price, 'PRICE' do |str|
|
34
34
|
str.to_i
|
data/lib/skypeapi/user.rb
CHANGED
@@ -44,7 +44,7 @@ module SkypeAPI
|
|
44
44
|
#getter :skypeOut, 'SkypeOut'
|
45
45
|
#getter :skypeMe, 'SKYPEME'
|
46
46
|
getter :LastOnlineTimestamp, 'LASTONLINETIMESTAMP' do |str|
|
47
|
-
str.
|
47
|
+
if str.empty? then nil else Time.at(str.to_i) end
|
48
48
|
end
|
49
49
|
getter :CanLeaveVM, 'CAN_LEAVE_VM' do |str|
|
50
50
|
str._flag
|
@@ -67,8 +67,8 @@ module SkypeAPI
|
|
67
67
|
end
|
68
68
|
getter :DisplayName, 'DISPLAYNAME'
|
69
69
|
|
70
|
-
def getAvatar(
|
71
|
-
sendCMD("GET USER #{@id} AVATAR 1 #{
|
70
|
+
def getAvatar(filePath)
|
71
|
+
sendCMD("GET USER #{@id} AVATAR 1 #{filePath}") =~ /^USER #{@id} AVATAR \d+ (.+)$/
|
72
72
|
if $1
|
73
73
|
return $1
|
74
74
|
else
|
@@ -77,18 +77,18 @@ module SkypeAPI
|
|
77
77
|
end
|
78
78
|
notice :Avatar, 'AVATAR 1'
|
79
79
|
|
80
|
-
def setBuddyStatus(
|
81
|
-
raise ArgumentErorr unless
|
82
|
-
sendSet('BUDDYSTATUS',"#{
|
80
|
+
def setBuddyStatus(statusCode, msg="")
|
81
|
+
raise ArgumentErorr unless statusCode.to_i == 1 or statusCode.to_i == 2
|
82
|
+
sendSet('BUDDYSTATUS',"#{statusCode} #{msg}")
|
83
83
|
end
|
84
84
|
|
85
|
-
def setIsBlocked
|
85
|
+
def setIsBlocked(flag) sendSet('ISBLOCKED', flag._str); end
|
86
86
|
|
87
|
-
def setIsAuthorized
|
87
|
+
def setIsAuthorized(flag) sendSet('ISAUTHORIZED', flag._str); end
|
88
88
|
|
89
|
-
def setSpeedDial
|
89
|
+
def setSpeedDial(numbers) sendSet('SPEEDDIAL', numbers); end
|
90
90
|
|
91
|
-
def setDisplayName
|
91
|
+
def setDisplayName(name) sendSet('DISPLAYNAME', name);end
|
92
92
|
|
93
93
|
=begin
|
94
94
|
def addContactList msg=""
|
data/lib/skypeapi/voicemail.rb
CHANGED
data/lib/skypeapi.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
require "forwardable.rb"
|
2
2
|
require "skypeApi/os.rb"
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
|
6
|
-
require "
|
7
|
-
require "
|
8
|
-
require "
|
9
|
-
require "
|
10
|
-
require "
|
11
|
-
require "
|
12
|
-
require "
|
13
|
-
require "
|
14
|
-
require "
|
15
|
-
require "
|
16
|
-
require "
|
17
|
-
require "
|
18
|
-
require "
|
19
|
-
require "
|
3
|
+
require "skypeapi/shareFunctions.rb"
|
4
|
+
require "skypeapi/object.rb"
|
5
|
+
require "skypeapi/version.rb"
|
6
|
+
require "skypeapi/user.rb"
|
7
|
+
require "skypeapi/profile.rb"
|
8
|
+
require "skypeapi/call.rb"
|
9
|
+
require "skypeapi/message.rb"
|
10
|
+
require "skypeapi/chat.rb"
|
11
|
+
require "skypeapi/chatmessage.rb"
|
12
|
+
require "skypeapi/chatmember.rb"
|
13
|
+
require "skypeapi/voicemail.rb"
|
14
|
+
require "skypeapi/sms.rb"
|
15
|
+
require "skypeapi/application.rb"
|
16
|
+
require "skypeapi/group.rb"
|
17
|
+
require "skypeapi/filetransfer.rb"
|
18
|
+
require "skypeapi/event.rb"
|
19
|
+
require "skypeapi/menuitem.rb"
|
20
20
|
|
21
21
|
class SkypeAPIError < StandardError
|
22
22
|
class Attach < SkypeAPIError; end
|
@@ -28,8 +28,6 @@ class SkypeAPIError < StandardError
|
|
28
28
|
end
|
29
29
|
|
30
30
|
module SkypeAPI
|
31
|
-
VERSION = "0.2.1"
|
32
|
-
|
33
31
|
include SkypeAPI::Object
|
34
32
|
extend Notify
|
35
33
|
extend Get
|
@@ -70,7 +68,7 @@ module SkypeAPI
|
|
70
68
|
)
|
71
69
|
|
72
70
|
#�O���p�B
|
73
|
-
self.class.__send__(:define_method, :os, Proc.new{@os})
|
71
|
+
#self.class.__send__(:define_method, :os, Proc.new{@os})
|
74
72
|
|
75
73
|
@notify = Hash.new
|
76
74
|
@os.addNotify nil, method(:notified)
|
@@ -87,6 +85,10 @@ module SkypeAPI
|
|
87
85
|
self
|
88
86
|
end
|
89
87
|
|
88
|
+
def self.os
|
89
|
+
@os
|
90
|
+
end
|
91
|
+
|
90
92
|
def self.notified msg
|
91
93
|
skypeProperty = nil
|
92
94
|
propertyReg = '(?:' + [
|
@@ -210,17 +212,17 @@ module SkypeAPI
|
|
210
212
|
|
211
213
|
def self.setMute(flag) sendSet("MUTE", flag._swi) ; end
|
212
214
|
|
213
|
-
def self.getAvatar(
|
215
|
+
def self.getAvatar(filePath, num=1) sendGet("AVATAR #{num} #{filePath}") ; end
|
214
216
|
notice :Avator, 'AVATOR'
|
215
217
|
#?
|
216
218
|
|
217
|
-
def self.setAvatar(
|
218
|
-
sendSet("AVATAR", "#{num} #{
|
219
|
+
def self.setAvatar(filePath, idx="", num=1)
|
220
|
+
sendSet("AVATAR", "#{num} #{filePath}#{idx.empty? ? '' : ':'+idx.to_s}").split(' ')[1]
|
219
221
|
end
|
220
222
|
|
221
223
|
def self.getRingtone(id=1) sendGet("RINGTONE #{id}") ; end
|
222
224
|
|
223
|
-
def self.setRingtone(
|
225
|
+
def self.setRingtone(filePath, idx="", id=1) sendSet("RINGTONE","#{id} #{filePath}:#{idx}") ; end
|
224
226
|
|
225
227
|
notice :Ringtone, "RINGTONE 1" do |str|
|
226
228
|
num, file = str.split(' ',2)
|
@@ -371,8 +373,8 @@ module SkypeAPI
|
|
371
373
|
open 'GETTINGSTARTED'
|
372
374
|
end
|
373
375
|
|
374
|
-
def self.openAuthorization
|
375
|
-
open 'AUTHORIZATION',
|
376
|
+
def self.openAuthorization user
|
377
|
+
open 'AUTHORIZATION', user
|
376
378
|
end
|
377
379
|
|
378
380
|
def self.BTNPressed key
|
@@ -394,7 +396,7 @@ module SkypeAPI
|
|
394
396
|
|
395
397
|
getter :WallPaper, 'WALLPAPER'
|
396
398
|
|
397
|
-
def self.setWallPaper(
|
399
|
+
def self.setWallPaper(filePath) sendSet('WALLPAPER', filePath) ; end
|
398
400
|
|
399
401
|
def self.setSilentMode(flag) sendSet('SILENT_MODE', flag._swi)._flag ; end
|
400
402
|
|
@@ -506,8 +508,8 @@ module SkypeAPI
|
|
506
508
|
end
|
507
509
|
end
|
508
510
|
|
509
|
-
def self.searchChatMessages
|
510
|
-
search('CHATMESSAGES','CHATMESSAGES',
|
511
|
+
def self.searchChatMessages target=''
|
512
|
+
search('CHATMESSAGES','CHATMESSAGES', target).map do |id|
|
511
513
|
chatMessage id
|
512
514
|
end
|
513
515
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: Ruby4Skype
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2008-02-
|
6
|
+
version: 0.2.2
|
7
|
+
date: 2008-02-07 00:00:00 +09:00
|
8
8
|
summary: SkypeAPI wrapper
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -46,6 +46,7 @@ files:
|
|
46
46
|
- lib/skypeapi/sharefunctions.rb
|
47
47
|
- lib/skypeapi/sms.rb
|
48
48
|
- lib/skypeapi/user.rb
|
49
|
+
- lib/skypeapi/version.rb
|
49
50
|
- lib/skypeapi/voicemail.rb
|
50
51
|
- lib/skypeapi.rb
|
51
52
|
test_files: []
|