1 """Short messaging system.
2 """
3 __docformat__ = 'restructuredtext en'
4
5
6 from utils import *
7
8
10 """Represents an SMS message.
11 """
12 _ValidateHandle = int
13
16
17 - def _Alter(self, AlterName, Args=None):
18 return self._Owner._Alter('SMS', self.Id, AlterName, Args)
19
22
23 - def _Property(self, PropName, Set=None, Cache=True):
24 return self._Owner._Property('SMS', self.Id, PropName, Set, Cache)
25
27 """Deletes this SMS message.
28 """
29 self._Owner._DoCommand('DELETE SMS %s' % self.Id)
30
32 """Marks this SMS message as seen.
33 """
34 self._Owner._DoCommand('SET SMS %s SEEN' % self.Id)
35
37 """Sends this SMS message.
38 """
39 self._Alter('SEND')
40
42 return self._Property('BODY')
43
44 - def _SetBody(self, Value):
45 self._Property('BODY', Value)
46
47 Body = property(_GetBody, _SetBody,
48 doc="""Text of this SMS message.
49
50 :type: unicode
51 """)
52
55
56 Chunks = property(_GetChunks,
57 doc="""Chunks of this SMS message. More than one if this is a multi-part message.
58
59 :type: `SmsChunkCollection`
60 """)
61
63 from datetime import datetime
64 return datetime.fromtimestamp(self.Timestamp)
65
66 Datetime = property(_GetDatetime,
67 doc="""Timestamp of this SMS message as datetime object.
68
69 :type: datetime.datetime
70 """)
71
73 return str(self._Property('FAILUREREASON'))
74
75 FailureReason = property(_GetFailureReason,
76 doc="""Reason an SMS message failed. Read this if `Status` == `enums.smsMessageStatusFailed`.
77
78 :type: `enums`.smsFailureReason*
79 """)
80
83
84 Id = property(_GetId,
85 doc="""Unique SMS message Id.
86
87 :type: int
88 """)
89
91 return (self._Property('IS_FAILED_UNSEEN') == 'TRUE')
92
93 IsFailedUnseen = property(_GetIsFailedUnseen,
94 doc="""Tells if a failed SMS message was unseen.
95
96 :type: bool
97 """)
98
100 return int(self._Property('PRICE'))
101
102 Price = property(_GetPrice,
103 doc="""SMS price. Expressed using `PricePrecision`. For a value expressed using `PriceCurrency`, use `PriceValue`.
104
105 :type: int
106
107 :see: `PriceCurrency`, `PricePrecision`, `PriceToText`, `PriceValue`
108 """)
109
111 return self._Property('PRICE_CURRENCY')
112
113 PriceCurrency = property(_GetPriceCurrency,
114 doc="""SMS price currency.
115
116 :type: unicode
117
118 :see: `Price`, `PricePrecision`, `PriceToText`, `PriceValue`
119 """)
120
122 return int(self._Property('PRICE_PRECISION'))
123
124 PricePrecision = property(_GetPricePrecision,
125 doc="""SMS price precision.
126
127 :type: int
128
129 :see: `Price`, `PriceCurrency`, `PriceToText`, `PriceValue`
130 """)
131
132 - def _GetPriceToText(self):
133 return (u'%s %.3f' % (self.PriceCurrency, self.PriceValue)).strip()
134
135 PriceToText = property(_GetPriceToText,
136 doc="""SMS price as properly formatted text with currency.
137
138 :type: unicode
139
140 :see: `Price`, `PriceCurrency`, `PricePrecision`, `PriceValue`
141 """)
142
147
148 PriceValue = property(_GetPriceValue,
149 doc="""SMS price. Expressed in `PriceCurrency`.
150
151 :type: float
152
153 :see: `Price`, `PriceCurrency`, `PricePrecision`, `PriceToText`
154 """)
155
157 return str(self._Property('REPLY_TO_NUMBER'))
158
160 self._Property('REPLY_TO_NUMBER', Value)
161
162 ReplyToNumber = property(_GetReplyToNumber, _SetReplyToNumber,
163 doc="""Reply-to number for this SMS message.
164
165 :type: str
166 """)
167
169 from warnings import warn
170 warn('SmsMessage.Seen = x: Use SmsMessage.MarkAsSeen() instead.', DeprecationWarning, stacklevel=2)
171 if Value:
172 self.MarkAsSeen()
173 else:
174 raise SkypeError(0, 'Seen can only be set to True')
175
176 Seen = property(fset=_SetSeen,
177 doc="""Set the read status of the SMS message. Accepts only True value.
178
179 :type: bool
180
181 :deprecated: Extremely unpythonic, use `MarkAsSeen` instead.
182 """)
183
185 return str(self._Property('STATUS'))
186
187 Status = property(_GetStatus,
188 doc="""SMS message status.
189
190 :type: `enums`.smsMessageStatus*
191 """)
192
194 return tuple(split(self._Property('TARGET_NUMBERS'), ', '))
195
197 self._Property('TARGET_NUMBERS', ', '.join(Value))
198
199 TargetNumbers = property(_GetTargetNumbers, _SetTargetNumbers,
200 doc="""Target phone numbers.
201
202 :type: tuple of str
203 """)
204
207
208 Targets = property(_GetTargets,
209 doc="""Target objects.
210
211 :type: `SmsTargetCollection`
212 """)
213
215 return float(self._Property('TIMESTAMP'))
216
217 Timestamp = property(_GetTimestamp,
218 doc="""Timestamp of this SMS message.
219
220 :type: float
221
222 :see: `Datetime`
223 """)
224
226 return str(self._Property('TYPE'))
227
228 Type = property(_GetType,
229 doc="""SMS message type
230
231 :type: `enums`.smsMessageType*
232 """)
233
234
237
238
240 """Represents a single chunk of a multi-part SMS message.
241 """
242 _ValidateHandle = int
243
246
252
253 CharactersLeft = property(_GetCharactersLeft,
254 doc="""CharactersLeft.
255
256 :type: int
257 """)
258
261
262 Id = property(_GetId,
263 doc="""SMS chunk Id.
264
265 :type: int
266 """)
267
270
271 Message = property(_GetMessage,
272 doc="""SMS message associated with this chunk.
273
274 :type: `SmsMessage`
275 """)
276
277 - def _GetText(self):
278 return self.Message._Property('CHUNK %s' % self.Id)
279
280 Text = property(_GetText,
281 doc="""Text (body) of this SMS chunk.
282
283 :type: unicode
284 """)
285
286
289
290
292 """Represents a single target of a multi-target SMS message.
293 """
294 _ValidateHandle = str
295
298
301
302 Message = property(_GetMessage,
303 doc="""An SMS message object this target refers to.
304
305 :type: `SmsMessage`
306 """)
307
310
311 Number = property(_GetNumber,
312 doc="""Target phone number.
313
314 :type: str
315 """)
316
318 for t in split(self.Message._Property('TARGET_STATUSES'), ', '):
319 number, status = t.split('=')
320 if number == self.Number:
321 return str(status)
322
323 Status = property(_GetStatus,
324 doc="""Status of this target.
325
326 :type: `enums`.smsTargetStatus*
327 """)
328
329
332