|
1 // Copyright (c) 2010 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 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include "mmfmediaclientextdisplaytestprovider.h" |
|
22 #include "mmfmediaclientextdisplaytesttrace.h" |
|
23 |
|
24 #include <f32file.h> |
|
25 #include <bautils.h> |
|
26 |
|
27 static const TInt KExternalDisplayTestNumber = 0; |
|
28 |
|
29 _LIT(KInitExtDisplayHDMI, "C:\\vclntavi\\InitExtDisplayHDMI.txt"); |
|
30 _LIT(KInitExtDisplayAnalog, "C:\\vclntavi\\InitExtDisplayAnalog.txt"); |
|
31 _LIT(KConnectExtDisplayOverHDMI, "C:\\vclntavi\\ConnectExtDisplayOverHDMI.txt"); |
|
32 _LIT(KConnectExtDisplayOverAnalog, "C:\\vclntavi\\ConnectExtDisplayOverAnalog.txt"); |
|
33 _LIT(KDisconnectExtDisplay, "C:\\vclntavi\\DisconnectExtDisplay.txt"); |
|
34 |
|
35 CExtDisplayTestConnectionProvider* CExtDisplayTestConnectionProvider::NewL() |
|
36 { |
|
37 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::NewL +++"); |
|
38 CExtDisplayTestConnectionProvider* self = new(ELeave) CExtDisplayTestConnectionProvider(); |
|
39 CleanupStack::PushL(self); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop(self); |
|
42 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::NewL ---"); |
|
43 return self; |
|
44 } |
|
45 |
|
46 CExtDisplayTestConnectionProvider::CExtDisplayTestConnectionProvider() |
|
47 { |
|
48 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::CExtDisplayTestConnectionProvider +++"); |
|
49 |
|
50 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::CExtDisplayTestConnectionProvider ---"); |
|
51 } |
|
52 |
|
53 void CExtDisplayTestConnectionProvider::ConstructL() |
|
54 { |
|
55 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::ConstructL +++"); |
|
56 |
|
57 ReadConnectionInfoL(); |
|
58 InitialiseConnectionChangeTimerL(); |
|
59 |
|
60 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::ConstructL ---"); |
|
61 } |
|
62 |
|
63 CExtDisplayTestConnectionProvider::~CExtDisplayTestConnectionProvider() |
|
64 { |
|
65 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::~CExtDisplayTestConnectionProvider +++"); |
|
66 |
|
67 if(iExtDisplayConnectionTimer != NULL) |
|
68 { |
|
69 iExtDisplayConnectionTimer->Cancel(); |
|
70 delete iExtDisplayConnectionTimer; |
|
71 } |
|
72 |
|
73 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::~CExtDisplayTestConnectionProvider ---"); |
|
74 } |
|
75 |
|
76 TExtDisplayConnectionProviderConnType CExtDisplayTestConnectionProvider::ExtDisplayConnType() |
|
77 { |
|
78 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::ExtDisplayConnType +++"); |
|
79 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::ExtDisplayConnType ---"); |
|
80 return iInitialConnectionType; |
|
81 } |
|
82 |
|
83 TInt CExtDisplayTestConnectionProvider::ExtDisplayId() |
|
84 { |
|
85 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::ExtDisplayId +++"); |
|
86 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::ExtDisplayId ---"); |
|
87 return KExternalDisplayTestNumber; |
|
88 } |
|
89 |
|
90 void CExtDisplayTestConnectionProvider::SetExtDisplayConnectionProviderCallback(MExtDisplayConnectionProviderCallback& aCallback) |
|
91 { |
|
92 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::SetExtDisplayConnectionProviderCallback +++"); |
|
93 |
|
94 iCallback = &aCallback; |
|
95 |
|
96 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::SetExtDisplayConnectionProviderCallback ---"); |
|
97 } |
|
98 |
|
99 void CExtDisplayTestConnectionProvider::ReadConnectionInfoL() |
|
100 { |
|
101 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::ReadConnectionInfoL +++"); |
|
102 |
|
103 RFs fs; |
|
104 User::LeaveIfError(fs.Connect()); |
|
105 CleanupClosePushL(fs); |
|
106 |
|
107 // determine initial connection type |
|
108 if(BaflUtils::FileExists(fs, KInitExtDisplayHDMI)) |
|
109 { |
|
110 iInitialConnectionType = EExtDisplayConnectionProviderConnTypeHdmi; |
|
111 } |
|
112 else if(BaflUtils::FileExists(fs, KInitExtDisplayAnalog)) |
|
113 { |
|
114 iInitialConnectionType = EExtDisplayConnectionProviderConnTypeAnalog; |
|
115 } |
|
116 else |
|
117 { |
|
118 iInitialConnectionType = EExtDisplayConnectionProviderConnTypeDisconnected; |
|
119 } |
|
120 |
|
121 // determine change connection type |
|
122 if(BaflUtils::FileExists(fs, KConnectExtDisplayOverHDMI)) |
|
123 { |
|
124 iConnectionTypeToBeNotified = EExtDisplayConnectionProviderConnTypeHdmi; |
|
125 } |
|
126 else if(BaflUtils::FileExists(fs, KConnectExtDisplayOverAnalog)) |
|
127 { |
|
128 iConnectionTypeToBeNotified = EExtDisplayConnectionProviderConnTypeAnalog; |
|
129 } |
|
130 else if(BaflUtils::FileExists(fs, KDisconnectExtDisplay)) |
|
131 { |
|
132 iConnectionTypeToBeNotified = EExtDisplayConnectionProviderConnTypeDisconnected; |
|
133 } |
|
134 else |
|
135 { |
|
136 iConnectionTypeToBeNotified = iInitialConnectionType; |
|
137 } |
|
138 |
|
139 CleanupStack::PopAndDestroy(1, &fs); |
|
140 |
|
141 DEBUG_PRINTF3("CExtDisplayTestConnectionProvider::ReadConnectionInfoL Initial = %d, Next = %d", |
|
142 iInitialConnectionType, iConnectionTypeToBeNotified); |
|
143 |
|
144 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::ReadConnectionInfoL ---"); |
|
145 } |
|
146 |
|
147 void CExtDisplayTestConnectionProvider::InitialiseConnectionChangeTimerL() |
|
148 { |
|
149 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::InitialiseConnectionChangeTimerL +++"); |
|
150 |
|
151 if(iInitialConnectionType != iConnectionTypeToBeNotified) |
|
152 { |
|
153 iExtDisplayConnectionTimer = CExtDisplayConnectionTimer::NewL(this, 2000000); |
|
154 iExtDisplayConnectionTimer->Start(); |
|
155 } |
|
156 |
|
157 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::InitialiseConnectionChangeTimerL ---"); |
|
158 } |
|
159 |
|
160 void CExtDisplayTestConnectionProvider::TimerExpired() |
|
161 { |
|
162 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::TimerExpired +++"); |
|
163 |
|
164 iCallback->MedcpcExtDisplayNotifyConnected(iConnectionTypeToBeNotified); |
|
165 |
|
166 DEBUG_PRINTF("CExtDisplayTestConnectionProvider::TimerExpired ---"); |
|
167 } |
|
168 |
|
169 |
|
170 CExtDisplayConnectionTimer* CExtDisplayConnectionTimer::NewL(CExtDisplayTestConnectionProvider* aParent, TTimeIntervalMicroSeconds32 aInterval) |
|
171 { |
|
172 DEBUG_PRINTF("CExtDisplayConnectionTimer::NewL +++"); |
|
173 |
|
174 CExtDisplayConnectionTimer* self = new (ELeave) CExtDisplayConnectionTimer(aParent, aInterval); |
|
175 CleanupStack::PushL(self); |
|
176 self->ConstructL(); // inherited |
|
177 CleanupStack::Pop(self); |
|
178 |
|
179 DEBUG_PRINTF("CExtDisplayConnectionTimer::NewL ---"); |
|
180 return self; |
|
181 } |
|
182 |
|
183 CExtDisplayConnectionTimer::CExtDisplayConnectionTimer(CExtDisplayTestConnectionProvider* aParent, TTimeIntervalMicroSeconds32 aInterval) |
|
184 : CTimer(EPriorityNormal), iParent(aParent), iInterval(aInterval) |
|
185 { |
|
186 DEBUG_PRINTF("CExtDisplayConnectionTimer::CExtDisplayConnectionTimer +++"); |
|
187 |
|
188 CActiveScheduler::Add(this); |
|
189 |
|
190 DEBUG_PRINTF("CExtDisplayConnectionTimer::CExtDisplayConnectionTimer ---"); |
|
191 } |
|
192 |
|
193 void CExtDisplayConnectionTimer::Start() |
|
194 { |
|
195 DEBUG_PRINTF("CExtDisplayConnectionTimer::Start +++"); |
|
196 |
|
197 After(iInterval); |
|
198 |
|
199 DEBUG_PRINTF("CExtDisplayConnectionTimer::Start ---"); |
|
200 } |
|
201 |
|
202 void CExtDisplayConnectionTimer::RunL() |
|
203 { |
|
204 DEBUG_PRINTF("CExtDisplayConnectionTimer::RunL +++"); |
|
205 |
|
206 iParent->TimerExpired(); |
|
207 |
|
208 DEBUG_PRINTF("CExtDisplayConnectionTimer::RunL ---"); |
|
209 |
|
210 } |