|
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" |
|
25 |
|
26 __FLOG_STMT( _LIT8( KComponent, "mtpConTimer" ); ) |
|
27 |
|
28 const TUid KMTPBtTransportUid = { 0x10286FCB }; |
|
29 const TInt KStartMTPSeconds = 7; |
|
30 |
|
31 CMTPControllerTimer* CMTPControllerTimer::NewLC( RMTPClient& aMTPClient, CMTPOperator & aMTPOperator ) |
|
32 { |
|
33 CMTPControllerTimer* self = new(ELeave) CMTPControllerTimer( aMTPClient, aMTPOperator ); |
|
34 CleanupStack::PushL( self ); |
|
35 self->ConstructL(); |
|
36 return self; |
|
37 } |
|
38 |
|
39 CMTPControllerTimer* CMTPControllerTimer::NewL( RMTPClient& aMTPClient, CMTPOperator & aMTPOperator ) |
|
40 { |
|
41 CMTPControllerTimer* self = NewLC( aMTPClient, aMTPOperator ); |
|
42 CleanupStack::Pop( self ); |
|
43 return self; |
|
44 } |
|
45 |
|
46 void CMTPControllerTimer::Start( TInt aTimeOut ) |
|
47 { |
|
48 CTimer::After( aTimeOut * ETimerMultiplier ); |
|
49 } |
|
50 |
|
51 TBool CMTPControllerTimer::GetStopTransportStatus() |
|
52 { |
|
53 return iStopTransport; |
|
54 } |
|
55 |
|
56 CMTPControllerTimer::~CMTPControllerTimer() |
|
57 { |
|
58 __FLOG( _L8("CMPTControllerTimer destruction") ); |
|
59 __FLOG_CLOSE; |
|
60 } |
|
61 |
|
62 CMTPControllerTimer::CMTPControllerTimer( RMTPClient& aMTPClient, CMTPOperator& aMTPOperator ): |
|
63 CTimer( CActive::EPriorityStandard ), iMTPClient(aMTPClient) |
|
64 { |
|
65 __FLOG_OPEN( KMTPSubsystem, KComponent ); |
|
66 iMTPOperator = &aMTPOperator; |
|
67 } |
|
68 |
|
69 void CMTPControllerTimer::ConstructL() |
|
70 { |
|
71 CTimer::ConstructL(); |
|
72 CActiveScheduler::Add( this ); |
|
73 iStopTransport = EFalse; |
|
74 __FLOG( _L8("CMPTControllerTimer construction") ); |
|
75 } |
|
76 |
|
77 void CMTPControllerTimer::RunL() |
|
78 { |
|
79 if (KErrNone == iMTPClient.IsProcessRunning() && !iStopTransport) |
|
80 { |
|
81 __FLOG( _L8("Stop transport to shut down mtp server") ); |
|
82 TInt error = iMTPClient.StopTransport(KMTPBtTransportUid); |
|
83 iMTPClient.Close(); |
|
84 iStopTransport = ETrue; |
|
85 __FLOG_1( _L8("The return value of stop transport is: %d"), error ); |
|
86 iMTPOperator->StartTimer(KStartMTPSeconds); |
|
87 } |
|
88 else |
|
89 { |
|
90 __FLOG( _L8("Start transport to launch mtp server") ); |
|
91 |
|
92 iMTPClient.Connect(); |
|
93 iMTPClient.StartTransport(KMTPBtTransportUid); |
|
94 iStopTransport = EFalse; |
|
95 iMTPOperator->SubscribeConnState(); |
|
96 } |
|
97 } |