|
1 /* |
|
2 * Copyright (c) 2004 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 declares the interface of class CDRMNotifierSession. |
|
15 * handles the queues for notification events |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef CDRMNOTIFIERSESSION_H |
|
21 #define CDRMNOTIFIERSESSION_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include "DRMMessageStorage.h" |
|
26 |
|
27 // CONSTANTS |
|
28 // MACROS |
|
29 // FUNCTION PROTOTYPES |
|
30 // DATA TYPES |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class RMessage2; |
|
34 class RRPointerArray; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * Server side instance of DRM Notifier session. |
|
40 * This class is the server side instance of C/S communications of a certain |
|
41 * session. |
|
42 * |
|
43 * @lib DRMCommon.dll |
|
44 * @since S60Rel2.6 |
|
45 */ |
|
46 NONSHARABLE_CLASS( CDRMNotifierSession ) : public CSession2 |
|
47 { |
|
48 public: // Constructors and destructor |
|
49 |
|
50 /** |
|
51 * Two-phased constructor. |
|
52 * |
|
53 * @since S60Rel2.6 |
|
54 * @param aClient Associated client side thread. |
|
55 * @param aStorage a pointer to an instance of CDRMMessageStorage |
|
56 * @return New session instance. |
|
57 */ |
|
58 static CDRMNotifierSession* NewL( CDRMMessageStorage* aStorage ); |
|
59 |
|
60 /** |
|
61 * Destructor. |
|
62 * @since S60Rel2.6 |
|
63 */ |
|
64 virtual ~CDRMNotifierSession(); |
|
65 |
|
66 public: // New functions |
|
67 |
|
68 /** |
|
69 * SendNotificationL |
|
70 * |
|
71 * Sends a notification to a client or adds it to the queue, depending on if |
|
72 * the client is active or not |
|
73 * |
|
74 * @since S60Rel2.6 |
|
75 * @param aMessage The message that needs to be sent |
|
76 * @exception Method leaves with appropriate exception value |
|
77 * if any errors occured. |
|
78 * @return ETrue if the message was put into queue |
|
79 * EFalse if it was run normally |
|
80 */ |
|
81 TBool SendNotificationL( CDRMMessageStorage::TMessageData* aMessage ); |
|
82 |
|
83 public: // Functions from base classes |
|
84 |
|
85 /** |
|
86 * From CSession: Handles the service request event. |
|
87 * @since S60Rel2.6 |
|
88 * @param aMessage The message related to the event. |
|
89 * @exception Method leaves with appropriate exception value |
|
90 * if any errors occured. |
|
91 */ |
|
92 void ServiceL( const RMessage2& aMessage ); |
|
93 |
|
94 private: |
|
95 |
|
96 /** |
|
97 * C++ constructor. |
|
98 * @since S60Rel2.6 |
|
99 * @param aClient Client thread. |
|
100 * @param aStorage a pointer to an instance of CDRMMessageStorage |
|
101 */ |
|
102 CDRMNotifierSession( CDRMMessageStorage* aStorage); |
|
103 |
|
104 /** |
|
105 * Second phase constructor. |
|
106 * @since S60Rel2.6 |
|
107 */ |
|
108 void ConstructL(); |
|
109 |
|
110 /** |
|
111 * ServiceL() runs DispatchL() under TRAP harness, so |
|
112 * all errors can be catched properly. DispatchL() then calls |
|
113 * appropriate private method depending on the request. |
|
114 * @since S60Rel2.6 |
|
115 * @param aMessage The message associated to the event. |
|
116 */ |
|
117 void DispatchL( const RMessage2& aMessage ); |
|
118 |
|
119 /** |
|
120 * Helper function for DispatchL(). |
|
121 * @since S60Rel2.6 |
|
122 * @param aMessage The message associated to the event. |
|
123 */ |
|
124 void NotifyClientsL( const RMessage2& aMessage ); |
|
125 |
|
126 |
|
127 /** |
|
128 * Helper function for DispatchL(). |
|
129 * @since S60Rel2.6 |
|
130 * @param aMessage The message associated to the event. |
|
131 */ |
|
132 void RecieveNotificationL( const RMessage2& aMessage ); |
|
133 |
|
134 /** |
|
135 * Helper function for DispatchL(). |
|
136 * @since S60Rel2.6 |
|
137 * @param aMessage The message associated to the event. |
|
138 */ |
|
139 void CancelNotificationL( const RMessage2& aMessage ); |
|
140 |
|
141 /** |
|
142 * Helper function for DispatchL(). |
|
143 * @since S60Rel2.6 |
|
144 * @param aMessage The message associated to the event. |
|
145 */ |
|
146 void RegisterL( const RMessage2& aMessage ); |
|
147 |
|
148 /** |
|
149 * Helper function for DispatchL(). |
|
150 * @since S60Rel2.6 |
|
151 * @param aMessage The message associated to the event. |
|
152 */ |
|
153 void UnRegisterL( const RMessage2& aMessage ); |
|
154 |
|
155 /** |
|
156 * Helper function for DispatchL(). |
|
157 * @since S60Rel2.6 |
|
158 * @param aMessage The message associated to the event. |
|
159 */ |
|
160 void RegisterURIL( const RMessage2& aMessage ); |
|
161 |
|
162 /** |
|
163 * Helper function for DispatchL(). |
|
164 * @since S60Rel2.6 |
|
165 * @param aMessage The message associated to the event. |
|
166 */ |
|
167 void UnRegisterURIL( const RMessage2& aMessage ); |
|
168 |
|
169 /** |
|
170 * NotifyL |
|
171 * |
|
172 * Helper function for sending a notification |
|
173 * |
|
174 * @since S60Rel2.6 |
|
175 * @param aMessage - The message to be sent |
|
176 * @param aFromQueue - ETrue if the message parameter is from the queue, |
|
177 EFalse if the message parameter is not from the queue |
|
178 */ |
|
179 void NotifyL(CDRMMessageStorage::TMessageData *aMessage, TBool aFromQueue ); |
|
180 |
|
181 /** |
|
182 * CanNotify |
|
183 * |
|
184 * Helper function for determining if we need to handle the notification |
|
185 * |
|
186 * @since S60Rel2.6 |
|
187 * @param aMessage - the message data of the message to be sent |
|
188 * @return ETrue if it can be sent, EFalse if it can't be send |
|
189 */ |
|
190 TBool CanNotify( CDRMMessageStorage::TMessageData *aMessage ); |
|
191 |
|
192 // Prohibit copy constructor. |
|
193 CDRMNotifierSession( const CDRMNotifierSession& ); |
|
194 // Prohibit assigment operator. |
|
195 CDRMNotifierSession& operator=( const CDRMNotifierSession& ); |
|
196 |
|
197 private: // Data |
|
198 NONSHARABLE_STRUCT( TContentData ) |
|
199 { |
|
200 HBufC8* iContentID; |
|
201 TDRMEventType iEventType; |
|
202 }; |
|
203 |
|
204 CDRMMessageStorage* iStorage; |
|
205 RPointerArray<TContentData> iContentIDList; |
|
206 RPointerArray<CDRMMessageStorage::TMessageData> iMessageQueue; |
|
207 TBool iIsListening; |
|
208 RMessage2 iListener; |
|
209 TBool iIsInStorage; |
|
210 |
|
211 }; |
|
212 |
|
213 |
|
214 #endif // CDRMNOTIFIERSESSION_H |
|
215 |
|
216 // End of File |