|
1 /* |
|
2 * Copyright (c) 2006 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: Subscriber (Publish & Subscribe) |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "CFileManagerPropertySubscriber.h" |
|
21 #include "FileManagerDebug.h" |
|
22 |
|
23 // ============================= MEMBER FUNCTIONS ============================= |
|
24 |
|
25 // ---------------------------------------------------------------------------- |
|
26 // CFileManagerPropertySubscriber::NewL() |
|
27 // |
|
28 // ---------------------------------------------------------------------------- |
|
29 CFileManagerPropertySubscriber* CFileManagerPropertySubscriber::NewL( |
|
30 MFileManagerPropertyObserver& aObserver, |
|
31 const TUid& aCategory, |
|
32 const TUint aKey ) |
|
33 { |
|
34 CFileManagerPropertySubscriber* self = new (ELeave) |
|
35 CFileManagerPropertySubscriber( |
|
36 aObserver, aCategory, aKey ); |
|
37 CleanupStack::PushL( self ); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop( self ); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // ---------------------------------------------------------------------------- |
|
44 // CFileManagerPropertySubscriber::ConstructL() |
|
45 // |
|
46 // ---------------------------------------------------------------------------- |
|
47 void CFileManagerPropertySubscriber::ConstructL() |
|
48 { |
|
49 CActiveScheduler::Add( this ); |
|
50 User::LeaveIfError( iProperty.Attach( iCategory, iKey ) ); |
|
51 Subscribe(); |
|
52 } |
|
53 |
|
54 // ---------------------------------------------------------------------------- |
|
55 // CFileManagerPropertySubscriber::Subscribe() |
|
56 // |
|
57 // ---------------------------------------------------------------------------- |
|
58 void CFileManagerPropertySubscriber::Subscribe() |
|
59 { |
|
60 iProperty.Subscribe( iStatus ); |
|
61 SetActive(); |
|
62 } |
|
63 |
|
64 // ---------------------------------------------------------------------------- |
|
65 // CFileManagerPropertySubscriber::CFileManagerPropertySubscriber() |
|
66 // |
|
67 // ---------------------------------------------------------------------------- |
|
68 CFileManagerPropertySubscriber::CFileManagerPropertySubscriber( |
|
69 MFileManagerPropertyObserver& aObserver, |
|
70 const TUid& aCategory, |
|
71 const TUint aKey ) : |
|
72 CActive( EPriorityStandard ), |
|
73 iObserver( aObserver ), |
|
74 iCategory( aCategory), |
|
75 iKey( aKey ) |
|
76 { |
|
77 } |
|
78 |
|
79 // ---------------------------------------------------------------------------- |
|
80 // CFileManagerPropertySubscriber::RunL() |
|
81 // |
|
82 // ---------------------------------------------------------------------------- |
|
83 void CFileManagerPropertySubscriber::RunL() |
|
84 { |
|
85 Subscribe(); |
|
86 iObserver.PropertyChangedL( iCategory, iKey ); |
|
87 } |
|
88 |
|
89 // ---------------------------------------------------------------------------- |
|
90 // CFileManagerPropertySubscriber::DoCancel() |
|
91 // |
|
92 // ---------------------------------------------------------------------------- |
|
93 void CFileManagerPropertySubscriber::DoCancel() |
|
94 { |
|
95 iProperty.Cancel(); |
|
96 } |
|
97 |
|
98 // ---------------------------------------------------------------------------- |
|
99 // CFileManagerPropertySubscriber::RunError() |
|
100 // |
|
101 // ---------------------------------------------------------------------------- |
|
102 TInt CFileManagerPropertySubscriber::RunError( TInt aError ) |
|
103 { |
|
104 ERROR_LOG1( "CFileManagerPropertySubscriber::RunError()-error=%d", aError ) |
|
105 return aError; |
|
106 } |
|
107 |
|
108 // ---------------------------------------------------------------------------- |
|
109 // CFileManagerPropertySubscriber::~CFileManagerPropertySubscriber() |
|
110 // |
|
111 // ---------------------------------------------------------------------------- |
|
112 CFileManagerPropertySubscriber::~CFileManagerPropertySubscriber() |
|
113 { |
|
114 Cancel(); |
|
115 iProperty.Close(); |
|
116 } |
|
117 |
|
118 // End of File |
|
119 |
|
120 |