phoneplugins/infowidgetplugin/infowidget/src/infowidgetengine.cpp
branchRCL_3
changeset 24 41a7f70b3818
equal deleted inserted replaced
23:40a3f856b14d 24:41a7f70b3818
       
     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    Constructor. 
       
    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    Destructor. 
       
    67  */
       
    68 InfoWidgetEngine::~InfoWidgetEngine()
       
    69 {
       
    70     DPRINT;
       
    71 }    
       
    72 
       
    73 /*!
       
    74    Getter for model data. 
       
    75  */
       
    76 const InfoWidgetEngine::ModelData& InfoWidgetEngine::modelData() const
       
    77 {
       
    78     DPRINT;
       
    79     return m_modelData; 
       
    80 }
       
    81 
       
    82 /*!
       
    83    Updates Network Handler's network data to model. 
       
    84  */
       
    85 void InfoWidgetEngine::updateNetworkDataToModel()
       
    86 {
       
    87     DPRINT;
       
    88     if (m_networkHandler->isOnline()) {
       
    89         DPRINT << ": online, update data";
       
    90         m_modelData.setServiceProviderName(
       
    91                 m_networkHandler->serviceProviderName());
       
    92 
       
    93         m_modelData.setServiceProviderNameDisplayRequired(
       
    94                 m_networkHandler->serviceProviderNameDisplayRequired());
       
    95     
       
    96         m_modelData.setMcnName(m_networkHandler->mcnName()); 
       
    97         m_modelData.setMcnIndicatorType(
       
    98                 m_networkHandler->mcnIndicatorType());
       
    99         
       
   100         m_modelData.setHomeZoneIndicatorType(
       
   101             m_networkHandler->homeZoneIndicatorType());
       
   102         m_modelData.setHomeZoneTextTag(
       
   103                 m_networkHandler->homeZoneTextTag());
       
   104     } else {
       
   105         DPRINT << ": offline, clear data";
       
   106         m_modelData.setServiceProviderName("");
       
   107         m_modelData.setMcnName("");
       
   108         m_modelData.setHomeZoneTextTag(""); 
       
   109     }
       
   110     emit modelChanged();
       
   111 }
       
   112 
       
   113 /*!
       
   114    Updates SAT handler's SAT data to model.
       
   115  */
       
   116 void InfoWidgetEngine::updateSatDataToModel()
       
   117 {
       
   118     DPRINT;
       
   119     if (m_satHandler) {
       
   120         m_modelData.setSatDisplayText(
       
   121                 m_satHandler->satDisplayText());
       
   122         
       
   123         emit modelChanged(); 
       
   124     } 
       
   125 }
       
   126 
       
   127 /*!
       
   128    Updates line handler's data to model. 
       
   129  */
       
   130 void InfoWidgetEngine::updateLineDataToModel()
       
   131 {
       
   132     DPRINT;
       
   133 }
       
   134 
       
   135 /*!
       
   136    Network error handler.  
       
   137  */
       
   138 void InfoWidgetEngine::handleNetworkError(
       
   139         int operation, int errorCode)
       
   140 {
       
   141     DWARNING << ": operation: " << operation << 
       
   142             " error code: " << errorCode; 
       
   143 }
       
   144 
       
   145 /*!
       
   146    SAT error handler. 
       
   147  */
       
   148 void InfoWidgetEngine::handleSatError(
       
   149         int operation, int errorCode)
       
   150 {
       
   151     DWARNING << ": operation: " << operation << 
       
   152             " error code: " << errorCode; 
       
   153 }
       
   154 
       
   155 /*!
       
   156    Line error handler. 
       
   157  */
       
   158 void InfoWidgetEngine::handleLineError(
       
   159         int operation, int errorCode)
       
   160 {
       
   161     DWARNING << ": operation: " << 
       
   162             operation << " error code: " << errorCode; 
       
   163 }
       
   164 
       
   165 /*!
       
   166    InfoWidgetEngine::handlePreferencesChanged
       
   167  */
       
   168 void InfoWidgetEngine::handlePreferencesChanged(
       
   169         InfoWidgetPreferences::Options options)
       
   170 {
       
   171     DPRINT; 
       
   172     if (options.testFlag(InfoWidgetPreferences::DisplayMcn)){
       
   173             m_networkHandler->enableMcn(); 
       
   174         } else {
       
   175             m_networkHandler->disableMcn();
       
   176         }
       
   177     if (options.testFlag(InfoWidgetPreferences::DisplaySatText)){
       
   178             m_satHandler->connect(true);
       
   179         } else {
       
   180             m_satHandler->connect(false);
       
   181         }
       
   182 }
       
   183 
       
   184 /*!
       
   185    Called when widget is deactivated 
       
   186    and widget should suspend all 
       
   187    possible activities 
       
   188  */
       
   189 void InfoWidgetEngine::suspend() 
       
   190 {
       
   191     DPRINT;
       
   192     m_networkHandler->suspend(); 
       
   193 }
       
   194 
       
   195 /*!
       
   196    Called when widget is activated 
       
   197    and widget can resume activities
       
   198  */
       
   199 void InfoWidgetEngine::resume()
       
   200 {
       
   201     DPRINT;
       
   202     m_networkHandler->resume(); 
       
   203 }
       
   204 
       
   205 
       
   206 // End of File. 
       
   207