Gammu internals  1.38.0
SMS messages
Collaboration diagram for SMS messages:

Data Structures

struct  GSM_SMSMemoryStatus
 
struct  GSM_SMSValidity
 
struct  GSM_SMSC
 
struct  GSM_UDHHeader
 
struct  GSM_SMSMessage
 
struct  GSM_OneSMSFolder
 
struct  GSM_SMSFolders
 
struct  GSM_SiemensOTASMSInfo
 
struct  GSM_MultiSMSMessage
 
struct  GSM_MultiPartSMSEntry
 
struct  GSM_MultiPartSMSInfo
 

Enumerations

enum  GSM_SMSFormat { SMS_FORMAT_Pager = 1, SMS_FORMAT_Fax, SMS_FORMAT_Email, SMS_FORMAT_Text }
 
enum  GSM_ValidityPeriod {
  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
}
 
enum  GSM_ValidityPeriodFormat { SMS_Validity_NotAvailable = 1, SMS_Validity_RelativeFormat }
 
enum  GSM_SMS_State { SMS_Sent = 1, SMS_UnSent, SMS_Read, SMS_UnRead }
 
enum  GSM_Coding_Type {
  SMS_Coding_Unicode_No_Compression = 1, SMS_Coding_Unicode_Compression, SMS_Coding_Default_No_Compression, SMS_Coding_Default_Compression,
  SMS_Coding_8bit
}
 
enum  GSM_UDH {
  UDH_NoUDH = 1, UDH_ConcatenatedMessages, 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
}
 
enum  GSM_SMSMessageType { SMS_Deliver = 1, SMS_Status_Report, SMS_Submit }
 
enum  EncodeMultiPartSMSID {
  SMS_Text = 1, SMS_ConcatenatedTextLong, SMS_ConcatenatedAutoTextLong, SMS_ConcatenatedTextLong16bit,
  SMS_ConcatenatedAutoTextLong16bit, SMS_NokiaProfileLong, SMS_NokiaPictureImageLong, SMS_NokiaScreenSaverLong,
  SMS_NokiaRingtone, SMS_NokiaRingtoneLong, SMS_NokiaOperatorLogo, SMS_NokiaOperatorLogoLong,
  SMS_NokiaCallerLogo, SMS_NokiaWAPBookmarkLong, SMS_NokiaWAPSettingsLong, SMS_NokiaMMSSettingsLong,
  SMS_NokiaVCARD10Long, SMS_NokiaVCARD21Long, SMS_NokiaVCALENDAR10Long, SMS_NokiaVTODOLong,
  SMS_VCARD10Long, SMS_VCARD21Long, SMS_DisableVoice, SMS_DisableFax,
  SMS_DisableEmail, SMS_EnableVoice, SMS_EnableFax, SMS_EnableEmail,
  SMS_VoidSMS, SMS_EMSSound10, SMS_EMSSound12, SMS_EMSSonyEricssonSound,
  SMS_EMSSound10Long, SMS_EMSSound12Long, SMS_EMSSonyEricssonSoundLong, SMS_EMSPredefinedSound,
  SMS_EMSPredefinedAnimation, SMS_EMSAnimation, SMS_EMSFixedBitmap, SMS_EMSVariableBitmap,
  SMS_EMSVariableBitmapLong, SMS_MMSIndicatorLong, SMS_WAPIndicatorLong, SMS_AlcatelMonoBitmapLong,
  SMS_AlcatelMonoAnimationLong, SMS_AlcatelSMSTemplateName, SMS_SiemensFile
}
 

Functions

GSM_Error GSM_DecodePDUFrame (GSM_Debug_Info *di, GSM_SMSMessage *SMS, const unsigned char *buffer, size_t length, size_t *final_pos, gboolean SMSC)
 
GSM_Error GSM_DecodeSMSFrame (GSM_Debug_Info *di, GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout)
 
GSM_Error GSM_EncodeSMSFrame (GSM_Debug_Info *di, GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout, int *length, gboolean clear)
 
GSM_Error GSM_DecodeSMSFrameStatusReportData (GSM_Debug_Info *di, GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout)
 
GSM_Error GSM_DecodeSMSFrameText (GSM_Debug_Info *di, GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout)
 
void GSM_DecodeUDHHeader (GSM_Debug_Info *di, GSM_UDHHeader *UDH)
 
void GSM_EncodeUDHHeader (GSM_Debug_Info *di, GSM_UDHHeader *UDH)
 
void GSM_SetDefaultReceivedSMSData (GSM_SMSMessage *SMS)
 
void GSM_SetDefaultSMSData (GSM_SMSMessage *SMS)
 
gboolean GSM_DecodeSiemensOTASMS (GSM_Debug_Info *di, GSM_SiemensOTASMSInfo *Info, GSM_SMSMessage *SMS)
 
GSM_Error PHONE_EncodeSMSFrame (GSM_StateMachine *s, GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout, int *length, gboolean clear)
 
GSM_Error GSM_EncodeMultiPartSMS (GSM_Debug_Info *di, GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS)
 
gboolean GSM_DecodeMultiPartSMS (GSM_Debug_Info *di, GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS, gboolean ems)
 
void GSM_ClearMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info)
 
void GSM_FreeMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info)
 
GSM_Error GSM_LinkSMS (GSM_Debug_Info *di, GSM_MultiSMSMessage **INPUT, GSM_MultiSMSMessage **OUTPUT, gboolean ems)
 
GSM_Error GSM_GetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc)
 
GSM_Error GSM_SetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc)
 
GSM_Error GSM_GetSMSStatus (GSM_StateMachine *s, GSM_SMSMemoryStatus *status)
 
GSM_Error GSM_GetSMS (GSM_StateMachine *s, GSM_MultiSMSMessage *sms)
 
GSM_Error GSM_GetNextSMS (GSM_StateMachine *s, GSM_MultiSMSMessage *sms, gboolean start)
 
GSM_Error GSM_SetSMS (GSM_StateMachine *s, GSM_SMSMessage *sms)
 
GSM_Error GSM_AddSMS (GSM_StateMachine *s, GSM_SMSMessage *sms)
 
GSM_Error GSM_DeleteSMS (GSM_StateMachine *s, GSM_SMSMessage *sms)
 
GSM_Error GSM_SendSMS (GSM_StateMachine *s, GSM_SMSMessage *sms)
 
GSM_Error GSM_SendSavedSMS (GSM_StateMachine *s, int Folder, int Location)
 
GSM_Error GSM_SetFastSMSSending (GSM_StateMachine *s, gboolean enable)
 
GSM_Error GSM_SetIncomingSMS (GSM_StateMachine *s, gboolean enable)
 
GSM_Error GSM_GetSMSFolders (GSM_StateMachine *s, GSM_SMSFolders *folders)
 
GSM_Error GSM_AddSMSFolder (GSM_StateMachine *s, unsigned char *name)
 
GSM_Error GSM_DeleteSMSFolder (GSM_StateMachine *s, int ID)
 
void GSM_SMSCounter (GSM_Debug_Info *di, unsigned char *MessageBuffer, GSM_UDH UDHType, GSM_Coding_Type Coding, int *SMSNum, size_t *CharsLeft)
 

Variables

GSM_SMSMessageLayout PHONE_SMSSubmit
 
GSM_SMSMessageLayout PHONE_SMSDeliver
 
GSM_SMSMessageLayout PHONE_SMSStatusReport
 

Detailed Description

SMS messages manipulations.

Enumeration Type Documentation

§ EncodeMultiPartSMSID

ID during packing SMS for Smart Messaging 3.0, EMS and other

Enumerator
SMS_Text 

1 text SMS.

SMS_ConcatenatedTextLong 

Contacenated SMS, when longer than 1 SMS.

SMS_ConcatenatedAutoTextLong 

Contacenated SMS, auto Default/Unicode coding.

SMS_ConcatenatedTextLong16bit 
SMS_ConcatenatedAutoTextLong16bit 
SMS_NokiaProfileLong 

Nokia profile = Name, Ringtone, ScreenSaver

SMS_NokiaPictureImageLong 

Nokia Picture Image + (text)

SMS_NokiaScreenSaverLong 

Nokia screen saver + (text)

SMS_NokiaRingtone 

Nokia ringtone - old SM2.0 format, 1 SMS

SMS_NokiaRingtoneLong 

Nokia ringtone contacenated, when very long

SMS_NokiaOperatorLogo 

Nokia 72x14 operator logo, 1 SMS

SMS_NokiaOperatorLogoLong 

Nokia 72x14 op logo or 78x21 in 2 SMS

SMS_NokiaCallerLogo 

Nokia 72x14 caller logo, 1 SMS

SMS_NokiaWAPBookmarkLong 

Nokia WAP bookmark in 1 or 2 SMS

SMS_NokiaWAPSettingsLong 

Nokia WAP settings in 2 SMS

SMS_NokiaMMSSettingsLong 

Nokia MMS settings in 2 SMS

SMS_NokiaVCARD10Long 

Nokia VCARD 1.0 - only name and default number

SMS_NokiaVCARD21Long 

Nokia VCARD 2.1 - all numbers + text

SMS_NokiaVCALENDAR10Long 

Nokia VCALENDAR 1.0 - can be in few sms

SMS_NokiaVTODOLong 
SMS_VCARD10Long 
SMS_VCARD21Long 
SMS_DisableVoice 
SMS_DisableFax 
SMS_DisableEmail 
SMS_EnableVoice 
SMS_EnableFax 
SMS_EnableEmail 
SMS_VoidSMS 
SMS_EMSSound10 

IMelody 1.0

SMS_EMSSound12 

IMelody 1.2

SMS_EMSSonyEricssonSound 

IMelody without header - SonyEricsson extension

SMS_EMSSound10Long 

IMelody 1.0 with UPI.

SMS_EMSSound12Long 

IMelody 1.2 with UPI.

SMS_EMSSonyEricssonSoundLong 

IMelody without header with UPI.

SMS_EMSPredefinedSound 
SMS_EMSPredefinedAnimation 
SMS_EMSAnimation 
SMS_EMSFixedBitmap 

Fixed bitmap of size 16x16 or 32x32.

SMS_EMSVariableBitmap 
SMS_EMSVariableBitmapLong 
SMS_MMSIndicatorLong 

MMS message indicator.

SMS_WAPIndicatorLong 
SMS_AlcatelMonoBitmapLong 

Variable bitmap with black and white colors

SMS_AlcatelMonoAnimationLong 

Variable animation with black and white colors

SMS_AlcatelSMSTemplateName 
SMS_SiemensFile 

Siemens OTA

Definition at line 840 of file gammu-message.h.

