Access Point in Symbian

Source: Internet
Author: User

1. In symbain OS, network connection-related configuration attributes are stored through the commdb module. The commdb module is based on the Symbian OS
DBMS database system, which stores different types of data tables, such as IAP, outgoing_gprs, modems, locations, and WAP setting.

There are also multiple tables for storing Access Point information. For example, iapid is different for Network Access Points of different names and access modes. This value is reflected in the IAP table in the commdb database, the IAP table stores network access points (IAP). The real access method (APN) is cmnet or cmwap. These attributes are stored in outgoing_wcdma or outgoing_gprs in another table.

Commdb is a database system. In Symbian OS, there is a database access connection class ccommsdatabase and table operation class ccommsdbtableview. Commdb_id is not the Access Point ID, but a field in each table. Commdb_id and commdb_name are two fields in each table of the database. You can view the relevant header files, which contain descriptions of each table.

2. Open the database and obtain a table. The general operations are as follows:
(1) access the IAP table
Tuint32 iapid;
Ccommsdatabase * commdb = ccommsdatabase: newl (edatabasetypeiap );
Cleanupstack: pushl (commdb );
Ccommsdbtableview * commview = commdb-> opentablelc (tptrc (IAP ));
If (commview-> gotofirstrecord () = kerrnone)
Commview-> readuintl (tptrc (commdb_id), iapid );
// You can continue to traverse other records in the commview table.
Cleanupstack: popanddestroy (2 );
(2) access the outgoing_gprs table
Tuint32 fakeiapid;
Tbuf <kcommsdbsvrmaxcolumnnamelength> apnname;
Ccommsdatabase * commdb = ccommsdatabase: newl (edatabasetypeiap );
Cleanupstack: pushl (commdb );
Ccommsdbtableview * commview = commdb-> opentablelc (tptrc (outgoing_gprs ));
If (commview-> gotofirstrecord () = kerrnone)
{
Commview-> readtextl (tptrc) upls_apn, testname );
Commview-> readuintl (tptrc (commdb_id), fakeiapid );
// You can continue to traverse other records in the commview table.
}
Cleanupstack: popanddestroy (2 );
(3) through the above operations, you can obtain the name of the APN configured for the mobile phone network and the corresponding fakeiapid (fake here, because the iapid is different from the iapid In The IAP table.

The iapid value in the IAP table ). The APN value includes two different access methods of the GPRS network, cmnet and cmwap.
The outgoing_gprs table shows the records that actually use cmnet or cmwap in the mobile phone. However, the iapid is not the iapid that is actually needed.

But cannot determine whether the underlying access method is cmnet or cmwap. Now the question is, how can we combine the two tables?
In this case, the commdb_id field in the outgoing_gprs table and the iap_service field in the IAP table are used. The two fields can be used together.
The following code provides the name of the APN access point to obtain the access point id.
Void setdefaultiap (tint aiaptype, tuint32 & aiapid)
{
Tint ret = kerrnone;
Tbuf <kcommsdbsvrmaxcolumnnamelength> apnname;
Tbuf <10> defapn;
Tuint32 fakeiapid;
Aiapid = 0;
If (aiaptype = 0)
Defapn = _ L ("cmnet ");
Else if (aiaptype = 1)
Defapn = _ L ("cmwap ");
Else if (aiaptype = 2) // Simulator
Defapn = _ L ("Winsock ");
Trap (Ret,
{
Ccommsdatabase * commdb = ccommsdatabase: newl (edatabasetypeiap );
Cleanupstack: pushl (commdb );
Ccommsdbtableview * commview = commdb-> opentablelc (tptrc (outgoing_wcdma ));
If (commview-> gotofirstrecord () = kerrnone)
{
Do
{
Commview-> readtextl (tptrc) upls_apn, apnname );
Commview-> readuintl (tptrc (commdb_id), fakeiapid );
If (apnname. Find (defapn)> = 0) // case insensitive
{
Ccommsdbtableview * piapview = commdb-> openviewmatchinguintlc (tptrc (IAP), tptrc (iap_service), fakeiapid );
Tint nerr = piapview-> gotofirstrecord ();
If (nerr = kerrnone)
{
Piapview-> readuintl (tptrc (commdb_id), fakeiapid );
Aiapid = fakeiapid;
Cleanupstack: popanddestroy (); // piapview
Break;
}
Cleanupstack: popanddestroy (); // piapview
}
} While (commview-> gotonextrecord () = kerrnone );
}
Cleanupstack: popanddestroy (2 );
});
}

 

3. If the IAP selection box is not displayed when controlling the network connection of the application software, you need to create a Symbian rsocket.
Specify an existing connection object when calling the rsocket open method:
Tint open (rsocketserv & aserver, tuint addrfamily, tuint socktype, tuint protocol,
Rconnection & aconnection)
The rconnection object parameter is an existing connection object. Then, the IAP option is not displayed when you want to control the network connection of the application software.
Selection box, provided that the IAP selection box is not displayed when the initial rconnection object connection is created. This mechanism can be easily implemented as follows:
Rconnection gconnection;
Tcommdbconnpref Pref;
Tuint32 iapid = 2; // this value should be the exact Query Result
Pref. setiapid (iapid );
Pref. setdialogpreference (ecommdbdialogprefdonotprompt); // No dialog box appears when connected
Pref. setbearerset (ecommdbbearerpsd );
Pref. setdirection (ecommdbconnectiondireoutoutgoing );
Gconnection. Start (Pref); // synchronously create a network connection that hides the IAP selection box
In the above tcommdbconnpref object attribute, the most important thing is to determine the iapid value, because other attribute values are fixed, only this value is changed.

4. The IAP selection box is displayed, and the selected iapid is obtained.

You can use irconnection. Start (istatus); // The selection box is displayed.

After an asynchronous response, you can tuint32 iapid = 0;
Irconnection. getintsetting (_ L ("IAP // ID"), iapid );

To obtain the ID of the selected IAP.

See the description of getintsetting () in the help document.

 

5. Test

When you use an access point in the connection status, the request network does not pause.

When many software are found to connect to the network, the waiting progress is also smooth, and the network connection icon exists until the program exits.

The connection icon on the desktop may be related to the rsockesrv connection, and the rsocket will be closed after each sending and receiving.

Place the request progress to a step-by-step operation on the request network ....

 

6. During isocket. Connect (iaddress, istatus), this function does not return immediately. A post says this is a bug found on the simulator and does not exist on the mobile phone.

7. collect statistics on system traffic

Http://bbs.51cto.com/archiver/tid-857253.html

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.