summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/service/sms/gsmsms.h
Unidiff
Diffstat (limited to 'gammu/emb/common/service/sms/gsmsms.h') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/service/sms/gsmsms.h492
1 files changed, 492 insertions, 0 deletions
diff --git a/gammu/emb/common/service/sms/gsmsms.h b/gammu/emb/common/service/sms/gsmsms.h
new file mode 100644
index 0000000..d87ff60
--- a/dev/null
+++ b/gammu/emb/common/service/sms/gsmsms.h
@@ -0,0 +1,492 @@
1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Pawel Kot, others and Gnokii */
3
4#ifndef __gsm_sms_h
5#define __gsm_sms_h
6
7#include "../../gsmcomon.h"
8#include "../gsmlogo.h"
9#include "../gsmcal.h"
10#include "../gsmpbk.h"
11#include "../gsmdata.h"
12#include "../gsmring.h"
13
14/* --------------------- Some general definitions ------------------------- */
15
16 #define GSM_MAX_UDH_LENGTH 140
17 #define GSM_MAX_SMS_LENGTH 160
18 #define GSM_MAX_8BIT_SMS_LENGTH 140
19
20/* -------------------- Cell Broadcast ------------------------------------ */
21
22/**
23 * Structure for Cell Broadcast messages.
24 */
25typedef struct {
26 /**
27 * Message text.
28 */
29 char Text[300];
30 /**
31 * Channel number.
32 */
33 int Channel;
34} GSM_CBMessage;
35
36/* ------------------------ SMS status ------------------------------------ */
37
38/**
39 * Status of SMS memory.
40 */
41typedef struct {
42 /**
43 * Number of unread messages on SIM.
44 */
45 int SIMUnRead;
46 /**
47 * Number of all saved messages (including unread) on SIM.
48 */
49 int SIMUsed;
50 /**
51 * Number of all possible messages on SIM.
52 */
53 int SIMSize;
54 /**
55 * Number of used templates (62xx/63xx/7110/etc.).
56 */
57 int TemplatesUsed;
58 /**
59 * Number of unread messages in phone.
60 */
61 int PhoneUnRead;
62 /**
63 * Number of all saved messages in phone.
64 */
65 int PhoneUsed;
66 /**
67 * Number of all possible messages on phone.
68 */
69 int PhoneSize;
70} GSM_SMSMemoryStatus;
71
72/* --------------------- SMS Center --------------------------------------- */
73
74/**
75 * Enum defines format of SMS messages. See GSM 03.40 section 9.2.3.9
76 */
77typedef enum {
78 SMS_FORMAT_Pager = 1,
79 SMS_FORMAT_Fax,
80 SMS_FORMAT_Email,
81 SMS_FORMAT_Text
82 /* Some values not handled here */
83} GSM_SMSFormat;
84
85/**
86 * Enum defines some the most often used validity lengths for SMS messages
87 * for relative validity format. See GSM 03.40 section 9.2.3.12.1 - it gives
88 * more values
89 */
90typedef enum {
91 SMS_VALID_1_Hour = 0x0b,
92 SMS_VALID_6_Hours = 0x47,
93 SMS_VALID_1_Day = 0xa7,
94 SMS_VALID_3_Days = 0xa9,
95 SMS_VALID_1_Week = 0xad,
96 SMS_VALID_Max_Time = 0xff
97} GSM_ValidityPeriod;
98
99/**
100 * Enum defines format of validity period for SMS messages.
101 * See GSM 03.40 section 9.2.3.12
102 */
103typedef enum {
104 SMS_Validity_NotAvailable = 1,
105 SMS_Validity_RelativeFormat
106 /* Specification gives also other possibilities */
107} GSM_ValidityPeriodFormat;
108
109/**
110 * Structure for validity of SMS messages
111 */
112typedef struct {
113 GSM_ValidityPeriodFormatFormat;
114 /**
115 * Value defines period for relative format
116 */
117 GSM_ValidityPeriod Relative;
118} GSM_SMSValidity;
119
120 #define GSM_MAX_SMSC_NAME_LENGTH30
121
122/**
123 * Structure for SMSC (SMS Center) information.
124 */
125typedef struct {
126 /**
127 * Number of the SMSC on SIM
128 */
129 int Location;
130 /**
131 * Name of the SMSC
132 */
133 unsigned char Name[(GSM_MAX_SMSC_NAME_LENGTH+1)*2];
134 /**
135 * SMSC phone number.
136 */
137 unsigned char Number[(GSM_MAX_NUMBER_LENGTH+1)*2];
138 /**
139 * Validity of SMS messages.
140 */
141 GSM_SMSValidity Validity;
142 /**
143 * Format of sent SMS messages.
144 */
145 GSM_SMSFormat Format;
146 /**
147 * Default recipient number. In old DCT3 ignored
148 */
149 unsigned char DefaultNumber[(GSM_MAX_NUMBER_LENGTH+1)*2];
150} GSM_SMSC;
151
152/* --------------------- single SMS --------------------------------------- */
153
154/**
155 * Status of SMS message.
156 */
157typedef enum {
158 SMS_Sent = 1,
159 SMS_UnSent,
160 SMS_Read,
161 SMS_UnRead
162} GSM_SMS_State;
163
164/**
165 * Coding type of SMS.
166 */
167typedef enum {
168 /**
169 * Unicode
170 */
171 SMS_Coding_Unicode = 1,
172 /**
173 * Default GSM aplhabet.
174 */
175 SMS_Coding_Default,
176 /**
177 * 8-bit.
178 */
179 SMS_Coding_8bit
180} GSM_Coding_Type;
181
182/**
183 * Types of UDH (User Data Header).
184 */
185typedef enum {
186 UDH_NoUDH = 1,
187 /**
188 * Linked SMS.
189 */
190 UDH_ConcatenatedMessages,
191 /**
192 * Linked SMS with 16 bit reference.
193 */
194 UDH_ConcatenatedMessages16bit,
195 UDH_DisableVoice,
196 UDH_DisableFax,
197 UDH_DisableEmail,
198 UDH_EnableVoice,
199 UDH_EnableFax,
200 UDH_EnableEmail,
201 UDH_VoidSMS,
202 UDH_NokiaRingtone,
203 UDH_NokiaRingtoneLong,
204 UDH_NokiaOperatorLogo,
205 UDH_NokiaOperatorLogoLong,
206 UDH_NokiaCallerLogo,
207 UDH_NokiaWAP,
208 UDH_NokiaWAPLong,
209 UDH_NokiaCalendarLong,
210 UDH_NokiaProfileLong,
211 UDH_NokiaPhonebookLong,
212 UDH_UserUDH,
213 UDH_MMSIndicatorLong
214} GSM_UDH;
215
216/**
217 * Structure for User Data Header.
218 */
219typedef struct {
220 /**
221 * UDH type.
222 */
223 GSM_UDH Type;
224 /**
225 * UDH length.
226 */
227 int Length;
228 /**
229 * UDH text.
230 */
231 unsigned char Text[GSM_MAX_UDH_LENGTH];
232 /**
233 * 8-bit ID, when required (-1 otherwise).
234 */
235 int ID8bit;
236 /**
237 * 16-bit ID, when required (-1 otherwise).
238 */
239 int ID16bit;
240 /**
241 * Number of current part.
242 */
243 int PartNumber;
244 /**
245 * Total number of parts.
246 */
247 int AllParts;
248} GSM_UDHHeader;
249
250/**
251 * TP-Message-Type-Indicator. See GSM 03.40 section 9.2.3.1.
252 */
253 typedef enum {
254 /**
255 * SMS in Inbox.
256 */
257 SMS_Deliver = 1,
258 /**
259 * Delivery Report
260 */
261 SMS_Status_Report,
262 /**
263 * SMS for sending or in Outbox
264 */
265 SMS_Submit
266 /* specification gives more */
267} GSM_SMSMessageType;
268
269/**
270 * Maximal length of SMS name.
271 */
272 #define GSM_MAX_SMS_NAME_LENGTH 40
273
274/**
275 * SMS message data.
276 */
277typedef struct {
278 /**
279 * Message to be replaced.
280 */
281 unsigned char ReplaceMessage;
282 /**
283 * Whether to reject duplicates.
284 */
285 bool RejectDuplicates;
286 /**
287 * UDH (User Data Header)
288 */
289 GSM_UDHHeader UDH;
290 /**
291 * Sender or recipient number.
292 */
293 unsigned char Number[(GSM_MAX_NUMBER_LENGTH+1)*2];
294 /**
295 * SMSC (SMS Center)
296 */
297 GSM_SMSC SMSC;
298 /**
299 * For saved SMS: where exactly it's saved (SIM/phone)
300 */
301 GSM_MemoryType Memory;
302 /**
303 * For saved SMS: location of SMS in memory.
304 */
305 int Location;
306 /**
307 * For saved SMS: number of folder, where SMS is saved
308 */
309 int Folder;
310 /**
311 * For saved SMS: whether SMS is really in Inbox.
312 */
313 bool InboxFolder;
314 /**
315 * Length of the SMS message.
316 */
317 int Length;
318 /**
319 * Status (read/unread/...) of SMS message.
320 */
321 GSM_SMS_State State;
322 /**
323 * Name in Nokia with SMS memory (6210/7110, etc.) Ignored in other.
324 */
325 unsigned char Name[(GSM_MAX_SMS_NAME_LENGTH+1)*2];
326 /**
327 * Text for SMS.
328 */
329 unsigned char Text[(GSM_MAX_SMS_LENGTH+1)*2];
330 /**
331 * Type of message.
332 */
333 GSM_SMSMessageType PDU;
334 /**
335 * Type of coding.
336 */
337 GSM_Coding_Type Coding;
338 /**
339 * Date and time, when SMS was saved or sent
340 */
341 GSM_DateTime DateTime;
342 /**
343 * Date of SMSC response in DeliveryReport messages.
344 */
345 GSM_DateTime SMSCTime;
346 /**
347 * In delivery reports: status.
348 */
349 unsigned char DeliveryStatus;
350 /**
351 * Indicates whether "Reply via same center" is set.
352 */
353 bool ReplyViaSameSMSC;
354 /**
355 * SMS class.
356 */
357 char Class;
358 /**
359 * Message reference.
360 */
361 unsigned char MessageReference;
362} GSM_SMSMessage;
363
364/* In layouts are saved locations for some SMS part. Below are listed
365 * specs, which describe them
366 */
367typedef struct {
368 /**
369 * TP-User-Data. GSM 03.40 section 9.2.3.24.
370 */
371 unsigned char Text;
372 /**
373 * - In SMS-Deliver: TP-Originating-Address. GSM 03.40 section 9.2.3.7.
374 * - In SMS-Submit: TP-Destination-Address. GSM 03.40 section 9.2.3.8.
375 * - In SMS-Status-Report: TP-Recipient-Address. GSM 03.40 section 9.2.3.14.
376 */
377 unsigned char Number;
378 /**
379 * SMSC number
380 */
381 unsigned char SMSCNumber;
382 /**
383 * TP-Data-Coding-Scheme. GSM 03.40 section 9.2.3.10
384 */
385 unsigned char TPDCS;
386 /**
387 * - For SMS-Submit: TP-Validity-Period. GSM 03.40 section 9.2.3.12.
388 * - For SMS-Status-Report: TP-Discharge Time. GSM 03.40 section 9.2.3.13.
389 */
390 unsigned char DateTime;
391 /**
392 * TP-Service-Centre-Time-Stamp in SMS-Status-Report. GSM 03.40 section 9.2.3.11.
393 */
394 unsigned char SMSCTime;
395 /**
396 * TP-Status in SMS-Status-Report. GSM 03.40 section 9.2.3.15.
397 */
398 unsigned char TPStatus;
399 /**
400 * TP-User-Data-Length. GSM 03.40 section 9.2.3.16.
401 */
402 unsigned char TPUDL;
403 /**
404 * TP-Validity Period in SMS-Submit. GSM 03.40 section 9.2.3.12.
405 */
406 unsigned char TPVP;
407 /**
408 * Byte contains in SMS-Deliver:
409 * - TP-Message-Type-Indicator (2 bits) GSM 03.40 section 9.2.3.1
410 * - TP-More-Messages-To-Send (1 bit). GSM 03.40 section 9.2.3.2
411 * - TP-Reply-Path (1 bit). GSM 03.40 section 9.2.3.17
412 * - TP-User-Data-Header-Indicator (1 bit). GSM 03.40 section 9.2.3.23
413 * - TP-Status-Report-Indicator (1 bit). GSM 03.40 section 9.2.3.4
414 *
415 * Byte contains in SMS-Submit:
416 * - TP-Message-Type-Indicator (2 bits) GSM 03.40 section 9.2.3.1
417 * - TP-Reject-Duplicates (1 bit). GSM 03.40 section
418 * - TP-Validity-Period-Format (2 bits).GSM 03.40 section 9.2.3.3
419 * - TP-Reply-Path (1 bit). GSM 03.40 section 9.2.3.17
420 * - TP-User-Data-Header-Indicator (1 bit). GSM 03.40 section 9.2.3.23
421 * - TP-Status-Report-Request (1 bit). GSM 03.40 section 9.2.3.5
422 */
423 unsigned char firstbyte;
424 /**
425 * TP-Message Reference in SMS-Submit. GSM 03.40 section 9.2.3.6
426 */
427 unsigned char TPMR;
428 /**
429 * TP-Protocol-Identifier. GSM 03.40 section 9.2.3.9
430 */
431 unsigned char TPPID;
432} GSM_SMSMessageLayout;
433
434GSM_Error GSM_DecodeSMSFrame(GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout);
435GSM_Error GSM_EncodeSMSFrame(GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout, int *length, bool clear);
436
437GSM_Error GSM_DecodeSMSFrameStatusReportData (GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout);
438 GSM_Error GSM_DecodeSMSFrameText (GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout);
439
440void GSM_DecodeUDHHeader(GSM_UDHHeader *UDH);
441void GSM_EncodeUDHHeader(GSM_UDHHeader *UDH);
442
443void GSM_SetDefaultSMSData(GSM_SMSMessage *SMS);
444
445/* ---------------------- SMS folders ------------------------------------- */
446
447/**
448 * Number of possible SMS folders.
449 */
450 #define GSM_MAX_SMS_FOLDERS 24
451/**
452 * Maximal length of SMS folder name.
453 */
454#define GSM_MAX_SMS_FOLDER_NAME_LEN 20
455
456/**
457 * Information about SMS folder.
458 */
459typedef struct {
460 /**
461 * Whether it is really inbox.
462 */
463 bool InboxFolder;
464 /**
465 * Where exactly it's saved
466 */
467 GSM_MemoryType Memory;
468 /**
469 * Name for SMS folder.
470 */
471 char Name[(GSM_MAX_SMS_FOLDER_NAME_LEN+1)*2];
472} GSM_OneSMSFolder;
473
474/**
475 * List of SMS folders.
476 */
477typedef struct {
478 /**
479 * Array of structures holding information about each folder.
480 */
481 GSM_OneSMSFolderFolder[GSM_MAX_SMS_FOLDERS];
482 /**
483 * Number of SMS folders.
484 */
485 unsigned char Number;
486} GSM_SMSFolders;
487
488#endif
489
490/* How should editor hadle tabs in this file? Add editor commands here.
491 * vim: noexpandtab sw=8 ts=8 sts=8:
492 */