This file is indexed.

/usr/include/gammu/gammu-message.h is in libgammu-dev 1.33.0-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
/**
 * \file gammu-message.h
 * \author Michal Čihař
 *
 * Message data and functions.
 */
#ifndef __gammu_message_h
#define __gammu_message_h

#include <gammu-limits.h>
#include <gammu-memory.h>
#include <gammu-datetime.h>
#include <gammu-ringtone.h>
#include <gammu-bitmap.h>
#include <gammu-wap.h>
#include <gammu-calendar.h>
#include <gammu-file.h>
#include <gammu-debug.h>

/**
 * \defgroup Message Messages
 * Messages manipulations.
 */

/**
 * \defgroup USSD USSD messages
 * USSD messages manipulations.
 * \ingroup Message
 */

/**
 * \defgroup CB CB messages
 * Cell broadcast messages manipulations.
 * \ingroup Message
 */

/**
 * \defgroup SMS SMS messages
 * SMS messages manipulations.
 * \ingroup Message
 */

/**
 * \defgroup MMS MMS messages
 * MMS messages manipulations.
 * \ingroup Message
 */

/**
 * MMS message class.
 */
typedef enum {
	/**
	 * None class specified.
	 */
	GSM_MMS_None = 0,
	/**
	 * Personal message.
	 */
	GSM_MMS_Personal = 1,
	/**
	 * Advertisement message.
	 */
	GSM_MMS_Advertisement,
	/**
	 * Informational message.
	 */
	GSM_MMS_Info,
	/**
	 * Automatic message class.
	 */
	GSM_MMS_Auto,
} GSM_MMS_Class;

/**
 * MMS indicator data.
 *
 * \ingroup MMS
 */
typedef struct {
	/**
	 * Message address (URL for download).
	 */
	char Address[500];
	/**
	 * Message title (subject).
	 */
	char Title[200];
	/**
	 * Message sender.
	 */
	char Sender[200];
	/**
	 * Message size, if 0 it won't be decoded or was not decoded.
	 */
	size_t MessageSize;
	/**
	 * Class of a message.
	 */
	GSM_MMS_Class Class;
} GSM_MMSIndicator;

/**
 * Structure for Cell Broadcast messages.
 *
 * \ingroup CB
 */
typedef struct {
	/**
	 * Channel number.
	 */
	int Channel;
	/**
	 * Message text.
	 */
	char Text[300];
} GSM_CBMessage;

/**
 * Status of USSD message.
 *
 * \ingroup USSD
 */
typedef enum {
	/**
	 * Unknown status
	 */
	USSD_Unknown = 1,
	/**
	 * No action is needed, maybe network initiated USSD
	 */
	USSD_NoActionNeeded,
	/**
	 * Reply is expected
	 */
	USSD_ActionNeeded,
	/**
	 * USSD dialog terminated
	 */
	USSD_Terminated,
	/**
	 * Another client replied
	 */
	USSD_AnotherClient,
	/**
	 * Operation not supported
	 */
	USSD_NotSupported,
	/**
	 * Network timeout
	 */
	USSD_Timeout,
} GSM_USSDStatus;

/**
 * Structure for USSD messages.
 *
 * \ingroup USSD
 */
typedef struct {
	/**
	 * Message text.
	 */
	unsigned char Text[2 * (GSM_MAX_USSD_LENGTH + 1)];
	/**
	 * Message status.
	 */
	GSM_USSDStatus Status;
} GSM_USSDMessage;

/**
 * Status of SMS memory.
 *
 * \ingroup SMS
 */
typedef struct {
	/**
	 * Number of unread messages on SIM.
	 */
	int SIMUnRead;
	/**
	 * Number of all saved messages (including unread) on SIM.
	 */
	int SIMUsed;
	/**
	 * Number of all possible messages on SIM.
	 */
	int SIMSize;
	/**
	 * Number of used templates (62xx/63xx/7110/etc.).
	 */
	int TemplatesUsed;
	/**
	 * Number of unread messages in phone.
	 */
	int PhoneUnRead;
	/**
	 * Number of all saved messages in phone.
	 */
	int PhoneUsed;
	/**
	 * Number of all possible messages on phone.
	 */
	int PhoneSize;
} GSM_SMSMemoryStatus;

/**
 * Enum defines format of SMS messages. See GSM 03.40 section 9.2.3.9
 *
 * \ingroup SMS
 */
typedef enum {
	SMS_FORMAT_Pager = 1,
	SMS_FORMAT_Fax,
	SMS_FORMAT_Email,
	SMS_FORMAT_Text
	    /* Some values not handled here */
} GSM_SMSFormat;

