|
1 /* |
|
2 * Copyright (c) 2002 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: Declares Registry watcher class for BTUI. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "BTUI.h" |
|
22 #include "BTUIRegistryWatcher.h" |
|
23 #include <bt_subscribe.h> |
|
24 |
|
25 #include "BTDevModel.h" //for Log printing Macro |
|
26 |
|
27 // ================= MEMBER FUNCTIONS ======================= |
|
28 |
|
29 // --------------------------------------------------------- |
|
30 // CBTUIRegistryWatcherAO::CBTUIRegistryWatcherAO |
|
31 // C++ default constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // --------------------------------------------------------- |
|
34 // |
|
35 CBTUIRegistryWatcherAO::CBTUIRegistryWatcherAO( MBTUIRegistryObserver* aParent ) |
|
36 : CActive(EPriorityNormal), iParent ( aParent ) |
|
37 { |
|
38 TRACE_FUNC_ENTRY |
|
39 |
|
40 CActiveScheduler::Add(this); |
|
41 |
|
42 TRACE_FUNC_EXIT |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------- |
|
46 // Destructor. |
|
47 // --------------------------------------------------------- |
|
48 // |
|
49 CBTUIRegistryWatcherAO::~CBTUIRegistryWatcherAO() |
|
50 { |
|
51 TRACE_FUNC_ENTRY |
|
52 |
|
53 Cancel(); |
|
54 iProperty.Close(); |
|
55 |
|
56 TRACE_FUNC_EXIT |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------- |
|
60 // CBTUIRegistryWatcherAO::WatchL |
|
61 // --------------------------------------------------------- |
|
62 // |
|
63 void CBTUIRegistryWatcherAO::WatchL() |
|
64 { |
|
65 TRACE_FUNC_ENTRY |
|
66 |
|
67 if( !iProperty.Handle() ) |
|
68 { |
|
69 User::LeaveIfError( iProperty.Attach( KPropertyUidBluetoothCategory, |
|
70 KPropertyKeyBluetoothRegistryTableChange ) ); |
|
71 } |
|
72 |
|
73 if( !IsActive() ) |
|
74 { |
|
75 iProperty.Subscribe(iStatus); |
|
76 SetActive(); |
|
77 } |
|
78 TRACE_FUNC_EXIT |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------- |
|
82 // CBTUIRegistryWatcherAO::DoCancel |
|
83 // --------------------------------------------------------- |
|
84 // |
|
85 void CBTUIRegistryWatcherAO::DoCancel() |
|
86 { |
|
87 TRACE_FUNC |
|
88 |
|
89 iProperty.Cancel(); |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------- |
|
93 // CBTUIRegistryWatcherAO::RunL |
|
94 // --------------------------------------------------------- |
|
95 // |
|
96 void CBTUIRegistryWatcherAO::RunL() |
|
97 { |
|
98 TRACE_FUNC_ENTRY |
|
99 |
|
100 if( iStatus.Int()==KErrNone ) |
|
101 { |
|
102 __ASSERT_DEBUG(iParent, PANIC(EBTPanicClassMemberVariableIsNull)); |
|
103 |
|
104 // Inform observer |
|
105 // |
|
106 iParent->RegistryContentChangedL(); |
|
107 |
|
108 // Continue watching |
|
109 // |
|
110 WatchL(); |
|
111 } |
|
112 |
|
113 TRACE_FUNC_EXIT |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------- |
|
117 // CBTUIRegistryWatcherAO::RunError |
|
118 // --------------------------------------------------------- |
|
119 // |
|
120 TInt CBTUIRegistryWatcherAO::RunError( TInt aError ) |
|
121 { |
|
122 TRACE_INFO((_L("RunError: %d"), aError)) |
|
123 |
|
124 return aError; |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------- |
|
128 // CBTUIRegistryWatcherAO::StopWatching |
|
129 // --------------------------------------------------------- |
|
130 // |
|
131 void CBTUIRegistryWatcherAO::StopWatching() |
|
132 { |
|
133 TRACE_FUNC |
|
134 |
|
135 Cancel(); |
|
136 } |
|
137 |
|
138 // End of File |