phoneplugins/infowidgetplugin/infowidgetprovider/infowidget/src/infowidgetengine.cpp
changeset 27 2f8f8080a020
parent 22 6bb1b21d2484
--- a/phoneplugins/infowidgetplugin/infowidgetprovider/infowidget/src/infowidgetengine.cpp	Fri Apr 16 14:58:25 2010 +0300
+++ b/phoneplugins/infowidgetplugin/infowidgetprovider/infowidget/src/infowidgetengine.cpp	Mon May 03 12:31:11 2010 +0300
@@ -17,18 +17,25 @@
 
 #include "infowidgetengine.h"
 #include "infowidgetnetworkhandler.h"
+#include "infowidgetsathandler.h"
 #include <networkhandlingproxy.h>
 #include "infowidgetlogging.h"
-#include <xqsettingsmanager.h>
-#include <xqsettingskey.h>
-#include <settingsinternalcrkeys.h>
+#include "infowidgetpreferences.h"
+
+/*!
+  \class InfoWidgetEngine
+  \brief Engine functionality of 
+         Operator info widget
+*/
+
 
 /*!
    InfoWidgetEngine::InfoWidgetEngine
  */
 InfoWidgetEngine::InfoWidgetEngine(QObject *parent): 
     QObject(parent),
-    m_networkHandler(new InfoWidgetNetworkHandler)
+    m_networkHandler(new InfoWidgetNetworkHandler),
+    m_satHandler(new InfoWidgetSatHandler)
 {
     DPRINT << ": IN";
     
@@ -39,14 +46,17 @@
     QObject::connect(
         m_networkHandler.data(), SIGNAL(networkDataChanged()),
         this, SLOT(updateNetworkDataToModel()));
+
+    QObject::connect(m_satHandler.data(), 
+            SIGNAL(handleError(int, int)),
+            this, SLOT(handleSatError(int, int))); 
     
-    XQSettingsManager *settingsManager = new XQSettingsManager(0); 
-    XQSettingsKey settingsKey(XQSettingsKey::TargetCentralRepository, 
-        KCRUidNetworkSettings.iUid, KSettingsMcnDisplay); 
-    bool result = settingsManager->writeItemValue(settingsKey, 1 );
-    delete settingsManager;
+    QObject::connect(m_satHandler.data(), 
+                SIGNAL(handleMessage(int)),
+                this, SLOT(updateSatDataToModel())); 
 
-    updateNetworkDataToModel(); 
+    updateNetworkDataToModel();
+    updateSatDataToModel();
     
     DPRINT << ": OUT";
 }
@@ -66,13 +76,19 @@
  */
 void InfoWidgetEngine::logModelData()
 {
-    DPRINT << ": mcn name: " << m_modelData.mcnName(); 
-    DPRINT << ": service provider name: " << m_modelData.serviceProviderName();
-    DPRINT << ": homezone text tag: " << m_modelData.homeZoneTextTag();
-    
-    DPRINT << ": mcn type: " << m_modelData.mcnIndicatorType(); 
-    DPRINT << ": active line: " << m_modelData.activeLine(); 
-    DPRINT << ": homezone indicator type: " << m_modelData.homeZoneIndicatorType(); 
+    DPRINT << ": mcn name: " << m_modelData.mcnName();
+    DPRINT << ": mcn type: " << m_modelData.mcnIndicatorType();
+    DPRINT << ": service provider name: " << 
+            m_modelData.serviceProviderName();
+    DPRINT << ": service provider display required: " << 
+            m_modelData.serviceProviderNameDisplayRequired(); 
+
+    DPRINT << ": homezone text tag: " << 
+            m_modelData.homeZoneTextTag();
+    DPRINT << ": homezone indicator type: " << 
+            m_modelData.homeZoneIndicatorType(); 
+    DPRINT << ": active line: " << 
+            m_modelData.activeLine(); 
 } 
 
 /*!
@@ -95,13 +111,28 @@
     
     m_networkHandler->logCurrentInfo();
     
-    // Read network handler data to model data
-    m_modelData.setHomeZoneIndicatorType(
-        m_networkHandler->homeZoneIndicatorType());
-    m_modelData.setHomeZoneTextTag(m_networkHandler->homeZoneTextTag()); 
-    m_modelData.setMcnName(m_networkHandler->mcnName()); 
-    m_modelData.setMcnIndicatorType(m_networkHandler->mcnIndicatorType());
+    if (m_networkHandler->isOnline()) {
+        // Read network handler data to model data
+        m_modelData.setServiceProviderName(
+                m_networkHandler->serviceProviderName());
+        m_modelData.setServiceProviderNameDisplayRequired(
+                m_networkHandler->serviceProviderNameDisplayRequired());
     
+        m_modelData.setMcnName(m_networkHandler->mcnName()); 
+        m_modelData.setMcnIndicatorType(
+                m_networkHandler->mcnIndicatorType());
+        
+        m_modelData.setHomeZoneIndicatorType(
+            m_networkHandler->homeZoneIndicatorType());
+        m_modelData.setHomeZoneTextTag(
+                m_networkHandler->homeZoneTextTag());
+    } else {
+        // Not registered to network, clear data
+        m_modelData.setServiceProviderName(QString(""));
+        m_modelData.setMcnName(QString(""));
+        m_modelData.setHomeZoneTextTag(QString("")); 
+    }
+        
     emit modelChanged();
     
     DPRINT << ": OUT";
@@ -112,7 +143,19 @@
  */
 void InfoWidgetEngine::updateSatDataToModel()
 {
-    DPRINT;
+    DPRINT << ": IN";
+    
+    if (m_satHandler) {
+        // Log current network data 
+        m_satHandler->logCurrentInfo();
+        // Read SAT handler data to model data
+        m_modelData.setSatDisplayText(
+                m_satHandler->satDisplayText());
+        
+        emit modelChanged(); 
+    } 
+     
+    DPRINT << ": OUT";
 }
 
 /*!
@@ -126,26 +169,81 @@
 /*!
    InfoWidgetEngine::handleNetworkError
  */
-void InfoWidgetEngine::handleNetworkError(int operation, int errorCode)
+void InfoWidgetEngine::handleNetworkError(
+        int operation, int errorCode)
 {
-    DPRINT << ": operation: " << operation << " error code: " << errorCode; 
+    DPRINT << ": operation: " << operation << 
+            " error code: " << errorCode; 
 }
 
 /*!
    InfoWidgetEngine::handleSatError
  */
-void InfoWidgetEngine::handleSatError(int operation, int errorCode)
+void InfoWidgetEngine::handleSatError(
+        int operation, int errorCode)
 {
-    DPRINT << ": operation: " << operation << " error code: " << errorCode; 
+    DPRINT << ": operation: " << operation << 
+            " error code: " << errorCode; 
 }
 
 /*!
    InfoWidgetEngine::handleLineError
  */
-void InfoWidgetEngine::handleLineError(int operation, int errorCode)
+void InfoWidgetEngine::handleLineError(
+        int operation, int errorCode)
 {
     DPRINT << ": operation: " << operation << " error code: " << errorCode; 
 }
 
+/*!
+   InfoWidgetEngine::preferenceChanged
+ */
+void InfoWidgetEngine::preferenceChanged(
+        int option, int displaySetting)
+{
+    DPRINT << "option: " << option << " displaySetting: " << displaySetting;
+    switch(option){
+    case InfoWidgetPreferences::DisplayMcn:
+        if (displaySetting == InfoWidgetPreferences::DisplayOn) {
+            m_networkHandler->enableMcn();
+        } else {
+            m_networkHandler->disableMcn();
+        }   
+        break; 
+    case InfoWidgetPreferences::DisplaySatText:
+        m_satHandler->connect(displaySetting);
+        break;
+    default:
+        break;
+    }
+    DPRINT << ": OUT";
+}
+
+/*!
+   InfoWidgetEngine::suspend
+   
+   Called when widget is deactivated 
+   and widget should suspend all 
+   possible activities 
+ */
+void InfoWidgetEngine::suspend() 
+{
+    DPRINT;
+    m_networkHandler->suspend(); 
+}
+
+/*!
+   InfoWidgetEngine::preferenceChanged
+   
+   Called when widget is activated 
+   and widget can resume activities
+ */
+void InfoWidgetEngine::resume()
+{
+    DPRINT;
+    m_networkHandler->resume(); 
+}
+
+
 // End of File.