cmmanager/cmmgr/cmmserver/src/cmmserver.cpp
branchGCC_SURGE
changeset 49 faa5ef4f80da
parent 46 95d45f234cf3
equal deleted inserted replaced
39:f10336de0cd6 49:faa5ef4f80da
    32 
    32 
    33 const TUint CCmmServer::iCmmRangeCount = 12;
    33 const TUint CCmmServer::iCmmRangeCount = 12;
    34 
    34 
    35 const TInt CCmmServer::iCmmRanges[iCmmRangeCount] =
    35 const TInt CCmmServer::iCmmRanges[iCmmRangeCount] =
    36     {
    36     {
    37     0,      //   0-10
    37     0,      //  1.   0-11
    38     11,     //  11-14
    38     12,     //  2.  12-15
    39     15,     //  15-21
    39     16,     //  3.  16-22
    40     22,     //  22-99
    40     23,     //  4.  23-99
    41     100,    // 100-112
    41     100,    //  5. 100-113
    42     113,    // 113-126
    42     114,    //  6. 114-128
    43     127,    // 127-199
    43     129,    //  7. 129-199
    44     200,    // 200-205
    44     200,    //  8. 200-205
    45     206,    // 206-210
    45     206,    //  9. 206-210
    46     211,    // 211-214
    46     211,    // 10. 211-214
    47     215,    // 215-220
    47     215,    // 11. 215-220
    48     221     // 221-KMaxInt
    48     221     // 12. 221-KMaxInt
    49     };
    49     };
    50 
    50 
    51 const TUint8 CCmmServer::iCmmElementIndex[iCmmRangeCount] =
    51 const TUint8 CCmmServer::iCmmElementIndex[iCmmRangeCount] =
    52     {
    52     {
    53     CPolicyServer::EAlwaysPass,     // 0-10
    53     CPolicyServer::EAlwaysPass,     // 0-11
    54     CPolicyServer::ECustomCheck,    // 11-14
    54     CPolicyServer::ECustomCheck,    // 12-15
    55     CPolicyServer::ECustomCheck,    // 15-21
    55     CPolicyServer::ECustomCheck,    // 16-22
    56     CPolicyServer::ENotSupported,   // 22-99
    56     CPolicyServer::ENotSupported,   // 23-99
    57     CPolicyServer::EAlwaysPass,     // 100-112
    57     CPolicyServer::EAlwaysPass,     // 100-113
    58     CPolicyServer::ECustomCheck,    // 113-126
    58     CPolicyServer::ECustomCheck,    // 114-128
    59     CPolicyServer::ENotSupported,   // 127-199
    59     CPolicyServer::ENotSupported,   // 129-199
    60     CPolicyServer::EAlwaysPass,     // 200-205
    60     CPolicyServer::EAlwaysPass,     // 200-205
    61     CPolicyServer::ECustomCheck,    // 206-210
    61     CPolicyServer::ECustomCheck,    // 206-210
    62     CPolicyServer::ECustomCheck,    // 211-214
    62     CPolicyServer::ECustomCheck,    // 211-214
    63     CPolicyServer::ECustomCheck,    // 215-220
    63     CPolicyServer::ECustomCheck,    // 215-220
    64     CPolicyServer::ENotSupported    // 221->
    64     CPolicyServer::ENotSupported    // 221->
    71     {_INIT_SECURITY_POLICY_C2(ECapabilityReadDeviceData, ECapabilityWriteDeviceData), 
    71     {_INIT_SECURITY_POLICY_C2(ECapabilityReadDeviceData, ECapabilityWriteDeviceData), 
    72             CPolicyServer::EFailClient},
    72             CPolicyServer::EFailClient},
    73     {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl), CPolicyServer::EFailClient},
    73     {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl), CPolicyServer::EFailClient},
    74     };
    74     };
    75 
    75 
    76 const CPolicyServer::TPolicy CCmmServer::iCmmPolicy = //TODO, check comments
    76 const CPolicyServer::TPolicy CCmmServer::iCmmPolicy =
    77     {
    77     {
    78     CPolicyServer::EAlwaysPass, // Specifies all connect attempts should pass
    78     CPolicyServer::EAlwaysPass, // Specifies all connect attempts should pass
    79     iCmmRangeCount,     // Count of ranges
    79     iCmmRangeCount,     // Count of ranges
    80     iCmmRanges,         // 0-999, 1000-1008, 1009...
    80     iCmmRanges,         // 0-11, 12-15, 16...
    81     iCmmElementIndex,   // Only range 1000-1008 are checked
    81     iCmmElementIndex,   // What to do for each range
    82     iCmmElements        // The list of policy elements
    82     iCmmElements        // The list of policy elements
    83     };
    83     };
    84 
    84 
    85 
    85 
    86 // -----------------------------------------------------------------------------
    86 // -----------------------------------------------------------------------------
    94         TInt& /*aAction*/,
    94         TInt& /*aAction*/,
    95         TSecurityInfo& /*aMissing*/ )
    95         TSecurityInfo& /*aMissing*/ )
    96     {
    96     {
    97     switch ( aMessage.Function() )
    97     switch ( aMessage.Function() )
    98         {
    98         {
    99         // ***********  2nd range: 11-14 *************
    99         // ***********  2nd range: 12-15 *************
   100         case ECmmGetConnMethodInfoInt:
   100         case ECmmGetConnMethodInfoInt:
   101         case ECmmGetConnMethodInfoBool:
   101         case ECmmGetConnMethodInfoBool:
   102         case ECmmGetConnMethodInfoString:
   102         case ECmmGetConnMethodInfoString:
   103         case ECmmGetConnMethodInfoString8:
   103         case ECmmGetConnMethodInfoString8:
   104         // ***********  10th range: 211-214 *************
   104         // ***********  10th range: 211-214 *************
   125                 case CMManager::EWlanWepKeyIndex:
   125                 case CMManager::EWlanWepKeyIndex:
   126                 // WAPI:
   126                 // WAPI:
   127                 case CMManager::EWlanWapiPsk:
   127                 case CMManager::EWlanWapiPsk:
   128                 case CMManager::EWlanWapiPskFormat:
   128                 case CMManager::EWlanWapiPskFormat:
   129                 // 802.1x:
   129                 // 802.1x:
   130                 case CMManager::EWlan802_1xAllowUnencrypted: //TODO, should this be here?
   130                 case CMManager::EWlan802_1xAllowUnencrypted:
   131                 // Authentication:
   131                 // Authentication:
   132                 case CMManager::ECmIFAuthName:
   132                 case CMManager::ECmIFAuthName:
   133                 case CMManager::EPacketDataIFAuthName:
   133                 case CMManager::EPacketDataIFAuthName:
   134                 case CMManager::ECmIFAuthPass:
   134                 case CMManager::ECmIFAuthPass:
   135                 case CMManager::EPacketDataIFAuthPass:
   135                 case CMManager::EPacketDataIFAuthPass:
   137                     // ECapabilityReadDeviceData
   137                     // ECapabilityReadDeviceData
   138                     return ( iCmmElements[0].iPolicy.CheckPolicy( aMessage ) ) ?
   138                     return ( iCmmElements[0].iPolicy.CheckPolicy( aMessage ) ) ?
   139                         EPass : EFail;
   139                         EPass : EFail;
   140                     }
   140                     }
   141                 default:
   141                 default:
   142                     // By default reading does not need any capabilities
   142                     // By default reading does not need any capabilities.
   143                     return EPass;
   143                     return EPass;
   144                 }
   144                 }
   145             }
   145             }
   146         // ***********  3rd range: 15-21 *************
   146         // ***********  3rd range: 16-22 *************
   147         case ECmmUpdateBearerPriorityArray:
   147         case ECmmUpdateBearerPriorityArray:
   148         case ECmmWriteDefaultConnection:
   148         case ECmmWriteDefaultConnection:
   149         case ECmmWriteGeneralConnectionSettings:
   149         case ECmmWriteGeneralConnectionSettings:
   150             {
   150         // At this phase all capabilities are not checked because of
   151             // ECapabilityWriteDeviceData is needed for writing
   151         // it's too heavy operation...
   152             return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
   152         // At Session phase the protection of the destination and/or
   153                 EPass : EFail;
   153         // connection method is checked. If protected, 
   154             }
   154         // ECapabilityNetworkControl is checked.
   155         case ECmmCopyConnMethod:
   155         case ECmmCopyConnMethod:
   156         case ECmmMoveConnMethod:
   156         case ECmmMoveConnMethod:
   157         case ECmmRemoveConnMethod:
   157         case ECmmRemoveConnMethod:
   158         case ECmmRemoveAllReferences:
   158         case ECmmRemoveAllReferences:
   159             {
   159             {
   160             // At this phase capability is not checked because of
       
   161             // it's too heavy operation...
       
   162             // At later phase the protection of the target destination
       
   163             // and/or connection method is checked.
       
   164             return EPass;
       
   165             }
       
   166         // ***********  6th range: 113-126 *************
       
   167         case EDestCreateDestinationWithName:
       
   168         case EDestCreateDestinationWithNameAndId:
       
   169             {
       
   170             // ECapabilityWriteDeviceData is needed for writing
   160             // ECapabilityWriteDeviceData is needed for writing
   171             return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
   161             return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
   172                 EPass : EFail;
   162                 EPass : EFail;
   173             }
   163             }
       
   164         // ***********  6th range: 114-128 *************
       
   165         case EDestCreateDestinationWithName:
       
   166         case EDestCreateDestinationWithNameAndId:
   174         case EDestIsConnected:
   167         case EDestIsConnected:
   175         case EDestAddConnMethod:
   168         case EDestAddConnMethod:
   176         case EDestAddEmbeddedDestination:
   169         case EDestAddEmbeddedDestination:
   177         case EDestDeleteConnMethod:
   170         case EDestDeleteConnMethod:
   178         case EDestRemoveConnMethod:
   171         case EDestRemoveConnMethod:
   181         case EDestSetMetadata:
   174         case EDestSetMetadata:
   182         case EDestSetProtection:
   175         case EDestSetProtection:
   183         case EDestSetHidden:
   176         case EDestSetHidden:
   184         case EDestUpdate:
   177         case EDestUpdate:
   185         case EDestDelete:
   178         case EDestDelete:
   186             {
   179         case EDestSetIcon:
   187             // At this phase capability is not checked because of
       
   188             // it's too heavy operation...
       
   189             // At Session phase the protection of the destination and/or
       
   190             // connection method is checked. If destination/connection method
       
   191             // is protected ECapabilityNetworkControl is required from a
       
   192             // client.
       
   193             return EPass;
       
   194             }
       
   195         // ***********  9th range: 206-210 *************
       
   196         case ECMCreateConnMethod:
       
   197         case ECMCreateConnMethodWithId:
       
   198             {
   180             {
   199             // ECapabilityWriteDeviceData is needed for writing
   181             // ECapabilityWriteDeviceData is needed for writing
   200             return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
   182             return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
   201                 EPass : EFail;
   183                 EPass : EFail;
   202             }
   184             }
       
   185         // ***********  9th range: 206-210 *************
       
   186 
       
   187         // ECapabilityWriteDeviceData is needed for writing
       
   188         case ECMCreateConnMethod:
       
   189         case ECMCreateConnMethodWithId:
       
   190         
       
   191         // At this phase all capabilities are not checked because of
       
   192         // it's too heavy operation...
       
   193         // At Session phase the protection of the destination and/or
       
   194         // connection method is checked. If protected, 
       
   195         // ECapabilityNetworkControl is checked.
   203         case ECMCreateConnMethodToDest:
   196         case ECMCreateConnMethodToDest:
   204         case ECMCreateConnMethodToDestWithId:
   197         case ECMCreateConnMethodToDestWithId:
   205         case ECMCreateCopyOfExisting:
   198         case ECMCreateCopyOfExisting:
   206             {
   199             {
   207             // At this phase capability is not checked because of
   200             return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
   208             // it's too heavy operation...
   201                 EPass : EFail;
   209             // At Session phase the protection of the destination and/or
       
   210             // connection method is checked.
       
   211             return EPass;
       
   212             }
   202             }
   213         // ***********  11th range: 215-220 *************
   203         // ***********  11th range: 215-220 *************
       
   204         // Protection of the CM is checked later(protected needs ECapabilityNetworkControl)
   214         case ECMSetIntAttribute:
   205         case ECMSetIntAttribute:
   215         case ECMSetBoolAttribute:
   206         case ECMSetBoolAttribute:
   216         case ECMSetStringAttribute:
   207         case ECMSetStringAttribute:
   217         case ECMSetString8Attribute:
   208         case ECMSetString8Attribute:
   218             {
   209             {
   233                 case CMManager::EWlanWepKeyIndex:
   224                 case CMManager::EWlanWepKeyIndex:
   234                 // WAPI:
   225                 // WAPI:
   235                 case CMManager::EWlanWapiPsk:
   226                 case CMManager::EWlanWapiPsk:
   236                 case CMManager::EWlanWapiPskFormat:
   227                 case CMManager::EWlanWapiPskFormat:
   237                 // 802.1x:
   228                 // 802.1x:
   238                 case CMManager::EWlan802_1xAllowUnencrypted: //TODO, should this be here?
   229                 case CMManager::EWlan802_1xAllowUnencrypted:
   239                 // Authentication:
   230                 // Authentication:
   240                 case CMManager::ECmIFAuthName:
   231                 case CMManager::ECmIFAuthName:
   241                 case CMManager::EPacketDataIFAuthName:
   232                 case CMManager::EPacketDataIFAuthName:
   242                 case CMManager::ECmIFAuthPass:
   233                 case CMManager::ECmIFAuthPass:
   243                 case CMManager::EPacketDataIFAuthPass:
   234                 case CMManager::EPacketDataIFAuthPass:
   255                 }
   246                 }
   256             }
   247             }
   257         case ECMDelete:
   248         case ECMDelete:
   258         case ECMUpdate:
   249         case ECMUpdate:
   259             {
   250             {
   260             // ECapabilityWriteDeviceData
   251             // ECapabilityWriteDeviceData (if protected, ECapabilityNetworkControl
       
   252             // is checked later).
   261             return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
   253             return ( iCmmElements[1].iPolicy.CheckPolicy( aMessage ) ) ?
   262                 EPass : EFail;
   254                 EPass : EFail;
   263             }
   255             }
   264         default:
   256         default:
   265             return EPass;
   257             return EPass;
       
   258         }
       
   259     }
       
   260 
       
   261 /**
       
   262  * This is for checking client's capabilities at later phase after
       
   263  * protections of destination/connection method have been checked
       
   264  * first.
       
   265  */
       
   266 CPolicyServer::TCustomResult CCmmServer::CapabilityCheckWithProtection( 
       
   267         const RMessage2& aMessage )
       
   268     {
       
   269     switch ( aMessage.Function() )
       
   270         {
       
   271         case ECmmCopyConnMethod:
       
   272         case ECmmMoveConnMethod:
       
   273         case ECmmRemoveConnMethod:
       
   274         case ECmmRemoveAllReferences:
       
   275         case EDestAddConnMethod:
       
   276         case EDestDeleteConnMethod:
       
   277         case EDestAddEmbeddedDestination:
       
   278         case EDestRemoveConnMethod:
       
   279         case EDestModifyPriority:
       
   280         case EDestSetName:
       
   281         case EDestSetMetadata:
       
   282         case EDestSetProtection:
       
   283         case EDestSetHidden:
       
   284         case EDestUpdate:
       
   285         case EDestDelete:
       
   286         case EDestSetIcon:
       
   287         case ECMCreateConnMethodToDest:
       
   288         case ECMCreateConnMethodToDestWithId:
       
   289         case ECMUpdate:
       
   290         case ECMDelete:
       
   291         case ECMSetIntAttribute:
       
   292         case ECMSetBoolAttribute:
       
   293         case ECMSetStringAttribute:
       
   294         case ECMSetString8Attribute:
       
   295             {
       
   296             // ECapabilityNetworkControl
       
   297             return ( iCmmElements[3].iPolicy.CheckPolicy( aMessage ) ) ? EPass : EFail;
       
   298             }
       
   299         default:
       
   300             // Execution should never come here.
       
   301             return EFail;
   266         }
   302         }
   267     }
   303     }
   268 
   304 
   269 CCmmServer::CCmmServer( TInt aPriority ) : CPolicyServer( aPriority, iCmmPolicy )
   305 CCmmServer::CCmmServer( TInt aPriority ) : CPolicyServer( aPriority, iCmmPolicy )
   270     {
   306     {
   338         const TVersion& /*aVersion*/,
   374         const TVersion& /*aVersion*/,
   339         const RMessage2& /*aMessage*/ ) const
   375         const RMessage2& /*aMessage*/ ) const
   340     {
   376     {
   341     OstTraceFunctionEntry0( CCMMSERVER_NEWSESSIONL_ENTRY );
   377     OstTraceFunctionEntry0( CCMMSERVER_NEWSESSIONL_ENTRY );
   342 
   378 
   343     return CCmmSession::NewL( *const_cast<CCmmServer*>( this ), iCmManager->Cache() );
   379     CSession2* session = CCmmSession::NewL(
       
   380             *const_cast<CCmmServer*>( this ),
       
   381             iCmManager->Cache() );
       
   382 
       
   383     OstTraceFunctionExit0( CCMMSERVER_NEWSESSIONL_EXIT );
       
   384     return session;
   344     }
   385     }
   345 
   386 
   346 // -----------------------------------------------------------------------------
   387 // -----------------------------------------------------------------------------
   347 // Increments the session counter. Cancels the shutdown timer if active.
   388 // Increments the session counter. Cancels the shutdown timer if active.
   348 // -----------------------------------------------------------------------------
   389 // -----------------------------------------------------------------------------
   374         if ( !iShutdown->IsActive() )
   415         if ( !iShutdown->IsActive() )
   375             {
   416             {
   376             iShutdown->Start();
   417             iShutdown->Start();
   377             }
   418             }
   378         }
   419         }
       
   420 
   379     OstTraceFunctionExit0( CCMMSERVER_DECREMENTSESSIONS_EXIT );
   421     OstTraceFunctionExit0( CCMMSERVER_DECREMENTSESSIONS_EXIT );
   380     }
   422     }
   381 
   423 
   382 // -----------------------------------------------------------------------------
   424 // -----------------------------------------------------------------------------
   383 // CCmmServer::NewContainerL
   425 // CCmmServer::NewContainerL
   385 //
   427 //
   386 CObjectCon* CCmmServer::NewContainerL()
   428 CObjectCon* CCmmServer::NewContainerL()
   387     {
   429     {
   388     OstTraceFunctionEntry0( CCMMSERVER_NEWCONTAINERL_ENTRY );
   430     OstTraceFunctionEntry0( CCMMSERVER_NEWCONTAINERL_ENTRY );
   389 
   431 
   390     return iContainerIndex->CreateL();
   432     CObjectCon* container = iContainerIndex->CreateL();
       
   433 
       
   434     OstTraceFunctionExit0( CCMMSERVER_NEWCONTAINERL_EXIT );
       
   435     return container;
   391     }
   436     }
   392 
   437 
   393 // -----------------------------------------------------------------------------
   438 // -----------------------------------------------------------------------------
   394 // CCmmServer::RemoveContainer
   439 // CCmmServer::RemoveContainer
   395 // -----------------------------------------------------------------------------
   440 // -----------------------------------------------------------------------------
   417     // skipping the call to request another message. So we issue the
   462     // skipping the call to request another message. So we issue the
   418     // request here in order to keep the server running.
   463     // request here in order to keep the server running.
   419     ReStart();
   464     ReStart();
   420 
   465 
   421     OstTraceFunctionExit0( CCMMSERVER_RUNERROR_EXIT );
   466     OstTraceFunctionExit0( CCMMSERVER_RUNERROR_EXIT );
   422 
       
   423     return KErrNone;
   467     return KErrNone;
   424     }
   468     }
   425 
   469 
   426 // -----------------------------------------------------------------------------
   470 // -----------------------------------------------------------------------------
   427 // CCmmServer::CmManager
   471 // CCmmServer::CmManager
   444 // - aEmbeddedDestinationId is the ID of the destination that is beeing
   488 // - aEmbeddedDestinationId is the ID of the destination that is beeing
   445 //   embedded.
   489 //   embedded.
   446 // -----------------------------------------------------------------------------
   490 // -----------------------------------------------------------------------------
   447 //
   491 //
   448 TBool CCmmServer::EmbeddedDestinationConflictsFromAllSessions(
   492 TBool CCmmServer::EmbeddedDestinationConflictsFromAllSessions(
   449         const TUint32& aDestinationId,
   493         const TUint32 aDestinationId,
   450         const TUint32& aEmbeddedDestinationId )
   494         const TUint32 aEmbeddedDestinationId )
   451     {
   495     {
   452     OstTraceFunctionEntry0( CCMMSERVER_EMBEDDEDDESTINATIONCONFLICTSFROMALLSESSIONS_ENTRY );
   496     OstTraceFunctionEntry0( CCMMSERVER_EMBEDDEDDESTINATIONCONFLICTSFROMALLSESSIONS_ENTRY );
   453 
   497 
   454     TBool result( EFalse );
   498     TBool result( EFalse );
   455     CSession2* session( NULL );
   499     CSession2* session( NULL );
   473 // ---------------------------------------------------------------------------
   517 // ---------------------------------------------------------------------------
   474 // Notify each session about a destination/connection method that has been
   518 // Notify each session about a destination/connection method that has been
   475 // updated to, or deleted from, database.
   519 // updated to, or deleted from, database.
   476 // ---------------------------------------------------------------------------
   520 // ---------------------------------------------------------------------------
   477 //
   521 //
   478 void CCmmServer::RefreshHandlesForAllSessions( const TUint32& aId )
   522 void CCmmServer::RefreshHandlesForAllSessions( const TUint32 aId )
   479     {
   523     {
   480     OstTraceFunctionEntry0( CCMMSERVER_REFRESHHANDLESFORALLSESSIONS_ENTRY );
   524     OstTraceFunctionEntry0( CCMMSERVER_REFRESHHANDLESFORALLSESSIONS_ENTRY );
   481 
   525 
   482     CSession2* session( NULL );
   526     CSession2* session( NULL );
   483 
   527