/**
 * Enum defines some the most often used validity lengths for SMS messages
 * for relative validity format. See GSM 03.40 section 9.2.3.12.1 - it gives
 * more values.
 *
 * \ingroup SMS
 */
typedef enum {
	SMS_VALID_1_Hour = 0x0b,
	SMS_VALID_6_Hours = 0x47,
	SMS_VALID_1_Day = 0xa7,
	SMS_VALID_3_Days = 0xa9,
	SMS_VALID_1_Week = 0xad,
	SMS_VALID_Max_Time = 0xff
} GSM_ValidityPeriod;

/**
 * Enum defines format of validity period for SMS messages.
 * See GSM 03.40 section 9.2.3.12
 *
 * \ingroup SMS
 */
typedef enum {
	SMS_Validity_NotAvailable = 1,
	SMS_Validity_RelativeFormat
	    /* Specification gives also other possibilities */
} GSM_ValidityPeriodFormat;

/**
 * Structure for validity of SMS messages
 *
 * \ingroup SMS
 */
typedef struct {
	GSM_ValidityPeriodFormat Format;
	/**
	 * Value defines period for relative format
	 */
	GSM_ValidityPeriod Relative;
} GSM_SMSValidity;

/**
 * Structure for SMSC (SMS Center) information.
 *
 * \ingroup SMS
 */
typedef struct {
	/**
	 * Number of the SMSC on SIM
	 */
	int Location;
	/**
	 * Name of the SMSC
	 */
	unsigned char Name[(GSM_MAX_SMSC_NAME_LENGTH + 1) * 2];
	/**
	 * SMSC phone number.
	 */
	unsigned char Number[(GSM_MAX_NUMBER_LENGTH + 1) * 2];
	/**
	 * Validity of SMS messages.
	 */
	GSM_SMSValidity Validity;
	/**
	 * Format of sent SMS messages.
	 */
	GSM_SMSFormat Format;
	/**
	 * Default recipient number. In old DCT3 ignored
	 */
	unsigned char DefaultNumber[(GSM_MAX_NUMBER_LENGTH + 1) * 2];
} GSM_SMSC;

/**
 * Status of SMS message.
 *
 * \ingroup SMS
 */
typedef enum {
	SMS_Sent = 1,
	SMS_UnSent,
	SMS_Read,
	SMS_UnRead
} GSM_SMS_State;

/**
 * Coding type of SMS.
 *
 * \ingroup SMS
 */
typedef enum {
	/**
	 * Unicode
	 */
	SMS_Coding_Unicode_No_Compression = 1,
	SMS_Coding_Unicode_Compression,
	/**
	 * Default GSM alphabet.
	 */
	SMS_Coding_Default_No_Compression,
	SMS_Coding_Default_Compression,
	/**
	 * 8-bit.
	 */
	SMS_Coding_8bit
} GSM_Coding_Type;

/**
 * Converts SMS coding to string.
 *
 * \return Pointer to static string, NULL on failure.
 */
const char *GSM_SMSCodingToString(GSM_Coding_Type type);

/**
 * Converts SMS coding to type.
 */
GSM_Coding_Type GSM_StringToSMSCoding(const char *s);

/**
 * Types of UDH (User Data Header).
 *
 * \ingroup SMS
 */
typedef enum {
	UDH_NoUDH = 1,
	/**
	 * Linked SMS.
	 */
	UDH_ConcatenatedMessages,
	/**
	 * Linked SMS with 16 bit reference.
	 */
	UDH_ConcatenatedMessages16bit,
	UDH_DisableVoice,
	UDH_DisableFax,
	UDH_DisableEmail,
	UDH_EnableVoice,
	UDH_EnableFax,
	UDH_EnableEmail,
	UDH_VoidSMS,
	UDH_NokiaRingtone,
	UDH_NokiaRingtoneLong,
	UDH_NokiaOperatorLogo,
	UDH_NokiaOperatorLogoLong,
	UDH_NokiaCallerLogo,
	UDH_NokiaWAP,
	UDH_NokiaWAPLong,
	UDH_NokiaCalendarLong,
	UDH_NokiaProfileLong,
	UDH_NokiaPhonebookLong,
	UDH_UserUDH,
	UDH_MMSIndicatorLong
} GSM_UDH;

/**
 * Structure for User Data Header.
 *
 * \ingroup SMS
 */
typedef struct {
	/**
	 * UDH type.
	 */
	GSM_UDH Type;
	/**
	 * UDH length.
	 */
	int Length;
	/**
	 * UDH text.
	 */
	unsigned char Text[GSM_MAX_UDH_LENGTH];
	/**
	 * 8-bit ID, when required (-1 otherwise).
	 */
	int ID8bit;
	/**
	 * 16-bit ID, when required (-1 otherwise).
	 */
	int ID16bit;
	/**
	 * Number of current part.
	 */
	int PartNumber;
	/**
	 * Total number of parts.
	 */
	int AllParts;
} GSM_UDHHeader;

