Ejemplo n.º 1
0
void SendImgJob::run()
{
    QString send_url;
    QString host;
    if (  sendimg_type_ == kOffpic )
    {
        send_url = "/ftn_access/upload_offline_pic?time=" + QString::number(QDateTime::currentMSecsSinceEpoch());
;
        host = "weboffline.ftn.qq.com";
    }
    else if ( sendimg_type_ == kGroupImg )
    {
        send_url = "/cgi-bin/cface_upload?time=" + QString::number(QDateTime::currentMSecsSinceEpoch());
;
        host = "up.web2.qq.com";
    }

    QHttpRequestHeader header;

    header.setRequest("POST", send_url);
    header.addValue("Host", host);
    header.addValue("Content-Length", QString::number(data_.length()));
    header.addValue("Cache-Control", "max-age=0");
    header.addValue("Origin", "http://web.qq.com");
    header.addValue("Content-Type", "multipart/form-data; boundary="+Protocol::QQProtocol::instance()->imgSender()->boundary());
    header.addValue("Referer", "http://web.qq.com/");
    header.addValue("Cookie", CaptchaInfo::instance()->cookie());

    http_.setHost(host);
    http_.request(header, data_);
}
Ejemplo n.º 2
0
QString Protocol::MsgSender::getGroupSig(QString gid, QString to_id)
{
    if ( group_sigs_.contains(gid+to_id) )
        return group_sigs_.value(gid+to_id);

    QString msg_sig_url = "/channel/get_c2cmsg_sig2?id="+ gid +"&to_uin=" + to_id +
        "&service_type=0&clientid=5412354841&psessionid=" + CaptchaInfo::instance()->psessionid() +"&t=" + QString::number(QDateTime::currentMSecsSinceEpoch());

    QHttpRequestHeader header;
    QString host = "d.web2.qq.com";
    header.setRequest("GET", msg_sig_url);
    header.addValue("Host", host);
    header.addValue("Content-Type", "utf-8");
    header.addValue("Referer", "http://d.web2.qq.com/proxy.html?v=20110331002");
    header.addValue("Cookie", CaptchaInfo::instance()->cookie());

    QTcpSocket fd;
    fd.connectToHost(host, 80);
    fd.write(header.toString().toAscii());

    QByteArray result;
    socketReceive(&fd, result);
    fd.close();

    int sig_s_idx = result.indexOf("value")+8;
    int sig_e_idx = result.indexOf('"', sig_s_idx);
    QString sig = result.mid(sig_s_idx, sig_e_idx - sig_s_idx);

    group_sigs_.insert(gid+to_id, sig);

    return sig;
}
Ejemplo n.º 3
0
void Translator::translate(const QString &text, const QString &language, QObject *sender) {
	qDebug() << "Translator::translate() " + text;

	Configuration *config = Configuration::getInstance();

	QUrl translatorUrl("http://ajax.googleapis.com/ajax/services/language/translate");
	QString request = "?v=1.0&q=" + QUrl::toPercentEncoding(text) + "&format=html&langpair=%7C" + language;

	QHttpRequestHeader header;
	header.setRequest("GET", translatorUrl.path() + request);
	header.setValue("Host", translatorUrl.host());
	header.setValue("Referer", "Qwit");

	if (config->useProxy) {
		http->setProxy(config->proxyAddress, config->proxyPort, config->proxyUsername, config->proxyPassword);
	} else {
		http->setProxy(QNetworkProxy(QNetworkProxy::NoProxy));
	}

	if(translatorUrl.toString().indexOf("https") == 0) {
		http->setHost(translatorUrl.host(), QHttp::ConnectionModeHttps, translatorUrl.port(443));
	} else {
		http->setHost(translatorUrl.host(), QHttp::ConnectionModeHttp, translatorUrl.port(80));
	}

	buffer = new QBuffer(this);
	buffer->open(QIODevice::WriteOnly);
	int requestId = http->request(header, 0, buffer);
	requestSender[requestId] = sender;
}
Ejemplo n.º 4
0
QByteArray TTSGoogle::CreateNewSound(QString text, QString voice, bool forceOverwrite)
{
	QEventLoop loop;

	if(!voiceList.contains(voice))
		voice = "fr";

	// Check (and create if needed) output folder
	QDir outputFolder = ttsFolder;
	if(!outputFolder.exists(voice))
		outputFolder.mkdir(voice);
	
	if(!outputFolder.cd(voice))
	{
		LogError(QString("Cant create TTS Folder : %1").arg(ttsFolder.absoluteFilePath(voice)));
		return QByteArray();
	}
	
	// Compute fileName
	QString fileName = QCryptographicHash::hash(text.toAscii(), QCryptographicHash::Md5).toHex().append(".mp3");
	QString filePath = outputFolder.absoluteFilePath(fileName);

	if(!forceOverwrite && QFile::exists(filePath))
		return ttsHTTPUrl.arg(voice, fileName).toAscii();

	// Fetch MP3
	QHttp http("translate.google.com");
	QObject::connect(&http, SIGNAL(done(bool)), &loop, SLOT(quit()));

	QByteArray ContentData;
	ContentData += "q=" + QUrl::toPercentEncoding(text) + "&tl=" + voice;

	QHttpRequestHeader Header;
	Header.addValue("Host", "translate.google.com");

	Header.setContentLength(ContentData.length());
	Header.setRequest("POST", "/translate_tts", 1, 1);

	http.request(Header, ContentData);
	loop.exec();

	QFile file(filePath);
	if (!file.open(QIODevice::WriteOnly))
	{
		LogError("Cannot open sound file for writing");
		return QByteArray();
	}
	file.write(http.readAll());
	file.close();
	return ttsHTTPUrl.arg(voice, fileName).toAscii();
}
Ejemplo n.º 5
0
void RefuseFileJob::run()
{
    QString send_url = "/channel/refuse_file2?to=%1&lcid=%2&clientid=5412354841&psessionid=%3&t=%4";
    QString host = "d.web2.qq.com";

    QHttpRequestHeader header;
    header.setRequest("GET", send_url.arg(to_id_).arg(session_id_).arg(CaptchaInfo::instance()->psessionid()).arg(QDateTime::currentMSecsSinceEpoch()));
    header.addValue("Host", host);
    header.addValue("Referer", "http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=2");
    header.addValue("Cookie", CaptchaInfo::instance()->cookie());

    http_.setHost(host);
    http_.request(header);
}
Ejemplo n.º 6
0
void HttpThread::run()
{
    QHttpRequestHeader header;
    header.setRequest("GET",url.path());
    header.setValue("Range","bytes="+QString::number(startByte)+"-"+QString::number(endByte));
    QString userAgent = "getit/0.1";
    header.setValue("Host", url.host());
    header.setValue("Accept", "*/*");
    header.setValue("User-Agent", userAgent);
    http.setHost(url.host());
    http.request(header);
    connect(&http,SIGNAL(readyRead(QHttpResponseHeader)),this,SLOT(writeToFile(QHttpResponseHeader)));
    connect(&http,SIGNAL(done(bool)),this,SLOT(finished(bool)));
    this->exec();
}
Ejemplo n.º 7
0
void SendMsgJob::sendMsg()
{
    QString send_url = getPath();
    QByteArray data = getData();

    QHttpRequestHeader header;
    header.setRequest("POST", send_url);
    header.addValue("Host", "d.web2.qq.com");
    header.addValue("Cookie", CaptchaInfo::instance()->cookie());
    header.addValue("Referer", "http://d.web2.qq.com/proxy.html?v=20110331002");
    header.addValue("Content-Length", QString::number(data.length()));
    header.addValue("Content-Type", "application/x-www-form-urlencoded");

    http_.setHost("d.web2.qq.com");
    http_.request(header, data);
}
Ejemplo n.º 8
0
	void HttpServer::handlePost(HttpClientHandler* hdlr,const QHttpRequestHeader & hdr,const QByteArray & data)
	{
		// this is either a file or a login
		if (hdr.value("Content-Type").startsWith("multipart/form-data"))
		{
			handleTorrentPost(hdlr,hdr,data);
		}
		else if (!checkLogin(hdr,data))
		{
			QHttpRequestHeader tmp = hdr;
			tmp.setRequest("GET","/login.html",1,1);
			handleGet(hdlr,tmp);
		}
		else
		{
			handleGet(hdlr,hdr,true);
		}
	}
