i was doing an application on create a GPRS IPA and access , but i met a problem which was I could create the IPA while i cant access with my application. however, I can surf the GPRS on web function of the phone with my IAP . here is some part of my code : anyone can help me ?
void CSocketsEngine::CreatConnection()
{
RGenericAgent netAgent;
CCommsDbTableView* view;
TInt error;
TUint32 gprsId;
TInt nId=0;
TCommDbOpeningMethod method;
CCommsDatabase* cdb=CCommsDatabase::NewL(EDatabaseTypeIAP,method);
CleanupStack::PushL(cdb);
view = cdb->OpenTableLC(TPtrC(OUTGOING_GPRS));
view->InsertRecord(gprsId);
view->WriteTextL(TPtrC(COMMDB_NAME), _L("internet"));
view->WriteBoolL(TPtrC(GPRS_IF_PROMPT_FOR_AUTH), ETrue);
view->WriteBoolL(TPtrC(GPRS_IP_ADDR_FROM_SERVER), ETrue);
view->WriteBoolL(TPtrC(GPRS_IP_DNS_ADDR_FROM_SERVER), ETrue);
view->WriteTextL(TPtrC(GPRS_IP_GATEWAY), _L("0.0.0.0"));
view->WriteTextL(TPtrC(GPRS_IF_AUTH_NAME), _L(""));
view->WriteTextL(TPtrC(GPRS_IF_AUTH_PASS),_L(""));
view->WriteTextL(TPtrC(GPRS_APN), _L("internet"));
view->WriteUintL(TPtrC(GPRS_PDP_TYPE), 0);
view->WriteBoolL(TPtrC(GPRS_IF_PROMPT_FOR_AUTH), EFalse);
view->WriteTextL(TPtrC(GPRS_IF_NETWORKS), _L("ip"));
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_USE_EDGE), EFalse);
view->WriteBoolL(TPtrC(GPRS_ENABLE_LCP_EXTENSIONS), EFalse);
view->WriteBoolL(TPtrC(GPRS_DISABLE_PLAIN_TEXT_AUTH), EFalse);
view->WriteUintL(TPtrC(GPRS_AP_TYPE), 0);
view->WriteUintL(TPtrC(GPRS_QOS_WARNING_TIMEOUT), -1);
view->WriteUintL(TPtrC(GPRS_PDP_TYPE), 0);
view->WriteTextL(TPtrC(GPRS_PDP_ADDRESS), _L(""));
//view1->WriteTextL(TPtrC(GPRS_IF_NAME),_L("")); GPRS_IF_NAME has been
//suppressed in cdbcol.h although it is still in the sdk doc!
view->WriteTextL(TPtrC(GPRS_IF_PARAMS), _L(""));
view->WriteUintL(TPtrC(GPRS_IF_AUTH_RETRIES), 0);
view->WriteTextL(TPtrC(GPRS_IP_NETMASK), _L(""));
view->WriteTextL(TPtrC(GPRS_IP_ADDR),_L("0.0.0.0"));
view->WriteTextL(TPtrC(GPRS_IP_NAME_SERVER1),_L("0.0.0.0"));
view->WriteTextL(TPtrC(GPRS_IP_NAME_SERVER2),_L("0.0.0.0"));
//view1->WriteTextL(TPtrC(GPRS_IF_NAME),_L("")); GPRS_IF_NAME has been
//suppressed in cdbcol.h although it is still in the sdk doc!
view->ReadUintL(TPtrC(COMMDB_ID), gprsId);
error = view->PutRecordChanges();
CleanupStack::PopAndDestroy(view);
CleanupStack::PopAndDestroy(cdb);
//2)Add record to NETWORK
TUint32 networkId;
CCommsDatabase* cdb2=CCommsDatabase::NewL(EDatabaseTypeIAP);
CleanupStack::PushL(cdb2);
CCommsDbTableView* view2 = cdb2->OpenTableLC(TPtrC(NETWORK));
view2->InsertRecord(networkId);
view2->WriteTextL(TPtrC(COMMDB_NAME), _L("internet"));
error = view2->PutRecordChanges(EFalse, EFalse);
CleanupStack::PopAndDestroy(view2);
CleanupStack::PopAndDestroy(cdb2);
//3)SEARCH FOR Mobile LOCATION id
TInt result;
TUint32 locationId;
TUint32 mobileLocationId;
// Open Database
CCommsDatabase* cdb3 = CCommsDatabase::NewL(EDatabaseTypeIAP);
CleanupStack::PushL(cdb3);
CCommsDbTableView* view3 = cdb3->OpenTableLC(TPtrC(LOCATION));
// Walk through records
result = view3->GotoFirstRecord();
TBuf<128> locationName;
while (result == KErrNone)
{
view3->ReadTextL(TPtrC(COMMDB_NAME), locationName);
view3->ReadUintL(TPtrC(LOCATION_MOBILE), locationId);
if (locationName.Match(_L("Mobile"))!= KErrNotFound)
mobileLocationId = locationId;
result = view3->GotoNextRecord(EFalse, EFalse);
}
CleanupStack::PopAndDestroy(view3);
CleanupStack::PopAndDestroy(cdb3);
//4)Create IAP
TUint32 iapId;
CCommsDatabase* cdb4=CCommsDatabase::NewL(EDatabaseTypeIAP);
CleanupStack::PushL(cdb4);
CCommsDbTableView* view4;
view4 = cdb4->OpenTableLC(TPtrC(IAP));
error = view4->InsertRecord(iapId);
view4->WriteTextL(TPtrC(COMMDB_NAME), _L("internet"));
view4->WriteTextL(TPtrC(IAP_SERVICE_TYPE), TPtrC(OUTGOING_GPRS));
view4->WriteUintL(TPtrC(IAP_SERVICE), gprsId);
view4->WriteUintL(TPtrC(IAP_NETWORK_WEIGHTING), 0);
view4->WriteUintL(TPtrC(IAP_NETWORK), networkId);
view4->WriteUintL(TPtrC(IAP_BEARER), 2);
view4->WriteTextL(TPtrC(IAP_BEARER_TYPE), TPtrC(MODEM_BEARER));
view4->WriteUintL(TPtrC(IAP_LOCATION), mobileLocationId);
//view4->WriteUintL(TPtrC(IAP_DIALOG_PREF), iapId); makes the app crash
error = view4->PutRecordChanges();
CleanupStack::PopAndDestroy(view4);
CleanupStack::PopAndDestroy(cdb4);
//5) CREATE WAP_ACCESS_POINT
CCommsDatabase* cdb5=CCommsDatabase::NewL(EDatabaseTypeIAP);
CleanupStack::PushL(cdb5);
TUint32 wapId;
CCommsDbTableView* view5 = cdb5->OpenTableLC(TPtrC(WAP_ACCESS_POINT));
error = view5->InsertRecord(wapId);
view5->WriteTextL(TPtrC(COMMDB_NAME), _L("internet"));
view5->WriteTextL(TPtrC(WAP_CURRENT_BEARER), TPtrC(WAP_IP_BEARER));
error = view5->PutRecordChanges(EFalse, EFalse);
CleanupStack::PopAndDestroy(view5);
CleanupStack::PopAndDestroy(cdb5);
//6) Create WAP_IP_BEARER
TUint32 wapIPId;
CCommsDatabase* cdb6=CCommsDatabase::NewL(EDatabaseTypeIAP);
CleanupStack::PushL(cdb6);
CCommsDbTableView* view6 = cdb6->OpenTableLC(TPtrC(WAP_IP_BEARER));
error = view6->InsertRecord(wapIPId);
// Has no name view6->WriteTextL(TPtrC(COMMDB_NAME), _L("websfr"));
view6->WriteUintL(TPtrC(WAP_ACCESS_POINT_ID), wapId);
view6->WriteTextL(TPtrC(WAP_GATEWAY_ADDRESS), _L("0.0.0.0"));
view6->WriteUintL(TPtrC(WAP_WSP_OPTION),EWapWspOptionConnectionOriented);
view6->WriteBoolL(TPtrC(WAP_SECURITY), EFalse);
view6->WriteUintL(TPtrC(WAP_IAP),iapId);
view6->WriteUintL(TPtrC(WAP_PROXY_PORT), 0);
view6->WriteTextL(TPtrC(WAP_PROXY_LOGIN_NAME), _L(""));
view6->WriteTextL(TPtrC(WAP_PROXY_LOGIN_PASS), _L(""));
error = view6->PutRecordChanges(EFalse, EFalse);
CleanupStack::PopAndDestroy(view6);
cdb4->SetGlobalSettingL(TPtrC(DIAL_OUT_IAP),iapId);
error = view4->PutRecordChanges(EFalse, EFalse);
TInt resolveResult = view4->GotoFirstRecord();
if ( resolveResult == KErrNone )
{
view4->ReadUintL((TPtrC) COMMDB_ID, iapId );
}
CStoreableOverrideSettings* overrides = CStoreableOverrideSettings::NewL(CStoreableOverrideSettings::EParamListFull);
CleanupStack::PushL(overrides);
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
pref.iRanking = 1;
pref.iDirection = ECommDbConnectionDirectionOutgoing;
pref.iDialogPref = ECommDbDialogPrefDoNotPrompt;
pref.iBearer.iBearerSet = ECommDbBearerGPRS;
pref.iBearer.iIapId=iapId;
User::LeaveIfError(overrides->SetConnectionPreferenceOverride(pref));
User::LeaveIfError(netAgent.Open());
netAgent.StartOutgoing(*overrides,iStatus);//KErrNone if successful, KErrInUse if the agent is already in use, i.e. a connection is already in progress, and KErrAlreadyExists
User::WaitForRequest(iStatus);
netAgent.Close();
TRequestStatus status;
netAgent.StartOutgoing(status);
User::WaitForRequest(status);
CleanupStack::PopAndDestroy(); // overrides
}
void CSocketsEngine::InitConnection()
{
RGenericAgent netAgent;
if (netAgent.Open() == KErrNone)
{
CleanupClosePushL(netAgent);
CCommsDatabase* db=CCommsDatabase::NewL();
CleanupStack::PushL(db);
CCommsDbConnectionPrefTableView*
view = db->OpenConnectionPrefTableViewOnRankLC(ECommDbConnectionDirectionOutgoing,1);
view->GotoFirstRecord();
view->UpdateDialogPrefL(ECommDbDialogPrefDoNotPrompt);
TRequestStatus status;
netAgent.StartOutgoing(status);
User::WaitForRequest(status);
CleanupStack::PopAndDestroy(3); // view, db, netAgent
}
then is the common void connectL();
anybody can give me some suggestion?
![]()



