1 /* |
|
2 * Copyright (c) 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "musmanagerserverstarter.h" |
|
21 #include "musmanageripccommon.h" |
|
22 #include "muslogger.h" |
|
23 |
|
24 // ---------------------------------------------------------------------------- |
|
25 // MusManagerServerStarter::Start |
|
26 // ---------------------------------------------------------------------------- |
|
27 // |
|
28 TInt MusManagerServerStarter::Start () |
|
29 { |
|
30 MUS_LOG( "mus: [MUSCLI] -> MusManagerServerStarter::Start()" ); |
|
31 TInt err( KErrNone ); |
|
32 |
|
33 if( !Started() ) |
|
34 { |
|
35 RSemaphore semaphore; |
|
36 err = semaphore.CreateGlobal( KMusManagerServerSemaphoreName ,0 ); |
|
37 if ( err != KErrNone ) |
|
38 { |
|
39 MUS_LOG1( "mus: [MUSCLI] <- MusManagerServerStarter::Start( %d )", |
|
40 err ); |
|
41 return err; |
|
42 } |
|
43 |
|
44 err = CreateServerProcess( semaphore ); |
|
45 semaphore.Close (); |
|
46 } |
|
47 MUS_LOG( "mus: [MUSCLI] <- MusManagerServerStarter::Start()" ); |
|
48 return err; |
|
49 } |
|
50 |
|
51 // ---------------------------------------------------------------------------- |
|
52 // MusManagerServerStarter::Started |
|
53 // ---------------------------------------------------------------------------- |
|
54 // |
|
55 TBool MusManagerServerStarter::Started() |
|
56 { |
|
57 MUS_LOG( "mus: [MUSCLI] -> MusManagerServerStarter::Start()" ); |
|
58 TFindServer findServer( KMusManagerServerName ); |
|
59 TFullName name; |
|
60 if (findServer.Next(name) == KErrNone) |
|
61 { |
|
62 MUS_LOG( "mus: [MUSCLI] <- MusManagerServerStarter::Start()" ); |
|
63 return ETrue; // Server already running |
|
64 } |
|
65 MUS_LOG( "mus: [MUSCLI] <- MusManagerServerStarter::Start()" ); |
|
66 return EFalse; |
|
67 } |
|
68 |
|
69 // ---------------------------------------------------------------------------- |
|
70 // MusManagerServerStarter::CreateServerProcess |
|
71 // ---------------------------------------------------------------------------- |
|
72 // |
|
73 TInt MusManagerServerStarter::CreateServerProcess( RSemaphore& aSemaphore ) |
|
74 { |
|
75 TInt err = KErrNone; |
|
76 const TUidType serverUid( KNullUid, KNullUid, KServerUid3 ); |
|
77 RProcess server; |
|
78 err = server.Create( KMusManagerServerName, KNullDesC() ,serverUid ); |
|
79 if ( err ) |
|
80 { |
|
81 return err; |
|
82 } |
|
83 server.Resume(); |
|
84 aSemaphore.Wait(); |
|
85 TInt exitReason = server.ExitReason(); |
|
86 server.Close(); |
|
87 return exitReason; |
|
88 } |
|
89 |
|
90 // End of File |
|