Hi,

I have got the solution to activate the GPRS service without prompting for 7.0s. I was facing this problem by last one month. Go through the document it may help you to

solve the problem.


Code :

/********************************************/
// define the variable and the approprian header and lib file
TInt err;
TUint32 iaIapId;// member variable
TInetAddr ServerAddr(KInetAddrMMRServer, KTcpPort);
RSocketServ ss;
RSocet iSocket;
Rconnection iConnection;
TCommDbConnPref prefs;
// Make a connection to the socket server
err=ss.Connect();
User::LeaveIfError(err);

User::LeaveIfError(iConnection.Open(ss));

// version7.0 dependent code

if(iPromptFlag) // Set the value of iPromptFlag=ETrue. It will execute first time to get the IAP id by prompting the

dailog.

{
LaunchIAPList();// it will display one dialog prompt to select access point. I have to store this value into onee

variable so that we can pass into prefs.SetIapId(iaIapId);///list function
WriteIapId();// permanent store value of iaiapld in one specific file
prefs.SetDialogPreference(ECommDbDialogPrefPrompt);// it will ask to select the accesss point

}
else
{
ReadIapId();// read the value of iaIapId from permanent stored files see implementation
prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);

}

prefs.SetIapId(iaIapId);///list
prefs.SetDirection(ECommDbConnectionDirectionOutgoing);
//Start Connection
User::LeaveIfError(iConnection.Start(prefs));

err=iSocket.Open(ss, KAfInet, KSockStream,KProtocolInetTcp ,iConnection);


iChannelState=EChannelConnected;
iSocket.Connect(ServerAddr, iStatus);

SetActive();

//////////////////////////////////////////////////////////////////////////////////






// // it will display one dialog prompt to select access point. I have to store this value into one variable so that we can pass

into prefs.SetIapId(iaIapId);///list function
void CMinTcpEngine::LaunchIAPList()// TUint32& aIapId
{

CEikTextListBox* lAccessPointList = (CEikTextListBox*)NULL;
MDesCArray* lAccessPointListarr = (MDesCArray*)NULL;
CDesCArray* lAccessPointArray = (CDesCArray*)NULL;
CAknPopupList* lAccessPointPopupList = (CAknPopupList*)NULL;
CCommsDatabase* lCommDb = (CCommsDatabase*)NULL; // CommsDb Object
CCommsDbTableView* lCommView = (CCommsDbTableView*)NULL;
TBuf<30> lNameItem;
TBuf<30> lAccessPointName;
TInt lAccessPointId = 0;
TBuf8<60> lIapName;

lAccessPointList = new(ELeave) CAknSinglePopupMenuStyleListBox;
CleanupStack::PushL(lAccessPointList);
// Create popup list and PUSH it.
lAccessPointPopupList = CAknPopupList::NewL(
lAccessPointList, R_AVKON_SOFTKEYS_MENU_LIST,
AknPopupLayouts::EPopupSNotePopupWindow);
CleanupStack::PushL(lAccessPointPopupList);

// initialize listbox.
lAccessPointList->ConstructL(lAccessPointPopupList, CEikListBox::ELeftDownInViewRect);
lAccessPointList->CreateScrollBarFrameL(ETrue);
lAccessPointList->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff,
CEikScrollBarFrame::EAuto);

lAccessPointListarr = lAccessPointList->Model()->ItemTextArray();

if ((MDesCArray*)NULL != lAccessPointListarr )
{
lAccessPointArray = STATIC_CAST(CDesCArray*, lAccessPointListarr);
}

lCommDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
CleanupStack::PushL(lCommDb);

// open IAP table
lCommView =

