|
1 /* |
|
2 * Copyright (c) 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 "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: Helper application to stop servers for IAD upgrade |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32base.h> |
|
19 #include <e32std.h> |
|
20 #include <e32property.h> |
|
21 |
|
22 #include "mdscommoninternal.h" |
|
23 #include "iadstop.h" |
|
24 |
|
25 // Print macro |
|
26 #ifdef _DEBUG |
|
27 #include <e32svr.h> |
|
28 #define PRINT(x) RDebug::Print x |
|
29 #else |
|
30 #define PRINT(x) |
|
31 #endif |
|
32 |
|
33 LOCAL_C void MainL() |
|
34 { |
|
35 |
|
36 TInt res( KErrNone ); |
|
37 RProcess process; |
|
38 TFullName name; |
|
39 |
|
40 // define P&S property types |
|
41 res = RProperty::Define(KMdSPSShutdown,KShutdown,RProperty::EInt,KAllowAllPolicy,KPowerMgmtPolicy); |
|
42 |
|
43 PRINT((_L("IADStop - terminate Harvester server, res = %d"), res )); |
|
44 |
|
45 // find and terminate Harvester Server |
|
46 TFindProcess findProcess2( KHarvesterServerProcess ); |
|
47 if ( findProcess2.Next(name) == KErrNone ) |
|
48 { |
|
49 |
|
50 res = process.Open(name); |
|
51 |
|
52 // logon to get termination signal |
|
53 TRequestStatus status; |
|
54 process.Logon(status); |
|
55 |
|
56 // shutdown using P&S key |
|
57 TInt error = RProperty::Set(KHarvesterPSShutdown, KShutdown, 1); |
|
58 |
|
59 PRINT((_L("IADStop - set property, error = %d"), error )); |
|
60 |
|
61 // blocks here until thread is terminated |
|
62 User::WaitForRequest(status); |
|
63 |
|
64 PRINT(_L("IADStop - Harvester server terminated")); |
|
65 |
|
66 process.Close(); |
|
67 } |
|
68 |
|
69 PRINT(_L("IADStop - terminate MdS server")); |
|
70 |
|
71 // find and terminate Mds Server |
|
72 TFindProcess findProcess( KMdSServerProcess ); |
|
73 if ( findProcess.Next(name) == KErrNone ) |
|
74 { |
|
75 PRINT(_L("IADStop - found MdS server")); |
|
76 |
|
77 res = process.Open(name); |
|
78 |
|
79 // logon to get termination signal |
|
80 TRequestStatus status; |
|
81 process.Logon(status); |
|
82 |
|
83 // shutdown using P&S key |
|
84 RProperty::Set(KMdSPSShutdown, KShutdown, 1); |
|
85 |
|
86 // blocks here until thread is terminated |
|
87 User::WaitForRequest(status); |
|
88 |
|
89 PRINT(_L("IADStop - MdS server terminated")); |
|
90 |
|
91 process.Close(); |
|
92 } |
|
93 |
|
94 else |
|
95 { |
|
96 PRINT(_L("IADStop - terminate Thumb AG Daemon")); |
|
97 |
|
98 // Kill Thumb AG Daemon !!! |
|
99 // find and terminate Mds Server |
|
100 TFindProcess findProcess3( KTAGDaemonProcess ); |
|
101 if ( findProcess3.Next(name) == KErrNone ) |
|
102 { |
|
103 PRINT(_L("IADStop - found thumb daemon")); |
|
104 |
|
105 res = process.Open(name); |
|
106 |
|
107 // logon to get termination signal |
|
108 TRequestStatus status; |
|
109 process.Logon(status); |
|
110 |
|
111 // shutdown using P&S key |
|
112 RProperty::Set(KMdSPSShutdown, KShutdown, 1); |
|
113 |
|
114 // blocks here until thread is terminated |
|
115 User::WaitForRequest(status); |
|
116 |
|
117 PRINT(_L("IADStop - thumb daemon terminated")); |
|
118 |
|
119 process.Close(); |
|
120 } |
|
121 } |
|
122 |
|
123 PRINT(_L("IADStop - terminate MdS watchdog")); |
|
124 |
|
125 // find and terminate mds watchdog |
|
126 TFindProcess findProcess4( KWatchdogProcess ); |
|
127 if ( findProcess4.Next(name) == KErrNone ) |
|
128 { |
|
129 |
|
130 res = process.Open(name); |
|
131 |
|
132 // logon to get termination signal |
|
133 TRequestStatus status; |
|
134 process.Logon(status); |
|
135 |
|
136 // shutdown using P&S key |
|
137 TInt error = RProperty::Set(KWatchdogPSShutdown, KShutdown, 1); |
|
138 |
|
139 PRINT((_L("IADStop - set property, error = %d"), error )); |
|
140 |
|
141 // blocks here until thread is terminated |
|
142 User::WaitForRequest(status); |
|
143 |
|
144 PRINT(_L("IADStop - MdS watchdog terminated")); |
|
145 |
|
146 process.Close(); |
|
147 } |
|
148 } |
|
149 |
|
150 GLDEF_C TInt E32Main() |
|
151 { |
|
152 // Create cleanup stack |
|
153 __UHEAP_MARK; |
|
154 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
155 |
|
156 // Run application code inside TRAP harness |
|
157 TInt err = KErrNone; |
|
158 TRAP(err, MainL()); |
|
159 |
|
160 delete cleanup; |
|
161 __UHEAP_MARKEND; |
|
162 return err; |
|
163 } |
|
164 |
|
165 // End of file |