|
1 /* |
|
2 * Copyright (c) 2004-2008 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: Observes for changes in skin files. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "aknssrvinstallobserver.h" |
|
20 #include <bautils.h> |
|
21 |
|
22 _LIT(KAknsSrvSkinRootPath,"?:\\private\\10207114\\import\\"); |
|
23 |
|
24 // ----------------------------------------------------------------------------- |
|
25 // CAknsSrvInstallObserver::NewL |
|
26 // |
|
27 // (other items were commented in a header). |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CAknsSrvFileObserver* CAknsSrvFileObserver::NewL(MAknsSrvFileObserver* aObserver) |
|
31 { |
|
32 CAknsSrvFileObserver* self = new (ELeave) CAknsSrvFileObserver(aObserver); |
|
33 CleanupStack::PushL(self); |
|
34 self->ConstructL(); |
|
35 CleanupStack::Pop( self ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 CAknsSrvFileObserver* CAknsSrvFileObserver::NewL(MAknsSrvFileObserver* aObserver, const TDesC& aFilename) |
|
40 { |
|
41 CAknsSrvFileObserver* self = new (ELeave) CAknsSrvFileObserver(aObserver); |
|
42 CleanupStack::PushL(self); |
|
43 self->ConstructL(); |
|
44 self->iFilename = aFilename.AllocL(); |
|
45 CleanupStack::Pop( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 CAknsSrvFileObserver* CAknsSrvFileObserver::NewL( |
|
50 MAknsSrvFileObserver* aObserver, TAknsSrvFileSrvObserverType aObserverType, |
|
51 const TDesC& aFilename ) |
|
52 { |
|
53 CAknsSrvFileObserver* self = |
|
54 new (ELeave) CAknsSrvFileObserver( aObserver ); |
|
55 CleanupStack::PushL(self); |
|
56 self->ConstructL(); |
|
57 self->iFilename = aFilename.AllocL(); |
|
58 self->iType = aObserverType; |
|
59 CleanupStack::Pop( self ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CAknsSrvInstallObserver::ConstructL |
|
65 // |
|
66 // (other items were commented in a header). |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void CAknsSrvFileObserver::ConstructL() |
|
70 { |
|
71 User::LeaveIfError(iFsSession.Connect()); |
|
72 CActiveScheduler::Add(this); |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CAknsSrvSkinInstallObserver::C++ Constructor |
|
77 // |
|
78 // (other items were commented in a header). |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 CAknsSrvFileObserver::CAknsSrvFileObserver(MAknsSrvFileObserver* aObserver ) : |
|
82 CActive(CActive::EPriorityIdle) |
|
83 { |
|
84 iObserver = aObserver; |
|
85 iType = EAknsSrvNotDefined; |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CAknsSrvSkinInstallObserver::C++ Desctructor |
|
90 // |
|
91 // (other items were commented in a header). |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 CAknsSrvFileObserver::~CAknsSrvFileObserver() |
|
95 { |
|
96 Cancel(); |
|
97 iFsSession.NotifyChangeCancel(); |
|
98 iFsSession.Close(); |
|
99 delete iFilename; |
|
100 iFilename = NULL; |
|
101 iObserver = NULL; |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CAknsSrvSkinInstallObserver::IssueRequest |
|
106 // |
|
107 // (other items were commented in a header). |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CAknsSrvFileObserver::IssueRequest() |
|
111 { |
|
112 if ( !IsActive() && iObserver ) |
|
113 { |
|
114 if ( iFilename ) |
|
115 { |
|
116 if ( iType == EAknsSrvFileObsSlidesetWallpaper ) |
|
117 { |
|
118 iFsSession.NotifyChange( ENotifyWrite, iStatus, *iFilename ); |
|
119 } |
|
120 else |
|
121 { |
|
122 iFsSession.NotifyChange(ENotifyFile, iStatus, *iFilename); |
|
123 } |
|
124 } |
|
125 else |
|
126 { |
|
127 iFsSession.NotifyChange( ENotifyDir, iStatus, KAknsSrvSkinRootPath ); |
|
128 } |
|
129 |
|
130 SetActive(); |
|
131 } |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CAknsSrvInstallObserver::RunL |
|
136 // |
|
137 // (other items were commented in a header). |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 void CAknsSrvFileObserver::RunL() |
|
141 { |
|
142 iFsSession.NotifyChangeCancel(); |
|
143 |
|
144 // Nobody is listening, so better stop. |
|
145 if ( !iObserver ) |
|
146 { |
|
147 return; |
|
148 } |
|
149 |
|
150 if (iFilename) |
|
151 { |
|
152 if (BaflUtils::FileExists(iFsSession, *iFilename)) |
|
153 { |
|
154 if ( iType == EAknsSrvFileObsSlidesetWallpaper ) |
|
155 { |
|
156 // Slideset file has changed. |
|
157 iObserver->SlideSetModifiedL(); |
|
158 } |
|
159 IssueRequest(); |
|
160 return; |
|
161 } |
|
162 else // the file has been deleted / renamed |
|
163 { |
|
164 iObserver->WallpaperLost(); |
|
165 } |
|
166 } |
|
167 else |
|
168 { |
|
169 // Since system immediately notifies of changes, let's wait awhile so that all operations on |
|
170 // directory have finished. |
|
171 User::After( 1000000 ); |
|
172 iObserver->NewSkinPackagesInstalled(); |
|
173 IssueRequest(); |
|
174 } |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CAknsSrvInstallObserver::DoCancel |
|
179 // |
|
180 // (other items were commented in a header). |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 void CAknsSrvFileObserver::DoCancel() |
|
184 { |
|
185 iFsSession.NotifyChangeCancel(); |
|
186 } |
|
187 |
|
188 // End of File |
|
189 |