File: convertors.h

package info (click to toggle)
python-gammu 0.26-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 648 kB
  • ctags: 643
  • sloc: ansic: 9,254; python: 1,770; makefile: 77; sh: 8
file content (394 lines) | stat: -rw-r--r-- 9,263 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
/*
 * python-gammu - Phone communication libary
 * Copyright © 2003 - 2008 Michal Čihař
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * vim: expandtab sw=4 ts=4 sts=4:
 */

#ifndef __pyg_convertors_h__
#define __pyg_convertors_h__

/* Python includes */
#include <Python.h>

/* Gammu includes */
#include <gammu.h>

#include <limits.h>

#include "misc.h"

/* Needed for Python 2.3, 2.4 has same included */
#ifndef Py_RETURN_NONE
#  define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
#endif

/**
 * Invalid value for bool.
 */
#define BOOL_INVALID ((bool)-1)

/**
 * Invalid value for integer.
 */
#define INT_INVALID (INT_MIN)

/**
 * Creates Python datetime.datetime from GSM_DateTime.
 */
PyObject *BuildPythonDateTime(const GSM_DateTime *dt);

/**
 * Creates Python datetime.time from GSM_DateTime.
 */
PyObject *BuildPythonTime(const GSM_DateTime *dt);

/**
 * Creates GSM_DateTime from Python datetime.time.
 */
int BuildGSMDateTime(PyObject *pydt, GSM_DateTime *dt);

/**
 * Creates GSM_DateTime from Python datetime.date.
 */
int BuildGSMDate(PyObject *pydt, GSM_DateTime *dt);

/**
 * Creates GSM_DateTime from Python datetime.time.
 */
int BuildGSMTime(PyObject *pydt, GSM_DateTime *dt);

/**
 * Convert Python unicode string to Gammu unicode string.
 */
unsigned char *strPythonToGammu(const Py_UNICODE *src, const size_t len);

/**
 * Converts either object to unicode and returns its value.
 */
unsigned char *StringPythonToGammu(PyObject *o);

/**
 * Convert Gammu unicode string to unicode string that can be read by Python.
 */
Py_UNICODE *strGammuToPython(const unsigned char *src);

/**
 * Convert Gammu unicode string with defined length to unicode string that can be read by Python.
 */
Py_UNICODE *strGammuToPythonL(const unsigned char *src, const int len);

/**
 * Convert Gammu unicode string to python unicode object.
 */
PyObject *UnicodeStringToPython(const unsigned char *src);

/**
 * Convert Gammu unicode string with defined length to python unicode object.
 */
PyObject *UnicodeStringToPythonL(const unsigned char *src, const int len);

/**
 * Converts locale encoded string to python unicode string.
 */
PyObject *LocaleStringToPython(const char *src);

/**
 * Converts string to CategoryType.
 */
GSM_CategoryType StringToCategoryType(const char *s);

/**
 * Converts string to MemoryType.
 */
GSM_MemoryType StringToMemoryType(const char *s);

/**
 * Converts MemoryType to string.
 */
char *MemoryTypeToString(const GSM_MemoryType t);

/**
 * Builds Python object containing all GSM_MemoryEntry values.
 */
PyObject *MemoryEntryToPython(const GSM_MemoryEntry *entry);

/**
 * Fills GSM_MemoryEntry from Pythons dictionary:.
 */
int MemoryEntryFromPython(PyObject *dict, GSM_MemoryEntry *entry, int needs_location);

/**
 * Gets integer from dictionary dict with key key.
 */
int GetIntFromDict(PyObject *dict, char *key);

/**
 * Gets bool from dictionary dict with key key.
 */
bool GetBoolFromDict(PyObject *dict, char *key);

/**
 * Gets C string from dictionary dict with key key.
 */
char *GetCStringFromDict(PyObject *dict, char *key);

/**
 * Gets gammu unicode string from dictionary dict with key key.
 */
unsigned char *GetStringFromDict(PyObject *dict, char *key);

/**
 * Copies unicode string from Python dictionary to Gammu string with length checking
 */
int CopyStringFromDict(PyObject *dict, char *key, int len, unsigned char *dest);

/**
 * Gets GSM_DateTime from dictionary dict with key key.
 */
GSM_DateTime GetDateTimeFromDict(PyObject *dict, char *key);

/**
 * Gets GSM_DateTime from dictionary dict with key key.
 */
GSM_DateTime GetDateFromDict(PyObject *dict, char *key);

/**
 * Gets char* from dictionary dict with key key. (doesn't allocate it!)
 */
char *GetCharFromDict(PyObject *dict, char *key);

/**
 * Gets char* with length (may contain NULs) from dictionary dict with key key. (doesn't allocate it!)
 */
char *GetDataFromDict(PyObject *dict, char *key, Py_ssize_t *len);

/**
 * Gets GSM_MemoryType from dictionary dict with key key.
 */
GSM_MemoryType GetMemoryTypeFromDict(PyObject *dict, char *key);

/**
 * Coverts cell broadcast message to Python object.
 */
PyObject *CBToPython(GSM_CBMessage *cb);

/**
 * Coverts USSD message to Python object.
 */
PyObject *USSDToPython(GSM_USSDMessage *ussd);

/**
 * Converts SMSValidity to string.
 */
char *SMSValidityToString(GSM_SMSValidity Validity);

