apengine/apeng/src/ApProtHandler.cpp
changeset 66 ed07dcc72692
parent 20 9c97ad6591ae
equal deleted inserted replaced
64:84c6623982f6 66:ed07dcc72692
    40 // CApProtHandler::IsTableProtectedL
    40 // CApProtHandler::IsTableProtectedL
    41 // ---------------------------------------------------------
    41 // ---------------------------------------------------------
    42 //
    42 //
    43 EXPORT_C TBool CApProtHandler::IsTableProtectedL( CCommsDatabase* aDb )
    43 EXPORT_C TBool CApProtHandler::IsTableProtectedL( CCommsDatabase* aDb )
    44     {
    44     {
    45     CLOG( ( EProtection, 0, _L( "-> CApProtHandler::IsTableProtectedL" ) ) );
    45     return EFalse;
    46 
       
    47     TBool retval( EFalse );
       
    48     retval = IsTableProtectedL( aDb, TPtrC(WAP_ACCESS_POINT) );
       
    49 
       
    50     CLOG( ( EProtection, 1, _L( "<- CApProtHandler::IsTableProtectedL" ) ) );
       
    51     return retval;
       
    52     }
    46     }
    53 
    47 
    54 
    48 
    55 // ---------------------------------------------------------
    49 // ---------------------------------------------------------
    56 // CApProtHandler::IsApProtectedL
    50 // CApProtHandler::IsApProtectedL
    57 // ---------------------------------------------------------
    51 // ---------------------------------------------------------
    58 //
    52 //
    59 EXPORT_C TBool CApProtHandler::IsApProtectedL( CCommsDatabase* aDb,
    53 EXPORT_C TBool CApProtHandler::IsApProtectedL( CCommsDatabase* aDb,
    60                                                      TUint32 aUid )
    54                                                      TUint32 aUid )
    61     {
    55     {
    62     CLOG( ( EProtection, 0, _L( "-> CApProtHandler::IsApProtectedL" ) ) );
    56     return EFalse;
    63 
       
    64     TBool retval( EFalse );
       
    65     retval = IsRecordProtectedL( aDb, TPtrC(WAP_ACCESS_POINT), aUid );
       
    66     
       
    67     CLOG( ( EProtection, 1, _L( "<- CApProtHandler::IsApProtectedL" ) ) );
       
    68     return retval;
       
    69     }
    57     }
    70 
    58 
    71 
    59 
    72 // ---------------------------------------------------------
    60 // ---------------------------------------------------------
    73 // CApProtHandler::ProtectItemL
    61 // CApProtHandler::ProtectItemL
    74 // ---------------------------------------------------------
    62 // ---------------------------------------------------------
    75 //
    63 //
    76 EXPORT_C void CApProtHandler::ProtectItemL( CCommsDatabase* aDb,
    64 EXPORT_C void CApProtHandler::ProtectItemL( CCommsDatabase* aDb,
    77                                              TUint32 aUid )
    65                                              TUint32 aUid )
    78     {
    66     {
    79     CLOG( ( EProtection, 0, _L( "-> CApProtHandler::ProtectItemL" ) ) );
       
    80 
       
    81     if ( ApCommons::GetVariantL() & KApUiEditOnlyVPNs )
       
    82         {
       
    83         User::Leave( KErrNotSupported );
       
    84         }
       
    85 #ifdef __TEST_CDMA_WRITE_PROTECT
       
    86     User::Leave( KErrNotSupported );
       
    87 #endif // __TEST_CDMA_WRITE_PROTECT
       
    88 
       
    89     ProtectRecordL( aDb, TPtrC(WAP_ACCESS_POINT), aUid );
       
    90     
       
    91     CLOG( ( EProtection, 1, _L( "<- CApProtHandler::ProtectItemL" ) ) );
       
    92     }
    67     }
    93 
    68 
    94 
    69 
    95 // ---------------------------------------------------------
    70 // ---------------------------------------------------------
    96 // CApProtHandler::UnprotectItemL
    71 // CApProtHandler::UnprotectItemL
    97 // ---------------------------------------------------------
    72 // ---------------------------------------------------------
    98 //
    73 //
    99 EXPORT_C void CApProtHandler::UnprotectItemL( CCommsDatabase* aDb,
    74 EXPORT_C void CApProtHandler::UnprotectItemL( CCommsDatabase* aDb,
   100                                                TUint32 aUid )
    75                                                TUint32 aUid )
   101     {
    76     {
   102     CLOG( ( EProtection, 0, _L( "-> CApProtHandler::UnprotectItemL" ) ) );
       
   103 
       
   104     if ( ApCommons::GetVariantL() & KApUiEditOnlyVPNs )
       
   105         {
       
   106         User::Leave( KErrNotSupported );
       
   107         }
       
   108 #ifdef __TEST_CDMA_WRITE_PROTECT
       
   109     User::Leave( KErrNotSupported );
       
   110 #endif // __TEST_CDMA_WRITE_PROTECT
       
   111 
       
   112     UnprotectRecordL( aDb, TPtrC(WAP_ACCESS_POINT), aUid );
       
   113     
       
   114     CLOG( ( EProtection, 1, _L( "<- CApProtHandler::UnprotectItemL" ) ) );
       
   115     }
    77     }
   116 
    78 
   117 
    79 
   118 
    80 
   119 // ---------------------------------------------------------
    81 // ---------------------------------------------------------
   120 // CApProtHandler::ProtectTableL
    82 // CApProtHandler::ProtectTableL
   121 // ---------------------------------------------------------
    83 // ---------------------------------------------------------
   122 //
    84 //
   123 EXPORT_C void CApProtHandler::ProtectTableL( CCommsDatabase* aDb )
    85 EXPORT_C void CApProtHandler::ProtectTableL( CCommsDatabase* aDb )
   124     {
    86     {
   125     CLOG( ( EProtection, 0, _L( "-> CApProtHandler::ProtectTableL" ) ) );
       
   126 
       
   127     if ( ApCommons::GetVariantL() & KApUiEditOnlyVPNs )
       
   128         {
       
   129         User::Leave( KErrNotSupported );
       
   130         }
       
   131 #ifdef __TEST_CDMA_WRITE_PROTECT
       
   132     User::Leave( KErrNotSupported );
       
   133 #endif // __TEST_CDMA_WRITE_PROTECT
       
   134 
       
   135     ProtectTableL( aDb, TPtrC(WAP_ACCESS_POINT) );
       
   136     
       
   137     CLOG( ( EProtection, 1, _L( "<- CApProtHandler::ProtectTableL" ) ) );
       
   138     }
    87     }
   139 
    88 
   140 
    89 
   141 // ---------------------------------------------------------
    90 // ---------------------------------------------------------
   142 // CApProtHandler::UnprotectTableL
    91 // CApProtHandler::UnprotectTableL
   143 // ---------------------------------------------------------
    92 // ---------------------------------------------------------
   144 //
    93 //
   145 EXPORT_C void CApProtHandler::UnprotectTableL( CCommsDatabase* aDb )
    94 EXPORT_C void CApProtHandler::UnprotectTableL( CCommsDatabase* aDb )
   146     {
    95     {
   147     CLOG( ( EProtection, 0, _L( "-> CApProtHandler::UnprotectTableL" ) ) );
       
   148 
       
   149     if ( ApCommons::GetVariantL() & KApUiEditOnlyVPNs )
       
   150         {
       
   151         User::Leave( KErrNotSupported );
       
   152         }
       
   153 #ifdef __TEST_CDMA_WRITE_PROTECT
       
   154     User::Leave( KErrNotSupported );
       
   155 #endif // __TEST_CDMA_WRITE_PROTECT
       
   156 
       
   157     UnprotectTableL( aDb, TPtrC(WAP_ACCESS_POINT) );
       
   158 
       
   159     CLOG( ( EProtection, 1, _L( "<- CApProtHandler::UnprotectTableL" ) ) );
       
   160     }
    96     }
   161 
    97 
   162 
    98 
   163 // ---------------------------------------------------------
    99 // ---------------------------------------------------------
   164 // CApProtHandler::IsPreferencesProtectedL
   100 // CApProtHandler::IsPreferencesProtectedL
   165 // ---------------------------------------------------------
   101 // ---------------------------------------------------------
   166 //
   102 //
   167 EXPORT_C TBool CApProtHandler::IsPreferencesProtectedL( CCommsDatabase* aDb )
   103 EXPORT_C TBool CApProtHandler::IsPreferencesProtectedL( CCommsDatabase* aDb )
   168     {
   104     {
   169     CLOG( ( EProtection, 0, 
   105     return EFalse;
   170         _L( "-> CApProtHandler::IsPreferencesProtectedL" ) ) );
       
   171 
       
   172     CCommsDatabase* db = aDb;
       
   173     if ( !aDb )
       
   174         {
       
   175         // create DB object
       
   176         db = CCommsDatabase::NewL( ETrue );
       
   177         CleanupStack::PushL( db );
       
   178         }
       
   179 
       
   180     CCommsDbProtectConnectPrefTableView* table = 
       
   181         STATIC_CAST( CCommsDbProtectConnectPrefTableView*, 
       
   182                      db->OpenConnectionPrefTableLC());
       
   183 
       
   184     TInt err = table->GotoFirstRecord();
       
   185     if ( err != KErrNotFound )
       
   186         {
       
   187         User::LeaveIfError( err );
       
   188         }
       
   189 
       
   190     RDbRowSet::TAccess access;
       
   191     User::LeaveIfError( table->GetTableAccess( access ) ); 
       
   192     CleanupStack::PopAndDestroy( table ); 
       
   193     if ( !aDb )
       
   194         {
       
   195         CleanupStack::PopAndDestroy( db ); //db
       
   196         }
       
   197     
       
   198     //access is EUpdatable if record is updatable
       
   199     TBool retval( !(access == RDbRowSet::EUpdatable) );
       
   200 
       
   201     CLOG( ( EProtection, 1, 
       
   202         _L( "<- CApProtHandler::IsPreferencesProtectedL" ) ) );
       
   203     return retval;
       
   204     }
   106     }
   205 
   107 
   206 
   108 
   207 // ---------------------------------------------------------
   109 // ---------------------------------------------------------
   208 // CApProtHandler::ProtectPreferencesL
   110 // CApProtHandler::ProtectPreferencesL
   209 // ---------------------------------------------------------
   111 // ---------------------------------------------------------
   210 //
   112 //
   211 EXPORT_C void CApProtHandler::ProtectPreferencesL( CCommsDatabase* aDb )
   113 EXPORT_C void CApProtHandler::ProtectPreferencesL( CCommsDatabase* aDb )
   212     {
   114     {
   213     CLOG( ( EProtection, 0, _L( "-> CApProtHandler::ProtectPreferencesL" ) ) );
       
   214 
       
   215     if ( ApCommons::GetVariantL() & KApUiEditOnlyVPNs )
       
   216         {
       
   217         User::Leave( KErrNotSupported );
       
   218         }
       
   219 #ifdef __TEST_CDMA_WRITE_PROTECT
       
   220     User::Leave( KErrNotSupported );
       
   221 #endif // __TEST_CDMA_WRITE_PROTECT
       
   222 
       
   223     CCommsDatabase* db = aDb;
       
   224     if ( !aDb )
       
   225         {
       
   226         // create DB object
       
   227         db = CCommsDatabase::NewL( ETrue );
       
   228         CleanupStack::PushL( db );
       
   229         }
       
   230 
       
   231     CCommsDbProtectConnectPrefTableView* table = 
       
   232         STATIC_CAST( CCommsDbProtectConnectPrefTableView*, 
       
   233                      db->OpenConnectionPrefTableLC());
       
   234 
       
   235     User::LeaveIfError( table->GotoFirstRecord() );
       
   236     User::LeaveIfError( table->ProtectTable() );
       
   237     
       
   238     CleanupStack::PopAndDestroy( table ); 
       
   239 
       
   240     if ( !aDb )
       
   241         {
       
   242         CleanupStack::PopAndDestroy( db ); //db
       
   243         }
       
   244 
       
   245     CLOG( ( EProtection, 1, _L( "<- CApProtHandler::ProtectPreferencesL" ) ) );
       
   246     }
   115     }
   247 
   116 
   248 
   117 
   249 
   118 
   250 // ---------------------------------------------------------
   119 // ---------------------------------------------------------
   251 // CApProtHandler::UnprotectPreferencesL
   120 // CApProtHandler::UnprotectPreferencesL
   252 // ---------------------------------------------------------
   121 // ---------------------------------------------------------
   253 //
   122 //
   254 EXPORT_C void CApProtHandler::UnprotectPreferencesL( CCommsDatabase* aDb )
   123 EXPORT_C void CApProtHandler::UnprotectPreferencesL( CCommsDatabase* aDb )
   255     {
   124     {
   256     CLOG( ( EProtection, 0, 
       
   257         _L( "-> CApProtHandler::UnprotectPreferencesL" ) ) );
       
   258 
       
   259     if ( ApCommons::GetVariantL() & KApUiEditOnlyVPNs )
       
   260         {
       
   261         User::Leave( KErrNotSupported );
       
   262         }
       
   263 #ifdef __TEST_CDMA_WRITE_PROTECT
       
   264     User::Leave( KErrNotSupported );
       
   265 #endif // __TEST_CDMA_WRITE_PROTECT
       
   266 
       
   267     CCommsDatabase* db = aDb;
       
   268     if ( !aDb )
       
   269         {
       
   270         // create DB object
       
   271         db = CCommsDatabase::NewL( ETrue );
       
   272         CleanupStack::PushL( db );
       
   273         }
       
   274     CCommsDbProtectConnectPrefTableView* table = 
       
   275         STATIC_CAST( CCommsDbProtectConnectPrefTableView*, 
       
   276                      db->OpenConnectionPrefTableLC());
       
   277 
       
   278     User::LeaveIfError( table->GotoFirstRecord() );
       
   279     User::LeaveIfError( table->UnprotectTable() );
       
   280     
       
   281     CleanupStack::PopAndDestroy( table );
       
   282     if ( !aDb )
       
   283         {
       
   284         CleanupStack::PopAndDestroy( db ); //db
       
   285         }
       
   286     
       
   287     CLOG( ( EProtection, 1, 
       
   288         _L( "<- CApProtHandler::UnprotectPreferencesL" ) ) );
       
   289     }
   125     }
   290 
   126 
   291 
   127 
   292 
   128 
   293 // ---------------------------------------------------------
   129 // ---------------------------------------------------------
   295 // ---------------------------------------------------------
   131 // ---------------------------------------------------------
   296 //
   132 //
   297 EXPORT_C void CApProtHandler::RemoveProtectedAccessPointsL(
   133 EXPORT_C void CApProtHandler::RemoveProtectedAccessPointsL(
   298                                           CCommsDatabase* aDb)
   134                                           CCommsDatabase* aDb)
   299     {
   135     {
   300     CLOG( ( EProtection, 0, 
       
   301         _L( "-> CApProtHandler::RemoveProtectedAccessPointsL" ) ) );
       
   302 
       
   303     if ( ApCommons::GetVariantL() & KApUiEditOnlyVPNs )
       
   304         {
       
   305         User::Leave( KErrNotSupported );
       
   306         }
       
   307 #ifdef __TEST_CDMA_WRITE_PROTECT
       
   308     User::Leave( KErrNotSupported );
       
   309 #endif // __TEST_CDMA_WRITE_PROTECT
       
   310 
       
   311     CCommsDatabase* db;
       
   312     if ( !aDb )
       
   313         {
       
   314         // create DB object
       
   315         db = CCommsDatabase::NewL( ETrue );
       
   316         CleanupStack::PushL( db );
       
   317         }
       
   318     else
       
   319         {
       
   320         db = aDb;
       
   321         }
       
   322     DoRemoveProtectedAccessPointsL( *db );
       
   323 
       
   324     if ( !aDb )
       
   325         {
       
   326         CleanupStack::PopAndDestroy( db ); // db
       
   327         }
       
   328 
       
   329     CLOG( ( EProtection, 1, 
       
   330         _L( "<- CApProtHandler::RemoveProtectedAccessPointsL" ) ) );
       
   331     }
   136     }
   332 
   137 
   333 // ================== OTHER MEMBER FUNCTIONS ===============
   138 // ================== OTHER MEMBER FUNCTIONS ===============
   334 
   139 
   335 
   140 
   342 //
   147 //
   343 TBool CApProtHandler::IsRecordProtectedL( CCommsDatabase* aDb,
   148 TBool CApProtHandler::IsRecordProtectedL( CCommsDatabase* aDb,
   344                                             const TDesC& aTable,
   149                                             const TDesC& aTable,
   345                                             TUint32 aUid )
   150                                             TUint32 aUid )
   346     {
   151     {
   347     CLOG( ( EProtection, 0, _L( "-> CApProtHandler::IsRecordProtectedL" ) ) );
   152     return EFalse;
   348 
       
   349     CCommsDatabase* db = aDb;
       
   350     if ( !aDb )
       
   351         {
       
   352         // create DB object
       
   353         db = CCommsDatabase::NewL( ETrue );
       
   354         CleanupStack::PushL( db );
       
   355         }
       
   356 
       
   357     TBool ownTransaction = ApCommons::StartPushedTransactionLC( *db, ETrue );
       
   358 
       
   359     CCommsDbProtectTableView* view =
       
   360         (CCommsDbProtectTableView*)db->OpenViewMatchingUintLC
       
   361                                              (
       
   362                                               aTable,
       
   363                                               TPtrC(COMMDB_ID),
       
   364                                               aUid
       
   365                                              );
       
   366 
       
   367     TInt err = view->GotoFirstRecord();
       
   368     User::LeaveIfError( err );
       
   369 
       
   370     TInt prot( EFalse );
       
   371     User::LeaveIfError( view->GetRecordAccess( prot ) );
       
   372 
       
   373     CleanupStack::PopAndDestroy( view ); // view
       
   374 
       
   375     if ( ownTransaction )
       
   376         {
       
   377         ApCommons::CommitTransaction( *db );
       
   378         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   379         }
       
   380 
       
   381     if ( !aDb )
       
   382         {
       
   383         CleanupStack::PopAndDestroy( db ); // db
       
   384         }
       
   385         
       
   386     CLOG( ( EProtection, 1, _L( "<- CApProtHandler::IsRecordProtectedL" ) ) );
       
   387     return prot;
       
   388     }
   153     }
   389 
   154 
   390 
   155 
   391 
   156 
   392 // ---------------------------------------------------------
   157 // ---------------------------------------------------------
   394 // ---------------------------------------------------------
   159 // ---------------------------------------------------------
   395 //
   160 //
   396 void CApProtHandler::ProtectRecordL( CCommsDatabase* aDb,
   161 void CApProtHandler::ProtectRecordL( CCommsDatabase* aDb,
   397                                     const TDesC& aTable, TUint32 aUid )
   162                                     const TDesC& aTable, TUint32 aUid )
   398     {
   163     {
   399     CLOG( ( EProtection, 0, _L( "-> CApProtHandler::ProtectRecordL" ) ) );
       
   400 
       
   401     if ( ApCommons::GetVariantL() & KApUiEditOnlyVPNs )
       
   402         {
       
   403         User::Leave( KErrNotSupported );
       
   404         }
       
   405 #ifdef __TEST_CDMA_WRITE_PROTECT
       
   406     User::Leave( KErrNotSupported );
       
   407 #endif // __TEST_CDMA_WRITE_PROTECT
       
   408 
       
   409     CCommsDatabase* db = aDb;
       
   410     if ( !aDb )
       
   411         {
       
   412         // create DB object
       
   413         db = CCommsDatabase::NewL( ETrue );
       
   414         CleanupStack::PushL( db );
       
   415         }
       
   416     TBool ownTransaction = ApCommons::StartPushedTransactionLC( *db, ETrue );
       
   417 
       
   418     CCommsDbProtectTableView* view =
       
   419         (CCommsDbProtectTableView*)db->OpenViewMatchingUintLC
       
   420                                                 (
       
   421                                                  aTable,
       
   422                                                  TPtrC(COMMDB_ID),
       
   423                                                  aUid
       
   424                                                 );
       
   425 
       
   426     TInt err = view->GotoFirstRecord();
       
   427     User::LeaveIfError( err );
       
   428 
       
   429     User::LeaveIfError( view->ProtectRecord() );
       
   430 
       
   431     CleanupStack::PopAndDestroy( view ); // view
       
   432 
       
   433     if ( ownTransaction )
       
   434         {
       
   435         ApCommons::CommitTransaction( *db );
       
   436         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   437         }
       
   438 
       
   439     if ( !aDb )
       
   440         {
       
   441         CleanupStack::PopAndDestroy( db ); // db
       
   442         }
       
   443     
       
   444     CLOG( ( EProtection, 1, _L( "<- CApProtHandler::ProtectRecordL" ) ) );
       
   445     }
   164     }
   446 
   165 
   447 
   166 
   448 
   167 
   449 // ---------------------------------------------------------
   168 // ---------------------------------------------------------
   451 // ---------------------------------------------------------
   170 // ---------------------------------------------------------
   452 //
   171 //
   453 void CApProtHandler::UnprotectRecordL( CCommsDatabase* aDb,
   172 void CApProtHandler::UnprotectRecordL( CCommsDatabase* aDb,
   454                                       const TDesC& aTable, TUint32 aUid )
   173                                       const TDesC& aTable, TUint32 aUid )
   455     {
   174     {
   456     CLOG( ( EProtection, 0, _L( "-> CApProtHandler::UnprotectRecordL" ) ) );
       
   457 
       
   458     if ( ApCommons::GetVariantL() & KApUiEditOnlyVPNs )
       
   459         {
       
   460         User::Leave( KErrNotSupported );
       
   461         }
       
   462 #ifdef __TEST_CDMA_WRITE_PROTECT
       
   463     User::Leave( KErrNotSupported );
       
   464 #endif // __TEST_CDMA_WRITE_PROTECT
       
   465 
       
   466     CCommsDatabase* db = aDb;
       
   467     if ( !aDb )
       
   468         {
       
   469         // create DB object
       
   470         db = CCommsDatabase::NewL( ETrue );
       
   471         CleanupStack::PushL( db );
       
   472         }
       
   473     TBool ownTransaction = ApCommons::StartPushedTransactionLC( *db, ETrue );
       
   474 
       
   475     CCommsDbProtectTableView* view =
       
   476         (CCommsDbProtectTableView*)db->OpenViewMatchingUintLC
       
   477                                              (
       
   478                                               aTable,
       
   479                                               TPtrC(COMMDB_ID),
       
   480                                               aUid
       
   481                                              );
       
   482 
       
   483     TInt err = view->GotoFirstRecord();
       
   484     User::LeaveIfError( err );
       
   485 
       
   486     User::LeaveIfError( view->UnprotectRecord() );
       
   487 
       
   488     CleanupStack::PopAndDestroy( view ); // view
       
   489 
       
   490     if ( ownTransaction )
       
   491         {
       
   492         ApCommons::CommitTransaction( *db );
       
   493         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   494         }
       
   495 
       
   496     if ( !aDb )
       
   497         {
       
   498         CleanupStack::PopAndDestroy( db ); // db
       
   499         }
       
   500 
       
   501     CLOG( ( EProtection, 1, _L( "<- CApProtHandler::UnprotectRecordL" ) ) );
       
   502     }
   175     }
   503 
   176 
   504 
   177 
   505 
   178 
   506 
   179 
   509 // ---------------------------------------------------------
   182 // ---------------------------------------------------------
   510 //
   183 //
   511 TBool CApProtHandler::IsTableProtectedL( CCommsDatabase* aDb,
   184 TBool CApProtHandler::IsTableProtectedL( CCommsDatabase* aDb,
   512                                                const TDesC& aTable )
   185                                                const TDesC& aTable )
   513     {
   186     {
   514     CLOG( ( EProtection, 0, 
   187     return EFalse;
   515         _L( "-> CApProtHandler::IsTableProtectedL(table)" ) ) );
       
   516 
       
   517     TBool retval( EFalse );
       
   518     CCommsDatabase* db = aDb;
       
   519     if ( !aDb )
       
   520         {
       
   521         // create DB object
       
   522         db = CCommsDatabase::NewL( ETrue );
       
   523         CleanupStack::PushL( db );
       
   524         }
       
   525     TBool ownTransaction = ApCommons::StartPushedTransactionLC( *db, ETrue );
       
   526 
       
   527     CCommsDbProtectTableView* view =
       
   528         (CCommsDbProtectTableView*)db->OpenTableLC( aTable );
       
   529 
       
   530     RDbRowSet::TAccess aAccessType( RDbRowSet::EUpdatable );
       
   531     
       
   532     User::LeaveIfError( view->GetTableAccess( aAccessType) );
       
   533     
       
   534     if ( aAccessType == RDbRowSet::EUpdatable )
       
   535         {
       
   536         retval = EFalse;
       
   537         }
       
   538     else
       
   539         { // EReadOnly, EInsertOnly
       
   540         retval = ETrue;
       
   541         }
       
   542 
       
   543     CleanupStack::PopAndDestroy( view ); // view
       
   544 
       
   545     if ( ownTransaction )
       
   546         {
       
   547         ApCommons::CommitTransaction( *db );
       
   548         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   549         }
       
   550 
       
   551     if ( !aDb )
       
   552         {
       
   553         CleanupStack::PopAndDestroy( db ); // db
       
   554         }
       
   555     
       
   556     CLOG( ( EProtection, 1, 
       
   557         _L( "<- CApProtHandler::IsTableProtectedL(table)" ) ) );
       
   558     return retval;
       
   559     }
   188     }
   560 
   189 
   561 
   190 
   562 // ---------------------------------------------------------
   191 // ---------------------------------------------------------
   563 // CApProtHandler::ProtectTableL
   192 // CApProtHandler::ProtectTableL
   564 // ---------------------------------------------------------
   193 // ---------------------------------------------------------
   565 //
   194 //
   566 void CApProtHandler::ProtectTableL( CCommsDatabase* aDb,
   195 void CApProtHandler::ProtectTableL( CCommsDatabase* aDb,
   567                                      const TDesC& aTable )
   196                                      const TDesC& aTable )
   568     {
   197     {
   569     CLOG( ( EProtection, 0, 
       
   570         _L( "-> CApProtHandler::ProtectTableL(table)" ) ) );
       
   571 
       
   572     if ( ApCommons::GetVariantL() & KApUiEditOnlyVPNs )
       
   573         {
       
   574         User::Leave( KErrNotSupported );
       
   575         }
       
   576 #ifdef __TEST_CDMA_WRITE_PROTECT
       
   577     User::Leave( KErrNotSupported );
       
   578 #endif // __TEST_CDMA_WRITE_PROTECT
       
   579 
       
   580     CCommsDatabase* db = aDb;
       
   581     if ( !aDb )
       
   582         {
       
   583         // create DB object
       
   584         db = CCommsDatabase::NewL( ETrue );
       
   585         CleanupStack::PushL( db );
       
   586         }
       
   587 
       
   588     CCommsDbProtectTableView* view =
       
   589         (CCommsDbProtectTableView*)db->OpenTableLC( aTable );
       
   590 
       
   591     TInt err = view->GotoFirstRecord();
       
   592     User::LeaveIfError( err );
       
   593 
       
   594     User::LeaveIfError( view->ProtectTable() );
       
   595 
       
   596     CleanupStack::PopAndDestroy( view ); // view
       
   597 
       
   598     if ( !aDb )
       
   599         {
       
   600         CleanupStack::PopAndDestroy( db ); //db
       
   601         }
       
   602 
       
   603     CLOG( ( EProtection, 1, 
       
   604         _L( "<- CApProtHandler::ProtectTableL(table)" ) ) );
       
   605     }
   198     }
   606 
   199 
   607 
   200 
   608 
   201 
   609 // ---------------------------------------------------------
   202 // ---------------------------------------------------------
   611 // ---------------------------------------------------------
   204 // ---------------------------------------------------------
   612 //
   205 //
   613 void CApProtHandler::UnprotectTableL( CCommsDatabase* aDb,
   206 void CApProtHandler::UnprotectTableL( CCommsDatabase* aDb,
   614                                        const TDesC& aTable )
   207                                        const TDesC& aTable )
   615     {
   208     {
   616     CLOG( ( EProtection, 0, 
       
   617         _L( "-> CApProtHandler::UnprotectTableL(table)" ) ) );
       
   618 
       
   619     if ( ApCommons::GetVariantL() & KApUiEditOnlyVPNs )
       
   620         {
       
   621         User::Leave( KErrNotSupported );
       
   622         }
       
   623 #ifdef __TEST_CDMA_WRITE_PROTECT
       
   624     User::Leave( KErrNotSupported );
       
   625 #endif // __TEST_CDMA_WRITE_PROTECT
       
   626 
       
   627     CCommsDatabase* db = aDb;
       
   628     if ( !aDb )
       
   629         {
       
   630         // create DB object
       
   631         db = CCommsDatabase::NewL( ETrue );
       
   632         CleanupStack::PushL( db );
       
   633         }
       
   634 //    Follow related error rep. and act accordingly:
       
   635 //    JBAH-58FCHH
       
   636 //    TBool ownTransaction = ApCommons::StartPushedTransactionLC( *db, ETrue );
       
   637 
       
   638     CCommsDbProtectTableView* view =
       
   639         (CCommsDbProtectTableView*)db->OpenTableLC( aTable );
       
   640 
       
   641 
       
   642     TInt err = view->GotoFirstRecord();
       
   643     // If not found, no problem, Unprotect will be carried out correctly
       
   644     // But if no GotoFirstRecord, and no records, it will Panic...
       
   645     if ( err != KErrNotFound )
       
   646         {
       
   647         User::LeaveIfError( err );
       
   648         }
       
   649 
       
   650     User::LeaveIfError( view->UnprotectTable() );
       
   651 
       
   652     CleanupStack::PopAndDestroy( view ); // view
       
   653 
       
   654 
       
   655 /*
       
   656     if ( ownTransaction )
       
   657         {
       
   658         ApCommons::CommitTransaction( *db );
       
   659         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   660         }
       
   661 */
       
   662     if ( !aDb )
       
   663         {
       
   664         CleanupStack::PopAndDestroy( db ); // db
       
   665         }
       
   666 
       
   667     CLOG( ( EProtection, 1, 
       
   668         _L( "<- CApProtHandler::UnprotectTableL(table)" ) ) );
       
   669     }
   209     }
   670 
   210 
   671 
   211 
   672 // ---------------------------------------------------------
   212 // ---------------------------------------------------------
   673 // CApProtHandler::GetProtectionStateL
   213 // CApProtHandler::GetProtectionStateL
   674 // ---------------------------------------------------------
   214 // ---------------------------------------------------------
   675 //
   215 //
   676 TBool CApProtHandler::GetProtectionStateL( CCommsDbTableView& aTable )
   216 TBool CApProtHandler::GetProtectionStateL( CCommsDbTableView& aTable )
   677     {
   217     {
   678     CLOG( ( EProtection, 0, _L( "-> CApProtHandler::GetProtectionStateL" ) ) );
   218     return 0;
   679 
       
   680     TInt aAccess( 0 );
       
   681     User::LeaveIfError(
       
   682         ( (CCommsDbProtectTableView*) &aTable )->GetRecordAccess( aAccess ) );
       
   683     
       
   684     CLOG( ( EProtection, 1, _L( "<- CApProtHandler::GetProtectionStateL" ) ) );
       
   685     return aAccess;
       
   686     }
   219     }
   687 
   220 
   688 
   221 
   689 
   222 
   690 // ---------------------------------------------------------
   223 // ---------------------------------------------------------
   692 // ---------------------------------------------------------
   225 // ---------------------------------------------------------
   693 //
   226 //
   694 void CApProtHandler::DoRemoveProtectedAccessPointsL(
   227 void CApProtHandler::DoRemoveProtectedAccessPointsL(
   695                                           CCommsDatabase& aDb)
   228                                           CCommsDatabase& aDb)
   696     {
   229     {
   697     CLOG( ( EProtection, 0, 
       
   698         _L( "-> CApProtHandler::DoRemoveProtectedAccessPointsL" ) ) );
       
   699 
       
   700     if ( ApCommons::GetVariantL() & KApUiEditOnlyVPNs )
       
   701         {
       
   702         User::Leave( KErrNotSupported );
       
   703         }
       
   704 #ifdef __TEST_CDMA_WRITE_PROTECT
       
   705     User::Leave( KErrNotSupported );
       
   706 #endif // __TEST_CDMA_WRITE_PROTECT
       
   707 
       
   708     // TRANSACTION STARTING IS REMOVED UNTIL ERROR 
       
   709     // JBAH-58FCHH IS CORRECTED BY SYMBIAN
       
   710     // start a transaction, just to make sure
       
   711 //    TBool ownTransaction = ApCommons::StartPushedTransactionLC( aDb, ETrue );
       
   712     
       
   713     // make AP table updatable
       
   714     UnprotectTableL( &aDb );
       
   715 
       
   716     // remove all protected AP
       
   717     // first get a list of current AP-s
       
   718     CApListItemList* list = new( ELeave )CApListItemList();
       
   719     CleanupStack::PushL( list );
       
   720     CApDataHandler* handler = CApDataHandler::NewLC( aDb );
       
   721     CApSelect* sel = 
       
   722         CApSelect::NewLC( aDb, KEApIspTypeAll, EApBearerTypeAllBearers,
       
   723                          KEApSortNameAscending);
       
   724     sel->AllListItemDataL( *list );
       
   725     // now get protected ones and delete them
       
   726     TInt count( list->Count() );
       
   727     for( TInt i = 0; i<count; i++)
       
   728         {
       
   729         if ( list->At( i )->IsReadOnly() )
       
   730             {
       
   731             UnprotectItemL( &aDb, list->At( i )->Uid() );
       
   732             handler->RemoveAPL( list->At( i )->Uid() );
       
   733             }
       
   734         }
       
   735     CleanupStack::PopAndDestroy( 3, list ); // sel, handler, list
       
   736 
       
   737 /*
       
   738     if ( ownTransaction )
       
   739         {
       
   740         ApCommons::CommitTransaction( *aDb );
       
   741         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   742         }
       
   743 */
       
   744     
       
   745     CLOG( ( EProtection, 1, 
       
   746         _L( "<- CApProtHandler::DoRemoveProtectedAccessPointsL" ) ) );
       
   747     }
   230     }
   748 
   231 
   749 
   232 
   750 //  End of File
   233 //  End of File