|
1 /* |
|
2 * Copyright (c) 2005-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: DRM Play Server |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <e32svr.h> |
|
21 #include "DRMPlayClientServer.h" |
|
22 #include "DRMPlayServer.h" |
|
23 |
|
24 |
|
25 |
|
26 CDRMPlayServer::CDRMPlayServer(TInt aPriority) |
|
27 : CServer2(aPriority) |
|
28 { |
|
29 } |
|
30 |
|
31 |
|
32 // Create and start a new DRM play server. |
|
33 CDRMPlayServer* CDRMPlayServer::New() |
|
34 { |
|
35 CDRMPlayServer *pS=new CDRMPlayServer(EPriority); |
|
36 __ASSERT_ALWAYS(pS!=NULL,PanicServer(ESvrCreateServer)); |
|
37 __ASSERT_ALWAYS(pS->Start(KDRMPlayServerName)==KErrNone, PanicServer(ESvrCreateServer)); |
|
38 return pS; |
|
39 } |
|
40 |
|
41 |
|
42 // Create a new server session. |
|
43 CSession2 *CDRMPlayServer::NewSessionL(const TVersion& aVersion,const RMessage2& aMessage ) const |
|
44 { |
|
45 // check we're the right version |
|
46 TVersion v(KDRMPlayServMajorVersionNumber,KDRMPlayServMinorVersionNumber,KDRMPlayServBuildVersionNumber); |
|
47 if (!User::QueryVersionSupported(v,aVersion)) |
|
48 User::Leave(KErrNotSupported); |
|
49 // make new session |
|
50 return CDRMPlayServerSession::NewL(const_cast<CDRMPlayServer*>(this), aMessage); |
|
51 } |
|
52 |
|
53 CDRMPlayServer::~CDRMPlayServer() |
|
54 { |
|
55 |
|
56 } |
|
57 |
|
58 |
|
59 // Panic the server |
|
60 GLDEF_C void PanicServer(TDRMPlayServPanic aPanic) |
|
61 { |
|
62 _LIT(KTxtServerPanic,"DRM Play server panic"); |
|
63 User::Panic(KTxtServerPanic,aPanic); |
|
64 } |
|
65 |
|
66 |
|
67 static void StartDRMPlayServerL() |
|
68 // Perform all server initialisation, in particular creation of the |
|
69 // scheduler and server and then run the scheduler |
|
70 // |
|
71 { |
|
72 |
|
73 |
|
74 |
|
75 // Naming the server thread after the server helps to debug panics |
|
76 |
|
77 User::LeaveIfError(User::RenameThread(KDRMPlayServerName)); |
|
78 |
|
79 // Create and install the active scheduler we need |
|
80 CActiveScheduler* scheduler = new(ELeave)CActiveScheduler; |
|
81 CActiveScheduler::Install(scheduler); |
|
82 |
|
83 // create the server |
|
84 CDRMPlayServer* server = CDRMPlayServer::New(); |
|
85 |
|
86 // Initialisation complete, now signal the client |
|
87 RProcess::Rendezvous(KErrNone); |
|
88 |
|
89 // Start the scheduler and wait for client requests |
|
90 CActiveScheduler::Start(); |
|
91 |
|
92 // Cleanup the server and scheduler |
|
93 CActiveScheduler::Install(NULL); |
|
94 delete scheduler; |
|
95 delete server; |
|
96 } |
|
97 |
|
98 TInt E32Main() |
|
99 // |
|
100 // Server process entry-point |
|
101 // Recover the startup parameters and run the server |
|
102 // |
|
103 { |
|
104 __UHEAP_MARK; |
|
105 // |
|
106 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
107 TInt r=KErrNoMemory; |
|
108 if (cleanup) |
|
109 { |
|
110 TRAP(r,StartDRMPlayServerL()); |
|
111 delete cleanup; |
|
112 } |
|
113 // |
|
114 __UHEAP_MARKEND; |
|
115 return r; |
|
116 } |
|
117 |
|
118 // End of file |