>Betreff : Re: [linux-minidisc] Fw: Re: autodetection of HiMD devices (Windows) >Gesendet: 10.03.2010 12:27:50 >An : "manner.moe@gmx.de" >Von: "Michael Karcher <Michael.Karcher@fu-berlin.de>" >----- Originale Nachricht ----- >Am Mittwoch, den 10.03.2010, 01:29 +0100 schrieb manner.moe@gmx.de: >> >Betreff : [linux-minidisc] autodetection of HiMD devices (Windows) >> >Gesendet: 02.03.2010 19:06:45 >> >An : "linux-minidisc@lists.fu-berlin.de" >> >Von: "manner.moe@gmx.de" >> >> >----- Originale Nachricht ----- >> >Hello, >> >> >here is my code for automatic detection of himd devices (windows >> only, tested >> Hi, >> now I´ve also splitted the code into platform dependent and platform >> independent parts. >Thanks for your patch. I took some time for another review. Do you want >me to change the stuff or do you want to implement the changes yourself? You can change the stuff if you want. I don´t have much experiences in programming, so i can look at the changed code for better understanding how the changes are working. ..... >> +void QHiMDDetection::closeEvent(QCloseEvent *event) >> +{ >> + disconnect(); >> +} >disconnect is >QObject::disconnect( const char * signal = 0, const QObject * receiver = 0, const char * method = 0 ) >Is calling this function really necessary? yes, you´re right. Classes automatically disconnect signals as they go out of scope. >> ........ >> +}; >> + >> +QHiMDDetection * createDetection(); >> + >> +#endif // QHIMDDETECTION_H >I'm still unsure about this being the right model of >OS-dependent/non-dependent split, but it seems to be a good start. It >doesn't block your patch to go in. i´m trying to implement a factory function (first time i´m doing this, i know there´s much i have to learn). ........... >> diff --git a/qhimdtransfer/qhimdmainwindow.cpp b/qhimdtransfer/qhimdmainwindow.cpp >> index 78a1786..e3d3e2a 100644 >> --- a/qhimdtransfer/qhimdmainwindow.cpp >> +++ b/qhimdtransfer/qhimdmainwindow.cpp >> @@ -239,7 +239,9 @@ void QHiMDMainWindow::init_local_browser() >> QStringList DownloadFileList; >> localmodel.setFilter(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); >> localmodel.setNameFilters(QStringList() << "*.mp3" << "*.wav" << "*.oma"); >> - localmodel.setSorting(QDir::DirsFirst | QDir::Name); >> + localmodel.setNameFilterDisables(false); >> + localmodel.setReadOnly(false); >> + localmodel.setRootPath("/home"); >Are you *really* sure you need setRootPath()? This will break on Unix, >and that's why we removed setRootPath from the old code. Qt dokumentation says: "QFileSystemModel will not fetch any files or directories until setRootPath is called. This will prevent any unnecessary querying on the file system until that point such as listing the drives on Windows." On Windows all drives are listed if the specified root path is not available, so it´s only necessary get QFileSystemModel working. If there is no way to get it running on Unix, we have to write our own function. Easiest way is to implement a refresh button, but i prefer to implement automatic update. ........ >> diff --git a/qhimdtransfer/qhimdtransfer.pro >> b/qhimdtransfer/qhimdtransfer.pro >> index 1f0689d..1776b6b 100644 >> --- a/qhimdtransfer/qhimdtransfer.pro >> +++ b/qhimdtransfer/qhimdtransfer.pro >Is reformatting this file needed? If yes, please make two seperate >patches out of it by using git-commit after just reformatting. No, it´s not needed. Windows version of QtCreator automatically reformats the file (I´m actually using Qt SDK 2009.04). I can change qhimdtransfer.pro outside QtCreator to prevent this. ....... >> + >> + if(msg->message == WM_DEVICECHANGE) >> + { >> + PDEV_BROADCAST_HDR pHdr = (PDEV_BROADCAST_HDR )msg->lParam; >> + switch(msg->wParam) >> + { >> + case DBT_DEVICEARRIVAL : >> + { >> + if(pHdr->dbch_devicetype == DBT_DEVTYP_VOLUME) >> + { >> + PDEV_BROADCAST_VOLUME pHdrv = (PDEV_BROADCAST_VOLUME)pHdr; >> + path = FindPath(pHdrv->dbcv_unitmask); >> + devID = get_deviceID_from_driveletter(path.at(0).toAscii()); >> + if(!devID.isEmpty()) >> + { >> + if(is_himddevice(devID, name)) >> + { >> + qDebug() << "Message:DBT_DEVICEARRIVAL for drive " + path; >> + add_himddevice(path, name); >> + } >> + } >> + } >> + break; >> + } >> + case DBT_DEVICEREMOVECOMPLETE : >> + { >> + if(pHdr->dbch_devicetype == DBT_DEVTYP_VOLUME) >> + { >> + PDEV_BROADCAST_VOLUME pHdrv = (PDEV_BROADCAST_VOLUME)pHdr; >> + path = FindPath(pHdrv->dbcv_unitmask); >> + qDebug() << "Message:DBT_DEVICEREMOVECOMPLETE for drive " + path; >> + remove_himddevice(path); >> + } >> + break; >> + } >Do we really need to handle DEVICEREMOVECOMPLETE? You already called >remove_himddevice on DEVICEQUERYREMOVE if you consented. Yes i think we have to. If someone removes the device by just disconnecting usb cable without using "safely remove hardware" windows function DEVICEQUERYREMOVE message will not be sent. >Regards, > Michael Karcher greetings, Thomas Arp