840  {
844  SMS_Text = 1,
920  SMS_VoidSMS,
EncodeMultiPartSMSID

§ GSM_Coding_Type

Coding type of SMS.

Enumerator
SMS_Coding_Unicode_No_Compression 

Unicode

SMS_Coding_Unicode_Compression 
SMS_Coding_Default_No_Compression 

Default GSM alphabet.

SMS_Coding_Default_Compression 
SMS_Coding_8bit 

8-bit.

Definition at line 316 of file gammu-message.h.

§ GSM_SMS_State

Status of SMS message.

Enumerator
SMS_Sent 
SMS_UnSent 
SMS_Read 
SMS_UnRead 

Definition at line 304 of file gammu-message.h.

304  {
305  SMS_Sent = 1,
306  SMS_UnSent,
307  SMS_Read,
308  SMS_UnRead
309 } GSM_SMS_State;
GSM_SMS_State

§ GSM_SMSFormat

Enum defines format of SMS messages. See GSM 03.40 section 9.2.3.9

Enumerator
SMS_FORMAT_Pager 
SMS_FORMAT_Fax 
SMS_FORMAT_Email 
SMS_FORMAT_Text 

Definition at line 218 of file gammu-message.h.

218  {
219  SMS_FORMAT_Pager = 1,
223  /* Some values not handled here */
224 } GSM_SMSFormat;
GSM_SMSFormat

§ GSM_SMSMessageType

TP-Message-Type-Indicator. See GSM 03.40 section 9.2.3.1.

Enumerator
SMS_Deliver 

SMS in Inbox.

SMS_Status_Report 

Delivery Report

SMS_Submit 

SMS for sending or in Outbox

Definition at line 422 of file gammu-message.h.

422  {
426  SMS_Deliver = 1,
434  SMS_Submit
435  /* specification gives more */
GSM_SMSMessageType

§ GSM_UDH

enum GSM_UDH

Types of UDH (User Data Header).

Enumerator
UDH_NoUDH 
UDH_ConcatenatedMessages 

Linked SMS.

UDH_ConcatenatedMessages16bit 

Linked SMS with 16 bit reference.

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 

Definition at line 350 of file gammu-message.h.

350  {
351  UDH_NoUDH = 1,
366  UDH_VoidSMS,
372  UDH_NokiaWAP,
377  UDH_UserUDH,
379 } GSM_UDH;
GSM_UDH

§ GSM_ValidityPeriod

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.

Enumerator
SMS_VALID_1_Hour 
SMS_VALID_6_Hours 
SMS_VALID_1_Day 
SMS_VALID_3_Days 
SMS_VALID_1_Week 
SMS_VALID_Max_Time 

Definition at line 233 of file gammu-message.h.

§ GSM_ValidityPeriodFormat

Enum defines format of validity period for SMS messages. See GSM 03.40 section 9.2.3.12

Enumerator
SMS_Validity_NotAvailable 
SMS_Validity_RelativeFormat 

Definition at line 248 of file gammu-message.h.

248  {
251  /* Specification gives also other possibilities */
GSM_ValidityPeriodFormat

Function Documentation

§ GSM_AddSMS()

GSM_Error GSM_AddSMS ( GSM_StateMachine s,
GSM_SMSMessage sms 
)

Adds SMS to specified folder.

Parameters
sState machine pointer.
[in,out]smsSMS message data, location will be updated.
Returns
Error code.

Adds SMS to specified folder.

Definition at line 712 of file api.c.

References GSM_Phone_Functions::AddSMS, CHECK_PHONE_CONNECTION, GSM_Phone::Functions, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, and PRINT_SMS_INFO.

713 {
714  GSM_Error err;
715 
717  PRINT_SMS_INFO();
718 
719  err = s->Phone.Functions->AddSMS(s, sms);
720  PRINT_LOG_ERROR(err);
721  return err;
722 }
GSM_Error
Definition: gammu-error.h:23
GSM_Error(* AddSMS)(GSM_StateMachine *s, GSM_SMSMessage *sms)
Definition: gsmstate.h:955
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
#define PRINT_SMS_INFO()
Definition: api.c:20

§ GSM_AddSMSFolder()

GSM_Error GSM_AddSMSFolder ( GSM_StateMachine s,
unsigned char *  name 
)

Creates SMS folder.

Parameters
sState machine pointer.
[in]nameName of SMS folder which should be created.
Returns
Error code.

Creates SMS folder.

Definition at line 819 of file api.c.

References GSM_Phone_Functions::AddSMSFolder, CHECK_PHONE_CONNECTION, GSM_Phone::Functions, _GSM_StateMachine::Phone, and PRINT_LOG_ERROR.

820 {
821  GSM_Error err;
822 
824 
825  err = s->Phone.Functions->AddSMSFolder(s, name);
826  PRINT_LOG_ERROR(err);
827  return err;
828 }
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
GSM_Error(* AddSMSFolder)(GSM_StateMachine *s, unsigned char *name)
Definition: gsmstate.h:987

§ GSM_ClearMultiPartSMSInfo()

void GSM_ClearMultiPartSMSInfo ( GSM_MultiPartSMSInfo Info)

Clears GSM_MultiPartSMSInfo to default values.

Definition at line 915 of file gsmmulti.c.

References GSM_MultiPartSMSEntry::Bitmap, GSM_MultiPartSMSEntry::Bold, GSM_MultiPartSMSEntry::Bookmark, GSM_MultiPartSMSEntry::Buffer, GSM_MultiPartSMSEntry::Calendar, GSM_MultiPartSMSEntry::Center, GSM_MultiPartSMSInfo::Class, GSM_MultiPartSMSInfo::Entries, GSM_MultiPartSMSInfo::EntriesNum, FALSE, GSM_MultiPartSMSEntry::File, GSM_MAX_MULTI_SMS, GSM_MultiPartSMSEntry::Italic, GSM_MultiPartSMSEntry::Large, GSM_MultiPartSMSEntry::Left, GSM_MultiPartSMSEntry::MMSIndicator, GSM_MultiPartSMSEntry::Number, GSM_MultiPartSMSEntry::Phonebook, GSM_MultiPartSMSEntry::Protected, GSM_MultiPartSMSInfo::ReplaceMessage, GSM_MultiPartSMSEntry::Right, GSM_MultiPartSMSEntry::Ringtone, GSM_MultiPartSMSEntry::RingtoneNotes, GSM_MultiPartSMSEntry::Settings, GSM_MultiPartSMSEntry::Small, GSM_MultiPartSMSEntry::Strikethrough, GSM_MultiPartSMSEntry::ToDo, GSM_MultiPartSMSEntry::Underlined, GSM_MultiPartSMSInfo::UnicodeCoding, and GSM_MultiPartSMSInfo::Unknown.

Referenced by GSM_DecodeMultiPartSMS().

916 {
917  int i;
918 
919  for (i=0;i<GSM_MAX_MULTI_SMS;i++) {
920  Info->Entries[i].Number = 0;
921  Info->Entries[i].Ringtone = NULL;
922  Info->Entries[i].Bitmap = NULL;
923  Info->Entries[i].Bookmark = NULL;
924  Info->Entries[i].File = NULL;
925  Info->Entries[i].Settings = NULL;
926  Info->Entries[i].MMSIndicator = NULL;
927  Info->Entries[i].Phonebook = NULL;
928  Info->Entries[i].Calendar = NULL;
929  Info->Entries[i].ToDo = NULL;
930  Info->Entries[i].Protected = FALSE;
931 
932  Info->Entries[i].Buffer = NULL;
933  Info->Entries[i].Left = FALSE;
934  Info->Entries[i].Right = FALSE;
935  Info->Entries[i].Center = FALSE;
936  Info->Entries[i].Large = FALSE;
937  Info->Entries[i].Small = FALSE;
938  Info->Entries[i].Bold = FALSE;
939  Info->Entries[i].Italic = FALSE;
940  Info->Entries[i].Underlined = FALSE;
941  Info->Entries[i].Strikethrough = FALSE;
942 
943  Info->Entries[i].RingtoneNotes = 0;
944  }
945  Info->Unknown = FALSE;
946  Info->EntriesNum = 0;
947  Info->Class = -1;
948  Info->ReplaceMessage = 0;
949  Info->UnicodeCoding = FALSE;
950 }
GSM_MemoryEntry * Phonebook
GSM_MultiBitmap * Bitmap
GSM_WAPSettings * Settings
unsigned char ReplaceMessage
GSM_MMSIndicator * MMSIndicator
GSM_ToDoEntry * ToDo
GSM_Ringtone * Ringtone
GSM_MultiPartSMSEntry Entries[GSM_MAX_MULTI_SMS]
#define FALSE
Definition: gammu-types.h:25
GSM_WAPBookmark * Bookmark
#define GSM_MAX_MULTI_SMS
Definition: gammu-limits.h:162
unsigned char * Buffer
GSM_CalendarEntry * Calendar

§ GSM_DecodeMultiPartSMS()

gboolean GSM_DecodeMultiPartSMS ( GSM_Debug_Info di,
GSM_MultiPartSMSInfo Info,
GSM_MultiSMSMessage SMS,
gboolean  ems 
)

Decodes multi part SMS to "readable" format.

Definition at line 1275 of file gsmmulti.c.

References GSM_SiemensOTASMSInfo::AllDataLen, GSM_MultiBitmap::Bitmap, GSM_MultiPartSMSEntry::Bitmap, GSM_File::Buffer, GSM_SiemensOTASMSInfo::Data, GSM_SiemensOTASMSInfo::DataLen, GSM_SiemensOTASMSInfo::DataName, _GSM_Debug_Info::df, _GSM_Debug_Info::dl, DL_TEXTALL, DL_TEXTALLDATE, EncodeUnicode(), GSM_MultiPartSMSInfo::Entries, GSM_MultiPartSMSInfo::EntriesNum, ERR_NONE, FALSE, GSM_MultiPartSMSEntry::File, GSM_ClearMultiPartSMSInfo(), GSM_DecodeEMSMultiPartSMS(), GSM_DecodeLinkedText(), GSM_DecodeMMSIndication(), GSM_DecodeNokiaProfile(), GSM_DecodeNokiaRTTLRingtone(), GSM_DecodeSiemensOTASMS(), GSM_NokiaCallerLogo, GSM_NokiaOperatorLogo, GSM_PrintBitmap(), GSM_MultiPartSMSEntry::ID, GSM_SMSMessage::Length, GSM_File::Name, GSM_Bitmap::NetworkCode, NOKIA_DecodeNetworkCode(), GSM_MultiBitmap::Number, GSM_MultiSMSMessage::Number, PHONE_DecodeBitmap(), GSM_MultiPartSMSEntry::Ringtone, GSM_MultiSMSMessage::SMS, SMS_NokiaCallerLogo, SMS_NokiaOperatorLogo, SMS_NokiaRingtone, SMS_NokiaVCALENDAR10Long, SMS_NokiaVCARD10Long, SMS_SiemensFile, GSM_SMSMessage::Text, TRUE, GSM_UDHHeader::Type, GSM_SMSMessage::UDH, UDH_ConcatenatedMessages, UDH_ConcatenatedMessages16bit, UDH_MMSIndicatorLong, UDH_NokiaCalendarLong, UDH_NokiaCallerLogo, UDH_NokiaOperatorLogo, UDH_NokiaPhonebookLong, UDH_NokiaProfileLong, UDH_NokiaRingtone, UDH_UserUDH, and GSM_File::Used.

1279 {
1280  int i;
1281  unsigned int j;
1282  gboolean emsexist = FALSE, result;
1283  GSM_SiemensOTASMSInfo SiemensInfo;
1284 
1286  if (ems) {
1287  emsexist = TRUE;
1288  for (i=0;i<SMS->Number;i++) {
1289  if (SMS->SMS[i].UDH.Type != UDH_ConcatenatedMessages &&
1291  SMS->SMS[i].UDH.Type != UDH_UserUDH) {
1292  emsexist = FALSE;
1293  break;
1294  }
1295  }
1296  }
1297 
1298  /* EMS decoding */
1299  if (emsexist) {
1300  return GSM_DecodeEMSMultiPartSMS(di, Info,SMS);
1301  }
1302 
1303  /* Siemens OTA */
1304  if (GSM_DecodeSiemensOTASMS(di, &SiemensInfo,&SMS->SMS[0])) {
1305  Info->Entries[0].File = (GSM_File *)malloc(sizeof(GSM_File));
1306  if (Info->Entries[0].File == NULL) return FALSE;
1307  Info->Entries[0].File->Buffer = NULL;
1308  Info->Entries[0].File->Used = 0;
1309  for (i=0;i<SMS->Number;i++) {
1310  if (GSM_DecodeSiemensOTASMS(di, &SiemensInfo,&SMS->SMS[i])) {
1311  j = SiemensInfo.AllDataLen - Info->Entries[0].File->Used;
1312  if (j>SiemensInfo.DataLen) j = SiemensInfo.DataLen;
1313  Info->Entries[0].File->Buffer = (unsigned char *)realloc(Info->Entries[0].File->Buffer,j+Info->Entries[0].File->Used);
1314  memcpy(Info->Entries[0].File->Buffer+Info->Entries[0].File->Used,SiemensInfo.Data,j);
1315  Info->Entries[0].File->Used += j;
1316  }
1317  }
1318  if (SiemensInfo.AllDataLen == Info->Entries[0].File->Used) {
1319  Info->Entries[0].ID = SMS_SiemensFile;
1320  Info->EntriesNum = 1;
1321  EncodeUnicode(Info->Entries[0].File->Name,SiemensInfo.DataName,strlen(SiemensInfo.DataName));
1322  return TRUE;
1323  }
1324  free(Info->Entries[0].File->Buffer);
1325  Info->Entries[0].File->Buffer=NULL;
1326  }
1327 
1328  /* Smart Messaging decoding */
1329  if (SMS->SMS[0].UDH.Type == UDH_NokiaRingtone && SMS->Number == 1) {
1330  Info->Entries[0].Ringtone = (GSM_Ringtone *)malloc(sizeof(GSM_Ringtone));
1331  if (Info->Entries[0].Ringtone == NULL) return FALSE;
1332  if (GSM_DecodeNokiaRTTLRingtone(Info->Entries[0].Ringtone, SMS->SMS[0].Text, SMS->SMS[0].Length)==ERR_NONE) {
1333  Info->Entries[0].ID = SMS_NokiaRingtone;
1334  Info->EntriesNum = 1;
1335  return TRUE;
1336  }
1337  }
1338  if (SMS->SMS[0].UDH.Type == UDH_NokiaCallerLogo && SMS->Number == 1) {
1339  Info->Entries[0].Bitmap = (GSM_MultiBitmap *)malloc(sizeof(GSM_MultiBitmap));
1340  if (Info->Entries[0].Bitmap == NULL) return FALSE;
1341  Info->Entries[0].Bitmap->Number = 1;
1342  PHONE_DecodeBitmap(GSM_NokiaCallerLogo, SMS->SMS[0].Text+4, &Info->Entries[0].Bitmap->Bitmap[0]);
1343 #ifdef DEBUG
1344  if (di->dl == DL_TEXTALL || di->dl == DL_TEXTALLDATE)
1345  GSM_PrintBitmap(di->df,&Info->Entries[0].Bitmap->Bitmap[0]);
1346 #endif
1347  Info->Entries[0].ID = SMS_NokiaCallerLogo;
1348  Info->EntriesNum = 1;
1349  return TRUE;
1350  }
1351  if (SMS->SMS[0].UDH.Type == UDH_NokiaOperatorLogo && SMS->Number == 1) {
1352  Info->Entries[0].Bitmap = (GSM_MultiBitmap *)malloc(sizeof(GSM_MultiBitmap));
1353  if (Info->Entries[0].Bitmap == NULL) return FALSE;
1354  Info->Entries[0].Bitmap->Number = 1;
1357 #ifdef DEBUG
1358  if (di->dl == DL_TEXTALL || di->dl == DL_TEXTALLDATE)
1359  GSM_PrintBitmap(di->df,&Info->Entries[0].Bitmap->Bitmap[0]);
1360 #endif
1361  Info->Entries[0].ID = SMS_NokiaOperatorLogo;
1362  Info->EntriesNum = 1;
1363  return TRUE;
1364  }
1365  if (SMS->SMS[0].UDH.Type == UDH_NokiaProfileLong) {
1366  return GSM_DecodeNokiaProfile(di, Info, SMS);
1367  }
1368 
1369  /* Linked sms */
1370  if (SMS->SMS[0].UDH.Type == UDH_ConcatenatedMessages ||
1372  return GSM_DecodeLinkedText(di, Info, SMS);
1373  }
1374  /* Nokia vCard/vCalendar */
1375  if (SMS->SMS[0].UDH.Type == UDH_NokiaCalendarLong ||
1376  SMS->SMS[0].UDH.Type == UDH_NokiaPhonebookLong) {
1377  result = GSM_DecodeLinkedText(di, Info, SMS);
1378  if (result) {
1379  if (SMS->SMS[0].UDH.Type == UDH_NokiaPhonebookLong) {
1380  Info->Entries[0].ID = SMS_NokiaVCARD10Long;
1381  } else {
1382  Info->Entries[0].ID = SMS_NokiaVCALENDAR10Long;
1383  }
1384  }
1385  return result;
1386  }
1387  /* MMS indication */
1388  if (SMS->SMS[0].UDH.Type == UDH_MMSIndicatorLong) {
1389  return GSM_DecodeMMSIndication(di, Info, SMS);
1390  }
1391 
1392  return FALSE;
1393 }
unsigned char Name[2 *(GSM_MAX_FILENAME_LENGTH+1)]
Definition: gammu-file.h:74
unsigned char Text[(GSM_MAX_SMS_LENGTH+1) *2]
gboolean GSM_DecodeMMSIndication(GSM_Debug_Info *di, GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS)
Definition: gsmmulti.c:981
GSM_MultiBitmap * Bitmap
FILE * df
Definition: debug.h:36
GSM_UDHHeader UDH
void PHONE_DecodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap)
Definition: gsmlogo.c:141
unsigned char DataName[40]
GSM_Ringtone * Ringtone
unsigned char * Buffer
Definition: gammu-file.h:94
GSM_MultiPartSMSEntry Entries[GSM_MAX_MULTI_SMS]
unsigned long AllDataLen
gboolean GSM_DecodeSiemensOTASMS(GSM_Debug_Info *di, GSM_SiemensOTASMSInfo *Info, GSM_SMSMessage *SMS)
Definition: gsmsms.c:1202
size_t Used
Definition: gammu-file.h:70
char NetworkCode[10]
Definition: gammu-bitmap.h:160
unsigned char Data[140]
void NOKIA_DecodeNetworkCode(const unsigned char *buffer, char *output)
Definition: gsmnet.c:2473
int gboolean
Definition: gammu-types.h:23
void GSM_PrintBitmap(FILE *file, GSM_Bitmap *bitmap)
Definition: gsmlogo.c:257
void GSM_ClearMultiPartSMSInfo(GSM_MultiPartSMSInfo *Info)
Definition: gsmmulti.c:915
void EncodeUnicode(unsigned char *dest, const char *src, size_t len)
Definition: coding.c:301
#define FALSE
Definition: gammu-types.h:25
gboolean GSM_DecodeEMSMultiPartSMS(GSM_Debug_Info *di, GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS)
Definition: gsmems.c:586
GSM_SMSMessage SMS[GSM_MAX_MULTI_SMS]
EncodeMultiPartSMSID ID
GSM_Bitmap Bitmap[GSM_MAX_MULTI_BITMAP]
Definition: gammu-bitmap.h:192
GSM_Error GSM_DecodeNokiaRTTLRingtone(GSM_Ringtone *ringtone, unsigned char *package, size_t maxlength UNUSED)
Definition: gsmring.c:1128
unsigned char Number
Definition: gammu-bitmap.h:188
gboolean GSM_DecodeNokiaProfile(GSM_Debug_Info *di, GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS)
Definition: gsmmulti.c:1126
#define TRUE
Definition: gammu-types.h:28
Debug_Level dl
Definition: debug.h:35
gboolean GSM_DecodeLinkedText(GSM_Debug_Info *di, GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS)
Definition: gsmmulti.c:1229

§ GSM_DecodePDUFrame()

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 PDU data.

Parameters
diDebug information structure.
SMSPointer where to store parsed message.
bufferPDU data.
lengthLength of PDU data.
final_posOptional pointer where end position will be stored.
SMSCWhether PDU includes SMSC data.

Definition at line 508 of file gsmsms.c.

References GSM_SMSMessage::Class, GSM_SMSMessage::Coding, GSM_SMSMessage::DateTime, DecodeDefault(), DecodeUnicodeSpecialNOKIAChars(), DecodeUnicodeString(), DumpMessageText(), ERR_CORRUPTED, ERR_NONE, ERR_NOTSUPPORTED, ERR_UNKNOWN, FALSE, GSM_SMSValidity::Format, GSM_DecodeSMSDateTime(), GSM_DecodeSMSStatusReportData(), GSM_DecodeUDHHeader(), GSM_GetMessageCoding(), GSM_SetDefaultReceivedSMSData(), GSM_UnpackEightBitsToSeven(), GSM_UnpackSemiOctetNumber(), GSM_UDHHeader::Length, GSM_SMSMessage::Length, GSM_SMSMessage::MessageReference, GSM_SMSC::Number, GSM_SMSMessage::Number, GSM_SMSMessage::PDU, GSM_SMSValidity::Relative, GSM_SMSMessage::ReplaceMessage, smfprintf(), SMS_Coding_8bit, SMS_Coding_Default_Compression, SMS_Coding_Default_No_Compression, SMS_Coding_Unicode_Compression, SMS_Coding_Unicode_No_Compression, SMS_Deliver, SMS_Status_Report, SMS_Submit, SMS_Validity_RelativeFormat, GSM_SMSMessage::SMSC, GSM_SMSMessage::SMSCTime, GSM_UDHHeader::Text, GSM_SMSMessage::Text, TRUE, GSM_SMSMessage::UDH, and GSM_SMSC::Validity.

509 {
510  size_t pos = 0;
511  int type, tp_pi;
512  int vpf = 0;
513  int udh = 0;
514  int i,w;
515  unsigned char output[161];
516  int datalength;
517  gboolean have_data = FALSE;
518  GSM_Error error;
519 
520  /* Set some sane data */
522 
523  /* Parse SMSC if it is included */
524  if (SMSC) {
525  error = GSM_UnpackSemiOctetNumber(di, SMS->SMSC.Number, buffer, &pos, length, FALSE);
526  if (error != ERR_NONE) {
527  return error;
528  }
529  smfprintf(di, "SMS center number : \"%s\"\n",DecodeUnicodeString(SMS->SMSC.Number));
530  }
531 
532  /* Message type */
533  type = buffer[pos];
534  pos++;
535  switch (type & 0x3) {
536  case 0:
537  smfprintf(di, "SMS type: Deliver");
538  SMS->PDU = SMS_Deliver;
539  break;
540  case 1:
541  smfprintf(di, "SMS type: Submit");
542  SMS->PDU = SMS_Submit;
543  break;
544  case 2:
545  smfprintf(di, "SMS type: Status report");
546  SMS->PDU = SMS_Status_Report;
547  break;
548  case 3:
549  smfprintf(di, "SMS type: Reserved message type, aborting!\n");
550  return ERR_UNKNOWN;;
551  }
552 
553  if (SMS->PDU == SMS_Submit || SMS->PDU == SMS_Deliver) {
554  if (type & (1 << 7)) {
555  smfprintf(di, ", Reply path set");
556  }
557  if (type & (1 << 6)) {
558  smfprintf(di, ", UDH included");
559  udh = 1;
560  }
561  if (type & (1 << 5)) {
562  smfprintf(di, ", Delivery report requested");
563  }
564  }
565  if (SMS->PDU == SMS_Submit) {
566  vpf = (type & (0x3 << 3)) >> 3;
567  switch (vpf) {
568  case 0:
569  smfprintf(di, ", No VP");
570  break;
571  case 1:
572  smfprintf(di, ", Reserved VP!\n");
573  return ERR_UNKNOWN;
574  case 2:
575  smfprintf(di, ", Relative VP");
576  break;
577  case 3:
578  smfprintf(di, ", Absolute VP");
579  break;
580  }
581  }
582  smfprintf(di, "\n");
583 
584  /* Message reference */
585  if (SMS->PDU == SMS_Submit || SMS->PDU == SMS_Status_Report) {
586  SMS->MessageReference = buffer[pos];
587  smfprintf(di, "SMS MR: 0x%02X\n", SMS->MessageReference);
588  pos++;
589  if (pos >= length) {
590  smfprintf(di, "Ran out of buffer when parsing PDU!\n");
591  return ERR_CORRUPTED;
592  }
593  }
594 
595  /* Remote number */
596  error = GSM_UnpackSemiOctetNumber(di, SMS->Number, buffer, &pos, length, TRUE);
597  if (error != ERR_NONE) {
598  return error;
599  }
600  smfprintf(di, "Remote number : \"%s\"\n",DecodeUnicodeString(SMS->Number));
601  if (pos >= length) {
602  smfprintf(di, "Ran out of buffer when parsing PDU!\n");
603  return ERR_CORRUPTED;
604  }
605 
606 
607  if (SMS->PDU == SMS_Submit || SMS->PDU == SMS_Deliver) {
608  /* Protocol identifier */
609  smfprintf(di, "SMS PID: 0x%02X\n", buffer[pos]);
610  if (buffer[pos] > 0x40 && buffer[pos] < 0x48) {
611  SMS->ReplaceMessage = buffer[pos] - 0x40;
612  }
613  pos++;
614  if (pos >= length) {
615  smfprintf(di, "Ran out of buffer when parsing PDU!\n");
616  return ERR_CORRUPTED;
617  }
618 
619  /* Data coding scheme */
620  smfprintf(di, "SMS DCS: 0x%02X\n", buffer[pos]);
621  SMS->Coding = GSM_GetMessageCoding(di, buffer[pos]);
622 
623  /* Message class */
624  SMS->Class = -1;
625  /* GSM 03.40 section 9.2.3.10 (TP-Data-Coding-Scheme) and GSM 03.38 section 4 */
626  if ((buffer[pos] & 0xD0) == 0x10 || (buffer[pos] & 0xF0) == 0xF0) {
627  SMS->Class = buffer[pos] & 3;
628  }
629  smfprintf(di, "SMS class: %i\n", SMS->Class);
630 
631  pos++;
632  if (pos >= length) {
633  smfprintf(di, "Ran out of buffer when parsing PDU!\n");
634  return ERR_CORRUPTED;
635  }
636  }
637 
638  /* SMSC time stamp */
639  if (SMS->PDU == SMS_Status_Report || SMS->PDU == SMS_Deliver) {
640  if (pos + 7 >= length) {
641  smfprintf(di, "Ran out of buffer when parsing PDU!\n");
642  return ERR_CORRUPTED;
643  }
644  GSM_DecodeSMSDateTime(di, &SMS->DateTime, buffer + pos);
645  pos += 7;
646  }
647 
648  if (SMS->PDU == SMS_Status_Report) {
649  /* Discharge Time */
650  if (pos + 7 >= length) {
651  smfprintf(di, "Ran out of buffer when parsing PDU!\n");
652  return ERR_CORRUPTED;
653  }
654  GSM_DecodeSMSDateTime(di, &SMS->SMSCTime, buffer + pos);
655  pos += 7;
656 
657  /* Status */
658  GSM_DecodeSMSStatusReportData(di, SMS, buffer[pos]);
659  pos++;
660 
661  /* Optional part coming from ETSI 123 040, section 9.2.2.3 */
662  /* We ignore 0xff, because some buggy phones pad SMS with it */
663  if (pos < length && buffer[pos] != 0xff) {
664  /* TP-Parameter-Indicator */
665  tp_pi = buffer[pos];
666  pos++;
667 
668  /* We have TP-PID */
669  if (tp_pi & 1) {
670  smfprintf(di, "SMS PID: 0x%02X\n", buffer[pos]);
671  if (buffer[pos] > 0x40 && buffer[pos] < 0x48) {
672  SMS->ReplaceMessage = buffer[pos] - 0x40;
673  }
674  pos++;
675  }
676 
677  /* We have TP-DCS */
678  if (tp_pi & 2) {
679  smfprintf(di, "SMS DCS: 0x%02X\n", buffer[pos]);
680  SMS->Coding = GSM_GetMessageCoding(di, buffer[pos]);
681  pos++;
682  } else {
683  SMS->Coding = GSM_GetMessageCoding(di, 0);
684  }
685 
686  /* We have TP-UDL */
687  if (tp_pi & 4) {
688  have_data = TRUE;
689  }
690  }
691  }
692 
693  /* Validity period */
694  if (SMS->PDU == SMS_Submit) {
695  if (vpf == 2) {
697  SMS->SMSC.Validity.Relative = buffer[pos];
698  smfprintf(di, "Relative validity: 0x%02X\n", buffer[pos]);
699  pos++;
700  if (pos >= length) {
701  smfprintf(di, "Ran out of buffer when parsing PDU!\n");
702  return ERR_CORRUPTED;
703  }
704  } else if (vpf == 3) {
705  /* @todo TODO: handle absolute validity */
706  smfprintf(di, "Absolute validity not handled!\n");
707  pos += 7;
708  if (pos >= length) {
709  smfprintf(di, "Ran out of buffer when parsing PDU!\n");
710  return ERR_CORRUPTED;
711  }
712  }
713  }
714 
715  /* Data */
716  if (SMS->PDU == SMS_Submit || SMS->PDU == SMS_Deliver || have_data) {
717  datalength = buffer[pos];
719  datalength = (datalength * 7) / 8;
720  if ((buffer[pos] * 7) % 8 != 0) {
721  datalength++;
722  }
723  } else if (SMS->Coding == SMS_Coding_Unicode_Compression) {
724  smfprintf(di, "Compressed unicode messages not yet supported!\n");
725  return ERR_NOTSUPPORTED;
726  } else if (SMS->Coding == SMS_Coding_Default_Compression) {
727  smfprintf(di, "Compressed 7-bit messages not yet supported!\n");
728  return ERR_NOTSUPPORTED;
729  }
730 
731  if (pos + datalength >= length) {
732  smfprintf(di, "Ran out of buffer when parsing PDU!\n");
733  return ERR_CORRUPTED;
734  }
735  if (final_pos != NULL) {
736  *final_pos = pos + datalength + 1;
737  }
738  SMS->UDH.Length = 0;
739  /* UDH header available */
740  if (udh) {
741  /* Length of UDH header */
742  SMS->UDH.Length = (buffer[pos + 1] + 1);
743  smfprintf(di, "UDH header available (length %i)\n",SMS->UDH.Length);
744 
745  /* Copy UDH header into SMS->UDH */
746  for (i = 0; i < SMS->UDH.Length; i++) SMS->UDH.Text[i] = buffer[pos + 1 + i];
747 
748  GSM_DecodeUDHHeader(di, &SMS->UDH);
749  }
750 
751  switch (SMS->Coding) {
753  i = 0;
754  do {
755  i+=7;
756  w=(i-SMS->UDH.Length)%i;
757  } while (w<0);
758  SMS->Length=buffer[pos] - (SMS->UDH.Length*8 + w) / 7;
759  if (SMS->Length < 0) {
760  smfprintf(di, "No SMS text!\n");
761  SMS->Length = 0;
762  break;
763  }
764  GSM_UnpackEightBitsToSeven(w, buffer[pos]-SMS->UDH.Length, SMS->Length, buffer+(pos + 1+SMS->UDH.Length), output);
765  smfprintf(di, "7 bit SMS, length %i\n",SMS->Length);
766  DecodeDefault (SMS->Text, output, SMS->Length, TRUE, NULL);
767  smfprintf(di, "%s\n",DecodeUnicodeString(SMS->Text));
768  break;
769  case SMS_Coding_8bit:
770  SMS->Length=buffer[pos] - SMS->UDH.Length;
771  if (SMS->Length < 0) {
772  smfprintf(di, "Invalid message length!\n");
773  return ERR_CORRUPTED;
774  }
775  memcpy(SMS->Text,buffer+(pos + 1+SMS->UDH.Length),SMS->Length);
776 #ifdef DEBUG
777  smfprintf(di, "8 bit SMS, length %i\n",SMS->Length);
778  DumpMessageText(di, SMS->Text, SMS->Length);
779 #endif
780  break;
782  SMS->Length=(buffer[pos] - SMS->UDH.Length) / 2;
783  if (SMS->Length < 0) {
784  smfprintf(di, "Invalid message length!\n");
785  return ERR_CORRUPTED;
786  }
787  DecodeUnicodeSpecialNOKIAChars(SMS->Text,buffer+(pos + 1+SMS->UDH.Length), SMS->Length);
788 #ifdef DEBUG
789  smfprintf(di, "Unicode SMS, length %i\n",SMS->Length);
790  DumpMessageText(di, buffer+(pos + 1+SMS->UDH.Length), SMS->Length*2);
791  smfprintf(di, "%s\n",DecodeUnicodeString(SMS->Text));
792 #endif
793  break;
794  default:
795  SMS->Length=0;
796  break;
797  }
798  } else {
799  if (final_pos != NULL) {
800  *final_pos = pos;
801  }
802  }
803 
804  return ERR_NONE;
805 }
GSM_SMSMessageType PDU
GSM_DateTime DateTime
void GSM_SetDefaultReceivedSMSData(GSM_SMSMessage *SMS)
Definition: gsmsms.c:1092
GSM_Error GSM_DecodeSMSStatusReportData(GSM_Debug_Info *di, GSM_SMSMessage *SMS, int TP_ST)
Definition: gsmsms.c:384
unsigned char Text[(GSM_MAX_SMS_LENGTH+1) *2]
char * DecodeUnicodeString(const unsigned char *src)
Definition: coding.c:245
unsigned char Number[(GSM_MAX_NUMBER_LENGTH+1) *2]
static GSM_Error GSM_DecodeSMSDateTime(GSM_Debug_Info *di, GSM_DateTime *DT, const unsigned char *req)
Definition: gsmsms.c:89
void DecodeDefault(unsigned char *dest, const unsigned char *src, size_t len, gboolean UseExtensions, unsigned char *ExtraAlphabet)
Definition: coding.c:498
unsigned char ReplaceMessage
void DumpMessageText(GSM_Debug_Info *d, const unsigned char *message, const size_t messagesize)
Definition: debug.c:371
GSM_Error
Definition: gammu-error.h:23
signed char Class
GSM_UDHHeader UDH
GSM_Coding_Type Coding
unsigned char Text[GSM_MAX_UDH_LENGTH]
int gboolean
Definition: gammu-types.h:23
GSM_ValidityPeriodFormat Format
#define FALSE
Definition: gammu-types.h:25
GSM_SMSValidity Validity
GSM_Coding_Type GSM_GetMessageCoding(GSM_Debug_Info *di, const char TPDCS)
Definition: gsmsms.c:261
unsigned char Number[(GSM_MAX_NUMBER_LENGTH+1) *2]
void DecodeUnicodeSpecialNOKIAChars(unsigned char *dest, const unsigned char *src, size_t len)
Definition: coding.c:1401
GSM_Error GSM_UnpackSemiOctetNumber(GSM_Debug_Info *di, unsigned char *retval, const unsigned char *Number, size_t *pos, size_t bufferlength, gboolean semioctet)
Definition: coding.c:1028
int GSM_UnpackEightBitsToSeven(size_t offset, size_t in_length, size_t out_length, const unsigned char *input, unsigned char *output)
Definition: coding.c:953
void GSM_DecodeUDHHeader(GSM_Debug_Info *di, GSM_UDHHeader *UDH)
Definition: gsmsms.c:121
int smfprintf(GSM_Debug_Info *d, const char *format,...)
Definition: debug.c:240
#define TRUE
Definition: gammu-types.h:28
unsigned char MessageReference
GSM_DateTime SMSCTime
GSM_ValidityPeriod Relative

§ GSM_DecodeSiemensOTASMS()

gboolean GSM_DecodeSiemensOTASMS ( GSM_Debug_Info di,
GSM_SiemensOTASMSInfo Info,
GSM_SMSMessage SMS 
)

Decodes Siemens OTA data.

Definition at line 1202 of file gsmsms.c.

References GSM_SiemensOTASMSInfo::AllDataLen, GSM_SMSMessage::Class, GSM_SMSMessage::Coding, GSM_SiemensOTASMSInfo::Data, GSM_SiemensOTASMSInfo::DataLen, GSM_SiemensOTASMSInfo::DataName, GSM_SiemensOTASMSInfo::DataType, FALSE, GSM_SMSMessage::Length, GSM_SiemensOTASMSInfo::PacketNum, GSM_SiemensOTASMSInfo::PacketsNum, GSM_SMSMessage::PDU, GSM_SiemensOTASMSInfo::SequenceID, smfprintf(), SMS_Coding_8bit, SMS_Deliver, GSM_SMSMessage::Text, TRUE, GSM_UDHHeader::Type, GSM_SMSMessage::UDH, and UDH_NoUDH.

Referenced by GSM_DecodeMultiPartSMS(), and GSM_LinkSMS().

1204 {
1205  int current;
1206 
1207  if (SMS->PDU != SMS_Deliver) {
1208  return FALSE;
1209  }
1210  if (SMS->Coding != SMS_Coding_8bit) {
1211  return FALSE;
1212  }
1213  if (SMS->Class != 1) {
1214  return FALSE;
1215  }
1216  if (SMS->UDH.Type != UDH_NoUDH) {
1217  return FALSE;
1218  }
1219  if (SMS->Length < 22) {
1220  return FALSE;
1221  }
1222 
1223  if (strncmp(SMS->Text, "//SEO",5) != 0) {
1224  return FALSE; /* Siemens Exchange Object */
1225  }
1226  if (SMS->Text[5] != 1) {
1227  return FALSE; /* version 1 */
1228  }
1229  Info->DataLen = SMS->Text[6] + SMS->Text[7]*256;
1230  Info->SequenceID = SMS->Text[8] + SMS->Text[9]*256 +
1231  SMS->Text[10]*256*256 + SMS->Text[11]*256*256*256;
1232  Info->PacketNum = SMS->Text[12] + SMS->Text[13]*256;
1233  Info->PacketsNum = SMS->Text[14] + SMS->Text[15]*256;
1234  smfprintf(di, "Packet %i/%i\n",Info->PacketNum,Info->PacketsNum);
1235  Info->AllDataLen = SMS->Text[16] + SMS->Text[17]*256 +
1236  SMS->Text[18]*256*256 + SMS->Text[19]*256*256*256;
1237  smfprintf(di, "DataLen %i/%lu\n",Info->DataLen,Info->AllDataLen);
1238 
1239  if (SMS->Text[20] > 9) {
1240  return FALSE;
1241  }
1242  memcpy(Info->DataType,SMS->Text+21,SMS->Text[20]);
1243  Info->DataType[SMS->Text[20]] = 0;
1244  smfprintf(di, "DataType '%s'\n",Info->DataType);
1245 
1246  current = 21+SMS->Text[20];
1247  if (SMS->Text[current] > 39) {
1248  return FALSE;
1249  }
1250  memcpy(Info->DataName,SMS->Text+current+1,SMS->Text[current]);
1251  Info->DataName[SMS->Text[current]] = 0;
1252  smfprintf(di, "DataName '%s'\n",Info->DataName);
1253 
1254  current += SMS->Text[current]+1;
1255  memcpy(Info->Data,SMS->Text+current,Info->DataLen);
1256 
1257  return TRUE;
1258 }
GSM_SMSMessageType PDU
unsigned char Text[(GSM_MAX_SMS_LENGTH+1) *2]
signed char Class
GSM_UDHHeader UDH
unsigned char DataName[40]
GSM_Coding_Type Coding
unsigned long AllDataLen
unsigned char Data[140]
#define FALSE
Definition: gammu-types.h:25
unsigned int PacketNum
unsigned int PacketsNum
int smfprintf(GSM_Debug_Info *d, const char *format,...)
Definition: debug.c:240
#define TRUE
Definition: gammu-types.h:28
unsigned long SequenceID
unsigned char DataType[10]

§ GSM_DecodeSMSFrame()

GSM_Error GSM_DecodeSMSFrame ( GSM_Debug_Info di,
GSM_SMSMessage SMS,
unsigned char *  buffer,
GSM_SMSMessageLayout  Layout 
)

Decodes SMS frame.

Definition at line 807 of file gsmsms.c.

References GSM_SMSMessage::Class, GSM_SMSMessage::Coding, GSM_SMSMessage::DateTime, GSM_SMSMessageLayout::DateTime, DecodeUnicodeString(), ERR_NONE, ERR_UNKNOWN, FALSE, GSM_SMSMessageLayout::firstbyte, GSM_DecodeSMSDateTime(), GSM_DecodeSMSFrameStatusReportData(), GSM_DecodeSMSFrameText(), GSM_GetMessageCoding(), GSM_SetDefaultReceivedSMSData(), GSM_UnpackSemiOctetNumber(), GSM_SMSMessage::MessageReference, GSM_SMSC::Number, GSM_SMSMessage::Number, GSM_SMSMessageLayout::Number, GSM_SMSMessage::RejectDuplicates, GSM_SMSMessage::ReplaceMessage, GSM_SMSMessage::ReplyViaSameSMSC, smfprintf(), GSM_SMSMessage::SMSC, GSM_SMSMessageLayout::SMSCNumber, GSM_SMSMessage::SMSCTime, GSM_SMSMessageLayout::SMSCTime, GSM_SMSMessageLayout::Text, GSM_SMSMessageLayout::TPDCS, GSM_SMSMessageLayout::TPMR, GSM_SMSMessageLayout::TPPID, GSM_SMSMessageLayout::TPStatus, GSM_SMSMessageLayout::TPUDL, and TRUE.

808 {
809  GSM_DateTime zerodt = {0,0,0,0,0,0,0};
810  size_t pos;
811  GSM_Error error;
812 
813 #ifdef DEBUG
814  if (Layout.firstbyte == 255) {
815  smfprintf(di, "ERROR: firstbyte in SMS layout not set\n");
816  return ERR_UNKNOWN;
817  }
818  if (Layout.TPDCS != 255) smfprintf(di, "TPDCS : %02x %i\n",buffer[Layout.TPDCS] ,buffer[Layout.TPDCS]);
819  if (Layout.TPMR != 255) smfprintf(di, "TPMR : %02x %i\n",buffer[Layout.TPMR] ,buffer[Layout.TPMR]);
820  if (Layout.TPPID != 255) smfprintf(di, "TPPID : %02x %i\n",buffer[Layout.TPPID] ,buffer[Layout.TPPID]);
821  if (Layout.TPUDL != 255) smfprintf(di, "TPUDL : %02x %i\n",buffer[Layout.TPUDL] ,buffer[Layout.TPUDL]);
822  if (Layout.firstbyte != 255) smfprintf(di, "FirstByte : %02x %i\n",buffer[Layout.firstbyte],buffer[Layout.firstbyte]);
823  if (Layout.Text != 255 && Layout.TPUDL != 255 && buffer[Layout.TPUDL] > 0) {
824  smfprintf(di, "Text : %02x %i\n",buffer[Layout.Text] ,buffer[Layout.Text]);
825  }
826 #endif
827 
829 
830  if (Layout.SMSCNumber!=255) {
831  pos = Layout.SMSCNumber;
832  error = GSM_UnpackSemiOctetNumber(di, SMS->SMSC.Number, buffer, &pos, 1000, FALSE);
833  if (error != ERR_NONE) {
834  return error;
835  }
836  smfprintf(di, "SMS center number : \"%s\"\n",DecodeUnicodeString(SMS->SMSC.Number));
837  }
838  if ((buffer[Layout.firstbyte] & 0x80)!=0) SMS->ReplyViaSameSMSC=TRUE;
839 #ifdef DEBUG
840  if (SMS->ReplyViaSameSMSC) smfprintf(di, "SMS centre set for reply\n");
841 #endif
842  if (Layout.Number!=255) {
843  pos = Layout.Number;
844  error = GSM_UnpackSemiOctetNumber(di, SMS->Number, buffer, &pos, 1000, TRUE);
845  if (error != ERR_NONE) {
846  return error;
847  }
848  smfprintf(di, "Remote number : \"%s\"\n",DecodeUnicodeString(SMS->Number));
849  }
850  if (Layout.TPDCS != 255) {
851  /* Get message coding */
852  SMS->Coding = GSM_GetMessageCoding(di, buffer[Layout.TPDCS]);
853  }
854  if (Layout.Text != 255 && Layout.TPDCS!=255 && Layout.TPUDL!=255 && buffer[Layout.TPUDL] > 0) {
855  GSM_DecodeSMSFrameText(di, SMS, buffer, Layout);
856  }
857  if (Layout.DateTime != 255) {
858  GSM_DecodeSMSDateTime(di, &SMS->DateTime,buffer+(Layout.DateTime));
859  } else {
860  SMS->DateTime = zerodt;
861  }
862  if (Layout.SMSCTime != 255 && Layout.TPStatus != 255) {
863  /* GSM 03.40 section 9.2.3.11 (TP-Service-Centre-Time-Stamp) */
864  smfprintf(di, "SMSC response date: ");
865  GSM_DecodeSMSDateTime(di, &SMS->SMSCTime, buffer+(Layout.SMSCTime));
866  GSM_DecodeSMSFrameStatusReportData(di, SMS,buffer,Layout);
867  } else {
868  SMS->SMSCTime = zerodt;
869  }
870  SMS->Class = -1;
871  if (Layout.TPDCS != 255) {
872  /* GSM 03.40 section 9.2.3.10 (TP-Data-Coding-Scheme) and GSM 03.38 section 4 */
873  if ((buffer[Layout.TPDCS] & 0xD0) == 0x10) {
874  /* bits 7..4 set to 00x1 */
875  if ((buffer[Layout.TPDCS] & 0xC) == 0xC) {
876  smfprintf(di, "WARNING: reserved alphabet value in TPDCS\n");
877  } else {
878  SMS->Class = (buffer[Layout.TPDCS] & 3);
879  }
880  } else if ((buffer[Layout.TPDCS] & 0xF0) == 0xF0) {
881  /* bits 7..4 set to 1111 */
882  if ((buffer[Layout.TPDCS] & 8) == 8) {
883  smfprintf(di, "WARNING: set reserved bit 3 in TPDCS\n");
884  } else {
885  SMS->Class = (buffer[Layout.TPDCS] & 3);
886  }
887  }
888  }
889  smfprintf(di, "SMS class: %i\n",SMS->Class);
890 
891  SMS->MessageReference = 0;
892  if (Layout.TPMR != 255) SMS->MessageReference = buffer[Layout.TPMR];
893 
894  SMS->ReplaceMessage = 0;
895  if (Layout.TPPID != 255) {
896  if (buffer[Layout.TPPID] > 0x40 && buffer[Layout.TPPID] < 0x48) {
897  SMS->ReplaceMessage = buffer[Layout.TPPID] - 0x40;
898  }
899  }
900  SMS->RejectDuplicates = FALSE;
901  if ((buffer[Layout.firstbyte] & 0x04)==0x04) SMS->RejectDuplicates = TRUE;
902 
903  return ERR_NONE;
904 }
unsigned char Text
GSM_DateTime DateTime
unsigned char TPUDL
void GSM_SetDefaultReceivedSMSData(GSM_SMSMessage *SMS)
Definition: gsmsms.c:1092
char * DecodeUnicodeString(const unsigned char *src)
Definition: coding.c:245
unsigned char Number[(GSM_MAX_NUMBER_LENGTH+1) *2]
static GSM_Error GSM_DecodeSMSDateTime(GSM_Debug_Info *di, GSM_DateTime *DT, const unsigned char *req)
Definition: gsmsms.c:89
unsigned char TPDCS
unsigned char ReplaceMessage
unsigned char SMSCTime
GSM_Error
Definition: gammu-error.h:23
gboolean RejectDuplicates
signed char Class
GSM_Coding_Type Coding
unsigned char SMSCNumber
GSM_Error GSM_DecodeSMSFrameText(GSM_Debug_Info *di, GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout)
Definition: gsmsms.c:316
#define FALSE
Definition: gammu-types.h:25
GSM_Coding_Type GSM_GetMessageCoding(GSM_Debug_Info *di, const char TPDCS)
Definition: gsmsms.c:261
unsigned char Number[(GSM_MAX_NUMBER_LENGTH+1) *2]
unsigned char firstbyte
GSM_Error GSM_UnpackSemiOctetNumber(GSM_Debug_Info *di, unsigned char *retval, const unsigned char *Number, size_t *pos, size_t bufferlength, gboolean semioctet)
Definition: coding.c:1028
unsigned char TPStatus
int smfprintf(GSM_Debug_Info *d, const char *format,...)
Definition: debug.c:240
#define TRUE
Definition: gammu-types.h:28
unsigned char MessageReference
gboolean ReplyViaSameSMSC
GSM_DateTime SMSCTime
unsigned char DateTime
unsigned char Number
unsigned char TPMR
GSM_Error GSM_DecodeSMSFrameStatusReportData(GSM_Debug_Info *di, GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout)
Definition: gsmsms.c:503
unsigned char TPPID

§ GSM_DecodeSMSFrameStatusReportData()

GSM_Error GSM_DecodeSMSFrameStatusReportData ( GSM_Debug_Info di,
GSM_SMSMessage SMS,
unsigned char *  buffer,
GSM_SMSMessageLayout  Layout 
)

Decodes SMS frame for status report.

Definition at line 503 of file gsmsms.c.

References GSM_DecodeSMSStatusReportData(), and GSM_SMSMessageLayout::TPStatus.

Referenced by GSM_DecodeSMSFrame().

504 {
505  return GSM_DecodeSMSStatusReportData(di, SMS, buffer[Layout.TPStatus]);
506 }
GSM_Error GSM_DecodeSMSStatusReportData(GSM_Debug_Info *di, GSM_SMSMessage *SMS, int TP_ST)
Definition: gsmsms.c:384
unsigned char TPStatus

§ GSM_DecodeSMSFrameText()

GSM_Error GSM_DecodeSMSFrameText ( GSM_Debug_Info di,
GSM_SMSMessage SMS,
unsigned char *  buffer,
GSM_SMSMessageLayout  Layout 
)

Decodes SMS frame in textual representation.

Definition at line 316 of file gsmsms.c.

References GSM_SMSMessage::Coding, DecodeDefault(), DecodeUnicodeSpecialNOKIAChars(), DecodeUnicodeString(), DumpMessageText(), ERR_CORRUPTED, ERR_NONE, GSM_SMSMessageLayout::firstbyte, GSM_DecodeUDHHeader(), GSM_UnpackEightBitsToSeven(), GSM_UDHHeader::Length, GSM_SMSMessage::Length, smfprintf(), SMS_Coding_8bit, SMS_Coding_Default_No_Compression, SMS_Coding_Unicode_No_Compression, GSM_UDHHeader::Text, GSM_SMSMessage::Text, GSM_SMSMessageLayout::Text, GSM_SMSMessageLayout::TPUDL, TRUE, and GSM_SMSMessage::UDH.

Referenced by GSM_DecodeSMSFrame().

317 {
318  int off=0; /* length of the User Data Header */
319  int w,i;
320  unsigned char output[1024];
321 
322  SMS->UDH.Length = 0;
323  /* UDH header available */
324  if (buffer[Layout.firstbyte] & 64) {
325  /* Length of UDH header */
326  off = (buffer[Layout.Text] + 1);
327  if (off > buffer[Layout.TPUDL]) {
328  return ERR_CORRUPTED;
329  }
330  SMS->UDH.Length = off;
331  smfprintf(di, "UDH header available (length %i)\n",off);
332 
333  /* Copy UDH header into SMS->UDH */
334  for (i = 0; i < off; i++) {
335  SMS->UDH.Text[i] = buffer[Layout.Text + i];
336  }
337 
338  GSM_DecodeUDHHeader(di, &SMS->UDH);
339  }
340 
341  switch (SMS->Coding) {
343  i = 0;
344  do {
345  i+=7;
346  w=(i-off)%i;
347  } while (w<0);
348  SMS->Length=buffer[Layout.TPUDL] - (off*8 + w) / 7;
349  if (SMS->Length < 0) {
350  smfprintf(di, "No SMS text!\n");
351  SMS->Length = 0;
352  break;
353  }
354  GSM_UnpackEightBitsToSeven(w, buffer[Layout.TPUDL]-off, SMS->Length, buffer+(Layout.Text+off), output);
355  smfprintf(di, "7 bit SMS, length %i\n",SMS->Length);
356  DecodeDefault (SMS->Text, output, SMS->Length, TRUE, NULL);
357  smfprintf(di, "%s\n",DecodeUnicodeString(SMS->Text));
358  break;
359  case SMS_Coding_8bit:
360  SMS->Length=buffer[Layout.TPUDL] - off;
361  memcpy(SMS->Text,buffer+(Layout.Text+off),SMS->Length);
362 #ifdef DEBUG
363  smfprintf(di, "8 bit SMS, length %i\n",SMS->Length);
364  DumpMessageText(di, SMS->Text, SMS->Length);
365 #endif
366  break;
368  SMS->Length=(buffer[Layout.TPUDL] - off) / 2;
369  DecodeUnicodeSpecialNOKIAChars(SMS->Text,buffer+(Layout.Text+off), SMS->Length);
370 #ifdef DEBUG
371  smfprintf(di, "Unicode SMS, length %i\n",SMS->Length);
372  DumpMessageText(di, buffer+(Layout.Text+off), SMS->Length*2);
373  smfprintf(di, "%s\n",DecodeUnicodeString(SMS->Text));
374 #endif
375  break;
376  default:
377  SMS->Length=0;
378  break;
379  }
380 
381  return ERR_NONE;
382 }
unsigned char Text
unsigned char TPUDL
unsigned char Text[(GSM_MAX_SMS_LENGTH+1) *2]
char * DecodeUnicodeString(const unsigned char *src)
Definition: coding.c:245
void DecodeDefault(unsigned char *dest, const unsigned char *src, size_t len, gboolean UseExtensions, unsigned char *ExtraAlphabet)
Definition: coding.c:498
void DumpMessageText(GSM_Debug_Info *d, const unsigned char *message, const size_t messagesize)
Definition: debug.c:371
GSM_UDHHeader UDH
GSM_Coding_Type Coding
unsigned char Text[GSM_MAX_UDH_LENGTH]
unsigned char firstbyte
void DecodeUnicodeSpecialNOKIAChars(unsigned char *dest, const unsigned char *src, size_t len)
Definition: coding.c:1401
int GSM_UnpackEightBitsToSeven(size_t offset, size_t in_length, size_t out_length, const unsigned char *input, unsigned char *output)
Definition: coding.c:953
void GSM_DecodeUDHHeader(GSM_Debug_Info *di, GSM_UDHHeader *UDH)
Definition: gsmsms.c:121
int smfprintf(GSM_Debug_Info *d, const char *format,...)
Definition: debug.c:240
#define TRUE
Definition: gammu-types.h:28

§ GSM_DecodeUDHHeader()

void GSM_DecodeUDHHeader ( GSM_Debug_Info di,
GSM_UDHHeader UDH 
)

Decodes UDH header.

Definition at line 121 of file gsmsms.c.

References GSM_UDHHeader::AllParts, DumpMessageText(), FALSE, GSM_UDHHeader::ID16bit, GSM_UDHHeader::ID8bit, GSM_UDHHeader::Length, GSM_UDHHeader::PartNumber, smfprintf(), GSM_UDHHeader::Text, TRUE, GSM_UDHHeader::Type, UDH_ConcatenatedMessages, UDH_ConcatenatedMessages16bit, UDH_DisableEmail, UDH_DisableFax, UDH_DisableVoice, UDH_EnableEmail, UDH_EnableFax, UDH_EnableVoice, UDH_MMSIndicatorLong, UDH_NokiaCalendarLong, UDH_NokiaCallerLogo, UDH_NokiaOperatorLogo, UDH_NokiaOperatorLogoLong, UDH_NokiaPhonebookLong, UDH_NokiaProfileLong, UDH_NokiaRingtone, UDH_NokiaRingtoneLong, UDH_NokiaWAP, UDH_NokiaWAPLong, UDH_NoUDH, UDH_UserUDH, and UDH_VoidSMS.

Referenced by GSM_DecodePDUFrame(), and GSM_DecodeSMSFrameText().

122 {
123  int i, tmp, w;
124  gboolean UDHOK;
125 
126  UDH->Type = UDH_UserUDH;
127  UDH->ID8bit = -1;
128  UDH->ID16bit = -1;
129  UDH->PartNumber = -1;
130  UDH->AllParts = -1;
131 
132  i=-1;
133  while (UDHHeaders[++i].Type != UDH_NoUDH) {
134 
135  tmp=UDHHeaders[i].Length;
136  /* if length is the same */
137  if (tmp==UDH->Text[0]) {
138 
139  if (tmp == 0x05) {
140  /* three last bytes can be different for such UDH */
141  tmp = tmp - 3;
142  }
143  if (tmp == 0x0b) {
144  /* three last bytes can be different for such UDH */
145  tmp = tmp - 3;
146  }
147  if (tmp == 0x06 && UDH->Text[1] == 0x08) {
148  tmp=tmp-4;
149  }
150 
151  UDHOK = TRUE;
152  for (w = 0; w < tmp; w++) {
153  if (UDHHeaders[i].Text[w] != UDH->Text[w + 1]) {
154  UDHOK = FALSE;
155  break;
156  }
157  }
158  if (UDHOK) {
159  UDH->Type=UDHHeaders[i].Type;
160 
161  if (UDHHeaders[i].ID8bit !=-1) {
162  UDH->ID8bit = UDH->Text[UDHHeaders[i].ID8bit+1];
163  }
164  if (UDHHeaders[i].ID16bit !=-1) {
165  UDH->ID16bit = UDH->Text[UDHHeaders[i].ID16bit+1]*256+UDH->Text[UDHHeaders[i].ID16bit+2];
166  }
167  if (UDHHeaders[i].PartNumber !=-1) {
168  UDH->PartNumber = UDH->Text[UDHHeaders[i].PartNumber+1];
169  }
170  if (UDHHeaders[i].AllParts !=-1) {
171  UDH->AllParts = UDH->Text[UDHHeaders[i].AllParts+1];
172  }
173  break;
174  }
175  }
176  }
177 
178 #ifdef DEBUG
179  smfprintf(di, "Type of UDH: ");
180  switch (UDH->Type) {
182  smfprintf(di, "Concatenated (linked) message");
183  break;
185  smfprintf(di, "Concatenated (linked) message");
186  break;
187  case UDH_DisableVoice:
188  smfprintf(di, "Disables voice indicator");
189  break;
190  case UDH_EnableVoice:
191  smfprintf(di, "Enables voice indicator");
192  break;
193  case UDH_DisableFax:
194  smfprintf(di, "Disables fax indicator");
195  break;
196  case UDH_EnableFax:
197  smfprintf(di, "Enables fax indicator");
198  break;
199  case UDH_DisableEmail:
200  smfprintf(di, "Disables email indicator");
201  break;
202  case UDH_EnableEmail:
203  smfprintf(di, "Enables email indicator");
204  break;
205  case UDH_VoidSMS:
206  smfprintf(di, "Void SMS");
207  break;
208  case UDH_NokiaWAP:
209  smfprintf(di, "Nokia WAP Bookmark");
210  break;
212  smfprintf(di, "Nokia operator logo");
213  break;
214  case UDH_NokiaWAPLong:
215  smfprintf(di, "Nokia WAP Bookmark or WAP/MMS Settings");
216  break;
217  case UDH_NokiaRingtone:
218  smfprintf(di, "Nokia ringtone");
219  break;
221  smfprintf(di, "Nokia ringtone");
222  break;
224  smfprintf(di, "Nokia GSM operator logo");
225  break;
226  case UDH_NokiaCallerLogo:
227  smfprintf(di, "Nokia caller logo");
228  break;
230  smfprintf(di, "Nokia profile");
231  break;
233  smfprintf(di, "Nokia calendar note");
234  break;
236  smfprintf(di, "Nokia phonebook entry");
237  break;
238  case UDH_UserUDH:
239  smfprintf(di, "User UDH");
240  break;
242  smfprintf(di, "MMS indicator");
243  break;
244  case UDH_NoUDH:
245  break;
246  }
247  if (UDH->ID8bit != -1) {
248  smfprintf(di, ", ID 8 bit %i", UDH->ID8bit);
249  }
250  if (UDH->ID16bit != -1) {
251  smfprintf(di, ", ID 16 bit %i", UDH->ID16bit);
252  }
253  if (UDH->PartNumber != -1 && UDH->AllParts != -1) {
254  smfprintf(di, ", part %i of %i",UDH->PartNumber,UDH->AllParts);
255  }
256  smfprintf(di, "\n");
257  DumpMessageText(di, UDH->Text, UDH->Length);
258 #endif
259 }
void DumpMessageText(GSM_Debug_Info *d, const unsigned char *message, const size_t messagesize)
Definition: debug.c:371
static GSM_UDHHeader UDHHeaders[]
Definition: gsmsms.c:29
unsigned char Text[GSM_MAX_UDH_LENGTH]
int gboolean
Definition: gammu-types.h:23
#define FALSE
Definition: gammu-types.h:25
int smfprintf(GSM_Debug_Info *d, const char *format,...)
Definition: debug.c:240
#define TRUE
Definition: gammu-types.h:28

§ GSM_DeleteSMS()

GSM_Error GSM_DeleteSMS ( GSM_StateMachine s,
GSM_SMSMessage sms 
)

Deletes SMS.

Parameters
sState machine pointer.
[in]smsSMS structure with SMS location and folder.
Returns
Error code.

Deletes SMS.

Definition at line 726 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone_Functions::DeleteSMS, GSM_Phone::Functions, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, and PRINT_SMS_INFO.

727 {
728  GSM_Error err;
729 
731  PRINT_SMS_INFO();
732 
733  err = s->Phone.Functions->DeleteSMS(s, sms);
734  PRINT_LOG_ERROR(err);
735  return err;
736 }
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Error(* DeleteSMS)(GSM_StateMachine *s, GSM_SMSMessage *sms)
Definition: gsmstate.h:959
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
#define PRINT_SMS_INFO()
Definition: api.c:20

§ GSM_DeleteSMSFolder()

GSM_Error GSM_DeleteSMSFolder ( GSM_StateMachine s,
int  ID 
)

Deletes SMS folder.

Parameters
sState machine pointer.
[in]IDID of SMS folder to delete.
Returns
Error code.

Deletes SMS folder.

Definition at line 832 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone_Functions::DeleteSMSFolder, GSM_Phone::Functions, _GSM_StateMachine::Phone, and PRINT_LOG_ERROR.

833 {
834  GSM_Error err;
835 
837 
838  err = s->Phone.Functions->DeleteSMSFolder(s, ID);
839  PRINT_LOG_ERROR(err);
840  return err;
841 }
GSM_Error(* DeleteSMSFolder)(GSM_StateMachine *s, int ID)
Definition: gsmstate.h:991
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_EncodeMultiPartSMS()

GSM_Error GSM_EncodeMultiPartSMS ( GSM_Debug_Info di,
GSM_MultiPartSMSInfo Info,
GSM_MultiSMSMessage SMS 
)

Encodes multi part SMS from "readable" format.

Returns
Error code.

Definition at line 500 of file gsmmulti.c.

References GSM_MMSIndicator::Address, ALCATELTDD_ANIMATION, ALCATELTDD_PICTURE, ALCATELTDD_SMSTEMPLATE, GSM_MultiBitmap::Bitmap, GSM_MultiPartSMSEntry::Bitmap, GSM_Bitmap::BitmapHeight, GSM_Bitmap::BitmapWidth, GSM_MultiPartSMSEntry::Bold, GSM_MultiPartSMSEntry::Bookmark, GSM_MultiPartSMSEntry::Buffer, GSM_MultiPartSMSEntry::Calendar, GSM_MultiPartSMSEntry::Center, GSM_MultiPartSMSInfo::Class, DecodeDefault(), _GSM_Debug_Info::dl, DL_TEXTALL, DL_TEXTALLDATE, DumpMessage(), EncodeDefault(), EncodeUnicode(), GSM_MultiPartSMSInfo::Entries, GSM_MultiPartSMSInfo::EntriesNum, ERR_EMPTY, ERR_MOREMEMORY, ERR_NONE, ERR_UNKNOWN, FALSE, FindDefaultAlphabetLen(), GSM_AlcatelBMMIPicture, GSM_EncodeAlcatelMultiPartSMS(), GSM_EncodeEMSMultiPartSMS(), GSM_EncodeMMSIndicatorSMSText(), GSM_EncodeNokiaRTTLRingtone(), GSM_EncodeSMS30MultiPartSMS(), GSM_EncodeUDHHeader(), GSM_EncodeVCALENDAR(), GSM_EncodeVCARD(), GSM_EncodeVTODO(), GSM_EncodeWAPIndicatorSMSText(), GSM_MakeMultiPartSMS(), GSM_MAX_8BIT_SMS_LENGTH, GSM_MAX_MULTI_SMS, GSM_MAX_SMS_CHARS_LENGTH, GSM_MAX_SMS_LENGTH, GSM_Nokia7110OperatorLogo, GSM_NokiaCallerLogo, GSM_NokiaOperatorLogo, GSM_PackSevenBitsToEight(), GSM_MultiPartSMSEntry::ID, GSM_MultiPartSMSEntry::Italic, GSM_MultiPartSMSEntry::Large, GSM_MultiPartSMSEntry::Left, GSM_UDHHeader::Length, GSM_MultiPartSMSEntry::MMSIndicator, GSM_Bitmap::NetworkCode, NOKIA_CopyBitmap(), NOKIA_EncodeNetworkCode(), NOKIA_EncodeWAPBookmarkSMSText(), NOKIA_EncodeWAPMMSSettingsSMSText(), Nokia_VCalendar, Nokia_VCard10, Nokia_VCard21, Nokia_VToDo, GSM_Ringtone::NoteTone, GSM_NoteRingtone::NrCommands, GSM_MultiBitmap::Number, GSM_MultiSMSMessage::Number, GSM_MultiPartSMSEntry::Number, PHONE_EncodeBitmap(), PHONE_GetBitmapSize(), GSM_MultiPartSMSEntry::Phonebook, GSM_MultiPartSMSInfo::ReplaceMessage, GSM_MultiPartSMSEntry::Right, GSM_MultiPartSMSEntry::Ringtone, GSM_MultiPartSMSEntry::RingtoneNotes, GSM_MultiPartSMSEntry::Settings, GSM_MultiPartSMSEntry::Small, smfprintf(), SMS_AlcatelMonoAnimationLong, SMS_AlcatelMonoBitmapLong, SMS_AlcatelSMSTemplateName, SMS_Coding_8bit, SMS_Coding_Default_No_Compression, SMS_Coding_Unicode_No_Compression, SMS_ConcatenatedAutoTextLong, SMS_ConcatenatedAutoTextLong16bit, SMS_ConcatenatedTextLong, SMS_ConcatenatedTextLong16bit, SMS_DisableEmail, SMS_DisableFax, SMS_DisableVoice, SMS_EMSAnimation, SMS_EMSFixedBitmap, SMS_EMSPredefinedAnimation, SMS_EMSPredefinedSound, SMS_EMSSonyEricssonSound, SMS_EMSSonyEricssonSoundLong, SMS_EMSSound10, SMS_EMSSound10Long, SMS_EMSSound12, SMS_EMSSound12Long, SMS_EMSVariableBitmap, SMS_EMSVariableBitmapLong, SMS_EnableEmail, SMS_EnableFax, SMS_EnableVoice, SMS_MMSIndicatorLong, SMS_NokiaCallerLogo, SMS_NokiaMMSSettingsLong, SMS_NokiaOperatorLogo, SMS_NokiaOperatorLogoLong, SMS_NokiaPictureImageLong, SMS_NokiaProfileLong, SMS_NokiaRingtone, SMS_NokiaRingtoneLong, SMS_NokiaScreenSaverLong, SMS_NokiaVCALENDAR10Long, SMS_NokiaVCARD10Long, SMS_NokiaVCARD21Long, SMS_NokiaVTODOLong, SMS_NokiaWAPBookmarkLong, SMS_NokiaWAPSettingsLong, SMS_Text, SMS_VCARD10Long, SMS_VCARD21Long, SMS_VoidSMS, SMS_WAPIndicatorLong, GSM_MultiPartSMSEntry::Strikethrough, GSM_Bitmap::Text, GSM_MMSIndicator::Title, GSM_MultiPartSMSEntry::ToDo, TRUE, GSM_UDHHeader::Type, UDH_ConcatenatedMessages, UDH_ConcatenatedMessages16bit, UDH_DisableEmail, UDH_DisableFax, UDH_DisableVoice, UDH_EnableEmail, UDH_EnableFax, UDH_EnableVoice, UDH_MMSIndicatorLong, UDH_NokiaCalendarLong, UDH_NokiaCallerLogo, UDH_NokiaOperatorLogo, UDH_NokiaOperatorLogoLong, UDH_NokiaPhonebookLong, UDH_NokiaProfileLong, UDH_NokiaRingtone, UDH_NokiaRingtoneLong, UDH_NokiaWAP, UDH_NokiaWAPLong, UDH_NoUDH, UDH_VoidSMS, GSM_MultiPartSMSEntry::Underlined, GSM_MultiPartSMSInfo::UnicodeCoding, and UnicodeLength().

503 {
504  unsigned char *Buffer;
505  unsigned char *Buffer2;
506  size_t buffer_size = GSM_MAX_SMS_LENGTH * 2 * GSM_MAX_MULTI_SMS;
507  int i, Class = -1, j;
508  size_t p;
509  size_t Length = 0, smslen;
510  GSM_Error error;
512  GSM_UDH UDH = UDH_NoUDH;
513  GSM_UDHHeader UDHHeader;
514  gboolean EMS = FALSE;
515  int textnum = 0;
516 
517  if (Info->EntriesNum == 0) return ERR_EMPTY;
518 
519  Buffer = malloc(buffer_size);
520  if (Buffer == NULL) {
521  return ERR_MOREMEMORY;
522  }
523  Buffer2 = malloc(buffer_size);
524  if (Buffer2 == NULL) {
525  free(Buffer);
526  return ERR_MOREMEMORY;
527  }
528 
529  SMS->Number = 0;
530 
531  if (Info->Entries[0].ID == SMS_AlcatelSMSTemplateName) {
532  Buffer[Length++] = 0x00; /* number of elements */
533  for (i=1;i<Info->EntriesNum;i++) {
534  switch (Info->Entries[i].ID) {
535  case SMS_EMSSound10:
536  case SMS_EMSSound12:
538  case SMS_EMSSound10Long:
539  case SMS_EMSSound12Long:
542  case SMS_EMSAnimation:
544  break;
546  Buffer[0]++;
547  Buffer[Length++] = 0x01; /* type of data */
548  Buffer[Length++] = 1 % 256; /* len */
549  Buffer[Length++] = 1 / 256; /* len */
550  Buffer[Length++] = Info->Entries[i].Number;
551  break;
553  Buffer[0]++;
554  Buffer[Length++] = 0x02; /* type of data */
555  Buffer[Length++] = 1 % 256; /* len */
556  Buffer[Length++] = 1 / 256; /* len */
557  Buffer[Length++] = Info->Entries[i].Number;
558  break;
560  Buffer[0]++;
561  p = UnicodeLength(Info->Entries[i].Buffer);
562  EncodeDefault(Buffer2, Info->Entries[i].Buffer, &p, TRUE, NULL);
563  Buffer[Length++] = 0x00; /* type of data */
564  Length = Length + 2;
565  smslen = GSM_PackSevenBitsToEight(0, Buffer2, Buffer+Length, p);
566  Buffer[Length-2] = smslen % 256; /* len */
567  Buffer[Length-1] = smslen / 256; /* len */
568  Length = Length + smslen;
569  break;
570  default:
571  error = ERR_UNKNOWN;
572  goto out;
573  }
574  }
575  Buffer[0] = Buffer[0] * 2;
576  error = GSM_EncodeAlcatelMultiPartSMS(di, SMS,Buffer,Length,Info->Entries[0].Buffer,ALCATELTDD_SMSTEMPLATE);
577  goto out;
578  }
579 
580  for (i=0;i<Info->EntriesNum;i++) {
581  switch (Info->Entries[i].ID) {
584  case SMS_EMSSound10:
585  case SMS_EMSSound12:
587  case SMS_EMSSound10Long:
588  case SMS_EMSSound12Long:
590  case SMS_EMSFixedBitmap:
592  case SMS_EMSAnimation:
594  EMS = TRUE;
595  break;
598 
599  /* This covers situation, when somebody will call function
600  * with two or more SMS_Concatenated.... entries only.
601  * It will be still only linked sms, but functions below
602  * will pack only first entry according to own limits.
603  * We redirect to EMS functions, because they are more generic
604  * here and will handle it correctly and produce linked sms
605  * from all entries
606  */
607  textnum ++;
608  if (textnum > 1) EMS = TRUE;
609 
610  if (Info->Entries[i].Left || Info->Entries[i].Right ||
611  Info->Entries[i].Center || Info->Entries[i].Large ||
612  Info->Entries[i].Small || Info->Entries[i].Bold ||
613  Info->Entries[i].Italic || Info->Entries[i].Underlined ||
614  Info->Entries[i].Strikethrough) {
615  EMS = TRUE;
616  }
617  default:
618  break;
619  }
620  if (EMS) break;
621  }
622  if (EMS) {
623  error=GSM_EncodeEMSMultiPartSMS(di, Info,SMS,UDH_NoUDH);
624  if (error != ERR_NONE) {
625  goto out;
626  }
627  if (SMS->Number != 1) {
628  SMS->Number = 0;
629  for (i=0;i<Info->EntriesNum;i++) {
630  if (Info->Entries[i].ID == SMS_ConcatenatedTextLong16bit) {
632  goto out;
633  }
634  }
636  }
637  goto out;
638  }
639 
640  if (Info->EntriesNum != 1) {
641  error = ERR_UNKNOWN;
642  goto out;
643  }
644 
645  switch (Info->Entries[0].ID) {
647  Buffer[0] = Info->Entries[0].Bitmap->Bitmap[0].BitmapWidth;
648  Buffer[1] = Info->Entries[0].Bitmap->Bitmap[0].BitmapHeight;
651  error = GSM_EncodeAlcatelMultiPartSMS(di, SMS,Buffer,Length,Info->Entries[0].Bitmap->Bitmap[0].Text,ALCATELTDD_PICTURE);
652  goto out;
654  /* Number of sequence words */
655  Buffer[0] = (Info->Entries[0].Bitmap->Number+1) % 256;
656  Buffer[1] = (Info->Entries[0].Bitmap->Number+1) / 256;
657  /* Picture display time 1 second (1 = 100ms) */
658  Buffer[2] = 10 % 256;
659  Buffer[3] = 10 / 256 + 0xF0;
660 
661  Length = 4;
662  j = 0;
663 
664  /* Offsets to bitmaps */
665  for (i=0;i<Info->Entries[0].Bitmap->Number;i++) {
666  Buffer[Length++] = (4+j+Info->Entries[0].Bitmap->Number*2) % 256;
667  Buffer[Length++] = (4+j+Info->Entries[0].Bitmap->Number*2) / 256;
669  }
670 
671  /* Bitmaps */
672  for (i=0;i<Info->Entries[0].Bitmap->Number;i++) {
673  Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth;
674  Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight;
675  PHONE_EncodeBitmap(GSM_AlcatelBMMIPicture, Buffer+Length, &Info->Entries[0].Bitmap->Bitmap[i]);
677  }
678  error = GSM_EncodeAlcatelMultiPartSMS(di, SMS,Buffer,Length,Info->Entries[0].Bitmap->Bitmap[0].Text,ALCATELTDD_ANIMATION);
679  goto out;
681  Class = 1;
682  UDH = UDH_MMSIndicatorLong;
683  GSM_EncodeMMSIndicatorSMSText(Buffer,&Length,Info->Entries[0].MMSIndicator);
684  break;
686  Class = 1;
687  UDH = UDH_MMSIndicatorLong;
689  break;
691  case SMS_NokiaRingtone:
692  UDH = UDH_NokiaRingtone;
693  Class = 1;
694  /* 7 = length of UDH_NokiaRingtone UDH header */
695  Length = GSM_MAX_8BIT_SMS_LENGTH-7;
696  Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(Info->Entries[0].Ringtone,Buffer,&Length);
697  if (Info->Entries[0].ID == SMS_NokiaRingtone) break;
698  if (Info->Entries[0].RingtoneNotes != Info->Entries[0].Ringtone->NoteTone.NrCommands) {
699  UDH = UDH_NokiaRingtoneLong;
700  Length = (GSM_MAX_8BIT_SMS_LENGTH-12)*3;
701  Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(Info->Entries[0].Ringtone,Buffer,&Length);
702  }
703  break;
705  if (Info->Entries[0].Bitmap->Bitmap[0].BitmapWidth > 72 || Info->Entries[0].Bitmap->Bitmap[0].BitmapHeight > 14) {
707  Class = 1;
709  Length = Length + 3;
710  NOKIA_CopyBitmap(GSM_Nokia7110OperatorLogo, &Info->Entries[0].Bitmap->Bitmap[0], Buffer, &Length);
711  break;
712  }
714  UDH = UDH_NokiaOperatorLogo;
715  Class = 1;
717  Length = Length + 3;
718  NOKIA_CopyBitmap(GSM_NokiaOperatorLogo, &Info->Entries[0].Bitmap->Bitmap[0], Buffer, &Length);
719  break;
720  case SMS_NokiaCallerLogo:
721  UDH = UDH_NokiaCallerLogo;
722  Class = 1;
723  NOKIA_CopyBitmap(GSM_NokiaCallerLogo, &Info->Entries[0].Bitmap->Bitmap[0], Buffer, &Length);
724  break;
728  Class = 1;
729  UDH = UDH_NokiaProfileLong;
730  GSM_EncodeSMS30MultiPartSMS(Info,Buffer,&Length);
731  break;
733  Class = 1;
734  NOKIA_EncodeWAPBookmarkSMSText(Buffer,&Length,Info->Entries[0].Bookmark);
735  /* 7 = length of UDH_NokiaWAP UDH header */
736  if (Length>(GSM_MAX_8BIT_SMS_LENGTH-7)) {
737  UDH=UDH_NokiaWAPLong;
738  } else {
739  UDH=UDH_NokiaWAP;
740  }
741  break;
743  Class = 1;
744  UDH = UDH_NokiaWAPLong;
745  NOKIA_EncodeWAPMMSSettingsSMSText(Buffer,&Length,Info->Entries[0].Settings,FALSE);
746  break;
748  Class = 1;
749  UDH = UDH_NokiaWAPLong;
750  NOKIA_EncodeWAPMMSSettingsSMSText(Buffer,&Length,Info->Entries[0].Settings,TRUE);
751  break;
755  error = GSM_EncodeVCARD(di, Buffer, buffer_size, &Length, Info->Entries[0].Phonebook, TRUE, Nokia_VCard10);
756  if (error != ERR_NONE) {
757  goto out;
758  }
759  memcpy(Buffer2,Buffer,Length);
760  EncodeUnicode(Buffer,Buffer2,Length);
761  break;
763  error = GSM_EncodeVCARD(di, Buffer, buffer_size, &Length, Info->Entries[0].Phonebook, TRUE, Nokia_VCard21);
764  if (error != ERR_NONE) {
765  goto out;
766  }
769  memcpy(Buffer2,Buffer,Length);
770  EncodeUnicode(Buffer,Buffer2,Length);
771  break;
772  case SMS_VCARD10Long:
773  error = GSM_EncodeVCARD(di, Buffer, buffer_size, &Length,Info->Entries[0].Phonebook,TRUE,Nokia_VCard10);
774  if (error != ERR_NONE) {
775  goto out;
776  }
779  memcpy(Buffer2,Buffer,Length);
780  EncodeUnicode(Buffer,Buffer2,Length);
781  break;
782  case SMS_VCARD21Long:
783  error = GSM_EncodeVCARD(di, Buffer, buffer_size, &Length,Info->Entries[0].Phonebook,TRUE,Nokia_VCard21);
784  if (error != ERR_NONE) {
785  goto out;
786  }
789  memcpy(Buffer2,Buffer,Length);
790  EncodeUnicode(Buffer,Buffer2,Length);
791  break;
793  error=GSM_EncodeVCALENDAR(Buffer, buffer_size,&Length,Info->Entries[0].Calendar,TRUE,Nokia_VCalendar);
794  if (error != ERR_NONE) {
795  goto out;
796  }
798  /* Is 1 SMS ? 8 = length of ..SCKE4 */
799  if (Length <= GSM_MAX_SMS_CHARS_LENGTH - 8) {
800  sprintf(Buffer,"//SCKE4 ");
801  Length = 8;
802  } else {
803  UDH = UDH_NokiaCalendarLong;
804  }
805  memcpy(Buffer2,Buffer,Length);
806  EncodeUnicode(Buffer,Buffer2,Length);
807  break;
808  case SMS_NokiaVTODOLong:
809  error=GSM_EncodeVTODO(Buffer, buffer_size,&Length,Info->Entries[0].ToDo,TRUE,Nokia_VToDo);
810  if (error != ERR_NONE) {
811  goto out;
812  }
813  UDH = UDH_NokiaCalendarLong;
815  memcpy(Buffer2,Buffer,Length);
816  EncodeUnicode(Buffer,Buffer2,Length);
817  break;
818  case SMS_DisableVoice:
819  case SMS_DisableFax:
820  case SMS_DisableEmail:
821  case SMS_EnableVoice:
822  case SMS_EnableFax:
823  case SMS_EnableEmail:
824  case SMS_VoidSMS:
825  case SMS_Text:
826  Class = Info->Class;
827  switch (Info->Entries[0].ID) {
828  case SMS_DisableVoice : UDH = UDH_DisableVoice; break;
829  case SMS_DisableFax : UDH = UDH_DisableFax; break;
830  case SMS_DisableEmail : UDH = UDH_DisableEmail; break;
831  case SMS_EnableVoice : UDH = UDH_EnableVoice; break;
832  case SMS_EnableFax : UDH = UDH_EnableFax; break;
833  case SMS_EnableEmail : UDH = UDH_EnableEmail; break;
834  case SMS_VoidSMS : UDH = UDH_VoidSMS; break;
835  case SMS_Text : UDH = UDH_NoUDH; break;
836  default : break;
837  }
838  UDHHeader.Type = UDH;
839  GSM_EncodeUDHHeader(di, &UDHHeader);
840  memcpy(Buffer,Info->Entries[0].Buffer,UnicodeLength(Info->Entries[0].Buffer)*2+2);
841  if (Info->UnicodeCoding) {
843  Length = UnicodeLength(Info->Entries[0].Buffer);
844  if (Length > (size_t)(140 - UDHHeader.Length) / 2) {
845  Length = (140 - UDHHeader.Length) / 2;
846  }
847  } else {
849  FindDefaultAlphabetLen(Info->Entries[0].Buffer,&Length,&smslen,(GSM_MAX_8BIT_SMS_LENGTH-UDHHeader.Length)*8/7);
850  }
851  break;
854  smslen = UnicodeLength(Info->Entries[0].Buffer);
855  memcpy(Buffer,Info->Entries[0].Buffer,smslen*2);
856  EncodeDefault(Buffer2, Buffer, &smslen, TRUE, NULL);
857  DecodeDefault(Buffer, Buffer2, smslen, TRUE, NULL);
858 #ifdef DEBUG
859  if (di->dl == DL_TEXTALL || di->dl == DL_TEXTALLDATE) {
860  smfprintf(di, "Info->Entries[0].Buffer:\n");
861  DumpMessage(di, Info->Entries[0].Buffer, UnicodeLength(Info->Entries[0].Buffer)*2);
862  smfprintf(di, "Buffer:\n");
863  DumpMessage(di, Buffer, UnicodeLength(Buffer)*2);
864  }
865 #endif
866  Info->UnicodeCoding = FALSE;
867  for (smslen = 0; smslen < UnicodeLength(Info->Entries[0].Buffer) * 2; smslen++) {
868  if (Info->Entries[0].Buffer[smslen] != Buffer[smslen]) {
869  Info->UnicodeCoding = TRUE;
870  smfprintf(di, "Setting to Unicode %ld\n", (long)smslen);
871  break;
872  }
873  }
874  /* No break here - we go to the SMS_ConcatenatedTextLong */
877  Class = Info->Class;
878  if (Info->Entries[0].Buffer == NULL) {
879  Buffer[0] = 0;
880  Buffer[1] = 0;
881  } else {
882  memcpy(Buffer,Info->Entries[0].Buffer,UnicodeLength(Info->Entries[0].Buffer)*2+2);
883  }
884  UDH = UDH_NoUDH;
885  if (Info->UnicodeCoding) {
887  Length = UnicodeLength(Buffer);
888  if (Info->Entries[0].ID == SMS_ConcatenatedTextLong16bit ||
890  if (Length>70) UDH=UDH_ConcatenatedMessages16bit;
891  } else {
892  if (Length>70) UDH=UDH_ConcatenatedMessages;
893  }
894  } else {
896  FindDefaultAlphabetLen(Buffer,&Length,&smslen,5000);
897  if (Info->Entries[0].ID == SMS_ConcatenatedTextLong16bit ||
900  } else {
902  }
903  }
904  default:
905  break;
906  }
907  GSM_MakeMultiPartSMS(di, SMS,Buffer,Length,UDH,Coding,Class,Info->ReplaceMessage);
908  error = ERR_NONE;
909 out:
910  free(Buffer);
911  free(Buffer2);
912  return error;
913 }
GSM_Error GSM_EncodeEMSMultiPartSMS(GSM_Debug_Info *di, GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS, GSM_UDH UDHType)
Definition: gsmems.c:20
GSM_Error GSM_EncodeVCALENDAR(char *Buffer, const size_t buff_len, size_t *Length, GSM_CalendarEntry *note, const gboolean header, const GSM_VCalendarVersion Version)
Definition: gsmcal.c:814
GSM_MemoryEntry * Phonebook
GSM_Error GSM_EncodeVCARD(GSM_Debug_Info *di, char *Buffer, const size_t buff_len, size_t *Length, GSM_MemoryEntry *pbk, const gboolean header, const GSM_VCardVersion Version)
Definition: gsmpbk.c:126
void DumpMessage(GSM_Debug_Info *d, const unsigned char *message, const size_t messagesize)
Definition: debug.c:314
size_t PHONE_GetBitmapSize(GSM_Phone_Bitmap_Types Type, size_t Width, size_t Height)
Definition: gsmlogo.c:44
GSM_MultiBitmap * Bitmap
GSM_WAPSettings * Settings
void DecodeDefault(unsigned char *dest, const unsigned char *src, size_t len, gboolean UseExtensions, unsigned char *ExtraAlphabet)
Definition: coding.c:498
void FindDefaultAlphabetLen(const unsigned char *src, size_t *srclen, size_t *smslen, size_t maxlen)
Definition: coding.c:914
unsigned char ReplaceMessage
char Address[500]
Definition: gammu-message.h:90
void GSM_EncodeMMSIndicatorSMSText(unsigned char *Buffer, size_t *Length, GSM_MMSIndicator *Indicator)
Definition: gsmdata.c:307
#define GSM_MAX_SMS_CHARS_LENGTH
Definition: gammu-limits.h:183
GSM_MMSIndicator * MMSIndicator
int GSM_PackSevenBitsToEight(size_t offset, const unsigned char *input, unsigned char *output, size_t length)
Definition: coding.c:993
GSM_Error
Definition: gammu-error.h:23
void PHONE_EncodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap)
Definition: gsmlogo.c:197
void NOKIA_EncodeWAPMMSSettingsSMSText(unsigned char *Buffer, size_t *Length, GSM_WAPSettings *settings, gboolean MMS)
Definition: gsmdata.c:41
size_t UnicodeLength(const unsigned char *str)
Definition: coding.c:186
GSM_ToDoEntry * ToDo
void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, size_t *Length, GSM_WAPBookmark *bookmark)
Definition: gsmdata.c:190
GSM_Ringtone * Ringtone
GSM_MultiPartSMSEntry Entries[GSM_MAX_MULTI_SMS]
#define ALCATELTDD_ANIMATION
Definition: gsmmulti.h:26
unsigned char GSM_EncodeNokiaRTTLRingtone(GSM_Ringtone *ringtone, unsigned char *package, size_t *maxlength)
Definition: gsmring.c:992
#define GSM_MAX_SMS_LENGTH
Definition: gammu-limits.h:176
#define GSM_MAX_8BIT_SMS_LENGTH
Definition: gammu-limits.h:190
GSM_NoteRingtone NoteTone
void NOKIA_CopyBitmap(GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, size_t *Length)
Definition: gsmlogo.c:1132
char NetworkCode[10]
Definition: gammu-bitmap.h:160
int gboolean
Definition: gammu-types.h:23
void GSM_MakeMultiPartSMS(GSM_Debug_Info *di, GSM_MultiSMSMessage *SMS, unsigned char *MessageBuffer, size_t MessageLength, GSM_UDH UDHType, GSM_Coding_Type Coding, int Class, unsigned char ReplaceMessage)
Definition: gsmmulti.c:305
void EncodeUnicode(unsigned char *dest, const char *src, size_t len)
Definition: coding.c:301
#define FALSE
Definition: gammu-types.h:25
GSM_Error GSM_EncodeVTODO(char *Buffer, const size_t buff_len, size_t *Length, const GSM_ToDoEntry *note, const gboolean header, const GSM_VToDoVersion Version)
Definition: gsmcal.c:1038
GSM_WAPBookmark * Bookmark
EncodeMultiPartSMSID ID
GSM_Bitmap Bitmap[GSM_MAX_MULTI_BITMAP]
Definition: gammu-bitmap.h:192
void GSM_EncodeWAPIndicatorSMSText(unsigned char *Buffer, size_t *Length, char *Text, char *URL)
Definition: gsmdata.c:233
#define GSM_MAX_MULTI_SMS
Definition: gammu-limits.h:162
void NOKIA_EncodeNetworkCode(unsigned char *buffer, const char *input)
Definition: gsmnet.c:2467
GSM_UDH
GSM_Coding_Type
unsigned char * Buffer
unsigned char Number
Definition: gammu-bitmap.h:188
size_t BitmapHeight
Definition: gammu-bitmap.h:152
int smfprintf(GSM_Debug_Info *d, const char *format,...)
Definition: debug.c:240
#define ALCATELTDD_SMSTEMPLATE
Definition: gsmmulti.h:27
void GSM_EncodeUDHHeader(GSM_Debug_Info *di, GSM_UDHHeader *UDH)
Definition: gsmsms.c:1151
size_t BitmapWidth
Definition: gammu-bitmap.h:156
unsigned char Text[2 *(GSM_BITMAP_TEXT_LENGTH+1)]
Definition: gammu-bitmap.h:118
GSM_CalendarEntry * Calendar
#define TRUE
Definition: gammu-types.h:28
#define ALCATELTDD_PICTURE
Definition: gsmmulti.h:25
void EncodeDefault(unsigned char *dest, const unsigned char *src, size_t *len, gboolean UseExtensions, unsigned char *ExtraAlphabet)
Definition: coding.c:831
Debug_Level dl
Definition: debug.h:35
GSM_Error GSM_EncodeAlcatelMultiPartSMS(GSM_Debug_Info *di, GSM_MultiSMSMessage *SMS, unsigned char *Data, size_t Len, unsigned char *Name, size_t Type)
Definition: gsmmulti.c:438
static void GSM_EncodeSMS30MultiPartSMS(GSM_MultiPartSMSInfo *Info, char *Buffer, size_t *Length)
Definition: gsmmulti.c:375

