lbs/lbstestutils/src/ctlbsagpsmoduleeventlistener.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 #include "ctlbsagpsmoduleeventlistener.h"
       
    18 
       
    19 EXPORT_C CT_AgpsModuleEventListener* CT_AgpsModuleEventListener::NewL(MT_AgpsModuleEventHandler& aHandler)
       
    20 	{
       
    21 	CT_AgpsModuleEventListener* self = new(ELeave) CT_AgpsModuleEventListener(aHandler);
       
    22 	CleanupStack::PushL(self);
       
    23 	self->ConstructL();
       
    24 	CleanupStack::Pop(self);
       
    25 	return self;
       
    26 	}
       
    27 
       
    28 EXPORT_C CT_AgpsModuleEventListener::~CT_AgpsModuleEventListener()
       
    29 	{
       
    30 	Cancel();
       
    31 	iModeChangesProperty.Close();
       
    32 	}
       
    33 
       
    34 CT_AgpsModuleEventListener::CT_AgpsModuleEventListener(MT_AgpsModuleEventHandler& aHandler)
       
    35 	: CActive(EPriorityHigh), iHandler(aHandler)
       
    36 	{
       
    37 	CActiveScheduler::Add(this);
       
    38 	}
       
    39 
       
    40 void CT_AgpsModuleEventListener::ConstructL()
       
    41 	{
       
    42 	User::LeaveIfError(iModeChangesProperty.Attach(KUidSystemCategory, ELbsTestAGpsModuleModeChanges));
       
    43 	iModeChangesProperty.Subscribe(iStatus);
       
    44 	SetActive();
       
    45 	}
       
    46 
       
    47 void CT_AgpsModuleEventListener::RunL()
       
    48 	{
       
    49 	TInt err = iStatus.Int();
       
    50 	iModeChangesProperty.Subscribe(iStatus);
       
    51 	SetActive();
       
    52 	if(KErrNone == err)
       
    53 		{
       
    54 		TLbsGpsOptionsArray options;
       
    55 		TPckg<TLbsGpsOptionsArray> pckgOptions(options);
       
    56 		err = iModeChangesProperty.Get(pckgOptions);
       
    57 		if(KErrNone == err)
       
    58 			{
       
    59 			iHandler.OnSetGpsOptions(options);
       
    60 			}
       
    61 		}
       
    62 	}
       
    63 
       
    64 void CT_AgpsModuleEventListener::DoCancel()
       
    65 	{
       
    66 	iModeChangesProperty.Cancel();
       
    67 	}