Esempio n. 1
0
void AccessConfig::assign(const AccessConfig& s) {
    setUsername (s.getUsername() );
    setPassword (s.getPassword() );
    setSyncURL  (s.getSyncURL()  );
    setProxyHost(s.getProxyHost());
    setProxyPort(s.getProxyPort());
    setUserAgent(s.getUserAgent());

    setProxyUsername(s.getProxyUsername());
    setProxyPassword(s.getProxyPassword());
    setBeginSync(s.getBeginSync());
    setEndSync(s.getEndSync());
    setFirstTimeSyncMode(s.getFirstTimeSyncMode());

    setServerAuthRequired(s.getServerAuthRequired());
    setClientAuthType(s.getClientAuthType());
    setServerAuthType(s.getServerAuthType());
    setServerPWD(s.getServerPWD());
    setServerID(s.getServerID());
    setServerNonce(s.getServerNonce());
    setClientNonce(s.getClientNonce());
    setMaxMsgSize(s.getMaxMsgSize());
    setReadBufferSize(s.getReadBufferSize());
    setCheckConn(s.getCheckConn());
    setResponseTimeout(s.getResponseTimeout());
    setCompression(s.getCompression());

    dirty = s.getDirty();
}
Esempio n. 2
0
void GTcpSocket::setSpeed(qint64 in, qint64 out)
{
    inspeed = in;
    outspeed = out;

    lastSize = readBufferSize();
    if(inspeed*2 < readBufferSize())return;
    setReadBufferSize(in*2);
}
Esempio n. 3
0
void GTcpSocket::setDownSpeed(qint64 spd)
{

    inspeed = spd;

    if(inspeed*2 < readBufferSize())return;

    lastSize = readBufferSize();
    setReadBufferSize(inspeed*2);

}
Esempio n. 4
0
DkConnection::DkConnection(QObject* parent) : QTcpSocket(parent) {
	
	mNumBytesForCurrentDataType = -1;
	mIsGreetingMessageSent = false;	
	mIsSynchronizeMessageSent = false;
	connectionCreated = false;
	mSynchronizedTimer = new QTimer(this);

	connect(mSynchronizedTimer, SIGNAL(timeout()), this, SLOT(synchronizedTimerTimeout()));
	connect(this, SIGNAL(readyRead()), this, SLOT(processReadyRead()));

	setReadBufferSize(MaxBufferSize);
}
Esempio n. 5
0
BoxitSocket::BoxitSocket(int sessionID, QObject *parent) :
    QSslSocket(parent),
    sessionID(sessionID)
{
    setReadBufferSize(0);
    setPeerVerifyMode(QSslSocket::VerifyNone);

    readBlockSize = 0;
    readMSGID = 0;
    timeoutCount = 0;
    timeOutTimer.setInterval(5000);

    // Connect signals and slots
    connect(this, SIGNAL(readyRead())   ,   this, SLOT(readyReadData()));
    connect(this, SIGNAL(sslErrors(QList<QSslError>))   ,   this, SLOT(sslErrors(QList<QSslError>)));
    connect(this, SIGNAL(error(QAbstractSocket::SocketError))   ,   this, SLOT(socketError()));
    connect(&timeOutTimer, SIGNAL(timeout())    ,   this, SLOT(timeOutDestroy()));

    // Start timeout timer
    timeOutTimer.start();
}
Esempio n. 6
0
void GTcpSocket::transferAct()
{
    if(shedule_now)return; //если уже идет обмен с внешними буферами, то выходим
    if(!t_flag) return; //если флаг паузы, то выходим - не переносим ничего и никуда

    shedule_now = true; //устанавливаем признак выполнения данного метода
    int interval = 1000; //начальный интервал для подсчета лимита байт на скачивания/передачи

    if(this->state() != QAbstractSocket::ConnectedState && QSslSocket::bytesAvailable() == 0)
    {
        shedule_now = false;
        if(inbuf->size() > 0)emit readyToRead();
        return;
    } //если сокет был отсоединен и нету данных во внешнем буфеое, то выходим

    if(!watcher->isNull()) //если таймер запускается не впервые
        interval = qMin(watcher->elapsed(), interval);//то выбираем наименьшее между начальным значением и интервалом с момента прошлой передачи данных
    watcher->start();

    qint64 inLimit = (inspeed * interval)/1000; //высчитываем лимит приема/передачи
    qint64 outLimit = (outspeed * interval)/1000;
    if(outLimit == 0) outLimit = outbuf->size(); // если не утсновлено ограничение на отдачу, то передается все cодержимое выходного буфера

    qint64 bytesToRead;

    if(state() != QAbstractSocket::ConnectedState)
    {
        bytesToRead = QSslSocket::bytesAvailable();

        if(bytesToRead > 2097152 /*2MB*/)bytesToRead = 2097152;
    }
    else
    {
        bytesToRead = qMin<qint64>(inLimit, QSslSocket::bytesAvailable());
        if(QSslSocket::bytesAvailable() > 0) timeout->start();
        else if(timeout->elapsed() > timeout_interval*1000 && !timeout->isNull())
        {
            emit error(QSslSocket::SocketTimeoutError);
            close();
            shedule_now = false;
            return;
        }
    }
    qint64 bytesToWrite = qMin<qint64>(outLimit, outbuf->size());

    if(inspeed*2 < readBufferSize())
    {
        qint64 dif = QSslSocket::bytesAvailable() - inspeed*2;
        if(dif > 50) setReadBufferSize(readBufferSize()-50);
        else setReadBufferSize(readBufferSize()-dif);
    }

    if(inspeed != 0)
    {
        int old_size = inbuf->size();
        inbuf->resize(old_size + bytesToRead);
        QSslSocket::readData(inbuf->data() + old_size, bytesToRead);
    }
    QSslSocket::writeData(outbuf->data(), bytesToWrite);
    outbuf->remove(0, bytesToWrite);
    flush();

    shedule_now = false;
    if(bytesToRead > 0 && inspeed !=0 )emit readyToRead();
    else if (inspeed == 0 && QSslSocket::bytesAvailable()!= 0) emit readyToRead();
}