lCommDb->OpenIAPTableViewMatchingBearerSetLC(ECommDbBearerCSD|ECommDbBearerGPRS,ECommDbConnectionDire

ctionOutgoing);
if (lCommView->GotoFirstRecord() == KErrNone)
{
for (;
{
lNameItem.Zero();
lCommView->ReadTextL(TPtrC(COMMDB_NAME),lNameItem);
lNameItem.Trim();

lAccessPointArray->AppendL(lNameItem);

if (lCommView->GotoNextRecord() != KErrNone)
{
break;
}

}
}


void CMinTcpEngine::LaunchIAPList()// TUint32& aIapId
{

CEikTextListBox* lAccessPointList = (CEikTextListBox*)NULL;
MDesCArray* lAccessPointListarr = (MDesCArray*)NULL;
CDesCArray* lAccessPointArray = (CDesCArray*)NULL;
CAknPopupList* lAccessPointPopupList = (CAknPopupList*)NULL;
CCommsDatabase* lCommDb = (CCommsDatabase*)NULL; // CommsDb Object
CCommsDbTableView* lCommView = (CCommsDbTableView*)NULL;
TBuf<30> lNameItem;
TBuf<30> lAccessPointName;
TInt lAccessPointId = 0;
TBuf8<60> lIapName;

lAccessPointList = new(ELeave) CAknSinglePopupMenuStyleListBox;
CleanupStack::PushL(lAccessPointList);
// Create popup list and PUSH it.
lAccessPointPopupList = CAknPopupList::NewL(
lAccessPointList, R_AVKON_SOFTKEYS_MENU_LIST,
AknPopupLayouts::EPopupSNotePopupWindow);
CleanupStack::PushL(lAccessPointPopupList);

// initialize listbox.
lAccessPointList->ConstructL(lAccessPointPopupList, CEikListBox::ELeftDownInViewRect);
lAccessPointList->CreateScrollBarFrameL(ETrue);
lAccessPointList->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff,
CEikScrollBarFrame::EAuto);

lAccessPointListarr = lAccessPointList->Model()->ItemTextArray();

if ((MDesCArray*)NULL != lAccessPointListarr )
{
lAccessPointArray = STATIC_CAST(CDesCArray*, lAccessPointListarr);
}

lCommDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
CleanupStack::PushL(lCommDb);

// open IAP table
lCommView =

lCommDb->OpenIAPTableViewMatchingBearerSetLC(ECommDbBearerCSD|ECommDbBearerGPRS,ECommDbConnectionDire

ctionOutgoing);
if (lCommView->GotoFirstRecord() == KErrNone)
{
for (;
{
lNameItem.Zero();
lCommView->ReadTextL(TPtrC(COMMDB_NAME),lNameItem);
lNameItem.Trim();

lAccessPointArray->AppendL(lNameItem);

if (lCommView->GotoNextRecord() != KErrNone)
{
break;
}

}
}



lAccessPointPopupList->SetTitleL(_L("Select Access Point"));

if(lAccessPointPopupList->ExecuteLD())
{
lAccessPointId = lAccessPointList->CurrentItemIndex();

if(lAccessPointListarr->MdcaCount() > lAccessPointId)
{
TPtrC lItemptr,lTempptr;
lItemptr.Set(lAccessPointListarr->MdcaPoint(lAccessPointId));

if(KErrNone == TextUtils::ColumnText(lTempptr,0,&lItemptr))
{
lAccessPointName.Zero();
lAccessPointName.Copy(lTempptr);
lAccessPointName.Trim();
}
}

}

lIapName.Copy(lAccessPointName);

CCommsDbTableView *lTableViewPtr = lCommDb->OpenViewMatchingTextLC((TPtrC)IAP,
(TPtrC)(COMMDB_NAME),
lIapName);
TInt lResult = lTableViewPtr->GotoFirstRecord();
if(KErrNone == lResult)
{
lTableViewPtr->ReadUintL((TPtrC)(COMMDB_ID),
iaIapId);
}

CleanupStack::PopAndDestroy(lTableViewPtr);
CleanupStack::PopAndDestroy(lCommView);
CleanupStack::PopAndDestroy(lCommDb);
CleanupStack::Pop();
CleanupStack::PopAndDestroy(lAccessPointList);

}



// These two function WriteIapId() and ReadIapId() are implented to permanent store the Interner App.. id so that we can use
// this value in consequent transaction.
void CMinTcpEngine::WriteIapId()
{
RFs fs;
RFile file;
fs.Connect();
_LIT(path,"c:\\merlin\\data\\");
_LIT(fileNm,"IAP.DAT");
TParse name;
fs.MkDirAll(path);
fs.Parse(fileNm,path,name);
User::LeaveIfError(file.Replace(fs,name.FullName(),EFileWrite)); // create the file for writing
RFile f=file; // create a new handle
RFileWriteStream out(f); // open the file as a stream
out.WriteUint32L(iaIapId); // write some test data (to a buffer)
out.CommitL(); // commit the data (to file)
out.Close(); // close the file with test data written twice
}


void CMinTcpEngine::ReadIapId()
{
RFs fs;
RFile file;
fs.Connect();
_LIT(path,"c:\\merlin\\data\\");
_LIT(fileNm,"IAP.DAT");
TParse name;
fs.Parse(fileNm,path,name);

User::LeaveIfError( file.Open(fs,name.FullName(),EFileRead));

RFile f=file; // create a new handle
RFileReadStream in(f); // open the file as a stream
iaIapId=in.ReadUint32L(); // read file data into a user buffer
in.Close(); // close the file (and use the data in buf)
}



/*********************************************/

note* For any problem related to these code. cantact me at symbiancpp@linuxmail.org.


Thank you
Regards
Rakesh