1 /* |
|
2 * Copyright (c) 2004-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: Interface for Active object handling Pub&Sub notify events. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "csssettingsactiveobject.h" |
|
21 #include <e32property.h> |
|
22 |
|
23 |
|
24 // ============================ MEMBER FUNCTIONS =============================== |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CSSSettingsActiveObject::CSSSettingsActiveObject |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CSSSettingsActiveObject::CSSSettingsActiveObject( |
|
31 const TUid aNotifyUid, |
|
32 const TUint32 aNotifyKey, |
|
33 MSSSettingsPubSubNotify& aNotifyHandler ) |
|
34 : CActive( CActive::EPriorityStandard ), |
|
35 iNotifyUid ( aNotifyUid ), |
|
36 iNotifyKey( aNotifyKey ), |
|
37 iNotifyHandler( &aNotifyHandler ), |
|
38 iNotify( EFalse ) |
|
39 { |
|
40 CActiveScheduler::Add( this ); |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CSSSettingsActiveObject::ConstructL |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 void CSSSettingsActiveObject::ConstructL() |
|
48 { |
|
49 TInt err = iProperty.Attach( |
|
50 iNotifyUid, |
|
51 iNotifyKey ); |
|
52 User::LeaveIfError( err ); |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CSSSettingsActiveObject::NewL |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CSSSettingsActiveObject* CSSSettingsActiveObject::NewL( |
|
60 const TUid aNotifyUid, |
|
61 const TUint32 aNotifyKey, |
|
62 MSSSettingsPubSubNotify& aNotifyHandler ) |
|
63 { |
|
64 CSSSettingsActiveObject* self = |
|
65 new ( ELeave ) CSSSettingsActiveObject( |
|
66 aNotifyUid, |
|
67 aNotifyKey, |
|
68 aNotifyHandler ); |
|
69 |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL(); |
|
72 CleanupStack::Pop(); |
|
73 |
|
74 return self; |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CSSSettingsActiveObject::~CSSSettingsActiveObject |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 CSSSettingsActiveObject::~CSSSettingsActiveObject() |
|
82 { |
|
83 Cancel(); |
|
84 iProperty.Close(); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CSSSettingsActiveObject::NotifyKeyChange |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 TInt CSSSettingsActiveObject::NotifyKeyChange() |
|
92 { |
|
93 TInt err(KErrNone); |
|
94 if ( iNotify || IsActive() ) |
|
95 { |
|
96 // Notify already active, so return error code. |
|
97 err = KErrInUse; |
|
98 } |
|
99 else |
|
100 { |
|
101 iProperty.Subscribe( iStatus ); |
|
102 SetActive(); |
|
103 iNotify = ETrue; |
|
104 } |
|
105 return err; |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CSSSettingsActiveObject::CancelNotifyCancelNotify |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 void CSSSettingsActiveObject::CancelNotify() |
|
113 { |
|
114 Cancel(); |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CSSSettingsActiveObject::RunL |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CSSSettingsActiveObject::RunL() |
|
122 { |
|
123 TInt err = iStatus.Int(); |
|
124 if ( err != KErrCancel && !iNotify ) |
|
125 { |
|
126 // Reset the notification. |
|
127 iProperty.Subscribe( iStatus ); |
|
128 SetActive(); |
|
129 } |
|
130 |
|
131 if ( !err ) |
|
132 { |
|
133 if ( iNotifyHandler ) |
|
134 { |
|
135 iNotifyHandler->HandlePubSubNotify( |
|
136 iNotifyUid, |
|
137 iNotifyKey ); |
|
138 } |
|
139 } |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------- |
|
143 // CSSSettingsActiveObject::DoCancel |
|
144 // --------------------------------------------------------- |
|
145 // |
|
146 void CSSSettingsActiveObject::DoCancel() |
|
147 { |
|
148 iNotify = EFalse; |
|
149 iProperty.Cancel(); |
|
150 } |
|
151 |
|
152 // End of File |
|