§ GSM_EncodeSMSFrame()

GSM_Error GSM_EncodeSMSFrame ( GSM_Debug_Info di,
GSM_SMSMessage SMS,
unsigned char *  buffer,
GSM_SMSMessageLayout  Layout,
int *  length,
gboolean  clear 
)

Encodes SMS frame.

Definition at line 1008 of file gsmsms.c.

References GSM_SMSMessage::Class, GSM_SMSMessage::DateTime, GSM_SMSMessageLayout::DateTime, DecodeUnicodeString(), ERR_NONE, FALSE, GSM_SMSMessageLayout::firstbyte, GSM_EncodeSMSDateTime(), GSM_EncodeSMSFrameText(), GSM_PackSemiOctetNumber(), GSM_SMSMessage::MessageReference, GSM_SMSC::Number, GSM_SMSMessage::Number, GSM_SMSMessageLayout::Number, GSM_SMSMessage::PDU, GSM_SMSMessage::RejectDuplicates, GSM_SMSValidity::Relative, GSM_SMSMessage::ReplaceMessage, GSM_SMSMessage::ReplyViaSameSMSC, smfprintf(), SMS_Deliver, SMS_Status_Report, SMS_Submit, GSM_SMSMessage::SMSC, GSM_SMSMessageLayout::SMSCNumber, GSM_SMSMessageLayout::Text, GSM_SMSMessageLayout::TPDCS, GSM_SMSMessageLayout::TPMR, GSM_SMSMessageLayout::TPPID, GSM_SMSMessageLayout::TPVP, TRUE, and GSM_SMSC::Validity.

