--- smsdaemon/Sms.cpp 2008/06/14 08:39:40 78 +++ smsdaemon/Sms.cpp 2008/12/07 15:51:02 142 @@ -8,23 +8,23 @@ -std::string GetSmsCommand(SMS& sms) +std::string SMS::ExtractCommand() { - unsigned int pos = sms.message.find(" "); + unsigned int pos = message.find(" "); std::string result; if (pos == std::string::npos) - result = sms.message; + result = message; else - result = sms.message.substr(0, pos); + result = message.substr(0, pos); return Util::str_trim(result); } -std::string GetSmsData(SMS& sms) +std::string SMS::ExtractParameters() { - unsigned int pos = sms.message.find(" "); + unsigned int pos = message.find(" "); if (pos == std::string::npos) return ""; @@ -32,7 +32,7 @@ { pos++; - std::string data = sms.message.substr(pos, sms.message.length()-pos ); + std::string data = message.substr(pos, message.length()-pos ); data = Util::str_trim(data); return data; @@ -43,61 +43,8 @@ { } -SMS::SMS(std::string _sender, std::string _message, std::string _timestamp) - : sender(_sender), message(_message), timestamp(_timestamp) +SMS::SMS(std::string _index, std::string _sender, std::string _message, std::string _timestamp) + : sms_index(_index), sender(_sender), message(_message), timestamp(_timestamp) { } -SMS SMS::FromRawString(const std::string& input) -{ - std::string smsline = input.substr(7, input.length() -7); //strip "+CMGL: " - - std::vector lines = Util::str_split(smsline, "\r\n"); - std::vector fields = Util::str_split(lines[0],","); - - std::string body; - for (unsigned i=1; i 0) - body += "\r\n"; - body += body_line; - } - } - - body = Util::str_trim(body); - - SMS newsms; - - newsms.sms_index = fields[0]; - - newsms.sender = fields[2]; - newsms.sender = Util::str_replace(newsms.sender, "\""); - - newsms.timestamp = fields[4] + std::string(",") + fields[5]; - newsms.timestamp = Util::str_replace(newsms.timestamp, "\""); - - newsms.message = body; - - return newsms; -} - -SMS SMS::FromPduString(const std::string& input) -{ - std::string smsline = input.substr(7, input.length() -7); //strip "+CMGL: " - - std::vector lines = Util::str_split(smsline, "\r\n"); - std::vector fields = Util::str_split(lines[0],","); - - SMS newsms = SmsPdu::ParseSmsPdu(lines[1]); - - newsms.sms_index = fields[0]; - - return newsms; -} - -