/[projects]/smsdaemon/Sms.cpp
ViewVC logotype

Diff of /smsdaemon/Sms.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 39 by torben, Tue Jun 10 20:28:42 2008 UTC revision 78 by torben, Sat Jun 14 08:39:40 2008 UTC
# Line 2  Line 2 
2  #include <string>  #include <string>
3  #include <vector>  #include <vector>
4    
 #include <iostream>  
5  #include "Sms.h"  #include "Sms.h"
6  #include "util.h"  #include "util.h"
7    #include "SmsPdu.h"
8    
9    
10    
11  std::string GetSmsCommand(SMS& sms)  std::string GetSmsCommand(SMS& sms)
12  {  {
13          unsigned int pos = sms.message.find(" ");          unsigned int pos = sms.message.find(" ");
14    
15            std::string result;
16    
17          if (pos == std::string::npos)          if (pos == std::string::npos)
18                  return sms.message;                  result =  sms.message;
19          else          else
20                  return sms.message.substr(0, pos);                  result = sms.message.substr(0, pos);
21    
22            return Util::str_trim(result);
23  }  }
24    
25  std::string GetSmsData(SMS& sms)  std::string GetSmsData(SMS& sms)
# Line 81  SMS SMS::FromRawString(const std::string Line 86  SMS SMS::FromRawString(const std::string
86          return newsms;          return newsms;
87  }  }
88    
89    SMS SMS::FromPduString(const std::string& input)
90    {
91            std::string smsline = input.substr(7, input.length() -7); //strip "+CMGL: "    
92    
93            std::vector<std::string> lines = Util::str_split(smsline, "\r\n");
94            std::vector<std::string> fields = Util::str_split(lines[0],",");
95    
96            SMS newsms = SmsPdu::ParseSmsPdu(lines[1]);
97    
98            newsms.sms_index = fields[0];
99    
100            return newsms;
101    }
102    
103    

Legend:
Removed from v.39  
changed lines
  Added in v.78

  ViewVC Help
Powered by ViewVC 1.1.20