Пример #1
0
void LoginDialog::accept()
{
    if (m_client){
        if (m_bLogin){
            stopLogin();
        }else{
            startLogin();
            m_client->setPassword(passwords[0]->text());
            unsigned status = m_client->getStatus();
            if (status  == STATUS_OFFLINE)
                status = STATUS_ONLINE;
            m_client->setStatus(status, m_client->getCommonStatus());
        }
        return;
    }
    LoginDialogBase::accept();
}
Пример #2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);


    m_pOAuth2 = new OAuth2(this);
    m_API_key = m_pOAuth2->getSimpleAPIKey();

    connect(m_pOAuth2, SIGNAL(loginDone()), this, SLOT(loginDone()));


    m_managerPrediction.setAPIKey(m_API_key);

    connect(&m_managerPrediction, SIGNAL(replyText(QString)), this, SLOT(addReplyText(QString)));
    connect(&m_managerPrediction, SIGNAL(recvModelsList(QVariantList)), this, SLOT(recvModelsList(QVariantList)));
    connect(&m_managerPrediction, SIGNAL(recvModelDescription(QVariant)), this, SLOT(recvModelDescription(QVariant)));
    connect(&m_managerPrediction, SIGNAL(recvPredictionResult(QVariant)), this, SLOT(recvPredictionResult(QVariant)));
    connect(&m_managerPrediction, SIGNAL(recvAddToModelComplete(bool)), this, SLOT(recvAddToModelComplete(bool)));

    connect(ui->lwModelsList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedModelChanged()));

    connect(ui->actionDeleteModel, SIGNAL(triggered()), this, SLOT(deleteModel()));
    connect(ui->actionNewModel, SIGNAL(triggered()), this, SLOT(newModel()));
    connect(ui->actionUpdateModelsList, SIGNAL(triggered()), this, SLOT(updateModelsList()));
    connect(ui->actionUpdateModelInfo, SIGNAL(triggered()), this, SLOT(updateModelInfo()));
    connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->predictButton, SIGNAL(clicked()), this, SLOT(predict()));


    connect(ui->lineEditTextToPredict, SIGNAL(returnPressed()), this, SLOT(predict()));
    connect(ui->actionLogin, SIGNAL(triggered()), this, SLOT(login()));

    connect(&timerTest, SIGNAL(timeout()), this, SLOT(testSendRequest()));

    startLogin(false);
}
Пример #3
0
void LoginDialog::accept()
{
    if (m_bLogin){
        stopLogin();
        return;
    }

    if (m_client){
        startLogin();
        QString prev = m_client->getPreviousPassword();
        if (prev.isEmpty())
            m_client->setPreviousPassword(m_client->getPassword());
        m_client->setPassword(passwords[0]->text());
        unsigned status = m_client->getStatus();
        if (status == STATUS_OFFLINE)
            status = STATUS_ONLINE;
        m_client->setStatus(status, m_client->getCommonStatus());
        LoginDialogBase::accept();
        return;
    }

    getContacts()->clearClients();
    int n = cmbProfile->currentItem();
    if ((n < 0) || (n >= cmbProfile->count() - 1)){
        CorePlugin::m_plugin->setSavePasswd(chkSave->isChecked());
        CorePlugin::m_plugin->setNoShow(chkNoShow->isChecked());
        CorePlugin::m_plugin->setProfile(NULL);
        CorePlugin::m_plugin->changeProfile();
        LoginDialogBase::accept();
        return;
    }

    CorePlugin::m_plugin->setProfile(CorePlugin::m_plugin->m_profiles[n].c_str());
    if (m_profile != CorePlugin::m_plugin->getProfile()){
        CorePlugin::m_plugin->changeProfile();
        m_bProfileChanged = true;
    }

    CorePlugin::m_plugin->setSavePasswd(chkSave->isChecked());
    CorePlugin::m_plugin->setNoShow(chkNoShow->isChecked());

    ClientList clients;
    CorePlugin::m_plugin->loadClients(clients);
    clients.addToContacts();
    getContacts()->load();

    m_bLogin = false;
    for (unsigned i = 0; i < passwords.size(); i++){
        Client *client = getContacts()->getClient(i);
        client->setSavePassword(chkSave->isChecked());
        QString pswd = client->getPassword();
        QString new_pswd = passwords[i]->text();
        if (pswd != new_pswd){
            QString prev = client->getPreviousPassword();
            if (!prev.isEmpty())
                client->setPreviousPassword(pswd);
            client->setPassword(new_pswd);
            m_bLogin = true;
        }
    }
    if (m_bLogin){
        startLogin();
        for (unsigned i = 0; i < passwords.size(); i++){
            Client *client = getContacts()->getClient(i);
            unsigned status = client->getStatus();
            if (status == STATUS_OFFLINE)
                status = STATUS_ONLINE;
            client->setStatus(status, client->getCommonStatus());
        }
        return;
    }
    LoginDialogBase::accept();
}
Пример #4
0
/*--------------------------------------------------------------------------------------
 * Purpose: the main function of login control module
 *  listens for cli connections and starts new thread for each connection 
 * Input:  none
 * Output: none
 * Kevin Burnett @ November 18, 2008
 * -------------------------------------------------------------------------------------*/
