1 '''Calls, conferences.
2 '''
3
4 from utils import *
5 from enums import *
6
7
9 '''Represents a voice/video call.
10 '''
11
14
15 - def _Alter(self, AlterName, Args=None):
16 return self._Skype._Alter('CALL', self._Id, AlterName, Args)
17
18 - def _Init(self, Id, Skype):
19 self._Skype = Skype
20 self._Id = int(Id)
21
22 - def _Property(self, PropName, Set=None, Cache=True):
23 return self._Skype._Property('CALL', self._Id, PropName, Set, Cache)
24
26 '''Answers the call.
27 '''
28 self._Property('STATUS', 'INPROGRESS')
29
31 '''Queries if a call can be transferred to a contact or phone number.
32
33 @param Target: Skypename or phone number the call is to be transfered to.
34 @type Target: unicode
35 @return: True if call can be transfered, False otherwise.
36 @rtype: bool
37 '''
38 return self._Property('CAN_TRANSFER %s' % Target) == 'TRUE'
39
41 '''Queries or sets the mic capture device.
42
43 @param DeviceType: Mic capture device type or None.
44 @type DeviceType: L{Call IO device type<enums.callIoDeviceTypeUnknown>} or None
45 @param Set: Value the device should be set to or None.
46 @type Set: unicode, int or None
47 @return: If DeviceType and Set are None, returns a dictionary of device types and their
48 values. Dictionary contains only those device types, whose values were set. If the
49 DeviceType is not None but Set is None, returns the current value of the device or
50 None if the device wasn't set. If Set is not None, sets a new value for the device.
51 @rtype: unicode, dict or None
52
53 @note: This command functions for active calls only.
54 '''
55 if Set == None:
56 args = args2dict(self._Property('CAPTURE_MIC', Cache=False))
57 for t in args:
58 if t == callIoDeviceTypePort:
59 args[t] = int(args[t])
60 if DeviceType == None:
61 return args
62 return args.get(DeviceType, None)
63 elif DeviceType != None:
64 self._Alter('SET_CAPTURE_MIC', '%s=%s' % (DeviceType, quote(unicode(Set), True)))
65 else:
66 raise TypeError('DeviceType must be specified if Set is used')
67
69 '''Ends the call.
70 '''
71 self._Property('STATUS', 'FINISHED')
72
74 '''Forwards a call.
75 '''
76 self._Alter('END', 'FORWARD_CALL')
77
79 '''Puts the call on hold.
80 '''
81 self._Property('STATUS', 'ONHOLD')
82
110
111 - def Join(self, Id):
112 '''Joins with another call to form a conference.
113
114 @param Id: Call Id of the other call to join to the conference.
115 @type Id: int
116 @return: Conference object.
117 @rtype: L{IConference}
118 '''
119 reply = self._Skype._DoCommand('SET CALL %s JOIN_CONFERENCE %s' % (self._Id, Id),
120 'CALL %s CONF_ID' % self._Id)
121 return IConference(reply.split()[-1], self._Skype)
122
124 '''Marks the call as seen.
125 '''
126 self.Seen = True
127
129 '''Queries or sets the sound output device.
130
131 @param DeviceType: Sound output device type or None.
132 @type DeviceType: L{Call IO device type<enums.callIoDeviceTypeUnknown>} or None
133 @param Set: Value the device should be set to or None.
134 @type Set: unicode, int or None
135 @return: If DeviceType and Set are None, returns a dictionary of device types and their
136 values. Dictionary contains only those device types, whose values were set. If the
137 DeviceType is not None but Set is None, returns the current value of the device or
138 None if the device wasn't set. If Set is not None, sets a new value for the device.
139 @rtype: unicode, dict or None
140
141 @note: This command functions for active calls only.
142 '''
143 if Set == None:
144 args = args2dict(self._Property('OUTPUT', Cache=False))
145 for t in args:
146 if t == callIoDeviceTypePort:
147 args[t] = int(args[t])
148 if DeviceType == None:
149 return args
150 return args.get(DeviceType, None)
151 elif DeviceType != None:
152 self._Alter('SET_OUTPUT', '%s=%s' % (DeviceType, quote(unicode(Set), True)))
153 else:
154 raise TypeError('DeviceType must be specified if Set is used')
155
157 '''Redirects a call to voicemail.
158 '''
159 self._Alter('END', 'REDIRECT_TO_VOICEMAIL')
160
162 '''Resumes the held call.
163 '''
164 self.Answer()
165
167 '''Starts video receive.
168 '''
169 self._Alter('START_VIDEO_RECEIVE')
170
172 '''Starts video send.
173 '''
174 self._Alter('START_VIDEO_SEND')
175
177 '''Stops video receive.
178 '''
179 self._Alter('STOP_VIDEO_RECEIVE')
180
182 '''Stops video send.
183 '''
184 self._Alter('STOP_VIDEO_SEND')
185
187 '''Transfers a call to one or more contacts or phone numbers.
188
189 @param Targets: one or more phone numbers or Skypenames the call is beeing transferred to.
190 @type Targets: unicode
191 @see: L{CanTransfer}
192
193 @note: You can transfer an incoming call to a group by specifying more than one
194 target, first one of the group to answer will get the call.
195 '''
196 self._Alter('TRANSFER', ', '.join(Targets))
197
199 return int(self._Property('CONF_ID'))
200
201 ConferenceId = property(_GetConferenceId,
202 doc='''ConferenceId.
203
204 @type: int
205 ''')
206
208 from datetime import datetime
209 return datetime.fromtimestamp(self.Timestamp)
210
211 Datetime = property(_GetDatetime,
212 doc='''Date and time of the call.
213
214 @type: datetime.datetime
215 @see: L{Timestamp}
216 ''')
217
219 self._Property('DTMF', value)
220
221 DTMF = property(fset=_SetDTMF,
222 doc='''Set this property to send DTMF codes.
223
224 @type: unicode
225
226 @note: This command functions for active calls only.
227 ''')
228
230 return int(self._Property('DURATION', Cache=False))
231
232 Duration = property(_GetDuration,
233 doc='''Duration of the call in seconds.
234
235 @type: int
236 ''')
237
239 return int(self._Property('FAILUREREASON'))
240
241 FailureReason = property(_GetFailureReason,
242 doc='''Call failure reason. Read if L{Status} == L{clsFailed<enums.clsFailed>}.
243
244 @type: L{Call failure reason<enums.cfrUnknown>}
245 ''')
246
248 return self._Property('FORWARDED_BY')
249
250 ForwardedBy = property(_GetForwardedBy,
251 doc='''Skypename of the user who forwarded a call.
252
253 @type: unicode
254 ''')
255
258
259 Id = property(_GetId,
260 doc='''Call Id.
261
262 @type: int
263 ''')
264
267
268 InputStatus = property(_GetInputStatus,
269 doc='''True if call voice input is enabled.
270
271 @type: bool
272 ''')
273
275 count = int(self._Property('CONF_PARTICIPANTS_COUNT'))
276 return tuple([IParticipant((self._Id, x), self._Skype) for x in xrange(count)])
277
278 Participants = property(_GetParticipants,
279 doc='''Participants of a conference call not hosted by the user.
280
281 @type: tuple of L{IParticipant}
282 ''')
283
285 return self._Property('PARTNER_DISPNAME')
286
287 PartnerDisplayName = property(_GetPartnerDisplayName,
288 doc='''The DisplayName of the remote caller.
289
290 @type: unicode
291 ''')
292
294 return self._Property('PARTNER_HANDLE')
295
296 PartnerHandle = property(_GetPartnerHandle,
297 doc='''The Skypename of the remote caller.
298
299 @type: unicode
300 ''')
301
303 return self._Property('PSTN_NUMBER')
304
305 PstnNumber = property(_GetPstnNumber,
306 doc='''PSTN number of the call.
307
308 @type: unicode
309 ''')
310
312 return self._Property('PSTN_STATUS')
313
314 PstnStatus = property(_GetPstnStatus,
315 doc='''PSTN number status.
316
317 @type: unicode
318 ''')
319
321 return int(self._Property('RATE'))
322
323 Rate = property(_GetRate,
324 doc='''Call rate. Expressed using L{RatePrecision}. If you're just interested in the call rate
325 expressed in current currency, use L{RateValue} instead.
326
327 @type: int
328 @see: L{RateCurrency}, L{RatePrecision}, L{RateToText}, L{RateValue}
329 ''')
330
332 return self._Property('RATE_CURRENCY')
333
334 RateCurrency = property(_GetRateCurrency,
335 doc='''Call rate currency.
336
337 @type: unicode
338 @see: L{Rate}, L{RatePrecision}, L{RateToText}, L{RateValue}
339 ''')
340
342 return int(self._Property('RATE_PRECISION'))
343
344 RatePrecision = property(_GetRatePrecision,
345 doc='''Call rate precision. Expressed as a number of times the call rate has to be divided by 10.
346
347 @type: int
348 @see: L{Rate}, L{RateCurrency}, L{RateToText}, L{RateValue}
349 ''')
350
351 - def _GetRateToText(self):
352 return (u'%s %.3f' % (self.RateCurrency, self.RateValue)).strip()
353
354 RateToText = property(_GetRateToText,
355 doc='''Returns the call rate as a text with currency and properly formatted value.
356
357 @type: unicode
358 @see: L{Rate}, L{RateCurrency}, L{RatePrecision}, L{RateValue}
359 ''')
360
365
366 RateValue = property(_GetRateValue,
367 doc='''Call rate value. Expressed in current currency.
368
369 @type: float
370 @see: L{Rate}, L{RateCurrency}, L{RatePrecision}, L{RateToText}
371 ''')
372
374 return self._Property('SEEN') == 'TRUE'
375
377 self._Property('SEEN', cndexp(value, 'TRUE', 'FALSE'))
378
379 Seen = property(_GetSeen, _SetSeen,
380 doc='''Queries/sets the seen status of the call. True if the call was seen, False otherwise.
381
382 @type: bool
383
384 @note: You cannot alter the call seen status from seen to unseen.
385 ''')
386
388 return self._Property('STATUS')
389
391 self._Property('STATUS', str(value))
392
393 Status = property(_GetStatus, _SetStatus,
394 doc='''The call status.
395
396 @type: L{Call status<enums.clsUnknown>}
397 ''')
398
400 return self._Property('SUBJECT')
401
402 Subject = property(_GetSubject,
403 doc='''Call subject.
404
405 @type: unicode
406 ''')
407
409 return self._Property('TARGET_IDENTIFY')
410
411 TargetIdentify = property(_GetTargetIdentify,
412 doc='''Target number for incoming SkypeIn calls.
413
414 @type: unicode
415 ''')
416
418 return float(self._Property('TIMESTAMP'))
419
420 Timestamp = property(_GetTimestamp,
421 doc='''Call date and time expressed as a timestamp.
422
423 @type: float
424 @see: L{Datetime}
425 ''')
426
428 return self._Property('TRANSFER_ACTIVE') == 'TRUE'
429
430 TransferActive = property(_GetTransferActive,
431 doc='''Returns True if the call has been transfered.
432
433 @type: bool
434 ''')
435
437 return self._Property('TRANSFERRED_BY')
438
439 TransferredBy = property(_GetTransferredBy,
440 doc='''Returns the Skypename of the user who transferred the call.
441
442 @type: unicode
443 ''')
444
446 return self._Property('TRANSFERRED_TO')
447
448 TransferredTo = property(_GetTransferredTo,
449 doc='''Returns the Skypename of the user or phone number the call has been transferred to.
450
451 @type: unicode
452 ''')
453
455 return self._Property('TRANSFER_STATUS')
456
457 TransferStatus = property(_GetTransferStatus,
458 doc='''Returns the call transfer status.
459
460 @type: L{Call status<enums.clsUnknown>}
461 ''')
462
464 return self._Property('TYPE')
465
466 Type = property(_GetType,
467 doc='''Call type.
468
469 @type: L{Call type<enums.cltUnknown>}
470 ''')
471
473 return self._Property('VIDEO_RECEIVE_STATUS')
474
475 VideoReceiveStatus = property(_GetVideoReceiveStatus,
476 doc='''Call video receive status.
477
478 @type: L{Call video send status<enums.vssUnknown>}
479 ''')
480
482 return self._Property('VIDEO_SEND_STATUS')
483
484 VideoSendStatus = property(_GetVideoSendStatus,
485 doc='''Call video send status.
486
487 @type: L{Call video send status<enums.vssUnknown>}
488 ''')
489
491 return self._Property('VIDEO_STATUS')
492
493 VideoStatus = property(_GetVideoStatus,
494 doc='''Call video status.
495
496 @type: L{Call video status<enums.cvsUnknown>}
497 ''')
498
500 return int(self._Property('VM_ALLOWED_DURATION'))
501
502 VmAllowedDuration = property(_GetVmAllowedDuration,
503 doc='''Returns the permitted duration of a voicemail in seconds.
504
505 @type: int
506 ''')
507
509 return int(self._Property('VM_DURATION'))
510
511 VmDuration = property(_GetVmDuration,
512 doc='''Returns the duration of a voicemail.
513
514 @type: int
515 ''')
516
517
519 '''Represents a conference call participant.
520 '''
521
523 return '<%s with Id=%s, Idx=%s, Handle=%s>' % (Cached.__repr__(self)[1:-1], repr(self.Id), repr(self.Idx), repr(self.Handle))
524
525 - def _Init(self, Id_Idx, Skype):
526 self._Skype = Skype
527 Id, Idx = Id_Idx
528 self._Id = int(Id)
529 self._Idx = int(Idx)
530
532 reply = self._Skype._Property('CALL', self._Id, 'CONF_PARTICIPANT %d' % self._Idx)
533 return chop(reply, 3)[Prop]
534
536 return self._Property(2)
537
538 CallStatus = property(_GetCallStatus,
539 doc='''Call status of a participant in a conference call.
540
541 @type: L{Call status<enums.clsUnknown>}
542 ''')
543
545 return self._Property(1)
546
547 CallType = property(_GetCallType,
548 doc='''Call type in a conference call.
549
550 @type: L{Call type<enums.cltUnknown>}
551 ''')
552
554 return self._Property(3)
555
556 DisplayName = property(_GetDisplayName,
557 doc='''DisplayName of a participant in a conference call.
558
559 @type: unicode
560 ''')
561
563 return self._Property(0)
564
565 Handle = property(_GetHandle,
566 doc='''Skypename of a participant in a conference call.
567
568 @type: unicode
569 ''')
570
573
574 Id = property(_GetId,
575 doc='''Call Id.
576
577 @type: int
578 ''')
579
582
583 Idx = property(_GetIdx,
584 doc='''Call participant index.
585
586 @type: int
587 ''')
588
589
591 '''Represents a conference call.
592 '''
593
596
597 - def _Init(self, Id, Skype):
598 self._Skype = Skype
599 self._Id = int(Id)
600
602 '''Finishes a conference so all active calls have the status L{clsFinished<enums.clsFinished>}.
603 '''
604 for c in self._GetCalls():
605 c.Finish()
606
608 '''Places all calls in a conference on hold so all active calls have the status L{clsLocalHold<enums.clsLocalHold>}.
609 '''
610 for c in self._GetCalls():
611 c.Hold()
612
614 '''Resumes a conference that was placed on hold so all active calls have the status L{clsInProgress<enums.clsInProgress>}.
615 '''
616 for c in self._GetCalls():
617 c.Resume()
618
621
622 ActiveCalls = property(_GetActiveCalls,
623 doc='''Active calls with the same conference ID.
624
625 @type: tuple of L{ICall}
626 ''')
627
630
631 Calls = property(_GetCalls,
632 doc='''Calls with the same conference ID.
633
634 @type: tuple of L{ICall}
635 ''')
636
639
640 Id = property(_GetId,
641 doc='''Id of a conference.
642
643 @type: int
644 ''')
645