Common Programming of Symbian Network Access Points

Source: Internet
Author: User

Obtain access point information from commdb:

Ccommsdatabase * commsdb = ccommsdatabase: newl (edatabasetypeiap );
Ccommsdbtableview * Table = commsdb-> openiaptableviewmatchingbearersetlc (
Ecommdbbearergprs | ecommdbbearerwlan, // GPRS and wireless LAN
Ecommdbconnectiondirectionoutgoing); // It Doesn't Matter in the direction. You can also write unknown.
User: leaveiferror (Table-> gotofirstrecord (); // go to the first record.

Tint err = kerrnone;
Do
{
Tbuf <32> name;
Tuint32 ID;
Table-> readtextl (tptrc (commdb_name), name); // obtain the name of the current access point
Table-> readuintl (tptrc (commdb_id), ID); // obtain the iapid of the current access point
... // Do something
Err = table-> gotonextrecord (); // go to the next record
}
While (ERR = kerrnone );

AboveCodeDemonstrate how to traverse the Access Point list. The implementation method is direct. We can also use another encapsulated class capselect to implement it:

Ccommsdatabase * commdb = ccommsdatabase: newl (edatabasetypeiap );
Capselect * apselect = capselect: newlc (* commdb, keapisptypeall, eapbearertypeall, keapsortuidascending); // the ISP and bearer types and sorting rules are specified.

If (apselect-> movetofirst ())
{
Do
{
Tptrc A = apselect-> name (); // Access Point name
Tuint uid = apselect-> UID (); // Access Point iapid
// Put here your IAP stuff
}
While (apselect-> movenext (); // The next record
}

Dialog Box to allow users to select Access Points

You can use the rconnection class to determine the access point you want to use:

Rsocketserv isocketserv; // data member
Rconnection iconnection; // data member

User: leaveiferror (isocketserv. Connect ());
User: leaveiferror (iconnection. Open (isocketserv ));

Tcommdbconnpref connectpref;
Connectpref. setdialogpreference (ecommdbdialogprefprompt); // prompt the user
Connectpref. setbearerset (ecommdbbearerwlan | ecommdbbearergprs );

User: leaveiferror (iconnection. Start (connectpref ));//Synchronous Functions,A dialog box is displayed, waiting for the access point to be selected to establish a connection.

Here we select the Access Point and establish a connection to bind it. If we do not connect immediately after selecting the access point, how can we achieve this? Look down.

Show default access point settings &Connect without user confirmation

The default access point setting is to bring up the display screen of a specific access point in settings-connection-Access Point in the real machine. You can select different access points based on the actual situation. After obtaining the iapid of the access point you want to use, you can directly establish a connection as needed without confirmation:
Usage class:Capsettingshandler

// Show IAP selection dialog to list Access Points
Cactiveapdb * ADB = cactiveapdb: newl ();
Cleanupstack: pushl (ADB );
Capsettingshandler * settings = capsettingshandler: newlc (
* ADB,
Etrue,
Eapsettingssellistispopup,
Eapsettingsselmenuselectnormal,
Keapisptypeall,
Bearerfilter,
Keapsortnameascending,
0,
Evpnfilterboth,
Etrue );

Tint iapret = settings-> runsettingsl (0, iselectediap); // Save the selected access point to iselectediap
Cleanupstack: popanddestroy (settings );
Cleanupstack: popanddestroy (ADB );

If (iapret! = Kapuieventselected)
{
// Exit no selection
User: Leave (kerrnotready );
}
Else
{
// IAP selected, which is connected Based on the selected Access Point
// Open socket server and start the connection
User: leaveiferror (isocketserv. Connect ());
User: leaveiferror (iconnection. Open (isocketserv ));

// Now we have the iap id. Use it to connect for the connection
Tcommdbconnpref connectpref;

// Setup preferences
Connectpref. setdialogpreference (ecommdbdialogprefprompt );

// Sets the commdb ID of the IAP to use for this connection
Connectpref. setiapid (iselectediap );

// Start connection
User: leaveiferror (iconnection. Start (connectpref ));
...
}

The above code can be divided into two parts to achieve the separation of Access Point Selection and connection establishment. The code for establishing a connection is as follows:
// IAP selected, which is connected Based on the selected Access Point
// Open socket server and start the connection
User: leaveiferror (isocketserv. Connect ());
User: leaveiferror (iconnection. Open (isocketserv ));

// Now we have the iap id. Use it to connect for the connection
Tcommdbconnpref connectpref;

// Setup preferences
Connectpref. setdialogpreference (ecommdbdialogprefprompt );

// Sets the commdb ID of the IAP to use for this connection
Connectpref. setiapid (iselectediap );

// Start connection
User: leaveiferror (iconnection. Start (connectpref ));



Shielding system access points in MTM Mode

    1. Timiapchoice apchoice;
    2. Apchoice. IIAP = 0; // store IAP ID
    3. Apchoice. idialogpref = ecommdbdialogprefdonotprompt; // prompt Dialog
    4. Cimiappreferences * appref = cimiappreferences: newlc ();
    5. Appref-> addiapl (apchoice );
    6. Mailaccount-> savepopiapsettingsl (popaccount, * appref );
    7. Cleanupstack: popanddestroy (appref );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.