Пример #1
1
void FileUploader::currentFailed() {
	Queue::iterator j = queue.find(uploading);
	if (j != queue.end()) {
		if (j->type() == PreparePhoto) {
			emit photoFailed(j.key());
		} else if (j->type() == PrepareDocument) {
			DocumentData *doc = App::document(j->id());
			if (doc->status == FileUploading) {
				doc->status = FileUploadFailed;
			}
			emit documentFailed(j.key());
		} else if (j->type() == PrepareAudio) {
			AudioData *audio = App::audio(j->id());
			if (audio->status == FileUploading) {
				audio->status = FileUploadFailed;
			}
			emit audioFailed(j.key());
		}
		queue.erase(j);
	}

	requestsSent.clear();
	docRequestsSent.clear();
	dcMap.clear();
	uploading = FullMsgId();
	sentSize = 0;
	for (int i = 0; i < MTPUploadSessionsCount; ++i) {
		sentSizes[i] = 0;
	}

	sendNext();
}
Пример #2
0
FileUploader::FileUploader() : sentSize(0), uploading(0) {
	memset(sentSizes, 0, sizeof(sentSizes));
	nextTimer.setSingleShot(true);
	connect(&nextTimer, SIGNAL(timeout()), this, SLOT(sendNext()));
	killSessionsTimer.setSingleShot(true);
	connect(&killSessionsTimer, SIGNAL(timeout()), this, SLOT(killSessions()));
}
Пример #3
0
  void Connection::sendPacket(Packet *packet) {
    packetQueue.enqueue(packet);

    if (packetQueue.size() == 1) {
      sendNext();
    }
  }
Пример #4
0
bool FileUploader::partFailed(const RPCError &err, mtpRequestId requestId) {
	if (requestsSent.constFind(requestId) != requestsSent.cend() || docRequestsSent.constFind(requestId) != docRequestsSent.cend()) { // failed to upload current file
		currentFailed();
	}
	sendNext();
	return true;
}
Пример #5
0
void FileUploader::currentFailed() {
	Queue::iterator j = queue.find(uploading);
	if (j != queue.end()) {
		if (j->media.type == ToPreparePhoto) {
			emit photoFailed(j.key());
		} else if (j->media.type == ToPrepareDocument) {
			DocumentData *doc = App::document(j->media.id);
			if (doc->status == FileUploading) {
				doc->status = FileFailed;
			}
			emit documentFailed(j.key());
		}
		queue.erase(j);
	}

	requestsSent.clear();
	docRequestsSent.clear();
	dcMap.clear();
	uploading = 0;
	sentSize = 0;
	for (int i = 0; i < MTPUploadSessionsCount; ++i) {
		sentSizes[i] = 0;
	}

	sendNext();
}
Пример #6
0
 void Connection::init() {
   connect(this, SIGNAL(connected()), SLOT(handshake()));
   connect(this, SIGNAL(readyRead()), SLOT(onDataReady()));
   connect(this, SIGNAL(encrypted()), SLOT(onEncrypted()));
   connect(this, SIGNAL(sslErrors(const QList<QSslError>&)),
           SLOT(onSslErrors(const QList<QSslError>&)));
   connect(this, SIGNAL(bytesWritten(qint64)), SLOT(sendNext(qint64)));  
 }
