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
|
// The Class declaration of our Http Connection system
class Fetcher : public eWindow
{
// The temp file in which we will store the download data
eString tempPath;
// internal pointers and functions of download connection
eHTTPDataSource * createDownloadSink(eHTTPConnection *conn);
public:
Signal1<void,int> downloadDone;
void fetch();
};
// The Class declaration of our Main Window
class eBibleMainWindow: public eWindow
{
// the label to show the text
eLabel *label;
// the button to start connection
eButton *ok;
// the textinput
// flag to indicate the download state
int downloadDoneFlag;
int inDownloadFlag;
public:
// the constructor.
eBibleMainWindow();
// function to call when button is pushed
void Wconnect();
// function to call when download is completed.
void downloadDone(int er);
// the destructor.
~eBibleMainWindow();
};
eBibleMainWindow::eBibleMainWindow(): eWindow(1)
{
inDownloadFlag = 0;
// move our dialog to 100.100...
cmove(ePoint(100, 150));
// ...and give x and y dimensions.
cresize(eSize(460, 200));
// set a title.
setText("Server Activation Tool... By .:: ZEOS ::.");
// create a label to show a text.
label=new eLabel(this);
// give a position
label->move(ePoint(10, 30));
// set the label dimensions
label->resize(eSize(500, 480));
/// create textinput
mytext=new eTextInputField(this);
// give position
mytext->move(ePoint(160, 70));
// give size
mytext->resize(eSize(130, 40));
// set max number of characters
mytext->setMaxChars(13);
mytext->setUseableChars("1234567890");
//mytext->setText(codeentry);
// show a frame decoration
mytext->loadDeco();
// create button and set properties
k->move(ePoint((clientrect.width() - 140)/2, clientrect.height() - 60));
ok->resize(eSize(130, 40));
ok->setShortcut("green");
ok->setShortcutPixmap("green");
ok->loadDeco();
//set focus to textinput
setFocus(mytext);
// function to call when button is pushed
CONNECT(ok->selected, eBibleMainWindow::Wconnect);
}
void eBibleMainWindow::Wconnect()
{
// Set the flag that indicates we are in downlading status
if(!inDownloadFlag) {
inDownloadFlag = 1;
// Hide Label to change text
label->hide();
// Hide mytext to change text
mytext->hide();
ok->hide();
// Set new text for the label
label->setText(" \n\n Wait please connecting to server in progress...");
// Show the label with New Text
label->show();
// Function to call when donwload is complete
CONNECT(theFetcher.downloadDone, eBibleMainWindow::downloadDone);
// Set the flag indicates that we are starting connections
downloadDoneFlag = 0;
// Call function to start http connection
theFetcher.fetch();
}
}
void Fetcher::fetch()
{
// declare variable
eString url, code;
code = mytext->getText();
// assign to the variable the url we want to connect
url = http://www.host.com/activate.php"+code;
// assign to class variable the temporary file we will use to store the dowanloaded data
tempPath = "/var/tmp/bdemo.sh";
// inizialize the control error flag
int error = 0;
// start connection
// Show a Messagebox in case of connection error
if(!connectionP || error)
{ eMessageBox msg("Error... network connections (" + eString().sprintf("%d", error) + ")", _("Details"), eMessageBox::btOK);
msg.show(); msg.exec(); msg.hide();
}
else
{
//if the connection is estabilished start the download funcions
CONNECT(connectionP->transferDone, Fetcher::transferDone);
CONNECT(connectionP->createDataSource, Fetcher::createDownloadSink);
// set the user-agent name
connectionP->start();
}
}
|