Example #1
0
void Utility::loginFinished(QNetworkReply *replys)
{
    if(replys->error() == QNetworkReply::NoError)
    {
        QString string=replys->readAll();
        QString cookie_temp = replys->rawHeader ("Set-Cookie");
        
        replys->manager ()->deleteLater ();//销毁这个对象
        emit loginOk (string, cookie_temp);
    }
}
Example #2
0
Weibo::Weibo(QObject *parent)
    :QObject(parent)
{
    mPut = new QPut(this);
    //connect(mPut, SIGNAL(ok(QString)), this, SIGNAL(ok()));
    connect(mPut, SIGNAL(fail(QString)), this, SIGNAL(error(QString)));
    connect(mPut, SIGNAL(fail(QString)), this, SLOT(dumpError(QString)));
    connect(mPut, SIGNAL(ok(QString)), this, SIGNAL(ok(QString)));
    connect(mPut, SIGNAL(ok(QString)), this, SLOT(dumpOk(QString)));
    connect(this, SIGNAL(loginOk()), SLOT(processNextRequest()), Qt::DirectConnection);
}
Example #3
0
//仅支持JPEG、GIF、PNG格式,图片大小小于5M
void Weibo::updateStatusWithPicture(const QString &status, const QString &fileName)
{
    mStatus = status;
    mFile = fileName;
    if (mAccessToken.isEmpty()) {
        qDebug("Not login.");
        connect(this, SIGNAL(loginOk()), SLOT(sendStatusWithPicture()));
        login();
        return;
    }
    sendStatusWithPicture();
}
Example #4
0
void Weibo::parseOAuth2ReplyData(const QString &data)
{
    static bool in = false;
    if (in)
        return;
    in = true;
    //{"access_token":"2.00xxxxD","remind_in":"4652955","expires_in":4652955,"uid":"12344"}
    QByteArray d(data.toUtf8());
    int i = d.indexOf("access_token");
    int p0 = d.indexOf(":", i) + 2;
    int p1 = d.indexOf("\"", p0);
    mAccessToken = d.mid(p0, p1 - p0);
    i = d.indexOf("uid");
    p0 = d.indexOf(":", i) + 2;
    p1 = d.indexOf("\"", p0);
    mUid = d.mid(p0, p1 - p0);
    qDebug("token=%s, uid=%s", mAccessToken.constData(), mUid.constData());

    disconnect(this, SLOT(parseOAuth2ReplyData(QString)));
    disconnect(this, SIGNAL(loginFail()));
    emit loginOk();
}
Example #5
0
	void setupUi(WeiboDialog *ui) {
		QObject::connect(api, SIGNAL(error(QString)), ui, SLOT(doError(QString)));
        QObject::connect(api, SIGNAL(loginOk()), ui, SLOT(loginDone()));
        ui->resize(qApp->desktop()->width()/2 - 11, qApp->desktop()->height() -22);
	}