mmsharing/mmshavailability/src/musavanetworkmodestatus.cpp
changeset 15 ccd8e69b5392
parent 2 b31261fd4e04
child 20 e8be2c2e049d
child 22 496ad160a278
equal deleted inserted replaced
2:b31261fd4e04 15:ccd8e69b5392
     1 /*
       
     2 * Copyright (c) 2005-2007 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:   Provide interface for the client requestin availability class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "musavanetworkmodestatus.h"
       
    21 #include "musavatelephonystatusobserver.h"
       
    22 #include "musavaavailability.h"
       
    23 #include "musunittesting.h"
       
    24 #include "mussettingskeys.h"
       
    25 #include "mussettings.h"
       
    26 #include "muslogger.h"
       
    27 
       
    28 #include <e32base.h>
       
    29 #include <mmtsy_names.h>
       
    30 
       
    31 // -------------------------------------------------------------------------
       
    32 //  Two-phased constructor.
       
    33 // -------------------------------------------------------------------------
       
    34 //
       
    35 CMusAvaNetworkModeStatus* CMusAvaNetworkModeStatus::NewL()
       
    36     {
       
    37     CMusAvaNetworkModeStatus* self = 
       
    38     new( ELeave ) CMusAvaNetworkModeStatus();
       
    39     CleanupStack::PushL( self );
       
    40     self->ConstructL();
       
    41     CleanupStack::Pop( self );
       
    42 
       
    43     return self;
       
    44     }
       
    45 
       
    46 
       
    47 // -------------------------------------------------------------------------
       
    48 //  Destructor.
       
    49 // -------------------------------------------------------------------------
       
    50 //
       
    51 CMusAvaNetworkModeStatus::~CMusAvaNetworkModeStatus()
       
    52     {
       
    53     Cancel();
       
    54     iObserver.Reset();
       
    55     iObserver.Close();
       
    56     iPhone.Close();
       
    57     iTelServer.UnloadPhoneModule( KMmTsyModuleName );
       
    58     iTelServer.Close();
       
    59     }
       
    60 
       
    61     
       
    62 // -------------------------------------------------------------------------
       
    63 // Test Current Phone Network Mode
       
    64 // -------------------------------------------------------------------------
       
    65 //
       
    66 RMobilePhone::TMobilePhoneNetworkMode CMusAvaNetworkModeStatus::PhoneNetworkMode()
       
    67     {
       
    68     MUS_LOG( "mus: [MUSAVA]  -> CMusAvaNetworkModeStatus::PhoneNetworkMode()" )
       
    69     RMobilePhone::TMobilePhoneNetworkMode networkMode;    
       
    70     TInt retval = iPhone.GetCurrentMode( networkMode );    
       
    71     MUS_LOG1( "mus: [MUSAVA]  <- CMusAvaNetworkModeStatus::PhoneNetworkMode()=%d",networkMode )
       
    72     return networkMode;
       
    73     }
       
    74     
       
    75 
       
    76 // -------------------------------------------------------------------------
       
    77 //  Reads the telephony status.
       
    78 // -------------------------------------------------------------------------
       
    79 //
       
    80 void CMusAvaNetworkModeStatus::TelephonyStatus()
       
    81     {
       
    82     MUS_LOG( "mus: [MUSAVA]  -> CMusAvaNetworkModeStatus::TelephonyStatus()" )
       
    83     MUS_LOG( "mus: [MUSAVA] NotifyModeChange" )
       
    84     iPhone.NotifyModeChange( iStatus, iNetworkMode );
       
    85     SetActive();
       
    86     MUS_LOG( "mus: [MUSAVA]  -> CMusAvaNetworkModeStatus::TelephonyStatus()" )
       
    87     }
       
    88 
       
    89 // -------------------------------------------------------------------------
       
    90 // 
       
    91 // -------------------------------------------------------------------------
       
    92 //    
       
    93 void CMusAvaNetworkModeStatus::PhoneNetworkModeStatus( 
       
    94                     RMobilePhone::TMobilePhoneNetworkMode aStatus )
       
    95     {
       
    96     MUS_LOG( "mus: [MUSAVA]  -> CMusAvaNetworkModeStatus::\
       
    97     PhoneNetworkModeStatus()" )
       
    98     MUS_LOG1( "TMobilePhoneNetworkMode = ", aStatus )
       
    99 
       
   100     for( TInt i=0; i<iObserver.Count(); i++ )
       
   101         {
       
   102         iObserver[i]->PhoneNetworkModeStatus( aStatus );
       
   103         }
       
   104     MUS_LOG( "mus: [MUSAVA]  <- CMusAvaNetworkModeStatus::\
       
   105     PhoneNetworkModeStatus()" )
       
   106     }
       
   107 
       
   108 // -------------------------------------------------------------------------
       
   109 //  Reads the call status property value and subscribes again.
       
   110 // -------------------------------------------------------------------------
       
   111 //
       
   112 void CMusAvaNetworkModeStatus::RunL()
       
   113     {
       
   114     MUS_LOG( "mus: [MUSAVA]  -> CMusAvaNetworkModeStatus::RunL()" )
       
   115     if( iStatus == KErrNone )
       
   116         {
       
   117         PhoneNetworkModeStatus( iNetworkMode );
       
   118         }
       
   119     //Subscribes registration status again.  
       
   120     MUS_LOG( "mus: [MUSAVA]  Subscribes registration status again" )
       
   121     TelephonyStatus();
       
   122     MUS_LOG( "mus: [MUSAVA]  -> CMusAvaNetworkModeStatus::RunL()" )
       
   123     }
       
   124     
       
   125     
       
   126 // -------------------------------------------------------------------------
       
   127 //  Cancel pendig request
       
   128 // -------------------------------------------------------------------------
       
   129 //
       
   130 void CMusAvaNetworkModeStatus::DoCancel()    
       
   131     {
       
   132     iPhone.CancelAsyncRequest( EMobilePhoneNotifyModeChange );
       
   133     }
       
   134     
       
   135 
       
   136 // -------------------------------------------------------------------------
       
   137 //  Constructor function.
       
   138 // -------------------------------------------------------------------------
       
   139 //
       
   140 CMusAvaNetworkModeStatus::CMusAvaNetworkModeStatus( )
       
   141     {
       
   142    
       
   143     }
       
   144 
       
   145 // -------------------------------------------------------------------------
       
   146 //  Second phase constructor.
       
   147 // -------------------------------------------------------------------------
       
   148 //
       
   149 void CMusAvaNetworkModeStatus::ConstructL()
       
   150     {
       
   151     RTelServer::TPhoneInfo phoneInfo;
       
   152    	User::LeaveIfError( iTelServer.Connect() ); 
       
   153     User::LeaveIfError( iTelServer.LoadPhoneModule( KMmTsyModuleName ) );
       
   154 	User::LeaveIfError( iTelServer.GetPhoneInfo( 0, phoneInfo ) );
       
   155 	User::LeaveIfError( iPhone.Open( iTelServer, phoneInfo.iName ) );
       
   156     User::LeaveIfError( iPhone.Initialise() );
       
   157     TelephonyStatus();
       
   158     }