|
1 /* |
|
2 * Copyright (c) 2005-2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #if (!defined __T_BT_DEV_ADDRDATA_H__) |
|
20 #define __T_BT_DEV_ADDRDATA_H__ |
|
21 |
|
22 // Classes to get to protected members |
|
23 #include "T_TRfcommSockAddrChild.h" |
|
24 #include "T_TBTSockAddrChild.h" |
|
25 |
|
26 // User includes |
|
27 #include "DataWrapperBase.h" |
|
28 |
|
29 // EPOC includes |
|
30 #include <w32std.h> |
|
31 #include <e32std.h> |
|
32 #include <es_sock.h> // TSockAddr address |
|
33 #include <bt_sock.h> // Bluetooth address classes |
|
34 |
|
35 |
|
36 class CT_BTDevAddrData: public CDataWrapperBase |
|
37 { |
|
38 public: |
|
39 /** |
|
40 * Two phase constructor |
|
41 */ |
|
42 static CT_BTDevAddrData* NewL(); |
|
43 |
|
44 /** |
|
45 * Process a command read from the ini file |
|
46 * |
|
47 * @param aCommand The command to process |
|
48 * @param aSection The section in the ini containing data for the command |
|
49 * @param aAsyncErrorIndex Command index for async calls to return errors to |
|
50 * |
|
51 * @return ETrue if the command is processed |
|
52 * |
|
53 * @leave System wide error |
|
54 */ |
|
55 virtual TBool DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex); |
|
56 |
|
57 /** |
|
58 * Set the internal iBTDevAddr object using the copy constructor |
|
59 */ |
|
60 |
|
61 void CopyObjectL(TAny* aObjectPtr); |
|
62 |
|
63 /** |
|
64 * Destructor |
|
65 */ |
|
66 ~CT_BTDevAddrData(); |
|
67 |
|
68 const TBTDevAddr* GetAddress(); |
|
69 |
|
70 /** |
|
71 * Return a pointer to the object that the data wraps |
|
72 * |
|
73 * @return pointer to the object that the data wraps |
|
74 */ |
|
75 virtual TAny* GetObject(); |
|
76 |
|
77 /** |
|
78 * Set the object that the data wraps |
|
79 * |
|
80 * @param aObject object that the wrapper is testing |
|
81 * |
|
82 * @leave KErrNotSupported if the the function is not supported |
|
83 */ |
|
84 virtual void SetObjectL(TAny* aObject); |
|
85 |
|
86 /** |
|
87 * The object will no longer be owned by this |
|
88 * |
|
89 * @leave KErrNotSupported if the the function is not supported |
|
90 */ |
|
91 virtual void DisownObjectL(); |
|
92 |
|
93 // MT_MMActiveCallback implementation |
|
94 virtual void RunL(CActive* aActive, const TInt aIndex); |
|
95 virtual void DoCancel(CActive* aActive, const TInt aIndex); |
|
96 inline void RunGetDeviceAddress(const TInt aIndex); |
|
97 |
|
98 inline virtual TCleanupOperation CleanupOperation(); |
|
99 |
|
100 protected: |
|
101 /** |
|
102 * Constructor. First phase construction |
|
103 */ |
|
104 CT_BTDevAddrData(); |
|
105 |
|
106 /** |
|
107 * Second phase construction |
|
108 * |
|
109 * @leave system wide error |
|
110 */ |
|
111 void ConstructL(); |
|
112 |
|
113 private: |
|
114 // Implementation of DoCommandL for each of the commands |
|
115 inline void TBTDAConstruct(const TDesC& aSection); |
|
116 inline void TBTDASetAddress(const TDesC& aSection); |
|
117 |
|
118 inline void OpenHostResolver(const TDesC& aSection); |
|
119 inline void SetHostNameL(const TDesC& aSection); |
|
120 inline void SetDiscoverable(const TDesC& aSection); |
|
121 inline void GetDeviceAddress(const TDesC& aSection, const TInt aIndex); |
|
122 |
|
123 |
|
124 /** |
|
125 * Delete iTBTSockAddr and set to NULL |
|
126 */ |
|
127 void Cleanup(); |
|
128 |
|
129 static void CleanupOperation(TAny* aAny); |
|
130 |
|
131 private: |
|
132 // An object of TBTDevAddr class in order to retain state between |
|
133 // calls |
|
134 TBTDevAddr* iBTDevAddr; |
|
135 |
|
136 CActiveCallback* iActive; |
|
137 |
|
138 TNameEntry iBtNameEntry; |
|
139 RHostResolver iHostResolver; |
|
140 TInquirySockAddr iAddr; |
|
141 TPtrC iDeviceName; |
|
142 TBool iHostResolverOpen; |
|
143 |
|
144 }; |
|
145 |
|
146 #endif /* __T_BT_DEV_ADDRDATA_H__ */ |