apengine/apeng/src/APSelect.cpp
branchRCL_3
changeset 13 68f0c7cd80ec
parent 8 2e6c4614c58e
child 17 c14618f9de99
equal deleted inserted replaced
12:ea6e024ea6f9 13:68f0c7cd80ec
    68 const TInt  KBEARERTYPE = 2;
    68 const TInt  KBEARERTYPE = 2;
    69 
    69 
    70 
    70 
    71 
    71 
    72 // LOCAL CONSTANTS AND MACROS
    72 // LOCAL CONSTANTS AND MACROS
    73 
    73 #define VPN_SERVICE_SNAP    _S("HomeSNAP")
    74 
    74 
    75 // LOCAL FUNCTION PROTOTYPES
    75 // LOCAL FUNCTION PROTOTYPES
    76 
    76 
    77 // ================= MEMBER FUNCTIONS =======================
    77 // ================= MEMBER FUNCTIONS =======================
    78 // Two-phased constructor.
    78 // Two-phased constructor.
   854                     TInt count = vpnArray->Count();
   854                     TInt count = vpnArray->Count();
   855                     
   855                     
   856                     CApUtils* util = CApUtils::NewLC( *iDb );
   856                     CApUtils* util = CApUtils::NewLC( *iDb );
   857                     for ( i = 0; i < count; i++ )
   857                     for ( i = 0; i < count; i++ )
   858                         {
   858                         {
   859                         // get home wap id first
   859                         if ( vpnArray->At( i ).iHomeIapId != 0 )
   860                         pos = PosInArray( ipiapid, 
   860                             {
   861                                           vpnArray->At( i ).iHomeIapId );
   861                             // get home wap id first
       
   862                             pos = PosInArray( ipiapid, 
       
   863                                              vpnArray->At( i ).iHomeIapId );
       
   864                             
       
   865                             }
       
   866                         else if ( vpnArray->At( i ).iHomeSnapId != 0 )
       
   867                             {
       
   868                             // VPN IAP points to a SNAP. Just mark it available.
       
   869                             pos = PosInArray( iapArrays[KVPN][1], vpnArray->At( i ).iVpnIapId );
       
   870                             if ( pos != KErrNotFound )
       
   871                                 { // now get VPN IAP ID
       
   872                                 TUint32 tempvpniapid = iapArrays[KVPN][0]->At( pos );
       
   873                                 TUint32 tempvpnwapid ( 0 );
       
   874                                 TRAP( err, tempvpnwapid = 
       
   875                                         util->WapIdFromIapIdL( 
       
   876                                                 tempvpniapid ) );
       
   877                                                     
       
   878                                 item = CApListItem::NewLC
       
   879                                     (
       
   880                                     EIspTypeInternetAndWAP,
       
   881                                     tempvpnwapid,
       
   882                                     *vpnArray->At( i ).iName,                                   
       
   883                                     EApBearerTypeAllBearers
       
   884                                     );
       
   885                                 item->SetVpnFlag( ETrue );
       
   886                                 iApList->AppendL( item );
       
   887                                 CleanupStack::Pop( item );
       
   888                                 continue;
       
   889                                 }                                                          
       
   890                             }                                                                                                              
       
   891                         
   862                         TInt foundpos( KErrNotFound );
   892                         TInt foundpos( KErrNotFound );
   863                         if ( pos!= KErrNotFound )
   893                         if ( pos!= KErrNotFound )
   864                             { // now we have the index in the
   894                             { // now we have the index in the
   865                             // ipiapid and as they are synchronized...
   895                             // ipiapid and as they are synchronized...
   866                             wapid = ipapid->At( pos );
   896                             wapid = ipapid->At( pos );
  2214             User::Leave( err );
  2244             User::Leave( err );
  2215             }
  2245             }
  2216         if ( err != KErrNotFound )
  2246         if ( err != KErrNotFound )
  2217             {
  2247             {
  2218             TUint32 tempvpn( 0 );
  2248             TUint32 tempvpn( 0 );
  2219             TUint32 temphome( 0 );
  2249             TUint32 temphomeiap( 0 );
       
  2250             TUint32 temphomesnap( 0 );
  2220             HBufC*  tempname = NULL;
  2251             HBufC*  tempname = NULL;
  2221             TVpnData data;
  2252             TVpnData data;
  2222             TBool goon( ETrue );
  2253             TBool goon( ETrue );
  2223             do
  2254             do
  2224                 {
  2255                 {
  2225                 err = ApCommons::ReadUintL( aTable, TPtrC(COMMDB_ID), 
  2256                 err = ApCommons::ReadUintL( aTable, TPtrC(COMMDB_ID), 
  2226                                             tempvpn );
  2257                                             tempvpn );
  2227                 if ( ( err == KErrNone ) && ( tempvpn ) )
  2258                 if ( ( err == KErrNone ) && ( tempvpn ) )
  2228                     {
  2259                     {
       
  2260                     // First try to check if VPN IAP uses another IAP directly
  2229                     err = ApCommons::ReadUintL( aTable, 
  2261                     err = ApCommons::ReadUintL( aTable, 
  2230                                                 TPtrC(VPN_SERVICE_IAP),
  2262                                                 TPtrC(VPN_SERVICE_IAP),                                                
  2231                                                 temphome );
  2263                                                 temphomeiap );
  2232                     if ( ( err == KErrNone ) && ( temphome ) )
  2264                     
       
  2265                     if ( (err != KErrNone ) || ( !tempvpn ) )
       
  2266                         {
       
  2267                         // IAP field was empty. VPN IAP must point to SNAP.
       
  2268                         err = ApCommons::ReadUintL( aTable, 
       
  2269                                 TPtrC(VPN_SERVICE_SNAP),                                                
       
  2270                                 temphomesnap );                                                         
       
  2271                         }
       
  2272                     
       
  2273                     if ( ( err == KErrNone ) && ( temphomeiap || temphomesnap ) )
  2233                         {
  2274                         {
  2234                         // now get the name
  2275                         // now get the name
  2235 
  2276 
  2236                         tempname = 
  2277                         tempname = 
  2237                             ApCommons::ReadText16ValueLC( aTable, 
  2278                             ApCommons::ReadText16ValueLC( aTable, 
  2238                                                           TPtrC(COMMDB_NAME) );
  2279                                                           TPtrC(COMMDB_NAME) );
  2239                         
  2280                         
  2240                         // everything is O.K., we can add the item
  2281                         // everything is O.K., we can add the item
  2241                         data.iHomeIapId = temphome;
  2282                         if ( temphomesnap )
       
  2283                             {
       
  2284                             data.iHomeSnapId = temphomesnap;
       
  2285                             data.iHomeIapId = 0;
       
  2286                             }
       
  2287                         else
       
  2288                             {
       
  2289                             data.iHomeSnapId = 0;
       
  2290                             data.iHomeIapId = temphomeiap;                            
       
  2291                             }                       
  2242                         data.iVpnIapId = tempvpn;
  2292                         data.iVpnIapId = tempvpn;
  2243                         data.iName = tempname;
  2293                         data.iName = tempname;
  2244                         aVpnArray->AppendL( data ); // array owns it...
  2294                         aVpnArray->AppendL( data ); // array owns it...
  2245                         }
  2295                         }
  2246                     // Only VPN iaps which point to a real IAP are added to list.
  2296                     // Only VPN iaps which point to a real IAP are added to list.