common/tools/ats/smoketest/lbs/common/src/ctlbsdox3p.cpp
changeset 748 e13acd883fbe
child 872 17498133d9ad
equal deleted inserted replaced
747:76f9aaeefbab 748:e13acd883fbe
       
     1 // Copyright (c) 2006-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 // Async wrapper around a LBS X3P transmitter.
       
    15 // 
       
    16 //
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file ctlbsdox3p.cpp
       
    22 */
       
    23 
       
    24 //#include <lbsx3p.h>
       
    25 
       
    26 #include "ctlbsdox3p.h"
       
    27 
       
    28 
       
    29 CT_LbsDoX3P* CT_LbsDoX3P::NewL(MT_LbsDoX3PObserver* aObserver, TInt aTransmitId)
       
    30 	{
       
    31 	CT_LbsDoX3P* self = new(ELeave)CT_LbsDoX3P(aObserver, aTransmitId);
       
    32 	CleanupStack::PushL(self);
       
    33 	self->ConstructL();
       
    34 	CleanupStack::Pop();
       
    35 
       
    36 	return self;
       
    37 	}
       
    38 
       
    39 
       
    40 CT_LbsDoX3P::CT_LbsDoX3P(MT_LbsDoX3PObserver* aObserver, TInt aTransmitId) : CActive(EPriorityStandard), iObserver(aObserver), iTransmitId(aTransmitId)
       
    41 	{ 	
       
    42 	CActiveScheduler::Add(this); 
       
    43 	}
       
    44 
       
    45 
       
    46 void CT_LbsDoX3P::ConstructL()
       
    47 	{
       
    48 	User::LeaveIfError(iServer.Connect());
       
    49 	User::LeaveIfError(iTransmitter.Open(iServer));
       
    50 	}
       
    51 	
       
    52 
       
    53 CT_LbsDoX3P::~CT_LbsDoX3P()
       
    54 	{
       
    55 	Cancel();
       
    56 
       
    57 	iTransmitter.Close();
       
    58 	iServer.Close();
       
    59 	}
       
    60 
       
    61 
       
    62 TInt CT_LbsDoX3P::SetOptions(const TLbsTransmitPositionOptions& aTransmitOptions)
       
    63 	{
       
    64 	return iTransmitter.SetTransmitOptions(aTransmitOptions);
       
    65 	}
       
    66 
       
    67 
       
    68 void CT_LbsDoX3P::StartL(const TDesC& aDestinationID, TUint aTransmitPriority, TPositionInfo & aTransmittedPosInfo)
       
    69 	{	
       
    70 	__ASSERT_ALWAYS(!IsActive(), User::Panic(KCT_LbsDoX3P, KErrInUse));
       
    71 
       
    72 	// Invoke the X3P transmit update.	
       
    73 	iTransmitter.TransmitPosition(aDestinationID, aTransmitPriority, iStatus, aTransmittedPosInfo);
       
    74 	SetActive();
       
    75 	}
       
    76 
       
    77 
       
    78 void CT_LbsDoX3P::DoCancel()
       
    79 	{
       
    80 	iTransmitter.CancelTransmitPosition(); 
       
    81 	}
       
    82 
       
    83 
       
    84 void CT_LbsDoX3P::RunL()
       
    85 	{
       
    86 	// Notify caller via callback, process the err in the callback.
       
    87 	if (iObserver)
       
    88 		{
       
    89 		iObserver->MT_LbsDoX3PCallback(iTransmitId, iStatus);
       
    90 		}
       
    91 	}
       
    92 
       
    93 TInt CT_LbsDoX3P::RunError(TInt aError)
       
    94 	{
       
    95 	return aError;
       
    96 	}