|
1 /* |
|
2 * Copyright (c) 2005 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: Implementation of the RDB watcher |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32def.h> |
|
20 #include <e32base.h> |
|
21 #include <f32file.h> |
|
22 #include <sysutil.h> |
|
23 #include "dirwatcher.h" |
|
24 #include "dbwatcher.h" |
|
25 #include "drmlog.h" |
|
26 |
|
27 static const TNotifyType KWatchTrigger = ENotifyEntry; |
|
28 |
|
29 // ======== MEMBER FUNCTIONS ======== |
|
30 |
|
31 void CDirWatcher::ConstructL( const TDesC& aDir ) |
|
32 { |
|
33 DRMLOG( _L( "CDirWatcher::ConstructL <-" ) ); |
|
34 |
|
35 iDir.Copy( aDir ); |
|
36 CActiveScheduler::Add( this ); |
|
37 |
|
38 DRMLOG( _L( "CDirWatcher::ConstructL ->" ) ); |
|
39 } |
|
40 |
|
41 CDirWatcher* CDirWatcher::NewL( MWatcherObserver& aObserver, RFs& aFs, const TDesC& aDir ) |
|
42 { |
|
43 CDirWatcher* self = new( ELeave ) CDirWatcher( aObserver, aFs ); |
|
44 self->ConstructL( aDir ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 CDirWatcher::CDirWatcher( MWatcherObserver& aObserver, RFs& aFs ): |
|
49 CActive( EPriorityStandard ), |
|
50 iFs( aFs ), |
|
51 iObserver( aObserver ) |
|
52 { |
|
53 DRMLOG( _L( "CDirWatcher::CDirWatcher ->" ) ); |
|
54 DRMLOG( _L( "CDirWatcher::CDirWatcher <-" ) ); |
|
55 } |
|
56 |
|
57 CDirWatcher::~CDirWatcher() |
|
58 { |
|
59 DRMLOG( _L( "CDirWatcher::~CDirWatcher ->" ) ); |
|
60 |
|
61 Cancel(); |
|
62 |
|
63 DRMLOG( _L( "CDirWatcher::~CDirWatcher <-" ) ); |
|
64 } |
|
65 |
|
66 void CDirWatcher::StartWatching() |
|
67 { |
|
68 DRMLOG( _L( "CDirWatcher::StartWatching ->" ) ); |
|
69 |
|
70 DRMLOG( iDir ); |
|
71 Cancel(); |
|
72 iFs.NotifyChangeCancel(); |
|
73 iFs.NotifyChange( KWatchTrigger, iStatus, iDir ); |
|
74 SetActive(); |
|
75 |
|
76 DRMLOG( _L( "CDirWatcher::StartWatching <-" ) ); |
|
77 } |
|
78 |
|
79 void CDirWatcher::DoCancel() |
|
80 { |
|
81 DRMLOG( _L( "CDirWatcher::DoCancel ->" ) ); |
|
82 |
|
83 iFs.NotifyChangeCancel(); |
|
84 |
|
85 DRMLOG( _L( "CDirWatcher::DoCancel <-" ) ); |
|
86 } |
|
87 |
|
88 void CDirWatcher::RunL() |
|
89 { |
|
90 TBuf<256> logBuffer; |
|
91 TFileName object; |
|
92 |
|
93 DRMLOG( _L( "CDirWatcher::RunL ->" ) ); |
|
94 |
|
95 DRMLOG( iDir ); |
|
96 logBuffer.AppendNum( iStatus.Int() ); |
|
97 DRMLOG( logBuffer ); |
|
98 if ( iStatus == KErrNone ) |
|
99 { |
|
100 object.Copy( KDirIdentifier ); |
|
101 object.Append( iDir ); |
|
102 iObserver.WatchedObjectChangedL( object ); |
|
103 } |
|
104 iFs.NotifyChange( KWatchTrigger, iStatus, iDir ); |
|
105 SetActive(); |
|
106 |
|
107 DRMLOG( _L( "CDirWatcher::RunL <-" ) ); |
|
108 } |