phoneplugins/infowidgetplugin/infowidget/src/infowidgetengine.cpp
branchGCC_SURGE
changeset 51 f39ed5e045e0
parent 46 bc5a64e5bc3c
child 50 377c906a8701
equal deleted inserted replaced
40:bab96b7ed1a4 51:f39ed5e045e0
       
     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     if (m_networkHandler->isOnline()) {
       
    92         DPRINT << ": online, update data";
       
    93         m_modelData.setServiceProviderName(
       
    94                 m_networkHandler->serviceProviderName());
       
    95 
       
    96         m_modelData.setServiceProviderNameDisplayRequired(
       
    97                 m_networkHandler->serviceProviderNameDisplayRequired());
       
    98     
       
    99         m_modelData.setMcnName(m_networkHandler->mcnName()); 
       
   100         m_modelData.setMcnIndicatorType(
       
   101                 m_networkHandler->mcnIndicatorType());
       
   102         
       
   103         m_modelData.setHomeZoneIndicatorType(
       
   104             m_networkHandler->homeZoneIndicatorType());
       
   105         m_modelData.setHomeZoneTextTag(
       
   106                 m_networkHandler->homeZoneTextTag());
       
   107     } else {
       
   108         DPRINT << ": offline, clear data";
       
   109         m_modelData.setServiceProviderName("");
       
   110         m_modelData.setMcnName("");
       
   111         m_modelData.setHomeZoneTextTag(""); 
       
   112     }
       
   113         
       
   114     emit modelChanged();
       
   115     
       
   116     DPRINT << ": OUT";
       
   117 }
       
   118 
       
   119 /*!
       
   120    InfoWidgetEngine::updateSatDataToModel
       
   121    
       
   122    Updates SAT handler's SAT data to model.
       
   123  */
       
   124 void InfoWidgetEngine::updateSatDataToModel()
       
   125 {
       
   126     DPRINT;
       
   127     if (m_satHandler) {
       
   128         m_modelData.setSatDisplayText(
       
   129                 m_satHandler->satDisplayText());
       
   130         
       
   131         emit modelChanged(); 
       
   132     } 
       
   133 }
       
   134 
       
   135 /*!
       
   136    InfoWidgetEngine::updateLineDataToModel
       
   137  */
       
   138 void InfoWidgetEngine::updateLineDataToModel()
       
   139 {
       
   140     DPRINT;
       
   141 }
       
   142 
       
   143 /*!
       
   144    InfoWidgetEngine::handleNetworkError
       
   145  */
       
   146 void InfoWidgetEngine::handleNetworkError(
       
   147         int operation, int errorCode)
       
   148 {
       
   149     DWARNING << ": operation: " << operation << 
       
   150             " error code: " << errorCode; 
       
   151 }
       
   152 
       
   153 /*!
       
   154    InfoWidgetEngine::handleSatError
       
   155  */
       
   156 void InfoWidgetEngine::handleSatError(
       
   157         int operation, int errorCode)
       
   158 {
       
   159     DWARNING << ": operation: " << operation << 
       
   160             " error code: " << errorCode; 
       
   161 }
       
   162 
       
   163 /*!
       
   164    InfoWidgetEngine::handleLineError
       
   165  */
       
   166 void InfoWidgetEngine::handleLineError(
       
   167         int operation, int errorCode)
       
   168 {
       
   169     DWARNING << ": operation: " << 
       
   170             operation << " error code: " << errorCode; 
       
   171 }
       
   172 
       
   173 /*!
       
   174    InfoWidgetEngine::handlePreferencesChanged
       
   175  */
       
   176 void InfoWidgetEngine::handlePreferencesChanged(
       
   177         InfoWidgetPreferences::Options options)
       
   178 {
       
   179     DPRINT; 
       
   180     if (options.testFlag(InfoWidgetPreferences::DisplayMcn)){
       
   181             m_networkHandler->enableMcn(); 
       
   182         } else {
       
   183             m_networkHandler->disableMcn();
       
   184         }
       
   185 
       
   186     if (options.testFlag(InfoWidgetPreferences::DisplaySatText)){
       
   187             m_satHandler->connect(true);
       
   188         } else {
       
   189             m_satHandler->connect(false);
       
   190         }
       
   191 }
       
   192 
       
   193 /*!
       
   194    InfoWidgetEngine::suspend
       
   195    
       
   196    Called when widget is deactivated 
       
   197    and widget should suspend all 
       
   198    possible activities 
       
   199  */
       
   200 void InfoWidgetEngine::suspend() 
       
   201 {
       
   202     DPRINT;
       
   203     m_networkHandler->suspend(); 
       
   204 }
       
   205 
       
   206 /*!
       
   207    InfoWidgetEngine::preferenceChanged
       
   208    
       
   209    Called when widget is activated 
       
   210    and widget can resume activities
       
   211  */
       
   212 void InfoWidgetEngine::resume()
       
   213 {
       
   214     DPRINT;
       
   215     m_networkHandler->resume(); 
       
   216 }
       
   217 
       
   218 
       
   219 // End of File. 
       
   220