locationtriggering/ltcellidmovementdetector/src/lbtcellidmvmtdetgetcelldata.cpp
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 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:  Definition of CLbtCellIdMvmtDetGetCellData class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "lbtcellidmvmtdetgetcelldata.h"
       
    21 #include "lbtlogger.h"
       
    22 
       
    23 
       
    24 // Class methods
       
    25 
       
    26 //------------------------------------------------------------
       
    27 // CLbtCellIdMvmtDetGetCellData::NewL
       
    28 // Symbian Two - phase constructor
       
    29 //------------------------------------------------------------
       
    30 //
       
    31 CLbtCellIdMvmtDetGetCellData* CLbtCellIdMvmtDetGetCellData::NewL(MLbtCellIdMvmtDetCellOberserver& aObserver,
       
    32 												 RMmCustomAPI& aMnCustomApi)
       
    33 	{
       
    34 	FUNC_ENTER("CLbtCellIdMvmtDetGetCellData::NewL");
       
    35 	CLbtCellIdMvmtDetGetCellData* self=new ( ELeave )
       
    36 									  CLbtCellIdMvmtDetGetCellData( aObserver, aMnCustomApi );
       
    37 	CleanupStack::PushL( self );
       
    38 	self->ConstructL();
       
    39 	CleanupStack::Pop( self );
       
    40 	return self;
       
    41 	}
       
    42 
       
    43 	
       
    44 //------------------------------------------------------------
       
    45 // CLbtCellIdMvmtDetGetCellData::~CLbtCellIdMvmtDetGetCellData
       
    46 // Destructor
       
    47 //------------------------------------------------------------
       
    48 //	
       
    49 CLbtCellIdMvmtDetGetCellData::~CLbtCellIdMvmtDetGetCellData()
       
    50 	{
       
    51 	FUNC_ENTER("CLbtCellIdMvmtDetGetCellData::~CLbtCellIdMvmtDetGetCellData");
       
    52 	Cancel();
       
    53 	iTimer.Close();
       
    54 	}
       
    55 
       
    56 
       
    57 //------------------------------------------------------------
       
    58 // CLbtCellIdMvmtDetGetCellData::Start
       
    59 //------------------------------------------------------------
       
    60 //	
       
    61 void CLbtCellIdMvmtDetGetCellData::Start()
       
    62     {
       
    63     FUNC_ENTER("CLbtCellIdMvmtDetGetCellData::Start");
       
    64     iStopNotification = EFalse;
       
    65     GetCellInfo();
       
    66     }
       
    67 
       
    68 	
       
    69 //------------------------------------------------------------
       
    70 // CLbtCellIdMvmtDetGetCellData::GetCellInfo
       
    71 //------------------------------------------------------------
       
    72 //	
       
    73 void CLbtCellIdMvmtDetGetCellData::GetCellInfo( )
       
    74 	{
       
    75 	FUNC_ENTER("CLbtCellIdMvmtDetGetCellData::GetCellInfo");
       
    76     if( !IsActive() )
       
    77         {
       
    78         iState = EProcessCellInfo;
       
    79         iCApi.GetCellInfo( iStatus, iCellPckg );
       
    80         iReqID = ECustomGetCellInfoIPC;
       
    81         SetActive();
       
    82         }
       
    83 	}
       
    84 	
       
    85 
       
    86 //------------------------------------------------------------
       
    87 // CLbtCellIdMvmtDetGetCellData::Stop
       
    88 //------------------------------------------------------------
       
    89 //
       
    90 void CLbtCellIdMvmtDetGetCellData::Stop()
       
    91     {
       
    92     FUNC_ENTER("CLbtCellIdMvmtDetGetCellData::Stop");
       
    93     iStopNotification = ETrue;	
       
    94     iTimer.Cancel();
       
    95     iCApi.CancelAsyncRequest( iReqID );
       
    96     }
       
    97     	
       
    98 	
       
    99 //------------------------------------------------------------
       
   100 // CLbtCellIdMvmtDetGetCellData::RunL
       
   101 //------------------------------------------------------------
       
   102 //	
       
   103 void CLbtCellIdMvmtDetGetCellData::RunL()
       
   104 	{
       
   105 	FUNC_ENTER("CLbtCellIdMvmtDetGetCellData::RunL");
       
   106 	TInt err = KErrNone;
       
   107 	if( iStopNotification )
       
   108 	    {
       
   109 	    return;
       
   110 	    }
       
   111     switch( iState )
       
   112         {
       
   113         case ETimerOperation:
       
   114             GetCellInfo();
       
   115             break;
       
   116             
       
   117         case EProcessCellInfo:
       
   118             err = iStatus.Int();
       
   119             iObserver.HandleCellDataL( iCellInfo, err );
       
   120             iState = ETimerOperation;
       
   121             iTimer.After( iStatus, 1000000 );
       
   122             SetActive();
       
   123             break;
       
   124             
       
   125         default:
       
   126             break;
       
   127         }
       
   128 	}
       
   129 
       
   130 
       
   131 //------------------------------------------------------------
       
   132 // CLbtCellIdMvmtDetGetCellData::DoCancel
       
   133 //------------------------------------------------------------
       
   134 //	
       
   135 void CLbtCellIdMvmtDetGetCellData::DoCancel()
       
   136 	{
       
   137 	FUNC_ENTER("CLbtCellIdMvmtDetGetCellData::DoCancel");
       
   138 	iTimer.Cancel();
       
   139     iCApi.CancelAsyncRequest( iReqID );
       
   140 	}	
       
   141 
       
   142 
       
   143 //------------------------------------------------------------
       
   144 // CLbtCellIdMvmtDetGetCellData::CLbtCellIdMvmtDetGetCellData
       
   145 // C++ Default constructor
       
   146 //------------------------------------------------------------
       
   147 //	
       
   148 CLbtCellIdMvmtDetGetCellData::CLbtCellIdMvmtDetGetCellData( 
       
   149                     MLbtCellIdMvmtDetCellOberserver& aObserver,
       
   150 				    RMmCustomAPI& aMnCustomApi ) : CActive( EPriorityNormal),
       
   151 					iObserver(aObserver),iCApi( aMnCustomApi ),iCellInfo(),
       
   152                     iCellPckg( iCellInfo )
       
   153 	{
       
   154 	CActiveScheduler::Add( this );										
       
   155 	}
       
   156 	    
       
   157 	
       
   158 //------------------------------------------------------------
       
   159 // CLbtCellIdMvmtDetGetCellData::ConstructL
       
   160 //------------------------------------------------------------
       
   161 //	
       
   162 void CLbtCellIdMvmtDetGetCellData::ConstructL()
       
   163 	{
       
   164 	FUNC_ENTER("CLbtCellIdMvmtDetGetCellData::ConstructL");
       
   165 	iStopNotification = EFalse;
       
   166 	iTimer.CreateLocal();
       
   167 	}