jce-manager/main/loginhandler.cpp

97 lines
2.4 KiB
C++
Raw Normal View History

2014-06-18 23:44:46 +00:00
#include "loginhandler.h"
loginHandler::loginHandler()
{
}
void loginHandler::setPointers(jceLogin *ptr,QLabel *statusLabelPtr,QLineEdit *pswdEditPtr,QLineEdit *usrnmEditPtr)
{
this->jceLog = ptr;
this->statusLabelPtr = statusLabelPtr;
this->pswdEditPtr = pswdEditPtr;
this->usrnmEditPtr = usrnmEditPtr;
}
bool loginHandler::makeConnection()
{
if (this->jceLog == NULL)
return false;
try
{
jceLog->makeConnection();
}
catch (jceLogin::jceStatus &a)
{
int status = (int)a;
switch (status)
{
case jceLogin::JCE_YOU_ARE_IN:
2014-06-18 23:44:46 +00:00
{
return true;
break;
2014-06-18 23:44:46 +00:00
}
case jceLogin::ERROR_ON_VALIDATION:
2014-06-18 23:44:46 +00:00
{
popMessage("Please Check Your Username & Password",false);
2014-06-18 23:44:46 +00:00
usrnmEditPtr->setDisabled(false);
pswdEditPtr->setDisabled(false);
pswdEditPtr->selectAll();
pswdEditPtr->setFocus();
return false;
}
case jceLogin::ERROR_ON_VALIDATION_USER_BLOCKED:
2014-06-18 23:44:46 +00:00
{
popMessage("You have been blocked by JCE, please try in a couple of minutes.");
2014-06-18 23:44:46 +00:00
jceLog->closeAll();
return false;
}
case jceLogin::ERROR_ON_OPEN_SOCKET:
2014-06-18 23:44:46 +00:00
{
popMessage("Please Check Your Internet Connection.");
jceLog->closeAll();
return false;
}
case jceLogin::JCE_NOT_CONNECTED:
{
jceLog->reConnect();
/*
* Fix: need to add promte window to ask user whenever he wants to reconnect or not
*/
break;
}
case jceLogin::ERROR_ON_GETTING_INFO:
{
popMessage("Recieve Request Time Out.");
jceLog->closeAll();
return false;
break;
}
case jceLogin::ERROR_ON_SEND_REQUEST:
{
popMessage("Send Request Time Out.");
2014-06-18 23:44:46 +00:00
jceLog->closeAll();
return false;
break;
}
2014-06-18 23:44:46 +00:00
}
}
return false;
}
void loginHandler::popMessage(QString message,bool addInfo)
2014-06-18 23:44:46 +00:00
{
if (addInfo)
message.append("\nIf this message appear without reason, please contact me at liranbg@gmail.com");
2014-06-18 23:44:46 +00:00
QMessageBox msgBox;
msgBox.setWindowTitle("Error");
msgBox.setText(message);
msgBox.exec();
msgBox.setFocus();
2014-06-18 23:44:46 +00:00
}