/**
 * TP-Message-Type-Indicator. See GSM 03.40 section 9.2.3.1.
 *
 * \ingroup SMS
 */
typedef enum {
	/**
	 * SMS in Inbox.
	 */
	SMS_Deliver = 1,
	/**
	 * Delivery Report
	 */
	SMS_Status_Report,
	/**
	 * SMS for sending or in Outbox
	 */
	SMS_Submit
	    /* specification gives more */
} GSM_SMSMessageType;

/**
 * SMS message data.
 *
 * \ingroup SMS
 */
typedef struct {
	/**
	 * Message to be replaced.
	 */
	unsigned char ReplaceMessage;
	/**
	 * Whether to reject duplicates.
	 */
	gboolean RejectDuplicates;
	/**
	 * UDH (User Data Header)
	 */
	GSM_UDHHeader UDH;
	/**
	 * Sender or recipient number.
	 */
	unsigned char Number[(GSM_MAX_NUMBER_LENGTH + 1) * 2];

	unsigned char
	 OtherNumbers[GSM_SMS_OTHER_NUMBERS][(GSM_MAX_NUMBER_LENGTH + 1) * 2];
	int OtherNumbersNum;

	/**
	 * SMSC (SMS Center)
	 */
	GSM_SMSC SMSC;
	/**
	 * For saved SMS: where exactly it's saved (SIM/phone)
	 */
	GSM_MemoryType Memory;
	/**
	 * For saved SMS: location of SMS in memory.
	 */
	int Location;
	/**
	 * For saved SMS: number of folder, where SMS is saved
	 */
	int Folder;
	/**
	 * For saved SMS: whether SMS is really in Inbox.
	 */
	gboolean InboxFolder;
	/**
	 * Length of the SMS message.
	 */
	int Length;
	/**
	 * Status (read/unread/...) of SMS message.
	 */
	GSM_SMS_State State;
	/**
	 * Name in Nokia with SMS memory (6210/7110, etc.) Ignored in other.
	 */
	unsigned char Name[(GSM_MAX_SMS_NAME_LENGTH + 1) * 2];
	/**
	 * Text for SMS.
	 */
	unsigned char Text[(GSM_MAX_SMS_LENGTH + 1) * 2];
	/**
	 * Type of message.
	 */
	GSM_SMSMessageType PDU;
	/**
	 * Type of coding.
	 */
	GSM_Coding_Type Coding;
	/**
	 * Date and time, when SMS was saved or sent
	 */
	GSM_DateTime DateTime;
	/**
	 * Date of SMSC response in DeliveryReport messages.
	 */
	GSM_DateTime SMSCTime;
	/**
	 * In delivery reports: status.
	 */
	unsigned char DeliveryStatus;
	/**
	 * Indicates whether "Reply via same center" is set.
	 */
	gboolean ReplyViaSameSMSC;
	/**
	 * SMS class (0 is flash SMS, 1 is normal one).
	 */
	signed char Class;
	/**
	 * Message reference.
	 */
	unsigned char MessageReference;
} GSM_SMSMessage;

/* In layouts are saved locations for some SMS part. Below are listed
 * specs, which describe them
 *
 * \ingroup SMS
 */
