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

Source Code for Module Skype4Py.voicemail

  1  '''Voicemails. 
  2  ''' 
  3   
  4  from utils import * 
  5  from enums import * 
  6  from errors import * 
  7   
  8   
9 -class IVoicemail(Cached):
10 '''Represents a voicemail. 11 ''' 12
13 - def __repr__(self):
14 return '<%s with Id=%s>' % (Cached.__repr__(self)[1:-1], repr(self.Id))
15
16 - def _Alter(self, AlterName, Args=None):
17 return self._Skype._Alter('VOICEMAIL', self._Id, AlterName, Args)
18
19 - def _Init(self, Id, Skype):
20 self._Id = int(Id) 21 self._Skype = Skype
22
23 - def _Property(self, PropName, Set=None, Cache=True):
24 return self._Skype._Property('VOICEMAIL', self._Id, PropName, Set, Cache)
25
26 - def CaptureMicDevice(self, DeviceType=None, Set=None):
27 '''Queries or sets the mic capture device. 28 29 @param DeviceType: Mic capture device type or None. 30 @type DeviceType: L{Call IO device type<enums.callIoDeviceTypeUnknown>} or None 31 @param Set: Value the device should be set to or None. 32 @type Set: unicode, int or None 33 @return: If DeviceType and Set are None, returns a dictionary of device types and their 34 values. Dictionary contains only those device types, whose values were set. If the 35 DeviceType is not None but Set is None, returns the current value of the device or 36 None if the device wasn't set. If Set is not None, sets a new value for the device. 37 @rtype: unicode, dict or None 38 ''' 39 if Set == None: # get 40 args = args2dict(self._Property('CAPTURE_MIC', Cache=False)) 41 for t in args: 42 if t == callIoDeviceTypePort: 43 args[t] = int(args[t]) 44 if DeviceType == None: # get active devices 45 return args 46 return args.get(DeviceType, None) 47 elif DeviceType != None: # set 48 self._Alter('SET_CAPTURE_MIC', '%s=%s' % (DeviceType, quote(unicode(Set), True))) 49 else: 50 raise TypeError('DeviceType must be specified if Set is used')
51
52 - def Delete(self):
53 '''Deletes this voicemail. 54 ''' 55 self._Alter('DELETE')
56
57 - def Download(self):
58 '''Downloads this voicemail object from the voicemail server to a local computer. 59 ''' 60 self._Alter('DOWNLOAD')
61
62 - def InputDevice(self, DeviceType=None, Set=None):
63 '''Queries or sets the sound input device. 64 65 @param DeviceType: Sound input device type or None. 66 @type DeviceType: L{Call IO device type<enums.callIoDeviceTypeUnknown>} or None 67 @param Set: Value the device should be set to or None. 68 @type Set: unicode, int or None 69 @return: If DeviceType and Set are None, returns a dictionary of device types and their 70 values. Dictionary contains only those device types, whose values were set. If the 71 DeviceType is not None but Set is None, returns the current value of the device or 72 None if the device wasn't set. If Set is not None, sets a new value for the device. 73 @rtype: unicode, dict or None 74 ''' 75 if Set == None: # get 76 args = args2dict(self._Property('INPUT', Cache=False)) 77 for t in args: 78 if t == callIoDeviceTypePort: 79 args[t] = int(args[t]) 80 if DeviceType == None: # get active devices 81 return args 82 return args.get(DeviceType, None) 83 elif DeviceType != None: # set 84 self._Alter('SET_INPUT', '%s=%s' % (DeviceType, quote(unicode(Set), True))) 85 else: 86 raise TypeError('DeviceType must be specified if Set is used')
87
88 - def Open(self):
89 '''Opens and plays this voicemail. 90 ''' 91 self._Skype._DoCommand('OPEN VOICEMAIL %s' % self._Id)
92
93 - def OutputDevice(self, DeviceType=None, Set=None):
94 '''Queries or sets the sound output device. 95 96 @param DeviceType: Sound output device type or None. 97 @type DeviceType: L{Call IO device type<enums.callIoDeviceTypeUnknown>} or None 98 @param Set: Value the device should be set to or None. 99 @type Set: unicode, int or None 100 @return: If DeviceType and Set are None, returns a dictionary of device types and their 101 values. Dictionary contains only those device types, whose values were set. If the 102 DeviceType is not None but Set is None, returns the current value of the device or 103 None if the device wasn't set. If Set is not None, sets a new value for the device. 104 @rtype: unicode, dict or None 105 ''' 106 if Set == None: # get 107 args = args2dict(self._Property('OUTPUT', Cache=False)) 108 for t in args: 109 if t == callIoDeviceTypePort: 110 args[t] = int(args[t]) 111 if DeviceType == None: # get active devices 112 return args 113 return args.get(DeviceType, None) 114 elif DeviceType != None: # set 115 self._Alter('SET_OUTPUT', '%s=%s' % (DeviceType, quote(unicode(Set), True))) 116 else: 117 raise TypeError('DeviceType must be specified if Set is used')
118
119 - def SetUnplayed(self):
120 '''Changes the status of a voicemail from played to unplayed. 121 ''' 122 self._Property('STATUS', vmsUnplayed)
123
124 - def StartPlayback(self):
125 '''Starts playing downloaded voicemail. 126 ''' 127 self._Alter('STARTPLAYBACK')
128
129 - def StartPlaybackInCall(self):
130 '''Starts playing downloaded voicemail during a call. 131 ''' 132 self._Alter('STARTPLAYBACKINCALL')
133
134 - def StartRecording(self):
135 '''Stops playing a voicemail greeting and starts recording a voicemail message. 136 ''' 137 self._Alter('STARTRECORDING')
138
139 - def StopPlayback(self):
140 '''Stops playing downloaded voicemail. 141 ''' 142 self._Alter('STOPPLAYBACK')
143
144 - def StopRecording(self):
145 '''Ends the recording of a voicemail message. 146 ''' 147 self._Alter('STOPRECORDING')
148
149 - def Upload(self):
150 '''Uploads recorded voicemail from a local computer to the voicemail server. 151 ''' 152 self._Alter('UPLOAD')
153
154 - def _GetAllowedDuration(self):
155 return int(self._Property('ALLOWED_DURATION'))
156 157 AllowedDuration = property(_GetAllowedDuration, 158 doc='''Maximum voicemail duration in seconds allowed to leave to partner 159 160 @type: int 161 ''') 162
163 - def _GetDatetime(self):
164 from datetime import datetime 165 return datetime.fromtimestamp(self.Timestamp)
166 167 Datetime = property(_GetDatetime, 168 doc='''Timestamp of this voicemail expressed using datetime. 169 170 @type: datetime.datetime 171 ''') 172
173 - def _GetDuration(self):
174 return int(self._Property('DURATION'))
175 176 Duration = property(_GetDuration, 177 doc='''Actual voicemail duration in seconds. 178 179 @type: int 180 ''') 181
182 - def _GetFailureReason(self):
183 return self._Property('FAILUREREASON')
184 185 FailureReason = property(_GetFailureReason, 186 doc='''Voicemail failure reason. Read if L{Status} == L{vmsFailed<enums.vmsFailed>}. 187 188 @type: L{Voicemail failure reason<enums.vmrUnknown>} 189 ''') 190
191 - def _GetId(self):
192 return self._Id
193 194 Id = property(_GetId, 195 doc='''Unique voicemail Id. 196 197 @type: int 198 ''') 199
200 - def _GetPartnerDisplayName(self):
201 return self._Property('PARTNER_DISPNAME')
202 203 PartnerDisplayName = property(_GetPartnerDisplayName, 204 doc='''DisplayName for voicemail sender (for incoming) or recipient (for outgoing). 205 206 @type: unicode 207 ''') 208
209 - def _GetPartnerHandle(self):
210 return self._Property('PARTNER_HANDLE')
211 212 PartnerHandle = property(_GetPartnerHandle, 213 doc='''Skypename for voicemail sender (for incoming) or recipient (for outgoing). 214 215 @type: unicode 216 ''') 217
218 - def _GetStatus(self):
219 return self._Property('STATUS')
220 221 Status = property(_GetStatus, 222 doc='''Voicemail status. 223 224 @type: L{Voicemail status<enums.vmsUnknown>} 225 ''') 226
227 - def _GetTimestamp(self):
228 return float(self._Property('TIMESTAMP'))
229 230 Timestamp = property(_GetTimestamp, 231 doc='''Timestamp of this voicemail. 232 233 @type: float 234 ''') 235
236 - def _GetType(self):
237 return self._Property('TYPE')
238 239 Type = property(_GetType, 240 doc='''Voicemail type. 241 242 @type: L{Voicemail type<enums.vmtUnknown>} 243 ''')
244