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