Package Skype4Py :: Module voicemail
[frames] | no frames]

Source Code for Module Skype4Py.voicemail

  1  """Voicemails. 
  2  """ 
  3  __docformat__ = 'restructuredtext en' 
  4   
  5   
  6  from utils import * 
  7  from enums import * 
  8  from call import DeviceMixin 
  9   
 10   
11 -class Voicemail(Cached, DeviceMixin):
12 """Represents a voicemail. 13 """ 14 _ValidateHandle = int 15
16 - def __repr__(self):
17 return Cached.__repr__(self, 'Id')
18
19 - def _Alter(self, AlterName, Args=None):
20 return self._Owner._Alter('VOICEMAIL', self.Id, AlterName, Args)
21
22 - def _Property(self, PropName, Set=None, Cache=True):
23 return self._Owner._Property('VOICEMAIL', self.Id, PropName, Set, Cache)
24
25 - def Delete(self):
26 """Deletes this voicemail. 27 """ 28 self._Alter('DELETE')
29
30 - def Download(self):
31 """Downloads this voicemail object from the voicemail server to a local computer. 32 """ 33 self._Alter('DOWNLOAD')
34
35 - def Open(self):
36 """Opens and plays this voicemail. 37 """ 38 self._Owner._DoCommand('OPEN VOICEMAIL %s' % self.Id)
39
40 - def SetUnplayed(self):
41 """Changes the status of a voicemail from played to unplayed. 42 """ 43 # Note. Due to a bug in Skype (tested using 3.8.0.115) the reply from 44 # [ALTER VOICEMAIL <id> SETUNPLAYED] is [ALTER VOICEMAIL <id> DELETE] 45 # causing the _Alter method to fail. Therefore we have to use a direct 46 # _DoCommand instead. For the event of this being fixed, we don't 47 # check for the "SETUNPLAYED"/"DELETE" part of the response. 48 49 #self._Alter('SETUNPLAYED') 50 self._Owner._DoCommand('ALTER VOICEMAIL %d SETUNPLAYED' % self.Id, 51 'ALTER VOICEMAIL %d' % self.Id)
52
53 - def StartPlayback(self):
54 """Starts playing downloaded voicemail. 55 """ 56 self._Alter('STARTPLAYBACK')
57
58 - def StartPlaybackInCall(self):
59 """Starts playing downloaded voicemail during a call. 60 """ 61 self._Alter('STARTPLAYBACKINCALL')
62
63 - def StartRecording(self):
64 """Stops playing a voicemail greeting and starts recording a voicemail message. 65 """ 66 self._Alter('STARTRECORDING')
67
68 - def StopPlayback(self):
69 """Stops playing downloaded voicemail. 70 """ 71 self._Alter('STOPPLAYBACK')
72
73 - def StopRecording(self):
74 """Ends the recording of a voicemail message. 75 """ 76 self._Alter('STOPRECORDING')
77
78 - def Upload(self):
79 """Uploads recorded voicemail from a local computer to the voicemail server. 80 """ 81 self._Alter('UPLOAD')
82
83 - def _GetAllowedDuration(self):
84 return int(self._Property('ALLOWED_DURATION'))
85 86 AllowedDuration = property(_GetAllowedDuration, 87 doc="""Maximum voicemail duration in seconds allowed to leave to partner 88 89 :type: int 90 """) 91
92 - def _GetDatetime(self):
93 from datetime import datetime 94 return datetime.fromtimestamp(self.Timestamp)
95 96 Datetime = property(_GetDatetime, 97 doc="""Timestamp of this voicemail expressed using datetime. 98 99 :type: datetime.datetime 100 """) 101
102 - def _GetDuration(self):
103 return int(self._Property('DURATION'))
104 105 Duration = property(_GetDuration, 106 doc="""Actual voicemail duration in seconds. 107 108 :type: int 109 """) 110
111 - def _GetFailureReason(self):
112 return str(self._Property('FAILUREREASON'))
113 114 FailureReason = property(_GetFailureReason, 115 doc="""Voicemail failure reason. Read if `Status` == `enums.vmsFailed`. 116 117 :type: `enums`.vmr* 118 """) 119
120 - def _GetId(self):
121 return self._Handle
122 123 Id = property(_GetId, 124 doc="""Unique voicemail Id. 125 126 :type: int 127 """) 128
129 - def _GetPartnerDisplayName(self):
130 return self._Property('PARTNER_DISPNAME')
131 132 PartnerDisplayName = property(_GetPartnerDisplayName, 133 doc="""DisplayName for voicemail sender (for incoming) or recipient (for outgoing). 134 135 :type: unicode 136 """) 137
138 - def _GetPartnerHandle(self):
139 return str(self._Property('PARTNER_HANDLE'))
140 141 PartnerHandle = property(_GetPartnerHandle, 142 doc="""Skypename for voicemail sender (for incoming) or recipient (for outgoing). 143 144 :type: str 145 """) 146
147 - def _GetStatus(self):
148 return str(self._Property('STATUS'))
149 150 Status = property(_GetStatus, 151 doc="""Voicemail status. 152 153 :type: `enums`.vms* 154 """) 155
156 - def _GetTimestamp(self):
157 return float(self._Property('TIMESTAMP'))
158 159 Timestamp = property(_GetTimestamp, 160 doc="""Timestamp of this voicemail. 161 162 :type: float 163 """) 164
165 - def _GetType(self):
166 return str(self._Property('TYPE'))
167 168 Type = property(_GetType, 169 doc="""Voicemail type. 170 171 :type: `enums`.vmt* 172 """)
173 174
175 -class VoicemailCollection(CachedCollection):
176 _CachedType = Voicemail
177