NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
qextserialenumerator_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (c) 2000-2003 Wayne Roth
3 ** Copyright (c) 2004-2007 Stefan Sander
4 ** Copyright (c) 2007 Michal Policht
5 ** Copyright (c) 2008 Brandon Fosdick
6 ** Copyright (c) 2009-2010 Liam Staskawicz
7 ** Copyright (c) 2011 Debao Zhang
8 ** All right reserved.
9 ** Web: http://code.google.com/p/qextserialport/
10 **
11 ** Permission is hereby granted, free of charge, to any person obtaining
12 ** a copy of this software and associated documentation files (the
13 ** "Software"), to deal in the Software without restriction, including
14 ** without limitation the rights to use, copy, modify, merge, publish,
15 ** distribute, sublicense, and/or sell copies of the Software, and to
16 ** permit persons to whom the Software is furnished to do so, subject to
17 ** the following conditions:
18 **
19 ** The above copyright notice and this permission notice shall be
20 ** included in all copies or substantial portions of the Software.
21 **
22 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 **
30 ****************************************************************************/
31 #ifndef _QEXTSERIALENUMERATOR_P_H_
32 #define _QEXTSERIALENUMERATOR_P_H_
33 
34 //
35 // W A R N I N G
36 // -------------
37 //
38 // This file is not part of the QESP API. It exists for the convenience
39 // of other QESP classes. This header file may change from version to
40 // version without notice, or even be removed.
41 //
42 // We mean it.
43 //
44 
45 #include "qextserialenumerator.h"
46 
47 #if defined(_WIN32) || defined(_WIN64)
48 // needed for mingw to pull in appropriate dbt business...
49 // probably a better way to do this
50 // http://mingw-users.1079350.n2.nabble.com/DEV-BROADCAST-DEVICEINTERFACE-was-not-declared-in-this-scope-td3552762.html
51 # ifdef __MINGW32__
52 # define _WIN32_WINNT 0x0500
53 # define _WIN32_WINDOWS 0x0500
54 # define WINVER 0x0500
55 # endif
56 # include <QtCore/qt_windows.h>
57 #endif /*Q_OS_WIN*/
58 
59 #ifdef __APPLE__
60 # include <IOKit/usb/IOUSBLib.h>
61 #endif /*Q_OS_MAC*/
62 
63 //#if (defined(QT_GUI_LIB) && QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) || defined(QT_WIDGETS_LIB)
64 //# define HAS_QWIDGET
65 //#endif
66 
67 class QextSerialRegistrationWidget;
68 
74 {
75  Q_DECLARE_PUBLIC(QextSerialEnumerator)
76 public:
79  void platformSpecificInit();
81 
82  static QList<QextPortInfo> getPorts_sys();
83  bool setUpNotifications_sys(bool setup);
84 
85 #if defined(_WIN32) || defined(_WIN64)
86  LRESULT onDeviceChanged( WPARAM wParam, LPARAM lParam );
87  bool matchAndDispatchChangedDevice(const QString & deviceID, const GUID & guid, WPARAM wParam);
88 # ifdef HAS_QWIDGET
89  QextSerialRegistrationWidget* notificationWidget;
90 # endif
91 #endif /*Q_OS_WIN*/
92 
93 #ifdef __APPLE__
94 
98  static void iterateServicesOSX(io_object_t service, QList<QextPortInfo> & infoList);
99  static bool getServiceDetailsOSX( io_object_t service, QextPortInfo* portInfo );
100  void onDeviceDiscoveredOSX( io_object_t service );
101  void onDeviceTerminatedOSX( io_object_t service );
102  friend void deviceDiscoveredCallbackOSX( void *ctxt, io_iterator_t serialPortIterator );
103  friend void deviceTerminatedCallbackOSX( void *ctxt, io_iterator_t serialPortIterator );
104 
105  IONotificationPortRef notificationPortRef;
106 #endif // Q_OS_MAC
107 
108 private:
109  QextSerialEnumerator * q_ptr;
110 };
111 
112 #endif //_QEXTSERIALENUMERATOR_P_H_
void platformSpecificInit()
Definition: qextserialenumerator_p.cxx:304
void platformSpecificDestruct()
Definition: qextserialenumerator_p.cxx:308
~QextSerialEnumeratorPrivate()
Definition: qextserialenumerator.cxx:45
Private implementation of QextSerialEnumerator.
Definition: qextserialenumerator_p.h:73
QextSerialEnumeratorPrivate(QextSerialEnumerator *enumrator)
Definition: qextserialenumerator.cxx:39
static QList< QextPortInfo > getPorts_sys()
Definition: qextserialenumerator_p.cxx:312
The QextSerialEnumerator class provides list of ports available in the system.
Definition: qextserialenumerator.h:51
The QextPortInfo class containing port information.
Definition: qextserialenumerator.h:40
bool setUpNotifications_sys(bool setup)
Definition: qextserialenumerator_p.cxx:362