|
1 /* |
|
2 * Copyright (c) 2004-2006 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: This class handles registering and unregistering of |
|
15 * DRM event observers to DRM notifier, and sending |
|
16 * DRM notifications to other registered observers. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #ifndef CDRMEVENTHANDLER_H |
|
23 #define CDRMEVENTHANDLER_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <e32base.h> |
|
27 #include <DRMEvent.h> |
|
28 #include <DRMEventAddRemove.h> |
|
29 #include <DRMEventObserver.h> |
|
30 #include "DRMEventModify.h" |
|
31 #include "DRMEventTimeChange.h" |
|
32 #include "DRMNotifierClient.h" |
|
33 |
|
34 // CONSTANTS |
|
35 const TInt KOperationNone = 0; |
|
36 const TInt KRegisterOperation = 1; |
|
37 const TInt KRegisterURIOperation = 2; |
|
38 const TInt KUnRegisterOperation = 3; |
|
39 const TInt KUnRegisterURIOperation = 4; |
|
40 |
|
41 // MACROS |
|
42 // DATA TYPES |
|
43 // FUNCTION PROTOTYPES |
|
44 // FORWARD DECLARATIONS |
|
45 class MDRMEventObserver; |
|
46 |
|
47 // CLASS DECLARATION |
|
48 |
|
49 /** |
|
50 * CDRMEventHandler |
|
51 * Performs the required operations between the client and the server |
|
52 * Handles the handles for the observers |
|
53 * |
|
54 * @lib DRMCommon.dll |
|
55 * @since S60Rel2.6 |
|
56 */ |
|
57 class CDRMEventHandler : public CActive |
|
58 { |
|
59 public: // Constructors and destructor |
|
60 |
|
61 /** |
|
62 * Two-phased constructor. |
|
63 */ |
|
64 static CDRMEventHandler* NewL(); |
|
65 |
|
66 /** |
|
67 * Destructor. |
|
68 */ |
|
69 virtual ~CDRMEventHandler(); |
|
70 |
|
71 public: // New functions |
|
72 |
|
73 /** |
|
74 * RegisterEventObserverL |
|
75 * |
|
76 * Registers a new event observer to DRM Notifier. Listens to all events |
|
77 * of the given type |
|
78 * |
|
79 * @since S60Rel2.6 |
|
80 * @param aObserver Observer. |
|
81 * @param aEvent the type of event to listen to |
|
82 * @return none, leaves with Symbian OS error code if an error occurs |
|
83 */ |
|
84 void RegisterEventObserverL( MDRMEventObserver& aObserver , |
|
85 const TDRMEventType& aEvent); |
|
86 /** |
|
87 * UnRegisterEventObserverL |
|
88 * |
|
89 * Unregisters existing event observer from DRM Notifier. |
|
90 * |
|
91 * @since S60Rel2.6 |
|
92 * @param aObserver Observer. |
|
93 * @param aEvent the type of event to unregister |
|
94 * @return none, leaves with Symbian OS error code if an error occurs |
|
95 */ |
|
96 void UnRegisterEventObserverL( MDRMEventObserver& aObserver, |
|
97 const TDRMEventType& aEvent); |
|
98 /** |
|
99 * RegisterEventObserverL |
|
100 * |
|
101 * Registers a new event observer to DRM Notifier. Only recieves |
|
102 * notification when the rights accociated with the given content id |
|
103 * are handled |
|
104 * |
|
105 * @since S60Rel2.6 |
|
106 * @param aObserver Observer |
|
107 * @param aEvent the type of event to listen to |
|
108 * @param aContentID the specific content id to listen to |
|
109 * @return none, leaves with Symbian OS error code if an error occurs |
|
110 */ |
|
111 void RegisterEventObserverL( MDRMEventObserver& aObserver , |
|
112 const TDRMEventType& aEvent, |
|
113 const TDesC8& aContentID); |
|
114 /** |
|
115 * UnRegisterEventObserverL |
|
116 * |
|
117 * Unregisters existing event observer from DRM Notifier. |
|
118 * |
|
119 * @since S60Rel2.6 |
|
120 * @param aObserver Observer. |
|
121 * @param aEvent the type of event to listen to |
|
122 * @param aContentID the specific content id to listen to |
|
123 * @return none, leaves with Symbian OS error code if an error occurs |
|
124 */ |
|
125 void UnRegisterEventObserverL( MDRMEventObserver& aObserver, |
|
126 const TDRMEventType& aEvent, |
|
127 const TDesC8& aContentID); |
|
128 /** |
|
129 * SendEventL |
|
130 * |
|
131 * Sends a notification to registered observers, asyncronous |
|
132 * |
|
133 * @since S60Rel2.6 |
|
134 * @param aEvent the event to send |
|
135 * @param aStatus the request status of the event |
|
136 */ |
|
137 void SendEventL( MDRMEvent& aEvent, TRequestStatus& aStatus ); |
|
138 |
|
139 public: // Functions from base classes |
|
140 |
|
141 protected: // New functions |
|
142 CDRMEventHandler(); |
|
143 |
|
144 /** |
|
145 * 2nd phase constructor. |
|
146 */ |
|
147 void ConstructL(); |
|
148 |
|
149 protected: // Functions from base classes |
|
150 |
|
151 /** |
|
152 * From CActive: RunL catches events from DRM server. |
|
153 */ |
|
154 void RunL(); |
|
155 |
|
156 void DoCancel(); |
|
157 |
|
158 private: |
|
159 |
|
160 /** |
|
161 * GetEventObjectLC |
|
162 * |
|
163 * Reserves memory for an object specified in the internal structure |
|
164 * and leaves it in the cleanup stack |
|
165 * |
|
166 * @return a base class pointer to the requested object |
|
167 * The function leaves if an error occurs with a Symbian OS |
|
168 * error code |
|
169 */ |
|
170 MDRMEvent* GetEventObjectLC(); |
|
171 |
|
172 /** |
|
173 * HandleRunL |
|
174 * |
|
175 * Helper function for RunL that does the actual callbacks to |
|
176 * registered clients |
|
177 * |
|
178 * @return none |
|
179 */ |
|
180 void HandleRunL(); |
|
181 |
|
182 // Prohibit copy constructor if not deriving from CBase. |
|
183 CDRMEventHandler( const CDRMEventHandler& ); |
|
184 // Prohibit assigment operator if not deriving from CBase. |
|
185 CDRMEventHandler& operator=( const CDRMEventHandler& ); |
|
186 |
|
187 public: // Data |
|
188 |
|
189 protected: // Data |
|
190 |
|
191 private: // Data |
|
192 struct TObserverData |
|
193 { |
|
194 MDRMEventObserver* iObserver; |
|
195 HBufC8* iContentID; |
|
196 }; |
|
197 |
|
198 struct TDelayedObserverData |
|
199 { |
|
200 TInt iRequest; |
|
201 MDRMEventObserver* iObserver; |
|
202 TDRMEventType iEventType; |
|
203 HBufC8* iContentID; |
|
204 }; |
|
205 |
|
206 // Instance of c/s communications. |
|
207 RDRMNotifierClient* iHandler; |
|
208 |
|
209 // List of observers |
|
210 CArrayPtrSeg< TObserverData >* iAddRemoveObservers; |
|
211 CArrayPtrSeg< TObserverData >* iModifyObservers; |
|
212 CArrayPtrSeg< TObserverData >* iTimeChangeObservers; |
|
213 CArrayPtrSeg< TDelayedObserverData >* iDelayedObservers; |
|
214 |
|
215 // variable to tell if calls are being delayed |
|
216 TBool iIsDelayed; |
|
217 |
|
218 // Status of Client |
|
219 TBool iIsOpen; |
|
220 |
|
221 // Client Server Communication |
|
222 TUint8* iDataBuffer; |
|
223 TDRMEventType* iEventType; |
|
224 TPtr8* iData; |
|
225 |
|
226 TUint8* iWaitDataBuffer; |
|
227 TDRMEventType* iEventTypeWait; |
|
228 TPtr8* iWaitData; |
|
229 |
|
230 public: // Friend classes |
|
231 |
|
232 protected: // Friend classes |
|
233 |
|
234 private: // Friend classes |
|
235 }; |
|
236 |
|
237 #endif // DRMEVENTHANDLER_H |
|
238 |
|
239 // End of File |