|
1 /* |
|
2 * Copyright (c) 2007-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 the License "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 * Server-side classes which are required to implement a streaming reference agent server. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 @released |
|
24 */ |
|
25 |
|
26 #ifndef SRASERVER_H |
|
27 #define SRASERVER_H |
|
28 |
|
29 |
|
30 #include <e32base.h> |
|
31 #include "sracommon.h" |
|
32 |
|
33 using namespace StreamAccess; |
|
34 |
|
35 // forward declarations |
|
36 class CSraServer; |
|
37 class CSraSession; |
|
38 class CSraRightsObject; |
|
39 class CSraProcessor; |
|
40 |
|
41 class CShutdownTimer : public CTimer |
|
42 /** |
|
43 An instance of this class is constructed with a delay period. |
|
44 If the object runs to completion, i.e. if it is not cancelled, then it stops |
|
45 the active scheduler, which has the effect of terminating the server. |
|
46 */ |
|
47 { |
|
48 public: |
|
49 static CShutdownTimer* NewL(TInt aDelay); |
|
50 void Restart(); |
|
51 |
|
52 private: |
|
53 CShutdownTimer(TInt aDelay); |
|
54 |
|
55 // implement CTimer |
|
56 virtual void RunL(); |
|
57 |
|
58 private: |
|
59 TInt iDelay; ///< Timer delay in microseconds. |
|
60 }; |
|
61 |
|
62 |
|
63 class CSraSession : public CSession2 |
|
64 /** |
|
65 Represents a session for a client thread on the server-side of the reference agent. |
|
66 A client thread can have multiple concurrent sessions with the reference agent server. |
|
67 */ |
|
68 { |
|
69 friend class CSraProcessor; |
|
70 public: |
|
71 static CSraSession* NewL(); |
|
72 ~CSraSession(); |
|
73 void CreateL(); |
|
74 |
|
75 // implement CSession2 |
|
76 virtual void ServiceL(const RMessage2& aMessage); |
|
77 // override CSession2 |
|
78 virtual void ServiceError(const RMessage2& aMessage, TInt aError); |
|
79 |
|
80 private: |
|
81 CSraSession(); |
|
82 CSraServer* GetServerHandle(); |
|
83 |
|
84 void GetAttributeL(const RMessage2& aMessage); |
|
85 void GetStringAttributeSizeL(const RMessage2& aMessage); |
|
86 void GetStringAttributeDataL(const RMessage2& aMessage); |
|
87 void GetPostDeliveryRightsL(const RMessage2& aMessage); |
|
88 void SetKeyStreamSinkL(const RMessage2& aMessage); |
|
89 void SetSdpMediaFieldL(const RMessage2& aMessage); |
|
90 void SetSdpDocumentL(const RMessage2& aMessage); |
|
91 |
|
92 void FindAndLoadRightsObjectL(const TDesC8& aCid); |
|
93 void VerifyRoL(); |
|
94 void StartProcessorL(); |
|
95 |
|
96 private: |
|
97 CSraProcessor* iProcessor; |
|
98 CKeyStreamSink* iKeyStreamSink; |
|
99 CSdpMediaField* iSdp; |
|
100 CSraRightsObject* iRo; |
|
101 CSdpDocument* iSdpDoc; |
|
102 /** |
|
103 A handle to a mutex which is used to signal the client that the key has been implemented. |
|
104 Not necessary in real-life agents and is present here only for testing. |
|
105 */ |
|
106 RMutex iMutex; |
|
107 }; |
|
108 |
|
109 |
|
110 class CSraServer : public CPolicyServer |
|
111 /** |
|
112 The reference agent server object allocates sessions. |
|
113 It also uses a shutdown timer to stop the server when |
|
114 there have been no open sessions for a set period. |
|
115 */ |
|
116 { |
|
117 friend class CSraSession; |
|
118 public: |
|
119 static CSraServer* NewLC(); |
|
120 ~CSraServer(); |
|
121 |
|
122 private: |
|
123 CSraServer(); |
|
124 void ConstructL(); |
|
125 void AddSession(); |
|
126 void RemoveSession(); |
|
127 // implement CServer2 |
|
128 virtual CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; |
|
129 |
|
130 private: |
|
131 CShutdownTimer* iShutdownTimer; |
|
132 const TVersion iVersion; |
|
133 /** Number of open sessions. Used to start and cancel the shutdown timer. */ |
|
134 TInt iSessionCount; |
|
135 /** File server handle. */ |
|
136 RFs iFs; |
|
137 }; |
|
138 |
|
139 |
|
140 /** |
|
141 The server is panicked with this category when it detects an invalid state. |
|
142 */ |
|
143 _LIT(KSraServerPanicCat, "SRA-Server"); |
|
144 |
|
145 /** The mime type of the post-acquisition rights object file. */ |
|
146 _LIT8(KPostAcquisitionRoMimeType,"application/x-sra.drm.postacqrights"); |
|
147 |
|
148 /** The mime type of the post-acquisition rights object file. */ |
|
149 _LIT8(KPostAcquisitionContentMimeType,"application/x-sra.drm.postacqcontent"); |
|
150 |
|
151 /** The content Id of the post-acquisition rights object file. */ |
|
152 _LIT8(KPostAcquisitionCid,"SamplePostAcquisitionCid"); |
|
153 |
|
154 /** The private folder of the Streaming Reference Agent. */ |
|
155 _LIT(KSraPrivateFolder,"!:\\private\\10285a1c\\"); |
|
156 |
|
157 /** |
|
158 Mutex name used to synchronize the reference agent with the test harness. |
|
159 @see CSraSession::iMutex |
|
160 */ |
|
161 _LIT(KSraMutexName, "MutexBtwTestHarnessAndRefAgent"); |
|
162 |
|
163 #endif |
|
164 |