显示标签为“Symbian”的博文。显示所有博文
显示标签为“Symbian”的博文。显示所有博文

2010年4月17日星期六

Using HMAC-SHA1 in qOAuth on Symbian

In the wake of qDou 0.2.5 release,I am working on Deploying qDou on Sybmain recently,But I am sorry about.........;-( I must admit I am a rookie on Symbian,irrespective Of  playing with Symbiam Os phone,or Development on Symbian Os.To take trial instance how scornful I was when using a 3250,I thought that it was just phone with colorful push buttons that can make happy noise and it was just a practical tools for accessing family,friends and business associats (maybe in the future,Because I am an undergraduate still now ).Upon a careful study these days,I learn a lot on Symbian development,really,Or at least To a rookie.When I look back,I just feel funny.So I change my mind.Symbian is Strong.
Back to the topic,becouse qDou release depends on qOAuth and oAuth request using the HMAC-SHA1 signature method.
On the Windows or linux,In order to do that
the following steps are
1. build OpenSSL 0.9.6+
2. build qca-2.0.0
3. build the qca plugin for OpenSSL (the Capabilities of qca-ossl contains HMAC_SHA1)?
4. build qOAuth
But on the Symbian,as a result of different platform,you will have a lot of work to do.
even though you achieved,Maybe It doesn't work at last and you will get into trouble when deploy your apps on Symbian.em.........There is a easy way,Look this.
How to generate oauth signature using HMAC-SHA1 in Symbian C++
Follow These Tips .
we just need to do little stuff
1.add macro Q_OS_SYMBIAN to remove anything about QCA from *.cpp or *.h in qOAuth when Precompiled
2.generating your own random number method to replace the following codes
QCA::InitializationVector iv( 16 );
QByteArray nonce = iv.toByteArray().toHex();
3.add these lines in function:createSignature
#ifdnef Q_OS_SYMBIAN
.....
.....
.....
#else 

CSHA1* sha=CSHA1::NewL();
TBuf8<100> keyVal;
keyVal.Copy(_L8(QByteArray(consumerSecret + "&" + tokenSecret).constData()));
CHMAC* hmac=CHMAC::NewL(keyVal,sha);
TBuf8<1024> baseString;
TPtrC8 hashedSig(hmac->Hash(baseString));
TImCodecB64 b64enc;
b64enc.Initialise();
HBufC8* buf = HBufC8::NewL(hashedSig.Length() * 2);
buf->Des().Copy(hashedSig);
TBuf8<512> result;
b64enc.Encode(buf->Des(),result);
result.Copy(result.Left(result.Length()));
if(hmac)
{
    delete hmac;
    hmac=NULL;
}
digest = QByteArray::fromRawData((char*)result.Ptr(),result.Length());
#endif
It's very easy right?
hope this is useful for thoses like me who want to use qOauth on Symbian
see you.

2010年1月28日星期四

When Qt for Window meets Qt for Symbian

Today,I install Qt libraries for Symbian again in my computer which has been installed Qt libraries for Windows.Of course,the version(4.6.1) is higher than last time. It reminds me of trouble that happened in the previous time.I just remember it’s a summer of last year.The situation is that every time I build the Symbian apps,the compiler displays a error that can't find bld.inf  and *.mmp .I google it and ask many people how to solve the problem.Later I find that the reason why miss there two important files is that compiler does not generate them.And How to.I didn’t know.So last time,I failed.But today,I make it.Look here,If the environment variable QMAKESPEC sets symbian-abld.It will be ok.It turns out that Qt for Symbian use symbian-abld not the value I set for Qt libraries for windows.
Like aamer4yu says:
"I dont know if you will read this post.. but just wanted to thank you a lot.. a ton of thanks..
I was not able to build qt projects for symbian...and was searching for a solution for almost a month"
A month to aamer4yu,half a year for me.
Why am I interested in Qt for Symbian suddenly?
The answer is QDou. :-)