typedef struct {
	/**
	 * TP-User-Data. GSM 03.40 section 9.2.3.24.
	 */
	unsigned char Text;
	/**
	 * - In SMS-Deliver:       TP-Originating-Address. GSM 03.40 section 9.2.3.7.
	 * - In SMS-Submit:        TP-Destination-Address. GSM 03.40 section 9.2.3.8.
	 * - In SMS-Status-Report: TP-Recipient-Address.   GSM 03.40 section 9.2.3.14.
	 */
	unsigned char Number;
	/**
	 * SMSC number
	 */
	unsigned char SMSCNumber;
	/**
	 * TP-Data-Coding-Scheme. GSM 03.40 section 9.2.3.10.
	 * Contains alphabet type, SMS class (and some others)
	 */
	unsigned char TPDCS;
	/**
	 * - For SMS-Submit:        TP-Validity-Period. GSM 03.40 section 9.2.3.12.
	 * - For SMS-Status-Report: TP-Discharge Time.  GSM 03.40 section 9.2.3.13.
	 */
	unsigned char DateTime;
	/**
	 * TP-Service-Centre-Time-Stamp in SMS-Status-Report. GSM 03.40 section 9.2.3.11.
	 */
	unsigned char SMSCTime;
	/**
	 * TP-Status in SMS-Status-Report. GSM 03.40 section 9.2.3.15.
	 */
	unsigned char TPStatus;
	/**
	 * TP-User-Data-Length. GSM 03.40 section 9.2.3.16.
	 */
	unsigned char TPUDL;
	/**
	 * TP-Validity Period in SMS-Submit. GSM 03.40 section 9.2.3.12.
	 */
	unsigned char TPVP;
	/**
	 * Byte contains in SMS-Deliver:
	 * - TP-Message-Type-Indicator     (2 bits) GSM 03.40 section 9.2.3.1
	 * - TP-More-Messages-To-Send      (1 bit). GSM 03.40 section 9.2.3.2
	 * - TP-Reply-Path                 (1 bit). GSM 03.40 section 9.2.3.17
	 * - TP-User-Data-Header-Indicator (1 bit). GSM 03.40 section 9.2.3.23
	 * - TP-Status-Report-Indicator    (1 bit). GSM 03.40 section 9.2.3.4
	 *
	 * Byte contains in SMS-Submit:
	 * - TP-Message-Type-Indicator     (2 bits) GSM 03.40 section 9.2.3.1
	 * - TP-Reject-Duplicates          (1 bit). GSM 03.40 section
	 * - TP-Validity-Period-Format     (2 bits).GSM 03.40 section 9.2.3.3
	 * - TP-Reply-Path                 (1 bit). GSM 03.40 section 9.2.3.17
	 * - TP-User-Data-Header-Indicator (1 bit). GSM 03.40 section 9.2.3.23
	 * - TP-Status-Report-Request      (1 bit). GSM 03.40 section 9.2.3.5
	 */
	unsigned char firstbyte;
	/**
	 * TP-Message Reference in SMS-Submit. GSM 03.40 section 9.2.3.6
	 */
	unsigned char TPMR;
	/**
	 * TP-Protocol-Identifier. GSM 03.40 section 9.2.3.9
	 */
	unsigned char TPPID;
} GSM_SMSMessageLayout;

/**
 * Decodes PDU data.
 *
 * \param di Debug information structure.
 * \param SMS Pointer where to store parsed message.
 * \param buffer PDU data.
 * \param length Length of PDU data.
 * \param final_pos Optional pointer where end position will be stored.
 * \param SMSC Whether PDU includes SMSC data.
 *
 * \ingroup SMS
 */
GSM_Error GSM_DecodePDUFrame(GSM_Debug_Info *di, GSM_SMSMessage *SMS,
			const unsigned char *buffer, size_t length,
			size_t *final_pos, gboolean SMSC);

/**
 * Decodes SMS frame.
 *
 * \ingroup SMS
 */
GSM_Error GSM_DecodeSMSFrame(GSM_Debug_Info * di, GSM_SMSMessage * SMS,
			     unsigned char *buffer,
			     GSM_SMSMessageLayout Layout);

/**
 * Finds out coding type based on TPDCS header byte as defined by GSM
 * 03.38.
 */
GSM_Coding_Type GSM_GetMessageCoding(GSM_Debug_Info * di, const char TPDCS);

/**
 * Encodes SMS frame.
 *
 * \ingroup SMS
 */
GSM_Error GSM_EncodeSMSFrame(GSM_Debug_Info * di, GSM_SMSMessage * SMS,
			     unsigned char *buffer, GSM_SMSMessageLayout Layout,
			     int *length, gboolean clear);

/**
 * Decodes SMS frame for status report.
 *
 * \ingroup SMS
 */
GSM_Error GSM_DecodeSMSFrameStatusReportData(GSM_Debug_Info * di,
					     GSM_SMSMessage * SMS,
					     unsigned char *buffer,
					     GSM_SMSMessageLayout Layout);

/**
 * Decodes SMS frame in textual representation.
 *
 * \ingroup SMS
 */
GSM_Error GSM_DecodeSMSFrameText(GSM_Debug_Info * di, GSM_SMSMessage * SMS,
				 unsigned char *buffer,
				 GSM_SMSMessageLayout Layout);

/**
 * Decodes UDH header.
 *
 * \ingroup SMS
 */
void GSM_DecodeUDHHeader(GSM_Debug_Info * di, GSM_UDHHeader * UDH);

/**
 * Encodes UDH header.
 *
 * \ingroup SMS
 */
void GSM_EncodeUDHHeader(GSM_Debug_Info * di, GSM_UDHHeader * UDH);

/**
 * Sets default content for SMS except for changing locations.
 * Use this for clearing structure while keeping location of message.
 *
 * \param SMS Pointer to structure which should be cleaned up.
 *
 * \ingroup SMS
 */
void GSM_SetDefaultReceivedSMSData(GSM_SMSMessage * SMS);