static PyObject *meth_QHttpRequestHeader_setRequest(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
{
    PyObject *sipParseErr = NULL;

    {
        const QString* a0;
        int a0State = 0;
        const QString* a1;
        int a1State = 0;
        int a2 = 1;
        int a3 = 1;
        QHttpRequestHeader *sipCpp;

        static const char *sipKwdList[] = {
            NULL,
            NULL,
            sipName_major,
            sipName_minor,
        };

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, NULL, "BJ1J1|ii", &sipSelf, sipType_QHttpRequestHeader, &sipCpp, sipType_QString,&a0, &a0State, sipType_QString,&a1, &a1State, &a2, &a3))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->setRequest(*a0,*a1,a2,a3);
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast<QString *>(a0),sipType_QString,a0State);
            sipReleaseType(const_cast<QString *>(a1),sipType_QString,a1State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QHttpRequestHeader, sipName_setRequest, doc_QHttpRequestHeader_setRequest);

    return NULL;
}
Ejemplo n.º 10
0
QByteArray TTSAcapela::CreateNewSound(QString text, QString voice, bool forceOverwrite)
{
	QEventLoop loop;

	if(!voiceList.contains(voice))
		voice = "claire";

	// Check (and create if needed) output folder
	QDir outputFolder = ttsFolder;
	if(!outputFolder.exists(voice))
		outputFolder.mkdir(voice);
	
	if(!outputFolder.cd(voice))
	{
		LogError(QString("Cant create TTS Folder : %1").arg(ttsFolder.absoluteFilePath(voice)));
		return QByteArray();
	}
	
	// Compute fileName
	QString fileName = QCryptographicHash::hash(text.toAscii(), QCryptographicHash::Md5).toHex().append(".mp3");
	QString filePath = outputFolder.absoluteFilePath(fileName);

	if(!forceOverwrite && QFile::exists(filePath))
		return ttsHTTPUrl.arg(voice, fileName).toAscii();

	// Fetch MP3
	QHttp http("vaas3.acapela-group.com");
	QObject::connect(&http, SIGNAL(done(bool)), &loop, SLOT(quit()));

	QByteArray ContentData;
	ContentData += "client%5Ftext=" + QUrl::toPercentEncoding(text) + "&client%5Fvoice=" + voice + "22k&client%5Frequest%5Ftype=CREATE%5FREQUEST&client%5Fpassword=demo_web&client%5Flogin=asTTS&client%5Fversion=1%2D00&actionscript%5Fversion=3";

	QHttpRequestHeader Header;
	Header.addValue("Host", "vaas3.acapela-group.com");
	Header.addValue("User-Agent", "Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.0.1) Gecko/2008072820 Firefox/3.0.1");
	Header.addValue("Referer", "http://www.acapela-group.com/Flash/Demo_Web_AS3/demo_web.swf?path=http://vaas3.acapela-group.com/connector/1-20/&lang=FR");
	Header.addValue("Content-type", "application/x-www-form-urlencoded"); 
	Header.addValue("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
	Header.addValue("Accept-Language", "fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3");
	Header.addValue("Accept-Encoding", "gzip,deflate");
	Header.addValue("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
	Header.addValue("Keep-Alive", "300");
	Header.addValue("Connection", "keep-alive");

	Header.setContentLength(ContentData.length());
	Header.setRequest("POST", "/connector/1-20/textToMP3.php", 1, 1);

	http.request(Header, ContentData);
	loop.exec();
	QByteArray reponse = http.readAll();
	QUrl url("?"+reponse);
	if(url.hasQueryItem("retour_php"))
	{
		//LogDebug(QString("Acapela answer : %1").arg(QString(reponse)));
		QString acapelaFile = url.queryItemValue("retour_php");
		//LogInfo(QString("Downloading MP3 file : %1").arg(QString(acapelaFile)));
		http.get(acapelaFile);
		loop.exec();
		QFile file(filePath);
		if (!file.open(QIODevice::WriteOnly))
		{
			LogError("Cannot open sound file for writing");
			return QByteArray();
		}
		file.write(http.readAll());
		file.close();
		return ttsHTTPUrl.arg(voice, fileName).toAscii();
	}
	LogError("Acapela demo did not return a sound file");
	LogDebug(QString("Acapela answer : %1").arg(QString(reponse)));
	return QByteArray();
}