71 // |
71 // |
72 CDRMActiveOperation::~CDRMActiveOperation() |
72 CDRMActiveOperation::~CDRMActiveOperation() |
73 { |
73 { |
74 // Close the stream |
74 // Close the stream |
75 iFileStream.Close(); |
75 iFileStream.Close(); |
76 |
76 |
77 if( iFileName ) |
77 if( iFileName ) |
78 { |
78 { |
79 if( iFileServer ) |
79 if( iFileServer ) |
80 { |
80 { |
81 iFileServer->Delete( *iFileName ); |
81 iFileServer->Delete( *iFileName ); |
82 } |
82 } |
83 delete iFileName; |
83 delete iFileName; |
84 iFileName = NULL; |
84 iFileName = NULL; |
85 } |
85 } |
86 |
86 |
87 if ( iActiveOperation ) |
87 if ( iActiveOperation ) |
88 { |
88 { |
89 // Construction was successful, but |
89 // Construction was successful, but |
90 // something has went wrong. |
90 // something has went wrong. |
91 |
91 |
92 iActiveOperation->Cancel(); |
92 iActiveOperation->Cancel(); |
93 if( !iMessage.IsNull() ) |
93 if( !iMessage.IsNull() ) |
94 { |
94 { |
95 iMessage.Complete( KErrCancel ); |
95 iMessage.Complete( KErrCancel ); |
96 } |
96 } |
97 } |
97 } |
98 } |
98 } |
99 |
99 |
100 // ----------------------------------------------------------------------------- |
100 // ----------------------------------------------------------------------------- |
101 // CDRMActiveOperation::ActivateL |
101 // CDRMActiveOperation::ActivateL |
102 // |
102 // |
103 // Activate the thing by issuing a request to the DB and executing it also. |
103 // Activate the thing by issuing a request to the DB and executing it also. |
104 // ----------------------------------------------------------------------------- |
104 // ----------------------------------------------------------------------------- |
105 // |
105 // |
106 void CDRMActiveOperation::ActivateL( CDRMRightsDB& aDb, |
106 void CDRMActiveOperation::ActivateL( CDRMRightsDB& aDb, |
107 const TTime& aTime ) |
107 const TTime& aTime ) |
108 { |
108 { |
109 CActiveScheduler::Add( this ); |
109 CActiveScheduler::Add( this ); |
110 |
110 |
111 |
111 |
112 CDRMRightsCleaner* cleaner = |
112 CDRMRightsCleaner* cleaner = |
113 aDb.DeleteExpiredPermissionsL( aTime, iStatus ); |
113 aDb.DeleteExpiredPermissionsL( aTime, iStatus ); |
114 CleanupStack::PushL( cleaner ); |
114 CleanupStack::PushL( cleaner ); |
115 cleaner->ExecuteCleanupLD(); |
115 cleaner->ExecuteCleanupLD(); |
116 CleanupStack::Pop(); |
116 CleanupStack::Pop(); |
117 SetActive(); |
117 SetActive(); |
118 iActiveOperation = cleaner; |
118 iActiveOperation = cleaner; |
119 } |
119 } |
120 |
120 |
121 // ----------------------------------------------------------------------------- |
121 // ----------------------------------------------------------------------------- |
122 // CDRMActiveOperation::ActivateL |
122 // CDRMActiveOperation::ActivateL |
123 // |
123 // |
124 // Activate the thing by creating an object and executing it |
124 // Activate the thing by creating an object and executing it |
125 // ----------------------------------------------------------------------------- |
125 // ----------------------------------------------------------------------------- |
126 // |
126 // |
127 void CDRMActiveOperation::ActivateL( CDRMRightsDB& aDb, |
127 void CDRMActiveOperation::ActivateL( CDRMRightsDB& aDb, |
128 RFs& aFileServer, |
128 RFs& aFileServer, |
129 const TDesC& aTempPath, |
129 const TDesC& aTempPath, |
130 const TBool aPerformScan ) |
130 const TBool aPerformScan ) |
131 { |
131 { |
132 CActiveScheduler::Add( this ); |
132 CActiveScheduler::Add( this ); |
133 |
133 |
134 iFileName = new (ELeave) TFileName; |
134 iFileName = new (ELeave) TFileName; |
135 iFileServer = &aFileServer; |
135 iFileServer = &aFileServer; |
136 |
136 |
137 User::LeaveIfError( |
137 User::LeaveIfError( |
138 iFileStream.Temp( aFileServer, |
138 iFileStream.Temp( aFileServer, |
139 aTempPath, |
139 aTempPath, |
140 *iFileName, |
140 *iFileName, |
141 EFileWrite | EFileStream ) ); |
141 EFileWrite | EFileStream ) ); |
142 |
142 |
143 CDRMObsoleteFinder* finder = CDRMObsoleteFinder::NewL(aFileServer, |
143 CDRMObsoleteFinder* finder = CDRMObsoleteFinder::NewL(aFileServer, |
144 &aDb, |
144 &aDb, |
145 iStatus, |
145 iStatus, |
146 iFileStream, |
146 iFileStream, |
147 aPerformScan ); |
147 aPerformScan ); |
148 CleanupStack::PushL( finder ); |
148 CleanupStack::PushL( finder ); |
149 finder->ExecuteFinderLD(); |
149 finder->ExecuteFinderLD(); |
150 CleanupStack::Pop(); |
150 CleanupStack::Pop(); |
151 SetActive(); |
151 SetActive(); |
152 iActiveOperation = finder; |
152 iActiveOperation = finder; |
153 } |
153 } |
154 |
154 |
155 // ----------------------------------------------------------------------------- |
155 // ----------------------------------------------------------------------------- |
156 // CDRMActiveOperation::Remove |
156 // CDRMActiveOperation::Remove |
157 // |
157 // |
158 // Cancels the operation. |
158 // Cancels the operation. |
182 // ----------------------------------------------------------------------------- |
182 // ----------------------------------------------------------------------------- |
183 // |
183 // |
184 void CDRMActiveOperation::RunL() |
184 void CDRMActiveOperation::RunL() |
185 { |
185 { |
186 TFileName* fileName = NULL; |
186 TFileName* fileName = NULL; |
187 |
187 |
188 // All done. |
188 // All done. |
189 if( !iMessage.IsNull() ) |
189 if( !iMessage.IsNull() ) |
190 { |
190 { |
191 iMessage.Complete( iStatus.Int() ); |
191 iMessage.Complete( iStatus.Int() ); |
192 } |
192 } |
193 |
193 |
194 // iActiveOperation deletes itself. |
194 // iActiveOperation deletes itself. |
195 iActiveOperation = NULL; |
195 iActiveOperation = NULL; |
196 |
196 |
197 Deque(); |
197 Deque(); |
198 |
198 |
199 if( iOperation == EOperationExportObsolete ) |
199 if( iOperation == EOperationExportObsolete ) |
200 { |
200 { |
201 fileName = iFileName; |
201 fileName = iFileName; |
202 iFileName = NULL; |
202 iFileName = NULL; |
203 iSession.AsyncOperationDone(fileName); |
203 iSession.AsyncOperationDone(fileName); |
204 } |
204 } |
205 else |
205 else |
206 { |
206 { |
207 iSession.AsyncOperationDone(); |
207 iSession.AsyncOperationDone(); |
208 } |
208 } |
209 } |
209 } |
210 |
210 |
211 // ----------------------------------------------------------------------------- |
211 // ----------------------------------------------------------------------------- |
212 // CDRMActiveOperation::DoCancel |
212 // CDRMActiveOperation::DoCancel |
213 // |
213 // |
214 // Cancels the operation. |
214 // Cancels the operation. |
215 // ----------------------------------------------------------------------------- |
215 // ----------------------------------------------------------------------------- |
216 // |
216 // |
217 void CDRMActiveOperation::DoCancel() |
217 void CDRMActiveOperation::DoCancel() |
218 { |
218 { |
219 } |
219 } |
220 |
220 |
221 |
221 |
222 |
222 |
223 // ----------------------------------------------------------------------------- |
223 // ----------------------------------------------------------------------------- |
224 // CDRMActiveOperation::CDRMActiveOperation |
224 // CDRMActiveOperation::CDRMActiveOperation |
225 // |
225 // |
226 // Constructor. |
226 // Constructor. |