![]() |
QBluetoothZero
2.0
|
00001 /* 00002 * auxFunctions_symbian.h 00003 * 00004 * Author: Ftylitakis Nikolaos, Luis Valente 00005 * 00006 * Licensed under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 00019 #ifndef AUXFUNCTIONS_SYMBIAN_H_ 00020 #define AUXFUNCTIONS_SYMBIAN_H_ 00021 00022 #include <QBtGlobal.h> 00023 00024 QBT_NAMESPACE_BEGIN 00025 00026 template <class T> inline void SafeDelete(T* &ptr) 00027 { 00028 if(ptr) 00029 { 00030 delete ptr; 00031 ptr = 0; 00032 } 00033 } 00034 00035 00036 //#ifdef Q_OS_SYMBIAN 00037 #include <QtCore/QString> 00038 #include <QtGui/QMessageBox> 00039 #include <QtCore/QDir> 00040 #include <QtCore/QDebug.h> 00041 00042 inline void _Debug_Msg (const QString & m, const QString & file, int line) 00043 { 00044 qDebug() << "file: " << file << " line: " << line << " " << m; 00045 } 00046 00047 inline void _Assert_Msg (const QString msg, const QString & file, int line) 00048 { 00049 // strip directory info 00050 int index = file.lastIndexOf("/"); 00051 QString f = file.mid (index+1); 00052 QString m = QString ("file: %1 line: %2\n%3").arg (f).arg(line).arg(msg); 00053 00054 // 00055 _Debug_Msg (m, file, line); 00056 00057 // 00058 QMessageBox::information(0, "assert failed", m); 00059 Q_ASSERT (false); 00060 } 00061 00062 inline void _Assert_Msg2 (const QString & msg1, const QString & msg2, const QString & file, int line) 00063 { 00064 _Assert_Msg (QString("%1 : %2").arg(msg1).arg(msg2), file, line); 00065 } 00066 00067 00068 inline void _Break_Here (const QString & file, int line) 00069 { 00070 // strip directory info 00071 int index = file.lastIndexOf("/"); 00072 QString f = file.mid (index+1); 00073 QString m = QString ("file: %1 line: %2").arg (f).arg (line); 00074 00075 // 00076 _Debug_Msg (m, file, line); 00077 00078 // 00079 QMessageBox::information(0, "code break", m); 00080 Q_ASSERT (false); 00081 } 00082 00083 00084 00085 inline void _Break_Here (const QString & file, const QString & line) 00086 { 00087 // strip directory info 00088 int index = file.lastIndexOf("/"); 00089 QString f = file.mid (index+1); 00090 QString m = QString ("file: %1 line: %2").arg (f, line); 00091 00092 QMessageBox::information(0, "code break", m); 00093 Q_ASSERT (false); 00094 } 00095 00096 00097 #ifdef QT_DEBUG 00098 #define BT_DEBUG_MSG(msg) (_Debug_Msg((msg),__FILE__,__LINE__) ) 00099 #define BT_BREAK_HERE() (_Break_Here(__FILE__, QString::number(__LINE__)) ) 00100 #define BT_ASSERT_MSG(test, msg) ((!(test)) ? _Assert_Msg((msg), __FILE__, __LINE__) : qt_noop() ) 00101 #define BT_ASSERT_MSG2(test, msg1, msg2) ((!(test)) ? _Assert_Msg2((msg1), (msg2), __FILE__, __LINE__) : qt_noop() ) 00102 00103 00104 #else 00105 00106 #define BT_DEBUG_MSG(msg) {} 00107 #define BT_ASSERT_MSG_X(test, where, msg) {} 00108 #define BT_ASSERT_MSG(test, msg) {} 00109 #define BT_ASSERT_MSG2(test, msg1, msg2) {} 00110 #define BT_BREAK_HERE() {} 00111 00112 //#endif 00113 00114 00115 #endif 00116 00117 00118 00119 #ifdef Q_OS_WIN32 00120 00121 #include <windows.h> 00122 #include <conio.h> 00123 #include <QBtAddress.h> 00124 00125 using namespace std; 00126 00127 // used to have the number of the classes that use the Bluesoleil SDK. 00128 // if the number reaches zero the sdk is deinitialized. 00129 static size_t sdkInitializationCounter = 0; 00130 00131 //forward declaration 00132 00133 #ifdef BLUETOOTH_LIB 00134 extern "C"{ 00135 #include "./BlueSoleil_SDK_2.0.5/include/Btsdk_ui.h" 00136 } 00137 #else 00138 class BTDEVHDL; 00139 #endif 00140 00141 class DLL_EXPORT QBtAuxFunctions 00142 { 00143 public: 00144 static bool InitBthSdk(); 00145 static void DeinitBthSdk(); 00146 static BTDEVHDL GetDeviceHandle(const QBtAddress& address); 00147 }; 00148 00149 #endif // Q_OS_WIN32 00150 00151 QBT_NAMESPACE_END 00152 #endif /* AUXFUNCTIONS_SYMBIAN_H_ */