Пример #7
0
bool FileUploader::partFailed(const RPCError &error, mtpRequestId requestId) {
    if (MTP::isDefaultHandledError(error)) return false;

    if (requestsSent.constFind(requestId) != requestsSent.cend() || docRequestsSent.constFind(requestId) != docRequestsSent.cend()) { // failed to upload current file
        currentFailed();
    }
    sendNext();
    return true;
}
Пример #8
0
bool FileUploader::partFailed(const RPCError &error, mtpRequestId requestId) {
	if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;

	if (requestsSent.constFind(requestId) != requestsSent.cend() || docRequestsSent.constFind(requestId) != docRequestsSent.cend()) { // failed to upload current file
		currentFailed();
	}
	sendNext();
	return true;
}
Пример #9
0
UniversalPana::UniversalPana(KInstance *inst,QObject *parent,QWidget *widgetParent, QString &desktopName, const char* name):
                   KonqSidebarPlugin(inst,parent,widgetParent,desktopName,name)
{
    KGlobal::iconLoader()->addAppDir( "pana" );
    widget = new panaWidget( widgetParent );
//    widgetParent->resize(580,300);
    KToolBar *topBar = new KToolBar( widget, "Topbar" );
    topBar->setIconSize(16);
    topBar->insertButton( "today",    0, SIGNAL( clicked() ), this, SLOT( currentTrack() ) );
    topBar->insertButton( "document", 0, SIGNAL( clicked() ), this, SLOT( lyrics() ) );
    topBar->insertButton( "personal", 0, SIGNAL( clicked() ), this, SLOT( wiki() ) );

    browser = new KHTMLPart(widget, "widget-browser");
//browser=new KHTMLPart(widget);
    kdDebug() << "parentPart() << " << browser->parentPart() << endl;
    browser->setDNDEnabled( true );
    browser->setEncoding( "utf8", true );
    updateBrowser( HTML_FILE );
    browser->view()->installEventFilter( widget );
    panaDCOP = new DCOPClient();
    panaDCOP->attach();

    playerStub   = new PanaPlayerInterface_stub( panaDCOP, "pana", "player");
    playlistStub = new PanaPlaylistInterface_stub( panaDCOP, "pana", "playlist");
    contextStub = new PanaContextBrowserInterface_stub (panaDCOP, "pana", "contextbrowser");

    KToolBar* toolBar=new KToolBar(widget, "PlayerControls");

    toolBar->setIconSize(16);
    toolBar->insertButton( "player_start",0, SIGNAL( clicked() ), this, SLOT( sendPrev() ) );
    toolBar->insertButton( "player_play", 0, SIGNAL( clicked() ), this, SLOT( sendPlay() ) );
    toolBar->insertButton( "player_pause",0, SIGNAL( clicked() ), this, SLOT( sendPause() ) );
    toolBar->insertButton( "player_stop", 0, SIGNAL( clicked() ), this, SLOT( sendStop() ) );
    toolBar->insertButton( "player_end",  0, SIGNAL( clicked() ), this, SLOT( sendNext() ) );

    toolBar->insertSeparator();
    toolBar->insertButton( "arts",        0, SIGNAL( clicked() ), this, SLOT( sendMute() ) );

    vol_slider = new QSlider(0,100,1,0,Qt::Horizontal, toolBar,"volume");
    vol_slider->setLineStep(2);

    connect(vol_slider, SIGNAL( valueChanged(int) ), this, SLOT(volChanged(int ) ) );
    toolBar->insertWidget(1,2, vol_slider);

    fileInfo  = new QFileInfo(HTML_FILE);
    QTimer *t = new QTimer( this );

    connect( t, SIGNAL(timeout()), SLOT(updateStatus() ) );
    t->start( 2000, false );
    kdDebug() << "Connecting widget signal" << endl;

    connect( widget,                      SIGNAL( emitURL( const KURL &)),
             this,                        SLOT( openURLRequest( const KURL &) ) );
    connect( browser->browserExtension(), SIGNAL( openURLRequest( const KURL &, const KParts::URLArgs & ) ),
             this,                        SLOT( openURLRequest( const KURL & ) ) );
    widget->show();
}
OsagoBlankDataForm::OsagoBlankDataForm(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::OsagoBlankDataForm)
{
    ui->setupUi(this);
    connect(this->ui->nextButton, SIGNAL(clicked()), this, SLOT(sendNext()));
    connect(this->ui->prevPushButton, SIGNAL(clicked()), this, SIGNAL(prev()));
    connect(this->ui->nextButton, SIGNAL(clicked()), this, SLOT(fillData()));
    connect(this->ui->prevPushButton, SIGNAL(clicked()), this, SLOT(fillData()));
}
Пример #11
0
void FileUploader::partLoaded(const MTPBool &result, mtpRequestId requestId) {
	QMap<mtpRequestId, int32>::iterator j = docRequestsSent.end();
	QMap<mtpRequestId, QByteArray>::iterator i = requestsSent.find(requestId);
	if (i == requestsSent.cend()) {
		j = docRequestsSent.find(requestId);
	}
	if (i != requestsSent.cend() || j != docRequestsSent.cend()) {
		if (!result.v) { // failed to upload current file
			currentFailed();
			return;
		} else {
			QMap<mtpRequestId, int32>::iterator dcIt = dcMap.find(requestId);
			if (dcIt == dcMap.cend()) { // must not happen
				currentFailed();
				return;
			}
			int32 dc = dcIt.value();
			dcMap.erase(dcIt);

			Queue::const_iterator k = queue.constFind(uploading);
			if (i != requestsSent.cend()) {
				sentSize -= i.value().size();
				sentSizes[dc] -= i.value().size();
				requestsSent.erase(i);
			} else {
				sentSize -= k->docPartSize;
				sentSizes[dc] -= k->docPartSize;
				docRequestsSent.erase(j);
			}
			if (k->media.type == ToPreparePhoto) {
				emit photoProgress(k.key());
			} else if (k->media.type == ToPrepareDocument) {
				DocumentData *doc = App::document(k->media.id);
				if (doc->status == FileUploading) {
					doc->uploadOffset = (k->docSentParts - docRequestsSent.size()) * k->docPartSize;
					if (doc->uploadOffset > doc->size) {
						doc->uploadOffset = doc->size;
					}
				}
				emit documentProgress(k.key());
			} else if (k->media.type == ToPrepareAudio) {
				AudioData *audio = App::audio(k->media.id);
				if (audio->status == FileUploading) {
					audio->uploadOffset = (k->docSentParts - docRequestsSent.size()) * k->docPartSize;
					if (audio->uploadOffset > audio->size) {
						audio->uploadOffset = audio->size;
					}
				}
			}
		}
	}

	sendNext();
}
Пример #12
0
    void putChar(char c) {
        lock();

        if(TX_WAIT_ON_BUFFERFULL) {
            while(((txWritingPointer+1)%TX_BUFFERSIZE)==txSendingPointer) {
                sendNext();
            }
        }

        txBuffer[txWritingPointer]=c;
        txWritingPointer=(txWritingPointer+1)%TX_BUFFERSIZE;

        if(txWritingPointer==txSendingPointer) {
            txOverrunFlag=1;
        }

        sendNext();

        unlock();
    }