/**
 * Sets default content for SMS. Use this for clearing structure.
 *
 * \param SMS Pointer to structure which should be cleaned up.
 *
 * \ingroup SMS
 */
void GSM_SetDefaultSMSData(GSM_SMSMessage * SMS);

/**
 * Information about SMS folder.
 *
 * \ingroup SMS
 */
typedef struct {
	/**
	 * Whether it is inbox.
	 */
	gboolean InboxFolder;
	/**
	 * Whether it is outbox.
	 */
	gboolean OutboxFolder;
	/**
	 * Where exactly it's saved.
	 */
	GSM_MemoryType Memory;
	/**
	 * Name of the folder
	 */
	unsigned char Name[(GSM_MAX_SMS_FOLDER_NAME_LEN + 1) * 2];
} GSM_OneSMSFolder;

/**
 * List of SMS folders.
 *
 * \ingroup SMS
 */
typedef struct {
	/**
	 * Array of structures holding information about each folder.
	 */
	GSM_OneSMSFolder Folder[GSM_MAX_SMS_FOLDERS];
	/**
 	 * Number of SMS folders.
	 */
	int Number;
} GSM_SMSFolders;

/**
 * Siemens OTA data.
 *
 * \ingroup SMS
 */
typedef struct {
	unsigned long SequenceID;
	unsigned int PacketsNum;
	unsigned int PacketNum;
	unsigned long AllDataLen;

	unsigned char DataType[10];
	unsigned char DataName[40];
	unsigned int DataLen;
	unsigned char Data[140];
} GSM_SiemensOTASMSInfo;

/**
 * Decodes Siemens OTA data.
 *
 * \ingroup SMS
 */
gboolean GSM_DecodeSiemensOTASMS(GSM_Debug_Info * di,
			     GSM_SiemensOTASMSInfo * Info,
			     GSM_SMSMessage * SMS);

/**
 * Multiple SMS messages, used for Smart Messaging 3.0/EMS.
 *
 * \ingroup SMS
 */
typedef struct {
	/**
	 * Number of messages.
	 */
	int Number;
	/**
	 * Array of SMSes.
	 */
	GSM_SMSMessage SMS[GSM_MAX_MULTI_SMS];
} GSM_MultiSMSMessage;

/**
 * Information about MMS folder.
 *
 * \ingroup MMS
 */
typedef struct {
	/**
	 * Whether it is really inbox.
	 */
	gboolean InboxFolder;
	/**
  	 * Name for MMS folder.
	 */
	char Name[(GSM_MAX_MMS_FOLDER_NAME_LEN + 1) * 2];
} GSM_OneMMSFolder;

/**
 * List of MMS folders.
 *
 * \ingroup MMS
 */
typedef struct {
	/**
 	 * Number of MMS folders.
	 */
	unsigned char Number;
	/**
	 * Array of structures holding information about each folder.
	 */
	GSM_OneMMSFolder Folder[GSM_MAX_MMS_FOLDERS];
} GSM_MMSFolders;

/**
 * Layout for submit message.
 *
 * \ingroup SMS
 */
extern GSM_SMSMessageLayout PHONE_SMSSubmit;

/**
 * Layout for deliver message.
 *
 * \ingroup SMS
 */
extern GSM_SMSMessageLayout PHONE_SMSDeliver;

/**
 * Layout for status report message.
 *
 * \ingroup SMS
 */
extern GSM_SMSMessageLayout PHONE_SMSStatusReport;

/**
 * ID during packing SMS for Smart Messaging 3.0, EMS and other
 *
 * \ingroup SMS
 */
