11b464e99SMatthias Ringwald /* 21b464e99SMatthias Ringwald * Copyright (C) 2019 BlueKitchen GmbH 31b464e99SMatthias Ringwald * 41b464e99SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 51b464e99SMatthias Ringwald * modification, are permitted provided that the following conditions 61b464e99SMatthias Ringwald * are met: 71b464e99SMatthias Ringwald * 81b464e99SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 91b464e99SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 101b464e99SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 111b464e99SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 121b464e99SMatthias Ringwald * documentation and/or other materials provided with the distribution. 131b464e99SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 141b464e99SMatthias Ringwald * contributors may be used to endorse or promote products derived 151b464e99SMatthias Ringwald * from this software without specific prior written permission. 161b464e99SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 171b464e99SMatthias Ringwald * personal benefit and not for any commercial purpose or for 181b464e99SMatthias Ringwald * monetary gain. 191b464e99SMatthias Ringwald * 201b464e99SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 211b464e99SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 221b464e99SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*2fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 24*2fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 251b464e99SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 261b464e99SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 271b464e99SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 281b464e99SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 291b464e99SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 301b464e99SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311b464e99SMatthias Ringwald * SUCH DAMAGE. 321b464e99SMatthias Ringwald * 331b464e99SMatthias Ringwald * Please inquire about commercial licensing options at 341b464e99SMatthias Ringwald * [email protected] 351b464e99SMatthias Ringwald * 361b464e99SMatthias Ringwald */ 371b464e99SMatthias Ringwald 381b464e99SMatthias Ringwald /* 391b464e99SMatthias Ringwald * btstack_run_loop_qt.h 401b464e99SMatthias Ringwald * Functionality special to the Qt event loop 411b464e99SMatthias Ringwald */ 421b464e99SMatthias Ringwald 431b464e99SMatthias Ringwald #ifndef btstack_run_loop_QT_H 441b464e99SMatthias Ringwald #define btstack_run_loop_QT_H 451b464e99SMatthias Ringwald 461b464e99SMatthias Ringwald #include "btstack_run_loop.h" 471b464e99SMatthias Ringwald 481b464e99SMatthias Ringwald // BTstack Run Loop Object for Qt integration 491b464e99SMatthias Ringwald #if defined __cplusplus 501b464e99SMatthias Ringwald #include <QObject> 511b464e99SMatthias Ringwald #include <QTimer> 529988cd6fSMatthias Ringwald #ifdef Q_OS_WIN 539988cd6fSMatthias Ringwald #include <windows.h> 549988cd6fSMatthias Ringwald #include <QWinEventNotifier> 5584ede529SMatthias Ringwald #else 5684ede529SMatthias Ringwald #include <QSocketNotifier> 579988cd6fSMatthias Ringwald #endif 581b464e99SMatthias Ringwald class BTstackRunLoopQt : public QObject { 591b464e99SMatthias Ringwald Q_OBJECT 60b3483efbSMatthias Ringwald public: 61b3483efbSMatthias Ringwald BTstackRunLoopQt(void); 621b464e99SMatthias Ringwald public slots: 631b464e99SMatthias Ringwald void processTimers(void); 64b3483efbSMatthias Ringwald void processCallbacks(void); 657b06a562SMatthias Ringwald void pollDataSources(void); 669988cd6fSMatthias Ringwald #ifdef Q_OS_WIN 679988cd6fSMatthias Ringwald void processDataSource(HANDLE handle); 6884ede529SMatthias Ringwald #else 6984ede529SMatthias Ringwald void processDataSourceRead(int fd); 7084ede529SMatthias Ringwald void processDataSourceWrite(int fd); 719988cd6fSMatthias Ringwald #endif 72b3483efbSMatthias Ringwald signals: 73b3483efbSMatthias Ringwald void callbackAdded(void); 747b06a562SMatthias Ringwald void dataSourcesPollRequested(void); 751b464e99SMatthias Ringwald }; 761b464e99SMatthias Ringwald #endif 771b464e99SMatthias Ringwald 781b464e99SMatthias Ringwald #if defined __cplusplus 791b464e99SMatthias Ringwald extern "C" { 801b464e99SMatthias Ringwald #endif 811b464e99SMatthias Ringwald 821b464e99SMatthias Ringwald /** 831b464e99SMatthias Ringwald * Provide btstack_run_loop_qt instance 841b464e99SMatthias Ringwald */ 851b464e99SMatthias Ringwald const btstack_run_loop_t * btstack_run_loop_qt_get_instance(void); 861b464e99SMatthias Ringwald 871b464e99SMatthias Ringwald /* API_END */ 881b464e99SMatthias Ringwald 891b464e99SMatthias Ringwald #if defined __cplusplus 901b464e99SMatthias Ringwald } 911b464e99SMatthias Ringwald #endif 921b464e99SMatthias Ringwald 931b464e99SMatthias Ringwald #endif // btstack_run_loop_QT_H 94