Пример #13
0
void FileUploader::partLoaded(const MTPBool &result, mtpRequestId requestId) {
    QMap<mtpRequestId, int32>::iterator j = docRequestsSent.end();
    QMap<mtpRequestId, QByteArray>::iterator i = requestsSent.find(requestId);
    if (i == requestsSent.cend()) {
        j = docRequestsSent.find(requestId);
    }
    if (i != requestsSent.cend() || j != docRequestsSent.cend()) {
        if (mtpIsFalse(result)) { // failed to upload current file
            currentFailed();
            return;
        } else {
            QMap<mtpRequestId, int32>::iterator dcIt = dcMap.find(requestId);
            if (dcIt == dcMap.cend()) { // must not happen
                currentFailed();
                return;
            }
            int32 dc = dcIt.value();
            dcMap.erase(dcIt);

            int32 sentPartSize = 0;
            Queue::const_iterator k = queue.constFind(uploading);
            if (i != requestsSent.cend()) {
                sentPartSize = i.value().size();
                requestsSent.erase(i);
            } else {
                sentPartSize = k->docPartSize;
                docRequestsSent.erase(j);
            }
            sentSize -= sentPartSize;
            sentSizes[dc] -= sentPartSize;
            if (k->type() == PreparePhoto) {
                k->fileSentSize += sentPartSize;
                PhotoData *photo = App::photo(k->id());
                if (photo->uploading() && k->file) {
                    photo->uploadingData->size = k->file->partssize;
                    photo->uploadingData->offset = k->fileSentSize;
                }
                emit photoProgress(k.key());
            } else if (k->type() == PrepareDocument || k->type() == PrepareAudio) {
                DocumentData *doc = App::document(k->id());
                if (doc->uploading()) {
                    doc->uploadOffset = (k->docSentParts - docRequestsSent.size()) * k->docPartSize;
                    if (doc->uploadOffset > doc->size) {
                        doc->uploadOffset = doc->size;
                    }
                }
                emit documentProgress(k.key());
            }
        }
    }

    sendNext();
}
Пример #14
0
void QxtSmtpPrivate::sendNext()
{
    if (state == Disconnected)
    {
        // leave the mail in the queue if not ready to send
        return;
    }

    if (pending.isEmpty())
    {
        // if there are no additional mails to send, finish up
        state = Waiting;
        emit qxt_p().finished();
        return;
    }

    if(state != Waiting) {
        state = Resetting;
        socket->write("rset\r\n");
        return;
    }
    const QxtMailMessage& msg = pending.first().second;
    rcptNumber = rcptAck = mailAck = 0;
    recipients = msg.recipients(QxtMailMessage::To) +
                 msg.recipients(QxtMailMessage::Cc) +
                 msg.recipients(QxtMailMessage::Bcc);
    if (recipients.count() == 0)
    {
        // can't send an e-mail with no recipients
        emit qxt_p().mailFailed(pending.first().first, QxtSmtp::NoRecipients );
        emit qxt_p().mailFailed(pending.first().first, QxtSmtp::NoRecipients, QByteArray( "e-mail has no recipients" ) );
        pending.removeFirst();
        sendNext();
        return;
    }
    // We explicitly use lowercase keywords because for some reason gmail
    // interprets any string starting with an uppercase R as a request
    // to renegotiate the SSL connection.
    socket->write("mail from:<" + qxt_extract_address(msg.sender()) + ">\r\n");
    if (extensions.contains("PIPELINING"))  // almost all do nowadays
    {
        foreach(const QString& rcpt, recipients)
        {
            socket->write("rcpt to:<" + qxt_extract_address(rcpt) + ">\r\n");
        }
Пример #15
0
void FileUploader::uploadMedia(MsgId msgId, const ReadyLocalMedia &media) {
	if (media.type == ToPreparePhoto) {
		App::feedPhoto(media.photo, media.photoThumbs);
	} else if (media.type == ToPrepareDocument) {
		DocumentData *document;
		if (media.photoThumbs.isEmpty()) {
			document = App::feedDocument(media.document);
		} else {
			document = App::feedDocument(media.document, media.photoThumbs.begin().value());
		}
		document->status = FileUploading;
		if (!media.file.isEmpty()) {
			document->location = FileLocation(mtpc_storage_filePartial, media.file);
		}
	}
	queue.insert(msgId, File(media));
	sendNext();
}
Пример #16
0
QxtSmtp::QxtSmtp(QObject* parent) : QObject(parent)
{
    QXT_INIT_PRIVATE(QxtSmtp);
    qxt_d().state = QxtSmtpPrivate::Disconnected;
    qxt_d().nextID = 0;
#ifndef QT_NO_OPENSSL
    qxt_d().socket = new QSslSocket(this);
    QObject::connect(socket(), SIGNAL(encrypted()), this, SIGNAL(encrypted()));
    //QObject::connect(socket(), SIGNAL(encrypted()), &qxt_d(), SLOT(ehlo()));
#else
    qxt_d().socket = new QTcpSocket(this);
#endif
    QObject::connect(socket(), SIGNAL(connected()), this, SIGNAL(connected()));
    QObject::connect(socket(), SIGNAL(disconnected()), this, SIGNAL(disconnected()));
    QObject::connect(socket(), SIGNAL(error(QAbstractSocket::SocketError)), &qxt_d(), SLOT(socketError(QAbstractSocket::SocketError)));
    QObject::connect(this, SIGNAL(authenticated()), &qxt_d(), SLOT(sendNext()));
    QObject::connect(socket(), SIGNAL(readyRead()), &qxt_d(), SLOT(socketRead()));
}
void spherebot::processAnswer(QString answer)
{
//    int linenumber = getOption(line,"N");
    //qDebug()<< "process answer: " << answer << endl;
    //qDebug()<< "buffer: " << toSendBuffer << endl;
    if(answer.contains("rs"))
    {
        resendLine();
    }
    else if (answer.contains("ok"))
    {
        //qDebug()<< "answer.contains(ok): "<< endl;
        lastLineTransmitted = true;
        timeout_timer->stop();

        if(toSendBuffer.size() > 0)
        {
            trySendBufferLine();
        }
        else if(sendingFile)
        {
            if( toSendBuffer.size() == 0 && lineCounter > lineMax)
            {
               emit fileTransmitted();
            }
            sendNext();
        }
        else
        {
            //everything sent
            retry_timer->stop();
        }
        emit dataSent(lastLine);
    }
    else if(answer.contains("Spherebot"))
    {
        //qDebug() << "received version" << endl;
        bot_connected = true;
    }
    else
    {
        //qDebug() << "answer did not contain rs or ok" << endl;
    }
}
Пример #18
0
void FileUploader::uploadMedia(MsgId msgId, const ReadyLocalMedia &media) {
	if (media.type == ToPreparePhoto) {
		App::feedPhoto(media.photo, media.photoThumbs);
	} else if (media.type == ToPrepareDocument) {
		DocumentData *document;
		if (media.photoThumbs.isEmpty()) {
			document = App::feedDocument(media.document);
		} else {
			document = App::feedDocument(media.document, media.photoThumbs.begin().value());
		}
		document->status = FileUploading;
		if (!media.file.isEmpty()) {
			document->fileName = media.file;
			document->modDate = QFileInfo(media.file).lastModified();
		}
	}
	queue.insert(msgId, File(media));
	sendNext();
}
Пример #19
0
void FileUploader::uploadMedia(const FullMsgId &msgId, const ReadyLocalMedia &media) {
    if (media.type == PreparePhoto) {
        App::feedPhoto(media.photo, media.photoThumbs);
    } else if (media.type == PrepareDocument || media.type == PrepareAudio) {
        DocumentData *document;
        if (media.photoThumbs.isEmpty()) {
            document = App::feedDocument(media.document);
        } else {
            document = App::feedDocument(media.document, media.photoThumbs.begin().value());
        }
        document->status = FileUploading;
        if (!media.data.isEmpty()) {
            document->setData(media.data);
        }
        if (!media.file.isEmpty()) {
            document->setLocation(FileLocation(StorageFilePartial, media.file));
        }
    }
    queue.insert(msgId, File(media));
    sendNext();
}
Пример #20
0
void FileUploader::upload(const FullMsgId &msgId, const FileLoadResultPtr &file) {
    if (file->type == PreparePhoto) {
        PhotoData *photo = App::feedPhoto(file->photo, file->photoThumbs);
        photo->uploadingData = new PhotoData::UploadingData(file->partssize);
    } else if (file->type == PrepareDocument || file->type == PrepareAudio) {
        DocumentData *document;
        if (file->thumb.isNull()) {
            document = App::feedDocument(file->document);
        } else {
            document = App::feedDocument(file->document, file->thumb);
        }
        document->status = FileUploading;
        if (!file->content.isEmpty()) {
            document->setData(file->content);
        }
        if (!file->filepath.isEmpty()) {
            document->setLocation(FileLocation(StorageFilePartial, file->filepath));
        }
    }
    queue.insert(msgId, File(file));
    sendNext();
}
Пример #21
0
void FileUploader::currentFailed() {
	Queue::iterator j = queue.find(uploading);
	if (j != queue.end()) {
		if (j->media.type == ToPreparePhoto) {
			emit photoFailed(j.key());
		} else if (j->media.type == ToPrepareDocument) {
			DocumentData *doc = App::document(j->media.id);
			if (doc->status == FileUploading) {
				doc->status = FileFailed;
			}
			emit documentFailed(j.key());
		}
		queue.erase(j);
	}

	requestsSent.clear();
	docRequestsSent.clear();
	queue.remove(uploading);
	uploading = 0;
	sentSize = 0;

	sendNext();
}
Пример #22
0
int WINAPI sendCallback(
  _In_       SOCKET s,
  _In_ const char   *buf,
  _In_       int    len,
  _In_       int    flags
)
{
	/// 웹 사이트 접속 차단
	if(TRUE == pRule->IsBlockAccessWebSite())
	{
		CString strHost = GetHostName(buf, len);
		if(TRUE == SearchStringFromFile(BLOCK_ACCESS_SITE_URL_TXT, strHost))
		{
			_TRACE(L"Block Site : %s", strHost);
			s = 0;
		}
	}

	/// 메일 본문을 남긴다.
	if(TRUE == pRule->IsLoggingMail() && pRule->IsLoggingContents())
		MakeLogContents(buf, len);

	return sendNext(s, buf, len, flags);
}
Пример #23
0
void txThread::run()
{
//    qDebug()<<"entering run";
    lineCounter = 0;
    sendNext();
}
Пример #24
0
void FileUploader::sendNext() {
	if (sentSize >= MaxUploadFileParallelSize) return;

	bool killing = killSessionsTimer.isActive();
	if (queue.isEmpty()) {
		if (!killing) {
			killSessionsTimer.start(MTPAckSendWaiting + MTPKillFileSessionTimeout);
		}
		return;
	}

	if (killing) {
		killSessionsTimer.stop();
	}
	Queue::iterator i = uploading ? queue.find(uploading) : queue.begin();
	if (!uploading) {
		uploading = i.key();
	} else if (i == queue.end()) {
		i = queue.begin(); 
		uploading = i.key();
	}
	int todc = 0;
	for (int dc = 1; dc < MTPUploadSessionsCount; ++dc) {
		if (sentSizes[dc] < sentSizes[todc]) {
			todc = dc;
		}
	}
	if (i->media.parts.isEmpty()) {
		if (i->docSentParts >= i->docPartsCount) {
			if (requestsSent.isEmpty() && docRequestsSent.isEmpty()) {
				if (i->media.type == ToPreparePhoto) {
					emit photoReady(uploading, MTP_inputFile(MTP_long(i->media.id), MTP_int(i->partsCount), MTP_string(i->media.filename), MTP_string(i->media.jpeg_md5)));
				} else if (i->media.type == ToPrepareDocument) {
					QByteArray docMd5(32, Qt::Uninitialized);
					hashMd5Hex(i->docHash.result(), docMd5.data());

					MTPInputFile doc = (i->docSize > UseBigFilesFrom) ? MTP_inputFileBig(MTP_long(i->media.id), MTP_int(i->docPartsCount), MTP_string(i->media.filename)) : MTP_inputFile(MTP_long(i->media.id), MTP_int(i->docPartsCount), MTP_string(i->media.filename), MTP_string(docMd5));
					if (i->partsCount) {
						emit thumbDocumentReady(uploading, doc, MTP_inputFile(MTP_long(i->media.thumbId), MTP_int(i->partsCount), MTP_string(qsl("thumb.") + i->media.thumbExt), MTP_string(i->media.jpeg_md5)));
					} else {
						emit documentReady(uploading, doc);
					}
				}
				queue.remove(uploading);
				uploading = 0;
				sendNext();
			}
			return;
		}

		QByteArray toSend;
		if (i->media.data.isEmpty()) {
			if (!i->docFile) {
				i->docFile.reset(new QFile(i->media.file));
				if (!i->docFile->open(QIODevice::ReadOnly)) {
					currentFailed();
					return;
				}
			}
			toSend = i->docFile->read(i->docPartSize);
			if (i->docSize <= UseBigFilesFrom) {
				i->docHash.feed(toSend.constData(), toSend.size());
			}
		} else {
			toSend = i->media.data.mid(i->docSentParts * i->docPartSize, i->docPartSize);
			if (i->media.type == ToPrepareDocument && i->docSentParts <= UseBigFilesFrom) {
				i->docHash.feed(toSend.constData(), toSend.size());
			}
		}
		if (toSend.size() > i->docPartSize || (toSend.size() < i->docPartSize && i->docSentParts + 1 != i->docPartsCount)) {
			currentFailed();
			return;
		}
		mtpRequestId requestId;
		if (i->docSize > UseBigFilesFrom) {
			requestId = MTP::send(MTPupload_SaveBigFilePart(MTP_long(i->media.id), MTP_int(i->docSentParts), MTP_int(i->docPartsCount), MTP_string(toSend)), rpcDone(&FileUploader::partLoaded), rpcFail(&FileUploader::partFailed), MTP::upl[todc]);
		} else {
			requestId = MTP::send(MTPupload_SaveFilePart(MTP_long(i->media.id), MTP_int(i->docSentParts), MTP_string(toSend)), rpcDone(&FileUploader::partLoaded), rpcFail(&FileUploader::partFailed), MTP::upl[todc]);
		}
		docRequestsSent.insert(requestId, i->docSentParts);
		dcMap.insert(requestId, todc);
		sentSize += i->docPartSize;
		sentSizes[todc] += i->docPartSize;

		i->docSentParts++;
	} else {
		LocalFileParts::iterator part = i->media.parts.begin();
	
		mtpRequestId requestId = MTP::send(MTPupload_SaveFilePart(MTP_long(i->media.thumbId), MTP_int(part.key()), MTP_string(part.value())), rpcDone(&FileUploader::partLoaded), rpcFail(&FileUploader::partFailed), MTP::upl[todc]);
		requestsSent.insert(requestId, part.value());
		dcMap.insert(requestId, todc);
		sentSize += part.value().size();
		sentSizes[todc] += part.value().size();

		i->media.parts.erase(part);
	}
	nextTimer.start(UploadRequestInterval);
}
Пример #25
0
void QxtSmtpPrivate::socketRead()
{
    buffer += socket->readAll();
    while (true)
    {
        int pos = buffer.indexOf("\r\n");
        if (pos < 0) return;
        QByteArray line = buffer.left(pos);
        buffer = buffer.mid(pos + 2);
        QByteArray code = line.left(3);
        switch (state)
        {
        case StartState:
            if (code[0] != '2')
            {
                socket->disconnectFromHost();
            }
            else
            {
                ehlo();
            }
            break;
        case HeloSent:
        case EhloSent:
        case EhloGreetReceived:
            parseEhlo(code, (line[3] != ' '), line.mid(4));
            break;
#ifndef QT_NO_OPENSSL
        case StartTLSSent:
            if (code == "220")
            {
                socket->startClientEncryption();
                ehlo();
            }
            else
            {
                authenticate();
            }
            break;
#endif
        case AuthRequestSent:
        case AuthUsernameSent:
            if (authType == AuthPlain) authPlain();
            else if (authType == AuthLogin) authLogin();
            else authCramMD5(line.mid(4));
            break;
        case AuthSent:
            if (code[0] == '2')
            {
                state = Authenticated;
                emit qxt_p().authenticated();
            }
            else
            {
                state = Disconnected;
                emit qxt_p().authenticationFailed();
                emit qxt_p().authenticationFailed( line );
                emit socket->disconnectFromHost();
            }
            break;
        case MailToSent:
        case RcptAckPending:
            if (code[0] != '2') {
                emit qxt_p().mailFailed( pending.first().first, code.toInt() );
                emit qxt_p().mailFailed(pending.first().first, code.toInt(), line);
				// pending.removeFirst();
				// DO NOT remove it, the body sent state needs this message to assigned the next mail failed message that will 
				// the sendNext 
				// a reset will be sent to clear things out
                sendNext();
                state = BodySent;
            }
            else
                sendNextRcpt(code, line);
            break;
        case SendingBody:
            sendBody(code, line);
            break;
        case BodySent:
			if ( pending.count() )
			{
				// if you removeFirst in RcpActpending/MailToSent on an error, and the queue is now empty, 
				// you will get into this state and then crash because no check is done.  CHeck added but shouldnt
				// be necessary since I commented out the removeFirst
				if (code[0] != '2')
				{
					emit qxt_p().mailFailed(pending.first().first, code.toInt() );
					emit qxt_p().mailFailed(pending.first().first, code.toInt(), line);
				}
				else
					emit qxt_p().mailSent(pending.first().first);
	            pending.removeFirst();
			}
            sendNext();
            break;
        case Resetting:
            if (code[0] != '2') {
                emit qxt_p().connectionFailed();
                emit qxt_p().connectionFailed( line );
            }
            else {
                state = Waiting;
                sendNext();
            }
            break;
        }
    }
}
Пример #26
0
void FileUploader::unpause() {
	_paused = FullMsgId();
	sendNext();
}
Пример #27
0
FileUploader::FileUploader() : sentSize(0), uploading(0) {
	nextTimer.setSingleShot(true);
	connect(&nextTimer, SIGNAL(timeout()), this, SLOT(sendNext()));
}