Referenced by PHONE_EncodeSMSFrame().

1009 {
1010  int i;
1011 
1012  if (clear) {
1013  /* Cleaning up to the SMS text */
1014  for (i=0;i<Layout.Text;i++) buffer[i] = 0;
1015  }
1016 
1017  /* GSM 03.40 section 9.2.3.1 (TP-Message-Type-Indicator) */
1018  switch (SMS->PDU) {
1019  case SMS_Submit:
1020  buffer[Layout.firstbyte] |= 0x01;
1021  break;
1022  /* SMS_Status_Report when Submit sms should have delivery report */
1023  /* We DON'T CREATE FRAME FOR REAL SMS_STATUS_REPORT */
1024  case SMS_Status_Report:
1025  buffer[Layout.firstbyte] |= 0x01;
1026  /* GSM 03.40 section 9.2.3.5 (TP-Status-Raport-Request) */
1027  /* Set when want delivery report from SMSC */
1028  buffer[Layout.firstbyte] |= 0x20;
1029  break;
1030  case SMS_Deliver:
1031  buffer[Layout.firstbyte] |= 0x00;
1032  }
1033 
1034  /* GSM 03.40 section 9.2.3.17 (TP-Reply-Path) */
1035  if (SMS->ReplyViaSameSMSC) buffer[Layout.firstbyte] |= 0x80;
1036 
1037  if (Layout.Number!=255) {
1038  buffer[Layout.Number] = GSM_PackSemiOctetNumber(SMS->Number,buffer+(Layout.Number+1),TRUE);
1039  smfprintf(di, "Recipient number \"%s\"\n",DecodeUnicodeString(SMS->Number));
1040  }
1041  if (Layout.SMSCNumber!=255) {
1042  buffer[Layout.SMSCNumber]=GSM_PackSemiOctetNumber(SMS->SMSC.Number,buffer+(Layout.SMSCNumber+1), FALSE);
1043  smfprintf(di, "SMSC number \"%s\"\n",DecodeUnicodeString(SMS->SMSC.Number));
1044  }
1045 
1046  /* Message Class*/
1047  /* GSM 03.40 section 9.2.3.10 (TP-Data-Coding-Scheme) and GSM 03.38 section 4 */
1048  if (Layout.TPDCS != 255) {
1049  if (SMS->Class >= 0 && SMS->Class <= 3) buffer[Layout.TPDCS] |= SMS->Class | (1 << 4);
1050  smfprintf(di, "SMS class %i\n",SMS->Class);
1051  }
1052 
1053  if (Layout.TPVP != 255) {
1054  /* GSM 03.40 section 9.2.3.3 (TP-Validity-Period-Format) */
1055  /* Bits 4 and 3: 10. TP-VP field present and integer represent (relative) */
1056  buffer[Layout.firstbyte] |= 0x10;
1057  buffer[Layout.TPVP]=((unsigned char)SMS->SMSC.Validity.Relative);
1058  smfprintf(di, "SMS validity %02x\n",SMS->SMSC.Validity.Relative);
1059  }
1060 
1061  if (Layout.DateTime != 255) {
1062  GSM_EncodeSMSDateTime(di, &SMS->DateTime, buffer+Layout.DateTime);
1063  }
1064 
1065  if (Layout.TPMR != 255) {
1066  smfprintf(di, "TPMR: %02x %i\n",SMS->MessageReference,SMS->MessageReference);
1067  buffer[Layout.TPMR] = SMS->MessageReference;
1068  }
1069 
1070  if (SMS->RejectDuplicates) {
1071  /* GSM 03.40 section 9.2.3.25 (TP Reject Duplicates) */
1072  buffer[Layout.firstbyte] |= 0x04;
1073  }
1074 
1075  if (Layout.TPPID != 255) {
1076  buffer[Layout.TPPID] = 0;
1077  if (SMS->ReplaceMessage > 0 && SMS->ReplaceMessage < 8) {
1078  buffer[Layout.TPPID] = 0x40 + SMS->ReplaceMessage;
1079  }
1080  }
1081 
1082  /* size is the length of the data in octets including UDH */
1083  *length=GSM_EncodeSMSFrameText(di, SMS,buffer,Layout);
1084 /* if (*length == 0) return GE_UNKNOWN; */
1085  *length += Layout.Text;
1086 
1087  return ERR_NONE;
1088 }
unsigned char Text
GSM_SMSMessageType PDU
GSM_DateTime DateTime
char * DecodeUnicodeString(const unsigned char *src)
Definition: coding.c:245
unsigned char Number[(GSM_MAX_NUMBER_LENGTH+1) *2]
unsigned char TPDCS
unsigned char ReplaceMessage
int GSM_PackSemiOctetNumber(const unsigned char *Number, unsigned char *Output, gboolean semioctet)
Definition: coding.c:1125
gboolean RejectDuplicates
signed char Class
static GSM_Error GSM_EncodeSMSDateTime(GSM_Debug_Info *di, GSM_DateTime *DT, unsigned char *req)
Definition: gsmsms.c:909
unsigned char SMSCNumber
#define FALSE
Definition: gammu-types.h:25
GSM_SMSValidity Validity
unsigned char TPVP
unsigned char Number[(GSM_MAX_NUMBER_LENGTH+1) *2]
unsigned char firstbyte
static int GSM_EncodeSMSFrameText(GSM_Debug_Info *di, GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout)
Definition: gsmsms.c:934
int smfprintf(GSM_Debug_Info *d, const char *format,...)
Definition: debug.c:240
#define TRUE
Definition: gammu-types.h:28
unsigned char MessageReference
gboolean ReplyViaSameSMSC
unsigned char DateTime
unsigned char Number
unsigned char TPMR
GSM_ValidityPeriod Relative
unsigned char TPPID

