Traverse all access points in Symbian and dynamically display them in popupsettingitem)

Source: Internet
Author: User

In network connection selection, we usually traverse existing access points in the user's mobile phone, and then select an appropriate access point to connect to the network. Because the number of existing access points in each mobile phone is different, dynamic reading and existing access points are required. Therefore, you can inherit caknenumeratedtextpopupsettingitem, overload the completeconstructionl () method, and implement it in caknsettingitemlist,

Lib commdb. Lib

Accesspointsettingitem. h

# Include <aknsettingitemlist. h>

Class caccesspointsettingitem: Public caknenumeratedtextpopupsettingitem
{
Public:
Caccesspointsettingitem (tint aidentifier, tint & avalue );
// Load the IAP data
Tint loadiaplistl ();

Void loadl ();

PRIVATE:
Void createandexecutesettingpagel ();
Void completeconstructionl ();

PRIVATE:
Tint & ivalue;
};


Caccesspointsettingitem. cpp

# Include <commdb. h>
# Include "aaccesspointsettingitem. H"

Caccesspointsettingitem: cmobbleraccesspointsettingitem (tint aidentifier, tint & avalue)
: Caknenumeratedtextpopupsettingitem (aidentifier, avalue), ivalue (avalue)
{
}


// We must check whether the target value, ivalue, is in the loaded array or not.
// if not, it definitely causes a panic -- "setting item Lis 6 ".
// In that case, we will choose the first item as the default one.
void caccesspointsettingitem: loadl ()
{< BR style =" line-Height: normal; "> carrayptr * Texts (enumeratedtextarray ();
tint selectedindex (indexfromvalue (ivalue);

If (selectedindex <0) // No match found.
{
If (texts-> count ()> 0)
{
// Choose the first item as default one.
Caknenumeratedtext * Item (texts-> at (0 ));
// Reset external value to the default one.
Setexternalvalue (item-> enumerationvalue ());
}
}

Caknenumeratedtextpopupsettingitem: loadl ();
}

tint caccesspointsettingitem: loadiaplistl ()
{< BR style =" line-Height: normal; "> tint firstiapid (kerrnotfound);
carrayptr * Texts = This-> enumeratedtextarray ();
// The destinations API does not exist
// so list all the connection points

// Add all the access points to the list
ccommsdatabase * commdb (ccommsdatabase: newl (edatabasetypeiap);
cleanupstack: pushl (commdb);

// Open IAP table
Ccommsdbtableview * commview (commdb-> openiaptableviewmatchingbearersetlc (
Ecommdbbearergprs | ecommdbbearerwlan,
Ecommdbconnectiondireoutoutgoing ));

// Search all IAPS
For (tint error (commview-> gotofirstrecord (); error = kerrnone; Error
= Commview-> gotonextrecord ())
{
Tbuf <kcommsdbsvrmaxcolumnnamelength> iapname;
Tuint32 iapid;

Commview-> readtextl (tptrc (commdb_name), iapname );
Commview-> readuintl (tptrc (commdb_id), iapid );

Hbufc * Text (iapname. alloclc ());
Caknenumeratedtext * enumtext (New (eleave) caknenumeratedtext (iapid,
Text ));
Cleanupstack: Pop (text );
Cleanupstack: pushl (enumtext );
Enumeratedtextarray ()-> appendl (enumtext );
Cleanupstack: Pop (enumtext );

If (firstiapid = kerrnotfound)
{
Firstiapid = iapid;
}

}

Cleanupstack: popanddestroy (commview );
Cleanupstack: popanddestroy (commdb );

Return firstiapid;
}

Void caccesspointsettingitem: createandexecutesettingpagel ()
{
Caknsettingpage * DLG (createsettingpagel ());

Setsettingpage (DLG );
Settingpage ()-> setsettingpageobserver (this );

Settingpage ()-> setsettingtextl (settingname ());

Settingpage ()-> executeld (caknsettingpage: eupdatewhenchanged );
Setsettingpage (0 );
}

Void caccesspointsettingitem: completeconstructionl ()
{
Caknenumeratedtextpopupsettingitem: completeconstructionl ();
}

Constructing resources in RSS
Resource avkon_popup_setting_texts r_popup_setting_texts_enum
{
Setting_texts_resource = r_texts_enum;
}


Resource array r_texts_enum
{
Items =
{
Avkon_enumerated_text
{
Value = 0;
TEXT = "";
}
};
}

Resource avkon_setting_page r_setting_page_enum
{
Type = eaknctpopupsettinglist;
Editor_resource_id = r_popup_setting_list_enum;
}

Resource popup_setting_list r_popup_setting_list_enum
{
Flags = 0;
}


Call in ccoecontrol
Caknsettingitemlist * iitemlist;

Tint tempiapid (0 );
Const tdesc & text (_ L ("accesspoint "));
Caccesspointsettingitem * Item (New (eleave) caccesspointsettingitem (0, tempiapid ));
Cleanupstack: pushl (item );
Item-> constructl (isnumberedstyle, icount, text, icons, r_setting_page_enum,-1, 0, r_popup_setting_texts_enum );

Carrayptr <caknenumeratedtext> * textss (item-> enumeratedtextarray ());
Textss-> resetanddestroy ();
Tint firstiapid (item-> loadiaplistl ());
// Load list of IAPS
Item-> load ();
//> Append list
Iitemlist-> settingitemarray ()-> appendl (item );
Cleanupstack: Pop (item );

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.