1 """Calls, conferences.
2 """
3 __docformat__ = 'restructuredtext en'
4
5
6 from types import NoneType
7
8 from utils import *
9 from enums import *
10
11
13 - def _Device(self, Name, DeviceType=None, Set=NoneType):
14 args = args2dict(self._Property(Name, Cache=False))
15 if Set is NoneType:
16 for dev, value in args.items():
17 try:
18 args[dev] = int(value)
19 except ValueError:
20 pass
21 if DeviceType is None:
22 return args
23 return args.get(DeviceType, None)
24 elif DeviceType is None:
25 raise TypeError('DeviceType must be specified if Set is used')
26 if Set:
27 args[DeviceType] = tounicode(Set)
28 else:
29 args.pop(DeviceType, None)
30 for dev, value in args.items():
31 args[dev] = quote(value, True)
32 self._Alter('SET_%s' % Name,
33 ', '.join('%s=%s' % item for item in args.items()))
34
36 """Queries or sets the mic capture device.
37
38 :Parameters:
39 DeviceType : `enums`.callIoDeviceType* or None
40 Mic capture device type.
41 Set
42 Value the device should be set to or None if it should be deactivated.
43
44 Querying all active devices:
45 Devices = CaptureMicDevice()
46
47 Returns a mapping of device types to their values. Only active devices are
48 returned.
49
50 Querying a specific device:
51 Value = CaptureMicDevice(DeviceType)
52
53 Returns a device value for the given DeviceType.
54
55 Setting a device value:
56 CaptureMicDevice(DeviceType, Value)
57
58 If Value is None, the device will be deactivated.
59
60 :note: This command functions for active calls only.
61 """
62 return self._Device('CAPTURE_MIC', DeviceType, Set)
63
92
94 """Queries or sets the sound output device.
95
96 :Parameters:
97 DeviceType : `enums`.callIoDeviceType* or None
98 Sound output device type.
99 Set
100 Value the device should be set to or None if it should be deactivated.
101
102 Querying all active devices:
103 Devices = OutputDevice()
104
105 Returns a mapping of device types to their values. Only active devices are
106 returned.
107
108 Querying a specific device:
109 Value = OutputDevice(DeviceType)
110
111 Returns a device value for the given DeviceType.
112
113 Setting a device value:
114 OutputDevice(DeviceType, Value)
115
116 If Value is None, the device will be deactivated.
117
118 :note: This command functions for active calls only.
119 """
120 return self._Device('OUTPUT', DeviceType, Set)
121
122
123 -class Call(Cached, DeviceMixin):
124 """Represents a voice/video call.
125 """
126 _ValidateHandle = int
127
130
131 - def _Alter(self, AlterName, Args=None):
132 return self._Owner._Alter('CALL', self.Id, AlterName, Args)
133
136
137 - def _Property(self, PropName, Set=None, Cache=True):
138 return self._Owner._Property('CALL', self.Id, PropName, Set, Cache)
139
141 """Answers the call.
142 """
143
144 self._Alter('ANSWER')
145
147 """Queries if a call can be transferred to a contact or phone number.
148
149 :Parameters:
150 Target : str
151 Skypename or phone number the call is to be transferred to.
152
153 :return: True if call can be transferred, False otherwise.
154 :rtype: bool
155 """
156 return self._Property('CAN_TRANSFER %s' % Target) == 'TRUE'
157
159 """Ends the call.
160 """
161
162 self._Alter('END', 'HANGUP')
163
165 """Forwards a call.
166 """
167 self._Alter('END', 'FORWARD_CALL')
168
170 """Puts the call on hold.
171 """
172
173 self._Alter('HOLD')
174
175 - def Join(self, Id):
176 """Joins with another call to form a conference.
177
178 :Parameters:
179 Id : int
180 Call Id of the other call to join to the conference.
181
182 :return: Conference object.
183 :rtype: `Conference`
184 """
185
186 reply = self._Owner._DoCommand('SET CALL %s JOIN_CONFERENCE %s' % (self.Id, Id),
187 'CALL %s CONF_ID' % self.Id)
188 return Conference(self._Owner, reply.split()[-1])
189
191 """Marks the call as seen.
192 """
193 self.Seen = True
194
196 """Redirects a call to voicemail.
197 """
198 self._Alter('END', 'REDIRECT_TO_VOICEMAIL')
199
201 """Resumes the held call.
202 """
203
204 self._Alter('RESUME')
205
207 """Starts video receive.
208 """
209 self._Alter('START_VIDEO_RECEIVE')
210
212 """Starts video send.
213 """
214 self._Alter('START_VIDEO_SEND')
215
217 """Stops video receive.
218 """
219 self._Alter('STOP_VIDEO_RECEIVE')
220
222 """Stops video send.
223 """
224 self._Alter('STOP_VIDEO_SEND')
225
227 """Transfers a call to one or more contacts or phone numbers.
228
229 :Parameters:
230 Targets : str
231 one or more phone numbers or Skypenames the call is being transferred to.
232
233 :note: You can transfer an incoming call to a group by specifying more than one target,
234 first one of the group to answer will get the call.
235 :see: `CanTransfer`
236 """
237 self._Alter('TRANSFER', ', '.join(Targets))
238
240 return int(self._Property('CONF_ID'))
241
242 ConferenceId = property(_GetConferenceId,
243 doc="""Conference Id.
244
245 :type: int
246 """)
247
249 from datetime import datetime
250 return datetime.fromtimestamp(self.Timestamp)
251
252 Datetime = property(_GetDatetime,
253 doc="""Date and time of the call.
254
255 :type: datetime.datetime
256
257 :see: `Timestamp`
258 """)
259
261 self._Alter('DTMF', Value)
262
263 DTMF = property(fset=_SetDTMF,
264 doc="""Set this property to send DTMF codes. Permitted symbols are: [0..9, #, \*].
265
266 :type: str
267
268 :note: This command functions for active calls only.
269 """)
270
272 return int(self._Property('DURATION', Cache=False))
273
274 Duration = property(_GetDuration,
275 doc="""Duration of the call in seconds.
276
277 :type: int
278 """)
279
281 return int(self._Property('FAILUREREASON'))
282
283 FailureReason = property(_GetFailureReason,
284 doc="""Call failure reason. Read if `Status` == `enums.clsFailed`.
285
286 :type: `enums`.cfr*
287 """)
288
290 return str(self._Property('FORWARDED_BY'))
291
292 ForwardedBy = property(_GetForwardedBy,
293 doc="""Skypename of the user who forwarded a call.
294
295 :type: str
296 """)
297
300
301 Id = property(_GetId,
302 doc="""Call Id.
303
304 :type: int
305 """)
306
309
310 InputStatus = property(_GetInputStatus,
311 doc="""True if call voice input is enabled.
312
313 :type: bool
314 """)
315
319
320 Participants = property(_GetParticipants,
321 doc="""Participants of a conference call not hosted by the user.
322
323 :type: `ParticipantCollection`
324 """)
325
327 return self._Property('PARTNER_DISPNAME')
328
329 PartnerDisplayName = property(_GetPartnerDisplayName,
330 doc="""The DisplayName of the remote caller.
331
332 :type: unicode
333 """)
334
336 return str(self._Property('PARTNER_HANDLE'))
337
338 PartnerHandle = property(_GetPartnerHandle,
339 doc="""The Skypename of the remote caller.
340
341 :type: str
342 """)
343
345 return str(self._Property('PSTN_NUMBER'))
346
347 PstnNumber = property(_GetPstnNumber,
348 doc="""PSTN number of the call.
349
350 :type: str
351 """)
352
354 return self._Property('PSTN_STATUS')
355
356 PstnStatus = property(_GetPstnStatus,
357 doc="""PSTN number status.
358
359 :type: unicode
360 """)
361
363 return int(self._Property('RATE'))
364
365 Rate = property(_GetRate,
366 doc="""Call rate. Expressed using `RatePrecision`. If you're just interested in the call rate
367 expressed in current currency, use `RateValue` instead.
368
369 :type: int
370
371 :see: `RateCurrency`, `RatePrecision`, `RateToText`, `RateValue`
372 """)
373
375 return self._Property('RATE_CURRENCY')
376
377 RateCurrency = property(_GetRateCurrency,
378 doc="""Call rate currency.
379
380 :type: unicode
381
382 :see: `Rate`, `RatePrecision`, `RateToText`, `RateValue`
383 """)
384
386 return int(self._Property('RATE_PRECISION'))
387
388 RatePrecision = property(_GetRatePrecision,
389 doc="""Call rate precision. Expressed as a number of times the call rate has to be divided by 10.
390
391 :type: int
392
393 :see: `Rate`, `RateCurrency`, `RateToText`, `RateValue`
394 """)
395
396 - def _GetRateToText(self):
397 return (u'%s %.3f' % (self.RateCurrency, self.RateValue)).strip()
398
399 RateToText = property(_GetRateToText,
400 doc="""Returns the call rate as a text with currency and properly formatted value.
401
402 :type: unicode
403
404 :see: `Rate`, `RateCurrency`, `RatePrecision`, `RateValue`
405 """)
406
411
412 RateValue = property(_GetRateValue,
413 doc="""Call rate value. Expressed in current currency.
414
415 :type: float
416
417 :see: `Rate`, `RateCurrency`, `RatePrecision`, `RateToText`
418 """)
419
421 return (self._Property('SEEN') == 'TRUE')
422
424 self._Property('SEEN', cndexp(Value, 'TRUE', 'FALSE'))
425
426 Seen = property(_GetSeen, _SetSeen,
427 doc="""Queries/sets the seen status of the call. True if the call was seen, False otherwise.
428
429 :type: bool
430
431 :note: You cannot alter the call seen status from seen to unseen.
432 """)
433
435 return str(self._Property('STATUS'))
436
438 self._Property('STATUS', str(Value))
439
440 Status = property(_GetStatus, _SetStatus,
441 doc="""The call status.
442
443 :type: `enums`.cls*
444 """)
445
447 return self._Property('SUBJECT')
448
449 Subject = property(_GetSubject,
450 doc="""Call subject.
451
452 :type: unicode
453 """)
454
456 return str(self._Property('TARGET_IDENTITY'))
457
458 TargetIdentity = property(_GetTargetIdentity,
459 doc="""Target number for incoming SkypeIn calls.
460
461 :type: str
462 """)
463
465 return float(self._Property('TIMESTAMP'))
466
467 Timestamp = property(_GetTimestamp,
468 doc="""Call date and time expressed as a timestamp.
469
470 :type: float
471
472 :see: `Datetime`
473 """)
474
476 return self._Property('TRANSFER_ACTIVE') == 'TRUE'
477
478 TransferActive = property(_GetTransferActive,
479 doc="""Returns True if the call has been transferred.
480
481 :type: bool
482 """)
483
485 return str(self._Property('TRANSFERRED_BY'))
486
487 TransferredBy = property(_GetTransferredBy,
488 doc="""Returns the Skypename of the user who transferred the call.
489
490 :type: str
491 """)
492
494 return str(self._Property('TRANSFERRED_TO'))
495
496 TransferredTo = property(_GetTransferredTo,
497 doc="""Returns the Skypename of the user or phone number the call has been transferred to.
498
499 :type: str
500 """)
501
503 return str(self._Property('TRANSFER_STATUS'))
504
505 TransferStatus = property(_GetTransferStatus,
506 doc="""Returns the call transfer status.
507
508 :type: `enums`.cls*
509 """)
510
512 return str(self._Property('TYPE'))
513
514 Type = property(_GetType,
515 doc="""Call type.
516
517 :type: `enums`.clt*
518 """)
519
521 return str(self._Property('VIDEO_RECEIVE_STATUS'))
522
523 VideoReceiveStatus = property(_GetVideoReceiveStatus,
524 doc="""Call video receive status.
525
526 :type: `enums`.vss*
527 """)
528
530 return str(self._Property('VIDEO_SEND_STATUS'))
531
532 VideoSendStatus = property(_GetVideoSendStatus,
533 doc="""Call video send status.
534
535 :type: `enums`.vss*
536 """)
537
539 return str(self._Property('VIDEO_STATUS'))
540
541 VideoStatus = property(_GetVideoStatus,
542 doc="""Call video status.
543
544 :type: `enums`.cvs*
545 """)
546
548 return int(self._Property('VM_ALLOWED_DURATION'))
549
550 VmAllowedDuration = property(_GetVmAllowedDuration,
551 doc="""Returns the permitted duration of a voicemail in seconds.
552
553 :type: int
554 """)
555
557 return int(self._Property('VM_DURATION'))
558
559 VmDuration = property(_GetVmDuration,
560 doc="""Returns the duration of a voicemail.
561
562 :type: int
563 """)
564
565
568
569
571 """Represents a conference call participant.
572 """
573 _ValidateHandle = int
574
577
579
580 reply = self._Owner._Property('CONF_PARTICIPANT %d' % self.Idx)
581 return chop(reply, 3)[Prop]
582
585
586 Call = property(_GetCall,
587 doc="""Call object.
588
589 :type: `Call`
590 """)
591
593 return str(self._Property(2))
594
595 CallStatus = property(_GetCallStatus,
596 doc="""Call status of a participant in a conference call.
597
598 :type: `enums`.cls*
599 """)
600
602 return str(self._Property(1))
603
604 CallType = property(_GetCallType,
605 doc="""Call type in a conference call.
606
607 :type: `enums`.clt*
608 """)
609
611 return self._Property(3)
612
613 DisplayName = property(_GetDisplayName,
614 doc="""DisplayName of a participant in a conference call.
615
616 :type: unicode
617 """)
618
620 return str(self._Property(0))
621
622 Handle = property(_GetHandle,
623 doc="""Skypename of a participant in a conference call.
624
625 :type: str
626 """)
627
629 return self._Owner.Id
630
631 Id = property(_GetId,
632 doc="""Call Id.
633
634 :type: int
635 """)
636
639
640 Idx = property(_GetIdx,
641 doc="""Call participant index.
642
643 :type: int
644 """)
645
646
649
650
652 """Represents a conference call.
653 """
654 _ValidateHandle = int
655
658
660 """Finishes a conference so all active calls have the status
661 `enums.clsFinished`.
662 """
663 for c in self._GetCalls():
664 c.Finish()
665
667 """Places all calls in a conference on hold so all active calls
668 have the status `enums.clsLocalHold`.
669 """
670 for c in self._GetCalls():
671 c.Hold()
672
674 """Resumes a conference that was placed on hold so all active calls
675 have the status `enums.clsInProgress`.
676 """
677 for c in self._GetCalls():
678 c.Resume()
679
682
683 ActiveCalls = property(_GetActiveCalls,
684 doc="""Active calls with the same conference ID.
685
686 :type: `CallCollection`
687 """)
688
691
692 Calls = property(_GetCalls,
693 doc="""Calls with the same conference ID.
694
695 :type: `CallCollection`
696 """)
697
700
701 Id = property(_GetId,
702 doc="""Id of a conference.
703
704 :type: int
705 """)
706
707
710