§ GSM_EncodeUDHHeader()

void GSM_EncodeUDHHeader ( GSM_Debug_Info di,
GSM_UDHHeader UDH 
)

Encodes UDH header.

GSM 03.40 section 9.2.3.24

Definition at line 1151 of file gsmsms.c.

References GSM_UDHHeader::AllParts, GSM_UDHHeader::ID16bit, GSM_UDHHeader::ID8bit, GSM_UDHHeader::Length, GSM_UDHHeader::PartNumber, smfprintf(), GSM_UDHHeader::Text, TRUE, GSM_UDHHeader::Type, UDH_NoUDH, and UDH_UserUDH.

Referenced by GSM_EncodeAlcatelMultiPartSMS(), GSM_EncodeEMSMultiPartSMS(), GSM_EncodeMultiPartSMS(), and GSM_MakeMultiPartSMS().

1152 {
1153  int i=0;
1154 
1155  if (UDH->Type == UDH_NoUDH) {
1156  UDH->Length = 0;
1157  return;
1158  }
1159  if (UDH->Type == UDH_UserUDH) {
1160  UDH->Length = UDH->Text[0] + 1;
1161  return;
1162  }
1163  while (TRUE) {
1164  if (UDHHeaders[i].Type==UDH_NoUDH) {
1165  smfprintf(di, "Not supported UDH type\n");
1166  break;
1167  }
1168  if (UDHHeaders[i].Type!=UDH->Type) {
1169  i++;
1170  continue;
1171  }
1172  /* UDH Length */
1173  UDH->Text[0] = UDHHeaders[i].Length;
1174  memcpy(UDH->Text+1, UDHHeaders[i].Text, UDHHeaders[i].Length);
1175  UDH->Length = UDH->Text[0] + 1;
1176 
1177  if (UDHHeaders[i].ID8bit != -1) {
1178  UDH->Text[UDHHeaders[i].ID8bit+1] = UDH->ID8bit % 256;
1179  } else {
1180  UDH->ID8bit = -1;
1181  }
1182  if (UDHHeaders[i].ID16bit != -1) {
1183  UDH->Text[UDHHeaders[i].ID16bit+1] = UDH->ID16bit / 256;
1184  UDH->Text[UDHHeaders[i].ID16bit+2] = UDH->ID16bit % 256;
1185  } else {
1186  UDH->ID16bit = -1;
1187  }
1188  if (UDHHeaders[i].PartNumber != -1) {
1189  UDH->Text[UDHHeaders[i].PartNumber+1] = UDH->PartNumber;
1190  } else {
1191  UDH->PartNumber = -1;
1192  }
1193  if (UDHHeaders[i].AllParts != -1) {
1194  UDH->Text[UDHHeaders[i].AllParts+1] = UDH->AllParts;
1195  } else {
1196  UDH->AllParts = -1;
1197  }
1198  break;
1199  }
1200 }
static GSM_UDHHeader UDHHeaders[]
Definition: gsmsms.c:29
unsigned char Text[GSM_MAX_UDH_LENGTH]
int smfprintf(GSM_Debug_Info *d, const char *format,...)
Definition: debug.c:240
#define TRUE
Definition: gammu-types.h:28

