With the UIQ 2 platform, users would have to manually make these connections from the settings menu every time they changed their environment. With the UIQ 3 platform, anytime ActiveSync attempts to connect to the internet, the phone will automatically select the best network connection to be used without any user intervention.
Here is an example for activating a single Internet group on UIQ3.
// ------- gets the default snap account id
void GetDefaultIAPL(TUint32 &defaultSnapID) {
CMDBSession *pDbSession = NULL;
CMDBRecordSet<CCDGlobalSettingsRecord> *pGlobalSettingsRecSet = NULL;
defaultSnapID = 0;
// start the session
pDbSession = CMDBSession::NewLC(CMDBSession::LatestVersion());
// load the global settings
pGlobalSettingsRecSet = new (ELeave) CMDBRecordSet<CCDGlobalSettingsRecord>(KCDTIdGlobalSettingsRecord);
CleanupStack::PushL(pGlobalSettingsRecSet);
pGlobalSettingsRecSet->LoadL(*pDbSession);
// get the default SNAP ID
if (pGlobalSettingsRecSet->iRecords.Count())
defaultSnapID = static_cast<TUint32>((*pGlobalSettingsRecSet)[0]->iDefaultSnap);
CleanupStack::PopAndDestroy(pGlobalSettingsRecSet); // pGlobalSettingsRecSet
CleanupStack::PopAndDestroy(pDbSession); // pDbSession
}
//-------
//------- connnects to the internet
{
TCommSnapPref iSNAPPrefs;
RConnection iConnection;
RSocketServ iSocketServer;
TUint32 currIAPID = 0;
iSocketServer.Connect();
iConnection.Open(iSocketServer);
GetDefaultIAPL(currIAPID); // please see function above for this
iSNAPPrefs.SetSnap(currIAPID);
iConnection.Start(iSNAPPrefs, iStatus);
SetActive();
}
//-------
//------- gets a list of snap accounts
class CSnapAccountInfo : public CBase
{
public:
CSnapAccountInfo() : mpName(NULL), mId(0), mIsDefault(EFalse) { }
virtual ~CSnapAccountInfo() { delete mpName; }
HBufC* mpName;
TUint32 mId;
TBool mIsDefault;
};
void GetListOfAccessPointsL(CArrayPtrFlat<CSnapAccountInfo> **ppListSnapAccounts) {
TUint32 defaultID = 0;
CSnapAccountInfo *pCurrSnapAccountsInfo = NULL;
CArrayPtrFlat<CSnapAccountInfo> *pLocalListSnapAccounts = NULL;
CMDBSession *pDbSession = NULL;
CMDBRecordSet<CCDGlobalSettingsRecord> *pGlobalSettingsRecSet = NULL;
CMDBRecordSet<CCDAccessPointRecord> *pSnapRecordSet = NULL;
CCDAccessPointRecord *pCurrSNAPRec = NULL;
// start the session
pDbSession = CMDBSession::NewLC(CMDBSession::LatestVersion());
// load the global settings
pGlobalSettingsRecSet = new (ELeave) CMDBRecordSet<CCDGlobalSettingsRecord>(KCDTIdGlobalSettingsRecord);
CleanupStack::PushL(pGlobalSettingsRecSet);
pGlobalSettingsRecSet->LoadL(*pDbSession);
// load the SNAp record list
pSnapRecordSet = new (ELeave) CMDBRecordSet<CCDAccessPointRecord>(KCDTIdAccessPointRecord);
CleanupStack::PushL(pSnapRecordSet);
pSnapRecordSet->LoadL(*pDbSession);
// get the default SNAP ID
if (pGlobalSettingsRecSet->iRecords.Count())
defaultID = static_cast<TUint32>((*pGlobalSettingsRecSet)[0]->iDefaultSnap);
// create the array to hold the access point info
*ppListSnapAccounts = NULL;
pLocalListSnapAccounts = new (ELeave) CArrayPtrFlat<CSnapAccountInfo>(4);
CleanupStack::PushL(pLocalListSnapAccounts);
// parse the SNAP record list to extract the display info
for (TInt i = 0; i < pSnapRecordSet->iRecords.Count(); ++i)
{
pCurrSNAPRec = (*pSnapRecordSet)[i];
pCurrSnapAccountsInfo = new (ELeave) CSnapAccountInfo;
CleanupStack::PushL(pCurrSnapAccountsInfo);
TPtrC recNamePtr(pCurrSNAPRec->iRecordName);
pCurrSnapAccountsInfo->mpName = recNamePtr.AllocL();
pCurrSnapAccountsInfo->mId = pCurrSNAPRec->RecordId();
if (pCurrSnapAccountsInfo->mId == defaultID)
pCurrSnapAccountsInfo->mIsDefault = ETrue;
pLocalListSnapAccounts->AppendL(pCurrSnapAccountsInfo);
CleanupStack::Pop(pCurrSnapAccountsInfo);
}
// now pass back the list
*ppListSnapAccounts = pLocalListSnapAccounts;
CleanupStack::Pop(pLocalListSnapAccounts);
CleanupStack::PopAndDestroy(pSnapRecordSet); // pSnapRecordSet
CleanupStack::PopAndDestroy(pGlobalSettingsRecSet); // pGlobalSettingsRecSet
CleanupStack::PopAndDestroy(pDbSession); // pDbSession }
//-------