|
1 // Copyright (c) 1999-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 #include <ascliclientutils.h> |
|
17 |
|
18 // System includes |
|
19 #include <e32math.h> |
|
20 |
|
21 // User includes |
|
22 #include <asclidefinitions.h> |
|
23 |
|
24 // |
|
25 // ----> AlarmClientUtils (source) |
|
26 // |
|
27 |
|
28 /* |
|
29 * Panic the client |
|
30 */ |
|
31 void AlarmClientUtils::Panic(TAlarmClientPanic aPanic) |
|
32 { |
|
33 _LIT(KAlarmServerClientPanic, "ALMSRVCLI"); |
|
34 User::Panic(KAlarmServerClientPanic, aPanic); |
|
35 } |
|
36 |
|
37 |
|
38 /* |
|
39 * Panic the client, indicating some form of logic error or terminal |
|
40 * fault. |
|
41 */ |
|
42 void AlarmClientUtils::Fault(TAlarmClientFault aFault) |
|
43 { |
|
44 _LIT(KAlarmServerClientFault, "ALMSRVCLIFAULT"); |
|
45 User::Panic(KAlarmServerClientFault, aFault); |
|
46 } |
|
47 |
|
48 |
|
49 EXPORT_C TInt AlarmClientUtils::StartAlarmServer() |
|
50 /** Starts the alarm server. |
|
51 |
|
52 @return KErrNone if successful, KErrAlreadyExists if the server is already |
|
53 running, otherwise a system-wide error. */ |
|
54 { |
|
55 // |
|
56 // EPOC is easy, we just create a new server process. Simultaneous launching |
|
57 // of two such processes should be detected when the second one attempts to |
|
58 // create the server object, failing with KErrAlreadyExists. |
|
59 // |
|
60 RProcess server; |
|
61 TInt ret = server.Create(ASCliDefinitions::ServerImageName(), KNullDesC, ASCliDefinitions::ServerUidType()); |
|
62 |
|
63 // Did we manage to create the thread/process? |
|
64 if (ret != KErrNone) |
|
65 return ret; |
|
66 |
|
67 // Wait to see if the thread/process died during construction |
|
68 TRequestStatus serverDiedRequestStatus; |
|
69 server.Rendezvous(serverDiedRequestStatus); |
|
70 |
|
71 // do we have to abort? |
|
72 if(serverDiedRequestStatus != KRequestPending) |
|
73 { |
|
74 server.Kill(0); // abort the sartup here |
|
75 } |
|
76 else |
|
77 { |
|
78 server.Resume(); // start server |
|
79 } |
|
80 |
|
81 User::WaitForRequest(serverDiedRequestStatus); |
|
82 // determine the reason for the server exit |
|
83 TInt exitReason =(server.ExitType()==EExitPanic) ? KErrGeneral : serverDiedRequestStatus.Int(); |
|
84 server.Close(); |
|
85 return exitReason; |
|
86 } |