§ GSM_FreeMultiPartSMSInfo()

void GSM_FreeMultiPartSMSInfo ( GSM_MultiPartSMSInfo Info)

Frees any allocated structures inside GSM_MultiPartSMSInfo.

Definition at line 952 of file gsmmulti.c.

References GSM_MultiPartSMSEntry::Bitmap, GSM_MultiPartSMSEntry::Bookmark, GSM_MultiPartSMSEntry::Buffer, GSM_MultiPartSMSEntry::Calendar, GSM_MultiPartSMSInfo::Entries, GSM_MAX_MULTI_SMS, GSM_MultiPartSMSEntry::MMSIndicator, GSM_MultiPartSMSEntry::Phonebook, GSM_MultiPartSMSEntry::Ringtone, GSM_MultiPartSMSEntry::Settings, and GSM_MultiPartSMSEntry::ToDo.

953 {
954  int i;
955 
956  for (i=0;i<GSM_MAX_MULTI_SMS;i++) {
957  free(Info->Entries[i].Ringtone);
958  Info->Entries[i].Ringtone = NULL;
959  free(Info->Entries[i].Bitmap);
960  Info->Entries[i].Bitmap = NULL;
961  free(Info->Entries[i].Bookmark);
962  Info->Entries[i].Bookmark = NULL;
963  free(Info->Entries[i].Settings);
964  Info->Entries[i].Settings = NULL;
965  free(Info->Entries[i].MMSIndicator);
966  Info->Entries[i].MMSIndicator = NULL;
967  free(Info->Entries[i].Phonebook);
968  Info->Entries[i].Phonebook = NULL;
969  free(Info->Entries[i].Calendar);
970  Info->Entries[i].Calendar = NULL;
971  free(Info->Entries[i].ToDo);
972  Info->Entries[i].ToDo = NULL;
973  free(Info->Entries[i].Buffer);
974  Info->Entries[i].Buffer = NULL;
975  }
976 }
GSM_MemoryEntry * Phonebook
GSM_MultiBitmap * Bitmap
GSM_WAPSettings * Settings
GSM_MMSIndicator * MMSIndicator
GSM_ToDoEntry * ToDo
GSM_Ringtone * Ringtone
GSM_MultiPartSMSEntry Entries[GSM_MAX_MULTI_SMS]
GSM_WAPBookmark * Bookmark
#define GSM_MAX_MULTI_SMS
Definition: gammu-limits.h:162
unsigned char * Buffer
GSM_CalendarEntry * Calendar

§ GSM_GetNextSMS()

GSM_Error GSM_GetNextSMS ( GSM_StateMachine s,
GSM_MultiSMSMessage sms,
gboolean  start 
)

Reads next (or first if start set) SMS message. This might be faster for some phones than using 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 GSM_GetSMS.

Parameters
sState machine pointer.
[in,out]smsSMS message data read from phone, for subsequent reads, location and folder might be used by phone driver to determine reading state.
[in]startWhether we start reading from beginning.
Returns
Error code.

Reads next (or first if start set) SMS message. This might be faster for some phones than using GSM_GetSMS for each message.

Definition at line 683 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, GSM_Phone_Functions::GetNextSMS, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, PRINT_MSMS_INFO, and PRINT_START.

684 {
685  GSM_Error err;
686 
688  PRINT_START();
689  PRINT_MSMS_INFO();
690 
691  err = s->Phone.Functions->GetNextSMS(s, sms, start);
692  PRINT_LOG_ERROR(err);
693  return err;
694 }
GSM_Error
Definition: gammu-error.h:23
#define PRINT_START()
Definition: api.c:21
GSM_Error(* GetNextSMS)(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, gboolean start)
Definition: gsmstate.h:947
#define PRINT_MSMS_INFO()
Definition: api.c:19
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_GetSMS()

GSM_Error GSM_GetSMS ( GSM_StateMachine s,
GSM_MultiSMSMessage sms 
)

Reads SMS message.

Parameters
sState machine pointer.
[in,out]smsSMS message data read from phone, location and folder should be set.
Returns
Error code.

Reads SMS message.

Definition at line 668 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, GSM_Phone_Functions::GetSMS, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, and PRINT_MSMS_INFO.

669 {
670  GSM_Error err;
671 
673  PRINT_MSMS_INFO();
674 
675  err = s->Phone.Functions->GetSMS(s, sms);
676  PRINT_LOG_ERROR(err);
677  return err;
678 }
GSM_Error
Definition: gammu-error.h:23
#define PRINT_MSMS_INFO()
Definition: api.c:19
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
GSM_Error(* GetSMS)(GSM_StateMachine *s, GSM_MultiSMSMessage *sms)
Definition: gsmstate.h:942

§ GSM_GetSMSC()

GSM_Error GSM_GetSMSC ( GSM_StateMachine s,
GSM_SMSC smsc 
)

Gets SMS Service Center number and SMS settings.

Parameters
sState machine pointer.
[in,out]smscSMSC structure, should contain location.
Returns
Error code.

Gets SMS Service Center number and SMS settings.

Definition at line 628 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, GSM_Phone_Functions::GetSMSC, _GSM_StateMachine::Phone, and PRINT_LOG_ERROR.

629 {
630  GSM_Error err;
631 
633 
634  err = s->Phone.Functions->GetSMSC(s, smsc);
635  PRINT_LOG_ERROR(err);
636  return err;
637 }
GSM_Error
Definition: gammu-error.h:23
GSM_Error(* GetSMSC)(GSM_StateMachine *s, GSM_SMSC *smsc)
Definition: gsmstate.h:929
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_GetSMSFolders()

GSM_Error GSM_GetSMSFolders ( GSM_StateMachine s,
GSM_SMSFolders folders 
)

Returns SMS folders information.

Parameters
sState machine pointer.
[out]foldersfolders Pointer to folders structure, which will be filled in.
Returns
Error code.

Returns SMS folders information.

Definition at line 806 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, GSM_Phone_Functions::GetSMSFolders, _GSM_StateMachine::Phone, and PRINT_LOG_ERROR.

807 {
808  GSM_Error err;
809 
811 
812  err = s->Phone.Functions->GetSMSFolders(s, folders);
813  PRINT_LOG_ERROR(err);
814  return err;
815 }
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Error(* GetSMSFolders)(GSM_StateMachine *s, GSM_SMSFolders *folders)
Definition: gsmstate.h:983
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_GetSMSStatus()

GSM_Error GSM_GetSMSStatus ( GSM_StateMachine s,
GSM_SMSMemoryStatus status 
)

Gets information about SMS memory (read/unread/size of memory for both SIM and phone).

Parameters
sState machine pointer.
[out]statusPointer to SMS status structure.
Returns
Error code.

Gets information about SMS memory (read/unread/size of memory for both SIM and phone).

Definition at line 655 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, GSM_Phone_Functions::GetSMSStatus, _GSM_StateMachine::Phone, and PRINT_LOG_ERROR.

656 {
657  GSM_Error err;
658 
660 
661  err = s->Phone.Functions->GetSMSStatus(s, status);
662  PRINT_LOG_ERROR(err);
663  return err;
664 }
GSM_Error
Definition: gammu-error.h:23
GSM_Error(* GetSMSStatus)(GSM_StateMachine *s, GSM_SMSMemoryStatus *status)
Definition: gsmstate.h:938
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_LinkSMS()

GSM_Error GSM_LinkSMS ( GSM_Debug_Info di,
GSM_MultiSMSMessage **  INPUT,
GSM_MultiSMSMessage **  OUTPUT,
gboolean  ems 
)

Links SMS messages according to IDs.

Returns
Error code.

Definition at line 1395 of file gsmmulti.c.

