8 |
#include <sstream> |
#include <sstream> |
9 |
|
|
10 |
#include <time.h> |
#include <time.h> |
11 |
#include <stdlib.h> |
#include <stdlib.h> |
12 |
|
|
13 |
#include "Logger.h" |
#include "Logger.h" |
14 |
#include "Util.h" |
#include "Util.h" |
29 |
string SwitchChars(string input) |
string SwitchChars(string input) |
30 |
{ |
{ |
31 |
for (unsigned int i=1; i<input.length(); i+=2) |
for (unsigned int i=1; i<input.length(); i+=2) |
32 |
{ |
{ |
33 |
char tmp = input[i]; |
char tmp = input[i]; |
34 |
input[i] = input[i-1]; |
input[i] = input[i-1]; |
35 |
input[i-1] = tmp; |
input[i-1] = tmp; |
188 |
pdu.insert( pdu.end(), phone.begin(), phone.end()); |
pdu.insert( pdu.end(), phone.begin(), phone.end()); |
189 |
|
|
190 |
pdu.push_back(0x00); // Protocol identifier |
pdu.push_back(0x00); // Protocol identifier |
191 |
pdu.push_back(0x00); // Data coding scheme |
pdu.push_back(0x00); // Data coding scheme |
192 |
|
|
193 |
int shift_start = 0; |
int shift_start = 0; |
194 |
string message_part; |
string message_part; |
281 |
|
|
282 |
std::list<SmsPart> partlist; |
std::list<SmsPart> partlist; |
283 |
typedef std::list<SmsPart>::iterator iterator; |
typedef std::list<SmsPart>::iterator iterator; |
284 |
|
|
285 |
SMS ConcatenateParts(SmsPart& part) |
SMS ConcatenateParts(SmsPart& part) |
286 |
{ |
{ |
287 |
SMS sms; |
SMS sms; |
288 |
if (part.group == -1) |
if (part.group == -1) |
289 |
{ |
{ |
290 |
sms.SetMessage(part.message); |
sms.SetMessage(part.message); |
291 |
sms.SetSender(part.sender); |
sms.SetSender(part.sender); |
292 |
} |
} |
293 |
else |
else |
294 |
{ |
{ |
295 |
partlist.push_back(part); |
partlist.push_back(part); |
296 |
|
|
297 |
vector<SmsPart> vec; |
vector<SmsPart> vec; |
298 |
for (iterator it=partlist.begin(); it!=partlist.end(); ++it) |
for (iterator it=partlist.begin(); it!=partlist.end(); ++it) |
299 |
{ |
{ |
335 |
|
|
336 |
void ParseUdh(vector<unsigned char>& udh, SmsPart& part) |
void ParseUdh(vector<unsigned char>& udh, SmsPart& part) |
337 |
{ |
{ |
338 |
if (udh.size() == 0) |
if (udh.size() == 0) |
339 |
{ |
{ |
340 |
Logger::logMessage("ParseUdh(): empty udh"); |
Logger::logMessage("ParseUdh(): empty udh"); |
341 |
return; |
return; |
342 |
} |
} |
343 |
|
|
344 |
if (udh[0] != 0) |
if (udh[0] != 0) |
345 |
{ |
{ |
346 |
Logger::logMessage("unknown UDH type"); |
Logger::logMessage("unknown UDH type"); |
347 |
return; |
return; |
348 |
} |
} |
349 |
|
|
350 |
if (udh.size() < 5) |
if (udh.size() < 5) |
351 |
{ |
{ |
352 |
Logger::logMessage("UDH to short to be multipart"); |
Logger::logMessage("UDH to short to be multipart"); |
353 |
return; |
return; |
354 |
} |
} |
355 |
|
|
356 |
part.group = udh[2]; |
part.group = udh[2]; |
357 |
part.count = udh[3]; |
part.count = udh[3]; |
358 |
part.id = udh[4]; |
part.id = udh[4]; |
398 |
|
|
399 |
if (UDHI) |
if (UDHI) |
400 |
{ |
{ |
401 |
int udh_len = (*it++); |
int udh_len = (*it++); |
402 |
|
|
403 |
vector<unsigned char> udh; |
vector<unsigned char> udh; |
404 |
for (int i=0; i<udh_len; i++) |
for (int i=0; i<udh_len; i++) |
415 |
|
|
416 |
vector<unsigned char> user_data; |
vector<unsigned char> user_data; |
417 |
user_data.insert(user_data.end(), it, it+data_len); |
user_data.insert(user_data.end(), it, it+data_len); |
418 |
|
|
419 |
string message = Decode8to7bit(user_data, shift_start).substr(0,data_len); |
string message = Decode8to7bit(user_data, shift_start).substr(0,data_len); |
420 |
|
|
421 |
message = Util::str_trim(message); |
message = Util::str_trim(message); |
422 |
|
|
423 |
|
|
424 |
part.message = message; |
part.message = message; |
425 |
part.sender = sender; |
part.sender = sender; |
426 |
|
|