callcontinuity/vcchotrigger/src/vccgsmsignallevelhandler.cpp
changeset 0 a4daefaec16c
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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 
       
    19 
       
    20 #include <mmtsy_names.h>
       
    21 
       
    22 #include "vccgsmsignallevelhandler.h"
       
    23 #include "rubydebug.h"
       
    24 
       
    25 static const TInt32 KStrengthMin = 110;
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 // ---------------------------------------------------------------------------
       
    29 // C++ constructor
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CVccGsmSignalLevelHandler::CVccGsmSignalLevelHandler( 
       
    33                                              MVccSignalLevelObserver& aObserver, 
       
    34                                              const TSignalLevelParams& aParams )
       
    35     : CVccSignalLevelHandler( aObserver, aParams )
       
    36     {
       
    37     }
       
    38     
       
    39 // ---------------------------------------------------------------------------
       
    40 // Symbian constructor.
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 void CVccGsmSignalLevelHandler::ConstructL()
       
    44     {
       
    45     RUBY_DEBUG_BLOCKL( "CVccGsmSignalLevelHandler::ConstructL" );
       
    46 
       
    47     CVccSignalLevelHandler::ConstructL();
       
    48     User::LeaveIfError( iEtelServer.Connect() );
       
    49     User::LeaveIfError( iEtelServer.LoadPhoneModule( KMmTsyModuleName ) );
       
    50     User::LeaveIfError( iPhone.Open( iEtelServer, KMmTsyPhoneName ) );
       
    51     iGsmNotifications = CVccGsmNotifications::NewL( iPhone );
       
    52     }   
       
    53     
       
    54 // ---------------------------------------------------------------------------
       
    55 // Symbian constructor.
       
    56 // ---------------------------------------------------------------------------
       
    57 // 
       
    58 CVccGsmSignalLevelHandler * CVccGsmSignalLevelHandler::NewL( 
       
    59                                             MVccSignalLevelObserver& aObserver, 
       
    60                                             const TSignalLevelParams& aParams )
       
    61     {
       
    62     CVccGsmSignalLevelHandler * self = 
       
    63                          CVccGsmSignalLevelHandler::NewLC( aObserver, aParams );
       
    64     CleanupStack::Pop(self);
       
    65     return self;
       
    66     }    
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // Symbian constructor.
       
    70 // ---------------------------------------------------------------------------
       
    71 // 
       
    72 CVccGsmSignalLevelHandler * CVccGsmSignalLevelHandler::NewLC( 
       
    73                                             MVccSignalLevelObserver& aObserver, 
       
    74                                             const TSignalLevelParams& aParams )
       
    75     {
       
    76     CVccGsmSignalLevelHandler * self = 
       
    77                     new(ELeave) CVccGsmSignalLevelHandler( aObserver, aParams );
       
    78     CleanupStack::PushL(self);
       
    79     self->ConstructL();
       
    80     return self;
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // C++ destructor.
       
    85 // ---------------------------------------------------------------------------
       
    86 //    
       
    87 CVccGsmSignalLevelHandler::~CVccGsmSignalLevelHandler()
       
    88     {
       
    89     Cancel(); // Cancel any request, if outstanding
       
    90     delete iGsmNotifications;
       
    91     iPhone.Close();
       
    92     iEtelServer.Close();
       
    93     }
       
    94     
       
    95 // ---------------------------------------------------------------------------
       
    96 // Enables signal level change notifications.
       
    97 // ---------------------------------------------------------------------------
       
    98 // 
       
    99 void CVccGsmSignalLevelHandler::EnableNotificationsL()
       
   100     {
       
   101     RUBY_DEBUG_BLOCK( "CVccGsmSignalLevelHandler::EnableNotificationsL" );
       
   102 
       
   103     iGsmNotifications->ActivateNotifications( this,
       
   104                                   iParams.iLowLevel, iParams.iHighLevel );
       
   105     }
       
   106     
       
   107 // ---------------------------------------------------------------------------
       
   108 // Disables signal level change notifications.
       
   109 // ---------------------------------------------------------------------------
       
   110 // 
       
   111 void CVccGsmSignalLevelHandler::DisableNotifications()
       
   112     {
       
   113     iGsmNotifications->CancelNotifications();
       
   114     }
       
   115     
       
   116 // ---------------------------------------------------------------------------
       
   117 // Issues signal strength request to RMobilePhone.
       
   118 // ---------------------------------------------------------------------------
       
   119 // 
       
   120 void CVccGsmSignalLevelHandler::GetStrength()
       
   121     {
       
   122     RUBY_DEBUG_BLOCK( "CVccGsmSignalLevelHandler::GetStrength" );
       
   123 
       
   124     iPhone.GetSignalStrength( iStatus, iStrength, iBar );
       
   125     RUBY_DEBUG3( " -iStatus = %d, iStrength = %d, iBar = %d",
       
   126                             iStatus.Int(), iStrength, iBar );
       
   127     }
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // Cancels signal strength request
       
   131 // ---------------------------------------------------------------------------
       
   132 // 
       
   133 void CVccGsmSignalLevelHandler::CancelGetStrength()
       
   134     {
       
   135     RUBY_DEBUG_BLOCK( "CVccGsmSignalLevelHandler::CancelGetStrength" );
       
   136    
       
   137     // EMobilePhoneNotifyModeChange
       
   138     iPhone.CancelAsyncRequest( EMobilePhoneGetSignalStrength ); 
       
   139     }
       
   140     
       
   141 // ---------------------------------------------------------------------------
       
   142 // Notification that signal strength has changed is received.
       
   143 // ---------------------------------------------------------------------------
       
   144 //
       
   145 void CVccGsmSignalLevelHandler::GsmStrengthChanged( TInt32 aStrength )
       
   146     {
       
   147     RUBY_DEBUG_BLOCK( "CVccGsmSignalLevelHandler::GsmStrengthChanged" );
       
   148     RUBY_DEBUG1( " -aStrength = %d", aStrength );
       
   149 
       
   150     iStrength = aStrength  ? aStrength : KStrengthMin;
       
   151     StrengthChanged();
       
   152     }
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // Notififies observer about signal level change.
       
   156 // ---------------------------------------------------------------------------
       
   157 //
       
   158 void CVccGsmSignalLevelHandler::NotifyChanges(
       
   159     TInt32 aSignalStrength,
       
   160     MVccSignalLevelObserver::TSignalStrengthClass aClass )
       
   161     {
       
   162     RUBY_DEBUG_BLOCK( "CVccGsmSignalLevelHandler::NotifyChanges" );
       
   163     iObserver.GsmSignalChanged( aSignalStrength, aClass );
       
   164     }