References GSM_UDHHeader::AllParts, GSM_SiemensOTASMSInfo::DataName, GSM_SiemensOTASMSInfo::DataType, GSM_SMSMessage::DateTime, GSM_DateTime::Day, DecodeUnicodeString(), ERR_MOREMEMORY, ERR_NONE, FALSE, GSM_DecodeSiemensOTASMS(), GSM_SMS_OTHER_NUMBERS, GSM_DateTime::Hour, GSM_UDHHeader::ID16bit, GSM_UDHHeader::ID8bit, GSM_DateTime::Minute, GSM_DateTime::Month, GSM_MultiSMSMessage::Number, GSM_SMSMessage::OtherNumbersNum, GSM_SiemensOTASMSInfo::PacketNum, GSM_SiemensOTASMSInfo::PacketsNum, GSM_UDHHeader::PartNumber, GSM_DateTime::Second, GSM_SiemensOTASMSInfo::SequenceID, smfprintf(), GSM_MultiSMSMessage::SMS, SMS_Deliver, GSM_UDHHeader::Text, TRUE, GSM_UDHHeader::Type, GSM_SMSMessage::UDH, UDH_ConcatenatedMessages, UDH_ConcatenatedMessages16bit, UDH_NoUDH, UDH_UserUDH, UnicodeLength(), and GSM_DateTime::Year.

1396 {
1397  gboolean *InputMessagesSorted, copyit,OtherNumbers[GSM_SMS_OTHER_NUMBERS+1],wrong=FALSE;
1398  int i,OutputMessagesNum,z,w,m,p;
1399  int j;
1400  GSM_SiemensOTASMSInfo SiemensOTA,SiemensOTA2;
1401 
1402  i = 0;
1403  while (InputMessages[i] != NULL) i++;
1404 
1405  OutputMessagesNum = 0;
1406  OutputMessages[0] = NULL;
1407 
1408  if (i == 0) {
1409  return ERR_NONE;
1410  }
1411 
1412  InputMessagesSorted = calloc(i, sizeof(gboolean));
1413  if (InputMessagesSorted == NULL) return ERR_MOREMEMORY;
1414 
1415  if (ems) {
1416  for (i = 0; InputMessages[i] != NULL; i++) {
1417  if (InputMessages[i]->SMS[0].UDH.Type == UDH_UserUDH) {
1418  w=1;
1419  while (w < InputMessages[i]->SMS[0].UDH.Length) {
1420  switch(InputMessages[i]->SMS[0].UDH.Text[w]) {
1421  case 0x00:
1422  smfprintf(di, "Adding ID to user UDH - linked SMS with 8 bit ID\n");
1423  InputMessages[i]->SMS[0].UDH.ID8bit = InputMessages[i]->SMS[0].UDH.Text[w+2];
1424  InputMessages[i]->SMS[0].UDH.ID16bit = -1;
1425  InputMessages[i]->SMS[0].UDH.AllParts = InputMessages[i]->SMS[0].UDH.Text[w+3];
1426  InputMessages[i]->SMS[0].UDH.PartNumber = InputMessages[i]->SMS[0].UDH.Text[w+4];
1427  break;
1428  case 0x08:
1429  smfprintf(di, "Adding ID to user UDH - linked SMS with 16 bit ID\n");
1430  InputMessages[i]->SMS[0].UDH.ID8bit = -1;
1431  InputMessages[i]->SMS[0].UDH.ID16bit = InputMessages[i]->SMS[0].UDH.Text[w+2]*256+InputMessages[i]->SMS[0].UDH.Text[w+3];
1432  InputMessages[i]->SMS[0].UDH.AllParts = InputMessages[i]->SMS[0].UDH.Text[w+4];
1433  InputMessages[i]->SMS[0].UDH.PartNumber = InputMessages[i]->SMS[0].UDH.Text[w+5];
1434  break;
1435  default:
1436  smfprintf(di, "Block %02x\n",InputMessages[i]->SMS[0].UDH.Text[w]);
1437  }
1438  smfprintf(di, "id8: %i, id16: %i, part: %i, parts count: %i\n",
1439  InputMessages[i]->SMS[0].UDH.ID8bit,
1440  InputMessages[i]->SMS[0].UDH.ID16bit,
1441  InputMessages[i]->SMS[0].UDH.PartNumber,
1442  InputMessages[i]->SMS[0].UDH.AllParts);
1443  w=w+InputMessages[i]->SMS[0].UDH.Text[w+1]+2;
1444  }
1445  }
1446  }
1447  }
1448 
1449  i=0;
1450  while (InputMessages[i]!=NULL) {
1451  /* If this one SMS was sorted earlier, do not touch */
1452  if (InputMessagesSorted[i]) {
1453  i++;
1454  continue;
1455  }
1456  /* We have 1'st part of SIEMENS sms. It's single.
1457  * We will try to find other parts
1458  */
1459  if (GSM_DecodeSiemensOTASMS(di, &SiemensOTA,&InputMessages[i]->SMS[0]) &&
1460  SiemensOTA.PacketNum == 1) {
1461  OutputMessages[OutputMessagesNum] = (GSM_MultiSMSMessage *)malloc(sizeof(GSM_MultiSMSMessage));
1462  if (OutputMessages[OutputMessagesNum] == NULL) {
1463  free(InputMessagesSorted);
1464  InputMessagesSorted=NULL;
1465  return ERR_MOREMEMORY;
1466  }
1467  OutputMessages[OutputMessagesNum+1] = NULL;
1468 
1469  memcpy(&OutputMessages[OutputMessagesNum]->SMS[0],&InputMessages[i]->SMS[0],sizeof(GSM_SMSMessage));
1470  OutputMessages[OutputMessagesNum]->Number = 1;
1471  InputMessagesSorted[i] = TRUE;
1472  j = 1;
1473  /* We're searching for other parts in sequence */
1474  while (j!=(int)SiemensOTA.PacketsNum) {
1475  z=0;
1476  while(InputMessages[z]!=NULL) {
1477  /* This was sorted earlier or is not single */
1478  if (InputMessagesSorted[z] || InputMessages[z]->Number != 1) {
1479  z++;
1480  continue;
1481  }
1482  if (!GSM_DecodeSiemensOTASMS(di, &SiemensOTA2,&InputMessages[z]->SMS[0])) {
1483  z++;
1484  continue;
1485  }
1486  if (SiemensOTA2.SequenceID != SiemensOTA.SequenceID ||
1487  (int)SiemensOTA2.PacketNum != j+1 ||
1488  SiemensOTA2.PacketsNum != SiemensOTA.PacketsNum ||
1489  strcmp(SiemensOTA2.DataType,SiemensOTA.DataType) ||
1490  strcmp(SiemensOTA2.DataName,SiemensOTA.DataName)) {
1491  z++;
1492  continue;
1493  }
1494  /* For SMS_Deliver compare also SMSC and Sender numbers */
1495  if (InputMessages[z]->SMS[0].PDU == SMS_Deliver &&
1496  strcmp(DecodeUnicodeString(InputMessages[z]->SMS[0].SMSC.Number),DecodeUnicodeString(InputMessages[i]->SMS[0].SMSC.Number))) {
1497  z++;
1498  continue;
1499  }
1500  if (InputMessages[z]->SMS[0].PDU == SMS_Deliver &&
1501  InputMessages[z]->SMS[0].OtherNumbersNum!=InputMessages[i]->SMS[0].OtherNumbersNum) {
1502  z++;
1503  continue;
1504  }
1505  if (InputMessages[z]->SMS[0].PDU == SMS_Deliver) {
1506  for (m=0;m<GSM_SMS_OTHER_NUMBERS+1;m++) {
1507  OtherNumbers[m]=FALSE;
1508  }
1509  for (m=0;m<InputMessages[z]->SMS[0].OtherNumbersNum+1;m++) {
1510  wrong=TRUE;
1511  for (p=0;p<InputMessages[i]->SMS[0].OtherNumbersNum+1;p++) {
1512  if (OtherNumbers[p]) continue;
1513  if (m==0 && p==0 && !strcmp(DecodeUnicodeString(InputMessages[z]->SMS[0].Number),DecodeUnicodeString(InputMessages[i]->SMS[0].Number))) {
1514  OtherNumbers[0]=TRUE;
1515  wrong=FALSE;
1516  break;
1517  }
1518  if (m==0 && p!=0 && !strcmp(DecodeUnicodeString(InputMessages[z]->SMS[0].Number),DecodeUnicodeString(InputMessages[i]->SMS[0].OtherNumbers[p-1]))) {
1519  OtherNumbers[p]=TRUE;
1520  wrong=FALSE;
1521  break;
1522  }
1523  if (m!=0 && p==0 && !strcmp(DecodeUnicodeString(InputMessages[z]->SMS[0].OtherNumbers[m-1]),DecodeUnicodeString(InputMessages[i]->SMS[0].Number))) {
1524  OtherNumbers[0]=TRUE;
1525  wrong=FALSE;
1526  break;
1527  }
1528  if (m!=0 && p!=0 && !strcmp(DecodeUnicodeString(InputMessages[z]->SMS[0].OtherNumbers[m-1]),DecodeUnicodeString(InputMessages[i]->SMS[0].OtherNumbers[p-1]))) {
1529  OtherNumbers[p]=TRUE;
1530  wrong=FALSE;
1531  break;
1532  }
1533  }
1534  if (wrong) break;
1535  }
1536  if (wrong) {
1537  z++;
1538  continue;
1539  }
1540  }
1541  /* DCT4 Outbox: SMS Deliver. Empty number and SMSC. We compare dates */
1542  if (InputMessages[z]->SMS[0].PDU == SMS_Deliver &&
1543  UnicodeLength(InputMessages[z]->SMS[0].SMSC.Number)==0 &&
1544  UnicodeLength(InputMessages[z]->SMS[0].Number)==0 &&
1545  (InputMessages[z]->SMS[0].DateTime.Day != InputMessages[i]->SMS[0].DateTime.Day ||
1546  InputMessages[z]->SMS[0].DateTime.Month != InputMessages[i]->SMS[0].DateTime.Month ||
1547  InputMessages[z]->SMS[0].DateTime.Year != InputMessages[i]->SMS[0].DateTime.Year ||
1548  InputMessages[z]->SMS[0].DateTime.Hour != InputMessages[i]->SMS[0].DateTime.Hour ||
1549  InputMessages[z]->SMS[0].DateTime.Minute != InputMessages[i]->SMS[0].DateTime.Minute ||
1550  InputMessages[z]->SMS[0].DateTime.Second != InputMessages[i]->SMS[0].DateTime.Second)) {
1551  z++;
1552  continue;
1553  }
1554  smfprintf(di, "Found Siemens SMS %i\n",j);
1555  /* We found correct sms. Copy it */
1556  memcpy(&OutputMessages[OutputMessagesNum]->SMS[j],&InputMessages[z]->SMS[0],sizeof(GSM_SMSMessage));
1557  OutputMessages[OutputMessagesNum]->Number++;
1558  InputMessagesSorted[z]=TRUE;
1559  break;
1560  }
1561  /* Incomplete sequence */
1562  if (OutputMessages[OutputMessagesNum]->Number==j) {
1563  smfprintf(di, "Incomplete sequence\n");
1564  break;
1565  }
1566  j++;
1567  }
1568  OutputMessagesNum++;
1569  i = 0;
1570  continue;
1571  }
1572  /* We have some next Siemens sms from sequence */
1573  if (GSM_DecodeSiemensOTASMS(di, &SiemensOTA,&InputMessages[i]->SMS[0]) &&
1574  SiemensOTA.PacketNum > 1) {
1575  j = 0;
1576  while (InputMessages[j]!=NULL) {
1577  if (InputMessagesSorted[j]) {
1578  j++;
1579  continue;
1580  }
1581  /* We have some not unassigned first sms from sequence.
1582  * We can't touch other sms from sequences
1583  */
1584  if (GSM_DecodeSiemensOTASMS(di, &SiemensOTA,&InputMessages[j]->SMS[0]) &&
1585  SiemensOTA.PacketNum == 1) {
1586  break;
1587  }
1588  j++;
1589  }
1590  if (InputMessages[j]==NULL) {
1591  OutputMessages[OutputMessagesNum] = (GSM_MultiSMSMessage *)malloc(sizeof(GSM_MultiSMSMessage));
1592  if (OutputMessages[OutputMessagesNum] == NULL) {
1593  free(InputMessagesSorted);
1594  InputMessagesSorted=NULL;
1595  return ERR_MOREMEMORY;
1596  }
1597  OutputMessages[OutputMessagesNum+1] = NULL;
1598 
1599  memcpy(OutputMessages[OutputMessagesNum],InputMessages[i],sizeof(GSM_MultiSMSMessage));
1600  InputMessagesSorted[i]=TRUE;
1601  OutputMessagesNum++;
1602  i = 0;
1603  continue;
1604  } else i++;
1605  }
1606  copyit = FALSE;
1607  /* If we have:
1608  * - linked sms returned by phone driver
1609  * - sms without linking
1610  * we copy it to OutputMessages
1611  */
1612  if (InputMessages[i]->Number != 1 ||
1613  InputMessages[i]->SMS[0].UDH.Type == UDH_NoUDH ||
1614  InputMessages[i]->SMS[0].UDH.PartNumber == -1) {
1615  copyit = TRUE;
1616  }
1617  /* If we have unknown UDH, we copy it to OutputMessages */
1618  if (InputMessages[i]->SMS[0].UDH.Type == UDH_UserUDH) {
1619  if (!ems) copyit = TRUE;
1620  if (ems && InputMessages[i]->SMS[0].UDH.PartNumber == -1) copyit = TRUE;
1621  }
1622  if (copyit) {
1623  OutputMessages[OutputMessagesNum] = (GSM_MultiSMSMessage *)malloc(sizeof(GSM_MultiSMSMessage));
1624  if (OutputMessages[OutputMessagesNum] == NULL) {
1625  free(InputMessagesSorted);
1626  InputMessagesSorted=NULL;
1627  return ERR_MOREMEMORY;
1628  }
1629  OutputMessages[OutputMessagesNum+1] = NULL;
1630 
1631  memcpy(OutputMessages[OutputMessagesNum],InputMessages[i],sizeof(GSM_MultiSMSMessage));
1632  InputMessagesSorted[i]=TRUE;
1633  OutputMessagesNum++;
1634  i = 0;
1635  continue;
1636  }
1637  /* We have 1'st part of linked sms. It's single.
1638  * We will try to find other parts
1639  */
1640  if (InputMessages[i]->SMS[0].UDH.PartNumber == 1) {
1641  OutputMessages[OutputMessagesNum] = (GSM_MultiSMSMessage *)malloc(sizeof(GSM_MultiSMSMessage));
1642  if (OutputMessages[OutputMessagesNum] == NULL) {
1643  free(InputMessagesSorted);
1644  InputMessagesSorted=NULL;
1645  return ERR_MOREMEMORY;
1646  }
1647  OutputMessages[OutputMessagesNum+1] = NULL;
1648 
1649  memcpy(&OutputMessages[OutputMessagesNum]->SMS[0],&InputMessages[i]->SMS[0],sizeof(GSM_SMSMessage));
1650  OutputMessages[OutputMessagesNum]->Number = 1;
1651  InputMessagesSorted[i] = TRUE;
1652  j = 1;
1653  /* We're searching for other parts in sequence */
1654  while (j != InputMessages[i]->SMS[0].UDH.AllParts) {
1655  z=0;
1656  while(InputMessages[z]!=NULL) {
1657  /* This was sorted earlier or is not single */
1658  if (InputMessagesSorted[z] || InputMessages[z]->Number != 1) {
1659  z++;
1660  continue;
1661  }
1662  if (ems && InputMessages[i]->SMS[0].UDH.Type != UDH_ConcatenatedMessages &&
1663  InputMessages[i]->SMS[0].UDH.Type != UDH_ConcatenatedMessages16bit &&
1664  InputMessages[i]->SMS[0].UDH.Type != UDH_UserUDH &&
1665  InputMessages[z]->SMS[0].UDH.Type != UDH_ConcatenatedMessages &&
1666  InputMessages[z]->SMS[0].UDH.Type != UDH_ConcatenatedMessages16bit &&
1667  InputMessages[z]->SMS[0].UDH.Type != UDH_UserUDH) {
1668  if (InputMessages[z]->SMS[0].UDH.Type != InputMessages[i]->SMS[0].UDH.Type) {
1669  z++;
1670  continue;
1671  }
1672  }
1673  if (!ems && InputMessages[z]->SMS[0].UDH.Type != InputMessages[i]->SMS[0].UDH.Type) {
1674  z++;
1675  continue;
1676  }
1677  smfprintf(di, "compare %i %i %i %i %i",
1678  j+1,
1679  InputMessages[i]->SMS[0].UDH.ID8bit,
1680  InputMessages[i]->SMS[0].UDH.ID16bit,
1681  InputMessages[i]->SMS[0].UDH.PartNumber,
1682  InputMessages[i]->SMS[0].UDH.AllParts);
1683  smfprintf(di, " %i %i %i %i\n",
1684  InputMessages[z]->SMS[0].UDH.ID8bit,
1685  InputMessages[z]->SMS[0].UDH.ID16bit,
1686  InputMessages[z]->SMS[0].UDH.PartNumber,
1687  InputMessages[z]->SMS[0].UDH.AllParts);
1688  if (InputMessages[z]->SMS[0].UDH.ID8bit != InputMessages[i]->SMS[0].UDH.ID8bit ||
1689  InputMessages[z]->SMS[0].UDH.ID16bit != InputMessages[i]->SMS[0].UDH.ID16bit ||
1690  InputMessages[z]->SMS[0].UDH.AllParts != InputMessages[i]->SMS[0].UDH.AllParts ||
1691  (InputMessages[z]->SMS[0].UDH.PartNumber) != j + 1) {
1692  z++;
1693  continue;
1694  }
1695  /* For SMS_Deliver compare also SMSC and Sender numbers */
1696  if (InputMessages[z]->SMS[0].PDU == SMS_Deliver &&
1697  strcmp(DecodeUnicodeString(InputMessages[z]->SMS[0].SMSC.Number),DecodeUnicodeString(InputMessages[i]->SMS[0].SMSC.Number))) {
1698  z++;
1699  continue;
1700  }
1701  if (InputMessages[z]->SMS[0].PDU == SMS_Deliver &&
1702  InputMessages[z]->SMS[0].OtherNumbersNum!=InputMessages[i]->SMS[0].OtherNumbersNum) {
1703  z++;
1704  continue;
1705  }
1706  if (InputMessages[z]->SMS[0].PDU == SMS_Deliver) {
1707  for (m=0;m<GSM_SMS_OTHER_NUMBERS+1;m++) {
1708  OtherNumbers[m]=FALSE;
1709  }
1710  for (m=0;m<InputMessages[z]->SMS[0].OtherNumbersNum+1;m++) {
1711  wrong=TRUE;
1712  for (p=0;p<InputMessages[i]->SMS[0].OtherNumbersNum+1;p++) {
1713  if (OtherNumbers[p]) continue;
1714  if (m==0 && p==0 && !strcmp(DecodeUnicodeString(InputMessages[z]->SMS[0].Number),DecodeUnicodeString(InputMessages[i]->SMS[0].Number))) {
1715  OtherNumbers[0]=TRUE;
1716  wrong=FALSE;
1717  break;
1718  }
1719  if (m==0 && p!=0 && !strcmp(DecodeUnicodeString(InputMessages[z]->SMS[0].Number),DecodeUnicodeString(InputMessages[i]->SMS[0].OtherNumbers[p-1]))) {
1720  OtherNumbers[p]=TRUE;
1721  wrong=FALSE;
1722  break;
1723  }
1724  if (m!=0 && p==0 && !strcmp(DecodeUnicodeString(InputMessages[z]->SMS[0].OtherNumbers[m-1]),DecodeUnicodeString(InputMessages[i]->SMS[0].Number))) {
1725  OtherNumbers[0]=TRUE;
1726  wrong=FALSE;
1727  break;
1728  }
1729  if (m!=0 && p!=0 && !strcmp(DecodeUnicodeString(InputMessages[z]->SMS[0].OtherNumbers[m-1]),DecodeUnicodeString(InputMessages[i]->SMS[0].OtherNumbers[p-1]))) {
1730  OtherNumbers[p]=TRUE;
1731  wrong=FALSE;
1732  break;
1733  }
1734  }
1735  if (wrong) break;
1736  }
1737  if (wrong) {
1738  z++;
1739  continue;
1740  }
1741  }
1742  /* DCT4 Outbox: SMS Deliver. Empty number and SMSC. We compare dates */
1743  if (InputMessages[z]->SMS[0].PDU == SMS_Deliver &&
1744  UnicodeLength(InputMessages[z]->SMS[0].SMSC.Number)==0 &&
1745  UnicodeLength(InputMessages[z]->SMS[0].Number)==0 &&
1746  (InputMessages[z]->SMS[0].DateTime.Day != InputMessages[i]->SMS[0].DateTime.Day ||
1747  InputMessages[z]->SMS[0].DateTime.Month != InputMessages[i]->SMS[0].DateTime.Month ||
1748  InputMessages[z]->SMS[0].DateTime.Year != InputMessages[i]->SMS[0].DateTime.Year ||
1749  InputMessages[z]->SMS[0].DateTime.Hour != InputMessages[i]->SMS[0].DateTime.Hour ||
1750  InputMessages[z]->SMS[0].DateTime.Minute != InputMessages[i]->SMS[0].DateTime.Minute ||
1751  InputMessages[z]->SMS[0].DateTime.Second != InputMessages[i]->SMS[0].DateTime.Second)) {
1752  z++;
1753  continue;
1754  }
1755  /* We found correct sms. Copy it */
1756  memcpy(&OutputMessages[OutputMessagesNum]->SMS[j],&InputMessages[z]->SMS[0],sizeof(GSM_SMSMessage));
1757  OutputMessages[OutputMessagesNum]->Number++;
1758  InputMessagesSorted[z]=TRUE;
1759  break;
1760  }
1761  /* Incomplete sequence */
1762  if (OutputMessages[OutputMessagesNum]->Number==j) {
1763  smfprintf(di, "Incomplete sequence\n");
1764  break;
1765  }
1766  j++;
1767  }
1768  OutputMessagesNum++;
1769  i = 0;
1770  continue;
1771  }
1772  /* We have some next linked sms from sequence */
1773  if (InputMessages[i]->SMS[0].UDH.PartNumber > 1) {
1774  j = 0;
1775  while (InputMessages[j]!=NULL) {
1776  if (InputMessagesSorted[j]) {
1777  j++;
1778  continue;
1779  }
1780  /* We have some not unassigned first sms from sequence.
1781  * We can't touch other sms from sequences
1782  */
1783  if (InputMessages[j]->SMS[0].UDH.PartNumber == 1) break;
1784  j++;
1785  }
1786  if (InputMessages[j]==NULL) {
1787  OutputMessages[OutputMessagesNum] = (GSM_MultiSMSMessage *)malloc(sizeof(GSM_MultiSMSMessage));
1788  if (OutputMessages[OutputMessagesNum] == NULL) {
1789  free(InputMessagesSorted);
1790  InputMessagesSorted=NULL;
1791  return ERR_MOREMEMORY;
1792  }
1793  OutputMessages[OutputMessagesNum+1] = NULL;
1794 
1795  memcpy(OutputMessages[OutputMessagesNum],InputMessages[i],sizeof(GSM_MultiSMSMessage));
1796  InputMessagesSorted[i]=TRUE;
1797  OutputMessagesNum++;
1798  i = 0;
1799  continue;
1800  } else i++;
1801  }
1802  }
1803  free(InputMessagesSorted);
1804  InputMessagesSorted=NULL;
1805  return ERR_NONE;
1806 }
char * DecodeUnicodeString(const unsigned char *src)
Definition: coding.c:245
size_t UnicodeLength(const unsigned char *str)
Definition: coding.c:186
unsigned char DataName[40]
gboolean GSM_DecodeSiemensOTASMS(GSM_Debug_Info *di, GSM_SiemensOTASMSInfo *Info, GSM_SMSMessage *SMS)
Definition: gsmsms.c:1202
int gboolean
Definition: gammu-types.h:23
#define GSM_SMS_OTHER_NUMBERS
Definition: gammu-limits.h:145
#define FALSE
Definition: gammu-types.h:25
unsigned int PacketNum
unsigned int PacketsNum
int smfprintf(GSM_Debug_Info *d, const char *format,...)
Definition: debug.c:240
#define TRUE
Definition: gammu-types.h:28
unsigned long SequenceID
unsigned char DataType[10]

