|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent - Internal Symbian test code |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 #include "messageservserver.h" |
|
25 #include "messageservsession.h" |
|
26 |
|
27 |
|
28 /** |
|
29 Constructor |
|
30 */ |
|
31 CMessageServServer::CMessageServServer(TInt aPriority) |
|
32 : CServer2(aPriority) |
|
33 { |
|
34 __DECLARE_NAME(_S("CMessageServServer")); |
|
35 } |
|
36 |
|
37 |
|
38 /** |
|
39 Auxiliary function for TestCaseID TPACKAGESTARTER-doTestStepL |
|
40 |
|
41 The method creates and start a the message server by invoking |
|
42 CServer::Start(). |
|
43 |
|
44 */ |
|
45 void CMessageServServer::New(MMessageProvider *aMessageProvider) |
|
46 { |
|
47 CMessageServServer *pS=new CMessageServServer(EPriority); |
|
48 __ASSERT_ALWAYS(pS!=NULL,PanicServer(ESvrCreateServer)); |
|
49 HBufC *pN=(&KMessageServerName)->Alloc(); |
|
50 __ASSERT_ALWAYS(pN!=NULL,PanicServer(ESvrCreateServer)); |
|
51 |
|
52 pS->iMessageProvider = aMessageProvider; |
|
53 |
|
54 TInt r=pS->Start(*pN); |
|
55 __ASSERT_ALWAYS(r==KErrNone,PanicServer(ESvrStartServer)); |
|
56 } |
|
57 |
|
58 |
|
59 /** |
|
60 Auxiliary function for TestCaseID TPACKAGESTARTER-doTestStepL. |
|
61 |
|
62 This method identifies the client thread. It then creates an returns a server |
|
63 session for the client. The new server session is created by calling |
|
64 CMessageServSession::NewL(). |
|
65 |
|
66 */ |
|
67 CSession2 *CMessageServServer::NewSessionL(const TVersion &aVersion, const RMessage2& ) const |
|
68 { |
|
69 // check we're the right version |
|
70 TVersion v(KMessageServMajorVersionNumber,KMessageServMinorVersionNumber,KMessageServBuildVersionNumber); |
|
71 if (!User::QueryVersionSupported(v,aVersion)) |
|
72 User::Leave(KErrNotSupported); |
|
73 // make new session |
|
74 //RThread thread;// = Message().Client(); |
|
75 //aMessage.Client(thread); |
|
76 |
|
77 return CMessageServSession::NewL((CMessageServServer*)this); |
|
78 } |
|
79 |
|
80 /** |
|
81 |
|
82 Auxiliary function for TestCaseID TPACKAGESTARTER-doTestStepL |
|
83 |
|
84 The method creates & installs an active scheduler for the server thread. It |
|
85 then creates & a message server instance by calling CMessageServServer::New(). |
|
86 The message server is then set ready to run by invoking RSemaphore::Signal(). |
|
87 |
|
88 */ |
|
89 EXPORT_C TInt CMessageServServer::ThreadFunction(TAny* anArg) |
|
90 { |
|
91 MMessageProvider *theProvider = (MMessageProvider*) anArg; |
|
92 |
|
93 // convert argument into semaphore reference |
|
94 RSemaphore& semaphore= theProvider->Semaphore(); |
|
95 |
|
96 // start scheduler and server |
|
97 CActiveScheduler *pA=new CActiveScheduler; |
|
98 __ASSERT_ALWAYS(pA!=NULL,PanicServer(EMainSchedulerError)); |
|
99 CActiveScheduler::Install(pA); |
|
100 CMessageServServer::New(theProvider); |
|
101 // signal that we've started |
|
102 semaphore.Signal(); |
|
103 // start fielding requests from clients |
|
104 CActiveScheduler::Start(); |
|
105 // finished |
|
106 |
|
107 //Adding a delay here seems to fix the crash on multicore SMP naviengine |
|
108 User::After(200000); |
|
109 |
|
110 return(KErrNone); |
|
111 } |
|
112 |
|
113 /** |
|
114 Auxiliary function for TestCaseID TPACKAGESTARTER-doTestStepL |
|
115 |
|
116 This method is used to panic the server thread. |
|
117 |
|
118 */ |
|
119 GLDEF_C void PanicServer(TMessageServPanic aPanic) |
|
120 { |
|
121 _LIT(KTxtServerPanic,"server panic"); |
|
122 User::Panic(KTxtServerPanic,aPanic); |
|
123 } |
|
124 |