phoneplugins/infowidgetplugin/infowidgetprovider/infowidget/src/infowidgetsathandlerprivate.cpp
branchGCC_SURGE
changeset 51 f39ed5e045e0
parent 40 bab96b7ed1a4
parent 46 bc5a64e5bc3c
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 <FBS.H>
       
    19 
       
    20 #include "InfoWidgetSatHandlerPrivate.h"
       
    21 #include "InfoWidgetSatHandler.h"
       
    22 #include "infowidgetlogging.h"
       
    23 
       
    24 /*!
       
    25    InfoWidgetSatHandlerPrivate::InfoWidgetSatHandlerPrivate   
       
    26  */
       
    27 InfoWidgetSatHandlerPrivate::InfoWidgetSatHandlerPrivate(
       
    28         InfoWidgetSatHandler *iwSatHandler, RSatService& satService)
       
    29     : CActive(CActive::EPriorityStandard), 
       
    30 	  q_ptr(iwSatHandler),
       
    31       m_satService(satService)
       
    32 {
       
    33     DPRINT << ": IN";
       
    34     CActiveScheduler::Add(this);
       
    35     DPRINT << ": OUT";
       
    36 }
       
    37 /*!
       
    38    InfoWidgetSatHandlerPrivate::~InfoWidgetSatHandlerPrivate           
       
    39 */
       
    40 InfoWidgetSatHandlerPrivate::~InfoWidgetSatHandlerPrivate()
       
    41 {
       
    42     DPRINT << ": IN";
       
    43     Cancel();
       
    44     DPRINT << ": OUT";
       
    45 }
       
    46 /*!
       
    47    InfoWidgetSatHandlerPrivate::connect
       
    48  */
       
    49 int InfoWidgetSatHandlerPrivate::connect()
       
    50 {
       
    51     TInt result( KErrGeneral  );
       
    52     TRAP(result, m_satSession.ConnectL());
       
    53     if (0 != result) {
       
    54         DPRINT << ": Exception occured while connecting SatSession:" << result;
       
    55     }
       
    56     else{
       
    57         TRAP(result, m_satService.OpenL(m_satSession));
       
    58         if (0 != result) {
       
    59             DPRINT << ": Exception occured while opening SatService:" << result;
       
    60         }
       
    61     }
       
    62     return !result;
       
    63 }
       
    64 /*! 
       
    65    InfoWidgetSatHandlerPrivate::startObserving
       
    66     
       
    67    To get initial content if any and start listening    
       
    68  */
       
    69 void InfoWidgetSatHandlerPrivate::startObserving()
       
    70 {
       
    71     //not observing yet but
       
    72     getIdleModeData();
       
    73     // in case there were content, there is need to send response to SAT
       
    74     if(!m_idleTxt.isEmpty()){
       
    75         q_ptr->handleIdleModeTxtMessage( m_idleResult );
       
    76     }
       
    77     // Start observing for changes
       
    78     activate();
       
    79 }
       
    80 /*!
       
    81    InfoWidgetSatHandlerPrivate::disconnect   
       
    82  */
       
    83 int InfoWidgetSatHandlerPrivate::disconnect()
       
    84 {
       
    85     DPRINT << ": IN";
       
    86     m_idleTxt = "";
       
    87     Cancel();
       
    88     m_satService.NotifySetupIdleModeTextChangeCancel(); 
       
    89     m_satService.Close();
       
    90     m_satSession.Close();
       
    91     
       
    92     DPRINT << ": OUT";
       
    93     return 0;//TODO:Fixme
       
    94 }
       
    95 /*!
       
    96    InfoWidgetSatHandlerPrivate::getIdleModeData   
       
    97  */
       
    98 void InfoWidgetSatHandlerPrivate::getIdleModeData()
       
    99 {
       
   100     HBufC* string( NULL );
       
   101     TUint8 recordId( NULL );
       
   102     RSatService::TSatIconQualifier iconQualifier( 
       
   103         RSatService::ESatIconNoIcon );
       
   104     
       
   105     // Get setup idle mode text, icon qualifier and record id.
       
   106     TInt result( KErrNotFound  );
       
   107     TRAP(result, m_satService.GetSetupIdleModeTextL( string, iconQualifier, recordId )); 
       
   108     if (0 != result) {
       
   109         DPRINT << ": Exception occured while GetSetupIdleModeTextL :" << result;
       
   110         m_idleResult = RSatService::ESATIdleMeUnableToProcessCmd;
       
   111     }
       
   112     else{
       
   113         DPRINT << "string->Length() : " << string->Length();
       
   114         if(RSatService::ESatIconSelfExplanatory != iconQualifier){ 
       
   115             m_idleTxt = QString((QChar*)string->Des().Ptr(), string->Length());
       
   116         }else{
       
   117             m_idleTxt = "";
       
   118         }
       
   119         //determine result
       
   120         if(RSatService::ESatIconNoIcon != iconQualifier
       
   121                 && !m_idleTxt.isEmpty()){
       
   122             //icon requested but we don't have icon support
       
   123             m_idleResult = RSatService::ESATIdleSuccessRequestedIconNotDisplayed;
       
   124         }else if(RSatService::ESatIconNoIcon == iconQualifier
       
   125                 && !m_idleTxt.isEmpty()){
       
   126             m_idleResult = RSatService::ESATIdleSuccess;
       
   127         }else{ //got empty string, could be permanen problem as well?
       
   128             //m_idleResult = RSatService::ESATIdleCmdBeyondMeCapabilities
       
   129             m_idleResult = RSatService::ESATIdleMeUnableToProcessCmd;
       
   130         }
       
   131     }
       
   132     delete string;
       
   133     q_ptr->setSatDisplayText(m_idleTxt);//empty in case of selexplanatory icon
       
   134 }
       
   135 
       
   136 /*!
       
   137    InfoWidgetSatHandlerPrivate::RunL   
       
   138  */
       
   139 void InfoWidgetSatHandlerPrivate::RunL()
       
   140 { 
       
   141     DPRINT << ": IN";
       
   142     if ( KErrNone == iStatus.Int() )
       
   143         {   
       
   144         getIdleModeData();
       
   145         q_ptr->handleIdleModeTxtMessage( m_idleResult );
       
   146     } else {
       
   147         q_ptr->handleSatError(1,iStatus.Int());
       
   148     }
       
   149     if ( !IsActive() )
       
   150         {
       
   151         activate();
       
   152         }       
       
   153     DPRINT << ": OUT";
       
   154 }
       
   155 /*!
       
   156    InfoWidgetSatHandlerPrivate::DoCancel   
       
   157  */
       
   158 void InfoWidgetSatHandlerPrivate::DoCancel()
       
   159 {
       
   160     DPRINT << ": IN";
       
   161     m_satService.NotifySetupIdleModeTextChangeCancel(); 
       
   162     DPRINT << ": OUT";
       
   163 }
       
   164 /*!
       
   165    InfoWidgetSatHandlerPrivate::activate   
       
   166  */
       
   167 void InfoWidgetSatHandlerPrivate::activate()
       
   168 {
       
   169     DPRINT << ": IN";
       
   170     Cancel();   
       
   171     TInt error = m_satService.NotifySetupIdleModeTextChange( iStatus );
       
   172     
       
   173     if ( KErrNone == error )
       
   174         {
       
   175         SetActive();
       
   176         }
       
   177     DPRINT << ": OUT";
       
   178 }
       
   179 
       
   180 
       
   181     
       
   182