|
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 |
|
23 #include "thumbnailmanagerconstants.h" |
|
24 |
|
25 LOCAL_C void MainL() |
|
26 { |
|
27 // delay so that cenrep has time to read new config |
|
28 User::After(5000000); |
|
29 |
|
30 TInt res( KErrNone ); |
|
31 RProcess process; |
|
32 TFullName name; |
|
33 |
|
34 // find and terminate Thumb AG Daemon |
|
35 TFindProcess findProcess( KTAGDaemonProcess ); |
|
36 if ( findProcess.Next(name) == KErrNone ) |
|
37 { |
|
38 res = process.Open(name); |
|
39 |
|
40 // logon to get termination signal |
|
41 TRequestStatus status; |
|
42 process.Logon(status); |
|
43 |
|
44 // shutdown using P&S key |
|
45 RProperty::Set(KTAGDPSNotification,KShutdown,1); |
|
46 |
|
47 // blocks here until thread is terminated |
|
48 User::WaitForRequest(status); |
|
49 |
|
50 // reset key |
|
51 RProperty::Set(KTAGDPSNotification,KShutdown,0); |
|
52 |
|
53 process.Close(); |
|
54 } |
|
55 |
|
56 // find and terminate Thumbnail Server |
|
57 TFindProcess findProcess2( KThumbnailServerProcess ); |
|
58 if ( findProcess2.Next(name) == KErrNone ) |
|
59 { |
|
60 res = process.Open(name); |
|
61 |
|
62 // logon to get termination signal |
|
63 TRequestStatus status; |
|
64 process.Logon(status); |
|
65 |
|
66 // shutdown using P&S key |
|
67 RProperty::Set(KTMPSNotification,KShutdown,1); |
|
68 |
|
69 // blocks here until thread is terminated |
|
70 User::WaitForRequest(status); |
|
71 |
|
72 // reset key |
|
73 RProperty::Set(KTMPSNotification,KShutdown,0); |
|
74 |
|
75 process.Close(); |
|
76 } |
|
77 |
|
78 // delay just in case old daemon hasn't died yet |
|
79 User::After(2500000); |
|
80 |
|
81 // start new ThumbAGDaemon |
|
82 RProcess server; |
|
83 TInt retryCount = 0; |
|
84 |
|
85 // Create the server process |
|
86 // KNullDesC param causes server's E32Main() to be run |
|
87 res = server.Create( KTAGDaemonExe, KNullDesC ); |
|
88 |
|
89 // try again 3 times if fails |
|
90 while ( res != KErrNone) |
|
91 { |
|
92 if (retryCount > 2) |
|
93 { |
|
94 return; |
|
95 } |
|
96 |
|
97 User::After(2500000); |
|
98 res = server.Create( KTAGDaemonExe, KNullDesC ); |
|
99 |
|
100 retryCount++; |
|
101 } |
|
102 |
|
103 // Process created successfully |
|
104 TRequestStatus status; |
|
105 server.Rendezvous( status ); |
|
106 server.Resume(); // start it going |
|
107 |
|
108 // Wait until the completion of the server creation |
|
109 User::WaitForRequest( status ); |
|
110 |
|
111 // Server created successfully |
|
112 server.Close(); // we're no longer interested in the other process |
|
113 } |
|
114 |
|
115 GLDEF_C TInt E32Main() |
|
116 { |
|
117 // Create cleanup stack |
|
118 __UHEAP_MARK; |
|
119 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
120 |
|
121 // Run application code inside TRAP harness |
|
122 TInt err = KErrNone; |
|
123 TRAP(err, MainL()); |
|
124 |
|
125 delete cleanup; |
|
126 __UHEAP_MARKEND; |
|
127 return err; |
|
128 } |
|
129 |
|
130 // End of file |