File: plus.cc

package info (click to toggle)
sms-pl 2.1.0-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 376 kB
  • ctags: 355
  • sloc: cpp: 2,618; perl: 109; makefile: 103; sh: 26
file content (44 lines) | stat: -rw-r--r-- 1,062 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "mr_pcre/mr_pcre.h"
#include "plus.h"

using namespace std;

PlusSMS::PlusSMS(Config &config) : GenericSMS(config)
{
	email = config["mailaddr"];
}

bool PlusSMS::Send(const std::string &phone_no, const std::string &message)
{
	bool ok = false;
	CURLcode status;
	Curl_Form form;

	while (true) {
		form.AddField("tprefix", phone_no.substr(3, 3));
		form.AddField("numer", phone_no.substr(6, 6));
		form.AddField("odkogo", email);
		form.AddField("tekst", message);
		form.AddField("dzien", "2003-01-30");
		form.AddField("godz", "12");
		form.AddField("min", "15");
		form.AddField("charno", "159");
		form.AddField("smsno", "1");

		status = curl.PerformPost("www.text.plusgsm.pl/sms/sendsms.php", form.PostFields());
		if (status) break;
		ok = curl.Body().find("Plus GSM - SMS zosta� wys�any") != string::npos;
		
		if (!ok) {
			PcreWrap::Array match;
			if (PcreWrap::pcre_match_all("<p class=\"font2\"> *([^\\.]*).*<P><HR>", 
				curl.Body(), "mis", match)) {
			   	throw Exception("[1] - " + match[0][0]);
			}
		}
		break;
	}
	
	return ok;
}