Imported gammu 0.90.7
[gammu.git] / common / service / sms / gsmsms.h
blobc5f5c1305fa04c5493fbddaf5a163b18eb3c80ae
2 #ifndef __gsm_sms_h
3 #define __gsm_sms_h
5 #include "../../gsmcomon.h"
6 #include "../gsmlogo.h"
7 #include "../gsmcal.h"
8 #include "../gsmpbk.h"
9 #include "../gsmwap.h"
10 #include "../gsmring.h"
12 /* --------------------- Some general definitions ------------------------- */
14 #define GSM_MAX_UDH_LENGTH 140
15 #define GSM_MAX_SMS_LENGTH 160
16 #define GSM_MAX_8BIT_SMS_LENGTH 140
18 /* -------------------- Cell Broadcast ------------------------------------ */
20 /**
21 * Structure for Cell Broadcast message.
23 typedef struct {
24 /**
25 * Channel number.
27 int Channel;
28 /**
29 * Message text.
31 char Text[300];
32 } GSM_CBMessage;
34 /* ------------------------ SMS status ------------------------------------ */
36 /**
37 * Status of SMS memory.
39 typedef struct {
40 /**
41 * Number of unread messages in SIM.
43 int SIMUnRead;
44 /**
45 * Number of all used messages in SIM.
47 int SIMUsed;
48 /**
49 * Number of all possible messages on SIM.
51 int SIMSize;
52 /**
53 * Number of unread messages in phone.
55 int PhoneUnRead;
56 /**
57 * Number of all used messages in phone.
59 int PhoneUsed;
60 /**
61 * Number of all possible messages on phone.
63 int PhoneSize;
64 /**
65 * Number of used templates (62xx/63xx/7110/etc.).
67 int TemplatesUsed;
68 } GSM_SMSMemoryStatus;
70 /* --------------------- SMS Center --------------------------------------- */
72 /**
73 * SMS Messages sent as...
75 typedef enum {
76 GSMF_Pager = 1,
77 GSMF_Fax,
78 GSMF_Email,
79 GSMF_Text
80 } GSM_SMSFormat;
82 /**
83 * Length of validity for SMS messages.
85 typedef enum {
86 GSMV_1_Hour = 0x0b,
87 GSMV_6_Hours = 0x47,
88 GSMV_24_Hours = 0xa7,
89 GSMV_72_Hours = 0xa9,
90 GSMV_1_Week = 0xad,
91 GSMV_Max_Time = 0xff
92 } GSM_ValidityPeriod;
94 /**
95 * Format of validity perion.
97 typedef enum {
98 GSM_NoValidityPeriod = 1,
99 GSM_RelativeFormat
100 /* ... */
101 } GSM_ValidityPeriodFormat;
104 * Validity of SMS message.
106 typedef struct {
107 GSM_ValidityPeriodFormat VPF;
108 GSM_ValidityPeriod Relative;
109 } GSM_SMSValidity;
111 #define GSM_MAX_SMSC_NAME_LENGTH 30
114 * Structure for SMSC (SMS Center) information.
116 typedef struct {
118 * Number of the SMSC in the phone memory.
120 int Location;
122 * Name of the SMSC.
124 unsigned char Name[(GSM_MAX_SMSC_NAME_LENGTH+1)*2];
126 * Format of sent SMSes.
128 GSM_SMSFormat Format;
130 * Validity of SMS.
132 GSM_SMSValidity Validity;
134 * SMSC number.
136 unsigned char Number[(GSM_MAX_NUMBER_LENGTH+1)*2];
138 * Default recipient number.
140 unsigned char DefaultNumber[(GSM_MAX_NUMBER_LENGTH+1)*2];
141 } GSM_SMSC;
143 /* --------------------- single SMS --------------------------------------- */
146 * Status of SMS message.
148 typedef enum {
149 GSM_Sent = 1,
150 GSM_UnSent,
151 GSM_Read,
152 GSM_UnRead
153 } GSM_SMS_State;
156 * Coding type of SMS.
158 typedef enum {
160 * Unicode
162 GSM_Coding_Unicode = 1,
164 * Default GSM aplhabet.
166 GSM_Coding_Default,
168 * 8-bit.
170 GSM_Coding_8bit
171 } GSM_Coding_Type;
174 * Types of UDH (User Data Header).
176 typedef enum {
177 UDH_NoUDH = 1,
179 * Linked SMS.
181 UDH_ConcatenatedMessages,
183 * Linked SMS with 16 bit reference.
185 UDH_ConcatenatedMessages16bit,
186 UDH_DisableVoice,
187 UDH_DisableFax,
188 UDH_DisableEmail,
189 UDH_EnableVoice,
190 UDH_EnableFax,
191 UDH_EnableEmail,
192 UDH_VoidSMS,
193 UDH_NokiaRingtone,
194 UDH_NokiaRingtoneLong,
195 UDH_NokiaOperatorLogo,
196 UDH_NokiaOperatorLogoLong,
197 UDH_NokiaCallerLogo,
198 UDH_NokiaWAP,
199 UDH_NokiaWAPLong,
200 UDH_NokiaCalendarLong,
201 UDH_NokiaProfileLong,
202 UDH_NokiaPhonebookLong,
203 UDH_UserUDH,
204 UDH_MMSIndicatorLong
205 } GSM_UDH;
208 * Structure to hold UDH Header.
210 typedef struct {
212 * UDH type.
214 GSM_UDH Type;
216 * UDH length.
218 int Length;
220 * UDH text.
222 unsigned char Text[GSM_MAX_UDH_LENGTH];
224 * 8-bit ID, when required (-1 otherwise).
226 int ID8bit;
228 * 16-bit ID, when required (-1 otherwise).
230 int ID16bit;
232 * Number of current part.
234 int PartNumber;
236 * Total number of parts.
238 int AllParts;
239 } GSM_UDHHeader;
242 * TP-Message-Type-Indicator, see GSM 03.40 version 6.1.0 Release 1997 Section 9.2.3.1.
244 typedef enum {
246 * Save SMS in Inbox.
248 SMS_Deliver = 1,
250 * Delivery Report received by phone.
252 SMS_Status_Report,
254 * Send SMS or save it in Outbox.
256 SMS_Submit
257 /*...*/
258 } GSM_SMSMessageType;
261 * Maximal length of SMS name.
263 #define GSM_MAX_SMS_NAME_LENGTH 40
266 * SMS message data.
268 typedef struct {
270 * Message center.
272 GSM_SMSC SMSC;
274 * UDH (User Defined Header).
276 GSM_UDHHeader UDH;
278 * Folder, where SMS is saved.
280 int Folder;
282 * Whether it is really inbox.
284 bool InboxFolder;
286 * Where exactly it's saved
288 GSM_MemoryType Memory;
290 * Location of SMS in memory.
292 int Location;
294 * Length of the SMS message.
296 int Length;
298 * Name in Nokia 6210/7110, etc. Ignored in other.
300 unsigned char Name[(GSM_MAX_SMS_NAME_LENGTH+1)*2];
302 * Sender or recipient number.
304 unsigned char Number[(GSM_MAX_NUMBER_LENGTH+1)*2];
306 * Text for SMS.
308 unsigned char Text[(GSM_MAX_SMS_LENGTH+1)*2];
310 * Type of message.
312 GSM_SMSMessageType PDU;
314 * Type of coding.
316 GSM_Coding_Type Coding;
318 * Date of reception/response of messages.
320 GSM_DateTime DateTime;
322 * Date of SMSC response in DeliveryReport messages.
324 GSM_DateTime SMSCTime;
326 * In delivery reports: status.
328 unsigned char DeliveryStatus;
330 * Indicates whether "Reply via same center" is set.
332 bool ReplyViaSameSMSC;
333 /**
334 * State (read/unread/...) of SMS.
336 GSM_SMS_State State;
338 * SMS class.
340 char Class;
342 * Message reference.
344 unsigned char MessageReference;
346 * Message to be replaced.
348 unsigned char ReplaceMessage;
350 * Whether to reject duplicates.
352 bool RejectDuplicates;
353 } GSM_SMSMessage;
355 /* In layouts are saved locations for some SMS part. Below are listed
356 * specs, which describe them
358 typedef struct {
360 * TP-User-Data. GSM 03.40 section 9.2.3.24.
362 unsigned char Text;
364 * - In SMS-Deliver: TP-Originating-Address. GSM 03.40 section 9.2.3.7.
365 * - In SMS-Submit: TP-Destination-Address. GSM 03.40 section 9.2.3.8.
366 * - In SMS-Status-Report: TP-Recipient-Address. GSM 03.40 section 9.2.3.14.
368 unsigned char Number;
370 * SMSC number
372 unsigned char SMSCNumber;
374 * TP-Data-Coding-Scheme. GSM 03.40 section 9.2.3.10
376 unsigned char TPDCS;
378 * - For SMS-Submit: TP-Validity-Period. GSM 03.40 section 9.2.3.12.
379 * - For SMS-Status-Report: TP-Discharge Time. GSM 03.40 section 9.2.3.13.
381 unsigned char DateTime;
383 * TP-Service-Centre-Time-Stamp in SMS-Status-Report. GSM 03.40 section 9.2.3.11.
385 unsigned char SMSCTime;
387 * TP-Status in SMS-Status-Report. GSM 03.40 section 9.2.3.15.
389 unsigned char TPStatus;
391 * TP-User-Data-Length. GSM 03.40 section 9.2.3.16.
393 unsigned char TPUDL;
395 * TP-Validity Period in SMS-Submit. GSM 03.40 section 9.2.3.12.
397 unsigned char TPVP;
399 * Byte contains in SMS-Deliver:
400 * - TP-Message-Type-Indicator (2 bits) GSM 03.40 section 9.2.3.1
401 * - TP-More-Messages-To-Send (1 bit). GSM 03.40 section 9.2.3.2
402 * - TP-Reply-Path (1 bit). GSM 03.40 section 9.2.3.17
403 * - TP-User-Data-Header-Indicator (1 bit). GSM 03.40 section 9.2.3.23
404 * - TP-Status-Report-Indicator (1 bit). GSM 03.40 section 9.2.3.4
406 * Byte contains in SMS-Submit:
407 * - TP-Message-Type-Indicator (2 bits) GSM 03.40 section 9.2.3.1
408 * - TP-Reject-Duplicates (1 bit). GSM 03.40 section
409 * - TP-Validity-Period-Format (2 bits).GSM 03.40 section 9.2.3.3
410 * - TP-Reply-Path (1 bit). GSM 03.40 section 9.2.3.17
411 * - TP-User-Data-Header-Indicator (1 bit). GSM 03.40 section 9.2.3.23
412 * - TP-Status-Report-Request (1 bit). GSM 03.40 section 9.2.3.5
414 unsigned char firstbyte;
416 * TP-Message Reference in SMS-Submit. GSM 03.40 section 9.2.3.6
418 unsigned char TPMR;
420 * TP-Protocol-Identifier. GSM 03.40 section 9.2.3.9
422 unsigned char TPPID;
423 } GSM_SMSMessageLayout;
425 GSM_Error GSM_DecodeSMSFrame(GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout);
426 GSM_Error GSM_EncodeSMSFrame(GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout, int *length, bool clear);
428 GSM_Error GSM_DecodeSMSFrameStatusReportData (GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout);
429 GSM_Error GSM_DecodeSMSFrameText (GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout);
431 void GSM_DecodeUDHHeader(GSM_UDHHeader *UDH);
432 void GSM_EncodeUDHHeader(GSM_UDHHeader *UDH);
434 void GSM_SetDefaultSMSData(GSM_SMSMessage *SMS);
436 /* ---------------------- SMS folders ------------------------------------- */
439 * Number of possible SMS folders.
441 #define GSM_MAX_SMS_FOLDERS 24
443 * Maximal length of SMS folder name.
445 #define GSM_MAX_SMS_FOLDER_NAME_LEN 16
448 * Information about SMS folder.
450 typedef struct {
452 * Whether it is really inbox.
454 bool InboxFolder;
456 * Where exactly it's saved
458 GSM_MemoryType Memory;
460 * Name for SMS folder.
462 char Name[(GSM_MAX_SMS_FOLDER_NAME_LEN+1)*2];
463 } GSM_OneSMSFolder;
466 * List of SMS folders.
468 typedef struct {
470 * Array of structures holding information about each folder.
472 GSM_OneSMSFolder Folder[GSM_MAX_SMS_FOLDERS];
474 * Number of SMS folders.
476 unsigned char Number;
477 } GSM_SMSFolders;
479 #endif
481 /* How should editor hadle tabs in this file? Add editor commands here.
482 * vim: noexpandtab sw=8 ts=8 sts=8: