jce-manager/main/loginhandler.cpp
2014-06-19 02:44:46 +03:00

68 lines
1.6 KiB
C++

#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)
{
if (a == jceLogin::JCE_YOU_ARE_IN)
{
return true;
}
else if (a == jceLogin::ERROR_ON_VALIDATION)
{
popMessage("check your password");
usrnmEditPtr->setDisabled(false);
pswdEditPtr->setDisabled(false);
pswdEditPtr->selectAll();
pswdEditPtr->setFocus();
return false;
}
else if (a == jceLogin::ERROR_ON_OPEN_SOCKET)
{
popMessage("Please check your Internet status");
jceLog->closeAll();
return false;
}
else if (a == jceLogin::ERROR_ON_VALIDATION_USER_BLOCKED)
{
popMessage("You were blocked, please wait couple of minutes or contact JCE");
jceLog->closeAll();
return false;
}
}
return false;
}
void loginHandler::popMessage(QString message)
{
QMessageBox msgBox;
msgBox.setWindowTitle("Error");
msgBox.setText(message);
msgBox.exec();
msgBox.setFocus();
}