步骤一:列举接入点
http://www.newlc.com/A-few-notes-about-the-CommDb.html
CCommsDatabase* CommDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
CleanupStack::PushL(CommDb);
CApSelect* ApSelect = CApSelect::NewLC(*CommDb, KEApIspTypeAll ,EApBearerTypeAll ,KEApSortUidAscending);
if (ApSelect->MoveToFirst())
{
do{
TUint uid = ApSelect->Uid();
//put here your IAP stuff
}while(ApSelect->MoveNext());
}
CleanupStack::PopAndDestroy(ApSelect);
CleanupStack::PopAndDestroy(CommDb);
步骤二:
//头文件
RHTTPSession iSession;
RHTTPTransaction iTransaction;
RConnection iConnection;
RSocketServ iSocketServ;
//构造中
User::LeaveIfError(iSocketServ.Connect());
User::LeaveIfError(iConnection.Open(iSocketServ));
iPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
iPref.SetIapId(IAPId);
iPref.SetBearerSet(KCommDbBearerPSD);
iPref.SetDirection(ECommDbConnectionDirectionOutgoing);
TInt ret;
if( ( ret = iConnection.Start(iPref)) != KErrNone)
{
//成功了
}
//打开会话成功
TRAPD(err, iSession.OpenL());
步骤三:将http绑定到指定SocketServ,在http Post中
http://www.forum.nokia.com/document/Forum_Nokia_Technical_Library/contents/FNTL/Using_the_HTTP_Client_API_with_RConnection.htm
User::LeaveIfError(iSocketServ.Connect());
User::LeaveIfError(iConnection.Open(iSocketServ));
iHttpSession.OpenL();
// Initiate connection
iConnection.Start(iStatus);
//...
RHTTPConnectionInfo connInfo = iHttpSession.ConnectionInfo();
RStringPool pool = iHttpSession.StringPool();
// Attach to socket server
connInfo.SetPropertyL(pool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal(iSocketServ.Handle()));
// Attach to connection
TInt connPtr = REINTERPRET_CAST(TInt, &iConnection);
connInfo.SetPropertyL(pool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), THTTPHdrVal(connPtr));
// Open transaction...
iHttpTrans = iHttpSession.OpenTransactionL(iUri, *this, pool.StringF(HTTP::EGET, RHTTPSession::GetTable()));
RHTTPHeaders hdr = iHttpTrans.Request().GetHeaderCollection();
http://www.newlc.com/A-few-notes-about-the-CommDb.html
CCommsDatabase* CommDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
CleanupStack::PushL(CommDb);
CApSelect* ApSelect = CApSelect::NewLC(*CommDb, KEApIspTypeAll ,EApBearerTypeAll ,KEApSortUidAscending);
if (ApSelect->MoveToFirst())
{
do{
TUint uid = ApSelect->Uid();
//put here your IAP stuff
}while(ApSelect->MoveNext());
}
CleanupStack::PopAndDestroy(ApSelect);
CleanupStack::PopAndDestroy(CommDb);
步骤二:
//头文件
RHTTPSession iSession;
RHTTPTransaction iTransaction;
RConnection iConnection;
RSocketServ iSocketServ;
//构造中
User::LeaveIfError(iSocketServ.Connect());
User::LeaveIfError(iConnection.Open(iSocketServ));
iPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
iPref.SetIapId(IAPId);
iPref.SetBearerSet(KCommDbBearerPSD);
iPref.SetDirection(ECommDbConnectionDirectionOutgoing);
TInt ret;
if( ( ret = iConnection.Start(iPref)) != KErrNone)
{
//成功了
}
//打开会话成功
TRAPD(err, iSession.OpenL());
步骤三:将http绑定到指定SocketServ,在http Post中
http://www.forum.nokia.com/document/Forum_Nokia_Technical_Library/contents/FNTL/Using_the_HTTP_Client_API_with_RConnection.htm
User::LeaveIfError(iSocketServ.Connect());
User::LeaveIfError(iConnection.Open(iSocketServ));
iHttpSession.OpenL();
// Initiate connection
iConnection.Start(iStatus);
//...
RHTTPConnectionInfo connInfo = iHttpSession.ConnectionInfo();
RStringPool pool = iHttpSession.StringPool();
// Attach to socket server
connInfo.SetPropertyL(pool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal(iSocketServ.Handle()));
// Attach to connection
TInt connPtr = REINTERPRET_CAST(TInt, &iConnection);
connInfo.SetPropertyL(pool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), THTTPHdrVal(connPtr));
// Open transaction...
iHttpTrans = iHttpSession.OpenTransactionL(iUri, *this, pool.StringF(HTTP::EGET, RHTTPSession::GetTable()));
RHTTPHeaders hdr = iHttpTrans.Request().GetHeaderCollection();