phoneapp/phoneuiqtviewadapter/src/phoneindicatorcontroller.cpp
changeset 77 2be0b271d017
parent 72 c76a0b1755b9
child 78 baacf668fe89
equal deleted inserted replaced
72:c76a0b1755b9 77:2be0b271d017
    67     connect( m_setManager, 
    67     connect( m_setManager, 
    68             SIGNAL( valueChanged(const XQSettingsKey & ,const QVariant &)),
    68             SIGNAL( valueChanged(const XQSettingsKey & ,const QVariant &)),
    69                 this, SLOT(updateDivertIndicator(XQSettingsKey, 
    69                 this, SLOT(updateDivertIndicator(XQSettingsKey, 
    70                         QVariant)));
    70                         QVariant)));
    71     
    71     
       
    72     fetchMissedCalls(
       
    73             m_setManager->readItemValue(
       
    74                     PhoneIndicatorControllerKeys::missedCallsSettingsKey).toInt());
       
    75     
    72     m_setManager->startMonitoring( PhoneIndicatorControllerKeys::missedCallsSettingsKey );
    76     m_setManager->startMonitoring( PhoneIndicatorControllerKeys::missedCallsSettingsKey );
    73     m_setManager->startMonitoring( PhoneIndicatorControllerKeys::unconditionalCFKey, 
    77     m_setManager->startMonitoring( PhoneIndicatorControllerKeys::unconditionalCFKey, 
    74             XQSettingsManager::TypeByteArray);
    78             XQSettingsManager::TypeByteArray);
    75     m_setManager->startMonitoring( PhoneIndicatorControllerKeys::currentCFKey,
    79     m_setManager->startMonitoring( PhoneIndicatorControllerKeys::currentCFKey,
    76             XQSettingsManager::TypeByteArray);
    80             XQSettingsManager::TypeByteArray);
    82         int cfStatus=0;
    86         int cfStatus=0;
    83         memcpy(&cfStatus, bytes.data_ptr()->array, sizeof(int));
    87         memcpy(&cfStatus, bytes.data_ptr()->array, sizeof(int));
    84         updateDiverIndicator(cfStatus & KCFVoiceForwarded);
    88         updateDiverIndicator(cfStatus & KCFVoiceForwarded);
    85     }
    89     }
    86 #endif
    90 #endif
    87     
       
    88     connect(&m_indicator,SIGNAL(userActivated(QString,QVariantMap)),
    91     connect(&m_indicator,SIGNAL(userActivated(QString,QVariantMap)),
    89             this,SLOT(handleInteraction(QString,QVariantMap)));
    92             this,SLOT(handleInteraction(QString,QVariantMap)));
    90 }
    93 }
    91 
    94 
    92 PhoneIndicatorController::~PhoneIndicatorController()
    95 PhoneIndicatorController::~PhoneIndicatorController()
   102 #endif
   105 #endif
   103 }
   106 }
   104 
   107 
   105 void PhoneIndicatorController::setActiveCallData()
   108 void PhoneIndicatorController::setActiveCallData()
   106 {
   109 {
       
   110     PHONE_TRACE
   107     m_cli = hbTrId("txt_phone_dblist_ongoing_call");
   111     m_cli = hbTrId("txt_phone_dblist_ongoing_call");
   108     m_callImage = "qtg_mono_call";//QString::fromUtf16 (icon.Ptr (), icon.Length ());
   112     m_callImage = "qtg_mono_call";
   109 }
   113 }
   110 
   114 
   111 void PhoneIndicatorController::clearActiveCallData()
   115 void PhoneIndicatorController::clearActiveCallData()
   112 {
   116 {
       
   117     PHONE_TRACE
   113     m_cli.clear();
   118     m_cli.clear();
   114     m_callImage.clear();
   119     m_callImage.clear();
   115     disableActiveCallIndicator();
   120     disableActiveCallIndicator();
   116 }
   121 }
   117 
   122 
   118 void PhoneIndicatorController::enableActiveCallIndicator()
   123 void PhoneIndicatorController::enableActiveCallIndicator()
   119 {
   124 {
       
   125     PHONE_TRACE
   120     if (!m_cli.isEmpty()){
   126     if (!m_cli.isEmpty()){
   121         QString indicatorType(indicatorName(PhoneActiveCallIndicator));
   127         QString indicatorType(indicatorName(PhoneActiveCallIndicator));
   122         QVariantMap parameters;
   128         QVariantMap parameters;
   123         
   129         
   124         parameters.insert(
   130         parameters.insert(
   131         m_indicator.activate(indicatorType, parameters);
   137         m_indicator.activate(indicatorType, parameters);
   132     }
   138     }
   133 }
   139 }
   134 void PhoneIndicatorController::disableActiveCallIndicator()
   140 void PhoneIndicatorController::disableActiveCallIndicator()
   135 {
   141 {
       
   142     PHONE_TRACE
   136     QString indicatorType(indicatorName(PhoneActiveCallIndicator));
   143     QString indicatorType(indicatorName(PhoneActiveCallIndicator));
   137     m_indicator.deactivate(indicatorType);
   144     m_indicator.deactivate(indicatorType);
   138 }
   145 }
   139 
   146 
   140 void PhoneIndicatorController::updateMissedCallIndicator(
   147 void PhoneIndicatorController::updateMissedCallIndicator(
   141         const XQSettingsKey &key, const QVariant &value)
   148         const XQSettingsKey &key, const QVariant &value)
   142 { 
   149 { 
   143 #ifdef Q_OS_SYMBIAN
   150 #ifdef Q_OS_SYMBIAN
   144 
   151     PHONE_TRACE
   145     if (compareKeys(key, PhoneIndicatorControllerKeys::missedCallsSettingsKey) ){
   152     if (compareKeys(key, PhoneIndicatorControllerKeys::missedCallsSettingsKey) ){
   146         if ( value.toInt() == 0 ){
   153         QString indicatorType(indicatorName(PhoneMissedCallIndicator));
   147             QString indicatorType(indicatorName(PhoneMissedCallIndicator));
   154         m_indicator.deactivate(indicatorType);
   148             m_indicator.deactivate(indicatorType);
   155         // deleting null pointer has no effect.
   149             delete m_missedCallsFilter;
   156         delete m_missedCallsFilter;
   150             m_missedCallsFilter = NULL;
   157         m_missedCallsFilter = NULL;
   151             delete m_logsModel;
   158         delete m_logsModel;
   152             m_logsModel = NULL;
   159         m_logsModel = NULL;
   153         } else {
   160         fetchMissedCalls(value.toInt());
   154             if(!m_logsModel){
   161     }   
   155                 m_logsModel = new LogsModel(LogsModel::LogsFullModel);
       
   156             }
       
   157             if(!m_missedCallsFilter){
       
   158                 m_missedCallsFilter = new LogsFilter(LogsFilter::Missed);
       
   159                 connect( m_missedCallsFilter, 
       
   160                     SIGNAL(rowsInserted(const QModelIndex &, int, int )),
       
   161                         this, SLOT(setMissedallIndicatorData()));
       
   162                 m_missedCallsFilter->setSourceModel(m_logsModel);
       
   163             }
       
   164             m_missedCallsFilter->setMaxSize(value.toInt() + 1);            
       
   165         }
       
   166     }
       
   167 #endif  
   162 #endif  
   168 }
   163 }
   169 
   164 
   170 void PhoneIndicatorController::updateDivertIndicator(
   165 void PhoneIndicatorController::updateDivertIndicator(
   171         const XQSettingsKey &key, const QVariant &value)
   166         const XQSettingsKey &key, const QVariant &value)
   186 }
   181 }
   187 
   182 
   188 void PhoneIndicatorController::setMissedallIndicatorData()
   183 void PhoneIndicatorController::setMissedallIndicatorData()
   189 {
   184 {
   190 #ifdef Q_OS_SYMBIAN
   185 #ifdef Q_OS_SYMBIAN
   191 
   186     PHONE_TRACE
   192     QString indicatorType(indicatorName(PhoneMissedCallIndicator));
   187     QString indicatorType(indicatorName(PhoneMissedCallIndicator));
   193     
   188     
   194     int missedCallCount = m_setManager->readItemValue( 
   189     int missedCallCount = m_setManager->readItemValue( 
   195             PhoneIndicatorControllerKeys::missedCallsSettingsKey,
   190             PhoneIndicatorControllerKeys::missedCallsSettingsKey,
   196                 XQSettingsManager::TypeInt ).toInt();
   191                 XQSettingsManager::TypeInt ).toInt();
   223             parameters.insert(
   218             parameters.insert(
   224                     QVariant( HbIndicatorInterface::DecorationNameRole ).toString(),
   219                     QVariant( HbIndicatorInterface::DecorationNameRole ).toString(),
   225                     iconName );
   220                     iconName );
   226         }
   221         }
   227         m_indicator.activate(indicatorType, parameters);
   222         m_indicator.activate(indicatorType, parameters);
   228     } else {
   223     }
   229         m_indicator.deactivate( indicatorType );
       
   230     }
       
   231    
       
   232 #endif
   224 #endif
   233 }
   225 }
   234 
   226 
   235 void PhoneIndicatorController::updateDiverIndicator(bool activeDiverts)
   227 void PhoneIndicatorController::updateDiverIndicator(bool activeDiverts)
   236 {
   228 {
   281         switch(interaction){
   273         switch(interaction){
   282             case OpenMissedCallView:
   274             case OpenMissedCallView:
   283                 service = "logs";
   275                 service = "logs";
   284                 interface = XQI_LOGS_VIEW;
   276                 interface = XQI_LOGS_VIEW;
   285                 operation = XQOP_LOGS_SHOW;
   277                 operation = XQOP_LOGS_SHOW;
   286                 map.insert(XQLOGS_VIEW_INDEX , QVariant((int)XQService::LogsViewAll));
   278                 map.insert(XQLOGS_VIEW_INDEX , QVariant((int)XQService::LogsViewMissed));
   287                 map.insert(XQLOGS_SHOW_DIALPAD, QVariant(false));
   279                 map.insert(XQLOGS_SHOW_DIALPAD, QVariant(false));
   288                 map.insert(XQLOGS_DIALPAD_TEXT, QVariant(QString()));
   280                 map.insert(XQLOGS_DIALPAD_TEXT, QVariant(QString()));
   289                 args.append(QVariant(map));
   281                 args.append(QVariant(map));
   290                 break;
   282                 break;
   291             case OpenCallUi:            
   283             case OpenCallUi:            
   309             appManager.create(service, interface, operation, false);
   301             appManager.create(service, interface, operation, false);
   310         if ( m_request == NULL ){
   302         if ( m_request == NULL ){
   311             return;       
   303             return;       
   312         }   
   304         }   
   313         m_request->setArguments(args);
   305         m_request->setArguments(args);
   314         m_request->send();    
   306         m_request->send();
   315         
   307     }
   316     }
   308 }
   317 }
   309 
       
   310 void PhoneIndicatorController::fetchMissedCalls(int count)
       
   311 {
       
   312     PHONE_TRACE1(count)
       
   313     
       
   314     if(count > 0 ){
       
   315         if(!m_logsModel){
       
   316             m_logsModel = new LogsModel(LogsModel::LogsFullModel);
       
   317         }
       
   318         if(!m_missedCallsFilter){
       
   319             m_missedCallsFilter = new LogsFilter(LogsFilter::Missed);
       
   320             connect( m_missedCallsFilter, 
       
   321                 SIGNAL(rowsInserted(const QModelIndex &, int, int )),
       
   322                     this, SLOT(setMissedallIndicatorData()));
       
   323             m_missedCallsFilter->setSourceModel(m_logsModel);
       
   324         }
       
   325         m_missedCallsFilter->setMaxSize(count + 1);
       
   326     }
       
   327 }