1 '''Calls, conferences.
2 '''
3
4 from utils import *
5 from enums import *
6 from errors import *
7
8
10 '''Represents a voice/video call.
11 '''
12
15
16 - def _Alter(self, AlterName, Args=None):
17 return self._Skype._Alter('CALL', self._Id, AlterName, Args)
18
19 - def _Init(self, Id, Skype):
20 self._Skype = Skype
21 self._Id = int(Id)
22
23 - def _Property(self, PropName, Set=None, Cache=True):
24 return self._Skype._Property('CALL', self._Id, PropName, Set, Cache)
25
27 '''Answers the call.
28 '''
29 self._Property('STATUS', 'INPROGRESS')
30
32 '''Queries if a call can be transferred to a contact or phone number.
33
34 @param Target: Skypename or phone number the call is to be transfered to.
35 @type Target: unicode
36 @return: True if call can be transfered, False otherwise.
37 @rtype: bool
38 '''
39 return self._Property('CAN_TRANSFER %s' % Target) == 'TRUE'
40
42 '''Queries or sets the mic capture device.
43
44 @param DeviceType: Mic capture device type or None.
45 @type DeviceType: L{Call IO device type<enums.callIoDeviceTypeUnknown>} or None
46 @param Set: Value the device should be set to or None.
47 @type Set: unicode, int or None
48 @return: If DeviceType and Set are None, returns a dictionary of device types and their
49 values. Dictionary contains only those device types, whose values were set. If the
50 DeviceType is not None but Set is None, returns the current value of the device or
51 None if the device wasn't set. If Set is not None, sets a new value for the device.
52 @rtype: unicode, dict or None
53
54 @note: This command functions for active calls only.
55 '''
56 if Set == None:
57 args = args2dict(self._Property('CAPTURE_MIC', Cache=False))
58 for t in args:
59 if t == callIoDeviceTypePort:
60 args[t] = int(args[t])
61 if DeviceType == None:
62 return args
63 return args.get(DeviceType, None)
64 elif DeviceType != None:
65 self._Alter('SET_CAPTURE_MIC', '%s=%s' % (DeviceType, quote(unicode(Set), True)))
66 else:
67 raise TypeError('DeviceType must be specified if Set is used')
68
70 '''Ends the call.
71 '''
72 self._Property('STATUS', 'FINISHED')
73
75 '''Forwards a call.
76 '''
77 self._Alter('END', 'FORWARD_CALL')
78
80 '''Puts the call on hold.
81 '''
82 self._Property('STATUS', 'ONHOLD')
83
111
112 - def Join(self, Id):
113 '''Joins with another call to form a conference.
114
115 @param Id: Call Id of the other call to join to the conference.
116 @type Id: int
117 @return: Conference object.
118 @rtype: L{IConference}
119 '''
120 reply = self._Skype._DoCommand('SET CALL %s JOIN_CONFERENCE %s' % (self._Id, Id),
121 'CALL %s CONF_ID' % self._Id)
122 return IConference(reply.split()[-1], self._Skype)
123
125 '''Marks the call as seen.
126 '''
127 self.Seen = True
128
130 '''Queries or sets the sound output device.
131
132 @param DeviceType: Sound output device type or None.
133 @type DeviceType: L{Call IO device type<enums.callIoDeviceTypeUnknown>} or None
134 @param Set: Value the device should be set to or None.
135 @type Set: unicode, int or None
136 @return: If DeviceType and Set are None, returns a dictionary of device types and their
137 values. Dictionary contains only those device types, whose values were set. If the
138 DeviceType is not None but Set is None, returns the current value of the device or
139 None if the device wasn't set. If Set is not None, sets a new value for the device.
140 @rtype: unicode, dict or None
141
142 @note: This command functions for active calls only.
143 '''
144 if Set == None:
145 args = args2dict(self._Property('OUTPUT', Cache=False))
146 for t in args:
147 if t == callIoDeviceTypePort:
148 args[t] = int(args[t])
149 if DeviceType == None:
150 return args
151 return args.get(DeviceType, None)
152 elif DeviceType != None:
153 self._Alter('SET_OUTPUT', '%s=%s' % (DeviceType, quote(unicode(Set), True)))
154 else:
155 raise TypeError('DeviceType must be specified if Set is used')
156
158 '''Redirects a call to voicemail.
159 '''
160 self._Alter('END', 'REDIRECT_TO_VOICEMAIL')
161
163 '''Resumes the held call.
164 '''
165 self.Answer()
166
168 '''Starts video receive.
169 '''
170 self._Alter('START_VIDEO_RECEIVE')
171
173 '''Starts video send.
174 '''
175 self._Alter('START_VIDEO_SEND')
176
178 '''Stops video receive.
179 '''
180 self._Alter('STOP_VIDEO_RECEIVE')
181
183 '''Stops video send.
184 '''
185 self._Alter('STOP_VIDEO_SEND')
186
188 '''Transfers a call to one or more contacts or phone numbers.
189
190 @param Targets: one or more phone numbers or Skypenames the call is beeing transferred to.
191 @type Targets: unicode
192 @see: L{CanTransfer}
193
194 @note: You can transfer an incoming call to a group by specifying more than one
195 target, first one of the group to answer will get the call.
196 '''
197 self._Alter('TRANSFER', ', '.join(Targets))
198
200 return int(self._Property('CONF_ID'))
201
202 ConferenceId = property(_GetConferenceId,
203 doc='''ConferenceId.
204
205 @type: int
206 ''')
207
209 from datetime import datetime
210 return datetime.fromtimestamp(self.Timestamp)
211
212 Datetime = property(_GetDatetime,
213 doc='''Date and time of the call.
214
215 @type: datetime.datetime
216 @see: L{Timestamp}
217 ''')
218
220 self._Property('DTMF', value)
221
222 DTMF = property(fset=_SetDTMF,
223 doc='''Set this property to send DTMF codes.
224
225 @type: unicode
226
227 @note: This command functions for active calls only.
228 ''')
229
231 return int(self._Property('DURATION', Cache=False))
232
233 Duration = property(_GetDuration,
234 doc='''Duration of the call in seconds.
235
236 @type: int
237 ''')
238
240 return int(self._Property('FAILUREREASON'))
241
242 FailureReason = property(_GetFailureReason,
243 doc='''Call failure reason. Read if L{Status} == L{clsFailed<enums.clsFailed>}.
244
245 @type: L{Call failure reason<enums.cfrUnknown>}
246 ''')
247
249 return self._Property('FORWARDED_BY')
250
251 ForwardedBy = property(_GetForwardedBy,
252 doc='''Skypename of the user who forwarded a call.
253
254 @type: unicode
255 ''')
256
259
260 Id = property(_GetId,
261 doc='''Call Id.
262
263 @type: int
264 ''')
265
268
269 InputStatus = property(_GetInputStatus,
270 doc='''True if call voice input is enabled.
271
272 @type: bool
273 ''')
274
276 count = int(self._Property('CONF_PARTICIPANTS_COUNT'))
277 return tuple(IParticipant((self._Id, x), self._Skype) for x in xrange(count))
278
279 Participants = property(_GetParticipants,
280 doc='''Participants of a conference call not hosted by the user.
281
282 @type: tuple of L{IParticipant}
283 ''')
284
286 return self._Property('PARTNER_DISPNAME')
287
288 PartnerDisplayName = property(_GetPartnerDisplayName,
289 doc='''The DisplayName of the remote caller.
290
291 @type: unicode
292 ''')
293
295 return self._Property('PARTNER_HANDLE')
296
297 PartnerHandle = property(_GetPartnerHandle,
298 doc='''The Skypename of the remote caller.
299
300 @type: unicode
301 ''')
302
304 return self._Property('PSTN_NUMBER')
305
306 PstnNumber = property(_GetPstnNumber,
307 doc='''PSTN number of the call.
308
309 @type: unicode
310 ''')
311
313 return self._Property('PSTN_STATUS')
314
315 PstnStatus = property(_GetPstnStatus,
316 doc='''PSTN number status.
317
318 @type: unicode
319 ''')
320
322 return int(self._Property('RATE'))
323
324 Rate = property(_GetRate,
325 doc='''Call rate. Expressed using L{RatePrecision}. If you're just interested in the call rate
326 expressed in current currency, use L{RateValue} instead.
327
328 @type: int
329 @see: L{RateCurrency}, L{RatePrecision}, L{RateToText}, L{RateValue}
330 ''')
331
333 return self._Property('RATE_CURRENCY')
334
335 RateCurrency = property(_GetRateCurrency,
336 doc='''Call rate currency.
337
338 @type: unicode
339 @see: L{Rate}, L{RatePrecision}, L{RateToText}, L{RateValue}
340 ''')
341
343 return int(self._Property('RATE_PRECISION'))
344
345 RatePrecision = property(_GetRatePrecision,
346 doc='''Call rate precision. Expressed as a number of times the call rate has to be divided by 10.
347
348 @type: int
349 @see: L{Rate}, L{RateCurrency}, L{RateToText}, L{RateValue}
350 ''')
351
352 - def _GetRateToText(self):
353 return (u'%s %.3f' % (self.RateCurrency, self.RateValue)).strip()
354
355 RateToText = property(_GetRateToText,
356 doc='''Returns the call rate as a text with currency and properly formatted value.
357
358 @type: unicode
359 @see: L{Rate}, L{RateCurrency}, L{RatePrecision}, L{RateValue}
360 ''')
361
366
367 RateValue = property(_GetRateValue,
368 doc='''Call rate value. Expressed in current currency.
369
370 @type: float
371 @see: L{Rate}, L{RateCurrency}, L{RatePrecision}, L{RateToText}
372 ''')
373
375 return self._Property('SEEN') == 'TRUE'
376
378 self._Property('SEEN', cndexp(value, 'TRUE', 'FALSE'))
379
380 Seen = property(_GetSeen, _SetSeen,
381 doc='''Queries/sets the seen status of the call. True if the call was seen, False otherwise.
382
383 @type: bool
384
385 @note: You cannot alter the call seen status from seen to unseen.
386 ''')
387
389 return self._Property('STATUS')
390
392 self._Property('STATUS', str(value))
393
394 Status = property(_GetStatus, _SetStatus,
395 doc='''The call status.
396
397 @type: L{Call status<enums.clsUnknown>}
398 ''')
399
401 return self._Property('SUBJECT')
402
403 Subject = property(_GetSubject,
404 doc='''Call subject.
405
406 @type: unicode
407 ''')
408
410 return self._Property('TARGET_IDENTIFY')
411
412 TargetIdentify = property(_GetTargetIdentify,
413 doc='''Target number for incoming SkypeIn calls.
414
415 @type: unicode
416 ''')
417
419 return float(self._Property('TIMESTAMP'))
420
421 Timestamp = property(_GetTimestamp,
422 doc='''Call date and time expressed as a timestamp.
423
424 @type: float
425 @see: L{Datetime}
426 ''')
427
429 return self._Property('TRANSFER_ACTIVE') == 'TRUE'
430
431 TransferActive = property(_GetTransferActive,
432 doc='''Returns True if the call has been transfered.
433
434 @type: bool
435 ''')
436
438 return self._Property('TRANSFERRED_BY')
439
440 TransferredBy = property(_GetTransferredBy,
441 doc='''Returns the Skypename of the user who transferred the call.
442
443 @type: unicode
444 ''')
445
447 return self._Property('TRANSFERRED_TO')
448
449 TransferredTo = property(_GetTransferredTo,
450 doc='''Returns the Skypename of the user or phone number the call has been transferred to.
451
452 @type: unicode
453 ''')
454
456 return self._Property('TRANSFER_STATUS')
457
458 TransferStatus = property(_GetTransferStatus,
459 doc='''Returns the call transfer status.
460
461 @type: L{Call status<enums.clsUnknown>}
462 ''')
463
465 return self._Property('TYPE')
466
467 Type = property(_GetType,
468 doc='''Call type.
469
470 @type: L{Call type<enums.cltUnknown>}
471 ''')
472
474 return self._Property('VIDEO_RECEIVE_STATUS')
475
476 VideoReceiveStatus = property(_GetVideoReceiveStatus,
477 doc='''Call video receive status.
478
479 @type: L{Call video send status<enums.vssUnknown>}
480 ''')
481
483 return self._Property('VIDEO_SEND_STATUS')
484
485 VideoSendStatus = property(_GetVideoSendStatus,
486 doc='''Call video send status.
487
488 @type: L{Call video send status<enums.vssUnknown>}
489 ''')
490
492 return self._Property('VIDEO_STATUS')
493
494 VideoStatus = property(_GetVideoStatus,
495 doc='''Call video status.
496
497 @type: L{Call video status<enums.cvsUnknown>}
498 ''')
499
501 return int(self._Property('VM_ALLOWED_DURATION'))
502
503 VmAllowedDuration = property(_GetVmAllowedDuration,
504 doc='''Returns the permitted duration of a voicemail in seconds.
505
506 @type: int
507 ''')
508
510 return int(self._Property('VM_DURATION'))
511
512 VmDuration = property(_GetVmDuration,
513 doc='''Returns the duration of a voicemail.
514
515 @type: int
516 ''')
517
518
520 '''Represents a conference call participant.
521 '''
522
524 return '<%s with Id=%s, Idx=%s, Handle=%s>' % (Cached.__repr__(self)[1:-1], repr(self.Id), repr(self.Idx), repr(self.Handle))
525
526 - def _Init(self, (Id, Idx), Skype):
527 self._Skype = Skype
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