typedef enum {
	/**
	 * 1 text SMS.
	 */
	SMS_Text = 1,
	/**
	 * Contacenated SMS, when longer than 1 SMS.
	 */
	SMS_ConcatenatedTextLong,
	/**
	 * Contacenated SMS, auto Default/Unicode coding.
	 */
	SMS_ConcatenatedAutoTextLong,
	SMS_ConcatenatedTextLong16bit,
	SMS_ConcatenatedAutoTextLong16bit,
	/**
	 * Nokia profile = Name, Ringtone, ScreenSaver
	 */
	SMS_NokiaProfileLong,
	/**
	 * Nokia Picture Image + (text)
	 */
	SMS_NokiaPictureImageLong,
	/**
	 * Nokia screen saver + (text)
	 */
	SMS_NokiaScreenSaverLong,
	/**
	 * Nokia ringtone - old SM2.0 format, 1 SMS
	 */
	SMS_NokiaRingtone,
	/**
	 * Nokia ringtone contacenated, when very long
	 */
	SMS_NokiaRingtoneLong,
	/**
	 * Nokia 72x14 operator logo, 1 SMS
	 */
	SMS_NokiaOperatorLogo,
	/**
	 * Nokia 72x14 op logo or 78x21 in 2 SMS
	 */
	SMS_NokiaOperatorLogoLong,
	/**
	 * Nokia 72x14 caller logo, 1 SMS
	 */
	SMS_NokiaCallerLogo,
	/**
	 * Nokia WAP bookmark in 1 or 2 SMS
	 */
	SMS_NokiaWAPBookmarkLong,
	/**
	 * Nokia WAP settings in 2 SMS
	 */
	SMS_NokiaWAPSettingsLong,
	/**
	 * Nokia MMS settings in 2 SMS
	 */
	SMS_NokiaMMSSettingsLong,
	/**
	 * Nokia VCARD 1.0 - only name and default number
	 */
	SMS_NokiaVCARD10Long,
	/**
	 * Nokia VCARD 2.1 - all numbers + text
	 */
	SMS_NokiaVCARD21Long,
	/**
	 * Nokia VCALENDAR 1.0 - can be in few sms
	 */
	SMS_NokiaVCALENDAR10Long,
	SMS_NokiaVTODOLong,
	SMS_VCARD10Long,
	SMS_VCARD21Long,
	SMS_DisableVoice,
	SMS_DisableFax,
	SMS_DisableEmail,
	SMS_EnableVoice,
	SMS_EnableFax,
	SMS_EnableEmail,
	SMS_VoidSMS,
	/**
	 * IMelody 1.0
	 */
	SMS_EMSSound10,
	/**
	 * IMelody 1.2
	 */
	SMS_EMSSound12,
	/**
	 * IMelody without header - SonyEricsson extension
	 */
	SMS_EMSSonyEricssonSound,
	/**
	 * IMelody 1.0 with UPI.
	 */
	SMS_EMSSound10Long,
	/**
	 * IMelody 1.2 with UPI.
	 */
	SMS_EMSSound12Long,
	/**
	 * IMelody without header with UPI.
	 */
	SMS_EMSSonyEricssonSoundLong,
	SMS_EMSPredefinedSound,
	SMS_EMSPredefinedAnimation,
	SMS_EMSAnimation,
	/**
	 * Fixed bitmap of size 16x16 or 32x32.
	 */
	SMS_EMSFixedBitmap,
	SMS_EMSVariableBitmap,
	SMS_EMSVariableBitmapLong,
	/**
	 * MMS message indicator.
	 */
	SMS_MMSIndicatorLong,
	SMS_WAPIndicatorLong,
	/**
	 * Variable bitmap with black and white colors
	 */
	SMS_AlcatelMonoBitmapLong,
	/**
	 * Variable animation with black and white colors
	 */
	SMS_AlcatelMonoAnimationLong,
	SMS_AlcatelSMSTemplateName,
	/**
	 * Siemens OTA
	 */
	SMS_SiemensFile
} EncodeMultiPartSMSID;

/**
 * Entry of multipart SMS.
 *
 * \ingroup SMS
 */
typedef struct {
	EncodeMultiPartSMSID ID;

	int Number;
	GSM_Ringtone *Ringtone;
	GSM_MultiBitmap *Bitmap;
	GSM_WAPBookmark *Bookmark;
	GSM_WAPSettings *Settings;
	GSM_MMSIndicator *MMSIndicator;
	GSM_MemoryEntry *Phonebook;
	GSM_CalendarEntry *Calendar;
	GSM_ToDoEntry *ToDo;
	GSM_File *File;
	gboolean Protected;

	unsigned char *Buffer;
	gboolean Left;
	gboolean Right;
	gboolean Center;
	gboolean Large;
	gboolean Small;
	gboolean Bold;
	gboolean Italic;
	gboolean Underlined;
	gboolean Strikethrough;

	/* Return values */
	int RingtoneNotes;
} GSM_MultiPartSMSEntry;

/**
 * Multipart SMS information.
 *
 * \ingroup SMS
 */
typedef struct {
	int EntriesNum;
	gboolean UnicodeCoding;
	int Class;
	unsigned char ReplaceMessage;
	gboolean Unknown;
	GSM_MultiPartSMSEntry Entries[GSM_MAX_MULTI_SMS];
} GSM_MultiPartSMSInfo;

/**
 * Encodes SMS frame according to layout.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error PHONE_EncodeSMSFrame(GSM_StateMachine * s, GSM_SMSMessage * SMS,
			       unsigned char *buffer,
			       GSM_SMSMessageLayout Layout, int *length,
			       gboolean clear);

/**
 * Encodes multi part SMS from "readable" format.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_EncodeMultiPartSMS(GSM_Debug_Info * di,
				 GSM_MultiPartSMSInfo * Info,
				 GSM_MultiSMSMessage * SMS);

/**
 * Decodes multi part SMS to "readable" format.
 *
 * \ingroup SMS
 */
