1 '''Voicemails.
2 '''
3
4 from utils import *
5 from enums import *
6 from errors import *
7
8
10 '''Represents a voicemail.
11 '''
12
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
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:
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:
45 return args
46 return args.get(DeviceType, None)
47 elif DeviceType != None:
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
53 '''Deletes this voicemail.
54 '''
55 self._Alter('DELETE')
56
58 '''Downloads this voicemail object from the voicemail server to a local computer.
59 '''
60 self._Alter('DOWNLOAD')
61
87
89 '''Opens and plays this voicemail.
90 '''
91 self._Skype._DoCommand('OPEN VOICEMAIL %s' % self._Id)
92
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:
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:
112 return args
113 return args.get(DeviceType, None)
114 elif DeviceType != None:
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
120 '''Changes the status of a voicemail from played to unplayed.
121 '''
122 self._Property('STATUS', vmsUnplayed)
123
125 '''Starts playing downloaded voicemail.
126 '''
127 self._Alter('STARTPLAYBACK')
128
130 '''Starts playing downloaded voicemail during a call.
131 '''
132 self._Alter('STARTPLAYBACKINCALL')
133
135 '''Stops playing a voicemail greeting and starts recording a voicemail message.
136 '''
137 self._Alter('STARTRECORDING')
138
140 '''Stops playing downloaded voicemail.
141 '''
142 self._Alter('STOPPLAYBACK')
143
145 '''Ends the recording of a voicemail message.
146 '''
147 self._Alter('STOPRECORDING')
148
150 '''Uploads recorded voicemail from a local computer to the voicemail server.
151 '''
152 self._Alter('UPLOAD')
153
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
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
174 return int(self._Property('DURATION'))
175
176 Duration = property(_GetDuration,
177 doc='''Actual voicemail duration in seconds.
178
179 @type: int
180 ''')
181
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
193
194 Id = property(_GetId,
195 doc='''Unique voicemail Id.
196
197 @type: int
198 ''')
199
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
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
219 return self._Property('STATUS')
220
221 Status = property(_GetStatus,
222 doc='''Voicemail status.
223
224 @type: L{Voicemail status<enums.vmsUnknown>}
225 ''')
226
228 return float(self._Property('TIMESTAMP'))
229
230 Timestamp = property(_GetTimestamp,
231 doc='''Timestamp of this voicemail.
232
233 @type: float
234 ''')
235
237 return self._Property('TYPE')
238
239 Type = property(_GetType,
240 doc='''Voicemail type.
241
242 @type: L{Voicemail type<enums.vmtUnknown>}
243 ''')
244