[J2s-symbian network programming] include commdb. h
Add commdb. lib to the library list of the MPs File
1. enumerate all access points, including GRPS, Bluetooth, and WiFi
ReferenceCodeAs follows:
...
Ccommsdatabase * dB;
Ccommsdbtableview * view;
Tbuf <kcommsdbsvrmaxcolumnnamelength> iapname;
Tuint32 iapid;
Tint result;
// Open Database
DB = ccommsdatabase: newl (edatabasetypeiap );
Cleanupstack: pushl (db );
View = DB-> opentablelc (tptrc (IAP); // IAP is the table name
Result = view-> gotofirstrecord ();
Tint ncount = 0;
While (result = kerrnone) & (ncount <30 ))
{
View-> readtextl (tptrc (commdb_name), iapname );
View-> readuintl (tptrc (commdb_id), iapid );
Additem (iapname );
Ncount;
Result = view-> gotonextrecord ();
}
Cleanupstack: popanddestroy (2 );
...
2. enable the user to query the connection information after selecting the access point, including distinguishing GRPS, Wi-Fi, and proxy information.
Reference code:
...
M_bisgrps = etrue;
Proxy. Zero ();
Port = 0;
Tint result = kerrnone;
Tbool Bok = efalse;
// 1.is GRPS?
Ccommsdatabase * DB = ccommsdatabase: newl (edatabasetypeiap );
Tuint32 id = 0;
Tbuf <kcommsdbsvrmaxcolumnnamelength> iapname;
Tuint32 iapservice;
Tbuf <kcommsdbsvrmaxcolumnnamelength> servicetype;
Ccommsdbtableview * view = DB-> opentablelc (tptrc (IAP); // IAP is the table name
Result = view-> gotofirstrecord ();
While (result = kerrnone)
{
View-> readuintl (tptrc (commdb_id), ID );
View-> readtextl (tptrc (commdb_name), iapname );
View-> readuintl (tptrc (iap_service), iapservice );
View-> readtextl (tptrc (iap_service_type), servicetype );
If (IAP = ID)
{
If (0 = servicetype. Compare (tptrc (outgoing_gprs )))
{
M_bisgrps = etrue;
}
Else
{
M_bisgrps = efalse;
}
Bok = etrue;
Break;
}
Result = view-> gotonextrecord ();
}
Cleanupstack: popanddestroy ();
If (! Bok)
{
Return kerrnotfound;
}
// 2.get proxy
Ccommsdatabase * commsdb = ccommsdatabase: newl (edatabasetypeiap );
Ccommsdbtableview * commsview = commsdb-> openviewonproxyrecordlc (iapservice, servicetype );
Result = commsview-> gotofirstrecord ();
If (kerrnone! = Result)
{
Cleanupstack: popanddestroy ();
Return kerrnotfound;
}
Tbool proxyenabled (efalse );
Commsview-> readbooll (tptrc (proxy_use_proxy_server), proxyenabled );
If (! Proxyenabled)
{
Cleanupstack: popanddestroy ();
Return kerrnotfound;
}
Proxy. Copy (* commsview-> readlongtextlc (tptrc (proxy_server_name )));
Commsview-> readuintl (tptrc (proxy_port_number), Port );
Cleanupstack: popanddestroy (2 );
...