Namespaces
Variants
Actions

Create new internet access point

Jump to: navigation, search
Article Metadata

Article
Created: kiran10182 (13 Aug 2007)
Last edited: hamishwillee (03 Feb 2012)

Creating the GPRS Internet Access Point (IAP) OS version independent

In order to create the IAP, CCommsDatabase is used. The following code example creates all the table entries manually. It actually duplicates the emulator's "Winsock" IAP initial settings. CreateNewIAP() is the main function.

#include <commdbconnpref.h>
#include <commdb.h>
#include <cdbpreftable.h>
 
TUint32 CreateWapApL(CCommsDatabase* db)
{
_LIT(KWapApName, "MyAP WAP");
TUint32 WapId;
CCommsDbTableView* view = db->OpenTableLC(TPtrC(WAP_ACCESS_POINT));
User::LeaveIfError(view->InsertRecord(WapId));
view->WriteTextL(TPtrC(COMMDB_NAME), KWapApName);
view->WriteTextL(TPtrC(WAP_CURRENT_BEARER), TPtrC(WAP_IP_BEARER));
 
User::LeaveIfError(view->PutRecordChanges());
delete view;
 
return WapId;
}
 
TUint32 CreateGprsServiceL(CCommsDatabase* db)
{
_LIT(KGprsName, "MyAP Gprs");
_LIT(KSettingAPN, "Winsock");
 
TUint32 gprsId;
CCommsDbTableView* view = db->OpenTableLC(TPtrC(OUTGOING_GPRS));
User::LeaveIfError(view->InsertRecord(gprsId));
 
 
view->WriteTextL(TPtrC(COMMDB_NAME), KGprsName);
view->WriteTextL(TPtrC(GPRS_APN), KSettingAPN);
view->WriteUintL(TPtrC(GPRS_PDP_TYPE), 0);
view->WriteBoolL(TPtrC(GPRS_IP_ADDR_FROM_SERVER), EFalse);
view->WriteBoolL(TPtrC(GPRS_IP_DNS_ADDR_FROM_SERVER), EFalse);
view->WriteBoolL(TPtrC(GPRS_IP6_DNS_ADDR_FROM_SERVER), EFalse);
view->WriteTextL(TPtrC(GPRS_IF_AUTH_NAME), _L(""));
view->WriteTextL(TPtrC(GPRS_IF_AUTH_PASS), _L(""));
view->WriteBoolL(TPtrC(GPRS_IF_PROMPT_FOR_AUTH), EFalse);
view->WriteUintL(TPtrC(SERVICE_IF_AUTH_RETRIES), 0);
view->WriteTextL(TPtrC(GPRS_IF_NETWORKS), _L("tcp,udp,icmp,icmp6"));
view->WriteBoolL(TPtrC(GPRS_HEADER_COMPRESSION), EFalse);
view->WriteBoolL(TPtrC(GPRS_DATA_COMPRESSION), EFalse);
view->WriteUintL(TPtrC(GPRS_REQ_PRECEDENCE), 0);
view->WriteUintL(TPtrC(GPRS_REQ_DELAY), 0);
view->WriteUintL(TPtrC(GPRS_REQ_RELIABILITY), 0);
view->WriteUintL(TPtrC(GPRS_REQ_PEAK_THROUGHPUT), 0);
view->WriteUintL(TPtrC(GPRS_REQ_MEAN_THROUGHPUT), 0);
view->WriteUintL(TPtrC(GPRS_MIN_PRECEDENCE), 0);
view->WriteUintL(TPtrC(GPRS_MIN_DELAY), 0);
view->WriteUintL(TPtrC(GPRS_MIN_RELIABILITY), 0);
view->WriteUintL(TPtrC(GPRS_MIN_PEAK_THROUGHPUT), 0);
view->WriteUintL(TPtrC(GPRS_MIN_MEAN_THROUGHPUT), 0);
view->WriteBoolL(TPtrC(GPRS_ANONYMOUS_ACCESS), EFalse);
view->WriteBoolL(TPtrC(GPRS_ENABLE_LCP_EXTENSIONS), EFalse);
view->WriteBoolL(TPtrC(GPRS_DISABLE_PLAIN_TEXT_AUTH), EFalse);
view->WriteUintL(TPtrC(GPRS_AP_TYPE), 2);
view->WriteUintL(TPtrC(GPRS_QOS_WARNING_TIMEOUT), -1);
 
User::LeaveIfError(view->PutRecordChanges());
delete view;
 
return gprsId;
}
 
TUint32 CreateLocationL(CCommsDatabase* db)
{
_LIT(KLocName, "MyAP Location");
TUint32 LocId;
CCommsDbTableView* view = db->OpenTableLC(TPtrC(LOCATION));
User::LeaveIfError(view->InsertRecord(LocId));
 
view->WriteTextL(TPtrC(COMMDB_NAME), KLocName);
view->WriteTextL(TPtrC(LOCATION_INTL_PREFIX_CODE),_L("+"));
view->WriteTextL(TPtrC(LOCATION_NAT_PREFIX_CODE),_L("0"));
view->WriteTextL(TPtrC(LOCATION_NAT_CODE),_L("44"));
view->WriteUintL(TPtrC(LOCATION_PAUSE_AFTER_DIAL_OUT), 0);
view->WriteBoolL(TPtrC(LOCATION_MOBILE), ETrue);
view->WriteBoolL(TPtrC(LOCATION_USE_PULSE_DIAL), EFalse);
view->WriteBoolL(TPtrC(LOCATION_WAIT_FOR_DIAL_TONE), EFalse);
 
User::LeaveIfError(view->PutRecordChanges());
delete view;
 
return LocId;
}
 
