Code Monkey home page Code Monkey logo

qdevicewatcher's Introduction

QDeviceWatcher can detect usb storage add and remove event. Tested on linux (>= 2.6), windows(mingw and msvc) and OSX(buggy).

License under LGPL 2.1 or later

Screenshot

Alt text Alt text Alt text Alt text Alt text

qdevicewatcher's People

Contributors

andrearicchi avatar erikbs avatar perencia avatar wang-bin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qdevicewatcher's Issues

Disable zdebug externally

A function that allows to disable the qdebug output when plugging or unplugging devices. This function should be usable externally if qdvicewatcher.h is included in the external code.

QMake error 129 QT 5.12

Hi, I am hoping you can help. I am using Win10, with Qt 5.12.2 and when I try to compile I am getting this error. Any help would be appreciated. I have tried with both MinGW64 and 32 bit. Here is my compile errors for both 32/64.

Thanks,

Rick

MinGW64

09:12:07: Running steps for project QDeviceWatcher...
09:12:07: Starting: "C:\Qt\Qt5.12.2\5.12.2\mingw73_64\bin\qmake.exe" "C:\Users\Rick Local\Desktop\QDeviceWatcher\qdevicewatcher-master\QDeviceWatcher.pro" -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
09:12:08: The process "C:\Qt\Qt5.12.2\5.12.2\mingw73_64\bin\qmake.exe" exited normally.
09:12:08: Starting: "C:\Qt\Qt5.12.2\Tools\mingw730_64\bin\mingw32-make.exe" -f "C:/Users/Rick Local/Desktop/QDeviceWatcher/build-QDeviceWatcher-Desktop_Qt_5_12_2_MinGW_64_bit-Debug/Makefile" qmake_all
0 [main] sh 13132 sync_with_child: child 17036(0x19C) died before initialization with status code 0xC0000142
29 [main] sh 13132 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
mingw32-make: *** [C:/Users/Rick Local/Desktop/QDeviceWatcher/build-QDeviceWatcher-Desktop_Qt_5_12_2_MinGW_64_bit-Debug/Makefile:37: sub-src-libQDeviceWatcher-pro-qmake_all] Error 129
09:12:08: The process "C:\Qt\Qt5.12.2\Tools\mingw730_64\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project QDeviceWatcher (kit: Desktop Qt 5.12.2 MinGW 64-bit)
When executing step "qmake"
09:12:08: Elapsed time: 00:00.

and with MinGW32

09:14:49: Running steps for project QDeviceWatcher...
09:14:49: Starting: "C:\Qt\Qt5.12.2\5.12.2\mingw73_32\bin\qmake.exe" "C:\Users\Rick Local\Desktop\QDeviceWatcher\qdevicewatcher-master\QDeviceWatcher.pro" -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
Info: creating stash file C:\Users\Rick Local\Desktop\QDeviceWatcher\build-QDeviceWatcher-Desktop_Qt_5_12_2_MinGW_32_bit-Debug.qmake.stash
09:14:49: The process "C:\Qt\Qt5.12.2\5.12.2\mingw73_32\bin\qmake.exe" exited normally.
09:14:49: Starting: "C:\Qt\Qt5.12.2\Tools\mingw730_32\bin\mingw32-make.exe" -f "C:/Users/Rick Local/Desktop/QDeviceWatcher/build-QDeviceWatcher-Desktop_Qt_5_12_2_MinGW_32_bit-Debug/Makefile" qmake_all
0 [main] sh 11132 sync_with_child: child 18004(0x1A0) died before initialization with status code 0xC0000142
16 [main] sh 11132 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
mingw32-make: *** [C:/Users/Rick Local/Desktop/QDeviceWatcher/build-QDeviceWatcher-Desktop_Qt_5_12_2_MinGW_32_bit-Debug/Makefile:37: sub-src-libQDeviceWatcher-pro-qmake_all] Error 129
09:14:50: The process "C:\Qt\Qt5.12.2\Tools\mingw730_32\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project QDeviceWatcher (kit: Desktop Qt 5.12.2 MinGW 32-bit)
When executing step "qmake"
09:14:50: Elapsed time: 00:01.

Missing header file - compiling on windows

#include <CoreServices/CoreServices.h>
#include <IOKit/storage/IOCDMedia.h>
#include <IOKit/storage/IODVDMedia.h>

Where can I get these files? I'm trying to compile but they are missing.
I'm copiling on windows are they needed only for mac ? if so how can I compile the project on windows avoiding the compiler to complain for that ?

udev support

because current implemention must run as a root user

