1 /** 2 * \file gammu-message.h 3 * \author Michal Čihař 4 * 5 * Message data and functions. 6 */ 7 #ifndef __gammu_message_h 8 #define __gammu_message_h 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 #include <gammu-limits.h> 15 #include <gammu-memory.h> 16 #include <gammu-datetime.h> 17 #include <gammu-ringtone.h> 18 #include <gammu-bitmap.h> 19 #include <gammu-wap.h> 20 #include <gammu-calendar.h> 21 #include <gammu-file.h> 22 #include <gammu-debug.h> 23 24 /** 25 * \defgroup Message Messages 26 * Messages manipulations. 27 */ 28 29 /** 30 * \defgroup USSD USSD messages 31 * USSD messages manipulations. 32 * \ingroup Message 33 */ 34 35 /** 36 * \defgroup CB CB messages 37 * Cell broadcast messages manipulations. 38 * \ingroup Message 39 */ 40 41 /** 42 * \defgroup SMS SMS messages 43 * SMS messages manipulations. 44 * \ingroup Message 45 */ 46 47 /** 48 * \defgroup MMS MMS messages 49 * MMS messages manipulations. 50 * \ingroup Message 51 */ 52 53 /** 54 * MMS message class. 55 */ 56 typedef enum { 57 /** 58 * None class specified. 59 */ 60 GSM_MMS_None = 0, 61 /** 62 * Personal message. 63 */ 64 GSM_MMS_Personal = 1, 65 /** 66 * Advertisement message. 67 */ 68 GSM_MMS_Advertisement, 69 /** 70 * Informational message. 71 */ 72 GSM_MMS_Info, 73 /** 74 * Automatic message class. 75 */ 76 GSM_MMS_Auto, 77 78 GSM_MMS_INVALID 79 } GSM_MMS_Class; 80 81 /** 82 * MMS indicator data. 83 * 84 * \ingroup MMS 85 */ 86 typedef struct { 87 /** 88 * Message address (URL for download). 89 */ 90 char Address[500]; 91 /** 92 * Message title (subject). 93 */ 94 char Title[200]; 95 /** 96 * Message sender. 97 */ 98 char Sender[200]; 99 /** 100 * Message size, if 0 it won't be decoded or was not decoded. 101 */ 102 size_t MessageSize; 103 /** 104 * Class of a message. 105 */ 106 GSM_MMS_Class Class; 107 } GSM_MMSIndicator; 108 109 /** 110 * Structure for Cell Broadcast messages. 111 * 112 * \ingroup CB 113 */ 114 typedef struct { 115 /** 116 * Channel number. 117 */ 118 int Channel; 119 /** 120 * Message text. 121 */ 122 char Text[300]; 123 } GSM_CBMessage; 124 125 /** 126 * Status of USSD message. 127 * 128 * \ingroup USSD 129 */ 130 typedef enum { 131 /** 132 * Unknown status 133 */ 134 USSD_Unknown = 1, 135 /** 136 * No action is needed, maybe network initiated USSD 137 */ 138 USSD_NoActionNeeded, 139 /** 140 * Reply is expected 141 */ 142 USSD_ActionNeeded, 143 /** 144 * USSD dialog terminated 145 */ 146 USSD_Terminated, 147 /** 148 * Another client replied 149 */ 150 USSD_AnotherClient, 151 /** 152 * Operation not supported 153 */ 154 USSD_NotSupported, 155 /** 156 * Network timeout 157 */ 158 USSD_Timeout, 159 } GSM_USSDStatus; 160 161 /** 162 * Structure for USSD messages. 163 * 164 * \ingroup USSD 165 */ 166 typedef struct { 167 /** 168 * Message text. 169 */ 170 unsigned char Text[2 * (GSM_MAX_USSD_LENGTH + 1)]; 171 /** 172 * Message status. 173 */ 174 GSM_USSDStatus Status; 175 } GSM_USSDMessage; 176 177 /** 178 * Status of SMS memory. 179 * 180 * \ingroup SMS 181 */ 182 typedef struct { 183 /** 184 * Number of unread messages on SIM. 185 */ 186 int SIMUnRead; 187 /** 188 * Number of all saved messages (including unread) on SIM. 189 */ 190 int SIMUsed; 191 /** 192 * Number of all possible messages on SIM. 193 */ 194 int SIMSize; 195 /** 196 * Number of used templates (62xx/63xx/7110/etc.). 197 */ 198 int TemplatesUsed; 199 /** 200 * Number of unread messages in phone. 201 */ 202 int PhoneUnRead; 203 /** 204 * Number of all saved messages in phone. 205 */ 206 int PhoneUsed; 207 /** 208 * Number of all possible messages on phone. 209 */ 210 int PhoneSize; 211 } GSM_SMSMemoryStatus; 212 213 /** 214 * Enum defines format of SMS messages. See GSM 03.40 section 9.2.3.9 215 * 216 * \ingroup SMS 217 */ 218 typedef enum { 219 SMS_FORMAT_Pager = 1, 220 SMS_FORMAT_Fax, 221 SMS_FORMAT_Email, 222 SMS_FORMAT_Text 223 /* Some values not handled here */ 224 } GSM_SMSFormat; 225 226 /** 227 * Enum defines some the most often used validity lengths for SMS messages 228 * for relative validity format. See GSM 03.40 section 9.2.3.12.1 - it gives 229 * more values. 230 * 231 * \ingroup SMS 232 */ 233 typedef enum { 234 SMS_VALID_1_Hour = 0x0b, 235 SMS_VALID_6_Hours = 0x47, 236 SMS_VALID_1_Day = 0xa7, 237 SMS_VALID_3_Days = 0xa9, 238 SMS_VALID_1_Week = 0xad, 239 SMS_VALID_Max_Time = 0xff 240 } GSM_ValidityPeriod; 241 242 /** 243 * Enum defines format of validity period for SMS messages. 244 * See GSM 03.40 section 9.2.3.12 245 * 246 * \ingroup SMS 247 */ 248 typedef enum { 249 SMS_Validity_NotAvailable = 1, 250 SMS_Validity_RelativeFormat 251 /* Specification gives also other possibilities */ 252 } GSM_ValidityPeriodFormat; 253 254 /** 255 * Structure for validity of SMS messages 256 * 257 * \ingroup SMS 258 */ 259 typedef struct { 260 GSM_ValidityPeriodFormat Format; 261 /** 262 * Value defines period for relative format 263 */ 264 GSM_ValidityPeriod Relative; 265 } GSM_SMSValidity; 266 267 /** 268 * Structure for SMSC (SMS Center) information. 269 * 270 * \ingroup SMS 271 */ 272 typedef struct { 273 /** 274 * Number of the SMSC on SIM 275 */ 276 int Location; 277 /** 278 * Name of the SMSC 279 */ 280 unsigned char Name[(GSM_MAX_SMSC_NAME_LENGTH + 1) * 2]; 281 /** 282 * SMSC phone number. 283 */ 284 unsigned char Number[(GSM_MAX_NUMBER_LENGTH + 1) * 2]; 285 /** 286 * Validity of SMS messages. 287 */ 288 GSM_SMSValidity Validity; 289 /** 290 * Format of sent SMS messages. 291 */ 292 GSM_SMSFormat Format; 293 /** 294 * Default recipient number. In old DCT3 ignored 295 */ 296 unsigned char DefaultNumber[(GSM_MAX_NUMBER_LENGTH + 1) * 2]; 297 } GSM_SMSC; 298 299 /** 300 * Status of SMS message. 301 * 302 * \ingroup SMS 303 */ 304 typedef enum { 305 SMS_Sent = 1, 306 SMS_UnSent, 307 SMS_Read, 308 SMS_UnRead 309 } GSM_SMS_State; 310 311 /** 312 * Coding type of SMS. 313 * 314 * \ingroup SMS 315 */ 316 typedef enum { 317 /** 318 * Unicode 319 */ 320 SMS_Coding_Unicode_No_Compression = 1, 321 SMS_Coding_Unicode_Compression, 322 /** 323 * Default GSM alphabet. 324 */ 325 SMS_Coding_Default_No_Compression, 326 SMS_Coding_Default_Compression, 327 /** 328 * 8-bit. 329 */ 330 SMS_Coding_8bit 331 } GSM_Coding_Type; 332 333 /** 334 * Converts SMS coding to string. 335 * 336 * \return Pointer to static string, NULL on failure. 337 */ 338 const char *GSM_SMSCodingToString(GSM_Coding_Type type); 339 340 /** 341 * Converts SMS coding to type. 342 */ 343 GSM_Coding_Type GSM_StringToSMSCoding(const char *s); 344 345 /** 346 * Types of UDH (User Data Header). 347 * 348 * \ingroup SMS 349 */ 350 typedef enum { 351 UDH_NoUDH = 1, 352 /** 353 * Linked SMS. 354 */ 355 UDH_ConcatenatedMessages, 356 /** 357 * Linked SMS with 16 bit reference. 358 */ 359 UDH_ConcatenatedMessages16bit, 360 UDH_DisableVoice, 361 UDH_DisableFax, 362 UDH_DisableEmail, 363 UDH_EnableVoice, 364 UDH_EnableFax, 365 UDH_EnableEmail, 366 UDH_VoidSMS, 367 UDH_NokiaRingtone, 368 UDH_NokiaRingtoneLong, 369 UDH_NokiaOperatorLogo, 370 UDH_NokiaOperatorLogoLong, 371 UDH_NokiaCallerLogo, 372 UDH_NokiaWAP, 373 UDH_NokiaWAPLong, 374 UDH_NokiaCalendarLong, 375 UDH_NokiaProfileLong, 376 UDH_NokiaPhonebookLong, 377 UDH_UserUDH, 378 UDH_MMSIndicatorLong 379 } GSM_UDH; 380 381 /** 382 * Structure for User Data Header. 383 * 384 * \ingroup SMS 385 */ 386 typedef struct { 387 /** 388 * UDH type. 389 */ 390 GSM_UDH Type; 391 /** 392 * UDH length. 393 */ 394 int Length; 395 /** 396 * UDH text. 397 */ 398 unsigned char Text[GSM_MAX_UDH_LENGTH]; 399 /** 400 * 8-bit ID, when required (-1 otherwise). 401 */ 402 int ID8bit; 403 /** 404 * 16-bit ID, when required (-1 otherwise). 405 */ 406 int ID16bit; 407 /** 408 * Number of current part. 409 */ 410 int PartNumber; 411 /** 412 * Total number of parts. 413 */ 414 int AllParts; 415 } GSM_UDHHeader; 416 417 /** 418 * TP-Message-Type-Indicator. See GSM 03.40 section 9.2.3.1. 419 * 420 * \ingroup SMS 421 */ 422 typedef enum { 423 /** 424 * SMS in Inbox. 425 */ 426 SMS_Deliver = 1, 427 /** 428 * Delivery Report 429 */ 430 SMS_Status_Report, 431 /** 432 * SMS for sending or in Outbox 433 */ 434 SMS_Submit 435 /* specification gives more */ 436 } GSM_SMSMessageType; 437 438 /** 439 * SMS message class. 440 * 441 * \ingroup SMS 442 */ 443 typedef enum { 444 GSM_SMS_None = -1, 445 GSM_SMS_Flash, 446 GSM_SMS_Normal, 447 GSM_SMS_USSD = 127 448 } GSM_SMS_Class; 449 450 /** 451 * SMS message data. 452 * 453 * \ingroup SMS 454 */ 455 typedef struct { 456 /** 457 * Message to be replaced. 458 */ 459 unsigned char ReplaceMessage; 460 /** 461 * Whether to reject duplicates. 462 */ 463 gboolean RejectDuplicates; 464 /** 465 * UDH (User Data Header) 466 */ 467 GSM_UDHHeader UDH; 468 /** 469 * Sender or recipient number. 470 */ 471 unsigned char Number[(GSM_MAX_NUMBER_LENGTH + 1) * 2]; 472 473 unsigned char 474 OtherNumbers[GSM_SMS_OTHER_NUMBERS][(GSM_MAX_NUMBER_LENGTH + 1) * 2]; 475 int OtherNumbersNum; 476 477 /** 478 * SMSC (SMS Center) 479 */ 480 GSM_SMSC SMSC; 481 /** 482 * For saved SMS: where exactly it's saved (SIM/phone) 483 */ 484 GSM_MemoryType Memory; 485 /** 486 * For saved SMS: location of SMS in memory. 487 */ 488 int Location; 489 /** 490 * For saved SMS: number of folder, where SMS is saved 491 */ 492 int Folder; 493 /** 494 * For saved SMS: whether SMS is really in Inbox. 495 */ 496 gboolean InboxFolder; 497 /** 498 * Length of the SMS message. 499 */ 500 int Length; 501 /** 502 * Status (read/unread/...) of SMS message. 503 */ 504 GSM_SMS_State State; 505 /** 506 * Name in Nokia with SMS memory (6210/7110, etc.) Ignored in other. 507 */ 508 unsigned char Name[(GSM_MAX_SMS_NAME_LENGTH + 1) * 2]; 509 /** 510 * Text for SMS. 511 */ 512 unsigned char Text[(GSM_MAX_SMS_LENGTH + 1) * 2]; 513 /** 514 * Type of message. 515 */ 516 GSM_SMSMessageType PDU; 517 /** 518 * Type of coding. 519 */ 520 GSM_Coding_Type Coding; 521 /** 522 * Date and time, when SMS was saved or sent 523 */ 524 GSM_DateTime DateTime; 525 /** 526 * Date of SMSC response in DeliveryReport messages. 527 */ 528 GSM_DateTime SMSCTime; 529 /** 530 * In delivery reports: status. 531 */ 532 unsigned char DeliveryStatus; 533 /** 534 * Indicates whether "Reply via same center" is set. 535 */ 536 gboolean ReplyViaSameSMSC; 537 /** 538 * SMS class (0 is flash SMS, 1 is normal one). 539 */ 540 signed char Class; 541 /** 542 * Message reference. 543 */ 544 unsigned char MessageReference; 545 } GSM_SMSMessage; 546 547 /* In layouts are saved locations for some SMS part. Below are listed 548 * specs, which describe them 549 * 550 * \ingroup SMS 551 */ 552 typedef struct { 553 /** 554 * TP-User-Data. GSM 03.40 section 9.2.3.24. 555 */ 556 unsigned char Text; 557 /** 558 * - In SMS-Deliver: TP-Originating-Address. GSM 03.40 section 9.2.3.7. 559 * - In SMS-Submit: TP-Destination-Address. GSM 03.40 section 9.2.3.8. 560 * - In SMS-Status-Report: TP-Recipient-Address. GSM 03.40 section 9.2.3.14. 561 */ 562 unsigned char Number; 563 /** 564 * SMSC number 565 */ 566 unsigned char SMSCNumber; 567 /** 568 * TP-Data-Coding-Scheme. GSM 03.40 section 9.2.3.10. 569 * Contains alphabet type, SMS class (and some others) 570 */ 571 unsigned char TPDCS; 572 /** 573 * - For SMS-Submit: TP-Validity-Period. GSM 03.40 section 9.2.3.12. 574 * - For SMS-Status-Report: TP-Discharge Time. GSM 03.40 section 9.2.3.13. 575 */ 576 unsigned char DateTime; 577 /** 578 * TP-Service-Centre-Time-Stamp in SMS-Status-Report. GSM 03.40 section 9.2.3.11. 579 */ 580 unsigned char SMSCTime; 581 /** 582 * TP-Status in SMS-Status-Report. GSM 03.40 section 9.2.3.15. 583 */ 584 unsigned char TPStatus; 585 /** 586 * TP-User-Data-Length. GSM 03.40 section 9.2.3.16. 587 */ 588 unsigned char TPUDL; 589 /** 590 * TP-Validity Period in SMS-Submit. GSM 03.40 section 9.2.3.12. 591 */ 592 unsigned char TPVP; 593 /** 594 * Byte contains in SMS-Deliver: 595 * - TP-Message-Type-Indicator (2 bits) GSM 03.40 section 9.2.3.1 596 * - TP-More-Messages-To-Send (1 bit). GSM 03.40 section 9.2.3.2 597 * - TP-Reply-Path (1 bit). GSM 03.40 section 9.2.3.17 598 * - TP-User-Data-Header-Indicator (1 bit). GSM 03.40 section 9.2.3.23 599 * - TP-Status-Report-Indicator (1 bit). GSM 03.40 section 9.2.3.4 600 * 601 * Byte contains in SMS-Submit: 602 * - TP-Message-Type-Indicator (2 bits) GSM 03.40 section 9.2.3.1 603 * - TP-Reject-Duplicates (1 bit). GSM 03.40 section 604 * - TP-Validity-Period-Format (2 bits).GSM 03.40 section 9.2.3.3 605 * - TP-Reply-Path (1 bit). GSM 03.40 section 9.2.3.17 606 * - TP-User-Data-Header-Indicator (1 bit). GSM 03.40 section 9.2.3.23 607 * - TP-Status-Report-Request (1 bit). GSM 03.40 section 9.2.3.5 608 */ 609 unsigned char firstbyte; 610 /** 611 * TP-Message Reference in SMS-Submit. GSM 03.40 section 9.2.3.6 612 */ 613 unsigned char TPMR; 614 /** 615 * TP-Protocol-Identifier. GSM 03.40 section 9.2.3.9 616 */ 617 unsigned char TPPID; 618 } GSM_SMSMessageLayout; 619 620 /** 621 * Decodes PDU data. 622 * 623 * \param di Debug information structure. 624 * \param SMS Pointer where to store parsed message. 625 * \param buffer PDU data. 626 * \param length Length of PDU data. 627 * \param final_pos Optional pointer where end position will be stored. 628 * \param SMSC Whether PDU includes SMSC data. 629 * 630 * \ingroup SMS 631 */ 632 GSM_Error GSM_DecodePDUFrame(GSM_Debug_Info *di, GSM_SMSMessage *SMS, 633 const unsigned char *buffer, size_t length, 634 size_t *final_pos, gboolean SMSC); 635 636 /** 637 * Decodes SMS frame. 638 * 639 * \ingroup SMS 640 */ 641 GSM_Error GSM_DecodeSMSFrame(GSM_Debug_Info * di, GSM_SMSMessage * SMS, 642 unsigned char *buffer, 643 GSM_SMSMessageLayout Layout); 644 645 /** 646 * Finds out coding type based on TPDCS header byte as defined by GSM 647 * 03.38. 648 */ 649 GSM_Coding_Type GSM_GetMessageCoding(GSM_Debug_Info * di, const char TPDCS); 650 651 /** 652 * Encodes SMS frame. 653 * 654 * \ingroup SMS 655 */ 656 GSM_Error GSM_EncodeSMSFrame(GSM_Debug_Info * di, GSM_SMSMessage * SMS, 657 unsigned char *buffer, GSM_SMSMessageLayout Layout, 658 int *length, gboolean clear); 659 660 /** 661 * Decodes SMS frame for status report. 662 * 663 * \ingroup SMS 664 */ 665 GSM_Error GSM_DecodeSMSFrameStatusReportData(GSM_Debug_Info * di, 666 GSM_SMSMessage * SMS, 667 unsigned char *buffer, 668 GSM_SMSMessageLayout Layout); 669 670 /** 671 * Decodes SMS frame in textual representation. 672 * 673 * \ingroup SMS 674 */ 675 GSM_Error GSM_DecodeSMSFrameText(GSM_Debug_Info * di, GSM_SMSMessage * SMS, 676 unsigned char *buffer, 677 GSM_SMSMessageLayout Layout); 678 679 /** 680 * Decodes UDH header. 681 * 682 * \ingroup SMS 683 */ 684 void GSM_DecodeUDHHeader(GSM_Debug_Info * di, GSM_UDHHeader * UDH); 685 686 /** 687 * Encodes UDH header. 688 * 689 * \ingroup SMS 690 */ 691 void GSM_EncodeUDHHeader(GSM_Debug_Info * di, GSM_UDHHeader * UDH); 692 693 /** 694 * Sets default content for SMS except for changing locations. 695 * Use this for clearing structure while keeping location of message. 696 * 697 * \param SMS Pointer to structure which should be cleaned up. 698 * 699 * \ingroup SMS 700 */ 701 void GSM_SetDefaultReceivedSMSData(GSM_SMSMessage * SMS); 702 703 /** 704 * Sets default content for SMS. Use this for clearing structure. 705 * 706 * \param SMS Pointer to structure which should be cleaned up. 707 * 708 * \ingroup SMS 709 */ 710 void GSM_SetDefaultSMSData(GSM_SMSMessage * SMS); 711 712 /** 713 * Information about SMS folder. 714 * 715 * \ingroup SMS 716 */ 717 typedef struct { 718 /** 719 * Whether it is inbox. 720 */ 721 gboolean InboxFolder; 722 /** 723 * Whether it is outbox. 724 */ 725 gboolean OutboxFolder; 726 /** 727 * Where exactly it's saved. 728 */ 729 GSM_MemoryType Memory; 730 /** 731 * Name of the folder 732 */ 733 unsigned char Name[(GSM_MAX_SMS_FOLDER_NAME_LEN + 1) * 2]; 734 } GSM_OneSMSFolder; 735 736 /** 737 * List of SMS folders. 738 * 739 * \ingroup SMS 740 */ 741 typedef struct { 742 /** 743 * Array of structures holding information about each folder. 744 */ 745 GSM_OneSMSFolder Folder[GSM_MAX_SMS_FOLDERS]; 746 /** 747 * Number of SMS folders. 748 */ 749 int Number; 750 } GSM_SMSFolders; 751 752 /** 753 * Siemens OTA data. 754 * 755 * \ingroup SMS 756 */ 757 typedef struct { 758 unsigned long SequenceID; 759 unsigned int PacketsNum; 760 unsigned int PacketNum; 761 unsigned long AllDataLen; 762 763 unsigned char DataType[10]; 764 unsigned char DataName[40]; 765 unsigned int DataLen; 766 unsigned char Data[140]; 767 } GSM_SiemensOTASMSInfo; 768 769 /** 770 * Decodes Siemens OTA data. 771 * 772 * \ingroup SMS 773 */ 774 gboolean GSM_DecodeSiemensOTASMS(GSM_Debug_Info * di, 775 GSM_SiemensOTASMSInfo * Info, 776 GSM_SMSMessage * SMS); 777 778 /** 779 * Multiple SMS messages, used for Smart Messaging 3.0/EMS. 780 * 781 * \ingroup SMS 782 */ 783 typedef struct { 784 /** 785 * Number of messages. 786 */ 787 int Number; 788 /** 789 * Array of SMSes. 790 */ 791 GSM_SMSMessage SMS[GSM_MAX_MULTI_SMS]; 792 /** 793 * Boolean flag for processing 794 */ 795 gboolean Processed; 796 } GSM_MultiSMSMessage; 797 798 /** 799 * Information about MMS folder. 800 * 801 * \ingroup MMS 802 */ 803 typedef struct { 804 /** 805 * Whether it is really inbox. 806 */ 807 gboolean InboxFolder; 808 /** 809 * Name for MMS folder. 810 */ 811 char Name[(GSM_MAX_MMS_FOLDER_NAME_LEN + 1) * 2]; 812 } GSM_OneMMSFolder; 813 814 /** 815 * List of MMS folders. 816 * 817 * \ingroup MMS 818 */ 819 typedef struct { 820 /** 821 * Number of MMS folders. 822 */ 823 unsigned char Number; 824 /** 825 * Array of structures holding information about each folder. 826 */ 827 GSM_OneMMSFolder Folder[GSM_MAX_MMS_FOLDERS]; 828 } GSM_MMSFolders; 829 830 /** 831 * Layout for submit message. 832 * 833 * \ingroup SMS 834 */ 835 extern GSM_SMSMessageLayout PHONE_SMSSubmit; 836 837 /** 838 * Layout for deliver message. 839 * 840 * \ingroup SMS 841 */ 842 extern GSM_SMSMessageLayout PHONE_SMSDeliver; 843 844 /** 845 * Layout for status report message. 846 * 847 * \ingroup SMS 848 */ 849 extern GSM_SMSMessageLayout PHONE_SMSStatusReport; 850 851 /** 852 * ID during packing SMS for Smart Messaging 3.0, EMS and other 853 * 854 * \ingroup SMS 855 */ 856 typedef enum { 857 /** 858 * 1 text SMS. 859 */ 860 SMS_Text = 1, 861 /** 862 * Contacenated SMS, when longer than 1 SMS. 863 */ 864 SMS_ConcatenatedTextLong, 865 /** 866 * Contacenated SMS, auto Default/Unicode coding. 867 */ 868 SMS_ConcatenatedAutoTextLong, 869 SMS_ConcatenatedTextLong16bit, 870 SMS_ConcatenatedAutoTextLong16bit, 871 /** 872 * Nokia profile = Name, Ringtone, ScreenSaver 873 */ 874 SMS_NokiaProfileLong, 875 /** 876 * Nokia Picture Image + (text) 877 */ 878 SMS_NokiaPictureImageLong, 879 /** 880 * Nokia screen saver + (text) 881 */ 882 SMS_NokiaScreenSaverLong, 883 /** 884 * Nokia ringtone - old SM2.0 format, 1 SMS 885 */ 886 SMS_NokiaRingtone, 887 /** 888 * Nokia ringtone contacenated, when very long 889 */ 890 SMS_NokiaRingtoneLong, 891 /** 892 * Nokia 72x14 operator logo, 1 SMS 893 */ 894 SMS_NokiaOperatorLogo, 895 /** 896 * Nokia 72x14 op logo or 78x21 in 2 SMS 897 */ 898 SMS_NokiaOperatorLogoLong, 899 /** 900 * Nokia 72x14 caller logo, 1 SMS 901 */ 902 SMS_NokiaCallerLogo, 903 /** 904 * Nokia WAP bookmark in 1 or 2 SMS 905 */ 906 SMS_NokiaWAPBookmarkLong, 907 /** 908 * Nokia WAP settings in 2 SMS 909 */ 910 SMS_NokiaWAPSettingsLong, 911 /** 912 * Nokia MMS settings in 2 SMS 913 */ 914 SMS_NokiaMMSSettingsLong, 915 /** 916 * Nokia VCARD 1.0 - only name and default number 917 */ 918 SMS_NokiaVCARD10Long, 919 /** 920 * Nokia VCARD 2.1 - all numbers + text 921 */ 922 SMS_NokiaVCARD21Long, 923 /** 924 * Nokia VCALENDAR 1.0 - can be in few sms 925 */ 926 SMS_NokiaVCALENDAR10Long, 927 SMS_NokiaVTODOLong, 928 SMS_VCARD10Long, 929 SMS_VCARD21Long, 930 SMS_DisableVoice, 931 SMS_DisableFax, 932 SMS_DisableEmail, 933 SMS_EnableVoice, 934 SMS_EnableFax, 935 SMS_EnableEmail, 936 SMS_VoidSMS, 937 /** 938 * IMelody 1.0 939 */ 940 SMS_EMSSound10, 941 /** 942 * IMelody 1.2 943 */ 944 SMS_EMSSound12, 945 /** 946 * IMelody without header - SonyEricsson extension 947 */ 948 SMS_EMSSonyEricssonSound, 949 /** 950 * IMelody 1.0 with UPI. 951 */ 952 SMS_EMSSound10Long, 953 /** 954 * IMelody 1.2 with UPI. 955 */ 956 SMS_EMSSound12Long, 957 /** 958 * IMelody without header with UPI. 959 */ 960 SMS_EMSSonyEricssonSoundLong, 961 SMS_EMSPredefinedSound, 962 SMS_EMSPredefinedAnimation, 963 SMS_EMSAnimation, 964 /** 965 * Fixed bitmap of size 16x16 or 32x32. 966 */ 967 SMS_EMSFixedBitmap, 968 SMS_EMSVariableBitmap, 969 SMS_EMSVariableBitmapLong, 970 /** 971 * MMS message indicator. 972 */ 973 SMS_MMSIndicatorLong, 974 SMS_WAPIndicatorLong, 975 /** 976 * Variable bitmap with black and white colors 977 */ 978 SMS_AlcatelMonoBitmapLong, 979 /** 980 * Variable animation with black and white colors 981 */ 982 SMS_AlcatelMonoAnimationLong, 983 SMS_AlcatelSMSTemplateName, 984 /** 985 * Siemens OTA 986 */ 987 SMS_SiemensFile, 988 SMS_USSD 989 } EncodeMultiPartSMSID; 990 991 /** 992 * Entry of multipart SMS. 993 * 994 * \ingroup SMS 995 */ 996 typedef struct { 997 EncodeMultiPartSMSID ID; 998 999 int Number; 1000 GSM_Ringtone *Ringtone; 1001 GSM_MultiBitmap *Bitmap; 1002 GSM_WAPBookmark *Bookmark; 1003 GSM_WAPSettings *Settings; 1004 GSM_MMSIndicator *MMSIndicator; 1005 GSM_MemoryEntry *Phonebook; 1006 GSM_CalendarEntry *Calendar; 1007 GSM_ToDoEntry *ToDo; 1008 GSM_File *File; 1009 gboolean Protected; 1010 1011 unsigned char *Buffer; 1012 gboolean Left; 1013 gboolean Right; 1014 gboolean Center; 1015 gboolean Large; 1016 gboolean Small; 1017 gboolean Bold; 1018 gboolean Italic; 1019 gboolean Underlined; 1020 gboolean Strikethrough; 1021 1022 /* Return values */ 1023 int RingtoneNotes; 1024 } GSM_MultiPartSMSEntry; 1025 1026 /** 1027 * Multipart SMS information. 1028 * 1029 * \ingroup SMS 1030 */ 1031 typedef struct { 1032 int EntriesNum; 1033 gboolean UnicodeCoding; 1034 int Class; 1035 unsigned char ReplaceMessage; 1036 gboolean Unknown; 1037 GSM_MultiPartSMSEntry Entries[GSM_MAX_MULTI_SMS]; 1038 gboolean Processed; 1039 } GSM_MultiPartSMSInfo; 1040 1041 /** 1042 * Encodes SMS frame according to layout. 1043 * 1044 * \return Error code. 1045 * 1046 * \ingroup SMS 1047 */ 1048 GSM_Error PHONE_EncodeSMSFrame(GSM_StateMachine * s, GSM_SMSMessage * SMS, 1049 unsigned char *buffer, 1050 GSM_SMSMessageLayout Layout, int *length, 1051 gboolean clear); 1052 1053 /** 1054 * Encodes multi part SMS from "readable" format. 1055 * 1056 * \return Error code. 1057 * 1058 * \ingroup SMS 1059 */ 1060 GSM_Error GSM_EncodeMultiPartSMS(GSM_Debug_Info * di, 1061 GSM_MultiPartSMSInfo * Info, 1062 GSM_MultiSMSMessage * SMS); 1063 1064 /** 1065 * Decodes multi part SMS to "readable" format. 1066 * 1067 * \ingroup SMS 1068 */ 1069 gboolean GSM_DecodeMultiPartSMS(GSM_Debug_Info * di, 1070 GSM_MultiPartSMSInfo * Info, 1071 GSM_MultiSMSMessage * SMS, gboolean ems); 1072 1073 /** 1074 * Clears @ref GSM_MultiPartSMSInfo to default values. 1075 * 1076 * \ingroup SMS 1077 */ 1078 void GSM_ClearMultiPartSMSInfo(GSM_MultiPartSMSInfo * Info); 1079 1080 /** 1081 * Frees any allocated structures inside @ref GSM_MultiPartSMSInfo. 1082 * 1083 * \ingroup SMS 1084 */ 1085 void GSM_FreeMultiPartSMSInfo(GSM_MultiPartSMSInfo * Info); 1086 1087 /** 1088 * Links SMS messages according to IDs. 1089 * 1090 * \return Error code. 1091 * 1092 * \ingroup SMS 1093 */ 1094 GSM_Error GSM_LinkSMS(GSM_Debug_Info * di, 1095 GSM_MultiSMSMessage ** INPUT, 1096 GSM_MultiSMSMessage ** OUTPUT, gboolean ems); 1097 1098 /** 1099 * MMS address type. 1100 * 1101 * \ingroup MMS 1102 */ 1103 typedef enum { 1104 MMSADDRESS_PHONE, 1105 MMSADDRESS_UNKNOWN 1106 } MMSAddressType; 1107 1108 /** 1109 * MMS entry. 1110 * 1111 * \ingroup MMS 1112 */ 1113 typedef struct { 1114 GSM_File File; 1115 /** 1116 * CT in Unicode 1117 */ 1118 unsigned char ContentType[400]; 1119 /** 1120 * Smil ID in Unicode 1121 */ 1122 unsigned char SMIL[400]; 1123 } GSM_EncodedMultiPartMMSEntry; 1124 1125 /** 1126 * MMS part. 1127 * 1128 * \ingroup MMS 1129 */ 1130 typedef struct { 1131 int EntriesNum; 1132 1133 /** 1134 * in Unicode 1135 */ 1136 unsigned char Source[200]; 1137 MMSAddressType SourceType; 1138 /** 1139 * in Unicode 1140 */ 1141 unsigned char Destination[200]; 1142 MMSAddressType DestinationType; 1143 /** 1144 * in Unicode 1145 */ 1146 unsigned char CC[200]; 1147 MMSAddressType CCType; 1148 1149 /** 1150 * in Unicode 1151 */ 1152 unsigned char Subject[200]; 1153 /** 1154 * CT in Unicode 1155 */ 1156 unsigned char ContentType[400]; 1157 /** 1158 * no Unicode 1159 */ 1160 unsigned char MSGType[50]; 1161 1162 gboolean DateTimeAvailable; 1163 GSM_DateTime DateTime; 1164 1165 gboolean MMSReportAvailable; 1166 gboolean MMSReport; 1167 /** 1168 * Subparts. 1169 */ 1170 GSM_EncodedMultiPartMMSEntry Entries[GSM_MAX_MULTI_MMS]; 1171 } GSM_EncodedMultiPartMMSInfo; 1172 1173 /** 1174 * Decodes MMS data. 1175 * 1176 * \ingroup MMS 1177 */ 1178 GSM_Error GSM_DecodeMMSFileToMultiPart(GSM_Debug_Info * di, GSM_File * file, 1179 GSM_EncodedMultiPartMMSInfo * info); 1180 1181 /** 1182 * Clears MMS data, used to initialize structure. 1183 * 1184 * \ingroup MMS 1185 */ 1186 GSM_Error GSM_ClearMMSMultiPart(GSM_EncodedMultiPartMMSInfo * info); 1187 1188 /** 1189 * Gets SMS Service Center number and SMS settings. 1190 * 1191 * \param s State machine pointer. 1192 * \param[in,out] smsc SMSC structure, should contain location. 1193 * 1194 * \return Error code. 1195 * 1196 * \ingroup SMS 1197 */ 1198 GSM_Error GSM_GetSMSC(GSM_StateMachine * s, GSM_SMSC * smsc); 1199 1200 /** 1201 * Sets SMS Service Center number and SMS settings. 1202 * 1203 * \param s State machine pointer. 1204 * \param[in] smsc SMSC structure. 1205 * 1206 * \return Error code. 1207 * 1208 * \ingroup SMS 1209 */ 1210 GSM_Error GSM_SetSMSC(GSM_StateMachine * s, GSM_SMSC * smsc); 1211 1212 /** 1213 * Gets information about SMS memory (read/unread/size of memory for 1214 * both SIM and phone). 1215 * 1216 * \param s State machine pointer. 1217 * \param[out] status Pointer to SMS status structure. 1218 * 1219 * \return Error code. 1220 * 1221 * \ingroup SMS 1222 */ 1223 GSM_Error GSM_GetSMSStatus(GSM_StateMachine * s, GSM_SMSMemoryStatus * status); 1224 1225 /** 1226 * Reads SMS message. 1227 * 1228 * \param s State machine pointer. 1229 * \param[in,out] sms SMS message data read from phone, location and 1230 * folder should be set. 1231 * 1232 * \return Error code. 1233 * 1234 * \ingroup SMS 1235 */ 1236 GSM_Error GSM_GetSMS(GSM_StateMachine * s, GSM_MultiSMSMessage * sms); 1237 1238 /** 1239 * Reads next (or first if start set) SMS message. This might be 1240 * faster for some phones than using \ref GSM_GetSMS for each message. 1241 * 1242 * Please note that this commend does not have to mark message as read 1243 * in phone. To do so, you have to call \ref GSM_GetSMS. 1244 * 1245 * \param s State machine pointer. 1246 * \param[in,out] sms SMS message data read from phone, for subsequent 1247 * reads, location and folder might be used by phone driver to determine 1248 * reading state. 1249 * \param[in] start Whether we start reading from beginning. 1250 * 1251 * \return Error code. 1252 * 1253 * \ingroup SMS 1254 */ 1255 GSM_Error GSM_GetNextSMS(GSM_StateMachine * s, GSM_MultiSMSMessage * sms, 1256 gboolean start); 1257 /** 1258 * Sets SMS. 1259 * 1260 * \param s State machine pointer. 1261 * \param[in] sms SMS message data. 1262 * 1263 * \return Error code. 1264 * 1265 * \ingroup SMS 1266 */ 1267 GSM_Error GSM_SetSMS(GSM_StateMachine * s, GSM_SMSMessage * sms); 1268 1269 /** 1270 * Adds SMS to specified folder. 1271 * 1272 * \param s State machine pointer. 1273 * \param[in,out] sms SMS message data, location will be updated. 1274 * 1275 * \return Error code. 1276 * 1277 * \ingroup SMS 1278 */ 1279 GSM_Error GSM_AddSMS(GSM_StateMachine * s, GSM_SMSMessage * sms); 1280 1281 /** 1282 * Deletes SMS. 1283 * 1284 * \param s State machine pointer. 1285 * \param[in] sms SMS structure with SMS location and folder. 1286 * 1287 * \return Error code. 1288 * 1289 * \ingroup SMS 1290 */ 1291 GSM_Error GSM_DeleteSMS(GSM_StateMachine * s, GSM_SMSMessage * sms); 1292 1293 /** 1294 * Sends SMS. 1295 * 1296 * \param s State machine pointer. 1297 * \param[in] sms SMS structure with SMS data to send. 1298 * 1299 * \return Error code. 1300 * 1301 * \ingroup SMS 1302 */ 1303 GSM_Error GSM_SendSMS(GSM_StateMachine * s, GSM_SMSMessage * sms); 1304 1305 /** 1306 * Sends SMS already saved in phone. 1307 * 1308 * \param s State machine pointer. 1309 * \param[in] Folder Folder, where message is stored. 1310 * \param[in] Location Location, where message is stored. 1311 * 1312 * \return Error code. 1313 * 1314 * \ingroup SMS 1315 */ 1316 GSM_Error GSM_SendSavedSMS(GSM_StateMachine * s, int Folder, int Location); 1317 1318 /** 1319 * Configures fast SMS sending. 1320 * 1321 * \param s State machine pointer. 1322 * \param[in] enable Whether to enable notifications. 1323 * 1324 * \return Error code. 1325 * 1326 * \ingroup SMS 1327 */ 1328 GSM_Error GSM_SetFastSMSSending(GSM_StateMachine * s, gboolean enable); 1329 1330 /** 1331 * Enable/disable notification on incoming SMS. 1332 * 1333 * \param s State machine pointer. 1334 * \param[in] enable Whether to enable notifications. 1335 * 1336 * \return Error code. 1337 * 1338 * \ingroup SMS 1339 */ 1340 GSM_Error GSM_SetIncomingSMS(GSM_StateMachine * s, gboolean enable); 1341 1342 /** 1343 * Gets network information from phone. 1344 * 1345 * \param s State machine pointer. 1346 * \param[in] enable Whether to enable notifications. 1347 * 1348 * \return Error code. 1349 * 1350 * \ingroup CB 1351 */ 1352 GSM_Error GSM_SetIncomingCB(GSM_StateMachine * s, gboolean enable); 1353 1354 /** 1355 * Returns SMS folders information. 1356 * 1357 * \param s State machine pointer. 1358 * \param[out] folders folders Pointer to folders structure, which will be 1359 * filled in. 1360 * 1361 * \return Error code. 1362 * 1363 * \ingroup SMS 1364 */ 1365 GSM_Error GSM_GetSMSFolders(GSM_StateMachine * s, GSM_SMSFolders * folders); 1366 1367 /** 1368 * Creates SMS folder. 1369 * 1370 * \param s State machine pointer. 1371 * \param[in] name Name of SMS folder which should be created. 1372 * 1373 * \return Error code. 1374 * 1375 * \ingroup SMS 1376 */ 1377 GSM_Error GSM_AddSMSFolder(GSM_StateMachine * s, unsigned char *name); 1378 1379 /** 1380 * Deletes SMS folder. 1381 * 1382 * \param s State machine pointer. 1383 * \param[in] ID ID of SMS folder to delete. 1384 * 1385 * \return Error code. 1386 * 1387 * \ingroup SMS 1388 */ 1389 GSM_Error GSM_DeleteSMSFolder(GSM_StateMachine * s, int ID); 1390 1391 /** 1392 * Lists MMS folders. 1393 * 1394 * \param s State machine pointer. 1395 * \param folders Pointer to structure, whehe folder information will be 1396 * stored. 1397 * 1398 * \return Error code. 1399 * 1400 * \ingroup MMS 1401 */ 1402 GSM_Error GSM_GetMMSFolders(GSM_StateMachine * s, GSM_MMSFolders * folders); 1403 1404 /** 1405 * Retrieves next part of MMS file information. 1406 * 1407 * \param s State machine pointer. 1408 * \param[in,out] FileID File ID will be stored here, might be 1409 * used for consequent reads. 1410 * \param[in,out] MMSFolder MMS folder ID will be stored here, might be 1411 * used for consequent reads. 1412 * \param[in] start Whether to start reading. 1413 * 1414 * \return Error code. 1415 * 1416 * \ingroup MMS 1417 */ 1418 GSM_Error GSM_GetNextMMSFileInfo(GSM_StateMachine * s, unsigned char *FileID, 1419 int *MMSFolder, gboolean start); 1420 /** 1421 * Activates/deactivates noticing about incoming USSDs (UnStructured Supplementary Services). 1422 * 1423 * \param s State machine pointer. 1424 * \param[in] enable Whether to enable notifications. 1425 * 1426 * \return Error code. 1427 * 1428 * \ingroup USSD 1429 */ 1430 GSM_Error GSM_SetIncomingUSSD(GSM_StateMachine * s, gboolean enable); 1431 1432 /** 1433 * Calculates number of messages and free chars needed for text. 1434 * 1435 * \param di Debug settings. 1436 * \param[in] MessageBuffer Actual message text in unicode. 1437 * \param[in] UDHType UDH type. 1438 * \param[in] Coding GSM Encoding type. 1439 * \param[out] SMSNum Number of messages needed to store the text. 1440 * \param[out] CharsLeft Number of free chars in the message. 1441 * 1442 * \ingroup SMS 1443 */ 1444 void GSM_SMSCounter(GSM_Debug_Info *di, unsigned char *MessageBuffer, 1445 GSM_UDH UDHType, GSM_Coding_Type Coding, int *SMSNum, size_t *CharsLeft); 1446 1447 #ifdef __cplusplus 1448 } 1449 #endif 1450 #endif 1451 1452 /* Editor configuration 1453 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: 1454 */ 1455