Categories: Symbian C++ | Networking | WLAN | Code Examples | S60
This page was last modified 09:10, 28 February 2008.
CS000837 - Show WLAN IAP only when the device is offline
From Forum Nokia Wiki
| ID | CS000837 | Creation date | February 28, 2008 |
| Platform | S60 3rd Edition S60 3rd Edition, FP1 | Tested on devices | Nokia E90 Communicator Nokia N95 |
| Category | Symbian C++ | Subcategory | Networking WLAN |
| APIs | None | Classes | CRepository CActiveApDb CApSettingsHandler |
| Methods | None |
Overview
When the device is in offline mode, the application must show only the WLAN Internet Access Point (IAP) in the IAP selection dialog. This functionality can be implemented with the CApSettingsHandler class.
This snippet can be self-signed.
MMP file
The following capabilities and libraries are required:
CAPABILITY NetworkServices
LIBRARY apsettingshandlerui.lib // for CApSettingsHandler
LIBRARY centralrepository.lib // for Offline/Online check
LIBRARY apengine.lib  // for getting Easy WLAN
Header file
#include <apsettingshandlerui.h> // EApBearerTypeWLAN #include <centralrepository.h> // CRepository #include <ProfileEngineSDKCRKeys.h> // CRepository #include <activeapdb.h> // CActiveApDb // Offline profileid const TInt KOffline = 5; // Class member variables TInt iPrevProfileId; TBool iConnectionSetupDone; RSocketServ iSocketServ; RConnection iConnection; RHTTPSession iSession;
Source file
In the connection setup method of the application (SetupConnectionL()), check the device profile by using CRepository. If the profile is Offline (5), show only WLANs of type EApBearerTypeWLAN in the IAP selection dialog.
If the profile is changed after the first IAP selection, the IAP checked again.
void CYourClass::SetupConnectionL() { TUint32 selectedIap = 0; TInt bearerFilter = EApBearerTypeAllBearers; TInt currentProfileId; // Create CRepository CRepository repository = CRepository::NewL(KCRUidProfileEngine); // Check whether device is offline or online repository->Get(KProEngActiveProfile, currentProfileId); delete repository; // Close the connection only if // a) this is not the first time and // b) the profile has changed and // c) either the previous or the current profile are Offline if (iPrevProfileId != -1 && iPrevProfileId != currentProfileId && (iPrevProfileId == KOffline || currentProfileId == KOffline)) { // Close and uninitialize iConnectionSetupDone = EFalse; iSession.Close(); iConnection.Close(); iSocketServ.Close(); } // Save the current profile ID iPrevProfileId = currentProfileId; if (iConnectionSetupDone) { // Connection setup is done return; } // Open RHTTPSession with default protocol ("HTTP/TCP") iSession.OpenL(); // In offline, only WLAN connections are available if (currentProfileId == KOffline) { bearerFilter = EApBearerTypeWLAN; } // Create the IAP selection dialog CActiveApDb* aDb = CActiveApDb::NewL(); CleanupStack::PushL(aDb); CApSettingsHandler* settings = CApSettingsHandler::NewLC( *aDb, ETrue, EApSettingsSelListIsPopUp, EApSettingsSelMenuSelectNormal, KEApIspTypeAll, bearerFilter, KEApSortNameAscending, 0, EVpnFilterBoth, ETrue); // Show the dialog TInt iapRet = settings->RunSettingsL(0, selectedIap); CleanupStack::PopAndDestroy(settings); CleanupStack::PopAndDestroy(aDb); if (iapRet != KApUiEventSelected) { // Exit: no selection User::Leave(KErrNotReady); } else { // IAP Selected // Open socket server and start the connection User::LeaveIfError(iSocketServ.Connect()); User::LeaveIfError(iConnection.Open(iSocketServ)); // Now you have the IAP ID. Use it to connect to the connection. TCommDbConnPref connectPref; // Setup preferences connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); // Set the CommDb ID of the IAP to use for this connection connectPref.SetIapId(selectedIap); // Start connection User::LeaveIfError(iConnection.Start(connectPref)); // Set the sessions connection info... RStringPool strPool = iSession.StringPool(); RHTTPConnectionInfo connInfo = iSession.ConnectionInfo(); // ...to use the socket server and connection connInfo.SetPropertyL( strPool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal(iSocketServ.Handle()) ); // ...to use the connection connInfo.SetPropertyL( strPool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), THTTPHdrVal(REINTERPRET_CAST(TInt, &(iConnection))) ); iConnectionSetupDone = ETrue; } }
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| n91 vs E70 WLAN connectivity | matrix241 | Wired and Wireless interfaces | 3 | 2006-10-03 16:45 |
| close gsm | mustundag | Mobile Java Networking & Messaging & Security | 2 | 2008-01-09 17:02 |
| iap popup | nicholasgaye | General Symbian C++ | 0 | 2005-07-07 10:31 |
| Check for WLAN availability | Dipakbaviskar | Symbian Networking & Messaging | 3 | 2008-05-09 04:36 |
| problem with WLAN on E70 | ondskapen | General Discussion | 2 | 2007-03-13 23:28 |

