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 #include <tswindowgroupsobserver.h> |
|
18 #include "tstaskmonitorglobals.h" |
|
19 #include "hsrunningappserver.h" |
|
20 #include "hsrunningappsession.h" |
|
21 #include "tsrunningappstorage.h" |
|
22 #include "tsscreenshotprovider.h" |
|
23 #include "tsbackstepping.h" |
|
24 |
|
25 _LIT(KErrObserverExists, "Observer already exists"); |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CRunningAppServer::CRunningAppServer() |
|
31 : |
|
32 CServer2(EPriorityStandard) |
|
33 { |
|
34 // No implementation required |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CRunningAppServer::~CRunningAppServer() |
|
42 { |
|
43 delete mBacksteppingEngine; |
|
44 delete mScreenshotProviderStarter; |
|
45 delete mStorage; |
|
46 delete mMonitor; |
|
47 mObservers.ResetAndDestroy(); |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CRunningAppServer* CRunningAppServer::NewLC() |
|
55 { |
|
56 CRunningAppServer* self = new (ELeave) CRunningAppServer(); |
|
57 CleanupStack::PushL(self); |
|
58 self->ConstructL(); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void CRunningAppServer::ConstructL() |
|
67 { |
|
68 StartL(KRunningAppServerName); |
|
69 User::LeaveIfError(mWsSession.Connect()); |
|
70 mResources = CTsResourceManager::NewL(); |
|
71 mMonitor = CTsWindowGroupsMonitor::NewL(*mResources); |
|
72 mStorage = CRunningAppStorage::NewL(*this, *mResources, *mMonitor); |
|
73 TRAP_IGNORE(mScreenshotProviderStarter = CTsScreenshotProvider::NewL(*mStorage); |
|
74 mBacksteppingEngine = CTsBackstepping::NewL(*mMonitor);) |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 CSession2* CRunningAppServer::NewSessionL(const TVersion &, const RMessage2&) const |
|
82 { |
|
83 return CRunningAppSession::NewL(*const_cast<CRunningAppServer *>(this), |
|
84 *const_cast<CRunningAppServer *>(this)->mStorage, |
|
85 *const_cast<CRunningAppServer *>(this)->mStorage); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CRunningAppServer::DataChanged() |
|
93 { |
|
94 while (0 < mObservers.Count()) { |
|
95 mObservers[0]->DataChanged(); |
|
96 } |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CRunningAppServer::PushL(CHsDataObserver* observer) |
|
104 { |
|
105 ( 0 <= mObservers.Find(observer)) ? |
|
106 User::Panic(KErrObserverExists, KErrAlreadyExists) : |
|
107 mObservers.AppendL(observer); |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 void CRunningAppServer::Pop(CHsDataObserver* observer) |
|
115 { |
|
116 const TInt offset(mObservers.Find(observer)); |
|
117 if(0 <= offset) { |
|
118 mObservers.Remove(offset); |
|
119 } |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 void CRunningAppServer::Cancel(const RMessage2& reason) |
|
127 { |
|
128 for (TInt iter(mObservers.Count() - 1); 0 <= iter; --iter) { |
|
129 mObservers[iter]->Cancel(reason); |
|
130 } |
|
131 reason.Complete(KErrNone); |
|
132 } |
|