cmmanager/cmmgr/cmmserver/src/cmmdestinationinstance.cpp
changeset 27 489cf6208544
parent 20 9c97ad6591ae
child 40 c5b848e6c7d1
equal deleted inserted replaced
23:7ec726f93df1 27:489cf6208544
   423 // Get the localised destination name.
   423 // Get the localised destination name.
   424 // ---------------------------------------------------------------------------
   424 // ---------------------------------------------------------------------------
   425 //
   425 //
   426 HBufC* CCmmDestinationInstance::GetLocalisedDestinationNameL()
   426 HBufC* CCmmDestinationInstance::GetLocalisedDestinationNameL()
   427     {
   427     {
       
   428     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETLOCALISEDDESTINATIONNAMEL_ENTRY );
       
   429 
   428     RefreshRecordL( ECmmDestNetworkRecord );
   430     RefreshRecordL( ECmmDestNetworkRecord );
   429 
   431 
   430     if ( !iNetworkRecord )
   432     if ( !iNetworkRecord )
   431         {
   433         {
   432         User::Leave( KErrCorrupt );
   434         User::Leave( KErrCorrupt );
   461             break;
   463             break;
   462         default:
   464         default:
   463             break;
   465             break;
   464         }
   466         }
   465 
   467 
   466     // Not Internet, operator or intranet...or something went wrong 
   468     // Not Internet, operator or intranet, or something went wrong. 
   467     if ( !isLocalised || ( isLocalised && !resolvedText ) )
   469     if ( !isLocalised || ( isLocalised && !resolvedText ) )
   468         {
   470         {
   469         resolvedText = ( iNetworkRecord->iRecordName.GetL() ).AllocL();
   471         resolvedText = TPtrC( iNetworkRecord->iRecordName ).AllocL();
   470         }
   472         }
   471     
   473 
       
   474     OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETLOCALISEDDESTINATIONNAMEL_EXIT );
   472     return resolvedText;
   475     return resolvedText;
   473     }
   476     }
   474 
   477 
   475 // ---------------------------------------------------------------------------
   478 // ---------------------------------------------------------------------------
   476 // Set the destination name.
   479 // Set the destination name.
   477 // ---------------------------------------------------------------------------
   480 // ---------------------------------------------------------------------------
   478 //
   481 //
   479 void CCmmDestinationInstance::SetDestinationNameL( const TDesC& aDestinationName )
   482 void CCmmDestinationInstance::SetDestinationNameL( const TDesC& aDestinationName )
   480     {
   483     {
   481     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETDESTINATIONNAMEL_ENTRY );
   484     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETDESTINATIONNAMEL_ENTRY );
   482 
       
   483     //TODO, capability check depending on destination protection level, or if it is internet destination. Internet destination should be protected always?
       
   484 
   485 
   485     // Write action, load all records.
   486     // Write action, load all records.
   486     LoadAllRecordsL();
   487     LoadAllRecordsL();
   487 
   488 
   488     iNetworkRecord->iRecordName.SetL( aDestinationName );
   489     iNetworkRecord->iRecordName.SetL( aDestinationName );
   494 
   495 
   495     OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETDESTINATIONNAMEL_EXIT );
   496     OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETDESTINATIONNAMEL_EXIT );
   496     }
   497     }
   497 
   498 
   498 // ---------------------------------------------------------------------------
   499 // ---------------------------------------------------------------------------
       
   500 // Get the destination icon.
       
   501 // ---------------------------------------------------------------------------
       
   502 //
       
   503 HBufC* CCmmDestinationInstance::GetDestinationIconL()
       
   504     {
       
   505     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETDESTINATIONICONL_ENTRY );
       
   506 
       
   507     RefreshRecordL( ECmmDestMetadataRecord );
       
   508 
       
   509     if ( !iMetadataRecord )
       
   510         {
       
   511         User::Leave( KErrCorrupt );
       
   512         }
       
   513 
       
   514     HBufC* icon( NULL );
       
   515     //icon = TPtrC( iMetadataRecord->iIconFileName ).AllocL();//TODO, enable after commsdat icon changes are implemented.
       
   516 	icon = KNullDesC().AllocL();//TODO
       
   517 
       
   518     OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETDESTINATIONICONL_EXIT );
       
   519     return icon;
       
   520     }
       
   521 
       
   522 // ---------------------------------------------------------------------------
       
   523 // Set the destination icon.
       
   524 // ---------------------------------------------------------------------------
       
   525 //
       
   526 void CCmmDestinationInstance::SetDestinationIconL( const TDesC& /*aDestinationIcon*/ )
       
   527     {
       
   528     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETDESTINATIONICONL_ENTRY );
       
   529 
       
   530     // Write action, load all records.
       
   531     LoadAllRecordsL();
       
   532 
       
   533     //iMetadataRecord->iIconFileName.SetL( aDestinationIcon );//TODO, enable after commsdat icon changes are implemented.
       
   534 
       
   535     iMetadataRecordStatus = ECmmRecordStatusModified;
       
   536     iStatus = ECmmDestinationStatusChanged;
       
   537 
       
   538     OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETDESTINATIONICONL_EXIT );
       
   539     }
       
   540 
       
   541 // ---------------------------------------------------------------------------
   499 // Get metadata of specified type.
   542 // Get metadata of specified type.
   500 // ---------------------------------------------------------------------------
   543 // ---------------------------------------------------------------------------
   501 //
   544 //
   502 void CCmmDestinationInstance::GetMetadataL(
   545 void CCmmDestinationInstance::GetMetadataL(
   503         const CMManager::TSnapMetadataField& aMetadataField,
   546         const CMManager::TSnapMetadataField& aMetadataField,
   628     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETPROTECTIONL_ENTRY );
   671     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETPROTECTIONL_ENTRY );
   629 
   672 
   630     // Write action, load all records.
   673     // Write action, load all records.
   631     LoadAllRecordsL();
   674     LoadAllRecordsL();
   632 
   675 
   633     //TODO, verify capability check is done (NetworkControl).
   676     //TODO, comment this:
   634 
       
   635     iCurrentProtectionLevel = aProtectionLevel;
   677     iCurrentProtectionLevel = aProtectionLevel;
   636     if ( !iProtectionChanged )
   678     if ( !iProtectionChanged )
   637         {
   679         {
   638         GetProtectionL( iLastProtectionLevel );
   680         GetProtectionL( iLastProtectionLevel );
   639         }
   681         }
  1287     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_ALLMANDATORYRECORDSCONTAINDATA_ENTRY );
  1329     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_ALLMANDATORYRECORDSCONTAINDATA_ENTRY );
  1288 
  1330 
  1289     TBool result( ETrue );
  1331     TBool result( ETrue );
  1290 
  1332 
  1291     if ( iNetworkRecordStatus != ECmmRecordStatusLoaded &&
  1333     if ( iNetworkRecordStatus != ECmmRecordStatusLoaded &&
  1292             iNetworkRecordStatus != ECmmRecordStatusExpired &&
       
  1293             iNetworkRecordStatus != ECmmRecordStatusModified )
  1334             iNetworkRecordStatus != ECmmRecordStatusModified )
  1294         {
  1335         {
  1295         result = EFalse;
  1336         result = EFalse;
  1296         }
  1337         }
  1297     if ( iDestApRecordStatus != ECmmRecordStatusLoaded &&
  1338     if ( iDestApRecordStatus != ECmmRecordStatusLoaded &&
  1298             iDestApRecordStatus != ECmmRecordStatusExpired &&
       
  1299             iDestApRecordStatus != ECmmRecordStatusModified )
  1339             iDestApRecordStatus != ECmmRecordStatusModified )
  1300         {
  1340         {
  1301         result = EFalse;
  1341         result = EFalse;
  1302         }
  1342         }
  1303     if ( iMetadataRecordStatus != ECmmRecordStatusLoaded &&
  1343     if ( iMetadataRecordStatus != ECmmRecordStatusLoaded &&
  1304             iMetadataRecordStatus != ECmmRecordStatusExpired &&
       
  1305             iMetadataRecordStatus != ECmmRecordStatusModified )
  1344             iMetadataRecordStatus != ECmmRecordStatusModified )
  1306         {
  1345         {
  1307         result = EFalse;
  1346         result = EFalse;
  1308         }
  1347         }
  1309     if ( !iNetworkRecord || !iDestApRecord || !iMetadataRecord )
  1348     if ( !iNetworkRecord || !iDestApRecord || !iMetadataRecord )
  1314     OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_ALLMANDATORYRECORDSCONTAINDATA_EXIT );
  1353     OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_ALLMANDATORYRECORDSCONTAINDATA_EXIT );
  1315     return result;
  1354     return result;
  1316     }
  1355     }
  1317 
  1356 
  1318 // ---------------------------------------------------------------------------
  1357 // ---------------------------------------------------------------------------
  1319 // Loads a certain type of record from database if it is not up-to-date.
  1358 // Loads a requested type of record from database if it is not yet loaded.
       
  1359 //
       
  1360 // Currently all records are loaded when client opens a handle to a
       
  1361 // destination, but if future optimizations are added and records are only
       
  1362 // loaded when needed, the functionality of this method becomes essential.
  1320 // ---------------------------------------------------------------------------
  1363 // ---------------------------------------------------------------------------
  1321 //
  1364 //
  1322 void CCmmDestinationInstance::RefreshRecordL( TCmmDbRecords aRecordType )
  1365 void CCmmDestinationInstance::RefreshRecordL( TCmmDbRecords aRecordType )
  1323     {
  1366     {
  1324     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_REFRESHRECORDL_ENTRY );
  1367     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_REFRESHRECORDL_ENTRY );
  1342 
  1385 
  1343     switch ( status )
  1386     switch ( status )
  1344         {
  1387         {
  1345         // Fallthrough intended
  1388         // Fallthrough intended
  1346         case ECmmRecordStatusBlank:
  1389         case ECmmRecordStatusBlank:
  1347         case ECmmRecordStatusExpired:
       
  1348             iCache->LoadDestinationRecordL( *this, aRecordType );
  1390             iCache->LoadDestinationRecordL( *this, aRecordType );
  1349             break;
  1391             break;
  1350         case ECmmRecordStatusLoaded:
  1392         case ECmmRecordStatusLoaded:
  1351         case ECmmRecordStatusModified:
  1393         case ECmmRecordStatusModified:
  1352             // Record is up-to-date.
  1394             // Record is up-to-date.
  1353             break;
  1395             break;
       
  1396         case ECmmRecordStatusExpired:
  1354         case ECmmRecordStatusUnsaved:
  1397         case ECmmRecordStatusUnsaved:
  1355         default:
  1398         default:
  1356             User::Leave( KErrCorrupt ); // Error, unknown status.
  1399             User::Leave( KErrCorrupt ); // Error, invalid or unknown status.
  1357             break;
  1400             break;
  1358         }
  1401         }
  1359 
  1402 
  1360     OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_REFRESHRECORDL_EXIT );
  1403     OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_REFRESHRECORDL_EXIT );
  1361     }
  1404     }
  1362 
  1405 
  1363 // ---------------------------------------------------------------------------
  1406 // ---------------------------------------------------------------------------
  1364 // Loads all records from database that are not up-to-date.
  1407 // Loads all records from database that are not up-to-date.
       
  1408 // Guarantees the record pointers are valid or leaves.
  1365 // ---------------------------------------------------------------------------
  1409 // ---------------------------------------------------------------------------
  1366 //
  1410 //
  1367 void CCmmDestinationInstance::LoadAllRecordsL()
  1411 void CCmmDestinationInstance::LoadAllRecordsL()
  1368     {
  1412     {
  1369     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_LOADALLRECORDSL_ENTRY );
  1413     OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_LOADALLRECORDSL_ENTRY );