|
1 /* |
|
2 * Copyright (c) 2003 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 |
|
19 #ifndef CDLSERVER_H |
|
20 #define CDLSERVER_H |
|
21 |
|
22 // CDL server classes |
|
23 |
|
24 #include <e32base.h> |
|
25 #include "CdlClientServer.h" |
|
26 #include "CdlClientServerStd.h" |
|
27 #include "CdlRefs.h" |
|
28 #include "CdlDllWatcher.h" |
|
29 |
|
30 class TDriveUnit; |
|
31 |
|
32 enum TCdlPanic |
|
33 { |
|
34 // client panics |
|
35 EPanicBadDescriptor, |
|
36 EPanicIllegalFunction, |
|
37 EPanicNotifyActive, |
|
38 EPanicNoCustomisationRequested, |
|
39 EPanicBufRequestedWithoutSetup, |
|
40 EPanicParamOutOfRange, |
|
41 |
|
42 // server panics |
|
43 EServerPanicBase = 100, |
|
44 EPanicTDllListOpEqNullCurrent, |
|
45 EPanicTDllListOpLtNullCurrent, |
|
46 EPanicTDllListCurrentNullCurrent, |
|
47 EPanicTDllListNextNullCurrent, |
|
48 EPanicTDllListNextNullDirs, |
|
49 }; |
|
50 |
|
51 void PanicClient(const RMessagePtr2& aMessage,TCdlPanic TCdlPanic); |
|
52 void Panic(TCdlPanic TCdlPanic); |
|
53 |
|
54 |
|
55 /** |
|
56 * Timer used to shut down the server after 2 seconds with no clients. |
|
57 */ |
|
58 class CShutdown : public CTimer |
|
59 { |
|
60 enum {KCdlShutdownDelay=2000000}; // 2 seconds |
|
61 public: |
|
62 CShutdown(); |
|
63 void ConstructL(); |
|
64 void Start(); |
|
65 private: |
|
66 void RunL(); |
|
67 }; |
|
68 |
|
69 |
|
70 /** |
|
71 * The CDL server. |
|
72 * This maintains a watch on the available CDL DLLs. It also maintains the total global |
|
73 * customisation state. |
|
74 */ |
|
75 class CCdlServer : public CServer2, MCdlDllsObserver |
|
76 { |
|
77 public: |
|
78 static CServer2* NewLC(); |
|
79 ~CCdlServer(); |
|
80 void AddSession(); |
|
81 void DropSession(); |
|
82 CCdlRefs* GetStateLC(const CCdlUids& aUids) const; |
|
83 void SetStateL(CCdlRefs* aState); |
|
84 const CCdlRefs& AllRefs() const; |
|
85 inline CCdlRefCollection* FileContentsLC(const TDesC& aFileName) { return iDllWatcher->FileContentsLC(aFileName); } |
|
86 TInt IsPluginInRom(const TDesC& aFileName, TBool& aIsInRom); |
|
87 TInt PluginDrive(const TDesC& aFileName, TDriveUnit& aDrive); |
|
88 |
|
89 private: |
|
90 CCdlServer(); |
|
91 void ConstructL(); |
|
92 CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const; |
|
93 TInt RunError(TInt aError); |
|
94 |
|
95 private: // from MCdlDllsObserver |
|
96 void McdoPrepareForChangesL(); |
|
97 void McdoFileAddedL(const TDesC& aFile); |
|
98 void McdoFileRemovedL(const TDesC& aFile); |
|
99 void McdoChangesCompleteL(); |
|
100 |
|
101 private: |
|
102 TInt iSessionCount; |
|
103 // All the following are owned |
|
104 CShutdown iShutdown; |
|
105 CCdlEngineRef* iEngRef; |
|
106 CCdlRefs* iState; |
|
107 RFs iFs; |
|
108 CCdlDllsWatcherBase* iDllWatcher; |
|
109 CCdlRefs* iAllRefs; |
|
110 }; |
|
111 |
|
112 |
|
113 /** |
|
114 * The CDL server's client session. |
|
115 * This maintains a list of the UIDs that the client is interested in. |
|
116 * Changes in available customisations and in the relevant global customisation state |
|
117 * are sent to the client. |
|
118 */ |
|
119 class CCdlSession : public CSession2 |
|
120 { |
|
121 public: |
|
122 CCdlSession(); |
|
123 void CreateL(); |
|
124 void HandleCustChangeL(const CCdlUids& aUids); |
|
125 void HandleRefsChangeL(); |
|
126 private: |
|
127 ~CCdlSession(); |
|
128 CCdlServer& Server(); |
|
129 void ServiceL(const RMessage2& aMessage); |
|
130 void RequestGetCustL(const RMessage2& aMessage); |
|
131 void GetCustL(const RMessage2& aMessage); |
|
132 void SetUidsToNotifyL(const RMessage2& aMessage); |
|
133 void NotifyChangeL(const RMessage2& aMessage); |
|
134 void CancelNotifyChangeL(const RMessage2& aMessage); |
|
135 void SetCustL(const RMessage2& aMessage); |
|
136 void GetRefsSizeL(const RMessage2& aMessage); |
|
137 void GetAllRefsSizeL(const RMessage2& aMessage); |
|
138 void GetNamesSizeL(const RMessage2& aMessage); |
|
139 void GetTempBufL(const RMessage2& aMessage); |
|
140 void IsPluginInRomL(const RMessage2& aMessage); |
|
141 void PluginDriveL(const RMessage2& aMessage); |
|
142 TBool NotifyPending() const; |
|
143 void NotifyCustChangeL(); |
|
144 void WriteAndComplete(const RMessagePtr2& aMessage, TInt aParam, const TDesC8& aDes, TInt aCode = KErrNone); |
|
145 TInt ValidIntL(TInt aVal, TInt aMin, TInt aMax) const; |
|
146 private: |
|
147 RMessagePtr2 iNotify; |
|
148 HBufC8* iSendingBuf; //owned |
|
149 CCdlRefs* iSendingState; //owned |
|
150 CCdlUids iUids; |
|
151 TBool iQueuedCustChange; // is there a global customisation change waiting to be sent to the client? |
|
152 TBool iQueuedRefsChange; // is there a refs list change waiting to be sent to the client? |
|
153 HBufC8* iTempBuf; //owned |
|
154 }; |
|
155 |
|
156 #endif |