phoneengine/servicehandling/src/cpeservicehandling.cpp
changeset 22 6bb1b21d2484
parent 21 92ab7f8d0eab
child 51 f39ed5e045e0
equal deleted inserted replaced
21:92ab7f8d0eab 22:6bb1b21d2484
    18 
    18 
    19 #include <mpephonemodelinternal.h>
    19 #include <mpephonemodelinternal.h>
    20 #include <mpedatastore.h>
    20 #include <mpedatastore.h>
    21 #include <pevirtualengine.h>
    21 #include <pevirtualengine.h>
    22 #include <e32debug.h>
    22 #include <e32debug.h>
    23 #include <talogger.h>
       
    24 
    23 
       
    24 #include "talogger.h"
    25 #include "cpeservicehandling.h"
    25 #include "cpeservicehandling.h"
    26 
    26 
    27 // ======== MEMBER FUNCTIONS ========
    27 // ======== MEMBER FUNCTIONS ========
    28 
    28 
    29 // ---------------------------------------------------------------------------
    29 // ---------------------------------------------------------------------------
    73 // ---------------------------------------------------------------------------
    73 // ---------------------------------------------------------------------------
    74 //
    74 //
    75 EXPORT_C CPEServiceHandling::~CPEServiceHandling()
    75 EXPORT_C CPEServiceHandling::~CPEServiceHandling()
    76     {
    76     {
    77     TEFLOGSTRING( KTAOBJECT, "PE CPEServiceHandling::~CPEServiceHandling" );
    77     TEFLOGSTRING( KTAOBJECT, "PE CPEServiceHandling::~CPEServiceHandling" );
    78     // <-- QT PHONE START -->
       
    79     // delete iCchClient;
       
    80     // <-- QT PHONE END -->
       
    81     }
    78     }
    82 
    79 
    83 // <-- QT PHONE START -->
       
    84 // ---------------------------------------------------------------------------
    80 // ---------------------------------------------------------------------------
    85 // CPEServiceHandling::EnableService
    81 // CPEServiceHandling::EnableService
    86 // ---------------------------------------------------------------------------
    82 // ---------------------------------------------------------------------------
    87 //
    83 //
    88 void CPEServiceHandling::EnableServiceL( TInt /*aServiceId*/ )
    84 void CPEServiceHandling::EnableServiceL( TInt /*aServiceId*/ )
    89     {
    85     {
    90     TEFLOGSTRING( KTAREQIN, "PE CPEServiceHandling::EnableServiceL" );
    86     TEFLOGSTRING( KTAREQIN, "PE CPEServiceHandling::EnableServiceL" );
    91         
       
    92     /*if ( !iCchClient )
       
    93         {
       
    94         iCchClient = CCch::NewL();
       
    95         }
       
    96 
       
    97     CCchService* service = iCchClient->GetService( aServiceId );
       
    98     
       
    99     TInt error( KErrNotFound );
       
   100     if( service )
       
   101         {
       
   102         iCurrentServiceId = aServiceId;
       
   103         
       
   104         TCchServiceStatus serviceStatus;
       
   105         error = service->GetStatus( ECCHVoIPSub, serviceStatus );
       
   106         TCCHSubserviceState state = serviceStatus.State();
       
   107     
       
   108         if( error == KErrNone )
       
   109             {
       
   110             if ( serviceStatus.Error() == KErrNone )
       
   111                 {
       
   112                 error = EnableServiceIfNeeded( state, *service );
       
   113                 }
       
   114             else
       
   115                 {
       
   116                 TEFLOGSTRING2( KTAERROR,
       
   117                         "PE CPEServiceHandling::EnableServiceL, error: %d"
       
   118                         , serviceStatus.Error() );
       
   119                 SendErrorMessage( serviceStatus.Error());
       
   120                 }
       
   121             }
       
   122         }
       
   123     
       
   124     if ( error != KErrNone )
       
   125         {
       
   126         if ( error == KErrNotFound )
       
   127              {
       
   128              iModel.SendMessage( MEngineMonitor::EPEMessageNoService );
       
   129              }
       
   130          else
       
   131              {
       
   132              TEFLOGSTRING2( KTAERROR,
       
   133                       "PE CPEServiceHandling::EnableServiceL, Error: %d"
       
   134                       , error );
       
   135              SendErrorMessage( error );
       
   136              }
       
   137         }
       
   138     
       
   139     TEFLOGSTRING2( KTAINT, 
       
   140             "PE CPEServiceHandling::EnableServiceL, error: %d", error );*/
       
   141 
       
   142     User::LeaveIfError( 0 );
    87     User::LeaveIfError( 0 );
   143     iModel.SendMessage( MEngineMonitor::EPEMessageServiceEnabled );
    88     iModel.SendMessage( MEngineMonitor::EPEMessageServiceEnabled );
   144     
       
   145     // <-- QT PHONE END -->
       
   146     }
    89     }
   147 
       
   148 // <-- QT PHONE START -->
       
   149 // ---------------------------------------------------------------------------
       
   150 // CPEServiceHandling::EnableServiceIfNeeded
       
   151 // ---------------------------------------------------------------------------
       
   152 //
       
   153 /*TInt CPEServiceHandling::EnableServiceIfNeeded( 
       
   154         const TCCHSubserviceState& aState, 
       
   155         CCchService& aService )
       
   156     {
       
   157     TEFLOGSTRING( KTAINT, "PE CPEServiceHandling::EnableServiceIfNeeded" );
       
   158     TInt error = KErrNone;
       
   159     
       
   160     TEFLOGSTRING2( KTAINT, 
       
   161             "PE CPEServiceHandling::EnableServiceIfNeeded, aState: %d", aState );
       
   162     switch ( aState )
       
   163         {
       
   164         case ECCHEnabled:
       
   165             {
       
   166             iModel.SendMessage( MEngineMonitor::EPEMessageServiceEnabled );
       
   167             }
       
   168             break;
       
   169         case ECCHUninitialized:
       
   170         case ECCHDisabled:
       
   171         case ECCHConnecting:
       
   172             {
       
   173             // Temporary solution, it will be fixed as soon as possible. 
       
   174             // Message have to send before enable is called. Reason is so that progress bar 
       
   175             //(global note) doesn't hide Networks's "Connection Needed" global note.
       
   176             iModel.SendMessage( MEngineMonitor::EPEMessageServiceEnabling );
       
   177             aService.AddObserver( *this );
       
   178             error = aService.Enable( ECCHUnknown );  
       
   179             }
       
   180             break;
       
   181         case ECCHDisconnecting:
       
   182             {
       
   183             error = KErrNotFound;
       
   184             }
       
   185             break;
       
   186         default:
       
   187             break;
       
   188         }
       
   189     TEFLOGSTRING2( KTAINT, 
       
   190             "PE CPEServiceHandling::EnableServiceIfNeeded, error: %d", error );
       
   191     return error;
       
   192     }
       
   193     
       
   194 // ---------------------------------------------------------------------------
       
   195 // CPEServiceHandling::ServiceStatusChanged
       
   196 // ---------------------------------------------------------------------------
       
   197 //
       
   198 void CPEServiceHandling::ServiceStatusChanged(
       
   199     TInt aServiceId,
       
   200     const TCCHSubserviceType aType,
       
   201     const TCchServiceStatus& aServiceStatus )
       
   202     {
       
   203     TEFLOGSTRING( KTAINT, "PE CPEServiceHandling::ServiceStatusChanged <" );
       
   204     
       
   205     if( aServiceId == iCurrentServiceId && aType == ECCHVoIPSub )
       
   206         {
       
   207         TEFLOGSTRING3( KTAINT,
       
   208                 "PE CPEServiceHandling::ServiceStatusChanged, state: %d, error: %d"
       
   209                 , aServiceStatus.State()
       
   210                 , aServiceStatus.Error() );
       
   211 
       
   212         CCchService* service = iCchClient->GetService( aServiceId );
       
   213         if( service )
       
   214             {
       
   215             if( aServiceStatus.Error() != KErrNone )
       
   216                 {
       
   217                 TEFLOGSTRING( KTAERROR, 
       
   218                         "PE CPEServiceHandling::ServiceStatusChanged, error" );
       
   219                 SendErrorMessage( aServiceStatus.Error());
       
   220                 CancelServiceEnabling();
       
   221                 }
       
   222             else 
       
   223                 {
       
   224                 if( aServiceStatus.State() == ECCHEnabled )
       
   225                     {
       
   226                     TEFLOGSTRING( KTAINT, 
       
   227                              "PE CPEServiceHandling::ServiceStatusChanged, enabled" );
       
   228                     iModel.SendMessage( MEngineMonitor::EPEMessageServiceEnabled );
       
   229                     }
       
   230 
       
   231 
       
   232                 // Notify UI, that service is disabled.
       
   233                 else if( aServiceStatus.State() == ECCHDisabled ) 
       
   234                      {
       
   235                      TEFLOGSTRING( KTAERROR, 
       
   236                               "PE CPEServiceHandling::ServiceStatusChanged, disabled" );
       
   237                      iModel.SendMessage( MEngineMonitor::EPEMessageServiceDisabled );
       
   238                      }
       
   239                 }
       
   240             
       
   241             // don't remove observer, if state are connecting or disconnecting
       
   242             if ( aServiceStatus.State() != ECCHConnecting && 
       
   243                  aServiceStatus.State() != ECCHDisconnecting )
       
   244                 {
       
   245                 service->RemoveObserver( *this );
       
   246                 }
       
   247             }//if( service )
       
   248         else
       
   249             {
       
   250             TEFLOGSTRING( KTAERROR, 
       
   251                     "PE CPEServiceHandling::ServiceStatusChanged, no service" );
       
   252             }
       
   253         }
       
   254     TEFLOGSTRING( KTAINT, "PE CPEServiceHandling::ServiceStatusChanged >" );
       
   255     }*/
       
   256 
       
   257 
       
   258     
    90     
   259 // ---------------------------------------------------------------------------
    91 // ---------------------------------------------------------------------------
   260 // CPEServiceHandling::CancelServiceEnabling
    92 // CPEServiceHandling::CancelServiceEnabling
   261 // ---------------------------------------------------------------------------
    93 // ---------------------------------------------------------------------------
   262 //
    94 //
   263 void CPEServiceHandling::CancelServiceEnabling() const
    95 void CPEServiceHandling::CancelServiceEnabling() const
   264     {
    96     {
   265     TEFLOGSTRING( KTAREQIN, "PE CPEServiceHandling::CancelServiceEnabling" );
    97     TEFLOGSTRING( KTAREQIN, "PE CPEServiceHandling::CancelServiceEnabling" );
   266     
       
   267     /*if ( iCchClient )
       
   268         {
       
   269         CCchService* service = iCchClient->GetService( iCurrentServiceId );
       
   270         
       
   271         if ( service )
       
   272             {
       
   273             TCchServiceStatus serviceStatus;
       
   274             TInt error = service->GetStatus( ECCHVoIPSub, serviceStatus );
       
   275             TCCHSubserviceState state = serviceStatus.State();
       
   276             
       
   277             // Disable only, if service is connecting state
       
   278             if ( error == KErrNone && state == ECCHConnecting )
       
   279                 {
       
   280                 TEFLOGSTRING( KTAREQOUT,
       
   281                   "PE CPEServiceHandling::CancelServiceEnabling, CCchService->Disable" );
       
   282                 service->Disable( ECCHUnknown );
       
   283                 }
       
   284             }
       
   285         }*/
       
   286     }
    98     }
   287         
    99         
   288 // -----------------------------------------------------------------------------
       
   289 // CPEServiceHandling::SendErrorMessage
       
   290 // -----------------------------------------------------------------------------
       
   291 //
       
   292 /*void CPEServiceHandling::SendErrorMessage(
       
   293         TInt aErrorCode )
       
   294     {
       
   295     TEFLOGSTRING2( KTAINT, 
       
   296         "PE CPEServiceHandling::SendErrorMessage, aErrorCode: %d", 
       
   297         aErrorCode );
       
   298 
       
   299     iModel.DataStore()->SetErrorCode( aErrorCode );
       
   300     iModel.SendMessage( MEngineMonitor::EPEMessageServiceHandlingError );
       
   301     }*/
       
   302 
       
   303 // -----------------------------------------------------------------------------
   100 // -----------------------------------------------------------------------------
   304 // CPEServiceHandling::DisableService
   101 // CPEServiceHandling::DisableService
   305 // -----------------------------------------------------------------------------
   102 // -----------------------------------------------------------------------------
   306 //
   103 //
   307 void CPEServiceHandling::DisableService() const
   104 void CPEServiceHandling::DisableService() const
   308     {
   105     {
   309     TEFLOGSTRING( KTAREQIN, "PE CPEServiceHandling::DisableService" );
   106     TEFLOGSTRING( KTAREQIN, "PE CPEServiceHandling::DisableService" );
   310 
       
   311     /*CCchService* service = iCchClient->GetService( iCurrentServiceId );
       
   312     
       
   313     if ( service )
       
   314         {
       
   315         TEFLOGSTRING( KTAREQOUT,
       
   316           "PE CPEServiceHandling::DisableService, CCchService->Disable" );
       
   317         service->Disable( ECCHUnknown );
       
   318         }*/
       
   319     } 
   107     } 
   320 
   108 
   321 // <-- QT PHONE END -->
       
   322 
       
   323 //  End of File
   109 //  End of File