1. Obtain the Access Point ID (iap id)
When creating a connection using the following code:
Rsocketserv socketserv;
Rconnection connection;
Tcommdbconnpref Pref;
Trequeststatus rsconn, rstimeout;
Timer timer;
User: leaveiferror (socketserv. Connect ());
User: leaveiferror (connect. Open (socketserv ));
Pref. setdialogpreference (ecommdbdialogprefprompt );
Pref. setdirection (ecommdbconnectiondirectionoutoing );
Pref. setbearerset (ecommdbbearerunknown );
If (timer. createlocal () = kerrnone)
{
Timer: After (rstimeout, 30*1000*1000)
Connection. Start (Pref, rsconn );
User: waitforrequest (rsconn, rstimeout );
Switch (rsconn. INT ())
{
Case kerrnone:
Case kerrinuse;
Case kerralreadyexists:
Dafault:
}
If (rsconn = krequestpending)
{
Connection. Stop ();
User: waitforrequest (rscconn );
}
If (rstimeout = krequestpending)
{
Timer: calcel ();
User: waitforrequest (rstimeout );
}
Timer: Close ();
}
Connection. Close ();
Socketserv. Close ();
A dialog box appears prompting you to select an access point. After you select an access point, you can use:
Tuint32 IAP (0 );
_ Commit (kcommdbiapsetting, "IAP // ID ");
User: leaveiferror (connection. getintsetting (kcommdbiapsetting, IAP ));
Obtain the ID of the Access Point. Here, IAP is the ID of the Access Point.
2. Obtain an active Access Point
Tuint32 IAP = 0;
Rsocketserv socketserv;
User: leaveiferror (socketserv. Connect ());
Cleanupclosepushl (socketserv );
Rconnection conn;
User: leaveiferror (conn. Open (socketserv ));
Cleanupclosepushl (conn );
Tuint COUNT = 0;
User: leaveiferror (conn. enumerateconnections (count ));
Tconnectioninfobuf connectioninfo;
Tuint I;
For (; count> 0; count --)
{
User: leaveiferror (conn. getconnectioninfo (count, connectioninfo ));
IAP = connectioninfo (). iiapid;
}
Cleanupstack: popanddestroy (2, & socketserv );
3. Round-Robin of available access points:
3.1
(From: http://www.ok371.cn/html/13/0/999/1.htm)
How do I get a list of Internet access point (IAP) names and the corresponding ID values?
Answer:
An Internet Access Point (IAP) is a table in Symbian's communication database (commdb) which provides an entry point for making a connection over a given bearer type e.g. GPRS, WCDMA, and GSM Data Call etc. there can be several IAP records in the IAP table within commdb Each pointing to a different connection type.
Note: The Example code below uses Symbian OS APIs directly. Some sdks might include UI platform specific APIs to achieve the same thing. You can use
The Symbian APIs to allow your solution to work over different platforms-though any future changes made to commdb API/functionality will affect your
Implementation.
How do I get a list of IAP's names?
The below code snippet below showshow to get the IAP names for GPRS (and also WCDMA ).
Tuint32 ccommsdbaccessor: getuplsiapsfromiaptablel (cdescarrayflat * alist)
{
Tbuf <52> iapfromtable;
Tint err = kerrnone;
// Open IAP table using the GPRS as the bearer.
Ccommsdbtableview * uplstable = icommsdb-> openiaptableviewmatchingbearersetlc (ecommdbbearergprs,
Ecommdbconnectiondirectionoutgoing );
// Point to the first entry
User: leaveiferror (uplstable-> gotofirstrecord ());
GPRS-> readtextl (tptrc (commdb_name), iapfromtable );
Alist-> appendl (iapfromtable );
While (ERR = maid-> gotonextrecord (), err = kerrnone)
{
GPRS-> readtextl (tptrc (commdb_name), iapfromtable );
Alist-> appendl (iapfromtable );
}
Cleanupstack: popanddestroy (); // GPRS
}
How do I get the IAP ID values?
You can extend the second example abve to get the IAP value. Include the line below
To read the IAP value for each record.
Tuint32 id = 0;
GPRS-> readuintl (tptrc (commdb_id), ID );
The IAP value can be used in the override settings when making a connection. see FAQ 1064 for more details.
3.2
Ccommsdatabase * commdb = ccommsdatabase: newl (edatabasetypeiap );
Cleanupstack: pushl (commdb );
// Commdb-> showhiddenrecords (); // if this function is called and the program does not have the corresponding permissions, an exception is thrown when commdb-> opentablelc is called, the exception cannot be caught.
Ccommsdbtableview * view = commdb-> opentablelc (tptrc (IAP ));
For (tint I = view-> gotofirstrecord (); I! = Kerrnotfound; I = view-> gotonextrecord ())
{
Tuint32 iapid;
Tbuf <512> iapname;
View-> readuintl (tptrc (commdb_id), iapid );
View-> readtextl (tptrc (commdb_name), iapname );
}
Cleanupstack: popanddestroy (2, commdb); // view, commdb
Iaptable-> readuintl (tptrc (commdb_id), ID );
Iaptable-> readtextl (tptrc (commdb_name), iapfromtable );
If (iapfromtable = findstring)
Return ID;
While (ERR = iaptable-> gotonextrecord (), err = kerrnone)
{
Iaptable-> readuintl (tptrc (commdb_id), ID );
Iaptable-> readtextl (tptrc (commdb_name), iapfromtable );
If (iapfromtable = findstring)
Return ID;
}
Return kerrnotfound;
}