Imported gammu 0.90.0
[gammu.git] / common / service / gsmsms.h
blobe46af4978377b5722c456acb6767841bc317405b
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 * Define datatype 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 messafes 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 * Maximum number of 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 /* ---------------------- multi SMS --------------------------------------- */
481 /* Identifiers for Smart Messaging 3.0 multipart SMS */
483 #define SM30_ISOTEXT 0 /* ISO 8859-1 text */
484 #define SM30_UNICODETEXT 1
485 #define SM30_OTA 2
486 #define SM30_RINGTONE 3
487 #define SM30_PROFILENAME 4
488 #define SM30_SCREENSAVER 6
490 void GSM_SMSCounter(int MessageLength,
491 unsigned char *MessageBuffer,
492 GSM_UDH UDHType,
493 GSM_Coding_Type Coding,
494 int *SMSNum,
495 int *CharsLeft);
497 #define MAX_MULTI_SMS 10
500 * Multiple SMS messages, used for Smart Messaging 3.0/EMS.
502 typedef struct {
504 * Sender or recipient number.
506 unsigned char Number;
508 * Array of SMSes.
510 GSM_SMSMessage SMS[MAX_MULTI_SMS];
511 } GSM_MultiSMSMessage;
513 GSM_Error GSM_AddSMS_Text_UDH(GSM_MultiSMSMessage *SMS,
514 GSM_Coding_Type Coding,
515 char *Buffer,
516 int BufferLen,
517 bool UDH,
518 int *UsedText,
519 int *CopiedText,
520 int *CopiedSMSText);
522 void GSM_MakeMultiPartSMS(GSM_MultiSMSMessage *SMS,
523 unsigned char *MessageBuffer,
524 int MessageLength,
525 GSM_UDH UDHType,
526 GSM_Coding_Type Coding,
527 int Class,
528 unsigned char RejectDuplicates);
531 * ID during packing SMS for Smart Messaging 3.0, EMS and other
533 typedef enum {
535 * 1 text SMS.
537 SMS_Text = 1,
539 * Contacenated SMS, when longer than 1 SMS.
541 SMS_ConcatenatedTextLong,
543 * Contacenated SMS, auto Default/Unicode coding.
545 SMS_ConcatenatedAutoTextLong,
546 SMS_ConcatenatedTextLong16bit,
547 SMS_ConcatenatedAutoTextLong16bit,
549 * Nokia profile = Name, Ringtone, ScreenSaver
551 SMS_NokiaProfileLong,
553 * Nokia Picture Image + (text)
555 SMS_NokiaPictureImageLong,
557 * Nokia screen saver + (text)
559 SMS_NokiaScreenSaverLong,
561 * Nokia ringtone - old SM2.0 format, 1 SMS
563 SMS_NokiaRingtone,
565 * Nokia ringtone contacenated, when very long
567 SMS_NokiaRingtoneLong,
569 * Nokia 72x14 operator logo, 1 SMS
571 SMS_NokiaOperatorLogo,
573 * Nokia 72x14 op logo or 78x21 in 2 SMS
575 SMS_NokiaOperatorLogoLong,
577 * Nokia 72x14 caller logo, 1 SMS
579 SMS_NokiaCallerLogo,
581 * Nokia WAP bookmark in 1 or 2 SMS
583 SMS_NokiaWAPBookmarkLong,
585 * Nokia WAP settings in 2 SMS
587 SMS_NokiaWAPSettingsLong,
589 * Nokia MMS settings in 2 SMS
591 SMS_NokiaMMSSettingsLong,
593 * Nokia VCARD 1.0 - only name and default number
595 SMS_NokiaVCARD10Long,
597 * Nokia VCARD 2.1 - all numbers + text
599 SMS_NokiaVCARD21Long,
601 * Nokia VCALENDAR 1.0 - can be in few sms
603 SMS_NokiaVCALENDAR10Long,
604 SMS_NokiaVTODOLong,
605 SMS_VCARD10Long,
606 SMS_VCARD21Long,
607 SMS_DisableVoice,
608 SMS_DisableFax,
609 SMS_DisableEmail,
610 SMS_EnableVoice,
611 SMS_EnableFax,
612 SMS_EnableEmail,
613 SMS_VoidSMS,
615 * IMelody 1.0
617 SMS_EMSSound10,
619 * IMelody 1.2
621 SMS_EMSSound12,
623 * IMelody without header - SonyEricsson extension
625 SMS_EMSSonyEricssonSound,
627 * IMelody 1.0 with UPI.
629 SMS_EMSSound10Long,
630 /***
631 * IMelody 1.2 with UPI.
633 SMS_EMSSound12Long,
635 * IMelody without header with UPI.
637 SMS_EMSSonyEricssonSoundLong,
638 SMS_EMSPredefinedSound,
639 SMS_EMSPredefinedAnimation,
640 SMS_EMSAnimation,
642 * Fixed bitmap of size 16x16 or 32x32.
644 SMS_EMSFixedBitmap,
645 SMS_EMSVariableBitmap,
646 SMS_EMSVariableBitmapLong,
647 SMS_MMSIndicatorLong
648 } EncodeMultiPartSMSID;
650 typedef struct {
651 EncodeMultiPartSMSID ID;
653 int Number;
654 GSM_Ringtone *Ringtone;
655 GSM_MultiBitmap *Bitmap;
656 GSM_WAPBookmark *Bookmark;
657 GSM_WAPSettings *Settings;
658 GSM_MMSIndicator *MMSIndicator;
659 GSM_MemoryEntry *Phonebook;
660 GSM_CalendarEntry *Calendar;
661 GSM_ToDoEntry *ToDo;
662 bool Protected;
664 unsigned char *Buffer;
665 bool Left;
666 bool Right;
667 bool Center;
668 bool Large;
669 bool Small;
670 bool Bold;
671 bool Italic;
672 bool Underlined;
673 bool Strikethrough;
675 /* Return values */
676 int RingtoneNotes;
677 } EncodeMultiPartSMSEntry;
679 typedef struct {
680 /* Input values */
681 EncodeMultiPartSMSEntry Entries[MAX_MULTI_SMS];
682 int EntriesNum;
683 bool UnicodeCoding;
684 int Class;
685 unsigned char ReplaceMessage;
686 } GSM_EncodeMultiPartSMSInfo;
688 GSM_Error GSM_EncodeMultiPartSMS (GSM_EncodeMultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS);
689 bool GSM_DecodeMultiPartSMS (GSM_EncodeMultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS);
690 void GSM_ClearMultiPartSMSInfo (GSM_EncodeMultiPartSMSInfo *Info);
692 GSM_Error GSM_SortSMS(GSM_MultiSMSMessage *INPUT[200], GSM_MultiSMSMessage *OUTPUT[200]);
694 #endif /* __gsm_sms_h */
696 /* How should editor hadle tabs in this file? Add editor commands here.
697 * vim: noexpandtab sw=8 ts=8 sts=8: