phoneplugins/infowidgetplugin/infowidget/src/infowidgetengine.cpp
changeset 45 6b911d05207e
child 46 bc5a64e5bc3c
equal deleted inserted replaced
37:ba76fc04e6c2 45:6b911d05207e
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:
       
    15  *
       
    16  */
       
    17 
       
    18 #include <networkhandlingproxy.h>
       
    19 #include "infowidgetengine.h"
       
    20 #include "infowidgetnetworkhandler.h"
       
    21 #include "infowidgetsathandler.h"
       
    22 #include "infowidgetlogging.h"
       
    23 #include "infowidgetpreferences.h"
       
    24 
       
    25 /*!
       
    26   \class InfoWidgetEngine
       
    27   \brief Engine functionality of 
       
    28          Operator info widget
       
    29 */
       
    30 
       
    31 
       
    32 /*!
       
    33    InfoWidgetEngine::InfoWidgetEngine
       
    34  */
       
    35 InfoWidgetEngine::InfoWidgetEngine(QObject *parent): 
       
    36     QObject(parent),
       
    37     m_networkHandler(new InfoWidgetNetworkHandler),
       
    38     m_satHandler(new InfoWidgetSatHandler)
       
    39 {
       
    40     DPRINT << ": IN";
       
    41     
       
    42     // Connect network handler signals 
       
    43     QObject::connect(
       
    44         m_networkHandler.data(), SIGNAL(networkError(int, int)),
       
    45         this, SLOT(handleNetworkError(int, int))); 
       
    46     QObject::connect(
       
    47         m_networkHandler.data(), SIGNAL(networkDataChanged()),
       
    48         this, SLOT(updateNetworkDataToModel()));
       
    49 
       
    50     // Connect SAT handler signals 
       
    51     QObject::connect(m_satHandler.data(), 
       
    52             SIGNAL(handleError(int, int)),
       
    53                 this, SLOT(handleSatError(int, int))); 
       
    54     QObject::connect(m_satHandler.data(), 
       
    55             SIGNAL(handleMessage(int)),
       
    56                 this, SLOT(updateSatDataToModel())); 
       
    57 
       
    58     // Update initial model data
       
    59     updateNetworkDataToModel();
       
    60     updateSatDataToModel();
       
    61     
       
    62     DPRINT << ": OUT";
       
    63 }
       
    64 
       
    65 /*!
       
    66    InfoWidgetEngine::~InfoWidgetEngine
       
    67  */
       
    68 InfoWidgetEngine::~InfoWidgetEngine()
       
    69 {
       
    70     DPRINT;
       
    71 }    
       
    72 
       
    73 /*!
       
    74    InfoWidgetEngine::modelData
       
    75    
       
    76    Getter for model data. 
       
    77  */
       
    78 const InfoWidgetEngine::ModelData& InfoWidgetEngine::modelData() const
       
    79 {
       
    80     DPRINT;
       
    81     return m_modelData; 
       
    82 }
       
    83 
       
    84 /*!
       
    85    InfoWidgetEngine::updateNetworkDataToModel
       
    86    
       
    87    Updates Network Handler's network data to model. 
       
    88  */
       
    89 void InfoWidgetEngine::updateNetworkDataToModel()
       
    90 {
       
    91     DPRINT << ": IN"; 
       
    92     
       
    93     if (m_networkHandler->sessionExists() && 
       
    94         m_networkHandler->isOnline()) {
       
    95     
       
    96         m_modelData.setServiceProviderName(
       
    97                 m_networkHandler->serviceProviderName());
       
    98         m_modelData.setServiceProviderNameDisplayRequired(
       
    99                 m_networkHandler->serviceProviderNameDisplayRequired());
       
   100     
       
   101         m_modelData.setMcnName(m_networkHandler->mcnName()); 
       
   102         m_modelData.setMcnIndicatorType(
       
   103                 m_networkHandler->mcnIndicatorType());
       
   104         
       
   105         m_modelData.setHomeZoneIndicatorType(
       
   106             m_networkHandler->homeZoneIndicatorType());
       
   107         m_modelData.setHomeZoneTextTag(
       
   108                 m_networkHandler->homeZoneTextTag());
       
   109     } else {
       
   110         // Not registered to network, clear data
       
   111         m_modelData.setServiceProviderName(QString(""));
       
   112         m_modelData.setMcnName(QString(""));
       
   113         m_modelData.setHomeZoneTextTag(QString("")); 
       
   114     }
       
   115         
       
   116     emit modelChanged();
       
   117     
       
   118     DPRINT << ": OUT";
       
   119 }
       
   120 
       
   121 /*!
       
   122    InfoWidgetEngine::updateSatDataToModel
       
   123    
       
   124    Updates SAT handler's SAT data to model.
       
   125  */
       
   126 void InfoWidgetEngine::updateSatDataToModel()
       
   127 {
       
   128     DPRINT;
       
   129     if (m_satHandler) {
       
   130         m_modelData.setSatDisplayText(
       
   131                 m_satHandler->satDisplayText());
       
   132         
       
   133         emit modelChanged(); 
       
   134     } 
       
   135 }
       
   136 
       
   137 /*!
       
   138    InfoWidgetEngine::updateLineDataToModel
       
   139  */
       
   140 void InfoWidgetEngine::updateLineDataToModel()
       
   141 {
       
   142     DPRINT;
       
   143 }
       
   144 
       
   145 /*!
       
   146    InfoWidgetEngine::handleNetworkError
       
   147  */
       
   148 void InfoWidgetEngine::handleNetworkError(
       
   149         int operation, int errorCode)
       
   150 {
       
   151     DWARNING << ": operation: " << operation << 
       
   152             " error code: " << errorCode; 
       
   153 }
       
   154 
       
   155 /*!
       
   156    InfoWidgetEngine::handleSatError
       
   157  */
       
   158 void InfoWidgetEngine::handleSatError(
       
   159         int operation, int errorCode)
       
   160 {
       
   161     DWARNING << ": operation: " << operation << 
       
   162             " error code: " << errorCode; 
       
   163 }
       
   164 
       
   165 /*!
       
   166    InfoWidgetEngine::handleLineError
       
   167  */
       
   168 void InfoWidgetEngine::handleLineError(
       
   169         int operation, int errorCode)
       
   170 {
       
   171     DWARNING << ": operation: " << 
       
   172             operation << " error code: " << errorCode; 
       
   173 }
       
   174 
       
   175 /*!
       
   176    InfoWidgetEngine::handlePreferencesChanged
       
   177  */
       
   178 void InfoWidgetEngine::handlePreferencesChanged(
       
   179         InfoWidgetPreferences::Options options)
       
   180 {
       
   181     DPRINT; 
       
   182     if (options.testFlag(InfoWidgetPreferences::DisplayMcn)){
       
   183             m_networkHandler->enableMcn(); 
       
   184         } else {
       
   185             m_networkHandler->disableMcn();
       
   186         }
       
   187 
       
   188     if (options.testFlag(InfoWidgetPreferences::DisplaySatText)){
       
   189             m_satHandler->connect(true);
       
   190         } else {
       
   191             m_satHandler->connect(false);
       
   192         }
       
   193 }
       
   194 
       
   195 /*!
       
   196    InfoWidgetEngine::suspend
       
   197    
       
   198    Called when widget is deactivated 
       
   199    and widget should suspend all 
       
   200    possible activities 
       
   201  */
       
   202 void InfoWidgetEngine::suspend() 
       
   203 {
       
   204     DPRINT;
       
   205     m_networkHandler->suspend(); 
       
   206 }
       
   207 
       
   208 /*!
       
   209    InfoWidgetEngine::preferenceChanged
       
   210    
       
   211    Called when widget is activated 
       
   212    and widget can resume activities
       
   213  */
       
   214 void InfoWidgetEngine::resume()
       
   215 {
       
   216     DPRINT;
       
   217     m_networkHandler->resume(); 
       
   218 }
       
   219 
       
   220 
       
   221 // End of File. 
       
   222