The Nokia example cannot be used directly on a mobile phone. It has been tested and modified several times .... The most perfect cmwap Access Point with proxy creation code is as follows, model judgment is also added in the middle ...... In short... It is a perfect version.
_ Metadata (kiapcmwap, "cmwap ");
_ Metadata (kapnname, "cmwap ");
# Define maid ("ifname ")
# Ifdef _ wins __
_ Timeout (Kip, "192.168.0.xxx"); // set your intranet
# Else
_ Forward (Kip, "10.0.0.172 ");
# Endif
//---------------------------------------------------------------------------
// Ciapconnectengine: createnewiapl (...)
//
// This function creates a new IAP record and insert it into the comms
// Database.
//---------------------------------------------------------------------------
//
Void ciapconnectengine: createnewiapl ()
{
Tint error;
Tuint32 uplsid;
Tint nid = 0;
Tuint32 iiapuid;
Tcommdbopeningmethod method;
Ccommsdatabase * CDB = ccommsdatabase: newl (edatabasetypeiap, method );
Cleanupstack: pushl (CDB );
Tversion version;
Version = User: Version ();
Tint Vs = version. ibuild;
// Iversion =;
Tint muid = 0;
HAL: Get (haldata: emanufacturer, muid );
// Iwhichwelcomeinfo = 0;
Ccommsdbtableview * view;
View = CDB-> openviewmatchingtextlc (tptrc (outgoing_gprs), tptrc (commdb_name), kapnname );
Error = view-> gotofirstrecord ();
If (error = kerrnone)
{
View-> readuintl (tptrc (commdb_id), GPRS Sid );
Tint error1 = view-> UpdateRecord ();
If (error1 = kerrnone)
{
View-> writetextl (tptrc (upls_apn), kiapcmwap );
View-> writetextl (tptrc (maid), _ L (""));
If (V. S. <400)
{
If (0x101f9072 = muid)
{
View-> writetextl (tptrc (upls_if_name), _ L ("PPP"); // GPRS
}
Else
{
View-> writetextl (tptrc (upls_if_name), _ L ("pppgprs "));//
}
}
View-> putrecordchanges ();
}
}
Else
{
Error = view-> insertrecord (GPRS Sid );
If (error! = Kerrnone)
{
Cleanupstack: popanddestroy (View );
Cleanupstack: popanddestroy (CDB );
Return;
}
View-> writetextl (tptrc (commdb_name), kapnname );
View-> writetextl (tptrc (upls_apn), kiapcmwap );
View-> writebooll (tptrc (maid), etrue );
View-> writebooll (tptrc (maid), etrue );
View-> writebooll (tptrc (maid), etrue );
View-> writetextl (tptrc (maid), _ L ("10.0.0.172 "));
View-> writetextl (tptrc (maid), _ L (""));
View-> writetextl (tptrc (maid), _ L (""));
View-> writeuintl (tptrc (upls_pdp_type), 0 );
View-> writebooll (tptrc (maid), efalse );
View-> writetextl (tptrc (maid), _ L ("ip "));
View-> writebooll (tptrc (upls_header_compression), efalse );
View-> writebooll (tptrc (maid), efalse );
View-> writeuintl (tptrc (maid), 0 );
View-> writeuintl (tptrc (maid), 0 );
View-> writeuintl (tptrc (maid), 0 );
View-> writeuintl (tptrc (maid), 0 );
View-> writeuintl (tptrc (maid), 0 );
View-> writeuintl (tptrc (upls_min_precedence), 0 );
View-> writeuintl (tptrc (upls_min_delay), 0 );
View-> writeuintl (tptrc (maid), 0 );
View-> writeuintl (tptrc (maid), 0 );
View-> writeuintl (tptrc (maid), 0 );
View-> writebooll (tptrc (maid), efalse );
If (vs >= 400)
{
View-> writebooll (tptrc (upls_use_edge), efalse );
}
View-> writebooll (tptrc (maid), efalse );
View-> writebooll (tptrc (maid), efalse );
View-> writeuintl (tptrc (upls_ap_type), 0 );
If (vs >= 400)
{
View-> writeuintl (tptrc (maid), 50000000 );
}
View-> writeuintl (tptrc (upls_pdp_type), 0 );
View-> writetextl (tptrc (maid address), _ L (""));
If (V. S. <400)
{
If (0x101f9072 = muid)
{
View-> writetextl (tptrc (upls_if_name), _ L ("PPP"); // GPRS
}
Else
{
View-> writetextl (tptrc (upls_if_name), _ L ("pppgprs "));//
}
}
View-> writetextl (tptrc (maid), _ L (""));
View-> writeuintl (tptrc (maid), 0 );
View-> writetextl (tptrc (maid), _ L (""));
View-> writetextl (tptrc (maid), _ L ("0.0.0.0 "));
View-> writetextl (tptrc (maid), _ L ("0.0.0.0 "));
View-> writetextl (tptrc (maid), _ L ("0.0.0.0 "));
Error = view-> putrecordchanges ();
}
Cleanupstack: popanddestroy (View );
// 2) Add record to Network
Tuint32 networkid;
If (vs >= 400)
{
Ccommsdbtableview * view2;
View2 = CDB-> openviewmatchingtextlc (tptrc (network), tptrc (commdb_name), _ L ("cmwap "));
Error = view2-> gotofirstrecord ();
If (error = kerrnone)
{
View-> readuintl (tptrc (commdb_id), networkid );
}
Else
{
Error = view2-> insertrecord (networkid );
If (error! = Kerrnone)
{
Cleanupstack: popanddestroy (view2 );
Cleanupstack: popanddestroy (CDB );
Return;
}
View2-> writetextl (tptrc (commdb_name), kapnname );
Error = view2-> putrecordchanges (efalse, efalse );
}
Cleanupstack: popanddestroy (view2 );
}
// 3) Search for Mobile Location ID
Tint result;
Tuint32 locationid;
Tuint32 cancelocationid;
Ccommsdbtableview * view3 = CDB-> opentablelc (tptrc (location ));
Result = view3-> gotofirstrecord ();
Tbuf <128> locationname;
While (result = kerrnone)
{
View3-> readtextl (tptrc (commdb_name), locationname );
View3-> readuintl (tptrc (location_mobile), locationid );
If (locationname. Match (_ L ("mobile "))! = Kerrnotfound)
Cancelocationid = locationid;
Result = view3-> gotonextrecord ();
}
Cleanupstack: popanddestroy (view3 );
// 4) Create IAP
Ccommsdbtableview * view4;
View4 = CDB-> openviewmatchingtextlc (tptrc (IAP), tptrc (commdb_name), kapnname );
Error = view4-> gotofirstrecord ();
If (error = kerrnone)
{
View4-> readuintl (tptrc (commdb_id), iiapuid );
Tint error1 = view4-> UpdateRecord ();
If (error1 = kerrnone)
{
View4-> writeuintl (tptrc (iap_service), GPRS Sid );
View4-> putrecordchanges (efalse, efalse );
}
}
Else
{
Error = view4-> insertrecord (iiapuid );
If (error! = Kerrnone)
{
Cleanupstack: popanddestroy (view4 );
Cleanupstack: popanddestroy (CDB );
Return;
}
View4-> writetextl (tptrc (commdb_name), kapnname );
View4-> writetextl (tptrc (iap_service_type), tptrc (outgoing_gprs ));
View4-> writeuintl (tptrc (iap_service), GPRS Sid );
If (vs >= 400)
{
View4-> writeuintl (tptrc (iap_network_weighting), 0 );
View4-> writeuintl (tptrc (iap_network), networkid );
// 6600 is 0x101fb3dd 6630 is 0x101fbb55
If (0x101fbb55 = muid | 0x101fb3dd = muid) // 3230 7610 is 2,6630 6600 is 1
{
View4-> writeuintl (tptrc (iap_bearer), 1 );
}
Else
{
View4-> writeuintl (tptrc (iap_bearer), 2 );
}
View4-> writetextl (tptrc (iap_bearer_type), tptrc (modem_bearer ));
}
View4-> writeuintl (tptrc (iap_location), cancelocationid );
Error = view4-> putrecordchanges (efalse, efalse );
}
Cleanupstack: popanddestroy (view4 );
// 5) Create wap_access_point
Tuint32 wapid;
Ccommsdbtableview * view5 = CDB-> openviewmatchingtextlc (tptrc (wap_access_point ),
Tptrc (commdb_name), kapnname );
Error = view5-> gotofirstrecord ();
If (error = kerrnone)
{
View5-> readuintl (tptrc (commdb_id), wapid );
}
Else
{
Error = view5-> insertrecord (wapid );
If (error! = Kerrnone)
{
Cleanupstack: popanddestroy (view5 );
Cleanupstack: popanddestroy (CDB );
Return;
}
View5-> writetextl (tptrc (commdb_name), kapnname );
View5-> writetextl (tptrc (wap_current_bearer), tptrc (wap_ip_bearer ));
View5-> writetextl (tptrc (wap_start_page), _ L ("http://www.unew.cn "));
Error = view5-> putrecordchanges (efalse, efalse );
}
Cleanupstack: popanddestroy (view5 );
// 6) Create wap_ip_bearer
Tuint32 wapipid;
Ccommsdbtableview * view6 = CDB-> openviewmatchinguintlc (tptrc (wap_ip_bearer ),
Tptrc (wap_access_point_id), wapid );
Error = view6-> gotofirstrecord ();
If (error = kerrnone)
{
View6-> readuintl (tptrc (commdb_id), wapipid );
Tint error1 = view6-> UpdateRecord ();
If (error1 = kerrnone)
{
View6-> writeuintl (tptrc (wap_access_point_id), wapid );
View6-> putrecordchanges (efalse, efalse );
}
}
Else
{
Error = view6-> insertrecord (wapipid );
If (error! = Kerrnone)
{
Cleanupstack: popanddestroy (view6 );
Cleanupstack: popanddestroy (CDB );
Return;
}
View6-> writeuintl (tptrc (wap_access_point_id), wapid );
View6-> writetextl (tptrc (wap_gateway_address), _ L ("0.0.0.0 "));
View6-> writeuintl (tptrc (wap_wsp_option), ewapwspoptionconnectionoriented );
View6-> writebooll (tptrc (wap_security), efalse );
View6-> writeuintl (tptrc (wap_iap), iiapuid );
If (vs >= 400)
{
View6-> writeuintl (tptrc (wap_proxy_port), 0 );
View6-> writetextl (tptrc (wap_proxy_login_name), _ L (""));
View6-> writetextl (tptrc (wap_proxy_login_pass), _ L (""));
}
Error = view6-> putrecordchanges (efalse, efalse );
}
Cleanupstack: popanddestroy (view6 );
Cleanupstack: popanddestroy (CDB );
// 7) proxy
_ Forward (Kip, "10.0.0.172 ");
Tuint32 proxiesid;
Ccommsdatabase * cdb7 = ccommsdatabase: newl (edatabasetypeiap );
Cleanupstack: pushl (cdb7 );
Ccommsdbtableview * view7 = cdb7-> opentablelc (tptrc (proxies ));
User: leaveiferror (view7-> insertrecord (proxiesid ));
View7-> writeuintl (tptrc (proxy_isp), GPRS Sid );
View7-> writetextl (tptrc (proxy_service_type), tptrc (outgoing_gprs ));
View7-> writebooll (tptrc (proxy_use_proxy_server), etrue );
View7-> writelongtextl (tptrc (proxy_server_name), kip );
View7-> writetextl (tptrc (proxy_protocol_name), _ L ("HTTP "));
View7-> writeuintl (tptrc (proxy_port_number), 80 );
Error = view7-> putrecordchanges (etrue, efalse );
If (error! = Kerrnone)
{
User: Leave (error );
}
Cleanupstack: popanddestroy (2 );
}