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

Diff of /smsdaemon/Sms.cpp

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

revision 26 by torben, Mon Jun 9 18:15:53 2008 UTC revision 75 by torben, Fri Jun 13 10:10:06 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)
# Line 29  std::string GetSmsData(SMS& sms) Line 30  std::string GetSmsData(SMS& sms)
30                                    
31                  std::string data =  sms.message.substr(pos, sms.message.length()-pos );                  std::string data =  sms.message.substr(pos, sms.message.length()-pos );
32    
33                  while (data.at(0) == ' ')                  data = Util::str_trim(data);
                         data = data.substr(1, data.length() -1);  
34                  return data;                  return data;
35          }          }
36  }  }
# Line 65  SMS SMS::FromRawString(const std::string Line 65  SMS SMS::FromRawString(const std::string
65                  }                  }
66          }          }
67    
68          while(body.at(0) == ' ') //remove starting space from body          body = Util::str_trim(body);
                 body = body.substr( 1, body.length() -1);  
69    
70          SMS newsms;          SMS newsms;
71    
72          newsms.sms_index = fields[0];          newsms.sms_index = fields[0];
73    
74          newsms.sender = fields[2];          newsms.sender = fields[2];
75          Util::str_clean(&newsms.sender, "\"");          newsms.sender = Util::str_replace(newsms.sender, "\"");
76                    
77          newsms.timestamp = fields[4] + std::string(",") + fields[5];          newsms.timestamp = fields[4] + std::string(",") + fields[5];    
78          Util::str_clean(&newsms.timestamp, "\"");          newsms.timestamp = Util::str_replace(newsms.timestamp, "\"");
79    
80          newsms.message = body;          newsms.message = body;
81    
82          return newsms;          return newsms;
83  }  }
84    
85    SMS SMS::FromPduString(const std::string& input)
86    {
87            std::string smsline = input.substr(7, input.length() -7); //strip "+CMGL: "    
88    
89            std::vector<std::string> lines = Util::str_split(smsline, "\r\n");
90            std::vector<std::string> fields = Util::str_split(lines[0],",");
91    
92            SMS newsms = SmsPdu::ParseSmsPdu(lines[1]);
93    
94            newsms.sms_index = fields[0];
95    
96            return newsms;
97    }
98    
99    

Legend:
Removed from v.26  
changed lines
  Added in v.75

  ViewVC Help
Powered by ViewVC 1.1.20