?? gsm_sms.c
字號:
break;
case TimePeriod::Relative:
os << _("relative");
break;
case TimePeriod::Absolute:
os << _("absolute");
break;
default:
os << _("unknown");
break;
}
os << endl
<< _("Reply path: ") << _replyPath << endl
<< _("User data header indicator: ")
<< (_userDataHeader.length()!=0) << endl
<< _("Status report request: ") << _statusReportRequest << endl
<< _("Message reference: ") << (unsigned int)_messageReference << endl
<< _("Destination address: '") << _destinationAddress._number
<< "'" << endl
<< _("Protocol identifier: 0x") << hex
<< (unsigned int)_protocolIdentifier << dec << endl
<< _("Data coding scheme: ") << _dataCodingScheme.toString() << endl
<< _("Validity period: ") << _validityPeriod.toString() << endl
<< _("User data length: ") << (int)userDataLength() << endl
<< _("User data header: 0x") << bufToHex((unsigned char*)
((string)_userDataHeader).data(),
_userDataHeader.length())
<< endl
<< _("User data: '") << _userData << "'" << endl
<< dashes << endl << endl
<< ends;
char *ss = os.str();
string result(ss);
delete[] ss;
return result;
}
Address SMSSubmitMessage::address() const
{
return _destinationAddress;
}
Ref<SMSMessage> SMSSubmitMessage::clone()
{
Ref<SMSMessage> result = new SMSSubmitMessage(*this);
return result;
}
// SMSStatusReportMessage members
void SMSStatusReportMessage::init()
{
_messageTypeIndicator = SMS_STATUS_REPORT;
_moreMessagesToSend = false;
_statusReportQualifier = false;
_messageReference = 0;
_status = SMS_STATUS_RECEIVED;
}
SMSStatusReportMessage::SMSStatusReportMessage(string pdu) throw(GsmException)
{
SMSDecoder d(pdu);
_serviceCentreAddress = d.getAddress(true);
_messageTypeIndicator = (MessageType)d.get2Bits(); // bits 0..1
assert(_messageTypeIndicator == SMS_STATUS_REPORT);
_moreMessagesToSend = d.getBit(); // bit 2
d.getBit(); // bit 3
d.getBit(); // bit 4
_statusReportQualifier = d.getBit(); // bit 5
_messageReference = d.getOctet();
_recipientAddress = d.getAddress();
_serviceCentreTimestamp = d.getTimestamp();
_dischargeTime = d.getTimestamp();
_status = d.getOctet();
}
string SMSStatusReportMessage::encode()
{
SMSEncoder e;
e.setAddress(_serviceCentreAddress, true);
e.set2Bits(_messageTypeIndicator); // bits 0..1
e.setBit(_moreMessagesToSend); // bit 2
e.setBit(); // bit 3
e.setBit(); // bit 4
e.setBit(_statusReportQualifier); // bit 5
e.setOctet(_messageReference);
e.setAddress(_recipientAddress);
e.setTimestamp(_serviceCentreTimestamp);
e.setTimestamp(_dischargeTime);
e.setOctet(_status);
return e.getHexString();
}
string SMSStatusReportMessage::toString() const
{
ostrstream os;
os << dashes << endl
<< _("Message type: SMS-STATUS-REPORT") << endl
<< _("SC address: '") << _serviceCentreAddress._number << "'" << endl
<< _("More messages to send: ") << _moreMessagesToSend << endl
<< _("Status report qualifier: ") << _statusReportQualifier << endl
<< _("Message reference: ") << (unsigned int)_messageReference << endl
<< _("Recipient address: '") << _recipientAddress._number << "'" << endl
<< _("SC timestamp: ") << _serviceCentreTimestamp.toString() << endl
<< _("Discharge time: ") << _dischargeTime.toString() << endl
<< _("Status: 0x") << hex << (unsigned int)_status << dec
<< " '" << getSMSStatusString(_status) << "'" << endl
<< dashes << endl << endl
<< ends;
char *ss = os.str();
string result(ss);
delete[] ss;
return result;
}
Address SMSStatusReportMessage::address() const
{
return _recipientAddress;
}
Ref<SMSMessage> SMSStatusReportMessage::clone()
{
Ref<SMSMessage> result = new SMSStatusReportMessage(*this);
return result;
}
// SMSCommandMessage members
void SMSCommandMessage::init()
{
_messageTypeIndicator = SMS_COMMAND;
_messageReference = 0;
_statusReportRequest = true;
_protocolIdentifier = 0;
_commandType = EnquireSM;
_messageNumber = 0;
_commandDataLength = 0;
}
SMSCommandMessage::SMSCommandMessage(string pdu) throw(GsmException)
{
SMSDecoder d(pdu);
_serviceCentreAddress = d.getAddress(true);
_messageTypeIndicator = (MessageType)d.get2Bits(); // bits 0..1
assert(_messageTypeIndicator == SMS_COMMAND);
d.getBit(); // bit 2
d.getBit(); // bit 3
d.getBit(); // bit 4
_statusReportRequest = d.getBit(); // bit 5
_messageReference = d.getOctet();
_protocolIdentifier = d.getOctet();
_commandType = d.getOctet();
_messageNumber = d.getOctet();
_destinationAddress = d.getAddress();
_commandDataLength = d.getOctet();
unsigned char *s =
(unsigned char*)alloca(sizeof(unsigned char) * _commandDataLength);
d.getOctets(s, _commandDataLength);
}
string SMSCommandMessage::encode()
{
SMSEncoder e;
e.setAddress(_serviceCentreAddress, true);
e.set2Bits(_messageTypeIndicator); // bits 0..1
e.setBit(); // bit 2
e.setBit(); // bit 3
e.setBit(); // bit 4
e.setBit(_statusReportRequest); // bit 5
e.setOctet(_messageReference);
e.setOctet(_protocolIdentifier);
e.setOctet(_commandType);
e.setOctet(_messageNumber);
e.setAddress(_destinationAddress);
e.setOctet(_commandData.length());
e.setOctets((const unsigned char*)_commandData.data(),
(short unsigned int)_commandData.length());
return e.getHexString();
}
string SMSCommandMessage::toString() const
{
ostrstream os;
os << dashes << endl
<< _("Message type: SMS-COMMAND") << endl
<< _("SC address: '") << _serviceCentreAddress._number << "'" << endl
<< _("Message reference: ") << (unsigned int)_messageReference << endl
<< _("Status report request: ") << _statusReportRequest << endl
<< _("Protocol identifier: 0x") << hex
<< (unsigned int)_protocolIdentifier << dec << endl
<< _("Command type: 0x") << hex << (unsigned int)_commandType
<< dec << endl
<< _("Message number: ") << (unsigned int)_messageNumber << endl
<< _("Destination address: '") << _destinationAddress._number
<< "'" << endl
<< _("Command data length: ") << (unsigned int)_commandDataLength << endl
<< _("Command data: '") << _commandData << "'" << endl
<< dashes << endl << endl
<< ends;
char *ss = os.str();
string result(ss);
delete[] ss;
return result;
}
Address SMSCommandMessage::address() const
{
return _destinationAddress;
}
Ref<SMSMessage> SMSCommandMessage::clone()
{
Ref<SMSMessage> result = new SMSCommandMessage(*this);
return result;
}
// SMSDeliverReportMessage members
void SMSDeliverReportMessage::init()
{
_messageTypeIndicator = SMS_DELIVER_REPORT;
_protocolIdentifierPresent = false;
_dataCodingSchemePresent = false;
_userDataLengthPresent = false;
}
SMSDeliverReportMessage::SMSDeliverReportMessage(string pdu)
throw(GsmException)
{
SMSDecoder d(pdu);
_serviceCentreAddress = d.getAddress(true);
_messageTypeIndicator = (MessageType)d.get2Bits(); // bits 0..1
assert(_messageTypeIndicator == SMS_DELIVER_REPORT);
d.alignOctet(); // skip to parameter indicator
_protocolIdentifierPresent = d.getBit(); // bit 0
_dataCodingSchemePresent = d.getBit(); // bit 1
_userDataLengthPresent = d.getBit(); // bit 2
if (_protocolIdentifierPresent)
_protocolIdentifier = d.getOctet();
if (_dataCodingSchemePresent)
_dataCodingScheme = d.getOctet();
if (_userDataLengthPresent)
{
unsigned char userDataLength = d.getOctet();
d.markSeptet();
if (_dataCodingScheme.getAlphabet() == DCS_DEFAULT_ALPHABET)
{
_userData = d.getString(userDataLength);
_userData = gsmToLatin1(_userData);
}
else
{ // userDataLength is length in octets
unsigned char *s =
(unsigned char*)alloca(sizeof(unsigned char) * userDataLength);
d.getOctets(s, userDataLength);
_userData.assign((char*)s, userDataLength);
}
}
}
string SMSDeliverReportMessage::encode()
{
SMSEncoder e;
e.setAddress(_serviceCentreAddress, true);
e.set2Bits(_messageTypeIndicator); // bits 0..1
e.alignOctet(); // skip to parameter indicator
e.setBit(_protocolIdentifierPresent); // bit 0
e.setBit(_dataCodingSchemePresent); // bit 1
e.setBit(_userDataLengthPresent); // bit 2
if (_protocolIdentifierPresent)
e.setOctet(_protocolIdentifier);
if (_dataCodingSchemePresent)
e.setOctet(_dataCodingScheme);
if (_userDataLengthPresent)
{
unsigned char userDataLength = _userData.length();
e.setOctet(userDataLength);
if (_dataCodingScheme.getAlphabet() == DCS_DEFAULT_ALPHABET)
e.setString(latin1ToGsm(_userData));
else
e.setOctets((unsigned char*)_userData.data(), userDataLength);
}
return e.getHexString();
}
string SMSDeliverReportMessage::toString() const
{
ostrstream os;
os << dashes << endl
<< _("Message type: SMS-DELIVER-REPORT") << endl
<< _("SC address: '") << _serviceCentreAddress._number << "'" << endl
<< _("Protocol identifier present: ") << _protocolIdentifierPresent
<< endl
<< _("Data coding scheme present: ") << _dataCodingSchemePresent << endl
<< _("User data length present: ") << _userDataLengthPresent << endl;
if (_protocolIdentifierPresent)
os << _("Protocol identifier: 0x") << hex
<< (unsigned int)_protocolIdentifier
<< dec << endl;
if (_dataCodingSchemePresent)
os << _("Data coding scheme: ") << _dataCodingScheme.toString() << endl;
if (_userDataLengthPresent)
os << _("User data length: ") << (int)userDataLength() << endl
<< _("User data: '") << _userData << "'" << endl;
os << dashes << endl << endl
<< ends;
char *ss = os.str();
string result(ss);
delete[] ss;
return result;
}
Address SMSDeliverReportMessage::address() const
{
assert(0); // not address, should not be in SMS store
return Address();
}
Ref<SMSMessage> SMSDeliverReportMessage::clone()
{
Ref<SMSMessage> result = new SMSDeliverReportMessage(*this);
return result;
}
// SMSSubmitReportMessage members
void SMSSubmitReportMessage::init()
{
_messageTypeIndicator = SMS_SUBMIT_REPORT;
_protocolIdentifierPresent = false;
_dataCodingSchemePresent = false;
_userDataLengthPresent = false;
}
SMSSubmitReportMessage::SMSSubmitReportMessage(string pdu) throw(GsmException)
{
SMSDecoder d(pdu);
_serviceCentreAddress = d.getAddress(true);
_messageTypeIndicator = (MessageType)d.get2Bits(); // bits 0..1
assert(_messageTypeIndicator == SMS_SUBMIT_REPORT);
_serviceCentreTimestamp = d.getTimestamp();
_protocolIdentifierPresent = d.getBit(); // bit 0
_dataCodingSchemePresent = d.getBit(); // bit 1
_userDataLengthPresent = d.getBit(); // bit 2
if (_protocolIdentifierPresent)
_protocolIdentifier = d.getOctet();
if (_dataCodingSchemePresent)
_dataCodingScheme = d.getOctet();
if (_userDataLengthPresent)
{
unsigned char userDataLength = d.getOctet();
d.markSeptet();
if (_dataCodingScheme.getAlphabet() == DCS_DEFAULT_ALPHABET)
{
_userData = d.getString(userDataLength);
_userData = gsmToLatin1(_userData);
}
else
{ // _userDataLength is length in octets
unsigned char *s =
(unsigned char*)alloca(sizeof(unsigned char) * userDataLength);
d.getOctets(s, userDataLength);
_userData.assign((char*)s, userDataLength);
}
}
}
string SMSSubmitReportMessage::encode()
{
SMSEncoder e;
e.setAddress(_serviceCentreAddress, true);
e.set2Bits(_messageTypeIndicator); // bits 0..1
e.setTimestamp(_serviceCentreTimestamp);
e.setBit(_protocolIdentifierPresent); // bit 0
e.setBit(_dataCodingSchemePresent); // bit 1
e.setBit(_userDataLengthPresent); // bit 2
if (_protocolIdentifierPresent)
e.setOctet(_protocolIdentifier);
if (_dataCodingSchemePresent)
e.setOctet(_dataCodingScheme);
if (_userDataLengthPresent)
{
e.setOctet(userDataLength());
if (_dataCodingScheme.getAlphabet() == DCS_DEFAULT_ALPHABET)
e.setString(latin1ToGsm(_userData));
else
e.setOctets((unsigned char*)_userData.data(), _userData.length());
}
return e.getHexString();
}
string SMSSubmitReportMessage::toString() const
{
ostrstream os;
os << dashes << endl
<< _("Message type: SMS-SUBMIT-REPORT") << endl
<< _("SC address: '") << _serviceCentreAddress._number << "'" << endl
<< _("SC timestamp: ") << _serviceCentreTimestamp.toString() << endl
<< _("Protocol identifier present: ") << _protocolIdentifierPresent
<< endl
<< _("Data coding scheme present: ") << _dataCodingSchemePresent << endl
<< _("User data length present: ") << _userDataLengthPresent << endl;
if (_protocolIdentifierPresent)
os << _("Protocol identifier: 0x") << hex
<< (unsigned int)_protocolIdentifier
<< dec << endl;
if (_dataCodingSchemePresent)
os << _("Data coding scheme: ") << _dataCodingScheme.toString() << endl;
if (_userDataLengthPresent)
os << _("User data length: ") << (int)userDataLength() << endl
<< _("User data: '") << _userData << "'" << endl;
os << dashes << endl << endl
<< ends;
char *ss = os.str();
string result(ss);
delete[] ss;
return result;
}
Address SMSSubmitReportMessage::address() const
{
assert(0); // not address, should not be in SMS store
return Address();
}
Ref<SMSMessage> SMSSubmitReportMessage::clone()
{
Ref<SMSMessage> result = new SMSSubmitReportMessage(*this);
return result;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -