-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
185 lines (133 loc) · 5.04 KB
/
mainwindow.cpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QSettings>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setWindowTitle("Smsapp");
ui->checkbox->setChecked(1);
ui->but->setStyleSheet("*{background-color:rgb(173, 255, 47);color:rgb(0,0,0)}");
connect(ui->developer,SIGNAL(triggered()),this,SLOT(developer()));
//ui->but->setEnabled(0);
QSettings settings("sat");
QString aValue = settings.value("akey","").toString();
ui->sender->setText(aValue);
QString aValu = settings.value("pas","").toString();
ui->password->setText(aValu);
QSettings settings1("path");
// the second argument to value is the default
// in case there hasn't been set a value in the settings yet
int index = settings1.value("def/comboBoxIndex", 0).toInt();
ui->box->setCurrentIndex(index);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_but_clicked()
{
if(ui->checkbox->isChecked())
{
QSettings settings("sat");
QString someValue=ui->sender->text();
settings.setValue("akey",someValue);
}
else
{
QSettings settings("sat");
QString someValue="";
settings.setValue("akey",someValue);
}
if(ui->checkbox->isChecked())
{
QSettings settings1("path");
settings1.setValue("def/comboBoxIndex", ui->box->currentIndex());
QSettings settings("sat");
QString pas=ui->password->text();
settings.setValue("pas",pas);
}
else
{
QSettings settings("sat");
QString pas="";
settings.setValue("pas",pas);
}
if(ui->sender->text()==""||ui->rcvr->text()==""||ui->password->text()=="")
{ ui->check->setText("<font color='red'><b>Fill All The Fields!!</b></font>");
ui->usernamelab->setStyleSheet("QLabel { background-color : red; color : blue; }");
ui->passlab->setStyleSheet("QLabel { background-color : red; color : blue; }");
ui->moblab->setStyleSheet("QLabel { background-color : red; color : blue; }");
}
else{ ui->status->setText("<font color='blue'><b>Please Wait...</b><font>");
ui->check->setText("");
ui->usernamelab->setStyleSheet("QLabel { color : blue; }");
ui->passlab->setStyleSheet("QLabel { color : blue; }");
ui->moblab->setStyleSheet("QLabel { color : blue; }");
QString message =ui->text->toPlainText();
QString mnum = ui->sender->text();
QString snum = ui->rcvr->text();
QString pass = ui->password->text();
QString pro;
//ui->but->setStyleSheet("*{background-color:rgb(118, 238 ,0);color:rgb(255,255,255)}");
if(ui->box->currentText()=="Indyarocks")
pro="indyarocks";
else if(ui->box->currentText()=="Fullonsms")
pro="fullonsms";
else
pro="Ultoo";
QString ur = "http://ubaid.tk/sms/sms.aspx?uid="+mnum+"&pwd="+pass+"&msg="+message+"&phone="+snum+"&provider="+pro;
first =QUrl(ur);
first.toEncoded();
QByteArray postData;
QString query =""; //"username="+mnum+"&password="+pass+"&userLogin=no&button=Login";
postData.append(query);
nam = new QNetworkAccessManager(this);
nam->setCookieJar(new QNetworkCookieJar(this));
//nam->setCookieJar(new QNetworkCookieJar(this));
req.setUrl(first);
//qDebug()<<req.url();
req.setHeader(QNetworkRequest::ContentTypeHeader,QVariant( "application/x-www-form-urlencoded"));
reply = nam->post(req, postData);
QEventLoop loop;
connect(reply, SIGNAL(finished()),&loop, SLOT(quit()));
loop.exec();
replyfinished1(reply);
qDebug()<<ur;
}
}
void MainWindow::replyfinished1(QNetworkReply *rep1)
{
ui->but->setText("Send Again");
QString stat=rep1->readAll();
if(stat=="1")
ui->status->setText("<font color='green'><b>Message Sent !!!</b></font>"); //here status is a label
else if (stat=="-4") {
ui->status->setText("<font color='red'><b>Login Failed :(</b></font>");
}
else if (stat=="-1")
ui->status->setText("<font color='red'><b>Server Error</b></font>");
else if (stat=="-2")
ui->status->setText("<font color='red'><b>Inalid Username</b></font>");
else if (stat=="-5")
ui->status->setText("<font color='red'><b>IP Blocked</b></font>");
else if (stat=="-11")
ui->status->setText("<font color='red'><b>Unsupported provider</b></font>");
}
void MainWindow::developer()
{
QWidget *devel = new QWidget;
QLabel *lab = new QLabel;
// QLabel *labb = new QLabel;
//labb->setIndent(50);
lab->setText("<p><b>Developed By:</b><br><b> RAJAT GUPTA</b><br><b>MIT Manipal</b><br>""<br><b>[email protected]</b><br><b><font color=\"white\">www.facebook.com/LUGManipal</font></b></p>");
//labb->setText("<img src='lug.jpg'>");
QVBoxLayout lay;
// lay.addWidget(labb);
lay.addWidget(lab);
devel->setLayout(&lay);
devel->setStyleSheet("*{background-color:rgb(10,125, 200 )}");
devel->setWindowTitle("LUG Manipal");
devel->show();
}