29
|
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 "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
@internalComponent
|
|
21 |
*/
|
|
22 |
|
|
23 |
#include "cmtpcontrollertimer.h"
|
|
24 |
#include "cmtpoperator.h"
|
49
|
25 |
#include "mtpdebug.h"
|
|
26 |
#include "OstTraceDefinitions.h"
|
|
27 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
28 |
#include "cmtpcontrollertimerTraces.h"
|
|
29 |
#endif
|
29
|
30 |
|
|
31 |
|
|
32 |
const TUid KMTPBtTransportUid = { 0x10286FCB };
|
|
33 |
const TInt KStartMTPSeconds = 7;
|
|
34 |
|
|
35 |
CMTPControllerTimer* CMTPControllerTimer::NewLC( RMTPClient& aMTPClient, CMTPOperator & aMTPOperator )
|
|
36 |
{
|
|
37 |
CMTPControllerTimer* self = new(ELeave) CMTPControllerTimer( aMTPClient, aMTPOperator );
|
|
38 |
CleanupStack::PushL( self );
|
|
39 |
self->ConstructL();
|
|
40 |
return self;
|
|
41 |
}
|
|
42 |
|
|
43 |
CMTPControllerTimer* CMTPControllerTimer::NewL( RMTPClient& aMTPClient, CMTPOperator & aMTPOperator )
|
|
44 |
{
|
|
45 |
CMTPControllerTimer* self = NewLC( aMTPClient, aMTPOperator );
|
|
46 |
CleanupStack::Pop( self );
|
|
47 |
return self;
|
|
48 |
}
|
|
49 |
|
|
50 |
void CMTPControllerTimer::Start( TInt aTimeOut )
|
|
51 |
{
|
|
52 |
CTimer::After( aTimeOut * ETimerMultiplier );
|
|
53 |
}
|
|
54 |
|
|
55 |
TBool CMTPControllerTimer::GetStopTransportStatus()
|
|
56 |
{
|
|
57 |
return iStopTransport;
|
|
58 |
}
|
|
59 |
|
|
60 |
CMTPControllerTimer::~CMTPControllerTimer()
|
|
61 |
{
|
49
|
62 |
OstTraceFunctionEntry0( CMTPCONTROLLERTIMER_DES_ENTRY );
|
|
63 |
OstTraceFunctionExit0( CMTPCONTROLLERTIMER_DES_EXIT );
|
29
|
64 |
}
|
|
65 |
|
|
66 |
CMTPControllerTimer::CMTPControllerTimer( RMTPClient& aMTPClient, CMTPOperator& aMTPOperator ):
|
|
67 |
CTimer( CActive::EPriorityStandard ), iMTPClient(aMTPClient)
|
|
68 |
{
|
|
69 |
iMTPOperator = &aMTPOperator;
|
|
70 |
}
|
|
71 |
|
|
72 |
void CMTPControllerTimer::ConstructL()
|
|
73 |
{
|
49
|
74 |
OstTraceFunctionEntry0( CMTPCONTROLLERTIMER_CONSTRUCTL_ENTRY );
|
29
|
75 |
CTimer::ConstructL();
|
|
76 |
CActiveScheduler::Add( this );
|
|
77 |
iStopTransport = EFalse;
|
49
|
78 |
OstTraceFunctionExit0( CMTPCONTROLLERTIMER_CONSTRUCTL_EXIT );
|
29
|
79 |
}
|
|
80 |
|
|
81 |
void CMTPControllerTimer::RunL()
|
|
82 |
{
|
49
|
83 |
OstTraceFunctionEntry0( CMTPCONTROLLERTIMER_RUNL_ENTRY );
|
29
|
84 |
if (KErrNone == iMTPClient.IsProcessRunning() && !iStopTransport)
|
|
85 |
{
|
49
|
86 |
OstTrace0( TRACE_NORMAL, CMTPCONTROLLERTIMER_RUNL, "Stop transport to shut down mtp server" );
|
29
|
87 |
TInt error = iMTPClient.StopTransport(KMTPBtTransportUid);
|
|
88 |
iMTPClient.Close();
|
|
89 |
iStopTransport = ETrue;
|
49
|
90 |
OstTrace1( TRACE_NORMAL, DUP1_CMTPCONTROLLERTIMER_RUNL, "The return value of stop transport is: %d", error );
|
29
|
91 |
iMTPOperator->StartTimer(KStartMTPSeconds);
|
|
92 |
}
|
|
93 |
else
|
|
94 |
{
|
49
|
95 |
OstTrace0( TRACE_NORMAL, DUP2_CMTPCONTROLLERTIMER_RUNL, "Start transport to launch mtp server" );
|
29
|
96 |
|
60
|
97 |
TInt err = iMTPClient.Connect();
|
|
98 |
if ( err == KErrNone )
|
|
99 |
{
|
|
100 |
iMTPClient.StartTransport(KMTPBtTransportUid);
|
|
101 |
iStopTransport = EFalse;
|
|
102 |
iMTPOperator->SubscribeConnState();
|
|
103 |
}
|
|
104 |
else
|
|
105 |
{
|
|
106 |
OstTrace1( TRACE_NORMAL, DUP3_CMTPCONTROLLERTIMER_RUNL, "connect to mtp server failed! error code %d", err );
|
|
107 |
}
|
|
108 |
|
29
|
109 |
}
|
49
|
110 |
OstTraceFunctionExit0( CMTPCONTROLLERTIMER_RUNL_EXIT );
|
29
|
111 |
}
|
60
|
112 |
|