--- gsmlib-1.8-SieMe/gsmlib/gsm_sorted_sms_store.cc-orig Sun Dec 2 09:30:10 2001 +++ gsmlib-1.8-SieMe/gsmlib/gsm_sorted_sms_store.cc Wed Jan 16 23:38:49 2002 @@ -40,6 +40,7 @@ // 4. PDU in hexadecimal format static const unsigned short int SMS_STORE_FILE_FORMAT_VERSION = 1; +static const unsigned short int SIEME_FILE_FORMAT_VERSION = 0x0b0b; // SortedSMSStore members @@ -83,6 +84,43 @@ // ignore error, file might be empty initially } unsigned_int_2 version = ntohs(*((unsigned_int_2*)numberBuf)); + + // try to read single entry in Siemens Mobile Equipment format + if (! pbs.eof() && version == SIEME_FILE_FORMAT_VERSION) { + + // read message type (I hope so): 7 is smo and 1 is smi + readnbytes(filename, pbs, 4, numberBuf); + unsigned_int_4 msgType = ntohl(*((unsigned_int_4*)numberBuf)); + if (msgType != 1 && msgType != 7) + throw GsmException(stringPrintf(_("file '%s' has wrong type"), + filename.c_str()), ParameterError); + SMSMessage::MessageType messageType = msgType == 1 ? + SMSMessage::SMS_DELIVER : SMSMessage::SMS_SUBMIT; + + // so far i've only encountered file sizes of 181 bytes + unsigned_int_2 hexLen = 175; // bad coder no biscuits... + char *hexBuf = (char*)alloca(sizeof(char) * hexLen); + + // read hex(!) pdu + readnbytes(filename, pbs, hexLen, hexBuf); + + // encode so standard methods can be applied (sic!) + string pdu = bufToHex((unsigned char *)hexBuf, hexLen); + + SMSMessageRef message = + SMSMessage::decode(pdu, + (messageType != SMSMessage::SMS_SUBMIT)); + + SMSStoreEntry *newEntry = new SMSStoreEntry(message, _nextIndex++); + _sortedSMSStore.insert( + SMSStoreMap::value_type( + SMSMapKey(*this, message->serviceCentreTimestamp()), + newEntry) + ); + + return; + } + if (! pbs.eof() && version != SMS_STORE_FILE_FORMAT_VERSION) throw GsmException(stringPrintf(_("file '%s' has wrong version"), filename.c_str()), ParameterError);