I want my http client to use the same network configuration as browser, can I do it?
I want my http client to use the same network configuration as browser, can I do it?
Refer RConnection for access point listings and how to avoid prompting IAP list to user. Explicitly set one IAP ID based on your requirement. I guess (even I may be wrong), If any application already using Internet and if that application keep the socket open, then the same connection is used for any other applications, as it maintains the same IP address for both the applications .
hope this helps !this code will pick the default (last used by browser) and use it without prompting
// open the IAP communications database
CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
CleanupStack::PushL(commDB);
// initialize a view
CCommsDbConnectionPrefTableView* commDBView =
commDB->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionUnknown);
// go to the first record
User::LeaveIfError(commDBView->GotoFirstRecord());
// Declare a prefTableView Object.
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
// read the connection preferences
commDBView->ReadConnectionPreferenceL(pref);
TUint32 iapID = pref.iBearer.iIapId;
// pop and destroy the IAP View
CleanupStack::PopAndDestroy(commDBView);
// pop and destroy the database object
CleanupStack::PopAndDestroy(commDB);
// Now we have the iap Id. Use it to connect for the connection.
// setup preferences
connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
connectPref.SetDirection(ECommDbConnectionDirectionUnknown);
connectPref.SetBearerSet(ECommDbBearerGPRS);
//Sets the CommDb ID of the IAP to use for this connection
connectPref.SetIapId(iapID);
User::LeaveIfError(iConnection.Start(connectPref));
Amit Kankani
Nokia Developer Champion
"this code will pick the default (last used by browser) and use it without prompting"----This statement is not correct. I changed used IAP of browser, but the iap got by your code was not changed.
what changes the rank of "OpenConnectionPrefTableInRankOrderLC"?
Amit,
Where did you get the code from? Its largely redundat and in some places even wrong.
First of all, getting the first IAP in the connection preferences table isn't going to help at all. The preferred IAP change as applications update it, its NOT just the browser.
Secondly, there's no reason why you'll need to do such an elaborate connection preferences setup!
// Now we have the iap Id. Use it to connect for the connection.
// setup preferences
connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
connectPref.SetDirection(ECommDbConnectionDirectionUnknown);
connectPref.SetBearerSet(ECommDbBearerGPRS);
//Sets the CommDb ID of the IAP to use for this connection
connectPref.SetIapId(iapID);
Just
connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
connectPref.SetIapId(iapID);
Should do. In fact by calling connectPref.SetBearerSet(ECommDbBearerGPRS); you are actually restricting the IAP selection to bearers of type GPRS only! What happens if the IAP is WLAN? Anyway, setting the bearer set won't have any effect in this case as an explicit IAP has already been specified.
Sigh...
daveice,
There two scenarios to consider for using the IAP being used by the browser.
First of all, the browser UI lets the user to specify an IAP OR prompt for an IAP every time the users connect.
In the latter case, how will you determine which IAP to use, since its already user selection dependent.
In the former case, there might be hope... the browser application just might store the IAP in use to some common location, which you might be able to retrive, however, I don't know enough about S60 to know that :-(
Hi maxxxpayne,
I just want to have the same configuration as local browser, if the browser setting changes, the IAP my app uses will change too.
The reason is that I don't want to write a dedicated UI to configure IAP in my app.
hey thanks for throwing some light on redundancies in the code
well may be this link can throw some more light:
http://wiki.forum.nokia.com/index.php/Default_iap
Well the logic written will pick the last IAP the user has selected when prompt by any other connection by any other app...
not too sure to read browser specific settings, but in most cases picking up default IAP is the best way. otherwise you got the ask for selection of IAP in your application and remember this selection in you app (one time ask) and also provide for settings to change this at a later point of time. This is what many apps do to avoid any conflict.
also this link from wiki may be of some help if you want to implement this:
http://wiki.forum.nokia.com/index.ph...oint_%28IAP%29
do correct me if wrong... after all, we all are here to learn![]()
Last edited by amitkankani; 2008-05-01 at 04:57.
Amit Kankani
Nokia Developer Champion
Still the same question, I dont know what changes the rank?
I did an interesting experiment: using amitkankani's code to get IAP of rank 1(in first record), say it is MyIAP1. Then I removed MyIAP1 from connection settings. Run the code again, it still get MyIAP1 in first record!! Obviously, it is not a valid one, connection establishing will fail and IAP selection dialog will pops up...
interesting !!!
well can you try another thing:
1. Go to browser and select an access point and make sure you are able to browse.
2. Now close the browser
3. Now delete this access point from the settings
4. Now open the browser and try to open the same page (probably after clearing the cache if needed)...
and let know the happenings...
Amit Kankani
Nokia Developer Champion
hello amit,
can i control the APN dialog in a simple HTTP connection
without using any RSocket element.
Actually here i am making a simple get request (http)as in http client example in sdk.here i have not used any socket.
now i want to save apn id only showing the dialog once at first time. Then after i want to use the saved value.
Any one please suggest.
Thanks
definitely you can, and that is what the code can help do.
The code mentioned in the above posts, with some minor modifications, (see the wiki links mentioned above to get the IAPs and also show selection dialog, next time onwards, you can simply use that IAP ID in the set Connection preference, and use the flag ECommDbDialogPrefDoNotPrompt)
I have done this in my code, and with HTTP only (no socket) and one time ask only and it is working fine ...
Amit Kankani
Nokia Developer Champion
Thanks for response. ok now i am able show the acess point dialog
using this link http://wiki.forum.nokia.com/index.ph...oint_%28IAP%29
but at this link http://wiki.forum.nokia.com/index.php/Default_iapi
get the code for setting connection properties
they use Rsocketserver . so how will i do this in my code.
actually after getting APNID iset the property as below
TCommDbConnPref connectPref;
connectPref.SetDirection(ECommDbConnectionDirectionUnknown);
connectPref.SetBearerSet(ECommDbBearerUnknown);
connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
connectPref.SetIapId(selectedIap);
after that what should i do.
I mean how can i replace the following code
RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketServ,
RHTTPSession::GetTable() ), THTTPHdrVal (isockServ.Handle()) );
TInt connPtr = REINTERPRET_CAST(TInt, &iconnection);
connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketConnection,
RHTTPSession::GetTable() ), THTTPHdrVal (connPtr) );
Thanks
Well I am not sure if you need to do this. HTTP will also at some point use sockets (it is actually a wrapper over the sockets(TCP in case of symbian HTTP class, not sure if UDP could be ), as sockets is a transport layer entity and http is an presentation layer entity)I mean how can i replace the following code
RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketServ,
RHTTPSession::GetTable() ), THTTPHdrVal (isockServ.Handle()) );
TInt connPtr = REINTERPRET_CAST(TInt, &iconnection);
connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketConnection,
RHTTPSession::GetTable() ), THTTPHdrVal (connPtr) );
So if u want to use HTTP, the code mentioned is just right.
I have verified this in India with Airtel live, where socket connections are blocked, however, with HTTP it seems to work !
well correct me if i am wrong... !!!
Amit Kankani
Nokia Developer Champion
I also have tested this code, this works fine.
but my question is now can we say this is a http request.
beacuse here we are using RSocketServ.....
Another question is why we are using this piece of code
// The CApUtils API is deprecated/removed, the following code can be
// used
// to convert the WapAP Id to IAP Id
if (selectedIap)
{
CCommsDatabase* db = CCommsDatabase::NewL();
CleanupStack::PushL(db);
CCommsDbTableView* wapTable;
wapTable = db->OpenViewMatchingUintLC( TPtrC(WAP_ACCESS_POINT),
TPtrC(COMMDB_ID), selectedIap );
User::LeaveIfError( wapTable->GotoFirstRecord() );
TBuf<100> wapBearer;
wapTable->ReadTextL(TPtrC(WAP_CURRENT_BEARER), wapBearer);
if ( wapBearer == TPtrC(WAP_IP_BEARER) )
{
CCommsDbTableView* bearerTable;
bearerTable = db->OpenViewMatchingUintLC( TPtrC(wapBearer),
TPtrC(WAP_ACCESS_POINT_ID),
selectedIap );
User::LeaveIfError( bearerTable->GotoFirstRecord() );
bearerTable->ReadUintL(TPtrC(WAP_IAP), iIap );
CleanupStack::PopAndDestroy( bearerTable ); // bearerTable
}
else
{
User::Leave( KErrInvalidBearerType );
}
CleanupStack::PopAndDestroy(2); // db, wapTable,
}
Thanks