1 /* |
|
2 * Copyright (c) 2010 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 #ifndef BLUETOOTHUITRACE_H |
|
19 #define BLUETOOTHUITRACE_H |
|
20 |
|
21 #include <bluetoothtrace.h> |
|
22 #include <QDateTime> |
|
23 |
|
24 #ifdef BLUETOOTHTRACE_ENABLED |
|
25 |
|
26 /* |
|
27 * trace macro for Qt code with an additional trace text. |
|
28 * param must be QString type. |
|
29 */ |
|
30 #define BtTraceQString1( groupName, traceName, traceText, param ) \ |
|
31 {\ |
|
32 _LIT(TrTxt, traceText); TPtrC p(TrTxt); \ |
|
33 TPtrC textPtr(reinterpret_cast<const TUint16*>(param.utf16()), param.length() ); \ |
|
34 BOstraceExt2( groupName, traceName, "%S%S", &p, &textPtr ); \ |
|
35 } |
|
36 |
|
37 /* |
|
38 * trace macro for Qt code with no additional trace text. |
|
39 * param must be QString type. |
|
40 */ |
|
41 #define BtTraceQString0( groupName, traceName, param ) \ |
|
42 {\ |
|
43 TPtrC textPtr(reinterpret_cast<const TUint16*>(param.utf16()), param.length() ); \ |
|
44 BOstraceExt1( groupName, traceName, "%S", &textPtr ); \ |
|
45 } |
|
46 |
|
47 /* |
|
48 * Macro for tracing a Bluetooth device entry in btuimdevlist |
|
49 * with no additional trace text. |
|
50 */ |
|
51 #define BtTraceDevListEntry0( groupName, traceName, dev ) \ |
|
52 {\ |
|
53 QString info("["); \ |
|
54 info += dev[Btuim::DevAddrReadableRole].toString() + "]"; \ |
|
55 QString filterBinary; \ |
|
56 filterBinary.setNum( dev[Btuim::MajorFilterRole].toInt(), 16); \ |
|
57 info += "[" + filterBinary + "]"; \ |
|
58 info += "[" \ |
|
59 + dev[Btuim::LastUsedTimeRole].value<QDateTime>().toString(Qt::ISODate ) \ |
|
60 + "]" ; \ |
|
61 info += "[" + dev[Btuim::DevNameRoleRole].toString() + "]" ; \ |
|
62 TPtrC textPtr(reinterpret_cast<const TUint16*>(info.utf16()), info.length() ); \ |
|
63 BOstraceExt1( groupName, traceName, "%S", &textPtr ); \ |
|
64 } |
|
65 |
|
66 /* |
|
67 * Macro for tracing a Bluetooth device entry in btuim |
|
68 * with an additional trace text. |
|
69 */ |
|
70 #define BtTraceDevListEntry1( groupName, traceName, traceText, dev ) \ |
|
71 {\ |
|
72 QString info("["); \ |
|
73 info += dev[Btuim::DevAddrReadableRole].toString() + "]"; \ |
|
74 QString cod; \ |
|
75 cod.setNum( dev[Btuim::ClassOfDeviceRole].toInt(), 16); \ |
|
76 info += "[" + cod + "]"; \ |
|
77 QString filterBinary; \ |
|
78 filterBinary.setNum( dev[Btuim::MajorFilterRole].toInt(), 16); \ |
|
79 info += "[" + filterBinary + "]"; \ |
|
80 info += "[" \ |
|
81 + dev[Btuim::LastUsedTimeRole].value<QDateTime>().toString(Qt::ISODate ) \ |
|
82 + "]" ; \ |
|
83 info += "[" + dev[Btuim::DevNameRole].toString() + "]" ; \ |
|
84 TPtrC textPtr(reinterpret_cast<const TUint16*>(info.utf16()), info.length() ); \ |
|
85 _LIT(TrTxt, traceText); TPtrC p(TrTxt); \ |
|
86 BOstraceExt2( groupName, traceName, "%S%S", &p, &textPtr ); \ |
|
87 } |
|
88 |
|
89 /* |
|
90 * Macro for Qt code with additional trace text. |
|
91 * list must be QStringList type. |
|
92 */ |
|
93 #define BtTraceQStringList1( groupName, traceName, traceText, list ) \ |
|
94 {\ |
|
95 QString info(": ["); \ |
|
96 info += list.join(".") + "]"; \ |
|
97 TPtrC textPtr(reinterpret_cast<const TUint16*>(info.utf16()), info.length() ); \ |
|
98 _LIT(TrTxt, traceText); TPtrC p(TrTxt); \ |
|
99 BOstraceExt2( groupName, traceName, "%S%S", &p, &textPtr ); \ |
|
100 } |
|
101 |
|
102 /* |
|
103 * Macro for Qt code with no additional trace text. |
|
104 * list must be QStringList type. |
|
105 */ |
|
106 #define BtTraceQStringList0( groupName, traceName, list ) \ |
|
107 {\ |
|
108 QString info(": ["); \ |
|
109 info += list.join(".") + "]"; \ |
|
110 TPtrC textPtr(reinterpret_cast<const TUint16*>(info.utf16()), info.length() ); \ |
|
111 BOstraceExt1( groupName, traceName, "%S", &textPtr ); \ |
|
112 } |
|
113 |
|
114 |
|
115 /* |
|
116 * Macro for tracing Bluetooth DevData data source in btuimdevdata |
|
117 * with no additional trace text. |
|
118 */ |
|
119 #define BtTraceDevDataEntry0( groupName, traceName, devData ) \ |
|
120 {\ |
|
121 QString info("["); \ |
|
122 QMap< int, QVariant > val = devData.at( Btuim::DevDataIndexName ); \ |
|
123 info += val.value(Qt::EditRole).toString() + "]" ; \ |
|
124 val = devData.at( Btuim::DevDataIndexStatus ); \ |
|
125 int statusBits = val.value(Qt::EditRole).toInt(); \ |
|
126 info += "["; \ |
|
127 info += QString::number(statusBits, 16 ); \ |
|
128 info += "]"; \ |
|
129 QStringList strl = val.value(Qt::DisplayRole).toStringList(); \ |
|
130 info += "[" ; \ |
|
131 for ( int i = 0; i < strl.count(); ++i ) { \ |
|
132 info += strl.at(i) + ","; \ |
|
133 } \ |
|
134 info += "]" ; \ |
|
135 val = devData.at( Btuim::DevDataIndexOptionsMenu ); \ |
|
136 info += " opts:"; \ |
|
137 QList<QVariant> cmdItems = val.value( Btuim::DevDataCmdItemsRole ).toList(); \ |
|
138 for ( int i = 0; i < cmdItems.count(); i++ ) { \ |
|
139 const Btuim::DevDataCmdItem& item = cmdItems.at(i).value<Btuim::DevDataCmdItem>(); \ |
|
140 info += "[" + QString::number(item.mCmdId) + "," + QString::number(item.mEnabled) + "," + "]"; \ |
|
141 } \ |
|
142 val = devData.at( Btuim::DevDataIndexCmdList ); \ |
|
143 info += " cmds:"; \ |
|
144 cmdItems = val.value( Btuim::DevDataCmdItemsRole ).toList(); \ |
|
145 for ( int i = 0; i < cmdItems.count(); i++ ) { \ |
|
146 const Btuim::DevDataCmdItem& item = cmdItems.at(i).value<Btuim::DevDataCmdItem>(); \ |
|
147 info += "[" + QString::number(item.mCmdId) + "," + QString::number(item.mEnabled) + "," + "]"; \ |
|
148 } \ |
|
149 TPtrC textPtr(reinterpret_cast<const TUint16*>(info.utf16()), info.length() ); \ |
|
150 BOstraceExt1( groupName, traceName, "%S", &textPtr ); \ |
|
151 } |
|
152 #else |
|
153 |
|
154 #define BtTraceQString1( aGroupName, aTraceName, aTraceText, aParam ) |
|
155 #define BtTraceQString0( aGroupName, aTraceName, aParam ) |
|
156 #define BtTraceDevListEntry0( groupName, traceName, dev ) |
|
157 #define BtTraceDevListEntry1( groupName, traceName, traceText, dev ) |
|
158 #define BtTraceQStringList1( groupName, traceName, traceText, list ) |
|
159 #define BtTraceQStringList0( groupName, traceName, list ) |
|
160 #define BtTraceDevDataEntry0( groupName, traceName, devData ) |
|
161 #endif // BLUETOOTHTRACE_ENABLED |
|
162 |
|
163 // At early development phase, we force assertion in release build to find out |
|
164 // design and implementation issues. |
|
165 //#ifndef QT_NO_DEBUG |
|
166 #define BTUI_DEBUG |
|
167 //#endif |
|
168 |
|
169 #if !defined(BTUI_ASSERT_X) |
|
170 # ifdef BTUI_DEBUG |
|
171 #define BTUI_ASSERT_X(cond, where, what) ((!(cond)) ? qt_assert_x(where, what,__FILE__,__LINE__) : qt_noop()) |
|
172 # else |
|
173 # define BTUI_ASSERT_X(cond, where, what) qt_noop() |
|
174 # endif |
|
175 #endif |
|
176 |
|
177 #endif // BLUETOOTHUITRACE_H |
|