idlehomescreen/sapiwrapper/hspswrapper/src/hspswrapper.cpp
branchRCL_3
changeset 16 9674c1a575e9
parent 9 f966699dea19
child 30 b8fae6b8a148
equal deleted inserted replaced
15:ff572dfe6d86 16:9674c1a575e9
    17 
    17 
    18 
    18 
    19 #include <liwservicehandler.h>
    19 #include <liwservicehandler.h>
    20 #include <liwvariant.h>
    20 #include <liwvariant.h>
    21 #include <bamdesca.h>
    21 #include <bamdesca.h>
       
    22 #include <centralrepository.h>
       
    23 #include <activeidle2domaincrkeys.h>
    22 
    24 
    23 #include "hspswrapper.h"
    25 #include "hspswrapper.h"
    24 #include "hspsconfiguration.h"
    26 #include "hspsconfiguration.h"
    25 #include "pluginmap.h"
    27 #include "pluginmap.h"
    26 #include "itemmap.h"
    28 #include "itemmap.h"
    27 #include "propertymap.h"
    29 #include "propertymap.h"
    28 #include "objectmap.h"
    30 #include "objectmap.h"
    29 #include "plugininfo.h"
    31 #include "plugininfo.h"
    30 
    32 
    31 
       
    32 _LIT8( KHSPS, "Service.HSPS" );
    33 _LIT8( KHSPS, "Service.HSPS" );
    33 _LIT8( KHSPSConfigurationIf, "IConfiguration" );
    34 _LIT8( KHSPSConfigurationIf, "IConfiguration" );
    34 
    35 
    35 _LIT8( KHSPSCommandGetActiveAppConf, "GetActiveAppConf" );
    36 _LIT8( KHSPSCommandGetActiveAppConf, "GetActiveAppConf" );
    36 _LIT8( KHSPSCommandGetPluginConf, "GetPluginConf" );
    37 _LIT8( KHSPSCommandGetPluginConf, "GetPluginConf" );
    37 _LIT8( KHSPSCommandGetPlugins, "GetPlugins" );
    38 _LIT8( KHSPSCommandGetPlugins, "GetPlugins" );
    38 _LIT8( KHSPSCommandAddPlugin, "AddPlugin" );
    39 _LIT8( KHSPSCommandAddPlugin, "AddPlugin" );
    39 _LIT8( KHSPSCommandRemovePlugin, "RemovePlugin" );
    40 _LIT8( KHSPSCommandRemovePlugin, "RemovePlugin" );
    40 _LIT8( KHSPSCommandReplacePlugin, "ReplacePlugin" );
    41 _LIT8( KHSPSCommandReplacePlugin, "ReplacePlugin" );
    41 _LIT8( KHSPSCommandSetActivePlugin, "SetActivePlugin" );
       
    42 _LIT8( KHSPSCommandSetConfState, "SetConfState" );
    42 _LIT8( KHSPSCommandSetConfState, "SetConfState" );
    43 _LIT8( KHSPSCommandGetAppConfs, "GetAppConfs" );
    43 _LIT8( KHSPSCommandGetAppConfs, "GetAppConfs" );
    44 _LIT8( KHSPSCommandSetAppConf, "SetActiveAppConf" );
    44 _LIT8( KHSPSCommandSetAppConf, "SetActiveAppConf" );
    45 _LIT8( KHSPSMovePlugins, "MovePlugins");
    45 _LIT8( KHSPSMovePlugins, "MovePlugins");
    46 _LIT8( KHSPSSetPluginSettings, "SetPluginSettings" );
    46 _LIT8( KHSPSSetPluginSettings, "SetPluginSettings" );
    67 _LIT8( KRequestNotification, "RequestNotification" );
    67 _LIT8( KRequestNotification, "RequestNotification" );
    68 _LIT8( KHSPSCommandRestoreConfigurations, "RestoreConfigurations" );
    68 _LIT8( KHSPSCommandRestoreConfigurations, "RestoreConfigurations" );
    69 _LIT8( KRestore, "restore" );
    69 _LIT8( KRestore, "restore" );
    70 _LIT8( KActive, "active" );
    70 _LIT8( KActive, "active" );
    71 _LIT8( KAll, "all" );
    71 _LIT8( KAll, "all" );
       
    72 _LIT8( K0, "0" );
       
    73 _LIT8( K1, "1" );
       
    74 _LIT8( KPluginIdNotSet, "-1" );
       
    75 const TInt KMaxPluginIdLen = 32;
    72 
    76 
    73 namespace hspswrapper{
    77 namespace hspswrapper{
    74 
    78 
    75 // ---------------------------------------------------------------------------
    79 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    80 // ---------------------------------------------------------------------------
   147 
   151 
   148 // ---------------------------------------------------------------------------
   152 // ---------------------------------------------------------------------------
   149 // ---------------------------------------------------------------------------
   153 // ---------------------------------------------------------------------------
   150 //
   154 //
   151 void CHspsWrapper::ConstructL(const TDesC8& aAppUid)
   155 void CHspsWrapper::ConstructL(const TDesC8& aAppUid)
   152     {
   156     {    
       
   157     // Read active view.
       
   158     iRepository = CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) );
       
   159     LoadActivePluginIdL();
       
   160         
   153     // Attach to HSPS:
   161     // Attach to HSPS:
   154     iServiceHandler = CLiwServiceHandler::NewL();
   162     iServiceHandler = CLiwServiceHandler::NewL();
   155     
   163     
   156     iHspsService = CLiwCriteriaItem::NewL( 1, KHSPSConfigurationIf, KHSPS );
   164     iHspsService = CLiwCriteriaItem::NewL( 1, KHSPSConfigurationIf, KHSPS );
   157     iHspsService->SetServiceClass( TUid::Uid( KLiwClassBase ) );
   165     iHspsService->SetServiceClass( TUid::Uid( KLiwClassBase ) );
   267         interestList.Reset();        
   275         interestList.Reset();        
   268         }
   276         }
   269     
   277     
   270     delete iHspsService;
   278     delete iHspsService;
   271     delete iServiceHandler;    
   279     delete iServiceHandler;    
       
   280     delete iRepository;
       
   281     delete iActivePluginId;
   272     }
   282     }
   273 
   283 
   274 // ---------------------------------------------------------------------------
   284 // ---------------------------------------------------------------------------
   275 // ---------------------------------------------------------------------------
   285 // ---------------------------------------------------------------------------
   276 //
   286 //
   295         {
   305         {
   296         const CLiwMap* confMap  = conf->Value().AsMap();
   306         const CLiwMap* confMap  = conf->Value().AsMap();
   297         // 2: Process Configuration map
   307         // 2: Process Configuration map
   298         if(confMap)
   308         if(confMap)
   299            {
   309            {
   300            ProcessConfigurationMapL(*confMap,*configuration);
   310            ProcessConfigurationMapL( *confMap, *configuration, ETrue );
   301            }
   311            }
   302         }
   312         }
   303     outParamList.Reset();
   313     outParamList.Reset();
   304     
   314     
   305     CleanupStack::Pop(configuration);
   315     CleanupStack::Pop(configuration);
   375 // ---------------------------------------------------------------------------
   385 // ---------------------------------------------------------------------------
   376 //
   386 //
   377 EXPORT_C TInt CHspsWrapper::SetAppConfigurationL(
   387 EXPORT_C TInt CHspsWrapper::SetAppConfigurationL(
   378     const TDesC8& aConfigurationUid )
   388     const TDesC8& aConfigurationUid )
   379     {
   389     {
       
   390     SetActivePluginL( KPluginIdNotSet );
       
   391     
   380 #ifdef _XN_PERFORMANCE_TEST_
   392 #ifdef _XN_PERFORMANCE_TEST_
   381     RDebug::Print( _L( "CHspsWrapper::SetAppConfigurationL() - start" ) );
   393     RDebug::Print( _L( "CHspsWrapper::SetAppConfigurationL() - start" ) );
   382 #endif //_XN_PERFORMANCE_TEST_        
   394 #endif //_XN_PERFORMANCE_TEST_        
   383     CLiwGenericParamList& inParamList = iServiceHandler->InParamListL();
   395     CLiwGenericParamList& inParamList = iServiceHandler->InParamListL();
   384     CLiwGenericParamList& outParamList = iServiceHandler->OutParamListL();
   396     CLiwGenericParamList& outParamList = iServiceHandler->OutParamListL();
   449         {
   461         {
   450         const CLiwMap* confMap  = conf->Value().AsMap();
   462         const CLiwMap* confMap  = conf->Value().AsMap();
   451         // 2: Process Configuration map
   463         // 2: Process Configuration map
   452         if(confMap)
   464         if(confMap)
   453            {
   465            {
   454            ProcessConfigurationMapL(*confMap,*configuration);
   466            ProcessConfigurationMapL( *confMap, *configuration, EFalse );
   455            }
   467            }
   456         }
   468         }
   457    
   469    
   458     outParamList.Reset();
   470     outParamList.Reset();
   459     CleanupStack::Pop(configuration);
   471     CleanupStack::Pop(configuration);
   723     }
   735     }
   724 
   736 
   725 // ---------------------------------------------------------------------------
   737 // ---------------------------------------------------------------------------
   726 // ---------------------------------------------------------------------------
   738 // ---------------------------------------------------------------------------
   727 //
   739 //
   728 EXPORT_C TInt CHspsWrapper::SetActivePluginL(const TDesC8& aPluginId)
   740 EXPORT_C TInt CHspsWrapper::SetActivePluginL( const TDesC8& aPluginId )
   729     {
   741     {
   730     // Compose AddPlugin hsps LIW message to Service.HomeScreenPluginConfiguration
   742     TPtrC8 pluginId = aPluginId;
   731     CLiwGenericParamList& inParamList = iServiceHandler->InParamListL();
   743     if( aPluginId.Length() > KMaxPluginIdLen )
   732     CLiwGenericParamList& outParamList = iServiceHandler->OutParamListL();
   744         {
   733          
   745         pluginId.Set( aPluginId.Left( KMaxPluginIdLen ) );
   734     // Compose Liw message
   746         }
   735     TLiwGenericParam pluginIdParam;
   747         
   736     pluginIdParam.SetNameAndValueL( KKeyPluginId, TLiwVariant(aPluginId) );
   748     const TInt error = iRepository->Set( KAIActiveViewPluginId, pluginId );
   737     pluginIdParam.PushL();
   749 
   738     inParamList.AppendL( pluginIdParam );
   750     delete iActivePluginId;
   739     CleanupStack::Pop(&pluginIdParam);
   751     iActivePluginId = NULL;    
   740     pluginIdParam.Reset();
   752     
   741       
   753     if( error == KErrNone )
   742     iHspsInterface->ExecuteCmdL( KHSPSCommandSetActivePlugin, 
   754         {
   743                                  inParamList, 
   755         iActivePluginId = pluginId.AllocL();        
   744                                  outParamList ); 
   756         }
   745       
   757     else
   746     inParamList.Reset();
   758         {
   747       
   759         iActivePluginId = KPluginIdNotSet().AllocL();
   748     // check success
   760         }
   749     const TLiwGenericParam* outParam = NULL;
   761     
   750     TInt pos(0);
   762     return error;
   751     outParam = outParamList.FindFirst( pos, KOutKeyStatus );
       
   752     TInt status(KErrGeneral);
       
   753     
       
   754     if ( outParam )
       
   755         {
       
   756         status = outParam->Value().AsTInt32();
       
   757         }
       
   758     outParamList.Reset();
       
   759     return status;
       
   760     }
   763     }
   761 
   764 
   762 // ---------------------------------------------------------------------------
   765 // ---------------------------------------------------------------------------
   763 // ---------------------------------------------------------------------------
   766 // ---------------------------------------------------------------------------
   764 //
   767 //
  1046 // ---------------------------------------------------------------------------
  1049 // ---------------------------------------------------------------------------
  1047 // ---------------------------------------------------------------------------
  1050 // ---------------------------------------------------------------------------
  1048 //
  1051 //
  1049 void CHspsWrapper::ProcessConfigurationMapL(
  1052 void CHspsWrapper::ProcessConfigurationMapL(
  1050     const CLiwMap& aSource, 
  1053     const CLiwMap& aSource, 
  1051     CHspsConfiguration& aTarget)
  1054     CHspsConfiguration& aTarget,
       
  1055     const TBool aAppConf )
  1052     {
  1056     {
  1053     TLiwVariant tempVariant;
  1057     TLiwVariant tempVariant;
  1054     tempVariant.PushL();
  1058     tempVariant.PushL();
  1055         
  1059         
  1056     if ( aSource.FindL( _L8("id"), tempVariant ) )
  1060     if ( aSource.FindL( _L8("id"), tempVariant ) )
  1088     if( aSource.FindL( _L8("plugins"), tempVariant ) )
  1092     if( aSource.FindL( _L8("plugins"), tempVariant ) )
  1089         {
  1093         {
  1090         const CLiwList* plugins( tempVariant.AsList() );
  1094         const CLiwList* plugins( tempVariant.AsList() );
  1091         if( plugins )
  1095         if( plugins )
  1092             {
  1096             {
  1093             ProcessConfigurationPluginsL(*plugins,aTarget);
  1097             ProcessConfigurationPluginsL( *plugins,
       
  1098                                           aTarget,
       
  1099                                           aAppConf );
  1094             }
  1100             }
  1095         }
  1101         }
  1096     if( aSource.FindL( _L8("settings"), tempVariant ) )
  1102     if( aSource.FindL( _L8("settings"), tempVariant ) )
  1097         {
  1103         {
  1098         const CLiwList* settings( tempVariant.AsList() );
  1104         const CLiwList* settings( tempVariant.AsList() );
  1116 // ---------------------------------------------------------------------------
  1122 // ---------------------------------------------------------------------------
  1117 // ---------------------------------------------------------------------------
  1123 // ---------------------------------------------------------------------------
  1118 //
  1124 //
  1119 void CHspsWrapper::ProcessConfigurationPluginsL(
  1125 void CHspsWrapper::ProcessConfigurationPluginsL(
  1120     const CLiwList& aPluginsList, 
  1126     const CLiwList& aPluginsList, 
  1121     CHspsConfiguration& aTarget)
  1127     CHspsConfiguration& aTarget,
  1122     {
  1128     const TBool aAppConf )
       
  1129     {
       
  1130     TBool activePluginFound = EFalse;
       
  1131     
  1123     TLiwVariant pluginMapVariant;
  1132     TLiwVariant pluginMapVariant;
  1124     pluginMapVariant.PushL();
  1133     pluginMapVariant.PushL();
  1125     for( int i=0;i<aPluginsList.Count();++i )
  1134     for( int i=0;i<aPluginsList.Count();++i )
  1126         {
  1135         {
  1127         if( aPluginsList.AtL(i,pluginMapVariant) )
  1136         if( aPluginsList.AtL(i,pluginMapVariant) )
  1138                     }
  1147                     }
  1139                 if( pluginMap->FindL( _L8("uid"),pluginVariant) )
  1148                 if( pluginMap->FindL( _L8("uid"),pluginVariant) )
  1140                     {
  1149                     {
  1141                     plugin->SetPluginUidL( pluginVariant.AsData() );
  1150                     plugin->SetPluginUidL( pluginVariant.AsData() );
  1142                     }
  1151                     }
  1143                 if( pluginMap->FindL( _L8("activationstate"),pluginVariant ) )
       
  1144                     {
       
  1145                     plugin->SetActivationStateL( pluginVariant.AsData() );
       
  1146                     }
       
  1147                 if ( pluginMap->FindL( _L8( "locking_status" ), pluginVariant ) )
  1152                 if ( pluginMap->FindL( _L8( "locking_status" ), pluginVariant ) )
  1148                     {
  1153                     {
  1149                     plugin->SetLockingStatusL( pluginVariant.AsData() );
  1154                     plugin->SetLockingStatusL( pluginVariant.AsData() );
       
  1155                     }                
       
  1156                 
       
  1157                 if( aAppConf )
       
  1158                     {
       
  1159                     if( ActivePluginId().Compare( KPluginIdNotSet ) == 0 && 
       
  1160                         pluginMap->FindL( _L8( "activationstate" ), pluginVariant ) )
       
  1161                         {
       
  1162                         const TPtrC8 data = pluginVariant.AsData();
       
  1163                         
       
  1164                         plugin->SetActivationStateL( data );
       
  1165                         
       
  1166                         if( data.Compare( K1 ) == 0 )
       
  1167                             {
       
  1168                             SetActivePluginL( plugin->PluginId() );
       
  1169                             activePluginFound = ETrue;
       
  1170                             }
       
  1171                         }
       
  1172                     else if( ActivePluginId().Compare( plugin->PluginId() ) == 0 )
       
  1173                         {
       
  1174                         plugin->SetActivationStateL( K1 );
       
  1175                         activePluginFound = ETrue;
       
  1176                         }
       
  1177                     else
       
  1178                         {
       
  1179                         plugin->SetActivationStateL( K0 );
       
  1180                         }
  1150                     }
  1181                     }
       
  1182                 else
       
  1183                     {
       
  1184                     if ( pluginMap->FindL( _L8( "activationstate" ), pluginVariant ) )
       
  1185                         {
       
  1186                         plugin->SetActivationStateL( pluginVariant.AsData() );
       
  1187                         }                                
       
  1188                     }
       
  1189                 
  1151                 aTarget.AddPluginMapL(plugin);                    
  1190                 aTarget.AddPluginMapL(plugin);                    
  1152                 CleanupStack::Pop(plugin);
  1191                 CleanupStack::Pop(plugin);
  1153                 }
  1192                 }
  1154             CleanupStack::Pop(&pluginVariant);
  1193             CleanupStack::Pop(&pluginVariant);
  1155             pluginVariant.Reset();
  1194             pluginVariant.Reset();
  1156             }
  1195             }       
  1157        
  1196         }
  1158         }
  1197     
  1159     CleanupStack::Pop(&pluginMapVariant);
  1198     CleanupStack::Pop(&pluginMapVariant);
  1160     pluginMapVariant.Reset();
  1199     pluginMapVariant.Reset();
       
  1200     
       
  1201     if( aAppConf &&
       
  1202         !activePluginFound &&
       
  1203         aTarget.PluginMaps().Count() > 0 )
       
  1204         {
       
  1205         CPluginMap* plugin = aTarget.PluginMaps()[0]; 
       
  1206         if( plugin )
       
  1207             {
       
  1208             plugin->SetActivationStateL( K1 );
       
  1209             SetActivePluginL( plugin->PluginId() );
       
  1210             }
       
  1211         }
  1161     }
  1212     }
  1162 
  1213 
  1163 // ---------------------------------------------------------------------------
  1214 // ---------------------------------------------------------------------------
  1164 // ---------------------------------------------------------------------------
  1215 // ---------------------------------------------------------------------------
  1165 //
  1216 //
  1562         
  1613         
  1563         }
  1614         }
  1564    
  1615    
  1565     
  1616     
  1566     return retval;    
  1617     return retval;    
  1567     }    
  1618     }
       
  1619 
       
  1620 // ---------------------------------------------------------------------------
       
  1621 // ---------------------------------------------------------------------------
       
  1622 //    
       
  1623 TInt CHspsWrapper::LoadActivePluginIdL()
       
  1624     {    
       
  1625     delete iActivePluginId;
       
  1626     iActivePluginId = NULL;    
       
  1627     
       
  1628     iActivePluginId = HBufC8::NewL( KMaxPluginIdLen );
       
  1629     TPtr8 activePluginId = iActivePluginId->Des();
       
  1630         
       
  1631     const TInt error = iRepository->Get( KAIActiveViewPluginId, activePluginId );
       
  1632     
       
  1633     if( error != KErrNone )
       
  1634         {
       
  1635         delete iActivePluginId;
       
  1636         iActivePluginId = NULL;
       
  1637         iActivePluginId = KPluginIdNotSet().AllocL();
       
  1638         }
       
  1639     
       
  1640     return error;
       
  1641     }
       
  1642 
       
  1643 // ---------------------------------------------------------------------------
       
  1644 // ---------------------------------------------------------------------------
       
  1645 //    
       
  1646 const TDesC8& CHspsWrapper::ActivePluginId() const
       
  1647     {
       
  1648     if( iActivePluginId )
       
  1649         {
       
  1650         return *iActivePluginId;
       
  1651         }
       
  1652     else
       
  1653         {
       
  1654         return KPluginIdNotSet;
       
  1655         }
       
  1656     }
       
  1657 
  1568 }
  1658 }
  1569 
  1659 
  1570 //End of file
  1660 //End of file