/**
 * Creates SMSValidity from string.
 */
GSM_SMSValidity StringToSMSValidity(char *s);

/**
 * Converts SMSFormat to string.
 */
char *SMSFormatToString(GSM_SMSFormat f);

/**
 * Converts string to SMSFormat.
 */
GSM_SMSFormat StringToSMSFormat(char *s);

/**
 * Builds python object from GSM_SMSC.
 */
PyObject *SMSCToPython(GSM_SMSC *smsc);

/**
 * Parses python object into GMS_SMSC.
 */
int SMSCFromPython(PyObject* dict, GSM_SMSC *smsc, bool complete);

/**
 * Converts SMS to python object.
 */
PyObject *SMSToPython(GSM_SMSMessage *sms);

/**
 * Creates SMS from python object.
 */
int SMSFromPython(PyObject *dict, GSM_SMSMessage *sms, int needslocation, int needsfolder, int needsnumber);

/**
 * Converts MultiSMS to list of python object.
 */
PyObject *MultiSMSToPython(GSM_MultiSMSMessage *sms);

/**
 * Converts MultiSMS from list of python objects.
 */
int MultiSMSFromPython(PyObject *list, GSM_MultiSMSMessage *sms);

/**
 * Converts MultiSMS list from list of python objects.
 */
int MultiSMSListFromPython(PyObject *list, GSM_MultiSMSMessage ***sms);

/**
 * Converts MultiSMS list to list of python objects.
 */
PyObject *MultiSMSListToPython(GSM_MultiSMSMessage **sms);

/**
 * Converts SMS backup to list of Python objects.
 */
PyObject *SMSBackupToPython(GSM_SMS_Backup *sms);

/**
 * Converts SMS backup from list of Python objects.
 */
int SMSBackupFromPython(PyObject *list, GSM_SMS_Backup *sms);

/**
 * Converts Todo to Python object.
 */
PyObject *TodoToPython(const GSM_ToDoEntry *entry);

/**
 * Converts Todo from Python object.
 */
int TodoFromPython(PyObject *dict, GSM_ToDoEntry *entry, int needs_location);

/**
 * Convert calendar type to string.
 */
char *CalendarTypeToString(GSM_CalendarNoteType p);

/**
 * Convert string to calendar type.
 */
GSM_CalendarNoteType StringToCalendarType(const char *s);

/**
 * Converts Calendar to Python object.
 */
PyObject *CalendarToPython(const GSM_CalendarEntry *entry);

/**
 * Converts Calendar from Python object.
 */
int CalendarFromPython(PyObject *dict, GSM_CalendarEntry *entry, int needs_location);

/**
 * Converts SMSInfo to Python object.
 */
PyObject *SMSInfoToPython(GSM_MultiPartSMSInfo *smsinfo);

/**
 * Converts SMSInfo from Python object.
 */
int SMSInfoFromPython(PyObject *dict, GSM_MultiPartSMSInfo *entry);

/**
 * Converts Bitmap to Python object.
 */
PyObject *BitmapToPython(GSM_Bitmap *bitmap);

/**
 * Converts multiple Bitmaps to list of Python objects.
 */
PyObject *MultiBitmapToPython(GSM_MultiBitmap *bmp);

/**
 * Converts Bitmap from Python object.
 */
int BitmapFromPython(PyObject *data, GSM_Bitmap *bitmap);

/**
 * Converts multiple Bitmaps from list of Python objects.
 */
int MultiBitmapFromPython(PyObject *list, GSM_MultiBitmap *bmp);

/**
 * Converts SMS folders structure to list of Python objects.
 */
PyObject *SMSFoldersToPython(GSM_SMSFolders *folders);

/**
 * Converts ringtone to Python object.
 */
PyObject *RingtoneToPython(GSM_Ringtone *ring);

/**
 * Converts ringtone from Python object.
 */
int RingtoneFromPython(PyObject *dict, GSM_Ringtone *ring);

/**
 * Converts backup to Python object.
 */
PyObject *BackupToPython(GSM_Backup *backup);

/**
 * Converts backup from Python object.
 */
int BackupFromPython(PyObject *dict, GSM_Backup *backup);

/**
 * Converts backup format from string to Gammu.
 */
int BackupFormatFromString(const char *s, GSM_BackupFormat *format);

/**
 * Converts file to Python object.
 */
PyObject *FileToPython(GSM_File *file);

/**
 * Converts file from Python object.
 */
int FileFromPython(PyObject *dict, GSM_File *file, bool check);

/**
 * Converts call to Python object.
 */
PyObject *CallToPython(GSM_Call *call);

/**
 * Converts call type to Python object.
 */
char *CallStatusToString(GSM_CallStatus ct);

/**
 * Converts MMS indicator to Python object.
 */
PyObject *MMSIndicatorToPython(GSM_MMSIndicator *mms);

/**
 * Converts MMS indicator from Python object.
 */
int MMSIndicatorFromPython(PyObject* dict, GSM_MMSIndicator *mms);

/**
 * Converts WAP bookmark to Python object.
 */
PyObject *WAPBookmarkToPython(GSM_WAPBookmark *wap);

/**
 * Converts WAP bookmark from Python object.
 */
int WAPBookmarkFromPython(PyObject* dict, GSM_WAPBookmark *wap);

#endif