src/hbcore/indicatorplugins/hbindicatorpluginmanager.cpp
changeset 34 ed14f46c0e55
parent 7 923ff622b8b9
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
   166     if (index >= 0 && checkAccess(index, indicatorType, securityCredentials)) {
   166     if (index >= 0 && checkAccess(index, indicatorType, securityCredentials)) {
   167         HbIndicatorInterface *indicator = indicatorInfo->indicator;
   167         HbIndicatorInterface *indicator = indicatorInfo->indicator;
   168 
   168 
   169         indicator->disconnect(this, SLOT(deactivateIndicator()));
   169         indicator->disconnect(this, SLOT(deactivateIndicator()));
   170         connect(indicator, SIGNAL(deactivate()), SLOT(deactivateIndicator()), Qt::QueuedConnection);
   170         connect(indicator, SIGNAL(deactivate()), SLOT(deactivateIndicator()), Qt::QueuedConnection);
   171 
   171         success = true;
   172         indicator->processClientRequest(
   172         try {
       
   173             indicator->processClientRequest(
   173                 HbIndicatorInterface::RequestActivate, parameter);
   174                 HbIndicatorInterface::RequestActivate, parameter);
   174         //in case indicator deactivated itself, find the indicator again.
   175         } catch (const std::bad_alloc &) {
   175         index = findPlugin(indicatorType, &indicatorInfo);
   176             success = false;
   176 
   177         }
   177         if (index >= 0 && !indicatorInfo->activated) {
   178         if (success) {
   178             indicatorInfo->activated = true;
   179             //in case indicator deactivated itself, find the indicator again.
   179             emit indicatorActivated(indicator);
   180             index = findPlugin(indicatorType, &indicatorInfo);
   180             indicatorInfo->statusAreaIconPath = statusAreaIconPath(indicator);
   181 
   181             emit indicatorActivated(IndicatorClientInfo(
   182             if (index >= 0 && !indicatorInfo->activated) {
   182                 indicator->indicatorType(), indicatorInfo->statusAreaIconPath,
   183                 indicatorInfo->activated = true;
   183                 indicator->category(), hasMenuData(*indicator)));
   184                 emit indicatorActivated(indicator);
   184 
   185                 indicatorInfo->statusAreaIconPath = statusAreaIconPath(indicator);
   185             connect(indicator, SIGNAL(dataChanged()), SLOT(indicatorDataChanged()));
   186                 emit indicatorActivated(IndicatorClientInfo(
   186             connect(indicator, SIGNAL(userActivated(QVariantMap)), SLOT(userActivateIndicator(QVariantMap)));
   187                     indicator->indicatorType(), indicatorInfo->statusAreaIconPath,
   187         }
   188                     indicator->category(), hasMenuData(*indicator)));
   188         success = true;
   189 
       
   190                 connect(indicator, SIGNAL(dataChanged()), SLOT(indicatorDataChanged()));
       
   191                 connect(indicator, SIGNAL(userActivated(QVariantMap)), SLOT(userActivateIndicator(QVariantMap)));
       
   192             }
       
   193         }
   189     }
   194     }
   190     return success;
   195     return success;
   191 }
   196 }
   192 
   197 
   193 /*
   198 /*
   216             hasMenuData(*indicator)));
   221             hasMenuData(*indicator)));
   217 
   222 
   218         //plugin-interface may also be HbIndicatorInterface.
   223         //plugin-interface may also be HbIndicatorInterface.
   219         //in that case, don't delete.
   224         //in that case, don't delete.
   220         HbIndicatorInterface *testPlugin =
   225         HbIndicatorInterface *testPlugin =
   221                 dynamic_cast<HbIndicatorInterface*>(pluginInfo.plugin());
   226             qobject_cast<HbIndicatorInterface*>(pluginInfo.mLoader->instance());
   222         if ( testPlugin != indicator) {
   227         if ( testPlugin != indicator) {
   223             //indicator deletion must occur before idle-timer-cleanup.
   228             //indicator deletion must occur before idle-timer-cleanup.
   224             delete indicator;
   229             delete indicator;
   225             indicator = 0;
   230             indicator = 0;
   226         }
   231         }
   251                 pluginInfo.mAddedIndicators) {
   256                 pluginInfo.mAddedIndicators) {
   252 
   257 
   253             HbIndicatorInterface *indicator = indicatorInfo.indicator;
   258             HbIndicatorInterface *indicator = indicatorInfo.indicator;
   254             HbIndicatorInterface::Category category = indicator->category();
   259             HbIndicatorInterface::Category category = indicator->category();
   255 
   260 
   256             QString path(indicatorInfo.statusAreaIconPath);
   261             IndicatorClientInfo clientInfo(indicator->indicatorType(), 
   257 
   262                 indicatorInfo.statusAreaIconPath, category, hasMenuData(*indicator));
   258             if (!path.isEmpty()) {
   263             clientInfoList.append(clientInfo);
   259                 IndicatorClientInfo clientInfo(indicator->indicatorType(), path, 
       
   260                     category, hasMenuData(*indicator));
       
   261                 clientInfoList.append(clientInfo);
       
   262             }
       
   263         }
   264         }
   264     }
   265     }
   265     return clientInfoList;
   266     return clientInfoList;
   266 }
   267 }
   267 
   268 
   300     bool success = false;
   301     bool success = false;
   301     IndicatorInfo *info = 0;
   302     IndicatorInfo *info = 0;
   302     int index = findPlugin(indicatorType, &info);
   303     int index = findPlugin(indicatorType, &info);
   303     if (index >= 0 && checkAccess(index, indicatorType, securityCredentials)) {
   304     if (index >= 0 && checkAccess(index, indicatorType, securityCredentials)) {
   304         HbIndicatorInterface *indicator = info->indicator;
   305         HbIndicatorInterface *indicator = info->indicator;
       
   306         success = true;
   305         if (indicator->indicatorType() == indicatorType && info->activated) {
   307         if (indicator->indicatorType() == indicatorType && info->activated) {
   306             indicator->processClientRequest(
   308             try {
       
   309                 indicator->processClientRequest(
   307                     HbIndicatorInterface::RequestDeactivate, parameter);
   310                     HbIndicatorInterface::RequestDeactivate, parameter);
   308         }
   311             } catch (const std::bad_alloc &) {
   309         success = true;
   312                 success = false;
       
   313             }
       
   314         }
   310     }
   315     }
   311     TRACE_EXIT
   316     TRACE_EXIT
   312     return success;
   317     return success;
   313 }
   318 }
   314 
   319