sl@0
|
1 |
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "mediaclientwseventobserver.h"
|
sl@0
|
17 |
#include "mediaclientvideotrace.h"
|
sl@0
|
18 |
|
sl@0
|
19 |
CMediaClientWsEventObserver* CMediaClientWsEventObserver::NewL(MMediaClientWsEventObserverCallback& aCallback)
|
sl@0
|
20 |
{
|
sl@0
|
21 |
DEBUG_PRINTF("CMediaClientWsEventObserver::NewL +++");
|
sl@0
|
22 |
CMediaClientWsEventObserver* self = new (ELeave) CMediaClientWsEventObserver(aCallback);
|
sl@0
|
23 |
CleanupStack::PushL(self);
|
sl@0
|
24 |
self->ConstructL();
|
sl@0
|
25 |
CleanupStack::Pop(self);
|
sl@0
|
26 |
DEBUG_PRINTF("CMediaClientWsEventObserver::NewL ---");
|
sl@0
|
27 |
return self;
|
sl@0
|
28 |
}
|
sl@0
|
29 |
|
sl@0
|
30 |
CMediaClientWsEventObserver::CMediaClientWsEventObserver(MMediaClientWsEventObserverCallback& aCallback) :
|
sl@0
|
31 |
CActive(EPriorityStandard),
|
sl@0
|
32 |
iCallback(aCallback)
|
sl@0
|
33 |
{
|
sl@0
|
34 |
DEBUG_PRINTF("CMediaClientWsEventObserver::CMediaClientWsEventObserver +++");
|
sl@0
|
35 |
DEBUG_PRINTF("CMediaClientWsEventObserver::CMediaClientWsEventObserver ---");
|
sl@0
|
36 |
}
|
sl@0
|
37 |
|
sl@0
|
38 |
void CMediaClientWsEventObserver::ConstructL()
|
sl@0
|
39 |
{
|
sl@0
|
40 |
DEBUG_PRINTF("CMediaClientWsEventObserver::ConstructL +++");
|
sl@0
|
41 |
|
sl@0
|
42 |
DEBUG_PRINTF("CMediaClientWsEventObserver::ConstructL RWsSession Connect");
|
sl@0
|
43 |
TInt err = iWs.Connect();
|
sl@0
|
44 |
if (err != KErrNone)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
DEBUG_PRINTF2("CMediaClientWsEventObserver::ConstructL Windows Server unavailable, err %d", err);
|
sl@0
|
47 |
User::Leave(err);
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
DEBUG_PRINTF("CMediaClientWsEventObserver::ConstructL RWindowGroup Create");
|
sl@0
|
51 |
iWindowGroup = RWindowGroup(iWs);
|
sl@0
|
52 |
User::LeaveIfError(iWindowGroup.Construct((TUint32)this, EFalse));
|
sl@0
|
53 |
|
sl@0
|
54 |
// Send created window to the background and hide it from the
|
sl@0
|
55 |
// application switcher
|
sl@0
|
56 |
iWindowGroup.SetOrdinalPosition( -1, -1000 ); // -1000 = ECoeWinPriorityNeverAtFront
|
sl@0
|
57 |
|
sl@0
|
58 |
DEBUG_PRINTF("CMediaClientWsEventObserver::ConstructL RWindowGroup EnableFocusChangeEvents");
|
sl@0
|
59 |
User::LeaveIfError(iWindowGroup.EnableFocusChangeEvents());
|
sl@0
|
60 |
|
sl@0
|
61 |
UpdateFocusWindowGroupId(ETrue);
|
sl@0
|
62 |
DEBUG_PRINTF3("CMediaClientWsEventObserver::ConstructL Initial WgId %d Error %d", iWgId, iWgIdError);
|
sl@0
|
63 |
|
sl@0
|
64 |
CActiveScheduler::Add(this);
|
sl@0
|
65 |
|
sl@0
|
66 |
// register with window server to receive focus change notifications
|
sl@0
|
67 |
DEBUG_PRINTF("CMediaClientWsEventObserver::ConstructL iWs.EventReady()");
|
sl@0
|
68 |
iWs.EventReady(&iStatus);
|
sl@0
|
69 |
|
sl@0
|
70 |
DEBUG_PRINTF("CMediaClientWsEventObserver::ConstructL SetActive()");
|
sl@0
|
71 |
SetActive();
|
sl@0
|
72 |
|
sl@0
|
73 |
DEBUG_PRINTF("CMediaClientWsEventObserver::ConstructL ---");
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|
sl@0
|
76 |
CMediaClientWsEventObserver::~CMediaClientWsEventObserver()
|
sl@0
|
77 |
{
|
sl@0
|
78 |
DEBUG_PRINTF("CMediaClientWsEventObserver::~CMediaClientWsEventObserver +++");
|
sl@0
|
79 |
|
sl@0
|
80 |
Cancel();
|
sl@0
|
81 |
|
sl@0
|
82 |
iWindowGroup.Close();
|
sl@0
|
83 |
|
sl@0
|
84 |
iWs.Close();
|
sl@0
|
85 |
|
sl@0
|
86 |
DEBUG_PRINTF("CMediaClientWsEventObserver::~CMediaClientWsEventObserver ---");
|
sl@0
|
87 |
}
|
sl@0
|
88 |
|
sl@0
|
89 |
TInt CMediaClientWsEventObserver::FocusWindowGroupId(TInt& aFocusGroupId)
|
sl@0
|
90 |
{
|
sl@0
|
91 |
DEBUG_PRINTF("CMediaClientWsEventObserver::FocusWindowGroupId +++");
|
sl@0
|
92 |
aFocusGroupId = iWgId;
|
sl@0
|
93 |
DEBUG_PRINTF3("CMediaClientWsEventObserver::FocusWindowGroupId --- WgId %d, Error %d", iWgId, iWgIdError);
|
sl@0
|
94 |
return iWgIdError;
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
void CMediaClientWsEventObserver::UpdateFocusWindowGroupId(TBool aConstruction)
|
sl@0
|
98 |
{
|
sl@0
|
99 |
DEBUG_PRINTF2("CMediaClientWsEventObserver::UpdateFocusWindowGroupId +++, construction %d", aConstruction);
|
sl@0
|
100 |
|
sl@0
|
101 |
TInt wgId = iWs.GetFocusWindowGroup();
|
sl@0
|
102 |
DEBUG_PRINTF2("CMediaClientWsEventObserver::UpdateFocusWindowGroupId id %d ", wgId);
|
sl@0
|
103 |
|
sl@0
|
104 |
// get the thread that owns windowgroup id
|
sl@0
|
105 |
TThreadId threadId;
|
sl@0
|
106 |
iWgIdError = iWs.GetWindowGroupClientThreadId(wgId, threadId);
|
sl@0
|
107 |
if(iWgIdError != KErrNone)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
DEBUG_PRINTF2("CMediaClientWsEventObserver::UpdateFocusWindowGroupId --- Get Thread Id error %d", iWgIdError);
|
sl@0
|
110 |
return;
|
sl@0
|
111 |
}
|
sl@0
|
112 |
|
sl@0
|
113 |
RThread thread;
|
sl@0
|
114 |
iWgIdError = thread.Open(threadId);
|
sl@0
|
115 |
if(iWgIdError != KErrNone)
|
sl@0
|
116 |
{
|
sl@0
|
117 |
DEBUG_PRINTF2("CMediaClientWsEventObserver::UpdateFocusWindowGroupId --- Open thread error %d", iWgIdError);
|
sl@0
|
118 |
return;
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
TSecureId fgThreadId = thread.SecureId();
|
sl@0
|
122 |
thread.Close();
|
sl@0
|
123 |
|
sl@0
|
124 |
if(iCallback.MmcweoIgnoreProcess(fgThreadId))
|
sl@0
|
125 |
{
|
sl@0
|
126 |
// If ignore returns ETrue during construction the previous value of iWgId does not contain a valid id. It is 0.
|
sl@0
|
127 |
// This is an error case so set error flag accordingly.
|
sl@0
|
128 |
if(aConstruction)
|
sl@0
|
129 |
{
|
sl@0
|
130 |
iWgIdError = KErrNotSupported;
|
sl@0
|
131 |
}
|
sl@0
|
132 |
}
|
sl@0
|
133 |
else
|
sl@0
|
134 |
{
|
sl@0
|
135 |
iWgId = wgId;
|
sl@0
|
136 |
}
|
sl@0
|
137 |
|
sl@0
|
138 |
DEBUG_PRINTF("CMediaClientWsEventObserver::UpdateFocusWindowGroupId --- ");
|
sl@0
|
139 |
}
|
sl@0
|
140 |
|
sl@0
|
141 |
void CMediaClientWsEventObserver::RunL()
|
sl@0
|
142 |
{
|
sl@0
|
143 |
DEBUG_PRINTF("CMediaClientWsEventObserver::RunL +++");
|
sl@0
|
144 |
|
sl@0
|
145 |
iWs.GetEvent(iEvent);
|
sl@0
|
146 |
|
sl@0
|
147 |
DEBUG_PRINTF("CMediaClientWsEventObserver::RunL EventReady()");
|
sl@0
|
148 |
iWs.EventReady(&iStatus);
|
sl@0
|
149 |
DEBUG_PRINTF("CMediaClientWsEventObserver::RunL SetActive()");
|
sl@0
|
150 |
SetActive();
|
sl@0
|
151 |
|
sl@0
|
152 |
DEBUG_PRINTF2("CMediaClientWsEventObserver::RunL() Ws event.Type %d", iEvent.Type());
|
sl@0
|
153 |
if(iEvent.Type() == EEventFocusGroupChanged)
|
sl@0
|
154 |
{
|
sl@0
|
155 |
DEBUG_PRINTF("CMediaClientWsEventObserver::RunL Received EEventFocusGroupChanged");
|
sl@0
|
156 |
|
sl@0
|
157 |
TInt prevWgId = iWgId;
|
sl@0
|
158 |
UpdateFocusWindowGroupId(EFalse);
|
sl@0
|
159 |
if((iWgIdError != KErrNone) || (iWgId != prevWgId))
|
sl@0
|
160 |
{
|
sl@0
|
161 |
iCallback.MmcweoFocusWindowGroupChanged();
|
sl@0
|
162 |
}
|
sl@0
|
163 |
}
|
sl@0
|
164 |
else
|
sl@0
|
165 |
{
|
sl@0
|
166 |
DEBUG_PRINTF("CMediaClientWsEventObserver::RunL Event Ignored");
|
sl@0
|
167 |
}
|
sl@0
|
168 |
|
sl@0
|
169 |
DEBUG_PRINTF("CMediaClientWsEventObserver::RunL ---");
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
void CMediaClientWsEventObserver::DoCancel()
|
sl@0
|
173 |
{
|
sl@0
|
174 |
DEBUG_PRINTF("CMediaClientWsEventObserver::DoCancel +++");
|
sl@0
|
175 |
iWs.EventReadyCancel();
|
sl@0
|
176 |
DEBUG_PRINTF("CMediaClientWsEventObserver::DoCancel ---");
|
sl@0
|
177 |
}
|