1 /* |
|
2 * Copyright (c) 2006-2007 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: Thumbnail Manager IAD Restart |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <e32std.h> |
|
21 #include <e32property.h> |
|
22 #include "thumbnaillog.h" |
|
23 |
|
24 #include "thumbnailmanagerconstants.h" |
|
25 #include "OstTraceDefinitions.h" |
|
26 #ifdef OST_TRACE_COMPILER_IN_USE |
|
27 #include "tmiadrestartTraces.h" |
|
28 #endif |
|
29 |
|
30 LOCAL_C void MainL() |
|
31 { |
|
32 // delay so that cenrep has time to read new config |
|
33 TN_DEBUG1( "MainL() after" ); |
|
34 OstTrace0( TRACE_NORMAL, _MAINL, "::MainL - after" ); |
|
35 |
|
36 User::After(5000000); |
|
37 |
|
38 TInt res( KErrNone ); |
|
39 RProcess process; |
|
40 TFullName name; |
|
41 |
|
42 // find and terminate Thumb AG Daemon |
|
43 TN_DEBUG1( "MainL() KTAGDaemonProcess find" ); |
|
44 OstTrace0( TRACE_NORMAL, DUP1__MAINL, "::MainL - find" ); |
|
45 TFindProcess findProcess( KTAGDaemonProcess ); |
|
46 |
|
47 if ( findProcess.Next(name) == KErrNone ) |
|
48 { |
|
49 res = process.Open(name); |
|
50 TN_DEBUG2( "MainL() KTAGDaemonProcess open res = %d", res ); |
|
51 OstTrace1( TRACE_NORMAL, DUP2__MAINL, "::MainL;res=%d - open res", res ); |
|
52 |
|
53 // logon to get termination signal |
|
54 TRequestStatus status; |
|
55 TN_DEBUG1( "MainL() KTAGDaemonProcess logon" ); |
|
56 OstTrace0( TRACE_NORMAL, DUP3__MAINL, "::MainL - logon" ); |
|
57 process.Logon(status); |
|
58 |
|
59 // shutdown using P&S key |
|
60 TN_DEBUG2( "MainL() KTAGDaemonProcess Set = %d", res ); |
|
61 OstTrace1( TRACE_NORMAL, DUP4__MAINL, "::MainL - Set = res;res=%d", res ); |
|
62 res = RProperty::Set(KTAGDPSNotification,KShutdown,1); |
|
63 |
|
64 // blocks here until thread is terminated |
|
65 TN_DEBUG1( "MainL() KTAGDaemonProcess wait" ); |
|
66 OstTrace0( TRACE_NORMAL, DUP5__MAINL, "::MainL - KTAGDaemonProcess wait" ); |
|
67 User::WaitForRequest(status); |
|
68 |
|
69 // reset key |
|
70 TN_DEBUG1( "MainL() KTAGDaemonProcess reset" ); |
|
71 OstTrace0( TRACE_NORMAL, DUP6__MAINL, "::MainL - KTAGDaemonProcess reset" ); |
|
72 res = RProperty::Set(KTAGDPSNotification, KShutdown, 0); |
|
73 |
|
74 TN_DEBUG1( "MainL() KTAGDaemonProcess close" ); |
|
75 OstTrace0( TRACE_NORMAL, DUP7__MAINL, "::MainL - close" ); |
|
76 process.Close(); |
|
77 } |
|
78 |
|
79 // find and terminate Thumbnail Server |
|
80 TFindProcess findProcess2( KThumbnailServerProcess ); |
|
81 TN_DEBUG1( "MainL() KThumbnailServerProcess find" ); |
|
82 OstTrace0( TRACE_NORMAL, DUP8__MAINL, "::MainL - find" ); |
|
83 if ( findProcess2.Next(name) == KErrNone ) |
|
84 { |
|
85 res = process.Open(name); |
|
86 TN_DEBUG2( "MainL() KThumbnailServerProcess open res = %d", res ); |
|
87 OstTrace1( TRACE_NORMAL, DUP9__MAINL, "::MainL - KThumbnailServerProcess open;res=%d", res ); |
|
88 |
|
89 // logon to get termination signal |
|
90 TRequestStatus status; |
|
91 TN_DEBUG1( "MainL() KThumbnailServerProcess logon" ); |
|
92 OstTrace0( TRACE_NORMAL, DUP10__MAINL, "::MainL - KThumbnailServerProcess logon" ); |
|
93 process.Logon(status); |
|
94 |
|
95 // shutdown using P&S key |
|
96 TN_DEBUG2( "MainL() KThumbnailServerProcess Set res = %d", res ); |
|
97 OstTrace1( TRACE_NORMAL, DUP11__MAINL, "::MainL - KThumbnailServerProcess Set;res=%d", res ); |
|
98 res = RProperty::Set(KTMPSNotification,KShutdown,1); |
|
99 |
|
100 // blocks here until thread is terminated |
|
101 TN_DEBUG1( "MainL() KThumbnailServerProcess wait" ); |
|
102 OstTrace0( TRACE_NORMAL, DUP12__MAINL, "::MainL - KThumbnailServerProcess wait" ); |
|
103 User::WaitForRequest(status); |
|
104 |
|
105 // reset key |
|
106 TN_DEBUG2( "MainL() KThumbnailServerProcess reset res = %d", res ); |
|
107 OstTrace1( TRACE_NORMAL, DUP13__MAINL, "::MainL;res=%d - KThumbnailServerProcess reset", res ); |
|
108 res = RProperty::Set(KTMPSNotification, KShutdown, 0); |
|
109 |
|
110 TN_DEBUG1( "MainL() KThumbnailServerProcess close" ); |
|
111 OstTrace0( TRACE_NORMAL, DUP14__MAINL, "::MainL - close" ); |
|
112 process.Close(); |
|
113 } |
|
114 |
|
115 // delay just in case old daemon hasn't died yet |
|
116 TN_DEBUG1( "MainL() after" ); |
|
117 User::After(2500000); |
|
118 |
|
119 // start new ThumbAGDaemon |
|
120 RProcess server; |
|
121 TInt retryCount = 0; |
|
122 |
|
123 // Create the server process |
|
124 // KNullDesC param causes server's E32Main() to be run |
|
125 TN_DEBUG2( "MainL() KTAGDaemonExe create res = %d", res ); |
|
126 OstTrace1( TRACE_NORMAL, DUP15__MAINL, "::MainL - KTAGDaemonExe create res;res=%d", res ); |
|
127 res = server.Create( KTAGDaemonExe, KNullDesC ); |
|
128 |
|
129 // try again 3 times if fails |
|
130 while ( res != KErrNone) |
|
131 { |
|
132 TN_DEBUG1( "MainL() KTAGDaemonExe retry" ); |
|
133 OstTrace0( TRACE_NORMAL, DUP16__MAINL, "::MainL- KTAGDaemonExe retry" ); |
|
134 if (retryCount > 2) |
|
135 { |
|
136 TN_DEBUG1( "MainL() KTAGDaemonExe retry > 2" ); |
|
137 OstTrace0( TRACE_NORMAL, DUP17__MAINL, "::MainL - KTAGDaemonExe retry > 2" ); |
|
138 return; |
|
139 } |
|
140 |
|
141 TN_DEBUG1( "MainL() after" ); |
|
142 OstTrace0( TRACE_NORMAL, DUP18__MAINL, "::MainL - after" ); |
|
143 User::After(2500000); |
|
144 TN_DEBUG2( "MainL() KTAGDaemonExe create res = %d", res ); |
|
145 OstTrace1( TRACE_NORMAL, DUP19__MAINL, "::MainL - KTAGDaemonExe create;res=%d", res ); |
|
146 res = server.Create( KTAGDaemonExe, KNullDesC ); |
|
147 retryCount++; |
|
148 } |
|
149 |
|
150 // Process created successfully |
|
151 TRequestStatus status; |
|
152 TN_DEBUG1( "MainL() Rendezvous" ); |
|
153 OstTrace0( TRACE_NORMAL, DUP20__MAINL, "::MainL - Rendezvous" ); |
|
154 server.Rendezvous( status ); |
|
155 TN_DEBUG1( "MainL() Resume" ); |
|
156 OstTrace0( TRACE_NORMAL, DUP21__MAINL, "::MainL - resume" ); |
|
157 server.Resume(); // start it going |
|
158 |
|
159 |
|
160 // Wait until the completion of the server creation |
|
161 TN_DEBUG1( "MainL() wait" ); |
|
162 OstTrace0( TRACE_NORMAL, DUP22__MAINL, "::MainL - wait" ); |
|
163 User::WaitForRequest( status ); |
|
164 TN_DEBUG1( "MainL() wait done" ); |
|
165 OstTrace0( TRACE_NORMAL, DUP23__MAINL, "::MainL - wait done" ); |
|
166 |
|
167 // Server created successfully |
|
168 server.Close(); // we're no longer interested in the other process |
|
169 } |
|
170 |
|
171 GLDEF_C TInt E32Main() |
|
172 { |
|
173 // Create cleanup stack |
|
174 __UHEAP_MARK; |
|
175 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
176 |
|
177 // Run application code inside TRAP harness |
|
178 TInt err = KErrNone; |
|
179 TRAP(err, MainL()); |
|
180 |
|
181 delete cleanup; |
|
182 cleanup = NULL; |
|
183 __UHEAP_MARKEND; |
|
184 return err; |
|
185 } |
|
186 |
|
187 // End of file |
|