OSX support

DARegisterDiskAppearedCallback, DARegisterDiskDisappearedCallback

update qmake pro

QDeviceWatcher not working on Windows

I tried using the following simple code on Windows to detect when devices are inserted or removed:

QDeviceWatcher deviceWatcher;
QObject::connect(&deviceWatcher, &QDeviceWatcher::deviceAdded, [](){
    qDebug() << "Device added";
});
QObject::connect(&deviceWatcher, &QDeviceWatcher::deviceChanged, [](){
    qDebug() << "Device changed";
});
QObject::connect(&deviceWatcher, &QDeviceWatcher::deviceRemoved, [](){
    qDebug() << "Device removed";
});

I tried inserting/removing several USB devices while this program was running, but none of these signals were ever emitted. The USB devices that I tried were a USB mouse and an Android phone with a USB cable.

Qt5 QAbstractNativeEventFilter

in Qt4, we can use installEventFilter and QAbstractEventDispatcher(i haven't let it work) to deal with system events theoretically. In Qt5 a new class is introduced, QAbstractNativeEventFilter, a better one.

unresolved external symbol in building qdevicewatcher

Hello,

I am confused with this point that I use qt5.5.1_msvc_32bit to build qdevicewatcher, But it happens unresolved external symbol about windows function, such as:

Creating library ..\out\lib_win_\QDeviceWatcherd2.lib and object ..\out\lib_win_\QDeviceWatcherd2.exp
qdevicewatcher_win32.obj : error LNK2019: unresolved external symbol imp__DefWindowProcW@16 referenced in function "long __stdcall dw_internal_proc(struct HWND *,unsigned int,unsigned int,long)" (?dw_internal_proc@@YGJPAUHWND__@@iij@Z)
qdevicewatcher_win32.obj : error LNK2019: unresolved external symbol imp__RegisterClassW@4 referenced in function "struct HWND * *cdecl dw_create_internal_window(void const )" (?dw_create_internal_window@@YAPAUHWND@@pbx@Z)
qdevicewatcher_win32.obj : error LNK2019: unresolved external symbol imp__UnregisterClassW@8 referenced in function "void __cdecl dw_destroy_internal_window(struct HWND *)" (?dw_destroy_internal_window@@YAXPAUHWND__@@@z)
qdevicewatcher_win32.obj : error LNK2019: unresolved external symbol imp__CreateWindowExW@48 referenced in function "struct HWND * *cdecl dw_create_internal_window(void const )" (?dw_create_internal_window@@YAPAUHWND@@pbx@Z)
qdevicewatcher_win32.obj : error LNK2019: unresolved external symbol imp__DestroyWindow@4 referenced in function "void __cdecl dw_destroy_internal_window(struct HWND *)" (?dw_destroy_internal_window@@YAXPAUHWND__@@@z)
qdevicewatcher_win32.obj : error LNK2019: unresolved external symbol imp__GetWindowLongW@8 referenced in function "long __stdcall dw_internal_proc(struct HWND *,unsigned int,unsigned int,long)" (?dw_internal_proc@@YGJPAUHWND__@@iij@Z)
qdevicewatcher_win32.obj : error LNK2019: unresolved external symbol imp__SetWindowLongW@12 referenced in function "struct HWND * *cdecl dw_create_internal_window(void const )" (?dw_create_internal_window@@YAPAUHWND@@pbx@Z)
..\out\lib_win_\QDeviceWatcherd2.dll : fatal error LNK1120: 7 unresolved externals

it points to windows function, Do I need to make some setting before build this project?

Bind: Address Already in Use

Your app compiles and runs fine. When I try to integrate the lib into my app I get "Bind: Address Already in Use". I tried to set SO_REUSEADDR as suggested here:

http://hea-www.harvard.edu/~fine/Tech/addrinuse.html

This did not help. I have integrated the files

qdevicewatcher.h
qdevicewatcher_p.h
qdevicewatcher.cpp
qdevicewatcher_linux.cpp

directly, not as a lib. My app builds without errors, but I get the bind() errormessage. Is there any idea how to overcome this issue?

Thanks in advance

QDevicewatcher does not build on Linux

I just tried to build the QDevicewatcher test app under Ubuntu 14.04, and it does not compile.
It seems that you use a mac for development, could that be true? Because I think that mac specific code is not removed by an #ifdef by the preprocessor - so it gets compiled under Linux as well and then the compiler doesn't find CoreServices.h and IOCDMedia.h + IODVDMedia.h

Did you try to compile the software/lib under Linux recently?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.