void * loginControlThread( void *arg) {
	fd_set read_fds; 	// file descriptor list for select()
	int fdmax = 0;		// maximum file descriptor number
	int listenSocket = -1;	// socket to listen for connections

	// timer to periodically check thread status
	struct timeval timeout; 
	timeout.tv_usec = 0;
	timeout.tv_sec = THREAD_CHECK_INTERVAL; 

	log_msg( "Login control thread started." );
	
	// listen for connections and start other client threads as needed.
  	while ( LoginSettings.shutdown == FALSE ) 
	{
		// update the last active time for this thread
		LoginSettings.lastAction = time(NULL);

		// if socket is down, reopen
		if (listenSocket == - 1) 
		{
			listenSocket = startLoginControlListener();
			// if listen succeeded, setup FD values
			// otherwise we will try next loop time
			if (listenSocket != - 1) 
			{
				FD_ZERO( &read_fds );
				FD_SET(listenSocket, &read_fds);
				fdmax = listenSocket+1;
#ifdef DEBUG
				debug( __FUNCTION__, "Opened the login listening socket(%d)!! ", listenSocket );
#endif
			}
		}
		else
		{
			FD_ZERO( &read_fds );
			FD_SET(listenSocket, &read_fds);
			fdmax = listenSocket+1;
		}
#ifdef DEBUG
		debug( __FUNCTION__, "login control thread is enabled" );
#endif

		if( select(fdmax, &read_fds, NULL, NULL, &timeout) == -1 )
		{
			log_err("login control thread select error:%s", strerror(errno));
			continue;
		}
		timeout.tv_usec = 0;
		timeout.tv_sec = THREAD_CHECK_INTERVAL; 


		if( listenSocket >= 0)
		{
			if( FD_ISSET(listenSocket, &read_fds) )//new client
			{
#ifdef DEBUG
				debug( __FUNCTION__, "new client attempting to start." );
#endif
				startLogin( listenSocket );
			}
		}
	}
	
	log_warning( "Login control thread exiting" );	 
	
	// close socket if open
	if( listenSocket != -1) 
	{
		close(listenSocket);
		FD_ZERO( &read_fds );
		fdmax = 0;
		listenSocket = -1;			
#ifdef DEBUG
		debug( __FUNCTION__, "Close the login listening socket(%d)!! ", listenSocket );
#endif
	}
	
	return NULL;
}
Пример #5
0
void LoginDialog::accept()
{
    if (m_bLogin){
        stopLogin();
        return;
    }

    if (m_client){
        startLogin();
        QString prev = m_client->getPreviousPassword();
        if (prev.isEmpty())
            m_client->setPreviousPassword(m_client->getPassword());
        m_client->setPassword(passwords[0]->text());
        unsigned status = m_client->getStatus();
        if (status == STATUS_OFFLINE)
            status = STATUS_ONLINE;
        m_client->setStatus(status, m_client->getCommonStatus());
        LoginDialogBase::accept();
        return;
    }

    getContacts()->clearClients();
    int n = cmbProfile->currentItem();
    if ((n < 0) || (n >= cmbProfile->count() - 1)){
        CorePlugin::m_plugin->setSavePasswd(chkSave->isChecked());
        CorePlugin::m_plugin->setNoShow(chkNoShow->isChecked());
        CorePlugin::m_plugin->setProfile(NULL);
        CorePlugin::m_plugin->changeProfile();
        LoginDialogBase::accept();
        return;
    }

    CorePlugin::m_plugin->setProfile(CorePlugin::m_plugin->m_profiles[n].c_str());
    if (m_profile != CorePlugin::m_plugin->getProfile()){
        if (!CorePlugin::m_plugin->lockProfile(CorePlugin::m_plugin->m_profiles[n].c_str())){
            CorePlugin::m_plugin->setProfile(m_profile.c_str());
            BalloonMsg::message(i18n("Other instance of SIM use this profile"), buttonOk);
            return;
        }
        CorePlugin::m_plugin->changeProfile();
        m_bProfileChanged = true;
    }

    CorePlugin::m_plugin->setSavePasswd(chkSave->isChecked());
    CorePlugin::m_plugin->setNoShow(chkNoShow->isChecked());

    ClientList clients;
    CorePlugin::m_plugin->loadClients(clients);
    clients.addToContacts();
    getContacts()->load();

    m_bLogin = false;
    unsigned j = 0;
    for (unsigned i = 0; i < passwords.size(); i++){
        Client *client = NULL;
        while (j < getContacts()->nClients()){
            client = getContacts()->getClient(j++);
            if ((client->protocol()->description()->flags & PROTOCOL_NO_AUTH) == 0)
                break;
            client = NULL;
        }
        if (client == NULL)
            break;
        client->setSavePassword(chkSave->isChecked());
        QString pswd = client->getPassword();
        QString new_pswd = passwords[i]->text();
        if (pswd != new_pswd){
            QString prev = client->getPreviousPassword();
            if (!prev.isEmpty())
                client->setPreviousPassword(pswd);
            client->setPassword(new_pswd);
            m_bLogin = true;
        }
    }
    if (m_bLogin){
        startLogin();
        for (unsigned i = 0; i < passwords.size(); i++){
            Client *client = getContacts()->getClient(i);
            unsigned status = client->getStatus();
            if (status == STATUS_OFFLINE)
                status = STATUS_ONLINE;
            client->setStatus(status, client->getCommonStatus());
        }
        return;
    }
    LoginDialogBase::accept();
}
Пример #6
0
void MainWindow::login()
{
    startLogin(true);
}