|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef REGUI_H |
|
17 #define REGUI_H |
|
18 |
|
19 // forward declarations |
|
20 #include <e32test.h> |
|
21 #include <btmanclient.h> |
|
22 |
|
23 class CLocalDeviceUser; |
|
24 class CActiveRegistryUser; |
|
25 |
|
26 class CRegistryViewObserver; |
|
27 |
|
28 class MActiveConsoleNotify |
|
29 { |
|
30 public: |
|
31 virtual void KeyPressedL(TChar aKey) = 0; |
|
32 }; |
|
33 |
|
34 class MViewNotify |
|
35 { |
|
36 public: |
|
37 virtual void ViewChanged() =0; |
|
38 }; |
|
39 |
|
40 class CActiveConsole : public CActive |
|
41 { |
|
42 public: |
|
43 static CActiveConsole* NewL(MActiveConsoleNotify& aNotify); |
|
44 void RequestKey(); |
|
45 |
|
46 inline CConsoleBase& Console() const |
|
47 { |
|
48 return *iConsole; |
|
49 }; |
|
50 |
|
51 ~CActiveConsole(); |
|
52 static CConsoleBase* AutoSizeNewL(const TDesC& aTitle, TSize aSize); |
|
53 |
|
54 private: |
|
55 void RunL(); |
|
56 TInt RunError(TInt aError); |
|
57 void DoCancel(); |
|
58 void DrawCursor(); |
|
59 CActiveConsole(MActiveConsoleNotify& aNotify); |
|
60 void ConstructL(); |
|
61 |
|
62 private: |
|
63 CConsoleBase* iConsole; |
|
64 MActiveConsoleNotify& iNotify; |
|
65 }; |
|
66 |
|
67 class CRegUIApp : public CBase, public MActiveConsoleNotify |
|
68 { |
|
69 public: |
|
70 static CRegUIApp* NewL(); |
|
71 |
|
72 void StartL(); |
|
73 void CreateViewL(const TBTRegistrySearch& aSearch); |
|
74 void CreateLocalDeviceL(); |
|
75 void Stop(); |
|
76 ~CRegUIApp(); |
|
77 void TestMenu(); |
|
78 TBTDeviceName GetName(); |
|
79 CActiveRegistryUser* NewRegUserPleaseL(); |
|
80 void KindlyRemoveRegUserPleaseL(CActiveRegistryUser* aUser); |
|
81 void KindlyRemoveLocalDeviceUserPlease(); |
|
82 void Error(TInt aError); |
|
83 |
|
84 public: // From MActiveConsoleNotify |
|
85 void KeyPressedL(TChar aKey); |
|
86 |
|
87 private: |
|
88 CRegUIApp(); |
|
89 void ConstructL(); |
|
90 void StartRegistryServerL(); |
|
91 private: |
|
92 RBTRegServ iRegServ; |
|
93 CActiveConsole* iActiveConsole; |
|
94 |
|
95 CLocalDeviceUser* iLocalDeviceUser; |
|
96 RPointerArray<CActiveRegistryUser> iUsers; |
|
97 }; |
|
98 |
|
99 |
|
100 |
|
101 class CActiveRegistryUser : public CActive, public MActiveConsoleNotify, public MViewNotify |
|
102 { |
|
103 public: |
|
104 ~CActiveRegistryUser(); |
|
105 static CActiveRegistryUser* NewL(CRegUIApp& aApp, |
|
106 RBTRegServ& aRegServ); |
|
107 |
|
108 void Search(const TBTRegistrySearch& aSearch); |
|
109 void Unpair(); |
|
110 void UnpairAllDevicesInView(); |
|
111 void Delete(); |
|
112 void ChangeFriendlyNameL(); |
|
113 void RequireAuthorisation(const TBool aAuthorisationRequired); |
|
114 void SetCookieL(); |
|
115 |
|
116 void DestroyIfDone(); |
|
117 |
|
118 private: |
|
119 CActiveRegistryUser(CRegUIApp& aApp, RBTRegServ& aRegServ); |
|
120 void DoCancel(); |
|
121 void RunL(); |
|
122 TInt RunError(TInt aError); |
|
123 void ConstructL(); |
|
124 TBool PreProcessKey(TChar aKey); |
|
125 void DoDisplayDevice(TInt aIndex, const CBTDevice& aDevice); |
|
126 void LogCoD(TUint aCoD); |
|
127 void MenuL(); |
|
128 void ChooseDeviceL(); |
|
129 void RegisterViewChangeNotifier(); |
|
130 |
|
131 private: // From MActiveConsoleNotify |
|
132 void KeyPressedL(TChar aKey); |
|
133 |
|
134 private: // From MViewNotify |
|
135 void ViewChanged(); |
|
136 |
|
137 private: |
|
138 enum TState |
|
139 { |
|
140 ECreatingView, |
|
141 EUsingResponse, |
|
142 ESelecting, |
|
143 EUnpairing, |
|
144 EDeleting, |
|
145 EChangingFriendlyName, |
|
146 EChangingAuthorisation, |
|
147 ESettingCookie, |
|
148 EReady, |
|
149 EDone, |
|
150 }; |
|
151 private: |
|
152 RBTRegistry iView; |
|
153 RBTRegServ& iRegistryServer; |
|
154 CRegUIApp& iApp; |
|
155 CActiveConsole* iActiveConsole; |
|
156 CBTRegistryResponse* iResponseHandler; |
|
157 TBTRegistrySearch iSearch; |
|
158 TBTNamelessDevice iDevice; |
|
159 TState iState; |
|
160 CActiveRegistryUser* iChildUser; |
|
161 CRegistryViewObserver* iViewObserver; |
|
162 }; |
|
163 |
|
164 class CLocalDeviceUser : public CBase, public MActiveConsoleNotify |
|
165 { |
|
166 public: |
|
167 ~CLocalDeviceUser(); |
|
168 static CLocalDeviceUser* NewL(CRegUIApp& aApp, |
|
169 RBTRegServ& aRegServ); |
|
170 |
|
171 private: |
|
172 CLocalDeviceUser(CRegUIApp& aApp, RBTRegServ& aRegServ); |
|
173 void ConstructL(); |
|
174 void MenuL(); |
|
175 |
|
176 private: // From MActiveConsoleNotify |
|
177 void KeyPressedL(TChar aKey); |
|
178 |
|
179 private: |
|
180 TBTLocalDevice iLocalDeviceSettings; |
|
181 RBTLocalDevice iLocalDevice; |
|
182 RBTRegServ& iRegistryServer; |
|
183 CRegUIApp& iApp; |
|
184 CActiveConsole* iActiveConsole; |
|
185 }; |
|
186 |
|
187 class CRegistryViewObserver : public CActive |
|
188 { |
|
189 public: |
|
190 static CRegistryViewObserver* New(MViewNotify& aNotifiee, RBTRegistry& aView); |
|
191 ~CRegistryViewObserver(); |
|
192 private: |
|
193 CRegistryViewObserver(MViewNotify& aNotifiee, RBTRegistry& aView); |
|
194 void Queue(); |
|
195 private: |
|
196 virtual void RunL(); |
|
197 virtual void DoCancel(); |
|
198 private: |
|
199 MViewNotify& iNotifiee; |
|
200 RBTRegistry& iView; |
|
201 }; |
|
202 |
|
203 #endif // REGUI_H |