Esempio n. 1
0
void
AsyncCDDBPLookup::doQuit()
{
    state_ = WaitingForQuitResponse;

    sendQuit();
}
/**
 * Отправка команды FTP-серверу.
 * 
 * @param command FTP-команда.
 * 
 * @return Флаг успешности выполнения (0 - не успешно, другое - успешно).
 */
int ProtocolInterpreter::sendCommand(string command) {
    int success;
    
    if (command == "USER") {
        success = sendUser();
    } else if (command == "PASS") {
        success = sendPass();
    } else if (command == "TYPE") {
        success = sendType();
    } else if (command == "MODE") {
        success = sendMode();
    } else if (command == "STRU") {
        success = sendStru();
    } else if (command == "PORT") {
        success = sendPort();
    } else if (command == "PASV") {
        success = sendPasv();
    } else if (command == "NLST") {
        success = sendNlst();
    } else if (command == "LIST") {
        success = sendList();
    } else if (command == "RETR") {
        success = sendRetr();
    } else if (command == "STOR") {
        success = sendStor();
    } else if (command == "RNTO") {
        success = sendRnto();
    } else if (command == "RNFR") {
        success = sendRnfr();
    } else if (command == "DELE") {
        success = sendDele();
    } else if (command == "MKD") {
        success = sendMkd();
    } else if (command == "RMD") {
        success = sendRmd();
    } else if (command == "CWD") {
        success = sendCwd();
    } else if (command == "CDUP") {
        success = sendCdup();
    } else if (command == "PWD") {
        success = sendPwd();
    } else if (command == "ABOR") {
        success = sendAbor();
    } else if (command == "REIN") {
        success = sendRein();
    } else if (command == "QUIT") {
        success = sendQuit();
    } else if (command == "SYST") {
        success = sendSyst();
    } else if (command == "STAT") {
        success = sendStat();
    } else if (command == "NOOP") {
        success = sendNoop();
    } else {
        service->printMessage(1, "Unknown command!");
    }
    
    return success;
}
Esempio n. 3
0
void initialisationReseau(char *strip,void (*backData)(Data*),void (*backList)(DataList*),void (*backGame)(DataGame*))
{

    mCData = backData;
    mCList= backList;
    mCGame= backGame;
    isQuitting=false;
    printf("initialisationReseau: test\n");
    if(isNetInitialised())
    {
        printf("initialisationReseau: réseau djà initialisé: libération des ressources\n");
        sendQuit();
        printf("Waiting for reception thread to reconnect\n");
        int threadReturnValue;
        SDL_WaitThread(threadRecept, &threadReturnValue);
        printf("\nThread returned value: %d\n", threadReturnValue);
        SDLNet_TCP_Close(sd);
    }
    else
    {
    if (SDLNet_Init() < 0)
    {
        printf("SDLNet_Init: %s\n", SDLNet_GetError());
        return;
    }
    bufferLock = SDL_CreateMutex();
    }
    /* Resolve the host we are connecting to */
    if (SDLNet_ResolveHost(&ip, strip, PORT) < 0)
    {
        printf("Can't resolve host: %s\n", SDLNet_GetError());
        return;
    }

    /* Open a connection with the IP provided (listen on the host's port) */
    if (!(sd = SDLNet_TCP_Open(&ip)))
    {
        printf("Can't open tcp connecting: %s\n", SDLNet_GetError());
        return;
    }


    if(!bufferLock)
    {
        printf("initialisationReseau: ERROR can't create mutex\n");
    }
    //canRecept = SDL_CreateCond();
    //canSend = SDL_CreateCond();
    networkinitialised = 1;
}
void LH_QtPlugin_WebKit::term()
{
    sendQuit();

    if(rssFeeds != NULL)
    {
        while( !rssFeeds->isEmpty() )
        {
            QString url = rssFeeds->keys().at(0);
            LH_RSSFeed* feed = rssFeeds->take(url);
            if( feed ) delete feed;
        }
        delete rssFeeds;
        rssFeeds = NULL;
    }

    LH_QtPlugin::term();
}
Esempio n. 5
0
void freeRessourcesReseau()
{
    if(networkinitialised!=1)
    {
        printf("freeRessourcesReseau: ERROR\n");
        return;
    }
    int threadReturnValue;
    sendQuit();
    printf("Waiting for reception thread\n");
    SDL_WaitThread(threadRecept, &threadReturnValue);
    printf("\nThread returned value: %d\n", threadReturnValue);
    SDLNet_TCP_Close(sd);
    SDL_DestroyMutex( bufferLock );
    //SDL_DestroyCond( canSend );
    //SDL_DestroyCond( canRecept );

    SDLNet_Quit();
    networkinitialised=0;
}
Esempio n. 6
0
void QtLearn::onClicked()
{
	static int cnt;

	emit sendQuit(++cnt);
}
Esempio n. 7
0
void QwwSmtpClientPrivate::processNextCommand(bool ok) {
    if (inProgress && !commandqueue.isEmpty()) {
        emit q->commandFinished(commandqueue.head().id, !ok);
        commandqueue.dequeue();
    }
    if (commandqueue.isEmpty()) {
        inProgress = false;
        emit q->done(false);
        return;
    }
    const SMTPCommand &cmd = commandqueue.head();
    switch (cmd.type) {
    case SMTPCommand::Connect: {
        QString hostName = cmd.data.toList().at(0).toString();
        uint port = cmd.data.toList().at(1).toUInt();
        bool ssl = cmd.data.toList().at(2).toBool();
        if(ssl){
            qDebug() << "SMTP ** connectToHostEncrypted";
            socket->connectToHostEncrypted(hostName, port);
        } else {
            qDebug() << "SMTP ** connectToHost";
            socket->connectToHost(hostName, port);
        }
        setState(QwwSmtpClient::Connecting);
    }
    break;
    case SMTPCommand::Disconnect: {
        sendQuit();
    }
    break;
    case SMTPCommand::StartTLS: {
        qDebug() << "SMTP >>> STARTTLS";
        socket->write("STARTTLS\r\n");
        setState(QwwSmtpClient::TLSRequested);
    }
    break;
    case SMTPCommand::Authenticate: {
        QwwSmtpClient::AuthMode authmode = (QwwSmtpClient::AuthMode)cmd.data.toList().at(0).toInt();
        switch (authmode) {
        case QwwSmtpClient::AuthPlain:
            qDebug() << "SMTP >>> AUTH PLAIN";
            socket->write("AUTH PLAIN\r\n");
            setState(QwwSmtpClient::Authenticating);
            break;
        case QwwSmtpClient::AuthLogin:
            qDebug() << "SMTP >>> AUTH LOGIN";
            socket->write("AUTH LOGIN\r\n");
            setState(QwwSmtpClient::Authenticating);
            break;
        default:
            qWarning("Unsupported or unknown authentication scheme");
            //processNextCommand(false);
        }
    }
    break;
    case SMTPCommand::Mail:
    case SMTPCommand::MailBurl:
    {
        setState(QwwSmtpClient::Sending);
        QByteArray buf = QByteArray("MAIL FROM:<").append(cmd.data.toList().at(0).toByteArray()).append(">\r\n");
        qDebug() << "SMTP >>>" << buf;
        socket->write(buf);
        break;
    }
    case SMTPCommand::RawCommand: {
	QString cont = cmd.data.toString();
	if(!cont.endsWith("\r\n")) cont.append("\r\n");
    setState(QwwSmtpClient::Sending);
    qDebug() << "SMTP >>>" << cont;
	socket->write(cont.toUtf8());
	} break;
    }
    inProgress = true;
    emit q->commandStarted(cmd.id);
}