§ GSM_SendSavedSMS()

GSM_Error GSM_SendSavedSMS ( GSM_StateMachine s,
int  Folder,
int  Location 
)

Sends SMS already saved in phone.

Parameters
sState machine pointer.
[in]FolderFolder, where message is stored.
[in]LocationLocation, where message is stored.
Returns
Error code.

Sends SMS already saved in phone.

Definition at line 753 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, GSM_Phone_Functions::SendSavedSMS, and smprintf().

754 {
755  GSM_Error err;
756 
758  smprintf(s, "Location = %d, Folder = %d\n", Location, Folder);
759 
760  err = s->Phone.Functions->SendSavedSMS(s, Folder, Location);
761  PRINT_LOG_ERROR(err);
762  return err;
763 }
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Error(* SendSavedSMS)(GSM_StateMachine *s, int Folder, int Location)
Definition: gsmstate.h:967
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
int smprintf(GSM_StateMachine *s, const char *format,...)
Definition: debug.c:261

§ GSM_SendSMS()

GSM_Error GSM_SendSMS ( GSM_StateMachine s,
GSM_SMSMessage sms 
)

Sends SMS.

Parameters
sState machine pointer.
[in]smsSMS structure with SMS data to send.
Returns
Error code.

Sends SMS.

Definition at line 740 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, and GSM_Phone_Functions::SendSMS.

741 {
742  GSM_Error err;
743 
745 
746  err = s->Phone.Functions->SendSMS(s, sms);
747  PRINT_LOG_ERROR(err);
748  return err;
749 }
GSM_Error(* SendSMS)(GSM_StateMachine *s, GSM_SMSMessage *sms)
Definition: gsmstate.h:963
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_SetDefaultReceivedSMSData()

void GSM_SetDefaultReceivedSMSData ( GSM_SMSMessage SMS)

Sets default content for SMS except for changing locations. Use this for clearing structure while keeping location of message.

Parameters
SMSPointer to structure which should be cleaned up.

Definition at line 1092 of file gsmsms.c.

References GSM_UDHHeader::AllParts, GSM_SMSMessage::Class, GSM_SMSMessage::Coding, GSM_SMSMessage::DateTime, GSM_SMSC::DefaultNumber, GSM_SMSMessage::DeliveryStatus, FALSE, GSM_SMSValidity::Format, GSM_SMSC::Format, GSM_UDHHeader::ID16bit, GSM_UDHHeader::ID8bit, GSM_UDHHeader::Length, GSM_SMSMessage::Length, GSM_SMSC::Location, GSM_SMSMessage::MessageReference, GSM_SMSC::Name, GSM_SMSMessage::Name, GSM_SMSC::Number, GSM_SMSMessage::Number, GSM_SMSMessage::OtherNumbersNum, GSM_UDHHeader::PartNumber, GSM_SMSMessage::RejectDuplicates, GSM_SMSValidity::Relative, GSM_SMSMessage::ReplaceMessage, GSM_SMSMessage::ReplyViaSameSMSC, SMS_Coding_8bit, SMS_FORMAT_Text, SMS_VALID_Max_Time, SMS_Validity_NotAvailable, GSM_SMSMessage::SMSC, GSM_UDHHeader::Text, GSM_SMSMessage::Text, GSM_UDHHeader::Type, GSM_SMSMessage::UDH, UDH_NoUDH, GSM_SMSC::Validity, and GSM_DateTime::Year.

Referenced by GSM_DecodePDUFrame(), GSM_DecodeSMSFrame(), and GSM_SetDefaultSMSData().

1093 {
1094  SMS->UDH.Type = UDH_NoUDH;
1095  SMS->UDH.Length = 0;
1096  SMS->UDH.Text[0] = 0;
1097  SMS->UDH.ID8bit = 0;
1098  SMS->UDH.ID16bit = 0;
1099  SMS->UDH.PartNumber = -1;
1100  SMS->UDH.AllParts = 0;
1101  SMS->Coding = SMS_Coding_8bit;
1102  SMS->Length = 0;
1103  SMS->SMSC.Location = 0;
1104  SMS->SMSC.DefaultNumber[0] = 0;
1105  SMS->SMSC.DefaultNumber[1] = 0;
1106  SMS->SMSC.Number[0] = 0;
1107  SMS->SMSC.Number[1] = 0;
1108  SMS->SMSC.Name[0] = 0;
1109  SMS->SMSC.Name[1] = 0;
1112  SMS->SMSC.Format = SMS_FORMAT_Text;
1113  SMS->Number[0] = 0;
1114  SMS->Number[1] = 0;
1115  SMS->OtherNumbersNum = 0;
1116  SMS->Name[0] = 0;
1117  SMS->Name[1] = 0;
1118  SMS->ReplyViaSameSMSC = FALSE;
1119  SMS->Class = 0;
1120  SMS->Text[0] = 0;
1121  SMS->Text[1] = 0;
1122  SMS->RejectDuplicates = FALSE;
1123  SMS->MessageReference = 0;
1124  SMS->ReplaceMessage = 0;
1125  SMS->DeliveryStatus = 0;
1126  SMS->DateTime.Year = 0;
1127 }
GSM_DateTime DateTime
unsigned char Text[(GSM_MAX_SMS_LENGTH+1) *2]
unsigned char Number[(GSM_MAX_NUMBER_LENGTH+1) *2]
unsigned char ReplaceMessage
gboolean RejectDuplicates
signed char Class
GSM_UDHHeader UDH
unsigned char DeliveryStatus
GSM_Coding_Type Coding
GSM_SMSFormat Format
unsigned char Text[GSM_MAX_UDH_LENGTH]
unsigned char DefaultNumber[(GSM_MAX_NUMBER_LENGTH+1) *2]
GSM_ValidityPeriodFormat Format
unsigned char Name[(GSM_MAX_SMS_NAME_LENGTH+1) *2]
#define FALSE
Definition: gammu-types.h:25
GSM_SMSValidity Validity
unsigned char Number[(GSM_MAX_NUMBER_LENGTH+1) *2]
unsigned char MessageReference
gboolean ReplyViaSameSMSC
GSM_ValidityPeriod Relative
unsigned char Name[(GSM_MAX_SMSC_NAME_LENGTH+1) *2]

§ GSM_SetDefaultSMSData()

void GSM_SetDefaultSMSData ( GSM_SMSMessage SMS)

Sets default content for SMS. Use this for clearing structure.

Parameters
SMSPointer to structure which should be cleaned up.

Definition at line 1129 of file gsmsms.c.

References GSM_SMSMessage::DateTime, FALSE, GSM_SMSMessage::Folder, GSM_SMSValidity::Format, GSM_GetCurrentDateTime(), GSM_SetDefaultReceivedSMSData(), GSM_SMSMessage::InboxFolder, GSM_SMSC::Location, GSM_SMSMessage::Location, GSM_SMSMessage::Memory, GSM_SMSMessage::PDU, GSM_SMSValidity::Relative, SMS_Submit, SMS_UnSent, SMS_VALID_Max_Time, SMS_Validity_RelativeFormat, GSM_SMSMessage::SMSC, GSM_SMSMessage::SMSCTime, GSM_SMSMessage::State, and GSM_SMSC::Validity.

Referenced by GSM_EncodeAlcatelMultiPartSMS(), GSM_EncodeEMSMultiPartSMS(), and GSM_MakeMultiPartSMS().

1130 {
1132 
1135  SMS->SMSC.Location = 1;
1136 
1137  /* This part is required to save SMS */
1138  SMS->State = SMS_UnSent;
1139  SMS->PDU = SMS_Submit;
1140  SMS->Location = 0;
1141  SMS->Memory = 0;
1142  SMS->Folder = 0x02; /*Outbox*/
1143  SMS->InboxFolder = FALSE;
1146 }
GSM_SMSMessageType PDU
GSM_DateTime DateTime
void GSM_SetDefaultReceivedSMSData(GSM_SMSMessage *SMS)
Definition: gsmsms.c:1092
GSM_SMS_State State
GSM_ValidityPeriodFormat Format
gboolean InboxFolder
#define FALSE
Definition: gammu-types.h:25
GSM_SMSValidity Validity
void GSM_GetCurrentDateTime(GSM_DateTime *Date)
Definition: misc.c:184
GSM_DateTime SMSCTime
GSM_ValidityPeriod Relative
GSM_MemoryType Memory

§ GSM_SetFastSMSSending()

GSM_Error GSM_SetFastSMSSending ( GSM_StateMachine s,
gboolean  enable 
)

Configures fast SMS sending.

Parameters
sState machine pointer.
[in]enableWhether to enable notifications.
Returns
Error code.

Configures fast SMS sending.

Definition at line 767 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, and GSM_Phone_Functions::SetFastSMSSending.

768 {
769  GSM_Error err;
770 
772 
773  err = s->Phone.Functions->SetFastSMSSending(s, enable);
774  PRINT_LOG_ERROR(err);
775  return err;
776 }
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
GSM_Error(* SetFastSMSSending)(GSM_StateMachine *s, gboolean enable)
Definition: gsmstate.h:971

§ GSM_SetIncomingSMS()

GSM_Error GSM_SetIncomingSMS ( GSM_StateMachine s,
gboolean  enable 
)

Enable/disable notification on incoming SMS.

Parameters
sState machine pointer.
[in]enableWhether to enable notifications.
Returns
Error code.

Enable/disable notification on incoming SMS.

Definition at line 780 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, and GSM_Phone_Functions::SetIncomingSMS.

781 {
782  GSM_Error err;
783 
785 
786  err = s->Phone.Functions->SetIncomingSMS(s, enable);
787  PRINT_LOG_ERROR(err);
788  return err;
789 }
GSM_Error(* SetIncomingSMS)(GSM_StateMachine *s, gboolean enable)
Definition: gsmstate.h:975
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_SetSMS()

GSM_Error GSM_SetSMS ( GSM_StateMachine s,
GSM_SMSMessage sms 
)

Sets SMS.

Parameters
sState machine pointer.
[in]smsSMS message data.
Returns
Error code.

Sets SMS.

Definition at line 698 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, PRINT_SMS_INFO, and GSM_Phone_Functions::SetSMS.

699 {
700  GSM_Error err;
701 
703  PRINT_SMS_INFO();
704 
705  err = s->Phone.Functions->SetSMS(s, sms);
706  PRINT_LOG_ERROR(err);
707  return err;
708 }
GSM_Error
Definition: gammu-error.h:23
GSM_Error(* SetSMS)(GSM_StateMachine *s, GSM_SMSMessage *sms)
Definition: gsmstate.h:951
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
#define PRINT_SMS_INFO()
Definition: api.c:20

§ GSM_SetSMSC()

GSM_Error GSM_SetSMSC ( GSM_StateMachine s,
GSM_SMSC smsc 
)

Sets SMS Service Center number and SMS settings.

Parameters
sState machine pointer.
[in]smscSMSC structure.
Returns
Error code.

Sets SMS Service Center number and SMS settings.

Definition at line 641 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, and GSM_Phone_Functions::SetSMSC.

642 {
643  GSM_Error err;
644 
646 
647  err = s->Phone.Functions->SetSMSC(s, smsc);
648  PRINT_LOG_ERROR(err);
649  return err;
650 }
GSM_Error(* SetSMSC)(GSM_StateMachine *s, GSM_SMSC *smsc)
Definition: gsmstate.h:933
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_SMSCounter()

void GSM_SMSCounter ( GSM_Debug_Info di,
unsigned char *  MessageBuffer,
GSM_UDH  UDHType,
GSM_Coding_Type  Coding,
int *  SMSNum,
size_t *  CharsLeft 
)

Calculates number of messages and free chars needed for text.

Parameters
diDebug settings.
[in]MessageBufferActual message text in unicode.
[in]UDHTypeUDH type.
[in]CodingGSM Encoding type.
[out]SMSNumNumber of messages needed to store the text.
[out]CharsLeftNumber of free chars in the message.

Definition at line 355 of file gsmmulti.c.

References FALSE, GSM_Find_Free_Used_SMS2(), GSM_MakeMultiPartSMS(), GSM_MultiSMSMessage::Number, GSM_MultiSMSMessage::SMS, and UnicodeLength().

361 {
362  size_t UsedText=0,FreeBytes=0;
363  GSM_MultiSMSMessage MultiSMS;
364 
365  MultiSMS.Number = 0;
366  GSM_MakeMultiPartSMS(di, &MultiSMS,MessageBuffer,UnicodeLength(MessageBuffer),UDHType,Coding,-1,FALSE);
368  di, Coding, &(MultiSMS.SMS[MultiSMS.Number-1]),
369  &UsedText, CharsLeft, &FreeBytes
370  );
371  *SMSNum = MultiSMS.Number;
372 }
size_t UnicodeLength(const unsigned char *str)
Definition: coding.c:186
void GSM_Find_Free_Used_SMS2(GSM_Debug_Info *di, GSM_Coding_Type Coding, GSM_SMSMessage *SMS, size_t *UsedText, size_t *FreeText, size_t *FreeBytes)
Definition: gsmmulti.c:37
void GSM_MakeMultiPartSMS(GSM_Debug_Info *di, GSM_MultiSMSMessage *SMS, unsigned char *MessageBuffer, size_t MessageLength, GSM_UDH UDHType, GSM_Coding_Type Coding, int Class, unsigned char ReplaceMessage)
Definition: gsmmulti.c:305
#define FALSE
Definition: gammu-types.h:25
GSM_SMSMessage SMS[GSM_MAX_MULTI_SMS]

§ PHONE_EncodeSMSFrame()

GSM_Error PHONE_EncodeSMSFrame ( GSM_StateMachine s,
GSM_SMSMessage SMS,
unsigned char *  buffer,
GSM_SMSMessageLayout  Layout,
int *  length,
gboolean  clear 
)

Encodes SMS frame according to layout.

Returns
Error code.

Definition at line 58 of file pfunc.c.

References ERR_EMPTYSMSC, ERR_GETTING_SMSC, ERR_NONE, GSM_Phone::Functions, GSM_Phone_Functions::GetSMSC, GSM_EncodeSMSFrame(), GSM_GetDI(), GSM_SMSC::Location, GSM_SMSC::Number, GSM_SMSMessage::PDU, _GSM_StateMachine::Phone, smprintf(), SMS_Deliver, and GSM_SMSMessage::SMSC.

Referenced by DUMMY_SendSMS().

59 {
60  GSM_Error error;
61 
62  if (SMS->SMSC.Location != 0) {
63  smprintf(s, "Getting SMSC from phone, location %d\n", SMS->SMSC.Location);
64  error = s->Phone.Functions->GetSMSC(s, &SMS->SMSC);
65  if (error != ERR_NONE) {
66  return ERR_GETTING_SMSC;
67  }
68  SMS->SMSC.Location = 0;
69  }
70  if (SMS->PDU == SMS_Deliver) {
71  if (SMS->SMSC.Number[0] == 0x00 && SMS->SMSC.Number[1] == 0x00) {
72  smprintf(s,"No SMSC in SMS Deliver\n");
73  return ERR_EMPTYSMSC;
74  }
75  }
76  return GSM_EncodeSMSFrame(GSM_GetDI(s), SMS, buffer, Layout, length, clear);
77 }
GSM_SMSMessageType PDU
GSM_Debug_Info * GSM_GetDI(GSM_StateMachine *s)
Definition: gsmstate.c:70
GSM_Error
Definition: gammu-error.h:23
GSM_Error(* GetSMSC)(GSM_StateMachine *s, GSM_SMSC *smsc)
Definition: gsmstate.h:929
GSM_Phone Phone
Definition: gsmstate.h:1431
unsigned char Number[(GSM_MAX_NUMBER_LENGTH+1) *2]
GSM_Error GSM_EncodeSMSFrame(GSM_Debug_Info *di, GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout, int *length, gboolean clear)
Definition: gsmsms.c:1008
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
int smprintf(GSM_StateMachine *s, const char *format,...)
Definition: debug.c:261

Variable Documentation

§ PHONE_SMSDeliver

GSM_SMSMessageLayout PHONE_SMSDeliver

Layout for deliver message.

Definition at line 16 of file pfunc.c.

Referenced by DUMMY_SendSMS().

§ PHONE_SMSStatusReport

GSM_SMSMessageLayout PHONE_SMSStatusReport

Layout for status report message.

Definition at line 30 of file pfunc.c.

§ PHONE_SMSSubmit

GSM_SMSMessageLayout PHONE_SMSSubmit

Layout for submit message.

Definition at line 23 of file pfunc.c.

Referenced by DUMMY_SendSMS().