gboolean GSM_DecodeMultiPartSMS(GSM_Debug_Info * di,
			    GSM_MultiPartSMSInfo * Info,
			    GSM_MultiSMSMessage * SMS, gboolean ems);

/**
 * Clears @ref GSM_MultiPartSMSInfo to default values.
 *
 * \ingroup SMS
 */
void GSM_ClearMultiPartSMSInfo(GSM_MultiPartSMSInfo * Info);

/**
 * Frees any allocated structures inside @ref GSM_MultiPartSMSInfo.
 *
 * \ingroup SMS
 */
void GSM_FreeMultiPartSMSInfo(GSM_MultiPartSMSInfo * Info);

/**
 * Links SMS messages according to IDs.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_LinkSMS(GSM_Debug_Info * di,
		      GSM_MultiSMSMessage ** INPUT,
		      GSM_MultiSMSMessage ** OUTPUT, gboolean ems);

/**
 * MMS address type.
 *
 * \ingroup MMS
 */
typedef enum {
	MMSADDRESS_PHONE,
	MMSADDRESS_UNKNOWN
} MMSAddressType;

/**
 * MMS entry.
 *
 * \ingroup MMS
 */
typedef struct {
	GSM_File File;
	/**
	 * CT in Unicode
	 */
	unsigned char ContentType[400];
	/**
	 * Smil ID in Unicode
	 */
	unsigned char SMIL[400];
} GSM_EncodedMultiPartMMSEntry;

/**
 * MMS part.
 *
 * \ingroup MMS
 */
typedef struct {
	int EntriesNum;

	/**
	 * in Unicode
	 */
	unsigned char Source[200];
	MMSAddressType SourceType;
	/**
	 * in Unicode
	 */
	unsigned char Destination[200];
	MMSAddressType DestinationType;
	/**
	 * in Unicode
	 */
	unsigned char CC[200];
	MMSAddressType CCType;

	/**
	 * in Unicode
	 */
	unsigned char Subject[200];
	/**
	 * CT in Unicode
	 */
	unsigned char ContentType[400];
	/**
	 * no Unicode
	 */
	unsigned char MSGType[50];

	gboolean DateTimeAvailable;
	GSM_DateTime DateTime;

	gboolean MMSReportAvailable;
	gboolean MMSReport;
	/**
	 * Subparts.
	 */
	GSM_EncodedMultiPartMMSEntry Entries[GSM_MAX_MULTI_MMS];
} GSM_EncodedMultiPartMMSInfo;

/**
 * Decodes MMS data.
 *
 * \ingroup MMS
 */
GSM_Error GSM_DecodeMMSFileToMultiPart(GSM_Debug_Info * di, GSM_File * file,
				       GSM_EncodedMultiPartMMSInfo * info);

/**
 * Clears MMS data, used to initialize structure.
 *
 * \ingroup MMS
 */
GSM_Error GSM_ClearMMSMultiPart(GSM_EncodedMultiPartMMSInfo * info);

