--- smsdaemon/Sms.cpp 2008/06/10 20:25:15 38 +++ smsdaemon/Sms.cpp 2008/06/13 10:10:06 75 @@ -2,9 +2,10 @@ #include #include -#include #include "Sms.h" #include "util.h" +#include "SmsPdu.h" + std::string GetSmsCommand(SMS& sms) @@ -29,8 +30,7 @@ std::string data = sms.message.substr(pos, sms.message.length()-pos ); - while (data.at(0) == ' ') - data = data.substr(1, data.length() -1); + data = Util::str_trim(data); return data; } } @@ -65,8 +65,7 @@ } } - while(body.at(0) == ' ') //remove starting space from body - body = body.substr( 1, body.length() -1); + body = Util::str_trim(body); SMS newsms; @@ -83,3 +82,18 @@ 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; +} + +