TUint32 CreateBearerL(CCommsDatabase* db)
{
_LIT(KAgentName, "wsocka.agt");
_LIT(KIfName, "wsocki");
_LIT(KLddName, "foo");
_LIT(KBearerName, "MyAP Bearer");
 
TUint32 BearerId;
CCommsDbTableView* view = db->OpenTableLC(TPtrC(LAN_BEARER));
User::LeaveIfError(view->InsertRecord(BearerId));
 
view->WriteTextL(TPtrC(COMMDB_NAME), KBearerName);
view->WriteTextL(TPtrC(IF_NAME), KIfName);
view->WriteTextL(TPtrC(LAN_BEARER_LDD_NAME), KIfName);
view->WriteTextL(TPtrC(LAN_BEARER_PDD_NAME), KIfName);
view->WriteTextL(TPtrC(AGENT_NAME), KAgentName);
 
view->WriteUintL(TPtrC(LAST_SOCKET_ACTIVITY_TIMEOUT), -1);
view->WriteUintL(TPtrC(LAST_SESSION_CLOSED_TIMEOUT), -1);
view->WriteUintL(TPtrC(LAST_SOCKET_CLOSED_TIMEOUT), -1);
 
User::LeaveIfError(view->PutRecordChanges());
delete view;
 
return BearerId;
}
 
TUint32 CreateNetworkL(CCommsDatabase* db)
{
_LIT(KNetName, "MyAP Network");
TUint32 NetId;
CCommsDbTableView* view = db->OpenTableLC(TPtrC(NETWORK));
User::LeaveIfError(view->InsertRecord(NetId));
 
view->WriteTextL(TPtrC(COMMDB_NAME), KNetName);
 
User::LeaveIfError(view->PutRecordChanges());
delete view;
 
return NetId;
}
 
void CreateConnectionPreferencesL(CCommsDatabase* db, TUint32 Iap)
{
CCommsDbConnectionPrefTableView * view =
db->OpenConnectionPrefTableLC(ECommDbConnectionDirectionOutgoing);
 
CCommsDbConnectionPrefTableView::TCommDbIapBearer bearerinfo;
bearerinfo.iBearerSet=-1;
bearerinfo.iIapId=Iap;
 
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
pref.iRanking=0;
pref.iDirection=ECommDbConnectionDirectionOutgoing;
pref.iDialogPref =ECommDbDialogPrefDoNotPrompt;
pref.iBearer=bearerinfo;
 
view->InsertConnectionPreferenceL(pref);
delete view;
 
}
 
 
 
TUint32 CreateIAPL(CCommsDatabase* db, TUint32 Bearer, TUint32 Network,
TUint32 Service, TUint32 Location)
{
_LIT(KIAPName, "MyAP");
TUint32 IapId;
CCommsDbTableView* view = db->OpenTableLC(TPtrC(IAP));
User::LeaveIfError(view->InsertRecord(IapId));
 
view->WriteTextL(TPtrC(COMMDB_NAME), KIAPName);
view->WriteTextL(TPtrC(IAP_SERVICE_TYPE), TPtrC(OUTGOING_GPRS));
view->WriteTextL(TPtrC(IAP_BEARER_TYPE), TPtrC(LAN_BEARER));
view->WriteUintL(TPtrC(IAP_BEARER), Bearer);
view->WriteUintL(TPtrC(IAP_NETWORK), Network);
view->WriteUintL(TPtrC(IAP_SERVICE), Service);
view->WriteUintL(TPtrC(LOCATION), Location);
view->WriteUintL(TPtrC(IAP_NETWORK_WEIGHTING), 0);
 
User::LeaveIfError(view->PutRecordChanges());
delete view;
 
return IapId;
}
 
void CreateWapIPBearerL(CCommsDatabase* db, TUint32 Iap, TUint32 WapIap)
{
_LIT(KWapBearer, "MyAP Wap Bearer");
TUint32 Id;
CCommsDbTableView* view = db->OpenTableLC(TPtrC(WAP_IP_BEARER));
User::LeaveIfError(view->InsertRecord(Id));
 
view->WriteTextL(TPtrC(COMMDB_NAME), KWapBearer);
view->WriteUintL(TPtrC(IAP), Iap);
view->WriteUintL(TPtrC(WAP_ACCESS_POINT_ID), WapIap);
view->WriteUintL(TPtrC(WAP_WSP_OPTION), EWapWspOptionConnectionless);
view->WriteBoolL(TPtrC(WAP_SECURITY), EFalse); \
view->WriteTextL(TPtrC(WAP_GATEWAY_ADDRESS), _L("0.0.0.0"));
view->WriteUintL(TPtrC(WAP_PROXY_PORT), 0);
 
User::LeaveIfError(view->PutRecordChanges());
delete view;
}
 
void CreateNewIAP()
{
CCommsDatabase* db=CCommsDatabase::NewL();
 
TUint32 Bearer=CreateBearerL(db);
TUint32 Network=CreateNetworkL(db);
TUint32 Service=CreateGprsServiceL(db);
TUint32 Location=CreateLocationL(db);
TUint32 Iap=CreateIAPL(db, Bearer, Network, Service, Location);
 
CreateConnectionPreferencesL(db, Iap);
 
TUint32 WapAp=CreateWapApL(db);
CreateWapIPBearerL(db,Iap,WapAp);
 
delete db;
}


Need to link with commdb.lib in the .mmp file.

 LIBRARY commdb.lib

The code requires WriteDeviceData capability to run on devices based on Symbian OS v9. So add them in mmp .file.

Capability  WriteDeviceData

Related Link

This page was last modified on 3 February 2012, at 05:19.
131 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved