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