/**
 * Gets SMS Service Center number and SMS settings.
 *
 * \param s State machine pointer.
 * \param[in,out] smsc SMSC structure, should contain location.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_GetSMSC(GSM_StateMachine * s, GSM_SMSC * smsc);

/**
 * Sets SMS Service Center number and SMS settings.
 *
 * \param s State machine pointer.
 * \param[in] smsc SMSC structure.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_SetSMSC(GSM_StateMachine * s, GSM_SMSC * smsc);

/**
 * Gets information about SMS memory (read/unread/size of memory for
 * both SIM and phone).
 *
 * \param s State machine pointer.
 * \param[out] status Pointer to SMS status structure.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_GetSMSStatus(GSM_StateMachine * s, GSM_SMSMemoryStatus * status);

/**
 * Reads SMS message.
 *
 * \param s State machine pointer.
 * \param[in,out] sms SMS message data read from phone, location and
 * folder should be set.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_GetSMS(GSM_StateMachine * s, GSM_MultiSMSMessage * sms);

/**
 * Reads next (or first if start set) SMS message. This might be
 * faster for some phones than using \ref GSM_GetSMS for each message.
 *
 * Please note that this commend does not have to mark message as read
 * in phone. To do so, you have to call \ref GSM_GetSMS.
 *
 * \param s State machine pointer.
 * \param[in,out] sms SMS message data read from phone, for subsequent
 * reads, location and folder might be used by phone driver to determine
 * reading state.
 * \param[in] start Whether we start reading from beginning.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_GetNextSMS(GSM_StateMachine * s, GSM_MultiSMSMessage * sms,
			 gboolean start);
/**
 * Sets SMS.
 *
 * \param s State machine pointer.
 * \param[in] sms SMS message data.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_SetSMS(GSM_StateMachine * s, GSM_SMSMessage * sms);

/**
 * Adds SMS to specified folder.
 *
 * \param s State machine pointer.
 * \param[in,out] sms SMS message data, location will be updated.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_AddSMS(GSM_StateMachine * s, GSM_SMSMessage * sms);

/**
 * Deletes SMS.
 *
 * \param s State machine pointer.
 * \param[in] sms SMS structure with SMS location and folder.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_DeleteSMS(GSM_StateMachine * s, GSM_SMSMessage * sms);

/**
 * Sends SMS.
 *
 * \param s State machine pointer.
 * \param[in] sms SMS structure with SMS data to send.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_SendSMS(GSM_StateMachine * s, GSM_SMSMessage * sms);

/**
 * Sends SMS already saved in phone.
 *
 * \param s State machine pointer.
 * \param[in] Folder Folder, where message is stored.
 * \param[in] Location Location, where message is stored.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_SendSavedSMS(GSM_StateMachine * s, int Folder, int Location);

/**
 * Configures fast SMS sending.
 *
 * \param s State machine pointer.
 * \param[in] enable Whether to enable notifications.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_SetFastSMSSending(GSM_StateMachine * s, gboolean enable);

/**
 * Enable/disable notification on incoming SMS.
 *
 * \param s State machine pointer.
 * \param[in] enable Whether to enable notifications.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_SetIncomingSMS(GSM_StateMachine * s, gboolean enable);

/**
 * Gets network information from phone.
 *
 * \param s State machine pointer.
 * \param[in] enable Whether to enable notifications.
 *
 * \return Error code.
 *
 * \ingroup CB
 */
GSM_Error GSM_SetIncomingCB(GSM_StateMachine * s, gboolean enable);

/**
 * Returns SMS folders information.
 *
 * \param s State machine pointer.
 * \param[out] folders folders Pointer to folders structure, which will be
 * filled in.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_GetSMSFolders(GSM_StateMachine * s, GSM_SMSFolders * folders);

/**
 * Creates SMS folder.
 *
 * \param s State machine pointer.
 * \param[in] name Name of SMS folder which should be created.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_AddSMSFolder(GSM_StateMachine * s, unsigned char *name);

/**
 * Deletes SMS folder.
 *
 * \param s State machine pointer.
 * \param[in] ID ID of SMS folder to delete.
 *
 * \return Error code.
 *
 * \ingroup SMS
 */
GSM_Error GSM_DeleteSMSFolder(GSM_StateMachine * s, int ID);

/**
 * Lists MMS folders.
 *
 * \param s State machine pointer.
 * \param folders Pointer to structure, whehe folder information will be
 * stored.
 *
 * \return Error code.
 *
 * \ingroup MMS
 */
GSM_Error GSM_GetMMSFolders(GSM_StateMachine * s, GSM_MMSFolders * folders);

/**
 * Retrieves next part of MMS file information.
 *
 * \param s State machine pointer.
 * \param[in,out] FileID File ID will be stored here, might be
 * used for consequent reads.
 * \param[in,out] MMSFolder MMS folder ID will be stored here, might be
 * used for consequent reads.
 * \param[in] start Whether to start reading.
 *
 * \return Error code.
 *
 * \ingroup MMS
 */
GSM_Error GSM_GetNextMMSFileInfo(GSM_StateMachine * s, unsigned char *FileID,
				 int *MMSFolder, gboolean start);
/**
 * Activates/deactivates noticing about incoming USSDs (UnStructured Supplementary Services).
 *
 * \param s State machine pointer.
 * \param[in] enable Whether to enable notifications.
 *
 * \return Error code.
 *
 * \ingroup USSD
 */
GSM_Error GSM_SetIncomingUSSD(GSM_StateMachine * s, gboolean enable);

/**
 * Calculates number of messages and free chars needed for text.
 *
 * \param di Debug settings.
 * \param[in] MessageBuffer Actual message text in unicode.
 * \param[in] UDHType UDH type.
 * \param[in] Coding GSM Encoding type.
 * \param[out] SMSNum Number of messages needed to store the text.
 * \param[out] CharsLeft Number of free chars in the message.
 *
 * \ingroup SMS
 */
void GSM_SMSCounter(GSM_Debug_Info *di, unsigned char *MessageBuffer,
	GSM_UDH UDHType, GSM_Coding_Type Coding, int *SMSNum, size_t *CharsLeft);

#endif

/* Editor configuration
 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72:
 */