|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <e32std.h> |
|
20 |
|
21 #include "trksrvclisession.h" |
|
22 #include "trkdebugstatelistener.h" |
|
23 |
|
24 // LOCAL FUNCTION PROTOTYPES |
|
25 |
|
26 // LOCAL CONSTANTS |
|
27 |
|
28 // |
|
29 // CTrkDebugStateListener::CTrkDebugStateListener |
|
30 // Constructor |
|
31 // |
|
32 CTrkDebugStateListener::CTrkDebugStateListener (RTrkSrvCliSession& aTrkSrvSession, MTrkServerEventCallback *aTrkServerEventCallback) |
|
33 :CTrkServerEventListener(aTrkSrvSession, aTrkServerEventCallback, CActive::EPriorityStandard), iDebugState(iDebugging) |
|
34 { |
|
35 iDebugging = EFalse; |
|
36 iTrkSrvSession.GetDebuggingStatus(iDebugging); |
|
37 CActiveScheduler::Add( this ); |
|
38 } |
|
39 |
|
40 // |
|
41 // CTrkDebugStateListener::~CTrkDebugStateListener |
|
42 // Destructor |
|
43 // |
|
44 CTrkDebugStateListener::~CTrkDebugStateListener() |
|
45 { |
|
46 Cancel(); // Ensure that any outstanding requests are cancelled |
|
47 Deque(); |
|
48 } |
|
49 |
|
50 // |
|
51 // CTrkDebugStateListener::ListenL |
|
52 // Starts listening for usb connection status notifications.. |
|
53 // |
|
54 void CTrkDebugStateListener::ListenL() |
|
55 { |
|
56 IssueRequestL(); |
|
57 } |
|
58 |
|
59 |
|
60 |
|
61 // |
|
62 // CTrkDebugStateListener::StopListening |
|
63 // Cancel any pending requests for connection status notifications. |
|
64 // |
|
65 void CTrkDebugStateListener::StopListening() |
|
66 { |
|
67 Cancel(); |
|
68 } |
|
69 |
|
70 // |
|
71 // CTrkDebugStateListener::IssueRequestL |
|
72 // |
|
73 TBool CTrkDebugStateListener::IsDebugging() |
|
74 { |
|
75 iTrkSrvSession.GetDebuggingStatus(iDebugging); |
|
76 return iDebugging; |
|
77 } |
|
78 |
|
79 // |
|
80 // CTrkDebugStateListener::IssueRequestL |
|
81 // |
|
82 void CTrkDebugStateListener::IssueRequestL() |
|
83 { |
|
84 if (IsActive()) //already listening, just return... |
|
85 return; |
|
86 iTrkSrvSession.DebuggingStatusNotify(iDebugState, iStatus); |
|
87 |
|
88 SetActive(); |
|
89 } |
|
90 |
|
91 // |
|
92 // CTrkDebugStateListener::DoCancel |
|
93 // This method gets called from CActive::Cancel(); |
|
94 // |
|
95 void CTrkDebugStateListener::DoCancel() |
|
96 { |
|
97 iTrkSrvSession.DebuggingStatusNotifyCancel(); |
|
98 } |
|
99 |
|
100 // |
|
101 // CTrkDebugStateListener::RunL |
|
102 // This method gets called whenever there is a change in the debugging status. |
|
103 // |
|
104 void CTrkDebugStateListener::RunL() |
|
105 { |
|
106 User::LeaveIfError( iStatus.Int() ); |
|
107 if (iTrkServerEventCallback) |
|
108 iTrkServerEventCallback->DebugStateChanged(iDebugging); |
|
109 |
|
110 IssueRequestL(); |
|
111 } |
|
112 |