From manner.moe@gmx.de Sun Dec 01 23:31:48 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VnFYI-00442p-Lj>; Sun, 01 Dec 2013 23:31:46 +0100 Received: from mout.gmx.net ([212.227.15.19]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VnFYI-003acj-I4>; Sun, 01 Dec 2013 23:31:46 +0100 Received: from [192.168.2.100] ([82.83.139.78]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0M6P5z-1VO8OB30f5-00yMK3 for ; Sun, 01 Dec 2013 23:31:45 +0100 Message-ID: <529BB859.50809@gmx.de> Date: Sun, 01 Dec 2013 23:29:45 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: "linux-minidisc@lists.fu-berlin.de" Content-Type: multipart/mixed; boundary="------------060404030800020501040300" X-Provags-ID: V03:K0:MIGvk9AKBFLFAQHzjH8vs8lMM+wGATPB3JmCaxqz833RHagupMi w38VzBBJ+REmlVbbJRtXL9CrYi3p1rPLDrz/CtmwNxw2kIJhtw2fNtSxpRNlmqjgSmEcJ3l R247aGAS9X3h7eF8hIDA7edpeveGIzCNE1sBzR7If0eDXb6PGTt+xk/BPJ668PV3mJiYlv+ bm9WFYWYs+Da4mDoOOIsg== X-Originating-IP: 212.227.15.19 X-ZEDAT-Hint: A X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1385937106-00000AC9-816FBB28/0-0/0-0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.004600, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Burundi.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: [linux-minidisc] Qt5 compatibility X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Dec 2013 22:31:48 -0000 This is a multi-part message in MIME format. --------------060404030800020501040300 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Hi, i upgraded my windows build environment to Qt5 for testing. I made some changes so that the code can be complied with Qt4 and Qt5. Regards Thomas P.S.: Tested with Qt 4.7 and Qt 5.1 with gcc on Windows XP --------------060404030800020501040300 Content-Type: text/x-patch; name="0001-Adaptations-to-make-the-code-Qt5-compatible.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Adaptations-to-make-the-code-Qt5-compatible.patch" >From 4619f10fc873f1c115f7c26258285e9a667bf135 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Sun, 1 Dec 2013 20:26:00 +0100 Subject: [PATCH] Adaptations to make the code Qt5 compatible --- qhimdtransfer/main.cpp | 2 +- qhimdtransfer/qhimdaboutdialog.h | 2 +- qhimdtransfer/qhimdformatdialog.h | 2 +- qhimdtransfer/qhimdmainwindow.cpp | 10 +++++----- qhimdtransfer/qhimdmainwindow.h | 4 ++-- qhimdtransfer/qhimdmodel.cpp | 6 ++++-- qhimdtransfer/qhimdmodel.h | 2 +- qhimdtransfer/qhimdtransfer.pro | 4 ++++ qhimdtransfer/qhimduploaddialog.h | 2 +- qhimdtransfer/qhimdwindetection.cpp | 21 +++++++++++++++------ 10 files changed, 35 insertions(+), 20 deletions(-) diff --git a/qhimdtransfer/main.cpp b/qhimdtransfer/main.cpp index 91ae588..e7a3e2f 100644 --- a/qhimdtransfer/main.cpp +++ b/qhimdtransfer/main.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include "qhimdmainwindow.h" diff --git a/qhimdtransfer/qhimdaboutdialog.h b/qhimdtransfer/qhimdaboutdialog.h index c7c8a5b..1ff4cda 100644 --- a/qhimdtransfer/qhimdaboutdialog.h +++ b/qhimdtransfer/qhimdaboutdialog.h @@ -1,7 +1,7 @@ #ifndef QHIMDABOUTDIALOG_H #define QHIMDABOUTDIALOG_H -#include +#include namespace Ui { class QHiMDAboutDialog; diff --git a/qhimdtransfer/qhimdformatdialog.h b/qhimdtransfer/qhimdformatdialog.h index 5b92c8a..d2bb04c 100644 --- a/qhimdtransfer/qhimdformatdialog.h +++ b/qhimdtransfer/qhimdformatdialog.h @@ -1,7 +1,7 @@ #ifndef QHIMDFORMATDIALOG_H #define QHIMDFORMATDIALOG_H -#include +#include namespace Ui { class QHiMDFormatDialog; diff --git a/qhimdtransfer/qhimdmainwindow.cpp b/qhimdtransfer/qhimdmainwindow.cpp index e2675d9..1b86651 100644 --- a/qhimdtransfer/qhimdmainwindow.cpp +++ b/qhimdtransfer/qhimdmainwindow.cpp @@ -2,8 +2,8 @@ #include "ui_qhimdmainwindow.h" #include "qhimdaboutdialog.h" #include "qhimduploaddialog.h" -#include -#include +#include +#include #include @@ -282,8 +282,8 @@ bool QHiMDMainWindow::autodetect_init() { int k; - k = QObject::connect(detect, SIGNAL(himd_found(QString)), this, SLOT(himd_found(QString))); - k += QObject::connect(detect, SIGNAL(himd_removed(QString)), this, SLOT(himd_removed(QString))); + k = (bool)QObject::connect(detect, SIGNAL(himd_found(QString)), this, SLOT(himd_found(QString))); + k += (bool)QObject::connect(detect, SIGNAL(himd_removed(QString)), this, SLOT(himd_removed(QString))); if(!k) return false; @@ -300,7 +300,7 @@ void QHiMDMainWindow::open_himd_at(const QString & path) QMessageBox himdStatus; QString error; - error = trackmodel.open(path.toAscii()); + error = trackmodel.open(path.toLatin1()); if (!error.isNull()) { himdStatus.setText(tr("Error opening HiMD data. Make sure you chose the proper root directory of your HiMD-Walkman.\n") + error); diff --git a/qhimdtransfer/qhimdmainwindow.h b/qhimdtransfer/qhimdmainwindow.h index 85be8ae..b9b14f7 100644 --- a/qhimdtransfer/qhimdmainwindow.h +++ b/qhimdtransfer/qhimdmainwindow.h @@ -1,8 +1,8 @@ #ifndef QHIMDMAINWINDOW_H #define QHIMDMAINWINDOW_H -#include -#include +#include +#include #include #include "qhimdaboutdialog.h" #include "qhimdformatdialog.h" diff --git a/qhimdtransfer/qhimdmodel.cpp b/qhimdtransfer/qhimdmodel.cpp index ac4bde5..9d8f4ed 100644 --- a/qhimdtransfer/qhimdmodel.cpp +++ b/qhimdtransfer/qhimdmodel.cpp @@ -232,8 +232,9 @@ QString QHiMDTracksModel::open(const QString & path) return QString::fromUtf8(status.statusmsg); } close(); + beginResetModel(); himd = newhimd; - reset(); /* inform views that the model contents changed */ + endResetModel(); /* inform views that the model contents changed */ return QString(); } @@ -247,9 +248,10 @@ void QHiMDTracksModel::close() struct himd * oldhimd; if(!himd) return; + beginResetModel(); oldhimd = himd; himd = NULL; - reset(); /* inform views that the model contents changed */ + endResetModel(); /* inform views that the model contents changed */ himd_close(oldhimd); delete oldhimd; } diff --git a/qhimdtransfer/qhimdmodel.h b/qhimdtransfer/qhimdmodel.h index 6ccc2f8..65218c3 100644 --- a/qhimdtransfer/qhimdmodel.h +++ b/qhimdtransfer/qhimdmodel.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include "himd.h" #include "sony_oma.h" diff --git a/qhimdtransfer/qhimdtransfer.pro b/qhimdtransfer/qhimdtransfer.pro index db12602..6d3e39d 100644 --- a/qhimdtransfer/qhimdtransfer.pro +++ b/qhimdtransfer/qhimdtransfer.pro @@ -5,6 +5,10 @@ TARGET = qhimdtransfer DEPENDPATH += . INCLUDEPATH += . +# for Qt5 compatibility +QT += gui +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + # determine version number from git VERSION = $$system(sh ../get_version.sh) # !isEmpty(VERSION){ diff --git a/qhimdtransfer/qhimduploaddialog.h b/qhimdtransfer/qhimduploaddialog.h index 86bcd5c..157c58d 100644 --- a/qhimdtransfer/qhimduploaddialog.h +++ b/qhimdtransfer/qhimduploaddialog.h @@ -1,7 +1,7 @@ #ifndef QHIMDUPLOADDIALOG_H #define QHIMDUPLOADDIALOG_H -#include +#include #include "qhimdmodel.h" namespace Ui { diff --git a/qhimdtransfer/qhimdwindetection.cpp b/qhimdtransfer/qhimdwindetection.cpp index 1dc437a..3e79038 100644 --- a/qhimdtransfer/qhimdwindetection.cpp +++ b/qhimdtransfer/qhimdwindetection.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include "qhimddetection.h" #define WINVER 0x0500 @@ -49,6 +49,7 @@ private: void remove_himd(HANDLE devhandle); HDEVNOTIFY register_mediaChange(HANDLE devhandle); void unregister_mediaChange(HDEVNOTIFY himd_change); + bool nativeEvent(const QByteArray & eventType, void * message, long *result); bool winEvent(MSG * msg, long * result); }; @@ -153,7 +154,7 @@ static bool is_himddevice(QString devID, QString & name) unsigned long buflen; QString recname, devicepath; - CM_Locate_DevNodeA(&devinst, devID.toAscii().data(), NULL); + CM_Locate_DevNodeA(&devinst, devID.toLatin1().data(), NULL); CM_Get_Parent(&devinstparent, devinst, NULL); if(devID.contains("RemovableMedia", Qt::CaseInsensitive)) // on Windows XP: get next parent device instance @@ -201,7 +202,7 @@ void QHiMDWinDetection::add_himddevice(QString path, QString name) STORAGE_DEVICE_NUMBER sdn; OFSTRUCT OFfile; - drv[4] = path.at(0).toAscii(); + drv[4] = path.at(0).toLatin1(); hdev = CreateFileA(drv, NULL , FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); @@ -223,7 +224,7 @@ void QHiMDWinDetection::add_himddevice(QString path, QString name) new_device->path = path; new_device->recorder_name = name; - file[0] = path.at(0).toAscii(); + file[0] = path.at(0).toLatin1(); if(OpenFile(file, &OFfile, OF_EXIST) != HFILE_ERROR) { new_device->md_inserted = true; @@ -301,7 +302,7 @@ HDEVNOTIFY QHiMDWinDetection::register_mediaChange(HANDLE devhandle) filter.dbch_handle = devhandle; filter.dbch_eventguid = my_GUID_IO_MEDIA_ARRIVAL; // includes GUID_IO_MEDIA_REMOVAL notification - return RegisterDeviceNotification( this->winId(), &filter, DEVICE_NOTIFY_WINDOW_HANDLE); + return RegisterDeviceNotification( (HWND)this->winId(), &filter, DEVICE_NOTIFY_WINDOW_HANDLE); } @@ -311,6 +312,14 @@ void QHiMDWinDetection::unregister_mediaChange(HDEVNOTIFY himd_change) UnregisterDeviceNotification(himd_change); } +bool QHiMDWinDetection::nativeEvent(const QByteArray & eventType, void * message, long *result) +{ + if (eventType == "windows_generic_MSG") + return winEvent(reinterpret_cast(message), result); + + return false; +} + bool QHiMDWinDetection::winEvent(MSG * msg, long * result) { QString name, devID, path ; @@ -325,7 +334,7 @@ bool QHiMDWinDetection::winEvent(MSG * msg, long * result) { PDEV_BROADCAST_VOLUME pHdrv = (PDEV_BROADCAST_VOLUME)pHdr; path = FindPath(pHdrv->dbcv_unitmask); - devID = get_deviceID_from_driveletter(path.at(0).toAscii()); + devID = get_deviceID_from_driveletter(path.at(0).toLatin1()); if(!devID.isEmpty()) { if(is_himddevice(devID, name)) -- 1.8.4.msysgit.0 --------------060404030800020501040300-- From glaubitz@physik.fu-berlin.de Sun Dec 01 23:33:11 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VnFZe-00449G-5i>; Sun, 01 Dec 2013 23:33:10 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1VnFZe-000QYP-3D>; Sun, 01 Dec 2013 23:33:10 +0100 Received: from port-92-206-26-122.dynamic.qsc.de ([92.206.26.122] helo=[192.168.178.71]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1VnFZd-003v2d-SU>; Sun, 01 Dec 2013 23:33:10 +0100 Message-ID: <529BB925.7070906@physik.fu-berlin.de> Date: Sun, 01 Dec 2013 23:33:09 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 MIME-Version: 1.0 To: Thomas Arp References: <529BB859.50809@gmx.de> In-Reply-To: <529BB859.50809@gmx.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.206.26.122 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1385937190-00000AC9-3AC275F2/0-0/0-0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Dschibuti.ZEDAT.FU-Berlin.DE X-Spam-Level: Cc: "linux-minidisc@lists.fu-berlin.de" Subject: Re: [linux-minidisc] Qt5 compatibility X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Dec 2013 22:33:11 -0000 On 12/01/2013 11:29 PM, Thomas Arp wrote: > i upgraded my windows build environment to Qt5 for testing. > I made some changes so that the code can be complied with Qt4 and Qt5. Nice, thanks for the patch! I'll have a look in a minute. Just have to update some other Debian packages. Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From glaubitz@physik.fu-berlin.de Mon Dec 02 00:06:04 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VnG5T-0045nV-BV>; Mon, 02 Dec 2013 00:06:03 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1VnG5T-000cR5-9d>; Mon, 02 Dec 2013 00:06:03 +0100 Received: from port-92-206-26-122.dynamic.qsc.de ([92.206.26.122] helo=[192.168.178.71]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1VnG5T-003x7d-5k>; Mon, 02 Dec 2013 00:06:03 +0100 Message-ID: <529BC0D9.3090509@physik.fu-berlin.de> Date: Mon, 02 Dec 2013 00:06:01 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 MIME-Version: 1.0 To: Thomas Arp References: <529BB859.50809@gmx.de> <529BB925.7070906@physik.fu-berlin.de> In-Reply-To: <529BB925.7070906@physik.fu-berlin.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.206.26.122 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1385939163-00000AC9-A40179DE/0-0/0-0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Algerien.ZEDAT.FU-Berlin.DE X-Spam-Level: Cc: "linux-minidisc@lists.fu-berlin.de" Subject: Re: [linux-minidisc] Qt5 compatibility X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Dec 2013 23:06:04 -0000 On 12/01/2013 11:33 PM, John Paul Adrian Glaubitz wrote: > On 12/01/2013 11:29 PM, Thomas Arp wrote: >> i upgraded my windows build environment to Qt5 for testing. >> I made some changes so that the code can be complied with Qt4 and Qt5. > > Nice, thanks for the patch! I'll have a look in a minute. Just have to > update some other Debian packages. Patch looks fine to me. I can't test it with Qt5 for the time being, however. Any comments from Michael? Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From linux-minidisc@lists.fu-berlin.de Mon Dec 02 04:35:54 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VnKIa-0007K4-R1>; Mon, 02 Dec 2013 04:35:52 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VnKIa-001sAP-PA>; Mon, 02 Dec 2013 04:35:52 +0100 Received: from z6.physik.fu-berlin.de ([160.45.34.66]) by inpost2.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtps (envelope-from ) id <1VnKIa-004Ajv-NO>; Mon, 02 Dec 2013 04:35:52 +0100 Received: from glaubitz by z6.physik.fu-berlin.de with local (Exim 4.82) (envelope-from ) id 1VnKKM-0001SN-PG for linux-minidisc@lists.fu-berlin.de; Mon, 02 Dec 2013 04:37:42 +0100 To: linux-minidisc@lists.fu-berlin.de MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: baf0f85914c5f2edcc9853a8e3e77cad6cb8d097 X-Git-Newrev: 79cff78f1427946da326150791782f1192db4116 Auto-Submitted: auto-generated Message-Id: From: John Paul Adrian Glaubitz Date: Mon, 02 Dec 2013 04:37:42 +0100 X-Originating-IP: 160.45.34.66 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1385955352-00000AC9-2B72D2AE/0-0/0-0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Botsuana.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: [linux-minidisc] [commit] Linux utilities to deal with Sony Minidisc Walkman branch master updated. 0.9.9-1-g79cff78 X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Dec 2013 03:35:54 -0000 This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Linux utilities to deal with Sony Minidisc Walkman". The branch, master has been updated via 79cff78f1427946da326150791782f1192db4116 (commit) from baf0f85914c5f2edcc9853a8e3e77cad6cb8d097 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 79cff78f1427946da326150791782f1192db4116 Author: Thomas Arp Date: Mon Dec 2 04:37:28 2013 +0100 Add build support for Qt5. ----------------------------------------------------------------------- Summary of changes: qhimdtransfer/main.cpp | 2 +- qhimdtransfer/qhimdaboutdialog.h | 2 +- qhimdtransfer/qhimdformatdialog.h | 2 +- qhimdtransfer/qhimdmainwindow.cpp | 10 +++++----- qhimdtransfer/qhimdmainwindow.h | 4 ++-- qhimdtransfer/qhimdmodel.cpp | 6 ++++-- qhimdtransfer/qhimdmodel.h | 2 +- qhimdtransfer/qhimdtransfer.pro | 4 ++++ qhimdtransfer/qhimduploaddialog.h | 2 +- qhimdtransfer/qhimdwindetection.cpp | 21 +++++++++++++++------ 10 files changed, 35 insertions(+), 20 deletions(-) hooks/post-receive -- Linux utilities to deal with Sony Minidisc Walkman From manner.moe@gmx.de Sun Dec 15 22:16:35 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VsJ3B-000dgC-LV>; Sun, 15 Dec 2013 22:16:33 +0100 Received: from mout.gmx.net ([212.227.17.22]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VsJ3B-001LdZ-IJ>; Sun, 15 Dec 2013 22:16:33 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0MDW9x-1Vkt3N0dAr-00Gp1u for ; Sun, 15 Dec 2013 22:16:32 +0100 Message-ID: <52AE1C28.6060007@gmx.de> Date: Sun, 15 Dec 2013 22:16:24 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "linux-minidisc@lists.fu-berlin.de" References: <529BB859.50809@gmx.de> <529BB925.7070906@physik.fu-berlin.de> <529BC0D9.3090509@physik.fu-berlin.de> In-Reply-To: <529BC0D9.3090509@physik.fu-berlin.de> Content-Type: multipart/mixed; boundary="------------050508010701000101010109" X-Provags-ID: V03:K0:NKcs0F48ux7tWedwNjIsyQ5kjkH8hfv41KMZb6xKnN4TrYuIJTU FpqX8FqVT3XAQYO+a/hvzVNWY3+yYV9CJazI12om4n+cBrw5M7n2dOac9JUXbULPHRNg+zk +M0JZABKPtmawwBbT2HN4DuJGuOAvF65p7O5NapbS32+Ylf0cNIRGPZqa1yESmf8TRZXYvO Z2Ee463Djl44tc4hDaIFg== X-Originating-IP: 212.227.17.22 X-ZEDAT-Hint: A X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387142193-0001F7A4-521F4796/0-0/0-0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000174, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Botsuana.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] Qt5 compatibility X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Dec 2013 21:16:35 -0000 This is a multi-part message in MIME format. --------------050508010701000101010109 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, there is one more incompatibility with Qt5 in the QTime class. A QTime object must be initialized before using it, else it will be invalid. So current source code will not display track length if compiled with Qt5. I made a small patch fixing this. Regards Thomas --------------050508010701000101010109 Content-Type: text/x-patch; name="0001-for-Qt5-support-QTime-object-must-be-initialized-els.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-for-Qt5-support-QTime-object-must-be-initialized-els.pa"; filename*1="tch" >From 554363f46ea51e36694765429271ebb1566cd9a3 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Sun, 15 Dec 2013 22:03:39 +0100 Subject: [PATCH] for Qt5 support: QTime object must be initialized, else it will be invalid and not usable --- qhimdtransfer/qhimdmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qhimdtransfer/qhimdmodel.cpp b/qhimdtransfer/qhimdmodel.cpp index 9d8f4ed..d0d303d 100644 --- a/qhimdtransfer/qhimdmodel.cpp +++ b/qhimdtransfer/qhimdmodel.cpp @@ -64,11 +64,11 @@ QString QHiMDTrack::codecname() const QTime QHiMDTrack::duration() const { - QTime t; + QTime t(0,0,0); if(trackslot != 0) return t.addSecs(ti.seconds); else - return t; + return QTime(); } bool QHiMDTrack::copyprotected() const -- 1.8.4.msysgit.0 --------------050508010701000101010109-- From glaubitz@physik.fu-berlin.de Sun Dec 15 22:23:04 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VsJ9S-000egg-Ji>; Sun, 15 Dec 2013 22:23:02 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1VsJ9S-003U1z-Hw>; Sun, 15 Dec 2013 22:23:02 +0100 Received: from port-92-206-24-241.dynamic.qsc.de ([92.206.24.241] helo=[192.168.178.71]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1VsJ9S-001Xeo-Dp>; Sun, 15 Dec 2013 22:23:02 +0100 Message-ID: <52AE1DB5.80503@physik.fu-berlin.de> Date: Sun, 15 Dec 2013 22:23:01 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.1.1 MIME-Version: 1.0 To: Thomas Arp , "linux-minidisc@lists.fu-berlin.de" References: <529BB859.50809@gmx.de> <529BB925.7070906@physik.fu-berlin.de> <529BC0D9.3090509@physik.fu-berlin.de> <52AE1C28.6060007@gmx.de> In-Reply-To: <52AE1C28.6060007@gmx.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.206.24.241 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387142582-0001F7A4-421AAC71/0-0/0-0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000019, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Dschibuti.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] Qt5 compatibility X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Dec 2013 21:23:04 -0000 On 12/15/2013 10:16 PM, Thomas Arp wrote: > there is one more incompatibility with Qt5 in the QTime class. A QTime > object must be initialized before using it, else it will be invalid. > So current source code will not display track length if compiled with Qt5. > I made a small patch fixing this. > - return t; > + return QTime(); Are you sure this is correct? Shouldn't this still return the name of the object and not the name of the class? Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From manner.moe@gmx.de Sun Dec 15 22:30:44 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VsJGt-000g4q-E0>; Sun, 15 Dec 2013 22:30:43 +0100 Received: from mout.gmx.net ([212.227.15.19]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VsJGt-001NZ4-BF>; Sun, 15 Dec 2013 22:30:43 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0LjuR3-1VHJYu2gzh-00bodv for ; Sun, 15 Dec 2013 22:30:41 +0100 Message-ID: <52AE1F79.8020607@gmx.de> Date: Sun, 15 Dec 2013 22:30:33 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "linux-minidisc@lists.fu-berlin.de" References: <529BB859.50809@gmx.de> <529BB925.7070906@physik.fu-berlin.de> <529BC0D9.3090509@physik.fu-berlin.de> <52AE1C28.6060007@gmx.de> <52AE1DB5.80503@physik.fu-berlin.de> <52AE1F4F.3090606@gmx.de> In-Reply-To: <52AE1F4F.3090606@gmx.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:0jS1jF1maR7XeN+E+11Vn76q+G/ZT6Ok5XXRiJsPJh6/5cwQ/AX SV+GmKW3awO9qVLzU0Whm7iuGzJ8Gto7yJyqZ8ERi3F63bFDvOzM4XC4USOMweK76OwIg65 j8IkE5/yFIagKF0s7AnaI5HYk/Xopxch5wVrQqw3ToL947GEJXR0OL+lkZ4uKAikwM9CMdR k9VkZKSUtkzObYnpNKJcA== X-Originating-IP: 212.227.15.19 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387143043-0001F7A4-B57E1386/0-0/0-0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.004546, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Dschibuti.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] Qt5 compatibility X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Dec 2013 21:30:44 -0000 Am 15.12.2013 22:29, schrieb Thomas Arp: > Am 15.12.2013 22:23, schrieb John Paul Adrian Glaubitz: >> On 12/15/2013 10:16 PM, Thomas Arp wrote: >>> there is one more incompatibility with Qt5 in the QTime class. A QTime >>> object must be initialized before using it, else it will be invalid. >>> So current source code will not display track length if compiled >>> with Qt5. >>> I made a small patch fixing this. >>> - return t; >>> + return QTime(); >> Are you sure this is correct? Shouldn't this still return the name >> of the object and not the name of the class? >> >> Adrian > > Yes, i am sure this is correct. > > return t; // returns a qtime object which is initialized > with 0,0,0 -> so track list will show 00:00 as length > return QTime(); // return an empty invalid QTime object, tracklist > will show nothing btw. an empty string > > I think this important, if the track length is smaller than 1 second > the track list will show 00:00. > If we use "return t;" we don't know if the track slot is valid or if > the track is smaller than 1 second. > > Thomas From linux-minidisc@lists.fu-berlin.de Sun Dec 15 22:32:50 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VsJIu-000gSU-Jk>; Sun, 15 Dec 2013 22:32:48 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VsJIu-003Wkt-Hg>; Sun, 15 Dec 2013 22:32:48 +0100 Received: from z6.physik.fu-berlin.de ([160.45.34.66]) by inpost2.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtps (envelope-from ) id <1VsJIu-001YFp-Fu>; Sun, 15 Dec 2013 22:32:48 +0100 Received: from glaubitz by z6.physik.fu-berlin.de with local (Exim 4.82) (envelope-from ) id 1VsJKs-0004V0-Md for linux-minidisc@lists.fu-berlin.de; Sun, 15 Dec 2013 22:34:50 +0100 To: linux-minidisc@lists.fu-berlin.de MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 79cff78f1427946da326150791782f1192db4116 X-Git-Newrev: 54971b8b39fbbe614aad5c766bffa5062b281f3d Auto-Submitted: auto-generated Message-Id: From: John Paul Adrian Glaubitz Date: Sun, 15 Dec 2013 22:34:50 +0100 X-Originating-IP: 160.45.34.66 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387143168-0001F7A4-9E9491B0/0-0/0-0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Botsuana.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: [linux-minidisc] [commit] Linux utilities to deal with Sony Minidisc Walkman branch master updated. 0.9.9-2-g54971b8 X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Dec 2013 21:32:50 -0000 This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Linux utilities to deal with Sony Minidisc Walkman". The branch, master has been updated via 54971b8b39fbbe614aad5c766bffa5062b281f3d (commit) from 79cff78f1427946da326150791782f1192db4116 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 54971b8b39fbbe614aad5c766bffa5062b281f3d Author: Thomas Arp Date: Sun Dec 15 22:21:42 2013 +0100 Initialize QTime object in QHiMDTrack::codecname before use. ----------------------------------------------------------------------- Summary of changes: qhimdtransfer/qhimdmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- Linux utilities to deal with Sony Minidisc Walkman From glaubitz@physik.fu-berlin.de Sun Dec 15 22:34:07 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VsJK9-000ggy-Oj>; Sun, 15 Dec 2013 22:34:05 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1VsJK9-003XGl-Mp>; Sun, 15 Dec 2013 22:34:05 +0100 Received: from port-92-206-24-241.dynamic.qsc.de ([92.206.24.241] helo=[192.168.178.71]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1VsJK9-001YO8-Ir>; Sun, 15 Dec 2013 22:34:05 +0100 Message-ID: <52AE204C.1010602@physik.fu-berlin.de> Date: Sun, 15 Dec 2013 22:34:04 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.1.1 MIME-Version: 1.0 To: Thomas Arp , "linux-minidisc@lists.fu-berlin.de" References: <529BB859.50809@gmx.de> <529BB925.7070906@physik.fu-berlin.de> <529BC0D9.3090509@physik.fu-berlin.de> <52AE1C28.6060007@gmx.de> <52AE1DB5.80503@physik.fu-berlin.de> <52AE1F4F.3090606@gmx.de> <52AE1F79.8020607@gmx.de> In-Reply-To: <52AE1F79.8020607@gmx.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.206.24.241 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387143245-0001F7A4-C9FFA917/0-0/0-0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Gabun.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] Qt5 compatibility X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Dec 2013 21:34:07 -0000 On 12/15/2013 10:30 PM, Thomas Arp wrote: >> return t; // returns a qtime object which is initialized >> with 0,0,0 -> so track list will show 00:00 as length >> return QTime(); // return an empty invalid QTime object, tracklist >> will show nothing btw. an empty string >> >> I think this important, if the track length is smaller than 1 second >> the track list will show 00:00. >> If we use "return t;" we don't know if the track slot is valid or if >> the track is smaller than 1 second. Oops, yes. I should read the full source instead just the lines changed next time ;). Applied. Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From manner.moe@gmx.de Wed Dec 18 00:45:35 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vt4KQ-0035ok-KQ>; Wed, 18 Dec 2013 00:45:30 +0100 Received: from mout.gmx.net ([212.227.15.19]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vt4KQ-001sG1-BX>; Wed, 18 Dec 2013 00:45:30 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx101) with ESMTPSA (Nemesis) id 0Mchyv-1WAsKM2QnB-00Hyd1 for ; Wed, 18 Dec 2013 00:45:28 +0100 Message-ID: <52B0E208.7090904@gmx.de> Date: Wed, 18 Dec 2013 00:45:12 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "linux-minidisc@lists.fu-berlin.de" Content-Type: multipart/mixed; boundary="------------080204090806020407090108" X-Provags-ID: V03:K0:+aRyiWNYQjVUMMVDHS9/PCKzlS17bCMIIRegxflQ9Nc+DGp+/e6 2rdN91RIBY0IU7+KGN8Nvj6TIPxF5ZHkXWtShSJpKQzw0R0Kzy22EUajlahriy0wiX2YeNa SmEuvRhO9HDLe8OQAcWzaf1YsCnGNv+njWT8BLhWf+glQM0cP9T20wsVmnWZPAbFymc6CwT Azm1kpjxs4CLiGR7NppGA== X-Originating-IP: 212.227.15.19 X-ZEDAT-Hint: A X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387323930-0001F7A4-68B507C4/0-0/0-0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.188300, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,T_FRT_PROFILE1 X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Benin.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Dec 2013 23:45:35 -0000 This is a multi-part message in MIME format. --------------080204090806020407090108 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Hi, i started implementing netmdsupport for the gui application some time ago. As the current master repository has changed, i updated my patches. They can be applied to the current repo now. I also made some cleanup and improvement. There are many changes, rearrangements and code moving, i splitted the patch into several parts (file by file btw. class by class). It can only be compiled if all patches are applied because many changes depends on other ones in other files. I just splitted it to make review easier. I hope Michael will find some time for a review. Thomas --------------080204090806020407090108 Content-Type: text/x-patch; name="0001-including-netmd-support-into-the-gui-application-imp.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-including-netmd-support-into-the-gui-application-imp.pa"; filename*1="tch" >From 0e055cb55082dd85cf0f45d99549035033f0468b Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Tue, 17 Dec 2013 23:15:40 +0100 Subject: [PATCH 1/7] including netmd support into the gui application: implemented new class QNetMDTrack analogous to QHiMDTrack and put a base class QMDTrack over it holding common members --- qhimdtransfer/qmdtrack.cpp | 222 +++++++++++++++++++++++++++++++++++++++++++++ qhimdtransfer/qmdtrack.h | 91 +++++++++++++++++++ 2 files changed, 313 insertions(+) create mode 100644 qhimdtransfer/qmdtrack.cpp create mode 100644 qhimdtransfer/qmdtrack.h diff --git a/qhimdtransfer/qmdtrack.cpp b/qhimdtransfer/qmdtrack.cpp new file mode 100644 index 0000000..9ecca74 --- /dev/null +++ b/qhimdtransfer/qmdtrack.cpp @@ -0,0 +1,222 @@ +#include "qmdtrack.h" + +static QString get_himd_str(struct himd * himd, int idx) +{ + QString outstr; + char * str; + if(!idx) + return QString(); + str = himd_get_string_utf8(himd, idx, NULL, NULL); + if(!str) + return QString(); + + outstr = QString::fromUtf8(str); + himd_free(str); + return outstr; +} + +QHiMDTrack::QHiMDTrack(struct himd * himd, unsigned int trackindex) : himd(himd), trknum(trackindex) +{ + trackslot = himd_get_trackslot(himd, trackindex, NULL); + if(trackslot != 0) + if(himd_get_track_info(himd, trackslot, &ti, NULL) < 0) + trackslot = -1; +} + +QHiMDTrack::~QHiMDTrack() +{ + himd = NULL; +} + +unsigned int QHiMDTrack::tracknum() const +{ + return trknum; +} + +QString QHiMDTrack::title() const +{ + if(trackslot != 0) + return get_himd_str(himd, ti.title); + else + return QString(); +} + +QString QHiMDTrack::artist() const +{ + if(trackslot != 0) + return get_himd_str(himd, ti.artist); + else + return QString(); +} + +QString QHiMDTrack::album() const +{ + if(trackslot != 0) + return get_himd_str(himd, ti.album); + else + return QString(); +} + +QString QHiMDTrack::codecname() const +{ + if(trackslot != 0) + return himd_get_codec_name(&ti); + else + return QString(); +} + +QTime QHiMDTrack::duration() const +{ + QTime t(0,0,0); + if(trackslot != 0) + return t.addSecs(ti.seconds); + else + return QTime(); +} + +bool QHiMDTrack::copyprotected() const +{ + if(trackslot != 0) + return !himd_track_uploadable(himd, &ti); + return true; +} + +int QHiMDTrack::blockcount() const +{ + if(trackslot != 0) + return himd_track_blocks(himd, &ti, NULL); + else + return 0; +} + +QString QHiMDTrack::openMpegStream(struct himd_mp3stream * str) const +{ + struct himderrinfo status; + if(himd_mp3stream_open(himd, trackslot, str, &status) < 0) + return QString::fromUtf8(status.statusmsg); + return QString(); +} + +QString QHiMDTrack::openNonMpegStream(struct himd_nonmp3stream * str) const +{ + struct himderrinfo status; + if(himd_nonmp3stream_open(himd, trackslot, str, &status) < 0) + return QString::fromUtf8(status.statusmsg); + return QString(); +} + +QByteArray QHiMDTrack::makeEA3Header() const +{ + char header[EA3_FORMAT_HEADER_SIZE]; + make_ea3_format_header(header, &ti.codec_info); + return QByteArray(header,EA3_FORMAT_HEADER_SIZE); +} + + +QNetMDTrack::QNetMDTrack(netmd_dev_handle * deviceh, minidisc * my_md, int trackindex) +{ + uint8_t g; + struct netmd_pair const *bitrate; + char *name, buffer[256]; + + devh = deviceh; + md = my_md; + trkindex = trackindex; + + if(netmd_request_title(devh, trkindex, buffer, sizeof(buffer)) < 0) + { + trkindex = -1; + return; // no track with this trackindex + } + + /* Figure out which group this track is in */ + for( g = 1; g < md->group_count; g++ ) + { + if( (md->groups[g].start <= trkindex+1U) && (md->groups[g].finish >= trkindex+1U )) + { + groupstring = QString(md->groups[g].name); + break; + } + } + + netmd_request_track_time(devh, trkindex, &time); + netmd_request_track_flags(devh, trkindex, &flags); + netmd_request_track_bitrate(devh, trkindex, &bitrate_id, &channel); + + bitrate = find_pair(bitrate_id, bitrates); + + /* Skip 'LP:' prefix... the codec type shows up in the list anyway*/ + name = strncmp( buffer, "LP:", 3 ) ? buffer : buffer+3 ; + + titlestring = QString(name); + codecstring = QString(bitrate->name); + blocks = 0; +} + +QNetMDTrack::~QNetMDTrack() +{ + devh = NULL; + md = NULL; +} + +unsigned int QNetMDTrack::tracknum() const +{ + /* returns zero based track number, maybe this function should return a one based track number as shown in the treeview, + * trackindex -> zero based; tracknumber -> one based + */ + return trkindex; +} + +QString QNetMDTrack::group() const +{ + if(trkindex < 0) + return QString(); + + return groupstring; +} + +QString QNetMDTrack::title() const +{ + if(trkindex < 0) + return QString(); + + return titlestring; +} + +QString QNetMDTrack::codecname() const +{ + if(trkindex < 0) + return QString(); + + return codecstring; +} + +QTime QNetMDTrack::duration() const +{ + QTime t(0,0,0); + + if(trkindex < 0) + return QTime(); + + return t.addSecs( time.minute * 60 + time.second); +} + +bool QNetMDTrack::copyprotected() const +{ + switch(flags) + { + case 0x00 : return false; + case 0x03 : return true; + default : return true; // return true if unknown + } +} + +void QNetMDTrack::setBlocks(int cnt) +{ + blocks = cnt; +} + +int QNetMDTrack::blockcount() const +{ + return blocks; +} diff --git a/qhimdtransfer/qmdtrack.h b/qhimdtransfer/qmdtrack.h new file mode 100644 index 0000000..ac47a9f --- /dev/null +++ b/qhimdtransfer/qmdtrack.h @@ -0,0 +1,91 @@ +#ifndef QMDTRACK_H +#define QMDTRACK_H + +#include +#include "himd.h" +#include "sony_oma.h" + +#ifdef Q_OS_WIN + #ifdef WINVER // WINVER needs to be 0x500 or later to make the windows autodetection mechanism work and it + #undef WINVER // must be defined correctly before including libusb.h (included from libnetmd.h), else it will be defined + #endif // in windef.h to 0x400 + #define WINVER 0x500 +#endif + +extern "C" { +#include +} + +/* define buffer size for netmd downloads */ +#define NETMD_RECV_BUF_SIZE 0x10000 + +class QMDTrack +{ +public: + QMDTrack() {} // returns dummy data, implemented to have a common class name with common members + virtual ~QMDTrack() {} + virtual unsigned int tracknum() const {return -1;} + virtual QString group() const {return QString();} + virtual QString title() const {return QString();} + virtual QString artist() const {return QString();} + virtual QString album() const {return QString();} + virtual QString codecname() const {return QString();} + virtual QTime duration() const {return QTime();} + virtual bool copyprotected() const {return true;} + virtual int blockcount() const {return 0;} +}; + +class QHiMDTrack : public QMDTrack{ + struct himd * himd; + unsigned int trknum; + unsigned int trackslot; + struct trackinfo ti; +public: + QHiMDTrack(struct himd * himd, unsigned int trackindex); + virtual ~QHiMDTrack(); + virtual unsigned int tracknum() const; + virtual QString title() const; + virtual QString artist() const; + virtual QString album() const; + virtual QString codecname() const; + virtual QTime duration() const; + virtual bool copyprotected() const; + virtual int blockcount() const; + + QString openMpegStream(struct himd_mp3stream * str) const; + QString openNonMpegStream(struct himd_nonmp3stream * str) const; + QByteArray makeEA3Header() const; +}; + +class QNetMDTrack : public QMDTrack { + netmd_dev_handle * devh; + minidisc * md; + int8_t trkindex; + struct netmd_track time; + unsigned char flags; + QString groupstring; + QString titlestring; + QString codecstring; +private: + int blocks; +public: + unsigned char bitrate_id; + unsigned char channel; + QNetMDTrack(netmd_dev_handle *deviceh, minidisc * my_md, int trackindex); + virtual ~QNetMDTrack(); + virtual unsigned int tracknum() const; + virtual QString group() const; + virtual QString title() const; + virtual QString codecname() const; + virtual QTime duration() const; + virtual bool copyprotected() const; + virtual void setBlocks(int cnt); + virtual int blockcount() const; +}; + +typedef QList QMDTrackList; +typedef QList QHiMDTrackList; +typedef QList QNetMDTrackList; +typedef QList QMDTrackIndexList; + +#endif // QMDTRACK_H -- 1.8.4.msysgit.0 --------------080204090806020407090108 Content-Type: text/x-patch; name="0002-including-netmd-support-into-the-gui-application-imp.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename*0="0002-including-netmd-support-into-the-gui-application-imp.pa"; filename*1="tch" >From 52d6ff0970c6b8355eed5ad70269326047aada56 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Tue, 17 Dec 2013 23:19:11 +0100 Subject: [PATCH 2/7] including netmd support into the gui application: implemented new class QMDDevice with subclasses QNetMDDevice and QHiMDDevice holding information for each device and containing upload routines --- qhimdtransfer/qmddevice.cpp | 659 ++++++++++++++++++++++++++++++++++++++++++++ qhimdtransfer/qmddevice.h | 101 +++++++ 2 files changed, 760 insertions(+) create mode 100644 qhimdtransfer/qmddevice.cpp create mode 100644 qhimdtransfer/qmddevice.h diff --git a/qhimdtransfer/qmddevice.cpp b/qhimdtransfer/qmddevice.cpp new file mode 100644 index 0000000..ee99669 --- /dev/null +++ b/qhimdtransfer/qmddevice.cpp @@ -0,0 +1,659 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +/* common device members */ +QMDDevice::QMDDevice() : dev_type(NO_DEVICE) +{ +} + +QMDDevice::~QMDDevice() +{ + close(); +} + +enum device_type QMDDevice::deviceType() +{ + return dev_type; +} + +void QMDDevice::setPath(QString path) +{ + device_path = path; +} + +QString QMDDevice::path() +{ + return device_path; +} + +void QMDDevice::setName(QString name) +{ + recorder_name = name; +} + +QString QMDDevice::name() +{ + return recorder_name; +} + +void QMDDevice::setBusy(bool busy) +{ + is_busy = busy; +} + +bool QMDDevice::isBusy() +{ + return is_busy; +} + +void QMDDevice::setMdInserted(bool inserted) +{ + md_inserted = inserted; +} + +bool QMDDevice::mdInserted() +{ + return md_inserted; +} + +void QMDDevice::setDeviceHandle(void * devicehandle) +{ + devhandle = devicehandle; +} + +void * QMDDevice::deviceHandle() +{ + return devhandle; +} + +void QMDDevice::registerMdChange(void * regMdChange) +{ + mdChange = regMdChange; +} + +void * QMDDevice::MdChange() +{ + return mdChange; +} + +QStringList QMDDevice::downloadableFileExtensions() const +{ + if(dev_type == NETMD_DEVICE) + return QStringList() << "wav"; + + if(dev_type == HIMD_DEVICE) + return QStringList() << "mp3"; + + return QStringList(); +} + +void QMDDevice::checkfile(QString UploadDirectory, QString &filename, QString extension) +{ + QFile f; + QString newname; + int i = 2; + + f.setFileName(UploadDirectory + "/" + filename + extension); + while(f.exists()) + { + newname = filename + " (" + QString::number(i) + ")"; + f.setFileName(UploadDirectory + "/" + newname + extension); + i++; + } + if(!newname.isEmpty()) + filename = newname; +} + + +/* netmd device members */ +QNetMDDevice::QNetMDDevice() +{ + dev_type = NETMD_DEVICE; + devh = NULL; + netmd = NULL; + is_open = false; +} + +QNetMDDevice::~QNetMDDevice() +{ + close(); +} + +void QNetMDDevice::setUsbDevice(netmd_device * dev) +{ + netmd = dev; +} + +QString QNetMDDevice::open() +{ + uint8_t i = 0; + netmd_error error; + char buffer[256]; + + if(!netmd) + return tr("netmd_device not set, use setUsbDevice() function first"); + + if((error = netmd_open(netmd, &devh)) != NETMD_NO_ERROR) + return tr("Error opening netmd: %1").arg(netmd_strerror(error)); + + netmd_initialize_disc_info(devh, ¤t_md); + + /* generate track count first, needed by QNetMDTracksModel */ + while(netmd_request_title(devh, i, buffer, sizeof(buffer)) >= 0) + i++; + + trk_count = i; + + is_open = true; + md_inserted = true; + emit opened(); + return QString(); +} + +void QNetMDDevice::close() +{ + if(!devh) + return; + + netmd_clean_disc_info(¤t_md); + netmd_close(devh); + devh = NULL; + + is_open = false; + trk_count = 0; + md_inserted = false; + emit closed(); +} + +QString QNetMDDevice::discTitle() +{ + return QString(current_md.groups[0].name); +} + +QNetMDTrack QNetMDDevice::netmdTrack(unsigned int trkindex) +{ + minidisc * disc = ¤t_md; + + return QNetMDTrack(devh, disc, trkindex); +} + +QString QNetMDDevice::upload_track_blocks(uint32_t length, FILE *file, size_t chunksize) +{ + /* this is a copy of netmd_secure_real_recv_track(...) function, but updates upload dialog progress bar */ + uint32_t done = 0; + unsigned char *data; + int status; + netmd_error error = NETMD_NO_ERROR; + int transferred = 0; + + data = (unsigned char *)malloc(chunksize); + while (done < length) { + if ((length - done) < chunksize) { + chunksize = length - done; + } + + status = libusb_bulk_transfer((libusb_device_handle*)devh, 0x81, data, (int)chunksize, &transferred, 10000); + + if (status >= 0) { + done += transferred; + fwrite(data, transferred, 1, file); + netmd_log(NETMD_LOG_DEBUG, "%.1f%%\n", (double)done/(double)length * 100); + + uploadDialog.blockTransferred(); + QApplication::processEvents(); + /* do not check for uploadDialog.upload_canceled() here, netmd device will remain busy if track upload hasnīt finished */ + } + else if (status != -LIBUSB_ERROR_TIMEOUT) { + error = NETMD_USB_ERROR; + } + } + free(data); + + return (error != NETMD_NO_ERROR) ? netmd_strerror(error) : QString(); +} + +void QNetMDDevice::upload(unsigned int trackidx, QString path) +{ + /* this is a copy of netmd_secure_recv_track(...) function, we need single block transfer function to make use of a progress bar, + * maybe we can add/change something inside libnetmd for this + */ + QNetMDTrack track = netmdTrack(trackidx); + uint16_t track_id = trackidx; + unsigned char cmdhdr[] = {0x00, 0x10, 0x01}; + unsigned char cmd[sizeof(cmdhdr) + sizeof(track_id)] = { 0 }; + unsigned char *buf; + unsigned char codec; + uint32_t length; + netmd_response response; + netmd_error error; + QString filename, errmsg, filepath; + FILE * file = NULL; + + if(name() != "SONY MZ-RH1 (NetMD)") + { + errmsg = tr("upload disabled, %1 does not support netmd uploads").arg(name()); + goto clean; + } + + if(track.copyprotected()) + { + errmsg = tr("upload disabled, Track is copy protected"); + goto clean; + } + + // create filename first + if(track.title().isEmpty()) + filename = tr("Track %1").arg(track.tracknum() + 1); + else + filename = track.title(); + + if(track.bitrate_id == NETMD_ENCODING_SP) { + checkfile(path, filename, ".aea"); + filepath = path + "/" + filename + ".aea"; + } + else { + checkfile(path, filename, ".wav"); + filepath = path + "/" + filename + ".wav"; + } + + if(!(file = fopen(filepath.toUtf8().data(), "wb"))) { + errmsg = tr("cannot open file %1 for writing").arg(filepath); + goto clean; + } + + buf = cmd; + memcpy(buf, cmdhdr, sizeof(cmdhdr)); + buf += sizeof(cmdhdr); + netmd_copy_word_to_buffer(&buf, trackidx + 1U, 0); + + netmd_send_secure_msg(devh, 0x30, cmd, sizeof(cmd)); + error = netmd_recv_secure_msg(devh, 0x30, &response, NETMD_STATUS_INTERIM); + netmd_check_response_bulk(&response, cmdhdr, sizeof(cmdhdr), &error); + netmd_check_response_word(&response, track_id + 1U, &error); + codec = netmd_read(&response); + length = netmd_read_doubleword(&response); + + /* initialize track.blockcount() here, needed by progress bar in the uploadDialog */ + track.setBlocks(length%NETMD_RECV_BUF_SIZE ? length / NETMD_RECV_BUF_SIZE + 1 : length / NETMD_RECV_BUF_SIZE); + uploadDialog.starttrack(track, filename); + if (track.bitrate_id == NETMD_ENCODING_SP) { + netmd_write_aea_header(track.title().toUtf8().data(), codec, track.channel, file); + } + else { + netmd_write_wav_header(codec, length, file); + } + + errmsg = upload_track_blocks(length, file, NETMD_RECV_BUF_SIZE); + if(!errmsg.isNull()) { + goto clean; + } + + error = netmd_recv_secure_msg(devh, 0x30, &response, NETMD_STATUS_ACCEPTED); + netmd_check_response_bulk(&response, cmdhdr, sizeof(cmdhdr), &error); + netmd_read_response_bulk(&response, NULL, 2, &error); + netmd_check_response_word(&response, 0, &error); + + if(error != NETMD_NO_ERROR) + errmsg = QString(netmd_strerror(error)); + +clean: + if(errmsg.isNull()) + uploadDialog.trackSucceeded(); + else + uploadDialog.trackFailed(errmsg); + + if(file) + fclose(file); + if(!errmsg.isNull()) { + QFile f(filepath); + if(f.exists()) + f.remove(); + } +} + +void QNetMDDevice::batchUpload(QMDTrackIndexList tlist, QString path) +{ + int allblocks = 0; + + setBusy(true); + + /* progress bar for all tracks does not work yet, is there any way to get track length without recieving a complete track ? + * as far as iīve tested device remains busy if download procedure hasnīt finished. + * progressbar for all tracks shows idle mode if maximum value is set to 0 + */ + for(int i = 0;i < tlist.length(); i++) { + allblocks += netmdTrack(tlist.at(i)).blockcount(); + } + + uploadDialog.init(tlist.length(), allblocks); + + for(int i = 0; i < tlist.length(); i++) { + upload(tlist[i], path); + QApplication::processEvents(); + if(uploadDialog.upload_canceled()) + break; + } + + uploadDialog.finished(); + setBusy(false); +} + +/* himd device members */ + +QHiMDDevice::QHiMDDevice() +{ + dev_type = HIMD_DEVICE; + himd = NULL; + is_open = false; +} + +QHiMDDevice::~QHiMDDevice() +{ + close(); +} + +QString QHiMDDevice::open() +{ + struct himderrinfo status; + + if(!mdInserted()) + return tr("cannot open device, no disc"); + + if(himd) // first close himd if opened + { + himd_close(himd); + delete himd; + himd = NULL; + } + + himd = new struct himd; + if(himd_open(himd, device_path.toUtf8(), &status) < 0) + { + delete himd; + himd = NULL; + return QString::fromUtf8(status.statusmsg); + } + + trk_count = himd_track_count(himd); + is_open = true; + md_inserted = true; + emit opened(); + return QString(); +} + +void QHiMDDevice::close() +{ + if(!himd) + return; + + himd_close(himd); + delete himd; + himd = NULL; + + is_open = false; + trk_count = 0; + emit closed(); +} + +QHiMDTrack QHiMDDevice::himdTrack(unsigned int trkindex) +{ + return QHiMDTrack(himd, trkindex); +} + +QString QHiMDDevice::dumpmp3(const QHiMDTrack &trk, QString file) +{ + QString errmsg; + struct himd_mp3stream str; + struct himderrinfo status; + unsigned int len; + const unsigned char * data; + QFile f(file); + + if(!f.open(QIODevice::ReadWrite)) + { + return tr("Error opening file for MP3 output"); + } + if(!(errmsg = trk.openMpegStream(&str)).isNull()) + { + f.remove(); + return tr("Error opening track: ") + errmsg; + } + while(himd_mp3stream_read_block(&str, &data, &len, NULL, &status) >= 0) + { + if(f.write((const char*)data,len) == -1) + { + errmsg = tr("Error writing audio data"); + goto clean; + } + uploadDialog.blockTransferred(); + QApplication::processEvents(); + if(uploadDialog.upload_canceled()) + { + errmsg = tr("upload aborted by the user"); + goto clean; + } + + } + if(status.status != HIMD_STATUS_AUDIO_EOF) + errmsg = tr("Error reading audio data: ") + status.statusmsg; + +clean: + f.close(); + himd_mp3stream_close(&str); + if(!errmsg.isNull()) + f.remove(); + return errmsg; +} + +static inline TagLib::String QStringToTagString(const QString & s) +{ + return TagLib::String(s.toUtf8().data(), TagLib::String::UTF8); +} + +static void addid3tag(QString title, QString artist, QString album, QString file) +{ +#ifdef Q_OS_WIN + TagLib::FileRef f(file.toStdWString().c_str()); +#else + TagLib::FileRef f(file.toUtf8().data()); +#endif + TagLib::Tag *t = f.tag(); + t->setTitle(QStringToTagString(title)); + t->setArtist(QStringToTagString(artist)); + t->setAlbum(QStringToTagString(album)); + t->setComment("*** imported from HiMD via QHiMDTransfer ***"); + f.file()->save(); +} + +QString QHiMDDevice::dumpoma(const QHiMDTrack &track, QString file) +{ + QString errmsg; + struct himd_nonmp3stream str; + struct himderrinfo status; + unsigned int len; + const unsigned char * data; + QFile f(file); + + if(!f.open(QIODevice::ReadWrite)) + return tr("Error opening file for ATRAC output"); + + if(!(errmsg = track.openNonMpegStream(&str)).isNull()) + { + f.remove(); + return tr("Error opening track: ") + status.statusmsg; + } + + if(f.write(track.makeEA3Header()) == -1) + { + errmsg = tr("Error writing header"); + goto clean; + } + while(himd_nonmp3stream_read_block(&str, &data, &len, NULL, &status) >= 0) + { + if(f.write((const char*)data,len) == -1) + { + errmsg = tr("Error writing audio data"); + goto clean; + } + uploadDialog.blockTransferred(); + QApplication::processEvents(); + if(uploadDialog.upload_canceled()) + { + errmsg = QString("upload aborted by the user"); + goto clean; + } + } + if(status.status != HIMD_STATUS_AUDIO_EOF) + errmsg = QString("Error reading audio data: ") + status.statusmsg; + +clean: + f.close(); + himd_nonmp3stream_close(&str); + + if(!errmsg.isNull()) + f.remove(); + return errmsg; +} + +QString QHiMDDevice::dumppcm(const QHiMDTrack &track, QString file) +{ + struct himd_nonmp3stream str; + struct himderrinfo status; + unsigned int len, i; + int left, right; + int clipcount; + QString errmsg; + QFile f(file); + const unsigned char * data; + sox_format_t * out; + sox_sample_t soxbuf [HIMD_MAX_PCMFRAME_SAMPLES * 2]; + sox_signalinfo_t signal_out; + + signal_out.channels = 2; + signal_out.length = 0; + signal_out.precision = 16; + signal_out.rate = 44100; + + if(!(out = sox_open_write(file.toUtf8(), &signal_out, NULL, NULL, NULL, NULL))) + return tr("Error opening file for WAV output"); + + if(!(errmsg = track.openNonMpegStream(&str)).isNull()) + { + f.remove(); + return tr("Error opening track: ") + status.statusmsg; + } + + while(himd_nonmp3stream_read_block(&str, &data, &len, NULL, &status) >= 0) + { + + for(i = 0; i < len/4; i++) { + + left = data[i*4]*256+data[i*4+1]; + right = data[i*4+2]*256+data[i*4+3]; + if (left > 0x8000) left -= 0x10000; + if (right > 0x8000) right -= 0x10000; + + soxbuf[i*2] = SOX_SIGNED_16BIT_TO_SAMPLE(left, clipcount); + soxbuf[i*2+1] = SOX_SIGNED_16BIT_TO_SAMPLE(right, clipcount); + (void)clipcount; /* suppess "is unused" warning */ + } + + if (sox_write(out, soxbuf, len/2) != len/2) + { + errmsg = tr("Error writing audio data"); + goto clean; + } + uploadDialog.blockTransferred(); + QApplication::processEvents(); + if(uploadDialog.upload_canceled()) + { + errmsg = QString("upload aborted by the user"); + goto clean; + } + } + if(status.status != HIMD_STATUS_AUDIO_EOF) + errmsg = QString("Error reading audio data: ") + status.statusmsg; + +clean: + sox_close(out); + himd_nonmp3stream_close(&str); + + if(!errmsg.isNull()) + f.remove(); + return errmsg; +} + +void QHiMDDevice::upload(unsigned int trackidx, QString path) +{ + QString filename, errmsg; + QHiMDTrack track = himdTrack(trackidx); + QString title = track.title(); + + if(title.isNull()) + filename = tr("Track %1").arg(track.tracknum()+1); + else + filename = track.artist() + " - " + title; + + uploadDialog.starttrack(track, filename); + if (!track.copyprotected()) + { + QString codec = track.codecname(); + if (codec == "MPEG") + { + checkfile(path, filename, ".mp3"); + errmsg = dumpmp3 (track, path + "/" + filename + ".mp3"); + if(errmsg.isNull()) + addid3tag (track.title(),track.artist(),track.album(), path + "/" +filename + ".mp3"); + } + else if (codec == "LPCM") + { + checkfile(path, filename, ".wav"); + errmsg = dumppcm (track, path + "/" + filename + ".wav"); + } + else if (codec == "AT3+" || codec == "AT3 ") + { + checkfile(path, filename, ".oma"); + errmsg = dumpoma (track, path + "/" + filename + ".oma"); + } + } + else + errmsg = tr("upload disabled because of DRM encryption"); + + if(errmsg.isNull()) + uploadDialog.trackSucceeded(); + else + uploadDialog.trackFailed(errmsg); + +} + +void QHiMDDevice::batchUpload(QMDTrackIndexList tlist, QString path) +{ + int allblocks = 0; + + setBusy(true); + + for(int i = 0;i < tlist.length(); i++) + allblocks += himdTrack(tlist.at(i)).blockcount(); + + uploadDialog.init(tlist.length(), allblocks); + + for(int i = 0; i < tlist.length(); i++) { + upload(tlist[i], path); + QApplication::processEvents(); + if(uploadDialog.upload_canceled()) + break; + } + + uploadDialog.finished(); + setBusy(false); +} diff --git a/qhimdtransfer/qmddevice.h b/qhimdtransfer/qmddevice.h new file mode 100644 index 0000000..c413f9c --- /dev/null +++ b/qhimdtransfer/qmddevice.h @@ -0,0 +1,101 @@ +#ifndef QMDDEVICE_H +#define QMDDEVICE_H + +#include +#include + +#include +#include "qhimduploaddialog.h" + +enum device_type { + NO_DEVICE, + NETMD_DEVICE, + HIMD_DEVICE +}; + +class QMDDevice : public QObject { + Q_OBJECT + Q_DISABLE_COPY(QMDDevice) + + QString recorder_name; + bool is_busy; +protected: + QString device_path; + enum device_type dev_type; + bool is_open; + unsigned int trk_count; + bool md_inserted; + void * devhandle; + void * mdChange; + QHiMDUploadDialog uploadDialog; +public: + explicit QMDDevice(); + virtual ~QMDDevice(); + virtual enum device_type deviceType(); + virtual void setPath(QString path); + virtual QString path(); + virtual void setName(QString name); + virtual QString name(); + virtual void setBusy(bool busy); + virtual bool isBusy(); + virtual QString open() {return QString();} + virtual void close() {} + virtual bool isOpen() {return is_open;} + virtual QString discTitle() {return QString();} + virtual void setMdInserted(bool inserted); + virtual bool mdInserted(); + virtual void setDeviceHandle(void * devicehandle); + virtual void * deviceHandle(); + virtual void registerMdChange(void * regMdChange); + virtual void * MdChange(); + virtual QMDTrack track(unsigned int trkindex) {return QMDTrack();} + virtual int trackCount() {return trk_count;} + virtual QStringList downloadableFileExtensions() const; + virtual void checkfile(QString UploadDirectory, QString &filename, QString extension); + virtual void batchUpload(QMDTrackIndexList tlist, QString path) {} + virtual void upload(unsigned int trackidx, QString path) {} + +signals: + void opened(); + void closed(); +}; + +class QNetMDDevice : public QMDDevice { + + netmd_device * netmd; + netmd_dev_handle * devh; + minidisc current_md; +private: + QString upload_track_blocks(uint32_t length, FILE *file, size_t chunksize); +public: + explicit QNetMDDevice(); + virtual ~QNetMDDevice(); + virtual void setUsbDevice(netmd_device * dev); + virtual QString open(); + virtual void close(); + virtual QString discTitle(); + virtual QNetMDTrack netmdTrack(unsigned int trkindex); + virtual void batchUpload(QMDTrackIndexList tlist, QString path); + virtual void upload(unsigned int trackidx, QString path); + +}; + +class QHiMDDevice : public QMDDevice { + + struct himd * himd; +private: + QString dumpmp3(const QHiMDTrack &trk, QString file); + QString dumpoma(const QHiMDTrack & track, QString file); + QString dumppcm(const QHiMDTrack &track, QString file); +public: + explicit QHiMDDevice(); + virtual ~QHiMDDevice(); + virtual QString open(); + virtual void close(); + virtual QHiMDTrack himdTrack(unsigned int trkindex); + virtual void upload(unsigned int trackidx, QString path); + virtual void batchUpload(QMDTrackIndexList tlist, QString path); + +}; + +#endif // QMDDEVICE_H -- 1.8.4.msysgit.0 --------------080204090806020407090108 Content-Type: text/x-patch; name="0003-including-netmd-support-into-the-gui-application-imp.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0003-including-netmd-support-into-the-gui-application-imp.pa"; filename*1="tch" >From 11ec5a6828ee2a7d7449545301312e4f2a62fee8 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Tue, 17 Dec 2013 23:27:43 +0100 Subject: [PATCH 3/7] including netmd support into the gui application:implemented new class QNetMDTracksModel analogous to QHiMDTracksModel, renamed qhimdmodel.h/.cpp to qmdmodel.h/.cpp, QHiMDTrack class is already moved to qmdtrack.h/.cpp --- qhimdtransfer/qmdmodel.cpp | 364 +++++++++++++++++++++++++++++++++++++++++++++ qhimdtransfer/qmdmodel.h | 80 ++++++++++ 2 files changed, 444 insertions(+) create mode 100644 qhimdtransfer/qmdmodel.cpp create mode 100644 qhimdtransfer/qmdmodel.h diff --git a/qhimdtransfer/qmdmodel.cpp b/qhimdtransfer/qmdmodel.cpp new file mode 100644 index 0000000..48ff275 --- /dev/null +++ b/qhimdtransfer/qmdmodel.cpp @@ -0,0 +1,364 @@ +#include +#include +#include + +enum hcolumnum { + ColId, ColTitle, ColArtist, ColAlbum, ColLength, ColCodec, ColUploadable, + LAST_hcolumnnum = ColUploadable +}; + +enum ncolumnum { + CoId, CoGroup, CoTitle, CoLength, CoCodec, CoUploadable, + LAST_ncolumnnum = CoUploadable +}; + + +/* netmd tracks model */ +QVariant QNetMDTracksModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if(orientation != Qt::Horizontal) + return QVariant(); + + if(role == Qt::SizeHintRole) + { + static QFont f; + static QFontMetrics met(f); + switch((ncolumnum)section) + { + case CoId: + return QSize(met.width("9999")+5, 0); + case CoGroup: + case CoTitle: + case CoLength: + return QSize(met.width("9:99:99"), 0); + case CoCodec: + case CoUploadable: + /* Really use the header for the metric in these columns, + contents will be shorter */ + return QAbstractListModel::headerData(section,orientation,role); + } + } + + if(role == Qt::DisplayRole) + { + switch((ncolumnum)section) + { + case CoId: + return tr("Nr."); + case CoGroup: + return tr("Group"); + case CoTitle: + return tr("Title"); + case CoLength: + return tr("Length"); + case CoCodec: + return tr("Format"); + case CoUploadable: + return tr("Uploadable"); + } + } + return QVariant(); +} + +QVariant QNetMDTracksModel::data(const QModelIndex & index, int role) const +{ + if(role == Qt::TextAlignmentRole && + (index.column() == CoId || index.column() == CoLength)) + return Qt::AlignRight; + + if(index.row() >= rowCount()) + return QVariant(); + + QNetMDTrack track = allTracks[index.row()]; + + if(role == Qt::CheckStateRole && index.column() == CoUploadable) + return ((ndev->name() != "SONY MZ-RH1 (NetMD)") || track.copyprotected()) ? Qt::Unchecked : Qt::Checked; + + if(role == Qt::DisplayRole) + { + switch((ncolumnum)index.column()) + { + case CoId: + return index.row() + 1; + case CoGroup: + return track.group(); + case CoTitle: + return track.title(); + case CoLength: + { + QTime t = track.duration(); + if(t < QTime(1,0,0)) + return t.toString("m:ss"); + else + return t.toString("h:mm:ss"); + } + case CoCodec: + return track.codecname(); + case CoUploadable: + return QVariant(); /* Displayed by checkbox */ + } + } + return QVariant(); +} + +int QNetMDTracksModel::rowCount(const QModelIndex &) const +{ + if(ndev == NULL) + return 0; + + return ndev->trackCount(); +} + +int QNetMDTracksModel::columnCount(const QModelIndex &) const +{ + return LAST_ncolumnnum+1; +} + +QString QNetMDTracksModel::open(QMDDevice * device) +{ + int i = 0; + QString ret = "error opening net device"; + + beginResetModel(); + if(ndev != NULL) + close(); + + if(device->deviceType() == NETMD_DEVICE) + { + ndev = static_cast(device); + ret = ndev->open(); + } + + if(!ret.isEmpty()) + close(); + + /* fetch track info for all tracks first, getting track info inside data() function is very slow */ + for(; i < ndev->trackCount(); i++) + allTracks.append(ndev->netmdTrack(i)); + + endResetModel(); /* inform views that the model contents changed */ + return ret; +} + +bool QNetMDTracksModel::is_open() +{ + return ndev->isOpen(); +} + +void QNetMDTracksModel::close() +{ + beginResetModel(); + + if(ndev != NULL && ndev->isOpen()) + ndev->close(); + + ndev = NULL; + + allTracks.clear(); + endResetModel(); /* inform views that the model contents changed */ +} + +QNetMDTrack QNetMDTracksModel::track(int trkidx) const +{ + return ndev->netmdTrack(trkidx); +} + +QNetMDTrackList QNetMDTracksModel::tracks(const QModelIndexList & modelindices) const +{ + QNetMDTrackList tracks; + QModelIndex index; + + foreach(index, modelindices) + tracks.append(ndev->netmdTrack(index.row())); + return tracks; +} + +QStringList QNetMDTracksModel::downloadableFileExtensions() const +{ + return ndev->downloadableFileExtensions(); +} + + +/* himd tracks model */ + +QVariant QHiMDTracksModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if(orientation != Qt::Horizontal) + return QVariant(); + + if(role == Qt::SizeHintRole) + { + static QFont f; + static QFontMetrics met(f); + switch((hcolumnum)section) + { + case ColId: + return QSize(met.width("9999")+5, 0); + case ColTitle: + case ColArtist: + case ColAlbum: + return QSize(25*met.averageCharWidth(), 0); + case ColLength: + return QSize(met.width("9:99:99"), 0); + case ColCodec: + case ColUploadable: + /* Really use the header for the metric in these columns, + contents will be shorter */ + return QAbstractListModel::headerData(section,orientation,role); + } + } + + if(role == Qt::DisplayRole) + { + switch((hcolumnum)section) + { + case ColId: + return tr("Nr."); + case ColTitle: + return tr("Title"); + case ColArtist: + return tr("Artist"); + case ColAlbum: + return tr("Album"); + case ColLength: + return tr("Length"); + case ColCodec: + return tr("Format"); + case ColUploadable: + return tr("Uploadable"); + } + } + return QVariant(); +} + +QVariant QHiMDTracksModel::data(const QModelIndex & index, int role) const +{ + if(role == Qt::TextAlignmentRole && + (index.column() == ColId || index.column() == ColLength)) + return Qt::AlignRight; + + if(index.row() >= rowCount()) + return QVariant(); + + QHiMDTrack track = hdev->himdTrack(index.row()); + + if(role == Qt::CheckStateRole && index.column() == ColUploadable) + return track.copyprotected() ? Qt::Unchecked : Qt::Checked; + + if(role == Qt::DisplayRole) + { + switch((hcolumnum)index.column()) + { + case ColId: + return index.row() + 1; + case ColTitle: + return track.title(); + case ColArtist: + return track.artist(); + case ColAlbum: + return track.album(); + case ColLength: + { + QTime t = track.duration(); + if(t < QTime(1,0,0)) + return t.toString("m:ss"); + else + return t.toString("h:mm:ss"); + } + case ColCodec: + return track.codecname(); + case ColUploadable: + return QVariant(); /* Displayed by checkbox */ + } + } + return QVariant(); +} + +int QHiMDTracksModel::rowCount(const QModelIndex &) const +{ + if(hdev == NULL) + return 0; + + return hdev->trackCount(); +} + +int QHiMDTracksModel::columnCount(const QModelIndex &) const +{ + return LAST_hcolumnnum+1; +} + +QString QHiMDTracksModel::open(QMDDevice * device) +{ + QString ret = "error opening himd device"; + + beginResetModel(); + if(hdev != NULL) + close(); + + if(device->deviceType() == HIMD_DEVICE) + { + hdev = static_cast(device); + ret = hdev->open(); + } + + if(!ret.isEmpty()) + close(); + + endResetModel(); /* inform views that the model contents changed */ + return ret; +} + +bool QHiMDTracksModel::is_open() +{ + return hdev->isOpen(); +} + +void QHiMDTracksModel::close() +{ + beginResetModel(); + + if(hdev != NULL && hdev->isOpen()) + hdev->close(); + + hdev = NULL; + + endResetModel(); /* inform views that the model contents changed */ +} + +QHiMDTrack QHiMDTracksModel::track(int trknum) const +{ + return hdev->himdTrack(trknum); +} + +QHiMDTrackList QHiMDTracksModel::tracks(const QModelIndexList & modelindices) const +{ + QHiMDTrackList tracks; + QModelIndex index; + + foreach(index, modelindices) + tracks.append(hdev->himdTrack(index.row())); + return tracks; +} + +QStringList QHiMDTracksModel::downloadableFileExtensions() const +{ + return hdev->downloadableFileExtensions(); +} + + +/* QFileSystemModel stuff */ + +Qt::ItemFlags QHiMDFileSystemModel::flags(const QModelIndex &index) const +{ + if(!isDir(index) && !selectableExtensions.contains((fileInfo(index).suffix()), Qt::CaseInsensitive)) + return Qt::NoItemFlags; //not selectable, not enabled (grayed out in the browser) + + return QFileSystemModel::flags(index); +} + +void QHiMDFileSystemModel::setSelectableExtensions(QStringList extensions) +{ + beginResetModel(); + selectableExtensions = extensions; + endResetModel(); +} diff --git a/qhimdtransfer/qmdmodel.h b/qhimdtransfer/qmdmodel.h new file mode 100644 index 0000000..3c59f51 --- /dev/null +++ b/qhimdtransfer/qmdmodel.h @@ -0,0 +1,80 @@ +#ifndef QMDMODEL_H +#define QMDMODEL_H + +#include + +#include +#include +#include +#include +#include + +class QMDTracksModel : public QAbstractListModel { + Q_OBJECT + + QMDDevice * dev; +public: + QMDTracksModel() : dev(NULL) {} + /* QAbstractListModel stuff */ + virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const {return QVariant();} + virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const {return QVariant();} + virtual int rowCount(const QModelIndex & parent = QModelIndex() ) const {return 0;} + virtual int columnCount(const QModelIndex & parent = QModelIndex() ) const {return 0;} + /* dummy data for unknown devices */ + virtual QString open(QMDDevice *device = NULL) {return tr("no known device type specified");} + virtual bool is_open() {return false;} + virtual void close() {} + QStringList downloadableFileExtensions() const {return QStringList();} +}; + +class QNetMDTracksModel : public QMDTracksModel { + Q_OBJECT + + QNetMDDevice * ndev; + QNetMDTrackList allTracks; +public: + QNetMDTracksModel() {ndev = NULL;} + /* QAbstractListModel stuff */ + virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + virtual int rowCount(const QModelIndex & parent = QModelIndex() ) const; + virtual int columnCount(const QModelIndex & parent = QModelIndex() ) const; + /* NetMD device stuff */ + QString open(QMDDevice *device); /* returns null if OK, error message otherwise */ + virtual bool is_open(); + void close(); + QNetMDTrack track(int trkidx) const; + virtual QNetMDTrackList tracks(const QModelIndexList & indices) const; // should be QMDTrackList later + QStringList downloadableFileExtensions() const; +}; + +class QHiMDTracksModel : public QMDTracksModel { + Q_OBJECT + + QHiMDDevice * hdev; +public: + QHiMDTracksModel() {hdev = NULL;} + /* QAbstractListModel stuff */ + virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + virtual int rowCount(const QModelIndex & parent = QModelIndex() ) const; + virtual int columnCount(const QModelIndex & parent = QModelIndex() ) const; + /* HiMD containter stuff */ + virtual QString open(QMDDevice *device); /* returns null if OK, error message otherwise */ + virtual bool is_open(); + virtual void close(); + virtual QHiMDTrack track(int trackidx) const; + virtual QHiMDTrackList tracks(const QModelIndexList & indices) const; // should be QMDTrackList later + QStringList downloadableFileExtensions() const; +}; + +class QHiMDFileSystemModel : public QFileSystemModel { + Q_OBJECT + + QStringList selectableExtensions; +public: + virtual Qt::ItemFlags flags(const QModelIndex &index) const; + void setSelectableExtensions(QStringList extensions); +}; + +#endif // QMDMODEL_H -- 1.8.4.msysgit.0 --------------080204090806020407090108 Content-Type: text/x-patch; name="0004-including-netmd-support-into-the-gui-application-imp.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0004-including-netmd-support-into-the-gui-application-imp.pa"; filename*1="tch" >From 3ad571e40e68c163d6d396548dad5a61fbc0d11f Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Tue, 17 Dec 2013 23:31:01 +0100 Subject: [PATCH 4/7] including netmd support into the gui application: implemented netmd autodetection at application start, also implemented autodetection during application runtime using the new QMDDevice classes --- libnetmd/libnetmd.pro | 3 +- libnetmd/use_libnetmd.prl | 2 +- qhimdtransfer/qhimddetection.cpp | 258 ++++++++++++++++++++++++++++++++---- qhimdtransfer/qhimddetection.h | 105 ++++++++++----- qhimdtransfer/qhimdwindetection.cpp | 198 +++++++++++++++++---------- 5 files changed, 436 insertions(+), 130 deletions(-) diff --git a/libnetmd/libnetmd.pro b/libnetmd/libnetmd.pro index eb6a402..3319d85 100644 --- a/libnetmd/libnetmd.pro +++ b/libnetmd/libnetmd.pro @@ -5,7 +5,8 @@ CONFIG += staticlib link_pkgconfig create_prl console debug_and_release_target DEFINES += G_DISABLE_DEPRECATED=1 PKGCONFIG += libusb-1.0 -HEADERS += common.h const.h error.h libnetmd.h log.h netmd_dev.h playercontrol.h secure.h trackinformation.h utils.h +HEADERS += common.h const.h error.h libnetmd.h log.h netmd_dev.h playercontrol.h secure.h trackinformation.h utils.h \ + libnetmd_extended.h SOURCES += common.c error.c libnetmd.c log.c netmd_dev.c playercontrol.c secure.c trackinformation.c utils.c LIBS += -lgcrypt diff --git a/libnetmd/use_libnetmd.prl b/libnetmd/use_libnetmd.prl index d9019f2..a3c72e0 100644 --- a/libnetmd/use_libnetmd.prl +++ b/libnetmd/use_libnetmd.prl @@ -11,7 +11,7 @@ build_pass:CONFIG(release,debug|release) { LIBS += -L../libnetmd/release } -# fallback if libhimd was not compiled with +# fallback if libnetmd was not compiled with # CONFIG += debug_and_release debug_and_release_target # while I force debug_and_release_target, it is ignored in a # just-one-kind build without debug_and_release diff --git a/qhimdtransfer/qhimddetection.cpp b/qhimdtransfer/qhimddetection.cpp index d563587..e73dc03 100644 --- a/qhimdtransfer/qhimddetection.cpp +++ b/qhimdtransfer/qhimddetection.cpp @@ -1,73 +1,275 @@ #include #include "qhimddetection.h" +void QHiMDDetection::clearDeviceList() +{ + QMDDevice * mddev; + QNetMDDevice * nmddev; + int i = 0; + + while( i < dlist.count() ) + { + mddev = dlist.at(i); + if(mddev->deviceType() == NETMD_DEVICE) + { + nmddev = static_cast(mddev); + if(nmddev->isOpen()) + nmddev->close(); + delete nmddev; + nmddev = NULL; + dlist.removeAt(i); + continue; + } + else if(mddev->deviceType() == HIMD_DEVICE) + { + remove_himddevice(mddev->path()); // uses platform dependent function if available + continue; + } + } + + if(!dlist.isEmpty()) + dlist.clear(); + emit deviceListChanged(dlist); +} + QHiMDDetection::QHiMDDetection(QObject *parent) : QObject(parent) { } -himd_device *QHiMDDetection::find_by_path(QString path) +QHiMDDetection::~QHiMDDetection() { - for (int i = 0; i < device_list.size(); i++) - if(device_list.at(i)->path == path) - return device_list.at(i); + clearDeviceList(); + cleanup_netmd_list(); +} - return NULL; +void QHiMDDetection::cleanup_netmd_list() +{ + if(dev_list != NULL) + netmd_clean(&dev_list); } -// slots +void QHiMDDetection::rescan_netmd_devices() +{ + QNetMDDevice * dev; + int i = 0; + + // find and remove netmd devices + while(i < dlist.count()) + { + if(dlist.at(i)->deviceType() != NETMD_DEVICE) + { + i++; + continue; + } + dev = static_cast(dlist.at(i)); + if(dev->isOpen()) + dev->close(); + + delete dev; + dev = NULL; + dlist.removeAt(i); + } + + netmd_clean(&dev_list); + dev_list = NULL; -void QHiMDDetection::himd_busy(QString path) + emit deviceListChanged(dlist); + scan_for_netmd_devices(); +} + +void QHiMDDetection::scan_for_minidisc_devices() +{ + /* create device entry for disc images first */ + QHiMDDevice * mddev = new QHiMDDevice(); + mddev->setMdInserted(true); + mddev->setName("disc image"); + dlist.append(mddev); + emit deviceListChanged(dlist); + + scan_for_himd_devices(); + scan_for_netmd_devices(); +} + +void QHiMDDetection::remove_himddevice(QString path) { - himd_device * dev = find_by_path(path); - if (!dev) + QHiMDDevice * dev = static_cast(find_by_path(path)); + int i = dlist.indexOf(find_by_path(path)); + + if(i < 0) return; - dev->is_busy = true; - qDebug() << "himd device at " + dev->path + " : device busy, starting transfer"; + if(dev->isOpen()) + dev->close(); + delete dev; + dev = NULL; + + dlist.removeAt(i); } -void QHiMDDetection::himd_idle(QString path) +void QHiMDDetection::scan_for_netmd_devices() { - himd_device * dev = find_by_path(path); - if (!dev) + netmd_device * md; + netmd_error error = netmd_init(&dev_list); + struct libusb_device_descriptor desc; + QNetMDDevice * mddev; + + if (error != NETMD_NO_ERROR) return; - dev->is_busy = false; - qDebug() << "himd device at " + dev->path + " : device idle, transfer complete"; + md = dev_list; // pick first device + + while( md != NULL) { + libusb_get_device_descriptor(md->usb_dev, &desc); + mddev = new QNetMDDevice(); + mddev->setName(identify_usb_device(desc.idVendor, desc.idProduct)); + mddev->setUsbDevice(md); + dlist.append(mddev); + emit deviceListChanged(dlist); + md = md->link; // pick next device + } +} + +QMDDevice *QHiMDDetection::find_by_path(QString path) +{ + QMDDevice * mddev; + + foreach(mddev, dlist) + { + if(mddev->path() == path) + return mddev; + } + return NULL; +} + +QMDDevice *QHiMDDetection::find_by_name(QString name) +{ + QMDDevice * mddev; + + foreach(mddev, dlist) + { + if(mddev->name() == name) + return mddev; + } + return NULL; } const char * identify_usb_device(int vid, int pid) { + if(vid == SHARP) + { + switch(pid) + { + case IM_MT880H: + return "SHARP IM-MT880H / IM-MT899H (NetMD)"; + case IM_DR400: + return "SHARP IM-DR400 / IM-DR410 (NetMD)"; + case IM_DR80: + return "SHARP IM-DR80 / IM-DR420/ IM-DR580 or KENWOOD DMC-S9NET (NetMD)"; + } + } + if (vid != SONY) return NULL; switch (pid) { - case MZ_NH1: + case MZ_NH1_HIMD: return "SONY MZ-NH1"; - case MZ_NH3D: + case MZ_NH3D_HIMD: return "SONY MZ-NH3D"; - case MZ_NH900: + case MZ_NH900_HIMD: return "SONY MZ-NH900"; - case MZ_NH700: + case MZ_NH700_HIMD: return "SONY MZ-NH700 / MZ-NH800"; - case MZ_NH600: + case MZ_NH600_HIMD: return "SONY MZ-NH600(D)"; - case LAM_3: + case LAM_3_HIMD: return "SONY LAM-3"; - case MZ_DH10P: + case MZ_DH10P_HIMD: return "SONY MZ-DH10P"; - case MZ_RH10: + case MZ_RH10_HIMD: return "SONY MZ-RH10"; - case MZ_RH910: + case MZ_RH910_HIMD: return "SONY MZ-RH910"; - case CMT_AH10: + case CMT_AH10_HIMD: return "SONY CMT-AH10"; - case DS_HMD1: + case DS_HMD1_HIMD: return "SONY DS-HMD1"; - case MZ_RH1: + case MZ_RH1_HIMD: return "SONY MZ-RH1"; + case PCLK_XX: + return "SONY PCLK-XX (NetMD)"; + case UNKNOWN_A: + return "SONY (unknown model, NetMD)"; + case MZ_N1: + return "SONY MZ-N1 (NetMD)"; + case UNKNOWN_B: + return "SONY (unknown model, NetMD)"; + case LAM_1: + return "Sony LAM-1 (NetMD)"; + case MDS_JE780: + return "SONY MDS-JE780 / MDS-JE980 (NetMD)"; + case MZ_N505: + return "SONY MZ-N505 (NetMD)"; + case MZ_S1: + return "SONY MZ-S1 (NetMD)"; + case MZ_N707: + return "SONY MZ-N707 (NetMD)"; + case CMT_C7NT: + return "SONY CMT-C7NT (NetMD)"; + case PCGA_MDN1: + return "SONY PCGA-MDN1 (NetMD)"; + case CMT_L7HD: + return "SONY CMT-L7HD (NetMD)"; + case MZ_N10: + return "SONY MZ-N10 (NetMD)"; + case MZ_N910: + return "SONY MZ-N910 (NetMD)"; + case MZ_N710: + return "SONY MZ-N710 / MZ-NE810 / MZ-NF810 (NetMD)"; + case MZ_N510: + return "SONY MZ-N510 (NetMD)"; + case MZ_NE410: + return "SONY MZ-NE410 / MZ-DN430 / MZ-NF520 (NetMD)"; + case MZ_NE810: + return "SONY MZ-NE810 / MZ-NE910 (NetMD)"; + case CMT_M333NT: + return "SONY CMT-M333NT / CMT_M373NT (NetMD)"; + case LAM_10: + return "SONY LAM-10 (NetMD)"; + case AIWA_AM_NX1: + return "AIWA AM-NX1 (NetMD)"; + case AIWA_AM_NX9: + return "AIWA AM-NX9 (NetMD)"; + case MZ_NH1: + return "SONY MZ-NH1 (NetMD)"; + case MZ_NH3D: + return "SONY MZ-NH3D (NetMD)"; + case MZ_NH900: + return "SONY MZ-NH900 (NetMD)"; + case MZ_NH700: + return "SONY MZ-NH700 / MZ-NH800 (NetMD)"; + case MZ_NH600: + return "SONY MZ-NH600 / MZ-NH600D (NetMD)"; + case MZ_N920: + return "SONY MZ-N920 (NetMD)"; + case LAM_3: + return "SONY LAM-3 (NetMD)"; + case MZ_DH10P: + return "SONY MZ-DH10P (NetMD)"; + case MZ_RH10: + return "SONY MZ-RH10 (NetMD)"; + case MZ_RH910: + return "SONY MZ-RH910 (NetMD)"; + case CMT_AH10_A: + return "SONY CMT-AH10 (NetMD)"; + case CMT_AH10_B: + return "SONY CMT-AH10 (NetMD)"; + case DS_HMD1: + return "SONY DS-HMD1 (NetMD)"; + case MZ_RH1: + return "SONY MZ-RH1 (NetMD)"; } return NULL; } diff --git a/qhimdtransfer/qhimddetection.h b/qhimdtransfer/qhimddetection.h index 5c30be9..4a5915a 100644 --- a/qhimdtransfer/qhimddetection.h +++ b/qhimdtransfer/qhimddetection.h @@ -4,50 +4,95 @@ #include #include #include +#include -#define SONY 0x054c //known himd-mode product IDs -#define MZ_NH1 0x017f -#define MZ_NH3D 0x0181 -#define MZ_NH900 0x0183 -#define MZ_NH700 0x0185 -#define MZ_NH600 0x0187 -#define LAM_3 0x018a -#define MZ_DH10P 0x01ea -#define MZ_RH10 0x021a -#define MZ_RH910 0x021c -#define CMT_AH10 0x022d -#define DS_HMD1 0x023d -#define MZ_RH1 0x0287 - -struct himd_device { - bool is_busy; - QString path; - bool md_inserted; - QString recorder_name; - virtual ~himd_device(){} /* for polymorphic delete */ - }; +// known vendor IDs +#define SONY 0x054c +#define SHARP 0x4dd + +// known himd-mode product IDs +#define MZ_NH1_HIMD 0x017f +#define MZ_NH3D_HIMD 0x0181 +#define MZ_NH900_HIMD 0x0183 +#define MZ_NH700_HIMD 0x0185 +#define MZ_NH600_HIMD 0x0187 +#define LAM_3_HIMD 0x018b +#define MZ_DH10P_HIMD 0x01ea +#define MZ_RH10_HIMD 0x021a +#define MZ_RH910_HIMD 0x021c +#define CMT_AH10_HIMD 0x022d +#define DS_HMD1_HIMD 0x023d +#define MZ_RH1_HIMD 0x0287 + +// known Sony/Aiwa netmd-mode product IDs +#define PCLK_XX 0x34 +#define UNKNOWN_A 0x36 +#define MZ_N1 0x75 +#define UNKNOWN_B 0x7c +#define LAM_1 0x80 +#define MDS_JE780 0x81 // or MDS-JE980 +#define MZ_N505 0x84 +#define MZ_S1 0x85 +#define MZ_N707 0x86 +#define CMT_C7NT 0x8e +#define PCGA_MDN1 0x97 +#define CMT_L7HD 0xad +#define MZ_N10 0xc6 +#define MZ_N910 0xc7 +#define MZ_N710 0xc8 // or MZ-NE810/NF810 +#define MZ_N510 0xc9 // or MZ-NF610 +#define MZ_NE410 0xca // or MZ-DN430/NF520 +#define MZ_NE810 0xeb // or MZ-NE910 +#define CMT_M333NT 0xe7 // or CMT-M373NT +#define LAM_10 0x101 +#define AIWA_AM_NX1 0x113 +#define AIWA_AM_NX9 0x14c +#define MZ_NH1 0x17e +#define MZ_NH3D 0x180 +#define MZ_NH900 0x182 +#define MZ_NH700 0x184 // or MZ-NH800 +#define MZ_NH600 0x186 // or MZ-NH600D +#define MZ_N920 0x188 +#define LAM_3 0x18a +#define MZ_DH10P 0x1e9 +#define MZ_RH10 0x219 +#define MZ_RH910 0x21b +#define CMT_AH10_A 0x21d +#define CMT_AH10_B 0x22c +#define DS_HMD1 0x23c +#define MZ_RH1 0x286 + +// known Sharp netmd-mode product IDs +#define IM_MT880H 0x7202 // or IM-MT899H +#define IM_DR400 0x9013 // or IM-DR410 +#define IM_DR80 0x9014 // or IM-DR420/DR580 / Kenwood DMC-S9NET const char * identify_usb_device(int vid, int pid); +typedef QList QMDDevicePtrList; + class QHiMDDetection : public QObject { Q_OBJECT Q_DISABLE_COPY(QHiMDDetection) protected: - QList device_list; + QMDDevicePtrList dlist; + netmd_device * dev_list; public: explicit QHiMDDetection(QObject *parent = 0); - virtual ~QHiMDDetection() {} + virtual ~QHiMDDetection(); + virtual void clearDeviceList(); + virtual void cleanup_netmd_list(); + void rescan_netmd_devices(); + void scan_for_minidisc_devices(); virtual void scan_for_himd_devices(){} - himd_device *find_by_path(QString path); - -protected slots: - virtual void himd_busy(QString path); - virtual void himd_idle(QString path); + virtual void remove_himddevice(QString path); + void scan_for_netmd_devices(); + QMDDevice *find_by_path(QString path); + QMDDevice *find_by_name(QString name); signals: - void himd_found(QString path); - void himd_removed(QString path); + void deviceListChanged(QMDDevicePtrList list); }; QHiMDDetection * createDetection(QObject * parent = NULL); diff --git a/qhimdtransfer/qhimdwindetection.cpp b/qhimdtransfer/qhimdwindetection.cpp index 3e79038..f5a9d0c 100644 --- a/qhimdtransfer/qhimdwindetection.cpp +++ b/qhimdtransfer/qhimdwindetection.cpp @@ -3,8 +3,6 @@ #include #include "qhimddetection.h" -#define WINVER 0x0500 - #include #include #include @@ -12,17 +10,15 @@ #include // needed for handling storage devices #include // needed for CM_Get_Child function -struct win_himd_device : himd_device { - HANDLE devhandle; - HDEVNOTIFY himdChange; - }; - static const GUID my_GUID_IO_MEDIA_ARRIVAL = {0xd07433c0, 0xa98e, 0x11d2, {0x91, 0x7a, 0x00, 0xa0, 0xc9, 0x06, 0x8f, 0xf3} }; static const GUID my_GUID_IO_MEDIA_REMOVAL = {0xd07433c1, 0xa98e, 0x11d2, {0x91, 0x7a, 0x00, 0xa0, 0xc9, 0x06, 0x8f, 0xf3} }; +static const GUID my_GUID_DEVINTERFACE_USB_DEVICE = + {0xa5dcbf10, 0x6530, 0x11d2, {0x90, 0x1f, 0x00, 0xc0,0x4f, 0xb9, 0x51, 0xed} }; + static const int my_DBT_CUSTOMEVENT = 0x8006; @@ -37,18 +33,19 @@ public: void scan_for_himd_devices(); QHiMDWinDetection(QObject * parent = NULL); ~QHiMDWinDetection(); - win_himd_device *find_by_path(QString path); private: HDEVNOTIFY hDevNotify; - win_himd_device *find_by_handle(HANDLE devhandle); - win_himd_device *win_dev_at(int idx); + HDEVNOTIFY listen_usbdev; + QMDDevice *find_by_handle(HANDLE devhandle); void add_himddevice(QString path, QString name); - void remove_himddevice(QString path); + virtual void remove_himddevice(QString path); void add_himd(HANDLE devhandle); void remove_himd(HANDLE devhandle); HDEVNOTIFY register_mediaChange(HANDLE devhandle); void unregister_mediaChange(HDEVNOTIFY himd_change); + HDEVNOTIFY register_usbDeviceNotification(); + void unregister_usbDeviceNotification(); bool nativeEvent(const QByteArray & eventType, void * message, long *result); bool winEvent(MSG * msg, long * result); }; @@ -64,12 +61,16 @@ QHiMDWinDetection::QHiMDWinDetection(QObject * parent) { // ask for Window ID to have Qt create the window. (void)winId(); + // register for usb device notifications + if((listen_usbdev = register_usbDeviceNotification()) == NULL) + qDebug() << "cannot register usb device notifications" << endl; } QHiMDWinDetection::~QHiMDWinDetection() { - while (!device_list.isEmpty()) - remove_himddevice(device_list.at(0)->path); + unregister_usbDeviceNotification(); + clearDeviceList(); + cleanup_netmd_list(); } void QHiMDWinDetection::scan_for_himd_devices() @@ -97,21 +98,17 @@ void QHiMDWinDetection::scan_for_himd_devices() return; } -win_himd_device *QHiMDWinDetection::win_dev_at(int idx) +QMDDevice *QHiMDWinDetection::find_by_handle(HANDLE devhandle) { - return static_cast(device_list.at(idx)); -} - -win_himd_device *QHiMDWinDetection::find_by_path(QString path) -{ - return static_cast(QHiMDDetection::find_by_path(path)); -} + QMDDevice *mddev; -win_himd_device *QHiMDWinDetection::find_by_handle(HANDLE devhandle) -{ - for (int i = 0; i < device_list.size(); i++) - if(win_dev_at(i)->devhandle == devhandle) - return win_dev_at(i); + foreach(mddev, dlist) + { + if(mddev->deviceType() != HIMD_DEVICE) + continue; + if(mddev->deviceHandle() == devhandle) + return mddev; + } return NULL; } @@ -192,13 +189,13 @@ void QHiMDWinDetection::add_himddevice(QString path, QString name) if (find_by_path(path)) return; - win_himd_device * new_device = new win_himd_device; + QHiMDDevice * new_device = new QHiMDDevice(); int k; char drv[] = "\\\\.\\X:"; QByteArray device = "\\\\.\\PHYSICALDRIVE"; char file[] = "X:\\HI-MD.IND"; DWORD retbytes; - HANDLE hdev; + HANDLE hdev, dev; STORAGE_DEVICE_NUMBER sdn; OFSTRUCT OFfile; @@ -214,81 +211,84 @@ void QHiMDWinDetection::add_himddevice(QString path, QString name) if(k != 0) device.append(QString::number(sdn.DeviceNumber)); - new_device->devhandle = CreateFileA(device.data(), NULL , FILE_SHARE_READ, NULL, + dev = CreateFileA(device.data(), NULL , FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if(new_device->devhandle == INVALID_HANDLE_VALUE) + if(dev == INVALID_HANDLE_VALUE) return; - new_device->himdChange = register_mediaChange(new_device->devhandle); - new_device->is_busy = false; - new_device->path = path; - new_device->recorder_name = name; + new_device->setDeviceHandle(dev); + new_device->registerMdChange(register_mediaChange(new_device->deviceHandle())); + new_device->setBusy(false); + new_device->setPath(path); + new_device->setName(name); file[0] = path.at(0).toLatin1(); if(OpenFile(file, &OFfile, OF_EXIST) != HFILE_ERROR) - { - new_device->md_inserted = true; - emit himd_found(new_device->path); - qDebug() << "himd device at " + new_device->path + " added (" + new_device->recorder_name + ")"; - } + new_device->setMdInserted(true); else - { - qDebug() << "himd device at " + new_device->path + " added (" + new_device->recorder_name + ")" + " ; without MD"; - new_device->md_inserted = false; - } + new_device->setMdInserted(false); - device_list.append(new_device); + dlist.append(new_device); + emit deviceListChanged(dlist); return; - } void QHiMDWinDetection::remove_himddevice(QString path) { - win_himd_device * dev = find_by_path(path); + int index = -1; + QHiMDDevice * dev = static_cast(find_by_path(path)); + if (!dev) return; - unregister_mediaChange(dev->himdChange); - - if (dev->devhandle != NULL) - CloseHandle(dev->devhandle); + index = dlist.indexOf(dev); - emit himd_removed(dev->path); + if(dev->isOpen()) + dev->close(); - qDebug() << "himd device at " + dev->path + " removed (" + dev->recorder_name + ")"; + if(dev->name() != "disc image") + { + if(dev->MdChange() != NULL) + unregister_mediaChange((HDEVNOTIFY)dev->MdChange()); + if(dev->deviceHandle() != NULL) + CloseHandle(dev->deviceHandle()); + } - device_list.removeAll(dev); delete dev; + dev = NULL; + + dlist.removeAt(index); + + emit deviceListChanged(dlist); } void QHiMDWinDetection::add_himd(HANDLE devhandle) { - win_himd_device * dev = find_by_handle(devhandle); + QMDDevice * dev = find_by_handle(devhandle); if (!dev) return; - if(!dev->md_inserted) - { - dev->md_inserted = true; - emit himd_found(dev->path); - qDebug() << "himd device at " + dev->path + " : md inserted"; - } + if(!dev->mdInserted()) + dev->setMdInserted(true); + + if(!dev->isOpen()) + dev->open(); + return; } void QHiMDWinDetection::remove_himd(HANDLE devhandle) { - win_himd_device * dev = find_by_handle(devhandle); + QMDDevice * dev = find_by_handle(devhandle); if (!dev) return; - if(dev->md_inserted) - { - dev->md_inserted = false; - emit himd_removed(dev->path); - qDebug() << "himd device at " + dev->path + " : md removed"; - } + if(dev->isOpen()) + dev->close(); + + dev->setMdInserted(false); + return; } @@ -312,6 +312,26 @@ void QHiMDWinDetection::unregister_mediaChange(HDEVNOTIFY himd_change) UnregisterDeviceNotification(himd_change); } +HDEVNOTIFY QHiMDWinDetection::register_usbDeviceNotification() +{ + DEV_BROADCAST_DEVICEINTERFACE filter; + + ZeroMemory(&filter, sizeof(filter)); + filter.dbcc_size = sizeof(filter); + filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; + filter.dbcc_reserved = 0; + filter.dbcc_classguid = my_GUID_DEVINTERFACE_USB_DEVICE; + + return RegisterDeviceNotification( (HWND)this->winId(), &filter, DEVICE_NOTIFY_WINDOW_HANDLE); + +} + +void QHiMDWinDetection::unregister_usbDeviceNotification() +{ + if(listen_usbdev != NULL) + UnregisterDeviceNotification(listen_usbdev); +} + bool QHiMDWinDetection::nativeEvent(const QByteArray & eventType, void * message, long *result) { if (eventType == "windows_generic_MSG") @@ -344,6 +364,17 @@ bool QHiMDWinDetection::winEvent(MSG * msg, long * result) } } } + else if(pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) + { + PDEV_BROADCAST_DEVICEINTERFACE pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)pHdr; + devID = QString::fromWCharArray(pDevInf->dbcc_name).toUpper(); + /* only handle netmd devices, himd devices will be handled by DBT_DEVTYP_VOLUME */ + if(identified(devID, name) && name.contains("NetMD)")) + { + qDebug() << name << " detected, rescanning netmd devices" << endl; + rescan_netmd_devices(); + } + } break; } case DBT_DEVICEREMOVECOMPLETE : @@ -355,6 +386,16 @@ bool QHiMDWinDetection::winEvent(MSG * msg, long * result) qDebug() << "Message:DBT_DEVICEREMOVECOMPLETE for drive " + path; remove_himddevice(path); } + else if(pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) + { + PDEV_BROADCAST_DEVICEINTERFACE pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)pHdr; + devID = QString::fromWCharArray(pDevInf->dbcc_name).toUpper(); + if(identified(devID, name) && name.contains("NetMD)")) + { + qDebug() << name << " removed, rescanning netmd devices" << endl; + rescan_netmd_devices(); + } + } break; } case DBT_DEVICEQUERYREMOVE : @@ -362,13 +403,13 @@ bool QHiMDWinDetection::winEvent(MSG * msg, long * result) if(pHdr->dbch_devicetype & DBT_DEVTYP_HANDLE) { PDEV_BROADCAST_HANDLE pHdrh = (PDEV_BROADCAST_HANDLE)pHdr; - win_himd_device *dev = find_by_handle(pHdrh->dbch_handle); + QMDDevice *dev = find_by_handle(pHdrh->dbch_handle); if(!dev) { qDebug() << "Message:DBT_DEVICEQUERYREMOVE for unknown device " << pHdrh->dbch_handle; break; } - if(dev->is_busy) + if(dev->isBusy()) { *result = BROADCAST_QUERY_DENY; qDebug() << "Message:DBT_DEVICEQUERYREMOVE for drive " + path + " denied: transfer in progress"; @@ -377,7 +418,24 @@ bool QHiMDWinDetection::winEvent(MSG * msg, long * result) else { qDebug() << "Message:DBT_DEVICEQUERYREMOVE requested"; - remove_himddevice(dev->path); + remove_himddevice(dev->path()); + } + } + else if(pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) + { + PDEV_BROADCAST_DEVICEINTERFACE pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)pHdr; + devID = QString::fromWCharArray(pDevInf->dbcc_name).toUpper(); + if(identified(devID, name) && name.contains("NetMD)")) + { + QMDDevice * dev = find_by_name(name); + if(!dev) + break; + if(dev->isBusy()) + { + *result = BROADCAST_QUERY_DENY; + return true; + } + dev->close(); } } break; -- 1.8.4.msysgit.0 --------------080204090806020407090108 Content-Type: text/x-patch; name="0005-including-netmd-support-into-the-gui-application-cha.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename*0="0005-including-netmd-support-into-the-gui-application-cha.pa"; filename*1="tch" >From 057236ba1315b108ebd54d0d04861f6b36a43b06 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Tue, 17 Dec 2013 23:37:02 +0100 Subject: [PATCH 5/7] including netmd support into the gui application: changed qhimduploaddialog to make it usable for netmd and himd devices --- qhimdtransfer/qhimduploaddialog.cpp | 10 +++++++++- qhimdtransfer/qhimduploaddialog.h | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/qhimdtransfer/qhimduploaddialog.cpp b/qhimdtransfer/qhimduploaddialog.cpp index acff6a7..390848e 100644 --- a/qhimdtransfer/qhimduploaddialog.cpp +++ b/qhimdtransfer/qhimduploaddialog.cpp @@ -34,6 +34,14 @@ void QHiMDUploadDialog::finished() /* Prevent shrinking of the box when hiding the indicators */ m_ui->current->setMinimumSize(m_ui->current->size()); m_ui->TrkPBar->hide(); + /* set AllPBar to 100% if it is not used during transfer, + * current netmd uploads doesnÂīt set the range correctly + */ + if(m_ui->AllPBar->maximum() == 0) + { + m_ui->AllPBar->setMaximum(1); + m_ui->AllPBar->setValue(1); + } m_ui->curtrack_label->hide(); m_ui->cancel_button->hide(); @@ -42,7 +50,7 @@ void QHiMDUploadDialog::finished() return; } -void QHiMDUploadDialog::starttrack(const QHiMDTrack & trk, const QString & title) +void QHiMDUploadDialog::starttrack(const QMDTrack & trk, const QString & title) { tracknum = trk.tracknum() + 1; m_ui->curtrack_label->setText(tr("current track: %1 - %2").arg(tracknum).arg(title)); diff --git a/qhimdtransfer/qhimduploaddialog.h b/qhimdtransfer/qhimduploaddialog.h index 157c58d..621fffd 100644 --- a/qhimdtransfer/qhimduploaddialog.h +++ b/qhimdtransfer/qhimduploaddialog.h @@ -2,7 +2,7 @@ #define QHIMDUPLOADDIALOG_H #include -#include "qhimdmodel.h" +#include "qmdtrack.h" namespace Ui { class QHiMDUploadDialog; @@ -17,7 +17,7 @@ public: bool upload_canceled() { return canceled; } void init(int trackcount, int totalblocks); - void starttrack(const QHiMDTrack & trk, const QString & title); + void starttrack(const QMDTrack & trk, const QString & title); void blockTransferred(); void trackFailed(const QString & errmsg); void trackSucceeded(); -- 1.8.4.msysgit.0 --------------080204090806020407090108 Content-Type: text/x-patch; name="0006-including-netmd-support-into-the-gui-application-cha.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0006-including-netmd-support-into-the-gui-application-cha.pa"; filename*1="tch" >From 28d4eb8596c6e1a0123f9b1c88f754e28ff8337c Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Tue, 17 Dec 2013 23:41:54 +0100 Subject: [PATCH 6/7] including netmd support into the gui application: changed qhimdmainwindow to use the new classes/device structure , removed upload routines which are already moved to other classes, updated qhimdtransfer.pro file --- qhimdtransfer/qhimdmainwindow.cpp | 476 ++++++++++---------------------------- qhimdtransfer/qhimdmainwindow.h | 26 +-- qhimdtransfer/qhimdmainwindow.ui | 18 +- qhimdtransfer/qhimdtransfer.pro | 13 +- 4 files changed, 156 insertions(+), 377 deletions(-) diff --git a/qhimdtransfer/qhimdmainwindow.cpp b/qhimdtransfer/qhimdmainwindow.cpp index 1b86651..588f3d1 100644 --- a/qhimdtransfer/qhimdmainwindow.cpp +++ b/qhimdtransfer/qhimdmainwindow.cpp @@ -1,213 +1,9 @@ #include "qhimdmainwindow.h" #include "ui_qhimdmainwindow.h" #include "qhimdaboutdialog.h" -#include "qhimduploaddialog.h" #include #include -#include - - -QString QHiMDMainWindow::dumpmp3(const QHiMDTrack & trk, QString file) -{ - QString errmsg; - struct himd_mp3stream str; - struct himderrinfo status; - unsigned int len; - const unsigned char * data; - QFile f(file); - - if(!f.open(QIODevice::ReadWrite)) - { - return tr("Error opening file for MP3 output"); - } - if(!(errmsg = trk.openMpegStream(&str)).isNull()) - { - f.remove(); - return tr("Error opening track: ") + errmsg; - } - while(himd_mp3stream_read_block(&str, &data, &len, NULL, &status) >= 0) - { - if(f.write((const char*)data,len) == -1) - { - errmsg = tr("Error writing audio data"); - goto clean; - } - uploadDialog->blockTransferred(); - QApplication::processEvents(); - if(uploadDialog->upload_canceled()) - { - errmsg = tr("upload aborted by the user"); - goto clean; - } - - } - if(status.status != HIMD_STATUS_AUDIO_EOF) - errmsg = tr("Error reading audio data: ") + status.statusmsg; - -clean: - f.close(); - himd_mp3stream_close(&str); - if(!errmsg.isNull()) - f.remove(); - return errmsg; -} - -static inline TagLib::String QStringToTagString(const QString & s) -{ - return TagLib::String(s.toUtf8().data(), TagLib::String::UTF8); -} - -static void addid3tag(QString title, QString artist, QString album, QString file) -{ -#ifdef Q_OS_WIN - TagLib::FileRef f(file.toStdWString().c_str()); -#else - TagLib::FileRef f(file.toUtf8().data()); -#endif - TagLib::Tag *t = f.tag(); - t->setTitle(QStringToTagString(title)); - t->setArtist(QStringToTagString(artist)); - t->setAlbum(QStringToTagString(album)); - t->setComment("*** imported from HiMD via QHiMDTransfer ***"); - f.file()->save(); -} - -QString QHiMDMainWindow::dumpoma(const QHiMDTrack & track, QString file) -{ - QString errmsg; - struct himd_nonmp3stream str; - struct himderrinfo status; - unsigned int len; - const unsigned char * data; - QFile f(file); - - if(!f.open(QIODevice::ReadWrite)) - return tr("Error opening file for ATRAC output"); - - if(!(errmsg = track.openNonMpegStream(&str)).isNull()) - { - f.remove(); - return tr("Error opening track: ") + status.statusmsg; - } - - if(f.write(track.makeEA3Header()) == -1) - { - errmsg = tr("Error writing header"); - goto clean; - } - while(himd_nonmp3stream_read_block(&str, &data, &len, NULL, &status) >= 0) - { - if(f.write((const char*)data,len) == -1) - { - errmsg = tr("Error writing audio data"); - goto clean; - } - uploadDialog->blockTransferred(); - QApplication::processEvents(); - if(uploadDialog->upload_canceled()) - { - errmsg = QString("upload aborted by the user"); - goto clean; - } - } - if(status.status != HIMD_STATUS_AUDIO_EOF) - errmsg = QString("Error reading audio data: ") + status.statusmsg; - -clean: - f.close(); - himd_nonmp3stream_close(&str); - - if(!errmsg.isNull()) - f.remove(); - return errmsg; -} - -QString QHiMDMainWindow::dumppcm(const QHiMDTrack & track, QString file) -{ - struct himd_nonmp3stream str; - struct himderrinfo status; - unsigned int len, i; - int left, right; - int clipcount; - QString errmsg; - QFile f(file); - const unsigned char * data; - sox_format_t * out; - sox_sample_t soxbuf [HIMD_MAX_PCMFRAME_SAMPLES * 2]; - sox_signalinfo_t signal_out; - - signal_out.channels = 2; - signal_out.length = 0; - signal_out.precision = 16; - signal_out.rate = 44100; - - if(!(out = sox_open_write(file.toUtf8(), &signal_out, NULL, NULL, NULL, NULL))) - return tr("Error opening file for WAV output"); - - if(!(errmsg = track.openNonMpegStream(&str)).isNull()) - { - f.remove(); - return tr("Error opening track: ") + status.statusmsg; - } - - while(himd_nonmp3stream_read_block(&str, &data, &len, NULL, &status) >= 0) - { - - for(i = 0; i < len/4; i++) { - - left = data[i*4]*256+data[i*4+1]; - right = data[i*4+2]*256+data[i*4+3]; - if (left > 0x8000) left -= 0x10000; - if (right > 0x8000) right -= 0x10000; - - soxbuf[i*2] = SOX_SIGNED_16BIT_TO_SAMPLE(left, clipcount); - soxbuf[i*2+1] = SOX_SIGNED_16BIT_TO_SAMPLE(right, clipcount); - (void)clipcount; /* suppess "is unused" warning */ - } - - if (sox_write(out, soxbuf, len/2) != len/2) - { - errmsg = tr("Error writing audio data"); - goto clean; - } - uploadDialog->blockTransferred(); - QApplication::processEvents(); - if(uploadDialog->upload_canceled()) - { - errmsg = QString("upload aborted by the user"); - goto clean; - } - } - if(status.status != HIMD_STATUS_AUDIO_EOF) - errmsg = QString("Error reading audio data: ") + status.statusmsg; - -clean: - sox_close(out); - himd_nonmp3stream_close(&str); - - if(!errmsg.isNull()) - f.remove(); - return errmsg; -} - -void QHiMDMainWindow::checkfile(QString UploadDirectory, QString &filename, QString extension) -{ - QFile f; - QString newname; - int i = 2; - - f.setFileName(UploadDirectory + "/" + filename + extension); - while(f.exists()) - { - newname = filename + " (" + QString::number(i) + ")"; - f.setFileName(UploadDirectory + "/" + newname + extension); - i++; - } - if(!newname.isEmpty()) - filename = newname; -} - void QHiMDMainWindow::set_buttons_enable(bool connect, bool download, bool upload, bool rename, bool del, bool format, bool quit) { ui->action_Connect->setEnabled(connect); @@ -221,23 +17,29 @@ void QHiMDMainWindow::set_buttons_enable(bool connect, bool download, bool uploa ui->download_button->setEnabled(download); } -void QHiMDMainWindow::init_himd_browser() +void QHiMDMainWindow::init_himd_browser(QMDTracksModel * model) { - int i = 0; + int i, width; + QString browser = current_device->deviceType() == NETMD_DEVICE ? "netmd_browser" : "himd_browser"; + ui->TrackList->setModel(model); - ui->TrackList->setModel(&trackmodel); - for(;i < trackmodel.columnCount(); i++) - ui->TrackList->resizeColumnToContents(i); QObject::connect(ui->TrackList->selectionModel(), SIGNAL(selectionChanged (const QItemSelection &, const QItemSelection &)), this, SLOT(handle_himd_selection_change(const QItemSelection&, const QItemSelection&))); + + // read saved column width for this model + for(i = 0; i < ui->TrackList->model()->columnCount(); i++) + { + width = settings.value(browser + QString::number(i), 0).toInt(); + if(width != 0) + ui->TrackList->setColumnWidth(i, width); + } } void QHiMDMainWindow::init_local_browser() { QStringList DownloadFileList; localmodel.setFilter(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); - localmodel.setNameFilters(QStringList() << "*.mp3" << "*.wav" << "*.oma"); - localmodel.setSelectableExtensions(trackmodel.downloadableFileExtensions()); + localmodel.setNameFilters(QStringList() << "*.mp3" << "*.wav" << "*.oma" << "*.aea"); localmodel.setNameFilterDisables(false); localmodel.setReadOnly(false); localmodel.setRootPath("/"); @@ -255,130 +57,92 @@ void QHiMDMainWindow::init_local_browser() void QHiMDMainWindow::save_window_settings() { - int i = 0; - settings.setValue("geometry", QMainWindow::saveGeometry()); settings.setValue("windowState", QMainWindow::saveState()); - for(;i < trackmodel.columnCount(); i++) - settings.setValue("himd_browser" + QString::number(i), ui->TrackList->columnWidth(i)); } void QHiMDMainWindow::read_window_settings() { - int i = 0; - int width; - QMainWindow::restoreGeometry(settings.value("geometry").toByteArray()); QMainWindow::restoreState(settings.value("windowState").toByteArray()); - for(; i < trackmodel.columnCount(); i++) - { - width = settings.value("himd_browser" + QString::number(i), 0).toInt(); - if(width != 0) - ui->TrackList->setColumnWidth(i, width); - } } bool QHiMDMainWindow::autodetect_init() { - int k; + if(!QObject::connect(detect, SIGNAL(deviceListChanged(QMDDevicePtrList)), this, SLOT(device_list_changed(QMDDevicePtrList)))) + return false; - k = (bool)QObject::connect(detect, SIGNAL(himd_found(QString)), this, SLOT(himd_found(QString))); - k += (bool)QObject::connect(detect, SIGNAL(himd_removed(QString)), this, SLOT(himd_removed(QString))); + detect->scan_for_minidisc_devices(); + return true; +} - if(!k) - return false; +void QHiMDMainWindow::setCurrentDevice(QMDDevice *dev) +{ + current_device = dev; + QObject::connect(current_device, SIGNAL(closed()), this, SLOT(current_device_closed())); - QObject::connect(this, SIGNAL(himd_busy(QString)), detect, SLOT(himd_busy(QString))); - QObject::connect(this, SIGNAL(himd_idle(QString)), detect, SLOT(himd_idle(QString))); + if(current_device->deviceType() == NETMD_DEVICE) + init_himd_browser(&ntmodel); - detect->scan_for_himd_devices(); - return true; + else if(current_device->deviceType() == HIMD_DEVICE) + init_himd_browser(&htmodel); } -void QHiMDMainWindow::open_himd_at(const QString & path) +void QHiMDMainWindow::open_device(QMDDevice * dev) { - QMessageBox himdStatus; + QMessageBox mdStatus; QString error; + QMDTracksModel * mod; + + int index = ui->himd_devices->currentIndex(); // remember current index of devices combo box, will be resetted by current_device_closed() function - error = trackmodel.open(path.toLatin1()); + if (dev == NULL) // "disconnected" selected by the user + { + current_device_closed(); + return; + } + + if(current_device) + { + current_device_closed(); + ui->himd_devices->setCurrentIndex(index); // set correct device index in the combo box + } - if (!error.isNull()) { - himdStatus.setText(tr("Error opening HiMD data. Make sure you chose the proper root directory of your HiMD-Walkman.\n") + error); - himdStatus.exec(); + if(dev->deviceType() == HIMD_DEVICE && dev->path().isEmpty()) + { + mdStatus.setText(tr("Error opening himd device/disc image , no device path given\nPlease use connect button to set the path to the himd device/disc image")); + mdStatus.exec(); set_buttons_enable(1,0,0,0,0,0,1); + ui->himd_devices->setCurrentIndex(0); return; } - ui->himdpath->setText(path); - settings.setValue("lastHiMDDirectory", path); + setCurrentDevice(dev); + mod = (QMDTracksModel *)ui->TrackList->model(); + error = mod->open(dev); - himd_device * dev = detect->find_by_path(path); - if(dev) - ui->statusBar->showMessage(dev->recorder_name); - else - ui->statusBar->clearMessage(); + if (!error.isEmpty()) + { + mdStatus.setText(tr("Error opening minidisc device (") + current_device->name() + "):\n" + error); + mdStatus.exec(); + set_buttons_enable(1,0,0,0,0,0,1); + ui->himd_devices->setCurrentIndex(0); + return; + } + localmodel.setSelectableExtensions(mod->downloadableFileExtensions()); + ui->DiscTitle->setText(current_device->discTitle()); set_buttons_enable(1,0,0,1,1,1,1); } void QHiMDMainWindow::upload_to(const QString & UploadDirectory) { - emit himd_busy(ui->himdpath->text()); - - QHiMDTrackList tracks = trackmodel.tracks(ui->TrackList->selectionModel()->selectedRows(0)); - - int allblocks = 0; - for(int i = 0;i < tracks.length(); i++) - allblocks += tracks[i].blockcount(); - - uploadDialog->init(tracks.length(), allblocks); - - for(int i = 0;i < tracks.length(); i++) - { - QString filename, errmsg; - QString title = tracks[i].title(); - if(title.isNull()) - filename = tr("Track %1").arg(tracks[i].tracknum()+1); - else - filename = tracks[i].artist() + " - " + title; - - uploadDialog->starttrack(tracks[i], filename); - if (!tracks[i].copyprotected()) - { - QString codec = tracks[i].codecname(); - if (codec == "MPEG") - { - checkfile(UploadDirectory, filename, ".mp3"); - errmsg = dumpmp3 (tracks[i], UploadDirectory + "/" + filename + ".mp3"); - if(errmsg.isNull()) - addid3tag (tracks[i].title(),tracks[i].artist(),tracks[i].album(), UploadDirectory+ "/" +filename + ".mp3"); - } - else if (codec == "LPCM") - { - checkfile(UploadDirectory, filename, ".wav"); - errmsg = dumppcm (tracks[i], UploadDirectory + "/" + filename + ".wav"); - } - else if (codec == "AT3+" || codec == "AT3 ") - { - checkfile(UploadDirectory, filename, ".oma"); - errmsg = dumpoma (tracks[i], UploadDirectory + "/" + filename + ".oma"); - } - } - else - errmsg = tr("upload disabled because of DRM encryption"); - - if(errmsg.isNull()) - uploadDialog->trackSucceeded(); - else - uploadDialog->trackFailed(errmsg); + QMDTrackIndexList tlist; - QApplication::processEvents(); - if(uploadDialog->upload_canceled()) - break; - } - uploadDialog->finished(); + foreach(QModelIndex index, ui->TrackList->selectionModel()->selectedRows(0)) + tlist.append(index.row()); - emit himd_idle(ui->himdpath->text()); + current_device->batchUpload(tlist, UploadDirectory); } QHiMDMainWindow::QHiMDMainWindow(QWidget *parent) @@ -386,22 +150,24 @@ QHiMDMainWindow::QHiMDMainWindow(QWidget *parent) { aboutDialog = new QHiMDAboutDialog; formatDialog = new QHiMDFormatDialog; - uploadDialog = new QHiMDUploadDialog; + current_device = NULL; detect = createDetection(this); ui->setupUi(this); ui->updir->setText(settings.value("lastUploadDirectory", QDir::homePath()).toString()); set_buttons_enable(1,0,0,0,0,0,1); - init_himd_browser(); init_local_browser(); read_window_settings(); - ui->himd_devices->hide(); + ui->himdpath->hide(); // not needed, replaced by combo box if(!autodetect_init()) ui->statusBar->showMessage(" autodetection disabled", 10000); } QHiMDMainWindow::~QHiMDMainWindow() { + if(current_device && current_device->isOpen()) + current_device->close(); + save_window_settings(); delete ui; } @@ -454,8 +220,9 @@ void QHiMDMainWindow::on_action_Format_triggered() void QHiMDMainWindow::on_action_Connect_triggered() { int index; + QHiMDDevice *dev; QString HiMDDirectory; - HiMDDirectory = settings.value("lastHiMDDirectory", QDir::rootPath()).toString(); + HiMDDirectory = settings.value("lastImageDirectory", QDir::rootPath()).toString(); HiMDDirectory = QFileDialog::getExistingDirectory(this, tr("Select directory of HiMD Medium"), HiMDDirectory, @@ -464,21 +231,13 @@ void QHiMDMainWindow::on_action_Connect_triggered() if(HiMDDirectory.isEmpty()) return; - index = ui->himd_devices->findText(HiMDDirectory); - if(index == -1) - { - ui->himd_devices->addItem(HiMDDirectory); - index = ui->himd_devices->findText(HiMDDirectory); - } - ui->himd_devices->setCurrentIndex(index); + index = ui->himd_devices->findText("disc image"); + ui->himd_devices->setCurrentIndex(index); // index of disk image device + dev = (QHiMDDevice *)ui->himd_devices->itemData(index).value(); + dev->setPath(HiMDDirectory); + ui->himd_devices->setItemText(index, QString((dev->name() + " at " + dev->path() ))); - if(ui->himd_devices->isHidden()) - { - ui->himd_devices->show(); - ui->himdpath->hide(); - } - - open_himd_at(HiMDDirectory); + open_device(dev); } void QHiMDMainWindow::on_upload_button_clicked() @@ -506,67 +265,74 @@ void QHiMDMainWindow::handle_local_selection_change(const QItemSelection&, const } if(localmodel.fileInfo(index).isFile()) - download_possible = trackmodel.is_open(); + download_possible = current_device && current_device->isOpen(); ui->action_Download->setEnabled(download_possible); ui->download_button->setEnabled(download_possible); } -void QHiMDMainWindow::himd_found(QString HiMDPath) +void QHiMDMainWindow::device_list_changed(QMDDevicePtrList dplist) { - int index; + QString device; + QMDDevice * dev; - if(HiMDPath.isEmpty()) - return; + /* close current device if it is removed from device list, just to be sure, should be handled by closed() signal */ + if(current_device && current_device->isOpen() && !dplist.contains(current_device)) + current_device_closed(); - index = ui->himd_devices->findText(HiMDPath); - if(index == -1) - ui->himd_devices->addItem(HiMDPath); + ui->himd_devices->clear(); + // add dummy entry for + ui->himd_devices->addItem(""); - if(ui->himd_devices->isHidden()) + foreach(dev, dplist) { - ui->himd_devices->show(); - ui->himdpath->hide(); + device = QString(dev->deviceType() == NETMD_DEVICE ? dev->name() : dev->name() + " at " + dev->path() ); + ui->himd_devices->addItem(device, qVariantFromValue((void *)dev)); } - if(!trackmodel.is_open()) + if(current_device) + ui->himd_devices->setCurrentIndex(dplist.indexOf(current_device) + 1); + else { - index = ui->himd_devices->findText(HiMDPath); - ui->himd_devices->setCurrentIndex(index); - open_himd_at(HiMDPath); + if(dplist.count() > 1) // open first autodetected device + { + ui->himd_devices->setCurrentIndex(2); + open_device(dplist.at(1)); + } } - } -void QHiMDMainWindow::himd_removed(QString HiMDPath) +void QHiMDMainWindow::on_himd_devices_activated(QString device) { - int index; - - if(HiMDPath.isEmpty()) - return; - if (ui->himdpath->text() == HiMDPath) - { - ui->himdpath->setText(tr("(disconnected)")); - ui->statusBar->clearMessage(); - trackmodel.close(); - } + QMDDevice * dev; + int index = ui->himd_devices->findText(device); - index = ui->himd_devices->findText(HiMDPath); - if(index != -1) + if (index == 0) // disconnected { - ui->himd_devices->removeItem(index); + open_device(NULL); + return; } - if(ui->himd_devices->count() == 0) - { - ui->himd_devices->hide(); - ui->himdpath->show(); - } + dev = (QMDDevice *)ui->himd_devices->itemData(index).value(); + open_device(dev); } -void QHiMDMainWindow::on_himd_devices_activated(QString device) +void QHiMDMainWindow::current_device_closed() { - open_himd_at(device); + int i; + QString browser = current_device->deviceType() == NETMD_DEVICE ? "netmd_browser" : "himd_browser"; + QMDTracksModel * mod = (QMDTracksModel *)ui->TrackList->model(); + + QObject::disconnect(current_device, SIGNAL(closed()), this, SLOT(current_device_closed())); + + // save column width for this model first + for(i = 0;i < mod->columnCount(); i++) + settings.setValue(browser + QString::number(i), ui->TrackList->columnWidth(i)); + + mod->close(); + current_device = NULL; + ui->DiscTitle->setText(QString()); + ui->himd_devices->setCurrentIndex(0); } void QHiMDMainWindow::on_download_button_clicked() diff --git a/qhimdtransfer/qhimdmainwindow.h b/qhimdtransfer/qhimdmainwindow.h index b9b14f7..da2c52a 100644 --- a/qhimdtransfer/qhimdmainwindow.h +++ b/qhimdtransfer/qhimdmainwindow.h @@ -6,14 +6,10 @@ #include #include "qhimdaboutdialog.h" #include "qhimdformatdialog.h" -#include "qhimduploaddialog.h" #include "qhimddetection.h" -#include "qhimdmodel.h" #include "../libhimd/himd.h" -#include -#include -#include -#include +#include "qmdmodel.h" +#include "qmddevice.h" extern "C" { #include @@ -36,22 +32,20 @@ private: Ui::QHiMDMainWindowClass *ui; QHiMDAboutDialog * aboutDialog; QHiMDFormatDialog * formatDialog; - QHiMDUploadDialog * uploadDialog; QHiMDDetection * detect; - QHiMDTracksModel trackmodel; + QNetMDTracksModel ntmodel; + QHiMDTracksModel htmodel; QHiMDFileSystemModel localmodel; QSettings settings; - QString dumpmp3(const QHiMDTrack & trk, QString file); - QString dumpoma(const QHiMDTrack & trk, QString file); - QString dumppcm(const QHiMDTrack & trk, QString file); - void checkfile(QString UploadDirectory, QString &filename, QString extension); + QMDDevice * current_device; void set_buttons_enable(bool connect, bool download, bool upload, bool rename, bool del, bool format, bool quit); - void init_himd_browser(); + void init_himd_browser(QMDTracksModel *model); void init_local_browser(); void save_window_settings(); void read_window_settings(); bool autodetect_init(); - void open_himd_at(const QString & path); + void setCurrentDevice(QMDDevice * dev); + void open_device(QMDDevice * dev); void upload_to(const QString & path); private slots: @@ -64,9 +58,9 @@ private slots: void on_upload_button_clicked(); void handle_himd_selection_change(const QItemSelection&, const QItemSelection&); void handle_local_selection_change(const QItemSelection&, const QItemSelection&); - void himd_found(QString path); - void himd_removed(QString path); + void device_list_changed(QMDDevicePtrList dplist); void on_himd_devices_activated(QString device); + void current_device_closed(); void on_download_button_clicked(); signals: diff --git a/qhimdtransfer/qhimdmainwindow.ui b/qhimdtransfer/qhimdmainwindow.ui index b55845f..d54f20d 100644 --- a/qhimdtransfer/qhimdmainwindow.ui +++ b/qhimdtransfer/qhimdmainwindow.ui @@ -35,7 +35,7 @@ - HiMD path + <html><head/><body><p>minidisc device (path):</p></body></html> @@ -52,6 +52,20 @@ + + + + + <html><head/><body><p><span style=" font-weight:600;">disc title:</span></p></body></html> + + + + + + + + + QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed @@ -174,7 +188,7 @@ 0 0 784 - 18 + 20 diff --git a/qhimdtransfer/qhimdtransfer.pro b/qhimdtransfer/qhimdtransfer.pro index 6d3e39d..9ac07cb 100644 --- a/qhimdtransfer/qhimdtransfer.pro +++ b/qhimdtransfer/qhimdtransfer.pro @@ -54,8 +54,10 @@ HEADERS += qhimdaboutdialog.h \ qhimdformatdialog.h \ qhimduploaddialog.h \ qhimdmainwindow.h \ - qhimdmodel.h \ - qhimddetection.h + qhimddetection.h \ + qmdmodel.h \ + qmdtrack.h \ + qmddevice.h FORMS += qhimdaboutdialog.ui \ qhimdformatdialog.ui \ qhimduploaddialog.ui \ @@ -65,8 +67,10 @@ SOURCES += main.cpp \ qhimdformatdialog.cpp \ qhimduploaddialog.cpp \ qhimdmainwindow.cpp \ - qhimdmodel.cpp \ - qhimddetection.cpp + qhimddetection.cpp \ + qmdmodel.cpp \ + qmdtrack.cpp \ + qmddevice.cpp win32:SOURCES += qhimdwindetection.cpp else:SOURCES += qhimddummydetection.cpp RESOURCES += icons.qrc @@ -82,6 +86,7 @@ mac:ICON = qhimdtransfer.icns win32:TARGET = QHiMDTransfer mac:TARGET = QHiMDTransfer include(../libhimd/use_libhimd.pri) +include(../libnetmd/use_libnetmd.prl) # Installing stuff translations.files = $$bracketAll(LANGUAGES, qhimdtransfer_,.qm) -- 1.8.4.msysgit.0 --------------080204090806020407090108 Content-Type: text/x-patch; name="0007-including-netmd-support-into-the-gui-application-add.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0007-including-netmd-support-into-the-gui-application-add.pa"; filename*1="tch" >From a1adb7407459e728a878a1acf95bcac8882a1e54 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Tue, 17 Dec 2013 23:53:30 +0100 Subject: [PATCH 7/7] including netmd support into the gui application: added missing additional libnetmd header file --- libnetmd/libnetmd_extended.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 libnetmd/libnetmd_extended.h diff --git a/libnetmd/libnetmd_extended.h b/libnetmd/libnetmd_extended.h new file mode 100644 index 0000000..1eb74db --- /dev/null +++ b/libnetmd/libnetmd_extended.h @@ -0,0 +1,37 @@ +/* + * include this header file to get access to additional libnetmd members + */ + +#include "libnetmd.h" + +typedef struct { + unsigned char content[255]; + size_t length; + size_t position; +} netmd_response; + +/* + * additional members from secure.c + */ + +void netmd_send_secure_msg(netmd_dev_handle *dev, unsigned char cmd, unsigned char *data, size_t data_size); +netmd_error netmd_recv_secure_msg(netmd_dev_handle *dev, unsigned char cmd, netmd_response *response, + unsigned char expected_response_code); +netmd_error netmd_secure_real_recv_track(netmd_dev_handle *dev, uint32_t length, FILE *file, size_t chunksize); +void netmd_write_aea_header(char *name, uint32_t frames, unsigned char channel, FILE* f); +void netmd_write_wav_header(unsigned char format, uint32_t bytes, FILE *f); + +/* + * additional members from utils.c + * XXX: do not include utils.h when using taglib, definition of min(a,b) is incomatible with definition of min(...) in taglib + */ +void netmd_check_response_bulk(netmd_response *response, const unsigned char* const expected, + const size_t expected_length, netmd_error *error); +void netmd_check_response_word(netmd_response *response, const uint16_t expected, + netmd_error *error); +void netmd_read_response_bulk(netmd_response *response, unsigned char* target, + const size_t length, netmd_error *error); +unsigned char *netmd_copy_word_to_buffer(unsigned char **buf, uint16_t value, int little_endian); +unsigned char netmd_read(netmd_response *response); +uint16_t netmd_read_word(netmd_response *response); +uint32_t netmd_read_doubleword(netmd_response *response); -- 1.8.4.msysgit.0 --------------080204090806020407090108-- From glaubitz@physik.fu-berlin.de Wed Dec 18 00:49:59 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vt4Oj-003652-TR>; Wed, 18 Dec 2013 00:49:58 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1Vt4Oj-0004HO-Ra>; Wed, 18 Dec 2013 00:49:57 +0100 Received: from port-92-206-0-171.dynamic.qsc.de ([92.206.0.171] helo=[192.168.178.71]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1Vt4Oj-000zgC-NS>; Wed, 18 Dec 2013 00:49:57 +0100 Message-ID: <52B0E324.6090408@physik.fu-berlin.de> Date: Wed, 18 Dec 2013 00:49:56 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.1.1 MIME-Version: 1.0 To: Thomas Arp , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> In-Reply-To: <52B0E208.7090904@gmx.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.206.0.171 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387324197-0001F7A4-DAAEB7AB/0-0/0-0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Gabun.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Dec 2013 23:49:59 -0000 On 12/18/2013 12:45 AM, Thomas Arp wrote: > i started implementing netmdsupport for the gui application some time ago. > As the current master repository has changed, i updated my patches. > They can be applied to the current repo now. > I also made some cleanup and improvement. And I made a stupid mistake. I forgot to push a previous contribution made by Howard Chu [1] and also tagging version 0.9.10. Could you rebase your patches against the github repository for linux-minidisc until I have fixed our main repository? The github repo can be found here [2]. > There are many changes, rearrangements and code moving, i splitted the > patch into several parts (file by file btw. class by class). > It can only be compiled if all patches are applied because many changes > depends on other ones in other files. > I just splitted it to make review easier. Ok, duly noted :). > I hope Michael will find some time for a review. Hopefully. I am currently busy with a bunch of Debian packages I need to review and sponsor, but I will have a look at your patches as well. Michael is currently in town and on vacation, so he might be willing to look at your patches. But, please rebase them against the github repository first. Sorry for the confusion and thanks for the patches! Cheers, Adrian > [1] https://github.com/glaubitz/linux-minidisc/commit/a3a65c0a2a6c043e8234823edd1786edf2e7685e > [2] https://github.com/glaubitz/linux-minidisc/ -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From manner.moe@gmx.de Wed Dec 18 01:13:35 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vt4lZ-0037LM-Q0>; Wed, 18 Dec 2013 01:13:33 +0100 Received: from mout.gmx.net ([212.227.15.15]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vt4lZ-001vOc-NM>; Wed, 18 Dec 2013 01:13:33 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0M96Jd-1VnoUj1V77-00CRGp for ; Wed, 18 Dec 2013 01:13:32 +0100 Message-ID: <52B0E89D.70805@gmx.de> Date: Wed, 18 Dec 2013 01:13:17 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: John Paul Adrian Glaubitz , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> In-Reply-To: <52B0E324.6090408@physik.fu-berlin.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:Ol1CT6yuUOgXXLUe//T8mRSvzsts/FFC1NZ1MVgoUvRGO173IeG Yk+atYiBKKxd26Oj6b/qJ9cnQeYhso1qZ0a1mKL+3V3GkFfbnidMWhBGA+aBbG79XEzM8/V SpPbCc7QdKVg4wkBWRJdJ2rlmEvjp8+ewhOwhm2zHtJDPVuV5SZIRPV/HwcMDm4ZgtrpgVW qA/KdlM+vysVXjqwfPccA== X-Originating-IP: 212.227.15.15 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387325613-0001F7A4-F2B23CD1/0-0/0-0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.005605, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Dschibuti.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Dec 2013 00:13:35 -0000 Am 18.12.2013 00:49, schrieb John Paul Adrian Glaubitz: > > And I made a stupid mistake. I forgot to push a previous contribution > made by Howard Chu [1] and also tagging version 0.9.10. > > Could you rebase your patches against the github repository for > linux-minidisc until I have fixed our main repository? > > > Sorry for the confusion and thanks for the patches! > > Cheers, > > Adrian > I took a quick look at it, The contribution by Howard Chu depends on files that will be deleted in my patches (code movement to other files). My pathes can be applied anyway but Howards changes will be deleted. I think the easiest way is that i make another patch that intergates this into my new files/classes. Else i have to rebuild my patch manually to integrate it. Thomas From manner.moe@gmx.de Wed Dec 18 02:17:17 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vt5lE-003AfP-2j>; Wed, 18 Dec 2013 02:17:16 +0100 Received: from mout.gmx.net ([212.227.17.20]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vt5lD-0022Oo-Vr>; Wed, 18 Dec 2013 02:17:16 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0Lh7M3-1V8QHN2UQ3-00oU85 for ; Wed, 18 Dec 2013 02:17:14 +0100 Message-ID: <52B0F78B.3040504@gmx.de> Date: Wed, 18 Dec 2013 02:16:59 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: John Paul Adrian Glaubitz , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> In-Reply-To: <52B0E89D.70805@gmx.de> Content-Type: multipart/mixed; boundary="------------080303090008090109070404" X-Provags-ID: V03:K0:pY6JKuGHZHz0pDHdCZwmChPzprr4Ac3Qe7fBGNzdhKqqYuDkdXy MtXvwP7jaYx1G0v8NUHTLypb0nQ5n3A7BsQa0cwpD3E0RH8Ge1k6v/ByqthKDZ8djDC2KAM TzMh7cCuYqQgt8/ixxI3WC+naZeED5LfG0ZsZyqDa7I4RFilteu87LZebb6dRqA5Kw3vjNo 8AYPSP+t9fVa1e8nfznHQ== X-Originating-IP: 212.227.17.20 X-ZEDAT-Hint: A X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387329436-0001F7A4-DB5FBE0B/0-0/0-0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Benin.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Dec 2013 01:17:18 -0000 This is a multi-part message in MIME format. --------------080303090008090109070404 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Am 18.12.2013 01:13, schrieb Thomas Arp: > Am 18.12.2013 00:49, schrieb John Paul Adrian Glaubitz: >> >> And I made a stupid mistake. I forgot to push a previous contribution >> made by Howard Chu [1] and also tagging version 0.9.10. >> >> Could you rebase your patches against the github repository for >> linux-minidisc until I have fixed our main repository? >> >> >> Sorry for the confusion and thanks for the patches! >> >> Cheers, >> >> Adrian >> > I took a quick look at it, > The contribution by Howard Chu depends on files that will be deleted > in my patches (code movement to other files). > My pathes can be applied anyway but Howards changes will be deleted. > I think the easiest way is that i make another patch that intergates > this into my new files/classes. > Else i have to rebuild my patch manually to integrate it. > O.K., i made an additional patch which includes Howards changes. I also initialized QTime and QDate objects for Qt5 support. Thomas --------------080303090008090109070404 Content-Type: text/x-patch; name="0008-Added-missing-patch-by-Howard-Chu-Add-column-in.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0008-Added-missing-patch-by-Howard-Chu-Add-column-in.patch" >From beda8dbbfd207d660f9f19f3dd2eb040cfdf56f0 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Wed, 18 Dec 2013 02:09:38 +0100 Subject: [PATCH 8/8] Added missing patch by Howard Chu: Add column in trackview to display recording date and time (updated for Qt5 support) --- qhimdtransfer/qmdmodel.cpp | 13 +++++++++++-- qhimdtransfer/qmdtrack.cpp | 17 +++++++++++++++++ qhimdtransfer/qmdtrack.h | 1 + 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/qhimdtransfer/qmdmodel.cpp b/qhimdtransfer/qmdmodel.cpp index 48ff275..890d51f 100644 --- a/qhimdtransfer/qmdmodel.cpp +++ b/qhimdtransfer/qmdmodel.cpp @@ -3,8 +3,8 @@ #include enum hcolumnum { - ColId, ColTitle, ColArtist, ColAlbum, ColLength, ColCodec, ColUploadable, - LAST_hcolumnnum = ColUploadable + ColId, ColTitle, ColArtist, ColAlbum, ColLength, ColCodec, ColUploadable, ColRecDate, + LAST_hcolumnnum = ColRecDate }; enum ncolumnum { @@ -205,6 +205,8 @@ QVariant QHiMDTracksModel::headerData(int section, Qt::Orientation orientation, /* Really use the header for the metric in these columns, contents will be shorter */ return QAbstractListModel::headerData(section,orientation,role); + case ColRecDate: + return QSize(met.width("yyyy.MM.dd hh:mm:ss"), 0); } } @@ -226,6 +228,8 @@ QVariant QHiMDTracksModel::headerData(int section, Qt::Orientation orientation, return tr("Format"); case ColUploadable: return tr("Uploadable"); + case ColRecDate: + return tr("Recorded At"); } } return QVariant(); @@ -269,6 +273,11 @@ QVariant QHiMDTracksModel::data(const QModelIndex & index, int role) const return track.codecname(); case ColUploadable: return QVariant(); /* Displayed by checkbox */ + case ColRecDate: + { + QDateTime dt = track.recdate(); + return dt.toString("yyyy.MM.dd hh:mm:ss"); + } } } return QVariant(); diff --git a/qhimdtransfer/qmdtrack.cpp b/qhimdtransfer/qmdtrack.cpp index 9ecca74..3d6bf1f 100644 --- a/qhimdtransfer/qmdtrack.cpp +++ b/qhimdtransfer/qmdtrack.cpp @@ -74,6 +74,23 @@ QTime QHiMDTrack::duration() const return QTime(); } +QDateTime QHiMDTrack::recdate() const +{ + QDate d(0,0,0); + QTime t(0,0,0); + if (trackslot != 0) + { + t.setHMS(ti.recordingtime.tm_hour, + ti.recordingtime.tm_min, + ti.recordingtime.tm_sec); + d.setDate(ti.recordingtime.tm_year+1900, + ti.recordingtime.tm_mon+1, + ti.recordingtime.tm_mday); + return QDateTime(d,t); + } + return QDateTime(); +} + bool QHiMDTrack::copyprotected() const { if(trackslot != 0) diff --git a/qhimdtransfer/qmdtrack.h b/qhimdtransfer/qmdtrack.h index ac47a9f..629448f 100644 --- a/qhimdtransfer/qmdtrack.h +++ b/qhimdtransfer/qmdtrack.h @@ -49,6 +49,7 @@ public: virtual QString album() const; virtual QString codecname() const; virtual QTime duration() const; + QDateTime recdate() const; virtual bool copyprotected() const; virtual int blockcount() const; -- 1.8.4.msysgit.0 --------------080303090008090109070404-- From manner.moe@gmx.de Fri Dec 20 19:42:10 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vu51U-003tuO-Te>; Fri, 20 Dec 2013 19:42:09 +0100 Received: from mout.gmx.net ([212.227.17.22]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vu51U-000FKP-PB>; Fri, 20 Dec 2013 19:42:08 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0LwrS8-1VRSL90Y5w-016PVv for ; Fri, 20 Dec 2013 19:42:07 +0100 Message-ID: <52B48F66.1090600@gmx.de> Date: Fri, 20 Dec 2013 19:41:42 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> In-Reply-To: <52B0F78B.3040504@gmx.de> Content-Type: multipart/mixed; boundary="------------080706070706060809060308" X-Provags-ID: V03:K0:m26WLONRi31QNDOktGuxoziCvkLIx622J6g31SpAmxMXlxY2WpZ CO8jb6tdBy1F8x83euw6oMe7RcekAN5qHXBqDDoW73mpdR5aKDj8tc+Hk3Jgks6L4mM2FfI 8jommzhnWwGuHvxjsy3oLyI1Jm6U7l8BulcllnY8Zbj4JeR9y+uvsT7HT2+AwpwU5uTgIoe ehxUZ0ORIJ9mAe590TIEg== X-Originating-IP: 212.227.17.22 X-ZEDAT-Hint: A X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387564928-0000CD40-A3552EFE/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Gabun.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Dec 2013 18:42:10 -0000 This is a multi-part message in MIME format. --------------080706070706060809060308 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, i fixed a small bug in my last patch (netmd support for qhimdtransfer) to prevent trying to perform any action on a NULL pointer. Thomas --------------080706070706060809060308 Content-Type: text/x-patch; name="0009-including-netmd-support-into-the-gui-application-che.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0009-including-netmd-support-into-the-gui-application-che.pa"; filename*1="tch" >From c33076f38f20ad545c6a60c4b92ac5eb0fa9f2e4 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Fri, 20 Dec 2013 19:36:37 +0100 Subject: [PATCH 9/9] including netmd support into the gui application: check if pointer to device to be closed exists before performing any actions on it in QHiMDMainWindow::current_device_closed() function --- qhimdtransfer/qhimdmainwindow.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qhimdtransfer/qhimdmainwindow.cpp b/qhimdtransfer/qhimdmainwindow.cpp index 588f3d1..a5c6e40 100644 --- a/qhimdtransfer/qhimdmainwindow.cpp +++ b/qhimdtransfer/qhimdmainwindow.cpp @@ -96,7 +96,7 @@ void QHiMDMainWindow::open_device(QMDDevice * dev) int index = ui->himd_devices->currentIndex(); // remember current index of devices combo box, will be resetted by current_device_closed() function - if (dev == NULL) // "disconnected" selected by the user + if (dev == NULL) { current_device_closed(); return; @@ -309,7 +309,7 @@ void QHiMDMainWindow::on_himd_devices_activated(QString device) if (index == 0) // disconnected { - open_device(NULL); + current_device_closed(); return; } @@ -320,6 +320,10 @@ void QHiMDMainWindow::on_himd_devices_activated(QString device) void QHiMDMainWindow::current_device_closed() { int i; + + if(!current_device) + return; + QString browser = current_device->deviceType() == NETMD_DEVICE ? "netmd_browser" : "himd_browser"; QMDTracksModel * mod = (QMDTracksModel *)ui->TrackList->model(); -- 1.8.4.msysgit.0 --------------080706070706060809060308-- From glaubitz@physik.fu-berlin.de Fri Dec 20 21:55:01 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vu763-0000iJ-KO>; Fri, 20 Dec 2013 21:54:59 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1Vu763-000bMC-Ia>; Fri, 20 Dec 2013 21:54:59 +0100 Received: from g225048226.adsl.alicedsl.de ([92.225.48.226] helo=[192.168.1.20]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1Vu763-001WyB-FV>; Fri, 20 Dec 2013 21:54:59 +0100 Message-ID: <52B4AEA2.7040506@physik.fu-berlin.de> Date: Fri, 20 Dec 2013 21:54:58 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.1.1 MIME-Version: 1.0 To: Thomas Arp , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> In-Reply-To: <52B48F66.1090600@gmx.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.225.48.226 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387572899-0000CD40-43D1EBCA/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Botsuana.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Dec 2013 20:55:01 -0000 On 12/20/2013 07:41 PM, Thomas Arp wrote: > i fixed a small bug in my last patch (netmd support for qhimdtransfer) > to prevent trying to perform any action on a NULL pointer. Thanks! I will try to look over them during the weekend, I was too busy with work this week. In any case, we need to re-base your patches against the current version in github such that Howard's patch comes first, then your NetMD support batch as we'd otherwise mess up the commit and version history which is already part of the uploaded Debian package. Again, sorry for the mess. Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From manner.moe@gmx.de Sat Dec 21 17:35:42 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuPWa-002DuW-DZ>; Sat, 21 Dec 2013 17:35:36 +0100 Received: from mout.gmx.net ([212.227.17.22]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuPWa-003AMR-4o>; Sat, 21 Dec 2013 17:35:36 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx101) with ESMTPSA (Nemesis) id 0LsPwa-1VW37k37SS-0120yC for ; Sat, 21 Dec 2013 17:35:34 +0100 Message-ID: <52B5C351.8000801@gmx.de> Date: Sat, 21 Dec 2013 17:35:29 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: John Paul Adrian Glaubitz , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> In-Reply-To: <52B4AEA2.7040506@physik.fu-berlin.de> Content-Type: multipart/mixed; boundary="------------070108020707030208000908" X-Provags-ID: V03:K0:LJTZWw3vTiGmduyRfSZt/5IaDlC2gM0ENF0PUwW1A1n56jtS2gg tE1x5uU4D7LLXaSXhHA6jMYkN9ySlqSNCu+BSaM/ALLjTEokRbqblwqGBJEkLjTZV/xJIKW 5pQhSB8qtclUt2LwyGjA2pCuSXv/Khzk2VeeWuUuZFlYVupaFwVqm/xhXVfkW5ZzTdZyOry LmeDxAWV05R8XXqfvN3IQ== X-Originating-IP: 212.227.17.22 X-ZEDAT-Hint: A X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387643736-0000CD40-847B8288/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.100358, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,T_FRT_PROFILE1 X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Botsuana.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Dec 2013 16:35:42 -0000 This is a multi-part message in MIME format. --------------070108020707030208000908 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Am 20.12.2013 21:54, schrieb John Paul Adrian Glaubitz: > In any case, we need to re-base your patches against the current version > in github such that Howard's patch comes first, then your NetMD support > batch as we'd otherwise mess up the commit and version history which > is already part of the uploaded Debian package. > > Again, sorry for the mess. > > Adrian > O.K., here is my updated patch rebased against the current repo on github. Thomas --------------070108020707030208000908 Content-Type: text/x-patch; name="0001-netmd-support-implemented-new-class-QNetMDTrack-anal.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-netmd-support-implemented-new-class-QNetMDTrack-anal.pa"; filename*1="tch" >From 195e2642885594514acdfcf30b201377d9615e7e Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Sat, 21 Dec 2013 17:15:19 +0100 Subject: [PATCH 1/6] netmd support:implemented new class QNetMDTrack analogous to QHiMDTrack and put a base class QMDTrack over it holding common members --- qhimdtransfer/qmdtrack.cpp | 239 +++++++++++++++++++++++++++++++++++++++++++++ qhimdtransfer/qmdtrack.h | 92 +++++++++++++++++ 2 files changed, 331 insertions(+) create mode 100644 qhimdtransfer/qmdtrack.cpp create mode 100644 qhimdtransfer/qmdtrack.h diff --git a/qhimdtransfer/qmdtrack.cpp b/qhimdtransfer/qmdtrack.cpp new file mode 100644 index 0000000..3d6bf1f --- /dev/null +++ b/qhimdtransfer/qmdtrack.cpp @@ -0,0 +1,239 @@ +#include "qmdtrack.h" + +static QString get_himd_str(struct himd * himd, int idx) +{ + QString outstr; + char * str; + if(!idx) + return QString(); + str = himd_get_string_utf8(himd, idx, NULL, NULL); + if(!str) + return QString(); + + outstr = QString::fromUtf8(str); + himd_free(str); + return outstr; +} + +QHiMDTrack::QHiMDTrack(struct himd * himd, unsigned int trackindex) : himd(himd), trknum(trackindex) +{ + trackslot = himd_get_trackslot(himd, trackindex, NULL); + if(trackslot != 0) + if(himd_get_track_info(himd, trackslot, &ti, NULL) < 0) + trackslot = -1; +} + +QHiMDTrack::~QHiMDTrack() +{ + himd = NULL; +} + +unsigned int QHiMDTrack::tracknum() const +{ + return trknum; +} + +QString QHiMDTrack::title() const +{ + if(trackslot != 0) + return get_himd_str(himd, ti.title); + else + return QString(); +} + +QString QHiMDTrack::artist() const +{ + if(trackslot != 0) + return get_himd_str(himd, ti.artist); + else + return QString(); +} + +QString QHiMDTrack::album() const +{ + if(trackslot != 0) + return get_himd_str(himd, ti.album); + else + return QString(); +} + +QString QHiMDTrack::codecname() const +{ + if(trackslot != 0) + return himd_get_codec_name(&ti); + else + return QString(); +} + +QTime QHiMDTrack::duration() const +{ + QTime t(0,0,0); + if(trackslot != 0) + return t.addSecs(ti.seconds); + else + return QTime(); +} + +QDateTime QHiMDTrack::recdate() const +{ + QDate d(0,0,0); + QTime t(0,0,0); + if (trackslot != 0) + { + t.setHMS(ti.recordingtime.tm_hour, + ti.recordingtime.tm_min, + ti.recordingtime.tm_sec); + d.setDate(ti.recordingtime.tm_year+1900, + ti.recordingtime.tm_mon+1, + ti.recordingtime.tm_mday); + return QDateTime(d,t); + } + return QDateTime(); +} + +bool QHiMDTrack::copyprotected() const +{ + if(trackslot != 0) + return !himd_track_uploadable(himd, &ti); + return true; +} + +int QHiMDTrack::blockcount() const +{ + if(trackslot != 0) + return himd_track_blocks(himd, &ti, NULL); + else + return 0; +} + +QString QHiMDTrack::openMpegStream(struct himd_mp3stream * str) const +{ + struct himderrinfo status; + if(himd_mp3stream_open(himd, trackslot, str, &status) < 0) + return QString::fromUtf8(status.statusmsg); + return QString(); +} + +QString QHiMDTrack::openNonMpegStream(struct himd_nonmp3stream * str) const +{ + struct himderrinfo status; + if(himd_nonmp3stream_open(himd, trackslot, str, &status) < 0) + return QString::fromUtf8(status.statusmsg); + return QString(); +} + +QByteArray QHiMDTrack::makeEA3Header() const +{ + char header[EA3_FORMAT_HEADER_SIZE]; + make_ea3_format_header(header, &ti.codec_info); + return QByteArray(header,EA3_FORMAT_HEADER_SIZE); +} + + +QNetMDTrack::QNetMDTrack(netmd_dev_handle * deviceh, minidisc * my_md, int trackindex) +{ + uint8_t g; + struct netmd_pair const *bitrate; + char *name, buffer[256]; + + devh = deviceh; + md = my_md; + trkindex = trackindex; + + if(netmd_request_title(devh, trkindex, buffer, sizeof(buffer)) < 0) + { + trkindex = -1; + return; // no track with this trackindex + } + + /* Figure out which group this track is in */ + for( g = 1; g < md->group_count; g++ ) + { + if( (md->groups[g].start <= trkindex+1U) && (md->groups[g].finish >= trkindex+1U )) + { + groupstring = QString(md->groups[g].name); + break; + } + } + + netmd_request_track_time(devh, trkindex, &time); + netmd_request_track_flags(devh, trkindex, &flags); + netmd_request_track_bitrate(devh, trkindex, &bitrate_id, &channel); + + bitrate = find_pair(bitrate_id, bitrates); + + /* Skip 'LP:' prefix... the codec type shows up in the list anyway*/ + name = strncmp( buffer, "LP:", 3 ) ? buffer : buffer+3 ; + + titlestring = QString(name); + codecstring = QString(bitrate->name); + blocks = 0; +} + +QNetMDTrack::~QNetMDTrack() +{ + devh = NULL; + md = NULL; +} + +unsigned int QNetMDTrack::tracknum() const +{ + /* returns zero based track number, maybe this function should return a one based track number as shown in the treeview, + * trackindex -> zero based; tracknumber -> one based + */ + return trkindex; +} + +QString QNetMDTrack::group() const +{ + if(trkindex < 0) + return QString(); + + return groupstring; +} + +QString QNetMDTrack::title() const +{ + if(trkindex < 0) + return QString(); + + return titlestring; +} + +QString QNetMDTrack::codecname() const +{ + if(trkindex < 0) + return QString(); + + return codecstring; +} + +QTime QNetMDTrack::duration() const +{ + QTime t(0,0,0); + + if(trkindex < 0) + return QTime(); + + return t.addSecs( time.minute * 60 + time.second); +} + +bool QNetMDTrack::copyprotected() const +{ + switch(flags) + { + case 0x00 : return false; + case 0x03 : return true; + default : return true; // return true if unknown + } +} + +void QNetMDTrack::setBlocks(int cnt) +{ + blocks = cnt; +} + +int QNetMDTrack::blockcount() const +{ + return blocks; +} diff --git a/qhimdtransfer/qmdtrack.h b/qhimdtransfer/qmdtrack.h new file mode 100644 index 0000000..0ac7e43 --- /dev/null +++ b/qhimdtransfer/qmdtrack.h @@ -0,0 +1,92 @@ +#ifndef QMDTRACK_H +#define QMDTRACK_H + +#include +#include "himd.h" +#include "sony_oma.h" + +#ifdef Q_OS_WIN + #ifdef WINVER // WINVER needs to be 0x500 or later to make the windows autodetection mechanism work and it + #undef WINVER // must be defined correctly before including libusb.h (included from libnetmd.h), else it will be defined + #endif // in windef.h to 0x400 + #define WINVER 0x500 +#endif + +extern "C" { +#include +} + +/* define buffer size for netmd uploads */ +#define NETMD_RECV_BUF_SIZE 0x10000 + +class QMDTrack +{ +public: + QMDTrack() {} // returns dummy data, implemented to have a common class name with common members + virtual ~QMDTrack() {} + virtual unsigned int tracknum() const {return -1;} + virtual QString group() const {return QString();} + virtual QString title() const {return QString();} + virtual QString artist() const {return QString();} + virtual QString album() const {return QString();} + virtual QString codecname() const {return QString();} + virtual QTime duration() const {return QTime();} + virtual bool copyprotected() const {return true;} + virtual int blockcount() const {return 0;} +}; + +class QHiMDTrack : public QMDTrack{ + struct himd * himd; + unsigned int trknum; + unsigned int trackslot; + struct trackinfo ti; +public: + QHiMDTrack(struct himd * himd, unsigned int trackindex); + virtual ~QHiMDTrack(); + virtual unsigned int tracknum() const; + virtual QString title() const; + virtual QString artist() const; + virtual QString album() const; + virtual QString codecname() const; + virtual QTime duration() const; + QDateTime recdate() const; + virtual bool copyprotected() const; + virtual int blockcount() const; + + QString openMpegStream(struct himd_mp3stream * str) const; + QString openNonMpegStream(struct himd_nonmp3stream * str) const; + QByteArray makeEA3Header() const; +}; + +class QNetMDTrack : public QMDTrack { + netmd_dev_handle * devh; + minidisc * md; + int8_t trkindex; + struct netmd_track time; + unsigned char flags; + QString groupstring; + QString titlestring; + QString codecstring; +private: + int blocks; +public: + unsigned char bitrate_id; + unsigned char channel; + QNetMDTrack(netmd_dev_handle *deviceh, minidisc * my_md, int trackindex); + virtual ~QNetMDTrack(); + virtual unsigned int tracknum() const; + virtual QString group() const; + virtual QString title() const; + virtual QString codecname() const; + virtual QTime duration() const; + virtual bool copyprotected() const; + virtual void setBlocks(int cnt); + virtual int blockcount() const; +}; + +typedef QList QMDTrackList; +typedef QList QHiMDTrackList; +typedef QList QNetMDTrackList; +typedef QList QMDTrackIndexList; + +#endif // QMDTRACK_H -- 1.8.4.msysgit.0 --------------070108020707030208000908 Content-Type: text/x-patch; name="0002-netmd-support-implemented-new-class-QMDDevice-with-s.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename*0="0002-netmd-support-implemented-new-class-QMDDevice-with-s.pa"; filename*1="tch" >From 2beffbe7aabe137b23848d19521ec2103e834183 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Sat, 21 Dec 2013 17:19:50 +0100 Subject: [PATCH 2/6] netmd support: implemented new class QMDDevice with subclasses QNetMDDevice and QHiMDDevice holding information for each device and containing upload routines, also created additional libnetmd header file to get access to additional libnetmd functions --- libnetmd/libnetmd.pro | 3 +- libnetmd/libnetmd_extended.h | 37 +++ qhimdtransfer/qmddevice.cpp | 660 +++++++++++++++++++++++++++++++++++++++++++ qhimdtransfer/qmddevice.h | 101 +++++++ 4 files changed, 800 insertions(+), 1 deletion(-) create mode 100644 libnetmd/libnetmd_extended.h create mode 100644 qhimdtransfer/qmddevice.cpp create mode 100644 qhimdtransfer/qmddevice.h diff --git a/libnetmd/libnetmd.pro b/libnetmd/libnetmd.pro index eb6a402..3319d85 100644 --- a/libnetmd/libnetmd.pro +++ b/libnetmd/libnetmd.pro @@ -5,7 +5,8 @@ CONFIG += staticlib link_pkgconfig create_prl console debug_and_release_target DEFINES += G_DISABLE_DEPRECATED=1 PKGCONFIG += libusb-1.0 -HEADERS += common.h const.h error.h libnetmd.h log.h netmd_dev.h playercontrol.h secure.h trackinformation.h utils.h +HEADERS += common.h const.h error.h libnetmd.h log.h netmd_dev.h playercontrol.h secure.h trackinformation.h utils.h \ + libnetmd_extended.h SOURCES += common.c error.c libnetmd.c log.c netmd_dev.c playercontrol.c secure.c trackinformation.c utils.c LIBS += -lgcrypt diff --git a/libnetmd/libnetmd_extended.h b/libnetmd/libnetmd_extended.h new file mode 100644 index 0000000..1eb74db --- /dev/null +++ b/libnetmd/libnetmd_extended.h @@ -0,0 +1,37 @@ +/* + * include this header file to get access to additional libnetmd members + */ + +#include "libnetmd.h" + +typedef struct { + unsigned char content[255]; + size_t length; + size_t position; +} netmd_response; + +/* + * additional members from secure.c + */ + +void netmd_send_secure_msg(netmd_dev_handle *dev, unsigned char cmd, unsigned char *data, size_t data_size); +netmd_error netmd_recv_secure_msg(netmd_dev_handle *dev, unsigned char cmd, netmd_response *response, + unsigned char expected_response_code); +netmd_error netmd_secure_real_recv_track(netmd_dev_handle *dev, uint32_t length, FILE *file, size_t chunksize); +void netmd_write_aea_header(char *name, uint32_t frames, unsigned char channel, FILE* f); +void netmd_write_wav_header(unsigned char format, uint32_t bytes, FILE *f); + +/* + * additional members from utils.c + * XXX: do not include utils.h when using taglib, definition of min(a,b) is incomatible with definition of min(...) in taglib + */ +void netmd_check_response_bulk(netmd_response *response, const unsigned char* const expected, + const size_t expected_length, netmd_error *error); +void netmd_check_response_word(netmd_response *response, const uint16_t expected, + netmd_error *error); +void netmd_read_response_bulk(netmd_response *response, unsigned char* target, + const size_t length, netmd_error *error); +unsigned char *netmd_copy_word_to_buffer(unsigned char **buf, uint16_t value, int little_endian); +unsigned char netmd_read(netmd_response *response); +uint16_t netmd_read_word(netmd_response *response); +uint32_t netmd_read_doubleword(netmd_response *response); diff --git a/qhimdtransfer/qmddevice.cpp b/qhimdtransfer/qmddevice.cpp new file mode 100644 index 0000000..35e01a8 --- /dev/null +++ b/qhimdtransfer/qmddevice.cpp @@ -0,0 +1,660 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +/* common device members */ +QMDDevice::QMDDevice() : dev_type(NO_DEVICE) +{ +} + +QMDDevice::~QMDDevice() +{ + close(); +} + +enum device_type QMDDevice::deviceType() +{ + return dev_type; +} + +void QMDDevice::setPath(QString path) +{ + device_path = path; +} + +QString QMDDevice::path() +{ + return device_path; +} + +void QMDDevice::setName(QString name) +{ + recorder_name = name; +} + +QString QMDDevice::name() +{ + return recorder_name; +} + +void QMDDevice::setBusy(bool busy) +{ + is_busy = busy; +} + +bool QMDDevice::isBusy() +{ + return is_busy; +} + +void QMDDevice::setMdInserted(bool inserted) +{ + md_inserted = inserted; +} + +bool QMDDevice::mdInserted() +{ + return md_inserted; +} + +void QMDDevice::setDeviceHandle(void * devicehandle) +{ + devhandle = devicehandle; +} + +void * QMDDevice::deviceHandle() +{ + return devhandle; +} + +void QMDDevice::registerMdChange(void * regMdChange) +{ + mdChange = regMdChange; +} + +void * QMDDevice::MdChange() +{ + return mdChange; +} + +QStringList QMDDevice::downloadableFileExtensions() const +{ + if(dev_type == NETMD_DEVICE) + return QStringList() << "wav"; + + if(dev_type == HIMD_DEVICE) + return QStringList() << "mp3"; + + return QStringList(); +} + +void QMDDevice::checkfile(QString UploadDirectory, QString &filename, QString extension) +{ + QFile f; + QString newname; + int i = 2; + + f.setFileName(UploadDirectory + "/" + filename + extension); + while(f.exists()) + { + newname = filename + " (" + QString::number(i) + ")"; + f.setFileName(UploadDirectory + "/" + newname + extension); + i++; + } + if(!newname.isEmpty()) + filename = newname; +} + + +/* netmd device members */ +QNetMDDevice::QNetMDDevice() +{ + dev_type = NETMD_DEVICE; + devh = NULL; + netmd = NULL; + is_open = false; +} + +QNetMDDevice::~QNetMDDevice() +{ + close(); +} + +void QNetMDDevice::setUsbDevice(netmd_device * dev) +{ + netmd = dev; +} + +QString QNetMDDevice::open() +{ + uint8_t i = 0; + netmd_error error; + char buffer[256]; + + if(!netmd) + return tr("netmd_device not set, use setUsbDevice() function first"); + + if((error = netmd_open(netmd, &devh)) != NETMD_NO_ERROR) + return tr("Error opening netmd: %1").arg(netmd_strerror(error)); + + netmd_initialize_disc_info(devh, ¤t_md); + + /* generate track count first, needed by QNetMDTracksModel */ + while(netmd_request_title(devh, i, buffer, sizeof(buffer)) >= 0) + i++; + + trk_count = i; + + is_open = true; + md_inserted = true; + emit opened(); + return QString(); +} + +void QNetMDDevice::close() +{ + if(!devh) + return; + + netmd_clean_disc_info(¤t_md); + netmd_close(devh); + devh = NULL; + + is_open = false; + trk_count = 0; + md_inserted = false; + emit closed(); +} + +QString QNetMDDevice::discTitle() +{ + return QString(current_md.groups[0].name); +} + +QNetMDTrack QNetMDDevice::netmdTrack(unsigned int trkindex) +{ + minidisc * disc = ¤t_md; + + return QNetMDTrack(devh, disc, trkindex); +} + +QString QNetMDDevice::upload_track_blocks(uint32_t length, FILE *file, size_t chunksize) +{ + /* this is a copy of netmd_secure_real_recv_track(...) function, but updates upload dialog progress bar */ + uint32_t done = 0; + unsigned char *data; + int status; + netmd_error error = NETMD_NO_ERROR; + int transferred = 0; + + data = (unsigned char *)malloc(chunksize); + while (done < length) { + if ((length - done) < chunksize) { + chunksize = length - done; + } + + status = libusb_bulk_transfer((libusb_device_handle*)devh, 0x81, data, (int)chunksize, &transferred, 10000); + + if (status >= 0) { + done += transferred; + fwrite(data, transferred, 1, file); + netmd_log(NETMD_LOG_DEBUG, "%.1f%%\n", (double)done/(double)length * 100); + + uploadDialog.blockTransferred(); + QApplication::processEvents(); + /* do not check for uploadDialog.upload_canceled() here, netmd device will remain busy if track upload hasnīt finished */ + } + else if (status != -LIBUSB_ERROR_TIMEOUT) { + error = NETMD_USB_ERROR; + } + } + free(data); + + return (error != NETMD_NO_ERROR) ? netmd_strerror(error) : QString(); +} + +void QNetMDDevice::upload(unsigned int trackidx, QString path) +{ + /* this is a copy of netmd_secure_recv_track(...) function, we need single block transfer function to make use of a progress bar, + * maybe we can add/change something inside libnetmd for this + */ + QNetMDTrack track = netmdTrack(trackidx); + uint16_t track_id = trackidx; + unsigned char cmdhdr[] = {0x00, 0x10, 0x01}; + unsigned char cmd[sizeof(cmdhdr) + sizeof(track_id)] = { 0 }; + unsigned char *buf; + unsigned char codec; + uint32_t length; + netmd_response response; + netmd_error error; + QString filename, errmsg, filepath; + FILE * file = NULL; + + if(name() != "SONY MZ-RH1 (NetMD)") + { + errmsg = tr("upload disabled, %1 does not support netmd track uploads").arg(name()); + goto clean; + } + + if(track.copyprotected()) + { + errmsg = tr("upload disabled, Track is copy protected"); + goto clean; + } + + // create filename first + if(track.title().isEmpty()) + filename = tr("Track %1").arg(track.tracknum() + 1); + else + filename = track.title(); + + if(track.bitrate_id == NETMD_ENCODING_SP) { + checkfile(path, filename, ".aea"); + filepath = path + "/" + filename + ".aea"; + } + else { + checkfile(path, filename, ".wav"); + filepath = path + "/" + filename + ".wav"; + } + + if(!(file = fopen(filepath.toUtf8().data(), "wb"))) { + errmsg = tr("cannot open file %1 for writing").arg(filepath); + goto clean; + } + + buf = cmd; + memcpy(buf, cmdhdr, sizeof(cmdhdr)); + buf += sizeof(cmdhdr); + netmd_copy_word_to_buffer(&buf, trackidx + 1U, 0); + + netmd_send_secure_msg(devh, 0x30, cmd, sizeof(cmd)); + error = netmd_recv_secure_msg(devh, 0x30, &response, NETMD_STATUS_INTERIM); + netmd_check_response_bulk(&response, cmdhdr, sizeof(cmdhdr), &error); + netmd_check_response_word(&response, track_id + 1U, &error); + codec = netmd_read(&response); + length = netmd_read_doubleword(&response); + + /* initialize track.blockcount() here, needed by progress bar in the uploadDialog */ + track.setBlocks(length%NETMD_RECV_BUF_SIZE ? length / NETMD_RECV_BUF_SIZE + 1 : length / NETMD_RECV_BUF_SIZE); + uploadDialog.starttrack(track, filename); + if (track.bitrate_id == NETMD_ENCODING_SP) { + netmd_write_aea_header(track.title().toUtf8().data(), codec, track.channel, file); + } + else { + netmd_write_wav_header(codec, length, file); + } + + errmsg = upload_track_blocks(length, file, NETMD_RECV_BUF_SIZE); + if(!errmsg.isNull()) { + goto clean; + } + + error = netmd_recv_secure_msg(devh, 0x30, &response, NETMD_STATUS_ACCEPTED); + netmd_check_response_bulk(&response, cmdhdr, sizeof(cmdhdr), &error); + netmd_read_response_bulk(&response, NULL, 2, &error); + netmd_check_response_word(&response, 0, &error); + + if(error != NETMD_NO_ERROR) + errmsg = QString(netmd_strerror(error)); + +clean: + if(errmsg.isNull()) + uploadDialog.trackSucceeded(); + else + uploadDialog.trackFailed(errmsg); + + if(file) + fclose(file); + if(!errmsg.isNull()) + { + QFile f(filepath); + if(f.exists()) + f.remove(); + } +} + +void QNetMDDevice::batchUpload(QMDTrackIndexList tlist, QString path) +{ + int allblocks = 0; + + setBusy(true); + + /* progress bar for all tracks does not work yet, is there any way to get track length without recieving a complete track ? + * as far as iīve tested device remains busy if download procedure hasnīt finished. + * progressbar for all tracks shows idle mode if maximum value is set to 0 + */ + for(int i = 0;i < tlist.length(); i++) { + allblocks += netmdTrack(tlist.at(i)).blockcount(); + } + + uploadDialog.init(tlist.length(), allblocks); + + for(int i = 0; i < tlist.length(); i++) { + upload(tlist[i], path); + QApplication::processEvents(); + if(uploadDialog.upload_canceled()) + break; + } + + uploadDialog.finished(); + setBusy(false); +} + +/* himd device members */ + +QHiMDDevice::QHiMDDevice() +{ + dev_type = HIMD_DEVICE; + himd = NULL; + is_open = false; +} + +QHiMDDevice::~QHiMDDevice() +{ + close(); +} + +QString QHiMDDevice::open() +{ + struct himderrinfo status; + + if(!mdInserted()) + return tr("cannot open device, no disc"); + + if(himd) // first close himd if opened + { + himd_close(himd); + delete himd; + himd = NULL; + } + + himd = new struct himd; + if(himd_open(himd, device_path.toUtf8(), &status) < 0) + { + delete himd; + himd = NULL; + return QString::fromUtf8(status.statusmsg); + } + + trk_count = himd_track_count(himd); + is_open = true; + md_inserted = true; + emit opened(); + return QString(); +} + +void QHiMDDevice::close() +{ + if(!himd) + return; + + himd_close(himd); + delete himd; + himd = NULL; + + is_open = false; + trk_count = 0; + emit closed(); +} + +QHiMDTrack QHiMDDevice::himdTrack(unsigned int trkindex) +{ + return QHiMDTrack(himd, trkindex); +} + +QString QHiMDDevice::dumpmp3(const QHiMDTrack &trk, QString file) +{ + QString errmsg; + struct himd_mp3stream str; + struct himderrinfo status; + unsigned int len; + const unsigned char * data; + QFile f(file); + + if(!f.open(QIODevice::ReadWrite)) + { + return tr("Error opening file for MP3 output"); + } + if(!(errmsg = trk.openMpegStream(&str)).isNull()) + { + f.remove(); + return tr("Error opening track: ") + errmsg; + } + while(himd_mp3stream_read_block(&str, &data, &len, NULL, &status) >= 0) + { + if(f.write((const char*)data,len) == -1) + { + errmsg = tr("Error writing audio data"); + goto clean; + } + uploadDialog.blockTransferred(); + QApplication::processEvents(); + if(uploadDialog.upload_canceled()) + { + errmsg = tr("upload aborted by the user"); + goto clean; + } + + } + if(status.status != HIMD_STATUS_AUDIO_EOF) + errmsg = tr("Error reading audio data: ") + status.statusmsg; + +clean: + f.close(); + himd_mp3stream_close(&str); + if(!errmsg.isNull()) + f.remove(); + return errmsg; +} + +static inline TagLib::String QStringToTagString(const QString & s) +{ + return TagLib::String(s.toUtf8().data(), TagLib::String::UTF8); +} + +static void addid3tag(QString title, QString artist, QString album, QString file) +{ +#ifdef Q_OS_WIN + TagLib::FileRef f(file.toStdWString().c_str()); +#else + TagLib::FileRef f(file.toUtf8().data()); +#endif + TagLib::Tag *t = f.tag(); + t->setTitle(QStringToTagString(title)); + t->setArtist(QStringToTagString(artist)); + t->setAlbum(QStringToTagString(album)); + t->setComment("*** imported from HiMD via QHiMDTransfer ***"); + f.file()->save(); +} + +QString QHiMDDevice::dumpoma(const QHiMDTrack &track, QString file) +{ + QString errmsg; + struct himd_nonmp3stream str; + struct himderrinfo status; + unsigned int len; + const unsigned char * data; + QFile f(file); + + if(!f.open(QIODevice::ReadWrite)) + return tr("Error opening file for ATRAC output"); + + if(!(errmsg = track.openNonMpegStream(&str)).isNull()) + { + f.remove(); + return tr("Error opening track: ") + status.statusmsg; + } + + if(f.write(track.makeEA3Header()) == -1) + { + errmsg = tr("Error writing header"); + goto clean; + } + while(himd_nonmp3stream_read_block(&str, &data, &len, NULL, &status) >= 0) + { + if(f.write((const char*)data,len) == -1) + { + errmsg = tr("Error writing audio data"); + goto clean; + } + uploadDialog.blockTransferred(); + QApplication::processEvents(); + if(uploadDialog.upload_canceled()) + { + errmsg = QString("upload aborted by the user"); + goto clean; + } + } + if(status.status != HIMD_STATUS_AUDIO_EOF) + errmsg = QString("Error reading audio data: ") + status.statusmsg; + +clean: + f.close(); + himd_nonmp3stream_close(&str); + + if(!errmsg.isNull()) + f.remove(); + return errmsg; +} + +QString QHiMDDevice::dumppcm(const QHiMDTrack &track, QString file) +{ + struct himd_nonmp3stream str; + struct himderrinfo status; + unsigned int len, i; + int left, right; + int clipcount; + QString errmsg; + QFile f(file); + const unsigned char * data; + sox_format_t * out; + sox_sample_t soxbuf [HIMD_MAX_PCMFRAME_SAMPLES * 2]; + sox_signalinfo_t signal_out; + + signal_out.channels = 2; + signal_out.length = 0; + signal_out.precision = 16; + signal_out.rate = 44100; + + if(!(out = sox_open_write(file.toUtf8(), &signal_out, NULL, NULL, NULL, NULL))) + return tr("Error opening file for WAV output"); + + if(!(errmsg = track.openNonMpegStream(&str)).isNull()) + { + f.remove(); + return tr("Error opening track: ") + status.statusmsg; + } + + while(himd_nonmp3stream_read_block(&str, &data, &len, NULL, &status) >= 0) + { + + for(i = 0; i < len/4; i++) { + + left = data[i*4]*256+data[i*4+1]; + right = data[i*4+2]*256+data[i*4+3]; + if (left > 0x8000) left -= 0x10000; + if (right > 0x8000) right -= 0x10000; + + soxbuf[i*2] = SOX_SIGNED_16BIT_TO_SAMPLE(left, clipcount); + soxbuf[i*2+1] = SOX_SIGNED_16BIT_TO_SAMPLE(right, clipcount); + (void)clipcount; /* suppess "is unused" warning */ + } + + if (sox_write(out, soxbuf, len/2) != len/2) + { + errmsg = tr("Error writing audio data"); + goto clean; + } + uploadDialog.blockTransferred(); + QApplication::processEvents(); + if(uploadDialog.upload_canceled()) + { + errmsg = QString("upload aborted by the user"); + goto clean; + } + } + if(status.status != HIMD_STATUS_AUDIO_EOF) + errmsg = QString("Error reading audio data: ") + status.statusmsg; + +clean: + sox_close(out); + himd_nonmp3stream_close(&str); + + if(!errmsg.isNull()) + f.remove(); + return errmsg; +} + +void QHiMDDevice::upload(unsigned int trackidx, QString path) +{ + QString filename, errmsg; + QHiMDTrack track = himdTrack(trackidx); + QString title = track.title(); + + if(title.isNull()) + filename = tr("Track %1").arg(track.tracknum()+1); + else + filename = track.artist() + " - " + title; + + uploadDialog.starttrack(track, filename); + if (!track.copyprotected()) + { + QString codec = track.codecname(); + if (codec == "MPEG") + { + checkfile(path, filename, ".mp3"); + errmsg = dumpmp3 (track, path + "/" + filename + ".mp3"); + if(errmsg.isNull()) + addid3tag (track.title(),track.artist(),track.album(), path + "/" +filename + ".mp3"); + } + else if (codec == "LPCM") + { + checkfile(path, filename, ".wav"); + errmsg = dumppcm (track, path + "/" + filename + ".wav"); + } + else if (codec == "AT3+" || codec == "AT3 ") + { + checkfile(path, filename, ".oma"); + errmsg = dumpoma (track, path + "/" + filename + ".oma"); + } + } + else + errmsg = tr("upload disabled because of DRM encryption"); + + if(errmsg.isNull()) + uploadDialog.trackSucceeded(); + else + uploadDialog.trackFailed(errmsg); + +} + +void QHiMDDevice::batchUpload(QMDTrackIndexList tlist, QString path) +{ + int allblocks = 0; + + setBusy(true); + + for(int i = 0;i < tlist.length(); i++) + allblocks += himdTrack(tlist.at(i)).blockcount(); + + uploadDialog.init(tlist.length(), allblocks); + + for(int i = 0; i < tlist.length(); i++) { + upload(tlist[i], path); + QApplication::processEvents(); + if(uploadDialog.upload_canceled()) + break; + } + + uploadDialog.finished(); + setBusy(false); +} diff --git a/qhimdtransfer/qmddevice.h b/qhimdtransfer/qmddevice.h new file mode 100644 index 0000000..c413f9c --- /dev/null +++ b/qhimdtransfer/qmddevice.h @@ -0,0 +1,101 @@ +#ifndef QMDDEVICE_H +#define QMDDEVICE_H + +#include +#include + +#include +#include "qhimduploaddialog.h" + +enum device_type { + NO_DEVICE, + NETMD_DEVICE, + HIMD_DEVICE +}; + +class QMDDevice : public QObject { + Q_OBJECT + Q_DISABLE_COPY(QMDDevice) + + QString recorder_name; + bool is_busy; +protected: + QString device_path; + enum device_type dev_type; + bool is_open; + unsigned int trk_count; + bool md_inserted; + void * devhandle; + void * mdChange; + QHiMDUploadDialog uploadDialog; +public: + explicit QMDDevice(); + virtual ~QMDDevice(); + virtual enum device_type deviceType(); + virtual void setPath(QString path); + virtual QString path(); + virtual void setName(QString name); + virtual QString name(); + virtual void setBusy(bool busy); + virtual bool isBusy(); + virtual QString open() {return QString();} + virtual void close() {} + virtual bool isOpen() {return is_open;} + virtual QString discTitle() {return QString();} + virtual void setMdInserted(bool inserted); + virtual bool mdInserted(); + virtual void setDeviceHandle(void * devicehandle); + virtual void * deviceHandle(); + virtual void registerMdChange(void * regMdChange); + virtual void * MdChange(); + virtual QMDTrack track(unsigned int trkindex) {return QMDTrack();} + virtual int trackCount() {return trk_count;} + virtual QStringList downloadableFileExtensions() const; + virtual void checkfile(QString UploadDirectory, QString &filename, QString extension); + virtual void batchUpload(QMDTrackIndexList tlist, QString path) {} + virtual void upload(unsigned int trackidx, QString path) {} + +signals: + void opened(); + void closed(); +}; + +class QNetMDDevice : public QMDDevice { + + netmd_device * netmd; + netmd_dev_handle * devh; + minidisc current_md; +private: + QString upload_track_blocks(uint32_t length, FILE *file, size_t chunksize); +public: + explicit QNetMDDevice(); + virtual ~QNetMDDevice(); + virtual void setUsbDevice(netmd_device * dev); + virtual QString open(); + virtual void close(); + virtual QString discTitle(); + virtual QNetMDTrack netmdTrack(unsigned int trkindex); + virtual void batchUpload(QMDTrackIndexList tlist, QString path); + virtual void upload(unsigned int trackidx, QString path); + +}; + +class QHiMDDevice : public QMDDevice { + + struct himd * himd; +private: + QString dumpmp3(const QHiMDTrack &trk, QString file); + QString dumpoma(const QHiMDTrack & track, QString file); + QString dumppcm(const QHiMDTrack &track, QString file); +public: + explicit QHiMDDevice(); + virtual ~QHiMDDevice(); + virtual QString open(); + virtual void close(); + virtual QHiMDTrack himdTrack(unsigned int trkindex); + virtual void upload(unsigned int trackidx, QString path); + virtual void batchUpload(QMDTrackIndexList tlist, QString path); + +}; + +#endif // QMDDEVICE_H -- 1.8.4.msysgit.0 --------------070108020707030208000908 Content-Type: text/x-patch; name="0003-netmd-support-implemented-new-class-QNetMDTracksMode.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0003-netmd-support-implemented-new-class-QNetMDTracksMode.pa"; filename*1="tch" >From 28f0773211065848aff6e36c5473b8d1c0ed024a Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Sat, 21 Dec 2013 17:23:11 +0100 Subject: [PATCH 3/6] netmd support: implemented new class QNetMDTracksModel analogous to QHiMDTracksModel, renamed qhimdmodel.h/.cpp to qmdmodel.h/.cpp, QHiMDTrack class is already moved to qmdtrack.h/.cpp --- qhimdtransfer/qmdmodel.cpp | 373 +++++++++++++++++++++++++++++++++++++++++++++ qhimdtransfer/qmdmodel.h | 79 ++++++++++ 2 files changed, 452 insertions(+) create mode 100644 qhimdtransfer/qmdmodel.cpp create mode 100644 qhimdtransfer/qmdmodel.h diff --git a/qhimdtransfer/qmdmodel.cpp b/qhimdtransfer/qmdmodel.cpp new file mode 100644 index 0000000..2a3c4e7 --- /dev/null +++ b/qhimdtransfer/qmdmodel.cpp @@ -0,0 +1,373 @@ +#include +#include +#include + +enum hcolumnum { + ColId, ColTitle, ColArtist, ColAlbum, ColLength, ColCodec, ColUploadable, ColRecDate, + LAST_hcolumnnum = ColRecDate +}; + +enum ncolumnum { + CoId, CoGroup, CoTitle, CoLength, CoCodec, CoUploadable, + LAST_ncolumnnum = CoUploadable +}; + + +/* netmd tracks model */ +QVariant QNetMDTracksModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if(orientation != Qt::Horizontal) + return QVariant(); + + if(role == Qt::SizeHintRole) + { + static QFont f; + static QFontMetrics met(f); + switch((ncolumnum)section) + { + case CoId: + return QSize(met.width("9999")+5, 0); + case CoGroup: + case CoTitle: + case CoLength: + return QSize(met.width("9:99:99"), 0); + case CoCodec: + case CoUploadable: + /* Really use the header for the metric in these columns, + contents will be shorter */ + return QAbstractListModel::headerData(section,orientation,role); + } + } + + if(role == Qt::DisplayRole) + { + switch((ncolumnum)section) + { + case CoId: + return tr("Nr."); + case CoGroup: + return tr("Group"); + case CoTitle: + return tr("Title"); + case CoLength: + return tr("Length"); + case CoCodec: + return tr("Format"); + case CoUploadable: + return tr("Uploadable"); + } + } + return QVariant(); +} + +QVariant QNetMDTracksModel::data(const QModelIndex & index, int role) const +{ + if(role == Qt::TextAlignmentRole && + (index.column() == CoId || index.column() == CoLength)) + return Qt::AlignRight; + + if(index.row() >= rowCount()) + return QVariant(); + + QNetMDTrack track = allTracks[index.row()]; + + if(role == Qt::CheckStateRole && index.column() == CoUploadable) + return ((ndev->name() != "SONY MZ-RH1 (NetMD)") || track.copyprotected()) ? Qt::Unchecked : Qt::Checked; + + if(role == Qt::DisplayRole) + { + switch((ncolumnum)index.column()) + { + case CoId: + return track.tracknum() + 1; + case CoGroup: + return track.group(); + case CoTitle: + return track.title(); + case CoLength: + { + QTime t = track.duration(); + if(t < QTime(1,0,0)) + return t.toString("m:ss"); + else + return t.toString("h:mm:ss"); + } + case CoCodec: + return track.codecname(); + case CoUploadable: + return QVariant(); /* Displayed by checkbox */ + } + } + return QVariant(); +} + +int QNetMDTracksModel::rowCount(const QModelIndex &) const +{ + if(ndev == NULL) + return 0; + + return ndev->trackCount(); +} + +int QNetMDTracksModel::columnCount(const QModelIndex &) const +{ + return LAST_ncolumnnum+1; +} + +QString QNetMDTracksModel::open(QMDDevice * device) +{ + int i = 0; + QString ret = "error opening net device"; + + beginResetModel(); + if(ndev != NULL) + close(); + + if(device->deviceType() == NETMD_DEVICE) + { + ndev = static_cast(device); + ret = ndev->open(); + } + + if(!ret.isEmpty()) + close(); + + /* fetch track info for all tracks first, getting track info inside data() function is very slow */ + for(; i < ndev->trackCount(); i++) + allTracks.append(ndev->netmdTrack(i)); + + endResetModel(); /* inform views that the model contents changed */ + return ret; +} + +bool QNetMDTracksModel::is_open() +{ + return ndev->isOpen(); +} + +void QNetMDTracksModel::close() +{ + beginResetModel(); + + if(ndev != NULL && ndev->isOpen()) + ndev->close(); + + ndev = NULL; + + allTracks.clear(); + endResetModel(); /* inform views that the model contents changed */ +} + +QNetMDTrack QNetMDTracksModel::track(int trkidx) const +{ + return ndev->netmdTrack(trkidx); +} + +QNetMDTrackList QNetMDTracksModel::tracks(const QModelIndexList & modelindices) const +{ + QNetMDTrackList tracks; + QModelIndex index; + + foreach(index, modelindices) + tracks.append(ndev->netmdTrack(index.row())); + return tracks; +} + +QStringList QNetMDTracksModel::downloadableFileExtensions() const +{ + return ndev->downloadableFileExtensions(); +} + + +/* himd tracks model */ + +QVariant QHiMDTracksModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if(orientation != Qt::Horizontal) + return QVariant(); + + if(role == Qt::SizeHintRole) + { + static QFont f; + static QFontMetrics met(f); + switch((hcolumnum)section) + { + case ColId: + return QSize(met.width("9999")+5, 0); + case ColTitle: + case ColArtist: + case ColAlbum: + return QSize(25*met.averageCharWidth(), 0); + case ColLength: + return QSize(met.width("9:99:99"), 0); + case ColCodec: + case ColUploadable: + /* Really use the header for the metric in these columns, + contents will be shorter */ + return QAbstractListModel::headerData(section,orientation,role); + case ColRecDate: + return QSize(met.width("yyyy.MM.dd hh:mm:ss"), 0); + } + } + + if(role == Qt::DisplayRole) + { + switch((hcolumnum)section) + { + case ColId: + return tr("Nr."); + case ColTitle: + return tr("Title"); + case ColArtist: + return tr("Artist"); + case ColAlbum: + return tr("Album"); + case ColLength: + return tr("Length"); + case ColCodec: + return tr("Format"); + case ColUploadable: + return tr("Uploadable"); + case ColRecDate: + return tr("Recorded At"); + } + } + return QVariant(); +} + +QVariant QHiMDTracksModel::data(const QModelIndex & index, int role) const +{ + if(role == Qt::TextAlignmentRole && + (index.column() == ColId || index.column() == ColLength)) + return Qt::AlignRight; + + if(index.row() >= rowCount()) + return QVariant(); + + QHiMDTrack track = hdev->himdTrack(index.row()); + + if(role == Qt::CheckStateRole && index.column() == ColUploadable) + return track.copyprotected() ? Qt::Unchecked : Qt::Checked; + + if(role == Qt::DisplayRole) + { + switch((hcolumnum)index.column()) + { + case ColId: + return index.row() + 1; + case ColTitle: + return track.title(); + case ColArtist: + return track.artist(); + case ColAlbum: + return track.album(); + case ColLength: + { + QTime t = track.duration(); + if(t < QTime(1,0,0)) + return t.toString("m:ss"); + else + return t.toString("h:mm:ss"); + } + case ColCodec: + return track.codecname(); + case ColUploadable: + return QVariant(); /* Displayed by checkbox */ + case ColRecDate: + { + QDateTime dt = track.recdate(); + return dt.toString("yyyy.MM.dd hh:mm:ss"); + } + } + } + return QVariant(); +} + +int QHiMDTracksModel::rowCount(const QModelIndex &) const +{ + if(hdev == NULL) + return 0; + + return hdev->trackCount(); +} + +int QHiMDTracksModel::columnCount(const QModelIndex &) const +{ + return LAST_hcolumnnum+1; +} + +QString QHiMDTracksModel::open(QMDDevice * device) +{ + QString ret = "error opening himd device"; + + beginResetModel(); + if(hdev != NULL) + close(); + + if(device->deviceType() == HIMD_DEVICE) + { + hdev = static_cast(device); + ret = hdev->open(); + } + + if(!ret.isEmpty()) + close(); + + endResetModel(); /* inform views that the model contents changed */ + return ret; +} + +bool QHiMDTracksModel::is_open() +{ + return hdev->isOpen(); +} + +void QHiMDTracksModel::close() +{ + beginResetModel(); + + if(hdev != NULL && hdev->isOpen()) + hdev->close(); + + hdev = NULL; + + endResetModel(); /* inform views that the model contents changed */ +} + +QHiMDTrack QHiMDTracksModel::track(int trknum) const +{ + return hdev->himdTrack(trknum); +} + +QHiMDTrackList QHiMDTracksModel::tracks(const QModelIndexList & modelindices) const +{ + QHiMDTrackList tracks; + QModelIndex index; + + foreach(index, modelindices) + tracks.append(hdev->himdTrack(index.row())); + return tracks; +} + +QStringList QHiMDTracksModel::downloadableFileExtensions() const +{ + return hdev->downloadableFileExtensions(); +} + + +/* QFileSystemModel stuff */ + +Qt::ItemFlags QHiMDFileSystemModel::flags(const QModelIndex &index) const +{ + if(!isDir(index) && !selectableExtensions.contains((fileInfo(index).suffix()), Qt::CaseInsensitive)) + return Qt::NoItemFlags; //not selectable, not enabled (grayed out in the browser) + + return QFileSystemModel::flags(index); +} + +void QHiMDFileSystemModel::setSelectableExtensions(QStringList extensions) +{ + beginResetModel(); + selectableExtensions = extensions; + endResetModel(); +} diff --git a/qhimdtransfer/qmdmodel.h b/qhimdtransfer/qmdmodel.h new file mode 100644 index 0000000..bb8b0b8 --- /dev/null +++ b/qhimdtransfer/qmdmodel.h @@ -0,0 +1,79 @@ +#ifndef QMDMODEL_H +#define QMDMODEL_H + +#include + +#include +#include +#include +#include + +class QMDTracksModel : public QAbstractListModel { + Q_OBJECT + + QMDDevice * dev; +public: + QMDTracksModel() : dev(NULL) {} + /* QAbstractListModel stuff */ + virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const {return QVariant();} + virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const {return QVariant();} + virtual int rowCount(const QModelIndex & parent = QModelIndex() ) const {return 0;} + virtual int columnCount(const QModelIndex & parent = QModelIndex() ) const {return 0;} + /* dummy data for unknown devices */ + virtual QString open(QMDDevice *device = NULL) {return tr("no known device type specified");} + virtual bool is_open() {return false;} + virtual void close() {} + QStringList downloadableFileExtensions() const {return QStringList();} +}; + +class QNetMDTracksModel : public QMDTracksModel { + Q_OBJECT + + QNetMDDevice * ndev; + QNetMDTrackList allTracks; +public: + QNetMDTracksModel() {ndev = NULL;} + /* QAbstractListModel stuff */ + virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + virtual int rowCount(const QModelIndex & parent = QModelIndex() ) const; + virtual int columnCount(const QModelIndex & parent = QModelIndex() ) const; + /* NetMD device stuff */ + QString open(QMDDevice *device); /* returns null if OK, error message otherwise */ + virtual bool is_open(); + void close(); + QNetMDTrack track(int trkidx) const; + virtual QNetMDTrackList tracks(const QModelIndexList & indices) const; // should be QMDTrackList later + QStringList downloadableFileExtensions() const; +}; + +class QHiMDTracksModel : public QMDTracksModel { + Q_OBJECT + + QHiMDDevice * hdev; +public: + QHiMDTracksModel() {hdev = NULL;} + /* QAbstractListModel stuff */ + virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + virtual int rowCount(const QModelIndex & parent = QModelIndex() ) const; + virtual int columnCount(const QModelIndex & parent = QModelIndex() ) const; + /* HiMD containter stuff */ + virtual QString open(QMDDevice *device); /* returns null if OK, error message otherwise */ + virtual bool is_open(); + virtual void close(); + virtual QHiMDTrack track(int trackidx) const; + virtual QHiMDTrackList tracks(const QModelIndexList & indices) const; // should be QMDTrackList later + QStringList downloadableFileExtensions() const; +}; + +class QHiMDFileSystemModel : public QFileSystemModel { + Q_OBJECT + + QStringList selectableExtensions; +public: + virtual Qt::ItemFlags flags(const QModelIndex &index) const; + void setSelectableExtensions(QStringList extensions); +}; + +#endif // QMDMODEL_H -- 1.8.4.msysgit.0 --------------070108020707030208000908 Content-Type: text/x-patch; name="0004-netmd-support-implemented-netmd-autodetection-at-app.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0004-netmd-support-implemented-netmd-autodetection-at-app.pa"; filename*1="tch" >From ae8c5310f5a61655eca134df44d803f6df940765 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Sat, 21 Dec 2013 17:25:51 +0100 Subject: [PATCH 4/6] netmd support: implemented netmd autodetection at application start, also implemented netmd autodetection during application runtime using the new QMDDevice classes --- libnetmd/use_libnetmd.prl | 2 +- qhimdtransfer/qhimddetection.cpp | 258 ++++++++++++++++++++++++++++++++---- qhimdtransfer/qhimddetection.h | 105 ++++++++++----- qhimdtransfer/qhimdwindetection.cpp | 198 +++++++++++++++++---------- 4 files changed, 434 insertions(+), 129 deletions(-) diff --git a/libnetmd/use_libnetmd.prl b/libnetmd/use_libnetmd.prl index d9019f2..a3c72e0 100644 --- a/libnetmd/use_libnetmd.prl +++ b/libnetmd/use_libnetmd.prl @@ -11,7 +11,7 @@ build_pass:CONFIG(release,debug|release) { LIBS += -L../libnetmd/release } -# fallback if libhimd was not compiled with +# fallback if libnetmd was not compiled with # CONFIG += debug_and_release debug_and_release_target # while I force debug_and_release_target, it is ignored in a # just-one-kind build without debug_and_release diff --git a/qhimdtransfer/qhimddetection.cpp b/qhimdtransfer/qhimddetection.cpp index d563587..e73dc03 100644 --- a/qhimdtransfer/qhimddetection.cpp +++ b/qhimdtransfer/qhimddetection.cpp @@ -1,73 +1,275 @@ #include #include "qhimddetection.h" +void QHiMDDetection::clearDeviceList() +{ + QMDDevice * mddev; + QNetMDDevice * nmddev; + int i = 0; + + while( i < dlist.count() ) + { + mddev = dlist.at(i); + if(mddev->deviceType() == NETMD_DEVICE) + { + nmddev = static_cast(mddev); + if(nmddev->isOpen()) + nmddev->close(); + delete nmddev; + nmddev = NULL; + dlist.removeAt(i); + continue; + } + else if(mddev->deviceType() == HIMD_DEVICE) + { + remove_himddevice(mddev->path()); // uses platform dependent function if available + continue; + } + } + + if(!dlist.isEmpty()) + dlist.clear(); + emit deviceListChanged(dlist); +} + QHiMDDetection::QHiMDDetection(QObject *parent) : QObject(parent) { } -himd_device *QHiMDDetection::find_by_path(QString path) +QHiMDDetection::~QHiMDDetection() { - for (int i = 0; i < device_list.size(); i++) - if(device_list.at(i)->path == path) - return device_list.at(i); + clearDeviceList(); + cleanup_netmd_list(); +} - return NULL; +void QHiMDDetection::cleanup_netmd_list() +{ + if(dev_list != NULL) + netmd_clean(&dev_list); } -// slots +void QHiMDDetection::rescan_netmd_devices() +{ + QNetMDDevice * dev; + int i = 0; + + // find and remove netmd devices + while(i < dlist.count()) + { + if(dlist.at(i)->deviceType() != NETMD_DEVICE) + { + i++; + continue; + } + dev = static_cast(dlist.at(i)); + if(dev->isOpen()) + dev->close(); + + delete dev; + dev = NULL; + dlist.removeAt(i); + } + + netmd_clean(&dev_list); + dev_list = NULL; -void QHiMDDetection::himd_busy(QString path) + emit deviceListChanged(dlist); + scan_for_netmd_devices(); +} + +void QHiMDDetection::scan_for_minidisc_devices() +{ + /* create device entry for disc images first */ + QHiMDDevice * mddev = new QHiMDDevice(); + mddev->setMdInserted(true); + mddev->setName("disc image"); + dlist.append(mddev); + emit deviceListChanged(dlist); + + scan_for_himd_devices(); + scan_for_netmd_devices(); +} + +void QHiMDDetection::remove_himddevice(QString path) { - himd_device * dev = find_by_path(path); - if (!dev) + QHiMDDevice * dev = static_cast(find_by_path(path)); + int i = dlist.indexOf(find_by_path(path)); + + if(i < 0) return; - dev->is_busy = true; - qDebug() << "himd device at " + dev->path + " : device busy, starting transfer"; + if(dev->isOpen()) + dev->close(); + delete dev; + dev = NULL; + + dlist.removeAt(i); } -void QHiMDDetection::himd_idle(QString path) +void QHiMDDetection::scan_for_netmd_devices() { - himd_device * dev = find_by_path(path); - if (!dev) + netmd_device * md; + netmd_error error = netmd_init(&dev_list); + struct libusb_device_descriptor desc; + QNetMDDevice * mddev; + + if (error != NETMD_NO_ERROR) return; - dev->is_busy = false; - qDebug() << "himd device at " + dev->path + " : device idle, transfer complete"; + md = dev_list; // pick first device + + while( md != NULL) { + libusb_get_device_descriptor(md->usb_dev, &desc); + mddev = new QNetMDDevice(); + mddev->setName(identify_usb_device(desc.idVendor, desc.idProduct)); + mddev->setUsbDevice(md); + dlist.append(mddev); + emit deviceListChanged(dlist); + md = md->link; // pick next device + } +} + +QMDDevice *QHiMDDetection::find_by_path(QString path) +{ + QMDDevice * mddev; + + foreach(mddev, dlist) + { + if(mddev->path() == path) + return mddev; + } + return NULL; +} + +QMDDevice *QHiMDDetection::find_by_name(QString name) +{ + QMDDevice * mddev; + + foreach(mddev, dlist) + { + if(mddev->name() == name) + return mddev; + } + return NULL; } const char * identify_usb_device(int vid, int pid) { + if(vid == SHARP) + { + switch(pid) + { + case IM_MT880H: + return "SHARP IM-MT880H / IM-MT899H (NetMD)"; + case IM_DR400: + return "SHARP IM-DR400 / IM-DR410 (NetMD)"; + case IM_DR80: + return "SHARP IM-DR80 / IM-DR420/ IM-DR580 or KENWOOD DMC-S9NET (NetMD)"; + } + } + if (vid != SONY) return NULL; switch (pid) { - case MZ_NH1: + case MZ_NH1_HIMD: return "SONY MZ-NH1"; - case MZ_NH3D: + case MZ_NH3D_HIMD: return "SONY MZ-NH3D"; - case MZ_NH900: + case MZ_NH900_HIMD: return "SONY MZ-NH900"; - case MZ_NH700: + case MZ_NH700_HIMD: return "SONY MZ-NH700 / MZ-NH800"; - case MZ_NH600: + case MZ_NH600_HIMD: return "SONY MZ-NH600(D)"; - case LAM_3: + case LAM_3_HIMD: return "SONY LAM-3"; - case MZ_DH10P: + case MZ_DH10P_HIMD: return "SONY MZ-DH10P"; - case MZ_RH10: + case MZ_RH10_HIMD: return "SONY MZ-RH10"; - case MZ_RH910: + case MZ_RH910_HIMD: return "SONY MZ-RH910"; - case CMT_AH10: + case CMT_AH10_HIMD: return "SONY CMT-AH10"; - case DS_HMD1: + case DS_HMD1_HIMD: return "SONY DS-HMD1"; - case MZ_RH1: + case MZ_RH1_HIMD: return "SONY MZ-RH1"; + case PCLK_XX: + return "SONY PCLK-XX (NetMD)"; + case UNKNOWN_A: + return "SONY (unknown model, NetMD)"; + case MZ_N1: + return "SONY MZ-N1 (NetMD)"; + case UNKNOWN_B: + return "SONY (unknown model, NetMD)"; + case LAM_1: + return "Sony LAM-1 (NetMD)"; + case MDS_JE780: + return "SONY MDS-JE780 / MDS-JE980 (NetMD)"; + case MZ_N505: + return "SONY MZ-N505 (NetMD)"; + case MZ_S1: + return "SONY MZ-S1 (NetMD)"; + case MZ_N707: + return "SONY MZ-N707 (NetMD)"; + case CMT_C7NT: + return "SONY CMT-C7NT (NetMD)"; + case PCGA_MDN1: + return "SONY PCGA-MDN1 (NetMD)"; + case CMT_L7HD: + return "SONY CMT-L7HD (NetMD)"; + case MZ_N10: + return "SONY MZ-N10 (NetMD)"; + case MZ_N910: + return "SONY MZ-N910 (NetMD)"; + case MZ_N710: + return "SONY MZ-N710 / MZ-NE810 / MZ-NF810 (NetMD)"; + case MZ_N510: + return "SONY MZ-N510 (NetMD)"; + case MZ_NE410: + return "SONY MZ-NE410 / MZ-DN430 / MZ-NF520 (NetMD)"; + case MZ_NE810: + return "SONY MZ-NE810 / MZ-NE910 (NetMD)"; + case CMT_M333NT: + return "SONY CMT-M333NT / CMT_M373NT (NetMD)"; + case LAM_10: + return "SONY LAM-10 (NetMD)"; + case AIWA_AM_NX1: + return "AIWA AM-NX1 (NetMD)"; + case AIWA_AM_NX9: + return "AIWA AM-NX9 (NetMD)"; + case MZ_NH1: + return "SONY MZ-NH1 (NetMD)"; + case MZ_NH3D: + return "SONY MZ-NH3D (NetMD)"; + case MZ_NH900: + return "SONY MZ-NH900 (NetMD)"; + case MZ_NH700: + return "SONY MZ-NH700 / MZ-NH800 (NetMD)"; + case MZ_NH600: + return "SONY MZ-NH600 / MZ-NH600D (NetMD)"; + case MZ_N920: + return "SONY MZ-N920 (NetMD)"; + case LAM_3: + return "SONY LAM-3 (NetMD)"; + case MZ_DH10P: + return "SONY MZ-DH10P (NetMD)"; + case MZ_RH10: + return "SONY MZ-RH10 (NetMD)"; + case MZ_RH910: + return "SONY MZ-RH910 (NetMD)"; + case CMT_AH10_A: + return "SONY CMT-AH10 (NetMD)"; + case CMT_AH10_B: + return "SONY CMT-AH10 (NetMD)"; + case DS_HMD1: + return "SONY DS-HMD1 (NetMD)"; + case MZ_RH1: + return "SONY MZ-RH1 (NetMD)"; } return NULL; } diff --git a/qhimdtransfer/qhimddetection.h b/qhimdtransfer/qhimddetection.h index 5c30be9..4a5915a 100644 --- a/qhimdtransfer/qhimddetection.h +++ b/qhimdtransfer/qhimddetection.h @@ -4,50 +4,95 @@ #include #include #include +#include -#define SONY 0x054c //known himd-mode product IDs -#define MZ_NH1 0x017f -#define MZ_NH3D 0x0181 -#define MZ_NH900 0x0183 -#define MZ_NH700 0x0185 -#define MZ_NH600 0x0187 -#define LAM_3 0x018a -#define MZ_DH10P 0x01ea -#define MZ_RH10 0x021a -#define MZ_RH910 0x021c -#define CMT_AH10 0x022d -#define DS_HMD1 0x023d -#define MZ_RH1 0x0287 - -struct himd_device { - bool is_busy; - QString path; - bool md_inserted; - QString recorder_name; - virtual ~himd_device(){} /* for polymorphic delete */ - }; +// known vendor IDs +#define SONY 0x054c +#define SHARP 0x4dd + +// known himd-mode product IDs +#define MZ_NH1_HIMD 0x017f +#define MZ_NH3D_HIMD 0x0181 +#define MZ_NH900_HIMD 0x0183 +#define MZ_NH700_HIMD 0x0185 +#define MZ_NH600_HIMD 0x0187 +#define LAM_3_HIMD 0x018b +#define MZ_DH10P_HIMD 0x01ea +#define MZ_RH10_HIMD 0x021a +#define MZ_RH910_HIMD 0x021c +#define CMT_AH10_HIMD 0x022d +#define DS_HMD1_HIMD 0x023d +#define MZ_RH1_HIMD 0x0287 + +// known Sony/Aiwa netmd-mode product IDs +#define PCLK_XX 0x34 +#define UNKNOWN_A 0x36 +#define MZ_N1 0x75 +#define UNKNOWN_B 0x7c +#define LAM_1 0x80 +#define MDS_JE780 0x81 // or MDS-JE980 +#define MZ_N505 0x84 +#define MZ_S1 0x85 +#define MZ_N707 0x86 +#define CMT_C7NT 0x8e +#define PCGA_MDN1 0x97 +#define CMT_L7HD 0xad +#define MZ_N10 0xc6 +#define MZ_N910 0xc7 +#define MZ_N710 0xc8 // or MZ-NE810/NF810 +#define MZ_N510 0xc9 // or MZ-NF610 +#define MZ_NE410 0xca // or MZ-DN430/NF520 +#define MZ_NE810 0xeb // or MZ-NE910 +#define CMT_M333NT 0xe7 // or CMT-M373NT +#define LAM_10 0x101 +#define AIWA_AM_NX1 0x113 +#define AIWA_AM_NX9 0x14c +#define MZ_NH1 0x17e +#define MZ_NH3D 0x180 +#define MZ_NH900 0x182 +#define MZ_NH700 0x184 // or MZ-NH800 +#define MZ_NH600 0x186 // or MZ-NH600D +#define MZ_N920 0x188 +#define LAM_3 0x18a +#define MZ_DH10P 0x1e9 +#define MZ_RH10 0x219 +#define MZ_RH910 0x21b +#define CMT_AH10_A 0x21d +#define CMT_AH10_B 0x22c +#define DS_HMD1 0x23c +#define MZ_RH1 0x286 + +// known Sharp netmd-mode product IDs +#define IM_MT880H 0x7202 // or IM-MT899H +#define IM_DR400 0x9013 // or IM-DR410 +#define IM_DR80 0x9014 // or IM-DR420/DR580 / Kenwood DMC-S9NET const char * identify_usb_device(int vid, int pid); +typedef QList QMDDevicePtrList; + class QHiMDDetection : public QObject { Q_OBJECT Q_DISABLE_COPY(QHiMDDetection) protected: - QList device_list; + QMDDevicePtrList dlist; + netmd_device * dev_list; public: explicit QHiMDDetection(QObject *parent = 0); - virtual ~QHiMDDetection() {} + virtual ~QHiMDDetection(); + virtual void clearDeviceList(); + virtual void cleanup_netmd_list(); + void rescan_netmd_devices(); + void scan_for_minidisc_devices(); virtual void scan_for_himd_devices(){} - himd_device *find_by_path(QString path); - -protected slots: - virtual void himd_busy(QString path); - virtual void himd_idle(QString path); + virtual void remove_himddevice(QString path); + void scan_for_netmd_devices(); + QMDDevice *find_by_path(QString path); + QMDDevice *find_by_name(QString name); signals: - void himd_found(QString path); - void himd_removed(QString path); + void deviceListChanged(QMDDevicePtrList list); }; QHiMDDetection * createDetection(QObject * parent = NULL); diff --git a/qhimdtransfer/qhimdwindetection.cpp b/qhimdtransfer/qhimdwindetection.cpp index 3e79038..f5a9d0c 100644 --- a/qhimdtransfer/qhimdwindetection.cpp +++ b/qhimdtransfer/qhimdwindetection.cpp @@ -3,8 +3,6 @@ #include #include "qhimddetection.h" -#define WINVER 0x0500 - #include #include #include @@ -12,17 +10,15 @@ #include // needed for handling storage devices #include // needed for CM_Get_Child function -struct win_himd_device : himd_device { - HANDLE devhandle; - HDEVNOTIFY himdChange; - }; - static const GUID my_GUID_IO_MEDIA_ARRIVAL = {0xd07433c0, 0xa98e, 0x11d2, {0x91, 0x7a, 0x00, 0xa0, 0xc9, 0x06, 0x8f, 0xf3} }; static const GUID my_GUID_IO_MEDIA_REMOVAL = {0xd07433c1, 0xa98e, 0x11d2, {0x91, 0x7a, 0x00, 0xa0, 0xc9, 0x06, 0x8f, 0xf3} }; +static const GUID my_GUID_DEVINTERFACE_USB_DEVICE = + {0xa5dcbf10, 0x6530, 0x11d2, {0x90, 0x1f, 0x00, 0xc0,0x4f, 0xb9, 0x51, 0xed} }; + static const int my_DBT_CUSTOMEVENT = 0x8006; @@ -37,18 +33,19 @@ public: void scan_for_himd_devices(); QHiMDWinDetection(QObject * parent = NULL); ~QHiMDWinDetection(); - win_himd_device *find_by_path(QString path); private: HDEVNOTIFY hDevNotify; - win_himd_device *find_by_handle(HANDLE devhandle); - win_himd_device *win_dev_at(int idx); + HDEVNOTIFY listen_usbdev; + QMDDevice *find_by_handle(HANDLE devhandle); void add_himddevice(QString path, QString name); - void remove_himddevice(QString path); + virtual void remove_himddevice(QString path); void add_himd(HANDLE devhandle); void remove_himd(HANDLE devhandle); HDEVNOTIFY register_mediaChange(HANDLE devhandle); void unregister_mediaChange(HDEVNOTIFY himd_change); + HDEVNOTIFY register_usbDeviceNotification(); + void unregister_usbDeviceNotification(); bool nativeEvent(const QByteArray & eventType, void * message, long *result); bool winEvent(MSG * msg, long * result); }; @@ -64,12 +61,16 @@ QHiMDWinDetection::QHiMDWinDetection(QObject * parent) { // ask for Window ID to have Qt create the window. (void)winId(); + // register for usb device notifications + if((listen_usbdev = register_usbDeviceNotification()) == NULL) + qDebug() << "cannot register usb device notifications" << endl; } QHiMDWinDetection::~QHiMDWinDetection() { - while (!device_list.isEmpty()) - remove_himddevice(device_list.at(0)->path); + unregister_usbDeviceNotification(); + clearDeviceList(); + cleanup_netmd_list(); } void QHiMDWinDetection::scan_for_himd_devices() @@ -97,21 +98,17 @@ void QHiMDWinDetection::scan_for_himd_devices() return; } -win_himd_device *QHiMDWinDetection::win_dev_at(int idx) +QMDDevice *QHiMDWinDetection::find_by_handle(HANDLE devhandle) { - return static_cast(device_list.at(idx)); -} - -win_himd_device *QHiMDWinDetection::find_by_path(QString path) -{ - return static_cast(QHiMDDetection::find_by_path(path)); -} + QMDDevice *mddev; -win_himd_device *QHiMDWinDetection::find_by_handle(HANDLE devhandle) -{ - for (int i = 0; i < device_list.size(); i++) - if(win_dev_at(i)->devhandle == devhandle) - return win_dev_at(i); + foreach(mddev, dlist) + { + if(mddev->deviceType() != HIMD_DEVICE) + continue; + if(mddev->deviceHandle() == devhandle) + return mddev; + } return NULL; } @@ -192,13 +189,13 @@ void QHiMDWinDetection::add_himddevice(QString path, QString name) if (find_by_path(path)) return; - win_himd_device * new_device = new win_himd_device; + QHiMDDevice * new_device = new QHiMDDevice(); int k; char drv[] = "\\\\.\\X:"; QByteArray device = "\\\\.\\PHYSICALDRIVE"; char file[] = "X:\\HI-MD.IND"; DWORD retbytes; - HANDLE hdev; + HANDLE hdev, dev; STORAGE_DEVICE_NUMBER sdn; OFSTRUCT OFfile; @@ -214,81 +211,84 @@ void QHiMDWinDetection::add_himddevice(QString path, QString name) if(k != 0) device.append(QString::number(sdn.DeviceNumber)); - new_device->devhandle = CreateFileA(device.data(), NULL , FILE_SHARE_READ, NULL, + dev = CreateFileA(device.data(), NULL , FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if(new_device->devhandle == INVALID_HANDLE_VALUE) + if(dev == INVALID_HANDLE_VALUE) return; - new_device->himdChange = register_mediaChange(new_device->devhandle); - new_device->is_busy = false; - new_device->path = path; - new_device->recorder_name = name; + new_device->setDeviceHandle(dev); + new_device->registerMdChange(register_mediaChange(new_device->deviceHandle())); + new_device->setBusy(false); + new_device->setPath(path); + new_device->setName(name); file[0] = path.at(0).toLatin1(); if(OpenFile(file, &OFfile, OF_EXIST) != HFILE_ERROR) - { - new_device->md_inserted = true; - emit himd_found(new_device->path); - qDebug() << "himd device at " + new_device->path + " added (" + new_device->recorder_name + ")"; - } + new_device->setMdInserted(true); else - { - qDebug() << "himd device at " + new_device->path + " added (" + new_device->recorder_name + ")" + " ; without MD"; - new_device->md_inserted = false; - } + new_device->setMdInserted(false); - device_list.append(new_device); + dlist.append(new_device); + emit deviceListChanged(dlist); return; - } void QHiMDWinDetection::remove_himddevice(QString path) { - win_himd_device * dev = find_by_path(path); + int index = -1; + QHiMDDevice * dev = static_cast(find_by_path(path)); + if (!dev) return; - unregister_mediaChange(dev->himdChange); - - if (dev->devhandle != NULL) - CloseHandle(dev->devhandle); + index = dlist.indexOf(dev); - emit himd_removed(dev->path); + if(dev->isOpen()) + dev->close(); - qDebug() << "himd device at " + dev->path + " removed (" + dev->recorder_name + ")"; + if(dev->name() != "disc image") + { + if(dev->MdChange() != NULL) + unregister_mediaChange((HDEVNOTIFY)dev->MdChange()); + if(dev->deviceHandle() != NULL) + CloseHandle(dev->deviceHandle()); + } - device_list.removeAll(dev); delete dev; + dev = NULL; + + dlist.removeAt(index); + + emit deviceListChanged(dlist); } void QHiMDWinDetection::add_himd(HANDLE devhandle) { - win_himd_device * dev = find_by_handle(devhandle); + QMDDevice * dev = find_by_handle(devhandle); if (!dev) return; - if(!dev->md_inserted) - { - dev->md_inserted = true; - emit himd_found(dev->path); - qDebug() << "himd device at " + dev->path + " : md inserted"; - } + if(!dev->mdInserted()) + dev->setMdInserted(true); + + if(!dev->isOpen()) + dev->open(); + return; } void QHiMDWinDetection::remove_himd(HANDLE devhandle) { - win_himd_device * dev = find_by_handle(devhandle); + QMDDevice * dev = find_by_handle(devhandle); if (!dev) return; - if(dev->md_inserted) - { - dev->md_inserted = false; - emit himd_removed(dev->path); - qDebug() << "himd device at " + dev->path + " : md removed"; - } + if(dev->isOpen()) + dev->close(); + + dev->setMdInserted(false); + return; } @@ -312,6 +312,26 @@ void QHiMDWinDetection::unregister_mediaChange(HDEVNOTIFY himd_change) UnregisterDeviceNotification(himd_change); } +HDEVNOTIFY QHiMDWinDetection::register_usbDeviceNotification() +{ + DEV_BROADCAST_DEVICEINTERFACE filter; + + ZeroMemory(&filter, sizeof(filter)); + filter.dbcc_size = sizeof(filter); + filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; + filter.dbcc_reserved = 0; + filter.dbcc_classguid = my_GUID_DEVINTERFACE_USB_DEVICE; + + return RegisterDeviceNotification( (HWND)this->winId(), &filter, DEVICE_NOTIFY_WINDOW_HANDLE); + +} + +void QHiMDWinDetection::unregister_usbDeviceNotification() +{ + if(listen_usbdev != NULL) + UnregisterDeviceNotification(listen_usbdev); +} + bool QHiMDWinDetection::nativeEvent(const QByteArray & eventType, void * message, long *result) { if (eventType == "windows_generic_MSG") @@ -344,6 +364,17 @@ bool QHiMDWinDetection::winEvent(MSG * msg, long * result) } } } + else if(pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) + { + PDEV_BROADCAST_DEVICEINTERFACE pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)pHdr; + devID = QString::fromWCharArray(pDevInf->dbcc_name).toUpper(); + /* only handle netmd devices, himd devices will be handled by DBT_DEVTYP_VOLUME */ + if(identified(devID, name) && name.contains("NetMD)")) + { + qDebug() << name << " detected, rescanning netmd devices" << endl; + rescan_netmd_devices(); + } + } break; } case DBT_DEVICEREMOVECOMPLETE : @@ -355,6 +386,16 @@ bool QHiMDWinDetection::winEvent(MSG * msg, long * result) qDebug() << "Message:DBT_DEVICEREMOVECOMPLETE for drive " + path; remove_himddevice(path); } + else if(pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) + { + PDEV_BROADCAST_DEVICEINTERFACE pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)pHdr; + devID = QString::fromWCharArray(pDevInf->dbcc_name).toUpper(); + if(identified(devID, name) && name.contains("NetMD)")) + { + qDebug() << name << " removed, rescanning netmd devices" << endl; + rescan_netmd_devices(); + } + } break; } case DBT_DEVICEQUERYREMOVE : @@ -362,13 +403,13 @@ bool QHiMDWinDetection::winEvent(MSG * msg, long * result) if(pHdr->dbch_devicetype & DBT_DEVTYP_HANDLE) { PDEV_BROADCAST_HANDLE pHdrh = (PDEV_BROADCAST_HANDLE)pHdr; - win_himd_device *dev = find_by_handle(pHdrh->dbch_handle); + QMDDevice *dev = find_by_handle(pHdrh->dbch_handle); if(!dev) { qDebug() << "Message:DBT_DEVICEQUERYREMOVE for unknown device " << pHdrh->dbch_handle; break; } - if(dev->is_busy) + if(dev->isBusy()) { *result = BROADCAST_QUERY_DENY; qDebug() << "Message:DBT_DEVICEQUERYREMOVE for drive " + path + " denied: transfer in progress"; @@ -377,7 +418,24 @@ bool QHiMDWinDetection::winEvent(MSG * msg, long * result) else { qDebug() << "Message:DBT_DEVICEQUERYREMOVE requested"; - remove_himddevice(dev->path); + remove_himddevice(dev->path()); + } + } + else if(pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) + { + PDEV_BROADCAST_DEVICEINTERFACE pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)pHdr; + devID = QString::fromWCharArray(pDevInf->dbcc_name).toUpper(); + if(identified(devID, name) && name.contains("NetMD)")) + { + QMDDevice * dev = find_by_name(name); + if(!dev) + break; + if(dev->isBusy()) + { + *result = BROADCAST_QUERY_DENY; + return true; + } + dev->close(); } } break; -- 1.8.4.msysgit.0 --------------070108020707030208000908 Content-Type: text/x-patch; name="0005-netmd-support-changed-qhimduploaddialog-to-make-it-u.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename*0="0005-netmd-support-changed-qhimduploaddialog-to-make-it-u.pa"; filename*1="tch" >From 4ca19aebe23aed1a4e1026f1264ffe0c3f204e85 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Sat, 21 Dec 2013 17:26:56 +0100 Subject: [PATCH 5/6] netmd support: changed qhimduploaddialog to make it usable for netmd and himd devices --- qhimdtransfer/qhimduploaddialog.cpp | 10 +++++++++- qhimdtransfer/qhimduploaddialog.h | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/qhimdtransfer/qhimduploaddialog.cpp b/qhimdtransfer/qhimduploaddialog.cpp index acff6a7..390848e 100644 --- a/qhimdtransfer/qhimduploaddialog.cpp +++ b/qhimdtransfer/qhimduploaddialog.cpp @@ -34,6 +34,14 @@ void QHiMDUploadDialog::finished() /* Prevent shrinking of the box when hiding the indicators */ m_ui->current->setMinimumSize(m_ui->current->size()); m_ui->TrkPBar->hide(); + /* set AllPBar to 100% if it is not used during transfer, + * current netmd uploads doesnÂīt set the range correctly + */ + if(m_ui->AllPBar->maximum() == 0) + { + m_ui->AllPBar->setMaximum(1); + m_ui->AllPBar->setValue(1); + } m_ui->curtrack_label->hide(); m_ui->cancel_button->hide(); @@ -42,7 +50,7 @@ void QHiMDUploadDialog::finished() return; } -void QHiMDUploadDialog::starttrack(const QHiMDTrack & trk, const QString & title) +void QHiMDUploadDialog::starttrack(const QMDTrack & trk, const QString & title) { tracknum = trk.tracknum() + 1; m_ui->curtrack_label->setText(tr("current track: %1 - %2").arg(tracknum).arg(title)); diff --git a/qhimdtransfer/qhimduploaddialog.h b/qhimdtransfer/qhimduploaddialog.h index 157c58d..621fffd 100644 --- a/qhimdtransfer/qhimduploaddialog.h +++ b/qhimdtransfer/qhimduploaddialog.h @@ -2,7 +2,7 @@ #define QHIMDUPLOADDIALOG_H #include -#include "qhimdmodel.h" +#include "qmdtrack.h" namespace Ui { class QHiMDUploadDialog; @@ -17,7 +17,7 @@ public: bool upload_canceled() { return canceled; } void init(int trackcount, int totalblocks); - void starttrack(const QHiMDTrack & trk, const QString & title); + void starttrack(const QMDTrack & trk, const QString & title); void blockTransferred(); void trackFailed(const QString & errmsg); void trackSucceeded(); -- 1.8.4.msysgit.0 --------------070108020707030208000908 Content-Type: text/x-patch; name="0006-netmd-support-changed-qhimdmainwindow-to-use-the-new.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0006-netmd-support-changed-qhimdmainwindow-to-use-the-new.pa"; filename*1="tch" >From d4f29483c31b0a857fc7c52ad355676962b4a06f Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Sat, 21 Dec 2013 17:28:48 +0100 Subject: [PATCH 6/6] netmd support: changed qhimdmainwindow to use the new classes/device structure , removed upload routines which are already moved to other classes, updated qhimdtransfer.pro file --- qhimdtransfer/qhimdmainwindow.cpp | 482 ++++++++++---------------------------- qhimdtransfer/qhimdmainwindow.h | 30 +-- qhimdtransfer/qhimdmainwindow.ui | 18 +- qhimdtransfer/qhimdtransfer.pro | 13 +- 4 files changed, 161 insertions(+), 382 deletions(-) diff --git a/qhimdtransfer/qhimdmainwindow.cpp b/qhimdtransfer/qhimdmainwindow.cpp index 1b86651..d5031b2 100644 --- a/qhimdtransfer/qhimdmainwindow.cpp +++ b/qhimdtransfer/qhimdmainwindow.cpp @@ -1,213 +1,9 @@ #include "qhimdmainwindow.h" #include "ui_qhimdmainwindow.h" #include "qhimdaboutdialog.h" -#include "qhimduploaddialog.h" #include #include -#include - - -QString QHiMDMainWindow::dumpmp3(const QHiMDTrack & trk, QString file) -{ - QString errmsg; - struct himd_mp3stream str; - struct himderrinfo status; - unsigned int len; - const unsigned char * data; - QFile f(file); - - if(!f.open(QIODevice::ReadWrite)) - { - return tr("Error opening file for MP3 output"); - } - if(!(errmsg = trk.openMpegStream(&str)).isNull()) - { - f.remove(); - return tr("Error opening track: ") + errmsg; - } - while(himd_mp3stream_read_block(&str, &data, &len, NULL, &status) >= 0) - { - if(f.write((const char*)data,len) == -1) - { - errmsg = tr("Error writing audio data"); - goto clean; - } - uploadDialog->blockTransferred(); - QApplication::processEvents(); - if(uploadDialog->upload_canceled()) - { - errmsg = tr("upload aborted by the user"); - goto clean; - } - - } - if(status.status != HIMD_STATUS_AUDIO_EOF) - errmsg = tr("Error reading audio data: ") + status.statusmsg; - -clean: - f.close(); - himd_mp3stream_close(&str); - if(!errmsg.isNull()) - f.remove(); - return errmsg; -} - -static inline TagLib::String QStringToTagString(const QString & s) -{ - return TagLib::String(s.toUtf8().data(), TagLib::String::UTF8); -} - -static void addid3tag(QString title, QString artist, QString album, QString file) -{ -#ifdef Q_OS_WIN - TagLib::FileRef f(file.toStdWString().c_str()); -#else - TagLib::FileRef f(file.toUtf8().data()); -#endif - TagLib::Tag *t = f.tag(); - t->setTitle(QStringToTagString(title)); - t->setArtist(QStringToTagString(artist)); - t->setAlbum(QStringToTagString(album)); - t->setComment("*** imported from HiMD via QHiMDTransfer ***"); - f.file()->save(); -} - -QString QHiMDMainWindow::dumpoma(const QHiMDTrack & track, QString file) -{ - QString errmsg; - struct himd_nonmp3stream str; - struct himderrinfo status; - unsigned int len; - const unsigned char * data; - QFile f(file); - - if(!f.open(QIODevice::ReadWrite)) - return tr("Error opening file for ATRAC output"); - - if(!(errmsg = track.openNonMpegStream(&str)).isNull()) - { - f.remove(); - return tr("Error opening track: ") + status.statusmsg; - } - - if(f.write(track.makeEA3Header()) == -1) - { - errmsg = tr("Error writing header"); - goto clean; - } - while(himd_nonmp3stream_read_block(&str, &data, &len, NULL, &status) >= 0) - { - if(f.write((const char*)data,len) == -1) - { - errmsg = tr("Error writing audio data"); - goto clean; - } - uploadDialog->blockTransferred(); - QApplication::processEvents(); - if(uploadDialog->upload_canceled()) - { - errmsg = QString("upload aborted by the user"); - goto clean; - } - } - if(status.status != HIMD_STATUS_AUDIO_EOF) - errmsg = QString("Error reading audio data: ") + status.statusmsg; - -clean: - f.close(); - himd_nonmp3stream_close(&str); - - if(!errmsg.isNull()) - f.remove(); - return errmsg; -} - -QString QHiMDMainWindow::dumppcm(const QHiMDTrack & track, QString file) -{ - struct himd_nonmp3stream str; - struct himderrinfo status; - unsigned int len, i; - int left, right; - int clipcount; - QString errmsg; - QFile f(file); - const unsigned char * data; - sox_format_t * out; - sox_sample_t soxbuf [HIMD_MAX_PCMFRAME_SAMPLES * 2]; - sox_signalinfo_t signal_out; - - signal_out.channels = 2; - signal_out.length = 0; - signal_out.precision = 16; - signal_out.rate = 44100; - - if(!(out = sox_open_write(file.toUtf8(), &signal_out, NULL, NULL, NULL, NULL))) - return tr("Error opening file for WAV output"); - - if(!(errmsg = track.openNonMpegStream(&str)).isNull()) - { - f.remove(); - return tr("Error opening track: ") + status.statusmsg; - } - - while(himd_nonmp3stream_read_block(&str, &data, &len, NULL, &status) >= 0) - { - - for(i = 0; i < len/4; i++) { - - left = data[i*4]*256+data[i*4+1]; - right = data[i*4+2]*256+data[i*4+3]; - if (left > 0x8000) left -= 0x10000; - if (right > 0x8000) right -= 0x10000; - - soxbuf[i*2] = SOX_SIGNED_16BIT_TO_SAMPLE(left, clipcount); - soxbuf[i*2+1] = SOX_SIGNED_16BIT_TO_SAMPLE(right, clipcount); - (void)clipcount; /* suppess "is unused" warning */ - } - - if (sox_write(out, soxbuf, len/2) != len/2) - { - errmsg = tr("Error writing audio data"); - goto clean; - } - uploadDialog->blockTransferred(); - QApplication::processEvents(); - if(uploadDialog->upload_canceled()) - { - errmsg = QString("upload aborted by the user"); - goto clean; - } - } - if(status.status != HIMD_STATUS_AUDIO_EOF) - errmsg = QString("Error reading audio data: ") + status.statusmsg; - -clean: - sox_close(out); - himd_nonmp3stream_close(&str); - - if(!errmsg.isNull()) - f.remove(); - return errmsg; -} - -void QHiMDMainWindow::checkfile(QString UploadDirectory, QString &filename, QString extension) -{ - QFile f; - QString newname; - int i = 2; - - f.setFileName(UploadDirectory + "/" + filename + extension); - while(f.exists()) - { - newname = filename + " (" + QString::number(i) + ")"; - f.setFileName(UploadDirectory + "/" + newname + extension); - i++; - } - if(!newname.isEmpty()) - filename = newname; -} - void QHiMDMainWindow::set_buttons_enable(bool connect, bool download, bool upload, bool rename, bool del, bool format, bool quit) { ui->action_Connect->setEnabled(connect); @@ -221,23 +17,29 @@ void QHiMDMainWindow::set_buttons_enable(bool connect, bool download, bool uploa ui->download_button->setEnabled(download); } -void QHiMDMainWindow::init_himd_browser() +void QHiMDMainWindow::init_himd_browser(QMDTracksModel * model) { - int i = 0; + int i, width; + QString browser = current_device->deviceType() == NETMD_DEVICE ? "netmd_browser" : "himd_browser"; + ui->TrackList->setModel(model); - ui->TrackList->setModel(&trackmodel); - for(;i < trackmodel.columnCount(); i++) - ui->TrackList->resizeColumnToContents(i); QObject::connect(ui->TrackList->selectionModel(), SIGNAL(selectionChanged (const QItemSelection &, const QItemSelection &)), this, SLOT(handle_himd_selection_change(const QItemSelection&, const QItemSelection&))); + + // read saved column width for this model + for(i = 0; i < ui->TrackList->model()->columnCount(); i++) + { + width = settings.value(browser + QString::number(i), 0).toInt(); + if(width != 0) + ui->TrackList->setColumnWidth(i, width); + } } void QHiMDMainWindow::init_local_browser() { QStringList DownloadFileList; localmodel.setFilter(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); - localmodel.setNameFilters(QStringList() << "*.mp3" << "*.wav" << "*.oma"); - localmodel.setSelectableExtensions(trackmodel.downloadableFileExtensions()); + localmodel.setNameFilters(QStringList() << "*.mp3" << "*.wav" << "*.oma" << "*.aea"); localmodel.setNameFilterDisables(false); localmodel.setReadOnly(false); localmodel.setRootPath("/"); @@ -255,130 +57,93 @@ void QHiMDMainWindow::init_local_browser() void QHiMDMainWindow::save_window_settings() { - int i = 0; - settings.setValue("geometry", QMainWindow::saveGeometry()); settings.setValue("windowState", QMainWindow::saveState()); - for(;i < trackmodel.columnCount(); i++) - settings.setValue("himd_browser" + QString::number(i), ui->TrackList->columnWidth(i)); } void QHiMDMainWindow::read_window_settings() { - int i = 0; - int width; - QMainWindow::restoreGeometry(settings.value("geometry").toByteArray()); QMainWindow::restoreState(settings.value("windowState").toByteArray()); - for(; i < trackmodel.columnCount(); i++) - { - width = settings.value("himd_browser" + QString::number(i), 0).toInt(); - if(width != 0) - ui->TrackList->setColumnWidth(i, width); - } } bool QHiMDMainWindow::autodetect_init() { - int k; + if(!QObject::connect(detect, SIGNAL(deviceListChanged(QMDDevicePtrList)), this, SLOT(device_list_changed(QMDDevicePtrList)))) + return false; - k = (bool)QObject::connect(detect, SIGNAL(himd_found(QString)), this, SLOT(himd_found(QString))); - k += (bool)QObject::connect(detect, SIGNAL(himd_removed(QString)), this, SLOT(himd_removed(QString))); + detect->scan_for_minidisc_devices(); + return true; +} - if(!k) - return false; +void QHiMDMainWindow::setCurrentDevice(QMDDevice *dev) +{ + current_device = dev; + QObject::connect(current_device, SIGNAL(closed()), this, SLOT(current_device_closed())); - QObject::connect(this, SIGNAL(himd_busy(QString)), detect, SLOT(himd_busy(QString))); - QObject::connect(this, SIGNAL(himd_idle(QString)), detect, SLOT(himd_idle(QString))); + if(current_device->deviceType() == NETMD_DEVICE) + init_himd_browser(&ntmodel); - detect->scan_for_himd_devices(); - return true; + else if(current_device->deviceType() == HIMD_DEVICE) + init_himd_browser(&htmodel); } -void QHiMDMainWindow::open_himd_at(const QString & path) +void QHiMDMainWindow::open_device(QMDDevice * dev) { - QMessageBox himdStatus; + QMessageBox mdStatus; QString error; + QMDTracksModel * mod; - error = trackmodel.open(path.toLatin1()); + int index = ui->himd_devices->currentIndex(); // remember current index of devices combo box, will be resetted by current_device_closed() function + + if (!dev) + { + current_device_closed(); + ui->himd_devices->setCurrentIndex(0); + return; + } - if (!error.isNull()) { - himdStatus.setText(tr("Error opening HiMD data. Make sure you chose the proper root directory of your HiMD-Walkman.\n") + error); - himdStatus.exec(); + if(current_device) + { + current_device_closed(); + ui->himd_devices->setCurrentIndex(index); // set correct device index in the combo box + } + + if(dev->deviceType() == HIMD_DEVICE && dev->path().isEmpty()) + { + mdStatus.setText(tr("Error opening himd device/disc image , no device path given\nPlease use connect button to set the path to the himd device/disc image")); + mdStatus.exec(); set_buttons_enable(1,0,0,0,0,0,1); + ui->himd_devices->setCurrentIndex(0); return; } - ui->himdpath->setText(path); - settings.setValue("lastHiMDDirectory", path); + setCurrentDevice(dev); + mod = (QMDTracksModel *)ui->TrackList->model(); + error = mod->open(dev); - himd_device * dev = detect->find_by_path(path); - if(dev) - ui->statusBar->showMessage(dev->recorder_name); - else - ui->statusBar->clearMessage(); + if (!error.isEmpty()) + { + mdStatus.setText(tr("Error opening minidisc device (") + current_device->name() + "):\n" + error); + mdStatus.exec(); + set_buttons_enable(1,0,0,0,0,0,1); + ui->himd_devices->setCurrentIndex(0); + return; + } + localmodel.setSelectableExtensions(mod->downloadableFileExtensions()); + ui->DiscTitle->setText(current_device->discTitle()); set_buttons_enable(1,0,0,1,1,1,1); } void QHiMDMainWindow::upload_to(const QString & UploadDirectory) { - emit himd_busy(ui->himdpath->text()); - - QHiMDTrackList tracks = trackmodel.tracks(ui->TrackList->selectionModel()->selectedRows(0)); - - int allblocks = 0; - for(int i = 0;i < tracks.length(); i++) - allblocks += tracks[i].blockcount(); - - uploadDialog->init(tracks.length(), allblocks); - - for(int i = 0;i < tracks.length(); i++) - { - QString filename, errmsg; - QString title = tracks[i].title(); - if(title.isNull()) - filename = tr("Track %1").arg(tracks[i].tracknum()+1); - else - filename = tracks[i].artist() + " - " + title; - - uploadDialog->starttrack(tracks[i], filename); - if (!tracks[i].copyprotected()) - { - QString codec = tracks[i].codecname(); - if (codec == "MPEG") - { - checkfile(UploadDirectory, filename, ".mp3"); - errmsg = dumpmp3 (tracks[i], UploadDirectory + "/" + filename + ".mp3"); - if(errmsg.isNull()) - addid3tag (tracks[i].title(),tracks[i].artist(),tracks[i].album(), UploadDirectory+ "/" +filename + ".mp3"); - } - else if (codec == "LPCM") - { - checkfile(UploadDirectory, filename, ".wav"); - errmsg = dumppcm (tracks[i], UploadDirectory + "/" + filename + ".wav"); - } - else if (codec == "AT3+" || codec == "AT3 ") - { - checkfile(UploadDirectory, filename, ".oma"); - errmsg = dumpoma (tracks[i], UploadDirectory + "/" + filename + ".oma"); - } - } - else - errmsg = tr("upload disabled because of DRM encryption"); + QMDTrackIndexList tlist; - if(errmsg.isNull()) - uploadDialog->trackSucceeded(); - else - uploadDialog->trackFailed(errmsg); + foreach(QModelIndex index, ui->TrackList->selectionModel()->selectedRows(0)) + tlist.append(index.row()); - QApplication::processEvents(); - if(uploadDialog->upload_canceled()) - break; - } - uploadDialog->finished(); - - emit himd_idle(ui->himdpath->text()); + current_device->batchUpload(tlist, UploadDirectory); } QHiMDMainWindow::QHiMDMainWindow(QWidget *parent) @@ -386,22 +151,24 @@ QHiMDMainWindow::QHiMDMainWindow(QWidget *parent) { aboutDialog = new QHiMDAboutDialog; formatDialog = new QHiMDFormatDialog; - uploadDialog = new QHiMDUploadDialog; + current_device = NULL; detect = createDetection(this); ui->setupUi(this); ui->updir->setText(settings.value("lastUploadDirectory", QDir::homePath()).toString()); set_buttons_enable(1,0,0,0,0,0,1); - init_himd_browser(); init_local_browser(); read_window_settings(); - ui->himd_devices->hide(); + ui->himdpath->hide(); // not needed, replaced by combo box if(!autodetect_init()) ui->statusBar->showMessage(" autodetection disabled", 10000); } QHiMDMainWindow::~QHiMDMainWindow() { + if(current_device && current_device->isOpen()) + current_device->close(); + save_window_settings(); delete ui; } @@ -454,8 +221,9 @@ void QHiMDMainWindow::on_action_Format_triggered() void QHiMDMainWindow::on_action_Connect_triggered() { int index; + QHiMDDevice *dev; QString HiMDDirectory; - HiMDDirectory = settings.value("lastHiMDDirectory", QDir::rootPath()).toString(); + HiMDDirectory = settings.value("lastImageDirectory", QDir::rootPath()).toString(); HiMDDirectory = QFileDialog::getExistingDirectory(this, tr("Select directory of HiMD Medium"), HiMDDirectory, @@ -464,21 +232,13 @@ void QHiMDMainWindow::on_action_Connect_triggered() if(HiMDDirectory.isEmpty()) return; - index = ui->himd_devices->findText(HiMDDirectory); - if(index == -1) - { - ui->himd_devices->addItem(HiMDDirectory); - index = ui->himd_devices->findText(HiMDDirectory); - } - ui->himd_devices->setCurrentIndex(index); - - if(ui->himd_devices->isHidden()) - { - ui->himd_devices->show(); - ui->himdpath->hide(); - } + index = ui->himd_devices->findText("disc image"); + ui->himd_devices->setCurrentIndex(index); // index of disk image device + dev = (QHiMDDevice *)ui->himd_devices->itemData(index).value(); + dev->setPath(HiMDDirectory); + ui->himd_devices->setItemText(index, QString((dev->name() + " at " + dev->path() ))); - open_himd_at(HiMDDirectory); + open_device(dev); } void QHiMDMainWindow::on_upload_button_clicked() @@ -506,67 +266,79 @@ void QHiMDMainWindow::handle_local_selection_change(const QItemSelection&, const } if(localmodel.fileInfo(index).isFile()) - download_possible = trackmodel.is_open(); + download_possible = current_device && current_device->isOpen(); ui->action_Download->setEnabled(download_possible); ui->download_button->setEnabled(download_possible); } -void QHiMDMainWindow::himd_found(QString HiMDPath) +void QHiMDMainWindow::device_list_changed(QMDDevicePtrList dplist) { - int index; + QString device; + QMDDevice * dev; - if(HiMDPath.isEmpty()) - return; + /* close current device if it is removed from device list, just to be sure, should be handled by closed() signal */ + if(current_device && current_device->isOpen() && !dplist.contains(current_device)) + current_device_closed(); - index = ui->himd_devices->findText(HiMDPath); - if(index == -1) - ui->himd_devices->addItem(HiMDPath); + ui->himd_devices->clear(); + // add dummy entry for + ui->himd_devices->addItem(""); - if(ui->himd_devices->isHidden()) + foreach(dev, dplist) { - ui->himd_devices->show(); - ui->himdpath->hide(); + device = QString(dev->deviceType() == NETMD_DEVICE ? dev->name() : dev->name() + " at " + dev->path() ); + ui->himd_devices->addItem(device, qVariantFromValue((void *)dev)); } - if(!trackmodel.is_open()) + if(current_device) + ui->himd_devices->setCurrentIndex(dplist.indexOf(current_device) + 1); + else { - index = ui->himd_devices->findText(HiMDPath); - ui->himd_devices->setCurrentIndex(index); - open_himd_at(HiMDPath); + if(dplist.count() > 1) // open first autodetected device + { + ui->himd_devices->setCurrentIndex(2); + open_device(dplist.at(1)); + } } - } -void QHiMDMainWindow::himd_removed(QString HiMDPath) +void QHiMDMainWindow::on_himd_devices_activated(QString device) { - int index; + QMDDevice * dev; + int index = ui->himd_devices->findText(device); - if(HiMDPath.isEmpty()) - return; - if (ui->himdpath->text() == HiMDPath) - { - ui->himdpath->setText(tr("(disconnected)")); - ui->statusBar->clearMessage(); - trackmodel.close(); - } - - index = ui->himd_devices->findText(HiMDPath); - if(index != -1) + if (index == 0) // disconnected { - ui->himd_devices->removeItem(index); + current_device_closed(); + return; } - if(ui->himd_devices->count() == 0) - { - ui->himd_devices->hide(); - ui->himdpath->show(); - } + dev = (QMDDevice *)ui->himd_devices->itemData(index).value(); + open_device(dev); } -void QHiMDMainWindow::on_himd_devices_activated(QString device) +void QHiMDMainWindow::current_device_closed() { - open_himd_at(device); + int i; + + if(!current_device) + return; + + QString browser = current_device->deviceType() == NETMD_DEVICE ? "netmd_browser" : "himd_browser"; + QMDTracksModel * mod = (QMDTracksModel *)ui->TrackList->model(); + + QObject::disconnect(current_device, SIGNAL(closed()), this, SLOT(current_device_closed())); + + // save column width for this model first + for(i = 0;i < mod->columnCount(); i++) + settings.setValue(browser + QString::number(i), ui->TrackList->columnWidth(i)); + + mod->close(); + current_device = NULL; + ui->DiscTitle->setText(QString()); + ui->himd_devices->setCurrentIndex(0); + set_buttons_enable(1,0,0,0,0,0,1); } void QHiMDMainWindow::on_download_button_clicked() diff --git a/qhimdtransfer/qhimdmainwindow.h b/qhimdtransfer/qhimdmainwindow.h index b9b14f7..a462f84 100644 --- a/qhimdtransfer/qhimdmainwindow.h +++ b/qhimdtransfer/qhimdmainwindow.h @@ -6,14 +6,8 @@ #include #include "qhimdaboutdialog.h" #include "qhimdformatdialog.h" -#include "qhimduploaddialog.h" #include "qhimddetection.h" -#include "qhimdmodel.h" -#include "../libhimd/himd.h" -#include -#include -#include -#include +#include "qmdmodel.h" extern "C" { #include @@ -36,22 +30,20 @@ private: Ui::QHiMDMainWindowClass *ui; QHiMDAboutDialog * aboutDialog; QHiMDFormatDialog * formatDialog; - QHiMDUploadDialog * uploadDialog; QHiMDDetection * detect; - QHiMDTracksModel trackmodel; + QNetMDTracksModel ntmodel; + QHiMDTracksModel htmodel; QHiMDFileSystemModel localmodel; QSettings settings; - QString dumpmp3(const QHiMDTrack & trk, QString file); - QString dumpoma(const QHiMDTrack & trk, QString file); - QString dumppcm(const QHiMDTrack & trk, QString file); - void checkfile(QString UploadDirectory, QString &filename, QString extension); + QMDDevice * current_device; void set_buttons_enable(bool connect, bool download, bool upload, bool rename, bool del, bool format, bool quit); - void init_himd_browser(); + void init_himd_browser(QMDTracksModel *model); void init_local_browser(); void save_window_settings(); void read_window_settings(); bool autodetect_init(); - void open_himd_at(const QString & path); + void setCurrentDevice(QMDDevice * dev); + void open_device(QMDDevice * dev); void upload_to(const QString & path); private slots: @@ -64,14 +56,10 @@ private slots: void on_upload_button_clicked(); void handle_himd_selection_change(const QItemSelection&, const QItemSelection&); void handle_local_selection_change(const QItemSelection&, const QItemSelection&); - void himd_found(QString path); - void himd_removed(QString path); + void device_list_changed(QMDDevicePtrList dplist); void on_himd_devices_activated(QString device); + void current_device_closed(); void on_download_button_clicked(); - -signals: - void himd_busy(QString path); - void himd_idle(QString path); }; #endif // QHIMDMAINWINDOW_H diff --git a/qhimdtransfer/qhimdmainwindow.ui b/qhimdtransfer/qhimdmainwindow.ui index b55845f..d54f20d 100644 --- a/qhimdtransfer/qhimdmainwindow.ui +++ b/qhimdtransfer/qhimdmainwindow.ui @@ -35,7 +35,7 @@ - HiMD path + <html><head/><body><p>minidisc device (path):</p></body></html> @@ -52,6 +52,20 @@ + + + + + <html><head/><body><p><span style=" font-weight:600;">disc title:</span></p></body></html> + + + + + + + + + QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed @@ -174,7 +188,7 @@ 0 0 784 - 18 + 20 diff --git a/qhimdtransfer/qhimdtransfer.pro b/qhimdtransfer/qhimdtransfer.pro index 6d3e39d..9ac07cb 100644 --- a/qhimdtransfer/qhimdtransfer.pro +++ b/qhimdtransfer/qhimdtransfer.pro @@ -54,8 +54,10 @@ HEADERS += qhimdaboutdialog.h \ qhimdformatdialog.h \ qhimduploaddialog.h \ qhimdmainwindow.h \ - qhimdmodel.h \ - qhimddetection.h + qhimddetection.h \ + qmdmodel.h \ + qmdtrack.h \ + qmddevice.h FORMS += qhimdaboutdialog.ui \ qhimdformatdialog.ui \ qhimduploaddialog.ui \ @@ -65,8 +67,10 @@ SOURCES += main.cpp \ qhimdformatdialog.cpp \ qhimduploaddialog.cpp \ qhimdmainwindow.cpp \ - qhimdmodel.cpp \ - qhimddetection.cpp + qhimddetection.cpp \ + qmdmodel.cpp \ + qmdtrack.cpp \ + qmddevice.cpp win32:SOURCES += qhimdwindetection.cpp else:SOURCES += qhimddummydetection.cpp RESOURCES += icons.qrc @@ -82,6 +86,7 @@ mac:ICON = qhimdtransfer.icns win32:TARGET = QHiMDTransfer mac:TARGET = QHiMDTransfer include(../libhimd/use_libhimd.pri) +include(../libnetmd/use_libnetmd.prl) # Installing stuff translations.files = $$bracketAll(LANGUAGES, qhimdtransfer_,.qm) -- 1.8.4.msysgit.0 --------------070108020707030208000908-- From glaubitz@physik.fu-berlin.de Sat Dec 21 17:41:31 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuPcH-002EFm-FG>; Sat, 21 Dec 2013 17:41:29 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1VuPcH-001Raw-Cv>; Sat, 21 Dec 2013 17:41:29 +0100 Received: from g225090166.adsl.alicedsl.de ([92.225.90.166] helo=[192.168.1.20]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1VuPcH-002c4g-9y>; Sat, 21 Dec 2013 17:41:29 +0100 Message-ID: <52B5C4B8.8090100@physik.fu-berlin.de> Date: Sat, 21 Dec 2013 17:41:28 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.1.1 MIME-Version: 1.0 To: Thomas Arp , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> In-Reply-To: <52B5C351.8000801@gmx.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.225.90.166 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387644089-0000CD40-1A002A00/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Gabun.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Dec 2013 16:41:31 -0000 On 12/21/2013 05:35 PM, Thomas Arp wrote: > O.K., here is my updated patch rebased against the current repo on github. Does this include your last patch to fix the NULL pointer exception from your previous patch? Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From manner.moe@gmx.de Sat Dec 21 17:42:58 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuPdg-002EKO-Q3>; Sat, 21 Dec 2013 17:42:56 +0100 Received: from mout.gmx.net ([212.227.17.22]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuPdg-003B97-NK>; Sat, 21 Dec 2013 17:42:56 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0LzpWx-1VPjkS1YMV-015425 for ; Sat, 21 Dec 2013 17:42:55 +0100 Message-ID: <52B5C50C.5000900@gmx.de> Date: Sat, 21 Dec 2013 17:42:52 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: John Paul Adrian Glaubitz , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5C4B8.8090100@physik.fu-berlin.de> In-Reply-To: <52B5C4B8.8090100@physik.fu-berlin.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:mA67RYMfO0+D+gv3DNvwBb7ZR0sS6rEXLMDtObrDM/8uj7TMsw9 7pnIA+72IPAmI4JuLRBBJUOwBJ/hg7dP8JbrGwbv64O3Emxj0DZunyktM0XasjnlJeEBLim ydY40pfIj/ornXLkGhVQyso2muN6RUzKh+ki1+UTFexU6bKWisPH8fveffjEMnzzX03PmED LUsFxUz6qkznv1DYssIJw== X-Originating-IP: 212.227.17.22 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387644176-0000CD40-869E2B9B/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Gabun.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Dec 2013 16:42:58 -0000 Am 21.12.2013 17:41, schrieb John Paul Adrian Glaubitz: > On 12/21/2013 05:35 PM, Thomas Arp wrote: >> O.K., here is my updated patch rebased against the current repo on github. > Does this include your last patch to fix the NULL pointer exception > from your previous patch? > > Adrian > Yes, it is included. Thomas From glaubitz@physik.fu-berlin.de Sat Dec 21 17:57:48 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuPs2-002F9s-H6>; Sat, 21 Dec 2013 17:57:46 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1VuPs2-001VbL-F7>; Sat, 21 Dec 2013 17:57:46 +0100 Received: from g225090166.adsl.alicedsl.de ([92.225.90.166] helo=[192.168.1.20]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1VuPs2-002cxU-BY>; Sat, 21 Dec 2013 17:57:46 +0100 Message-ID: <52B5C889.5050103@physik.fu-berlin.de> Date: Sat, 21 Dec 2013 17:57:45 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.1.1 MIME-Version: 1.0 To: Thomas Arp , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> In-Reply-To: <52B5C351.8000801@gmx.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.225.90.166 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387645066-0000CD40-561C1A1D/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Burundi.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Dec 2013 16:57:48 -0000 On 12/21/2013 05:35 PM, Thomas Arp wrote: > O.K., here is my updated patch rebased against the current repo on github. Patch #4 currently breaks the build on Unix. The proper include path for libusb-1.0 is missing in the compiler command line. I haven't figured however, why this is happenning: g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DVER="\"0.9.11-0-gf8ba927\"" -DBDATE="\"Sat 12/21/2013\"" -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I../libhimd -I../libnetmd -I/usr/include/taglib -I. -I. -o main.o main.cpp In file included from ../libnetmd/libnetmd_extended.h:5:0, from ./qmdtrack.h:16, from ./qmddevice.h:7, from qhimddetection.h:7, from qhimdmainwindow.h:9, from main.cpp:4: ../libnetmd/libnetmd.h:35:20: fatal error: libusb.h: No such file or directory #include ^ compilation terminated. make[1]: *** [main.o] Error 1 make[1]: Leaving directory `/home/glaubitz/tmp/linux-minidisc/qhimdtransfer' make: *** [sub-qhimdtransfer-make_default] Error 2 I'm pretty sure it's related to your hack to fix qmake on Windows. Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From manner.moe@gmx.de Sat Dec 21 18:16:17 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuQ9v-002G9J-Lv>; Sat, 21 Dec 2013 18:16:15 +0100 Received: from mout.gmx.net ([212.227.17.20]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuQ9v-003EdS-J4>; Sat, 21 Dec 2013 18:16:15 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0LjdS8-1VNHCH3hrU-00bXbZ for ; Sat, 21 Dec 2013 18:16:13 +0100 Message-ID: <52B5CCDA.1060407@gmx.de> Date: Sat, 21 Dec 2013 18:16:10 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: John Paul Adrian Glaubitz , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5C889.5050103@physik.fu-berlin.de> In-Reply-To: <52B5C889.5050103@physik.fu-berlin.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:j4qZ9lj+vVjIh3hMVZTSwQikb6gl8i+W2POc2wsi6RCzL4LXyLD DFRM2KCHlAvoAiU9rZUPYH9ydc2K6MmYU/EnegtWYUdJPcwVoelRajJVRC9ZppRr4ASwL1p nuKBu49SX5BG7lpsLUhNl+v14ZPAkhjq+qipscQmoIpSn19sDNvQBIKMGrTGiWjvHaPJBfX 8as/Tc9YpN/jgZzPn5/AQ== X-Originating-IP: 212.227.17.20 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387646175-0000CD40-E0FECAFC/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Algerien.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Dec 2013 17:16:17 -0000 Am 21.12.2013 17:57, schrieb John Paul Adrian Glaubitz: > On 12/21/2013 05:35 PM, Thomas Arp wrote: >> O.K., here is my updated patch rebased against the current repo on github. > Patch #4 currently breaks the build on Unix. The proper include path > for libusb-1.0 is missing in the compiler command line. I haven't > figured however, why this is happenning: ... > ../libnetmd/libnetmd.h:35:20: fatal error: libusb.h: No such file or > directory > > I'm pretty sure it's related to your hack to fix qmake on Windows. > > Adrian > Hm, Are you sure libusb.h is located anywhere your include path ? I didn't change/hack anything, just used use_libnetmd.prl the same way netmdcli uses it. I don't know what's wrong but it works fine on my ubuntu machine. libusb include and library paths should be handled by pkgconfig. Thomas From manner.moe@gmx.de Sat Dec 21 18:19:47 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuQDJ-002GK4-HC>; Sat, 21 Dec 2013 18:19:45 +0100 Received: from mout.gmx.net ([212.227.17.21]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuQDJ-003EwN-EB>; Sat, 21 Dec 2013 18:19:45 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx101) with ESMTPSA (Nemesis) id 0MLzXM-1Vr7tT3dhk-007lcz for ; Sat, 21 Dec 2013 18:19:43 +0100 Message-ID: <52B5CDAC.8030302@gmx.de> Date: Sat, 21 Dec 2013 18:19:40 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: John Paul Adrian Glaubitz , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5C889.5050103@physik.fu-berlin.de> In-Reply-To: <52B5C889.5050103@physik.fu-berlin.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:2qXkjF+tH7PfzgqAcvxcuqyta1Lgnf8daBPs3snkXS25Mvc410w Z8z0a/HtPwL5aLwsZMXh9CymqmYSqYNceH8d1yaP7Gm5vo7OISKxl5ZK8oKaJ4rY53AoNjB gSsnX3dci30IUs1qNFikVbDGB4daRZPLbz5SaNN379+scVYMH9lLS0urCsWsZGKumbXZQw9 875GKrKHlKnwMsCFXoljQ== X-Originating-IP: 212.227.17.21 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387646385-0000CD40-71A225ED/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,T_FRT_PROFILE1 X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Gabun.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Dec 2013 17:19:47 -0000 Am 21.12.2013 17:57, schrieb John Paul Adrian Glaubitz: > On 12/21/2013 05:35 PM, Thomas Arp wrote: >> O.K., here is my updated patch rebased against the current repo on github. > Patch #4 currently breaks the build on Unix. The proper include path > for libusb-1.0 is missing in the compiler command line. I haven't > figured however, why this is happenning: > > g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT > -DVER="\"0.9.11-0-gf8ba927\"" -DBDATE="\"Sat 12/21/2013\"" -DQT_NO_DEBUG > -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED > -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore > -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I../libhimd > -I../libnetmd -I/usr/include/taglib -I. -I. -o main.o main.cpp > In file included from ../libnetmd/libnetmd_extended.h:5:0, > from ./qmdtrack.h:16, > from ./qmddevice.h:7, > from qhimddetection.h:7, > from qhimdmainwindow.h:9, > from main.cpp:4: > ../libnetmd/libnetmd.h:35:20: fatal error: libusb.h: No such file or > directory > #include > ^ > compilation terminated. > make[1]: *** [main.o] Error 1 > make[1]: Leaving directory `/home/glaubitz/tmp/linux-minidisc/qhimdtransfer' > make: *** [sub-qhimdtransfer-make_default] Error 2 > > I'm pretty sure it's related to your hack to fix qmake on Windows. > > Adrian > O.K., try ta add "PKGCONFIG += libusb-1.0" to qhimdtransfer.pro file, Thomas From glaubitz@physik.fu-berlin.de Sat Dec 21 20:03:41 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuRps-002Nti-ED>; Sat, 21 Dec 2013 20:03:40 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1VuRps-001yo5-C6>; Sat, 21 Dec 2013 20:03:40 +0100 Received: from g225090166.adsl.alicedsl.de ([92.225.90.166] helo=[192.168.1.20]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1VuRps-002jvI-8C>; Sat, 21 Dec 2013 20:03:40 +0100 Message-ID: <52B5E60B.7030603@physik.fu-berlin.de> Date: Sat, 21 Dec 2013 20:03:39 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.1.1 MIME-Version: 1.0 To: Thomas Arp , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> In-Reply-To: <52B5C351.8000801@gmx.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.225.90.166 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387652620-0000CD40-64124A93/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Benin.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Dec 2013 19:03:41 -0000 On 12/21/2013 05:35 PM, Thomas Arp wrote: > O.K., here is my updated patch rebased against the current repo on github. I have committed the first of the 6 patches now, it looks ok. Now for the second one: I think I would like to move the definitions in libnetmd_extended.h into libnetmd.h. It looks a bit clunky to have an extra header file required for libnetmd. Could you comment on this? Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From manner.moe@gmx.de Sat Dec 21 22:28:58 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuU6S-002VbL-Qa>; Sat, 21 Dec 2013 22:28:57 +0100 Received: from mout.gmx.net ([212.227.17.22]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuU6S-003cdn-Nq>; Sat, 21 Dec 2013 22:28:56 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx101) with ESMTPSA (Nemesis) id 0MDm4o-1VhsvB1hAk-00H4mx for ; Sat, 21 Dec 2013 22:28:55 +0100 Message-ID: <52B60813.10509@gmx.de> Date: Sat, 21 Dec 2013 22:28:51 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: John Paul Adrian Glaubitz , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5E60B.7030603@physik.fu-berlin.de> In-Reply-To: <52B5E60B.7030603@physik.fu-berlin.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:ChOsp0fgTZX90D1f1moSrIab78NI/87TwEczxFqVhAmw7oXT8+t RW4lDVxyYLSUt66/sH6jdauEe/l/dX8zCisX0ZBU51QxEkAu5VDcDPuWCqmHW0fDw9khUXU rZxZaqJiScK7pNNIz3y4zaFQ0NeA0m4LauoMVC8YncMiOt1QpuQ7I6z0tZZPwgldaEmk/qV Leg1VN1w/IDC4VCbEXK2g== X-Originating-IP: 212.227.17.22 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387661336-0000CD40-D73A9471/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Benin.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Dec 2013 21:28:58 -0000 Am 21.12.2013 20:03, schrieb John Paul Adrian Glaubitz: > On 12/21/2013 05:35 PM, Thomas Arp wrote: >> O.K., here is my updated patch rebased against the current repo on github. > I have committed the first of the 6 patches now, it looks ok. Now for > the second one: > > I think I would like to move the definitions in libnetmd_extended.h into > libnetmd.h. It looks a bit clunky to have an extra header file required > for libnetmd. > > Could you comment on this? > > Adrian > This is a bit difficult. libnetmd.h includes common.h which includes utils.h. Take a look at my comment in libnetmd_extended.h. Definition of min() in utils.h is incompatible with the definition of min() used by taglib. If we can fix this it is ok to move the definition to libnetmd.h Thomas From glaubitz@physik.fu-berlin.de Sat Dec 21 22:37:11 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuUEQ-002W9g-Cx>; Sat, 21 Dec 2013 22:37:10 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1VuUEQ-002VPt-Ap>; Sat, 21 Dec 2013 22:37:10 +0100 Received: from g225090166.adsl.alicedsl.de ([92.225.90.166] helo=[192.168.1.20]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1VuUEQ-002sJx-7Y>; Sat, 21 Dec 2013 22:37:10 +0100 Message-ID: <52B60A05.7060206@physik.fu-berlin.de> Date: Sat, 21 Dec 2013 22:37:09 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.1.1 MIME-Version: 1.0 To: Thomas Arp , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5E60B.7030603@physik.fu-berlin.de> <52B60813.10509@gmx.de> In-Reply-To: <52B60813.10509@gmx.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.225.90.166 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387661830-0000CD40-0B5369F8/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Gabun.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Dec 2013 21:37:11 -0000 On 12/21/2013 10:28 PM, Thomas Arp wrote: > This is a bit difficult. libnetmd.h includes common.h which includes > utils.h. > Take a look at my comment in libnetmd_extended.h. Definition of min() in > utils.h is incompatible with the definition of min() used by taglib. Hmm, I can't find min() defined anywhere in /usr/include/taglib. Are you sure it comes from taglib? I also can't find it in the documentation anywhere. Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From manner.moe@gmx.de Sat Dec 21 22:50:00 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuUQo-002Woy-H7>; Sat, 21 Dec 2013 22:49:58 +0100 Received: from mout.gmx.net ([212.227.17.21]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuUQo-003eWn-EB>; Sat, 21 Dec 2013 22:49:58 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0MMCSP-1VrT692yHV-0081T3 for ; Sat, 21 Dec 2013 22:49:57 +0100 Message-ID: <52B60D00.2000200@gmx.de> Date: Sat, 21 Dec 2013 22:49:52 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: John Paul Adrian Glaubitz , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5E60B.7030603@physik.fu-berlin.de> <52B60813.10509@gmx.de> <52B60A05.7060206@physik.fu-berlin.de> In-Reply-To: <52B60A05.7060206@physik.fu-berlin.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:90w/lIZ23KzAYqy6CDXYG8hjtpzed3sQxl5wIXuHJg6SYdGJ7n1 O8TWHj84Ob/AkcRXU7NVeSluMKKcLNsEvJpUvY/fWcZjSKRwjIvPBye/hQA5cP7j8D4/t7i xoE7xzpplx1qXfMR8bBW5jzMWgDjRobGolil9EfIOEFACOsjsdbNsWpYAuODrimVMt8xYNZ v6Vvfe6HTDU0ypHjdLmZQ== X-Originating-IP: 212.227.17.21 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387662598-0000CD40-04CAB98B/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Dschibuti.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Dec 2013 21:50:00 -0000 Am 21.12.2013 22:37, schrieb John Paul Adrian Glaubitz: > On 12/21/2013 10:28 PM, Thomas Arp wrote: >> This is a bit difficult. libnetmd.h includes common.h which includes >> utils.h. >> Take a look at my comment in libnetmd_extended.h. Definition of min() in >> utils.h is incompatible with the definition of min() used by taglib. > Hmm, I can't find min() defined anywhere in /usr/include/taglib. Are > you sure it comes from taglib? I also can't find it in the documentation > anywhere. > > Adrian > Yes, you are right, i just remembered from my first try that utils.h is incompatible with taglib but it seem to work now. We can include utils.h and move the needed function definitions from secure.c into libnetmd.h. Thomas From glaubitz@physik.fu-berlin.de Sat Dec 21 23:02:04 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuUcV-002XUv-4X>; Sat, 21 Dec 2013 23:02:03 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1VuUcV-002adv-2X>; Sat, 21 Dec 2013 23:02:03 +0100 Received: from g225090166.adsl.alicedsl.de ([92.225.90.166] helo=[192.168.1.20]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1VuUcU-002teB-Vh>; Sat, 21 Dec 2013 23:02:03 +0100 Message-ID: <52B60FDA.7080102@physik.fu-berlin.de> Date: Sat, 21 Dec 2013 23:02:02 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.1.1 MIME-Version: 1.0 To: Thomas Arp , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5E60B.7030603@physik.fu-berlin.de> <52B60813.10509@gmx.de> <52B60A05.7060206@physik.fu-berlin.de> <52B60D00.2000200@gmx.de> In-Reply-To: <52B60D00.2000200@gmx.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.225.90.166 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387663323-0000CD40-8609BD07/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Burundi.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Dec 2013 22:02:04 -0000 On 12/21/2013 10:49 PM, Thomas Arp wrote: > Yes, you are right, i just remembered from my first try that utils.h is > incompatible with taglib but it seem to work now. > > We can include utils.h and move the needed function definitions from > secure.c into libnetmd.h. Ok, then just let's keep this in mind now and change it afterwards. I want to have the current patch set committed first. Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From manner.moe@gmx.de Sun Dec 22 20:28:40 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vuoha-0000Wh-DD>; Sun, 22 Dec 2013 20:28:38 +0100 Received: from mout.gmx.net ([212.227.15.19]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vuoha-001cWI-9i>; Sun, 22 Dec 2013 20:28:38 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx003) with ESMTPSA (Nemesis) id 0MZTP3-1WDIML3uAP-00LEd5 for ; Sun, 22 Dec 2013 20:28:37 +0100 Message-ID: <52B73D5D.7010509@gmx.de> Date: Sun, 22 Dec 2013 20:28:29 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: John Paul Adrian Glaubitz , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5E60B.7030603@physik.fu-berlin.de> <52B60813.10509@gmx.de> <52B60A05.7060206@physik.fu-berlin.de> <52B60D00.2000200@gmx.de> <52B60FDA.7080102@physik.fu-berlin.de> In-Reply-To: <52B60FDA.7080102@physik.fu-berlin.de> Content-Type: multipart/mixed; boundary="------------020500030100030109070601" X-Provags-ID: V03:K0:BBIzgq6hkXNHD4Ad8qjVtCSSM8NsarGRwSg77tYOjOaOBSVomR0 TtST8yiZTI86NVhkt1SeW2UffzFlWNDmu8pwhei8uvyFvvLfLQzLhU/i14PwWVCWzdpQfsq tOXTfC7QA0uCcxyPdn/IBCLQ7nRmt7ixhot9Vr9oU1QzRKUXsdB56/NBrs0z8KhpOsIEjDY 0AVuLZUepVb59w8UaRbsg== X-Originating-IP: 212.227.15.19 X-ZEDAT-Hint: A X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387740518-0000CD40-47471224/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Botsuana.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2013 19:28:40 -0000 This is a multi-part message in MIME format. --------------020500030100030109070601 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, i made some cleanup for my patch. As we can obtain track information directly from the new mddevice classes we don't need the functions in the model anymore. I know my patch is not reviewed jet, but i thinks it's easier to review when there are no unused/unnessessary functions. Also, as stated by Adrian, compilation will break on linux because of missing include and library paths for libusb. Thomas --------------020500030100030109070601 Content-Type: text/x-patch; name="0007-netmd-support-removed-unused-members-track-tracks-an.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0007-netmd-support-removed-unused-members-track-tracks-an.pa"; filename*1="tch" >From a57d2aee74925ebd640251217cdff10043a43022 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Sun, 22 Dec 2013 19:59:09 +0100 Subject: [PATCH 7/8] netmd support: removed unused members track(), tracks() and downloadableFileExtensions() from the QMDModel classes. This can be used directly from the QMDDevice classes instead --- qhimdtransfer/qhimdmainwindow.cpp | 2 +- qhimdtransfer/qmdmodel.cpp | 40 --------------------------------------- qhimdtransfer/qmdmodel.h | 7 ------- 3 files changed, 1 insertion(+), 48 deletions(-) diff --git a/qhimdtransfer/qhimdmainwindow.cpp b/qhimdtransfer/qhimdmainwindow.cpp index d5031b2..0d90882 100644 --- a/qhimdtransfer/qhimdmainwindow.cpp +++ b/qhimdtransfer/qhimdmainwindow.cpp @@ -131,7 +131,7 @@ void QHiMDMainWindow::open_device(QMDDevice * dev) return; } - localmodel.setSelectableExtensions(mod->downloadableFileExtensions()); + localmodel.setSelectableExtensions(current_device->downloadableFileExtensions()); ui->DiscTitle->setText(current_device->discTitle()); set_buttons_enable(1,0,0,1,1,1,1); } diff --git a/qhimdtransfer/qmdmodel.cpp b/qhimdtransfer/qmdmodel.cpp index 2a3c4e7..a7fa13d 100644 --- a/qhimdtransfer/qmdmodel.cpp +++ b/qhimdtransfer/qmdmodel.cpp @@ -158,26 +158,6 @@ void QNetMDTracksModel::close() endResetModel(); /* inform views that the model contents changed */ } -QNetMDTrack QNetMDTracksModel::track(int trkidx) const -{ - return ndev->netmdTrack(trkidx); -} - -QNetMDTrackList QNetMDTracksModel::tracks(const QModelIndexList & modelindices) const -{ - QNetMDTrackList tracks; - QModelIndex index; - - foreach(index, modelindices) - tracks.append(ndev->netmdTrack(index.row())); - return tracks; -} - -QStringList QNetMDTracksModel::downloadableFileExtensions() const -{ - return ndev->downloadableFileExtensions(); -} - /* himd tracks model */ @@ -334,26 +314,6 @@ void QHiMDTracksModel::close() endResetModel(); /* inform views that the model contents changed */ } -QHiMDTrack QHiMDTracksModel::track(int trknum) const -{ - return hdev->himdTrack(trknum); -} - -QHiMDTrackList QHiMDTracksModel::tracks(const QModelIndexList & modelindices) const -{ - QHiMDTrackList tracks; - QModelIndex index; - - foreach(index, modelindices) - tracks.append(hdev->himdTrack(index.row())); - return tracks; -} - -QStringList QHiMDTracksModel::downloadableFileExtensions() const -{ - return hdev->downloadableFileExtensions(); -} - /* QFileSystemModel stuff */ diff --git a/qhimdtransfer/qmdmodel.h b/qhimdtransfer/qmdmodel.h index bb8b0b8..bb8ec97 100644 --- a/qhimdtransfer/qmdmodel.h +++ b/qhimdtransfer/qmdmodel.h @@ -23,7 +23,6 @@ public: virtual QString open(QMDDevice *device = NULL) {return tr("no known device type specified");} virtual bool is_open() {return false;} virtual void close() {} - QStringList downloadableFileExtensions() const {return QStringList();} }; class QNetMDTracksModel : public QMDTracksModel { @@ -42,9 +41,6 @@ public: QString open(QMDDevice *device); /* returns null if OK, error message otherwise */ virtual bool is_open(); void close(); - QNetMDTrack track(int trkidx) const; - virtual QNetMDTrackList tracks(const QModelIndexList & indices) const; // should be QMDTrackList later - QStringList downloadableFileExtensions() const; }; class QHiMDTracksModel : public QMDTracksModel { @@ -62,9 +58,6 @@ public: virtual QString open(QMDDevice *device); /* returns null if OK, error message otherwise */ virtual bool is_open(); virtual void close(); - virtual QHiMDTrack track(int trackidx) const; - virtual QHiMDTrackList tracks(const QModelIndexList & indices) const; // should be QMDTrackList later - QStringList downloadableFileExtensions() const; }; class QHiMDFileSystemModel : public QFileSystemModel { -- 1.8.4.msysgit.0 --------------020500030100030109070601 Content-Type: text/x-patch; name="0008-netmd-support-add-pkgconfig-file-for-libusb-1.0-to-q.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0008-netmd-support-add-pkgconfig-file-for-libusb-1.0-to-q.pa"; filename*1="tch" >From 96f57c42a185361f0dfc86117ce26b11657e5732 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Sun, 22 Dec 2013 20:12:59 +0100 Subject: [PATCH 8/8] netmd support: add pkgconfig file for libusb-1.0 to qhimdtransfer.pro config file --- qhimdtransfer/qhimdtransfer.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/qhimdtransfer/qhimdtransfer.pro b/qhimdtransfer/qhimdtransfer.pro index 9ac07cb..0fc2de1 100644 --- a/qhimdtransfer/qhimdtransfer.pro +++ b/qhimdtransfer/qhimdtransfer.pro @@ -1,6 +1,7 @@ TEMPLATE = app CONFIG += link_prl \ link_pkgconfig +PKGCONFIG += libusb-1.0 TARGET = qhimdtransfer DEPENDPATH += . INCLUDEPATH += . -- 1.8.4.msysgit.0 --------------020500030100030109070601-- From glaubitz@physik.fu-berlin.de Sun Dec 22 20:40:12 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vuosl-0001ZY-3W>; Sun, 22 Dec 2013 20:40:11 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1Vuosl-002XyD-1W>; Sun, 22 Dec 2013 20:40:11 +0100 Received: from port-92-206-87-81.dynamic.qsc.de ([92.206.87.81] helo=[192.168.178.71]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1Vuosk-0040YV-Nc>; Sun, 22 Dec 2013 20:40:11 +0100 Message-ID: <52B74019.6070100@physik.fu-berlin.de> Date: Sun, 22 Dec 2013 20:40:09 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.1.1 MIME-Version: 1.0 To: Thomas Arp , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5E60B.7030603@physik.fu-berlin.de> <52B60813.10509@gmx.de> <52B60A05.7060206@physik.fu-berlin.de> <52B60D00.2000200@gmx.de> <52B60FDA.7080102@physik.fu-berlin.de> <52B73D5D.7010509@gmx.de> In-Reply-To: <52B73D5D.7010509@gmx.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.206.87.81 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387741211-0000CD40-8EB6922F/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Burundi.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2013 19:40:12 -0000 On 12/22/2013 08:28 PM, Thomas Arp wrote: > i made some cleanup for my patch. Thanks! > As we can obtain track information directly from the new mddevice > classes we don't need the functions in the model anymore. > I know my patch is not reviewed jet, but i thinks it's easier to review > when there are no unused/unnessessary functions. Sure. I hope to look at the second one today, just got back home :). Just need some time for a careful review. > Also, as stated by Adrian, compilation will break on linux because of > missing include and library paths for libusb. Thanks for looking into that so quickly! Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From glaubitz@physik.fu-berlin.de Sun Dec 22 20:45:26 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vuoxp-00029d-Ji>; Sun, 22 Dec 2013 20:45:25 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1Vuoxp-002Z04-Hn>; Sun, 22 Dec 2013 20:45:25 +0100 Received: from port-92-206-87-81.dynamic.qsc.de ([92.206.87.81] helo=[192.168.178.71]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1Vuoxp-0040ow-DW>; Sun, 22 Dec 2013 20:45:25 +0100 Message-ID: <52B74153.4040900@physik.fu-berlin.de> Date: Sun, 22 Dec 2013 20:45:23 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.1.1 MIME-Version: 1.0 To: Thomas Arp , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5E60B.7030603@physik.fu-berlin.de> <52B60813.10509@gmx.de> <52B60A05.7060206@physik.fu-berlin.de> <52B60D00.2000200@gmx.de> <52B60FDA.7080102@physik.fu-berlin.de> <52B73D5D.7010509@gmx.de> <52B74019.6070100@physik.fu-berlin.de> In-Reply-To: <52B74019.6070100@physik.fu-berlin.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.206.87.81 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387741525-0000CD40-E780A8BA/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Benin.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2013 19:45:27 -0000 On 12/22/2013 08:40 PM, John Paul Adrian Glaubitz wrote: >> As we can obtain track information directly from the new mddevice >> classes we don't need the functions in the model anymore. >> I know my patch is not reviewed jet, but i thinks it's easier to review >> when there are no unused/unnessessary functions. > > Sure. I hope to look at the second one today, just got back home :). > Just need some time for a careful review. Patches 7 and 8 are supposed to be applied after the previous 6 ones have been applied, right? Please always provide this information as well, so I don't lose track what to review and merge and what not. Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From manner.moe@gmx.de Sun Dec 22 22:03:54 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuqBl-000BR0-Ax>; Sun, 22 Dec 2013 22:03:53 +0100 Received: from mout.gmx.net ([212.227.17.21]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VuqBl-001no6-8D>; Sun, 22 Dec 2013 22:03:53 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0MOx4J-1VoV3g3m1n-006Kxh for ; Sun, 22 Dec 2013 22:03:52 +0100 Message-ID: <52B753B0.6000803@gmx.de> Date: Sun, 22 Dec 2013 22:03:44 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: John Paul Adrian Glaubitz , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5E60B.7030603@physik.fu-berlin.de> <52B60813.10509@gmx.de> <52B60A05.7060206@physik.fu-berlin.de> <52B60D00.2000200@gmx.de> <52B60FDA.7080102@physik.fu-berlin.de> <52B73D5D.7010509@gmx.de> <52B74019.6070100@physik.fu-berlin.de> <52B74153.4040900@physik.fu-berlin.de> In-Reply-To: <52B74153.4040900@physik.fu-berlin.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:Gn5GZWJw/iPd5JXBrLm+M1tX4Tp7Axx5s0gYn/l9stZE6x+yNF+ HBylSm4LWs6dZ1bUwQrCpkaUgE37tjLLQgJhy2IMTFtNtuu6w+c9Cux6Q+WqoHq1zrSO+vz UClfPMf8/H4ytQOx+9nYKyYHDseCssGPl5mW6DmZdMSL7m+sWxSNXMiHkIDPF9rL/LvM8qC nGiYNd8UC2x8atv4iJQtA== X-Originating-IP: 212.227.17.21 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1387746233-0000CD40-C73342B4/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Benin.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2013 21:03:54 -0000 Am 22.12.2013 20:45, schrieb John Paul Adrian Glaubitz: > Patches 7 and 8 are supposed to be applied after the previous 6 ones > have been applied, right? Yes, this is right. > Please always provide this information as well, so I don't lose track > what to review and merge and what not. > > Adrian > Sorry, i forgot. I will provide important information like this next time. Thomas From manner.moe@gmx.de Wed Dec 25 20:59:27 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vvuc2-002Lx2-57>; Wed, 25 Dec 2013 20:59:26 +0100 Received: from mout.gmx.net ([212.227.17.20]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vvuc2-002Aka-0H>; Wed, 25 Dec 2013 20:59:26 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx003) with ESMTPSA (Nemesis) id 0LztHH-1VQRhP1wbT-014xjK for ; Wed, 25 Dec 2013 20:59:24 +0100 Message-ID: <52BB390B.2080006@gmx.de> Date: Wed, 25 Dec 2013 20:59:07 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5E60B.7030603@physik.fu-berlin.de> <52B60813.10509@gmx.de> <52B60A05.7060206@physik.fu-berlin.de> <52B60D00.2000200@gmx.de> <52B60FDA.7080102@physik.fu-berlin.de> <52B73D5D.7010509@gmx.de> In-Reply-To: <52B73D5D.7010509@gmx.de> Content-Type: multipart/mixed; boundary="------------030705060802090305050606" X-Provags-ID: V03:K0:mBa3sPFaSCEdoB6HDWDiH7fxu2sAmNURnvAfE42lOb1CQjAvaSr OCvg75kJutyUQePacDiixlyupUZmHVKPrNwshoKXYniys8S7VGsunxZHjW2FYahj+blZ3RJ WYfP0jF5EEqaOCg9gMbUPyDWJz76uBzptobFhkV5Q1/w2f5k4kv2iDZuIghF6C9wghVyxOl jHSJhKrnzFe57d0o3SPpA== X-Originating-IP: 212.227.17.20 X-ZEDAT-Hint: A X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1388001566-0000CD40-484BEA98/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.041246, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,T_FRT_CLICK X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Gabun.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Dec 2013 19:59:27 -0000 This is a multi-part message in MIME format. --------------030705060802090305050606 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, i fixed some bugs in my last patch: patch #9: reload current index of the local browser, will be cleared by calling localmodel->setSelectableExtensions() (can be applied anytime after patch #7) patch #10: (not a bug but a new feature for windows users) add windows usb driver installation support, needed for netmd devices, (can be applied anytime after patch #8) patch #11: fixed a bug in connect() function finding the device list entry reserved for manual selected himd paths (can be applied anytime after patch #9) Thomas --------------030705060802090305050606 Content-Type: text/x-patch; name="0009-netmd-support-reload-the-current-index-of-the-localb.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0009-netmd-support-reload-the-current-index-of-the-localb.pa"; filename*1="tch" >From 30c1240776de1ab47eac65e4aa6369523b75901f Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Sun, 22 Dec 2013 22:49:40 +0100 Subject: [PATCH 09/11] netmd support: reload the current index of the localbrowser after calling localmodel->setSelectableExtensions() --- qhimdtransfer/qhimdmainwindow.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qhimdtransfer/qhimdmainwindow.cpp b/qhimdtransfer/qhimdmainwindow.cpp index 0d90882..42281d3 100644 --- a/qhimdtransfer/qhimdmainwindow.cpp +++ b/qhimdtransfer/qhimdmainwindow.cpp @@ -132,6 +132,9 @@ void QHiMDMainWindow::open_device(QMDDevice * dev) } localmodel.setSelectableExtensions(current_device->downloadableFileExtensions()); + QModelIndex curdir = localmodel.index(ui->updir->text()); + ui->localScan->expand(curdir); + ui->localScan->setCurrentIndex(curdir); ui->DiscTitle->setText(current_device->discTitle()); set_buttons_enable(1,0,0,1,1,1,1); } -- 1.8.4.msysgit.0 --------------030705060802090305050606 Content-Type: text/x-patch; name="0010-netmd-support-add-support-for-usb-driver-installatio.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0010-netmd-support-add-support-for-usb-driver-installatio.pa"; filename*1="tch" >From 7bb23749cf632c19e7e006d5de8b6674a94a5791 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Tue, 24 Dec 2013 22:54:35 +0100 Subject: [PATCH 10/11] netmd support: add support for usb driver installation on windows --- qhimdtransfer/icons.qrc | 1 + qhimdtransfer/netmd_win_hint.txt | 39 ++++++++++++++++++ qhimdtransfer/qhimdtransfer.pro | 2 + qhimdtransfer/qhimdwindetection.cpp | 79 +++++++++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+) create mode 100644 qhimdtransfer/netmd_win_hint.txt diff --git a/qhimdtransfer/icons.qrc b/qhimdtransfer/icons.qrc index 2f44f90..9b7d6e1 100755 --- a/qhimdtransfer/icons.qrc +++ b/qhimdtransfer/icons.qrc @@ -14,5 +14,6 @@ icons/arrow_download.png icons/arrow_upload.png icons/qhimdtransfer_24.png + icons/qhimdtransfer_64.png diff --git a/qhimdtransfer/netmd_win_hint.txt b/qhimdtransfer/netmd_win_hint.txt new file mode 100644 index 0000000..9184c7d --- /dev/null +++ b/qhimdtransfer/netmd_win_hint.txt @@ -0,0 +1,39 @@ +How to install libusb compatible usb driver (WinUSB) for netmd devices: +(Please read this instructions completely before installing the driver!) + +- connect your netmd device (or himddevice in netmd mode) to your computer via usb + +- run zadig_xp.exe if you are using Windows XP or zadig.exe for any later version of + windows, alternatively klick on "Install driver now" in the message box. + +- if your device is not listed in the combo box activate "list all devices" from "options" + menu first + +- select your netmd device from the combo box (e.g. "Net MD/HiMD") +!!! Be sure to not select any "USB-HID" device, this should be mouse/keyboard or + something like this, they cannot be used anymore if you install the driver on it. + +Note: If you have more than one device you want to use QHimdTransfer with it is + recommended that you rename the device in the combo box by activating "Edit" + checkbox and edit the device name (e.g. "Net MD/HiMD" -> + "Sony MZ-RH1 NetMD" for Sony MZ-RH1, or anything else you want). + +- leave the section as it is, WinUSB driver works fine, the others may not + work correctly with the libusb version currently used + +- klick "Install WCID driver" to install the driver + +- If you get the "Driver was installed successfully" message you are done. + If this fails try to run zadig with root permissions and try again. + +You have to do this for ALL netmd devices you want to use QHiMDTransfer with. + +Important: The installed driver is not compatible with SonicStage! + For using the device with SonicStage you have to remove the driver first. + You can do this by opening windows device manager, find your device + at "Universal Serial Bus devices", right klick on it an choose "Uninstall" + After reconnection it can be used with SonicStage. + +If you select "Do not show this message again" you can find this driver installation +instructions at netmd_win_hint.txt in the QHiMDTransfer programm folder if you need +it for future reference. diff --git a/qhimdtransfer/qhimdtransfer.pro b/qhimdtransfer/qhimdtransfer.pro index 0fc2de1..6b250ab 100644 --- a/qhimdtransfer/qhimdtransfer.pro +++ b/qhimdtransfer/qhimdtransfer.pro @@ -101,3 +101,5 @@ unix:!macx { target.path = /usr/bin INSTALLS += target } + +win32:OTHER_FILES += netmd_win_hint.txt diff --git a/qhimdtransfer/qhimdwindetection.cpp b/qhimdtransfer/qhimdwindetection.cpp index f5a9d0c..bc29d4d 100644 --- a/qhimdtransfer/qhimdwindetection.cpp +++ b/qhimdtransfer/qhimdwindetection.cpp @@ -2,6 +2,14 @@ #include #include #include "qhimddetection.h" +#include "QSettings" +#include +#include +#include +#include +#include +#include +#include #include #include @@ -37,6 +45,8 @@ public: private: HDEVNOTIFY hDevNotify; HDEVNOTIFY listen_usbdev; + void show_netmd_hint(); + void install_netmd_driver(); QMDDevice *find_by_handle(HANDLE devhandle); void add_himddevice(QString path, QString name); virtual void remove_himddevice(QString path); @@ -64,6 +74,8 @@ QHiMDWinDetection::QHiMDWinDetection(QObject * parent) // register for usb device notifications if((listen_usbdev = register_usbDeviceNotification()) == NULL) qDebug() << "cannot register usb device notifications" << endl; + + show_netmd_hint(); } QHiMDWinDetection::~QHiMDWinDetection() @@ -73,6 +85,73 @@ QHiMDWinDetection::~QHiMDWinDetection() cleanup_netmd_list(); } +/* show_netmd_hint() and install_netmd_driver() are used for libusb compatible usb driver installation for netmd devices, + * when compiling yourself be sure that netmd_win_hint.txt, zadig.exe and zadig_xp.exe are located in the same directory as QHiMDTransfer.exe. + * + * these files will be provided and installed by the QHiMDTransfer windows installer package automatically + */ + +void QHiMDWinDetection::show_netmd_hint() +{ + QSettings settings; + QString netmdText = QMessageBox::tr("
Preparing netmd devices for use with QHiMDTransfer
"); + // begin string with <...> quotes to indicate that this string is in Qt::RichText format + QString netmdInfoText = QMessageBox::tr("For each netmd device (and himd device in netmd mode) a libusb compatible driver must be installed first.

"); + netmdInfoText.append(QMessageBox::tr("To do this connect your netmd device to your computer and klick on Install driver now,")); + netmdInfoText.append(QMessageBox::tr("alternatively install the driver later by running the usb driver installer (zadig.exe).
")); + netmdInfoText.append(QMessageBox::tr("You can find it inside the QHiMDTransfer programm folder.

")); + netmdInfoText.append(QMessageBox::tr("For a more detailed description on how to use the usb driver installer klick on Show Details...
")); + + QString netmdDetails; + QMessageBox msg; + QPushButton *install; + QFile file("netmd_win_hint.txt"); + + if(settings.value("hide_netmd_hint", false).toBool()) + return; + + //read detailed information from textfile + if(file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + QTextStream details(&file); + netmdDetails = details.readAll(); + } + else + netmdDetails = msg.tr("No detailed information available"); + + msg.setIconPixmap(QPixmap(":icons/qhimdtransfer_64.png")); + msg.setWindowTitle(msg.tr("Using NetMD Devices with QHiMDTransfer")); + msg.setText(netmdText); + msg.setInformativeText(netmdInfoText); + msg.setDetailedText(netmdDetails); + + /* keep button order/location by using the same button role, else hideInfo checkbox will appear anywhere + * in the middle between the other buttons + */ + QCheckBox hideInfo(hideInfo.tr("Do not show this message again"), &msg); + hideInfo.blockSignals(true); // prevent closing message box when checkbox is toggled + msg.addButton(&hideInfo, QMessageBox::NoRole); + install = msg.addButton("Install driver now", QMessageBox::NoRole); + msg.addButton("Install later", QMessageBox::NoRole); + + msg.exec(); + if((QPushButton*)msg.clickedButton() == install) + install_netmd_driver(); + + settings.setValue("hide_netmd_hint", hideInfo.checkState() == Qt::Checked); +} + +void QHiMDWinDetection::install_netmd_driver() +{ + QProcess process; + QSysInfo sys; + + if(sys.windowsVersion() < QSysInfo::WV_6_0) + process.execute("zadig_xp.exe"); + else + process.execute("zadig.exe"); +} + void QHiMDWinDetection::scan_for_himd_devices() { unsigned long drives = GetLogicalDrives(); -- 1.8.4.msysgit.0 --------------030705060802090305050606 Content-Type: text/x-patch; name="0011-fixed-a-bug-in-connect-function-finding-the-correct-.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0011-fixed-a-bug-in-connect-function-finding-the-correct-.pa"; filename*1="tch" >From f36722828f881deaa725bf6a2e44109c3c363eb9 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Wed, 25 Dec 2013 20:22:03 +0100 Subject: [PATCH 11/11] fixed a bug in connect() function finding the correct device entry for disc images/ manual selected himd device paths --- qhimdtransfer/qhimdmainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qhimdtransfer/qhimdmainwindow.cpp b/qhimdtransfer/qhimdmainwindow.cpp index 42281d3..1ce0278 100644 --- a/qhimdtransfer/qhimdmainwindow.cpp +++ b/qhimdtransfer/qhimdmainwindow.cpp @@ -235,7 +235,7 @@ void QHiMDMainWindow::on_action_Connect_triggered() if(HiMDDirectory.isEmpty()) return; - index = ui->himd_devices->findText("disc image"); + index = ui->himd_devices->findText("disc image", Qt::MatchContains); ui->himd_devices->setCurrentIndex(index); // index of disk image device dev = (QHiMDDevice *)ui->himd_devices->itemData(index).value(); dev->setPath(HiMDDirectory); -- 1.8.4.msysgit.0 --------------030705060802090305050606-- From glaubitz@physik.fu-berlin.de Wed Dec 25 21:25:16 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vvv11-002OVS-HV>; Wed, 25 Dec 2013 21:25:15 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1Vvv11-001JaH-Ff>; Wed, 25 Dec 2013 21:25:15 +0100 Received: from port-92-206-31-67.dynamic.qsc.de ([92.206.31.67] helo=[192.168.178.71]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1Vvv11-003gh8-BW>; Wed, 25 Dec 2013 21:25:15 +0100 Message-ID: <52BB3F2A.4040807@physik.fu-berlin.de> Date: Wed, 25 Dec 2013 21:25:14 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.1.1 MIME-Version: 1.0 To: Thomas Arp , "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5E60B.7030603@physik.fu-berlin.de> <52B60813.10509@gmx.de> <52B60A05.7060206@physik.fu-berlin.de> <52B60D00.2000200@gmx.de> <52B60FDA.7080102@physik.fu-berlin.de> <52B73D5D.7010509@gmx.de> <52BB390B.2080006@gmx.de> In-Reply-To: <52BB390B.2080006@gmx.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.206.31.67 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1388003115-0000CD40-40038D4C/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Burundi.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Dec 2013 20:25:16 -0000 On 12/25/2013 08:59 PM, Thomas Arp wrote: > i fixed some bugs in my last patch: Thanks! I just applied patch #2 and pushed it to the github repository. Going to look at 3 and 4 now. When finished with your patch series, I will push everything back to the original master repository. Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From Michael.Karcher@fu-berlin.de Fri Dec 27 01:00:54 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VwKrF-002AZf-8l>; Fri, 27 Dec 2013 01:00:53 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1VwKrF-001OAW-6u>; Fri, 27 Dec 2013 01:00:53 +0100 Received: from port-92-204-11-240.dynamic.qsc.de ([92.204.11.240] helo=[192.168.178.25]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1VwKrF-000rUC-1G>; Fri, 27 Dec 2013 01:00:53 +0100 Message-ID: <1388102452.8557.36.camel@localhost> From: Michael Karcher To: Thomas Arp Date: Fri, 27 Dec 2013 01:00:52 +0100 In-Reply-To: <529BB859.50809@gmx.de> References: <529BB859.50809@gmx.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.8.5-2+b1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Originating-IP: 92.204.11.240 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1388102453-0000CD40-0EE50F8A/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.069084, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Dschibuti.ZEDAT.FU-Berlin.DE X-Spam-Level: Cc: "linux-minidisc@lists.fu-berlin.de" Subject: Re: [linux-minidisc] Qt5 compatibility X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Dec 2013 00:00:54 -0000 Hi, the evil critic is back... Am Sonntag, den 01.12.2013, 23:29 +0100 schrieb Thomas Arp: > i upgraded my windows build environment to Qt5 for testing. > I made some changes so that the code can be complied with Qt4 and Qt5. Thanks for your patch, but let me comment on it. You remove "QtGui/" from the include directory paths, as it is mostly "QtWidgets/" in Qt5. This is fine, as the module-specific subdirectories are put into the include path by qmake. But this has a bad end result: We pick up headers from QtCore using paths specifying the include directory explicitly (like ), but we pick up headers from QtGui without specifying it. I really dislike that inconsistency. In my oppinion, we should drop "QtCore/" as well. Furthermore, some things look like should be improved/fixed: > @@ -282,8 +282,8 @@ bool QHiMDMainWindow::autodetect_init() > { > int k; > > - k = QObject::connect(detect, SIGNAL(himd_found(QString)), this, SLOT(himd_found(QString))); > - k += QObject::connect(detect, SIGNAL(himd_removed(QString)), this, SLOT(himd_removed(QString))); > + k = (bool)QObject::connect(detect, SIGNAL(himd_found(QString)), this, SLOT(himd_found(QString))); > + k += (bool)QObject::connect(detect, SIGNAL(himd_removed(QString)), this, SLOT(himd_removed(QString))); I would prefer "k" to be a boolean variable here, which makes the first cast superflous. You also can get rid of the second cast by writing that line "k = k || QObject::connect(...)". In my oppinion that one expresses the intent better that we want to know whether the first *or* the second connect worked. In fact, I would suggest to refactor the code this way: > bool worked = QObject::connect(detect, SIGNAL(himd_found(QString)), this, SLOT(himd_found(QString))) > || QObject::connect(detect, SIGNAL(himd_removed(QString)), this, SLOT(himd_removed(QString))); > > if(!worked) > return false; The "||" operator implicitly treats the parameters as bools, and "worked" is more expressive than "k". I also dislike this hunk: > @@ -300,7 +300,7 @@ void QHiMDMainWindow::open_himd_at(const QString & path) > QMessageBox himdStatus; > QString error; > - error = trackmodel.open(path.toAscii()); > + error = trackmodel.open(path.toLatin1()); > if (!error.isNull()) { > himdStatus.setText(tr("Error opening HiMD data. Make sure you chose the proper root directory of your HiMD-Walkman.\n") + error); But this is not really your fault. You did do the correct transformation here, but the code was bad before to begin with. QHiMDTracksModel accepts a const QString &, so there is no need at all to convert the string into the "default 8-bit encoding" (toAscii, Qt4 only) or Latin 1. In fact, QHiMDTracksModel converts the path to utf-8, as this is what glib (on which libhimd is based) likes to see as filename encoding. In fact, the old, bad, code was indeed (accidentally) working correctly on Qt 4 as long as the file name was representable in the "default 8-bit encoding", which could have been be something different from Latin 1 (but as no one calls setCodecForCStrings was Latin 1 all the time), because the returned QByteArray was implicitly converted back to a QString using the constructor accepting a QByteArray that undid toAscii() per spec. On the other hand, in Qt5, the constructor of QString accepting a byte array does *not* undo toLatin1, but interprets the string as UTF-8 instead. So that patch breaks filenames like "BlÃķdsinn". As we are talking about all those toLatin1 calls: There are a lot of them in the QHiMDWinDetection code. The one for getting the drive letter are OK in my oppinion, but is there any reason to use toLatin1 and the CM_Locate_DevnodeA, instead of using toUtf16 and CM_Locate_DevodeW? And last, but not least: You use the dreaded "reinterpret_cast" to cast from void* to MSG*. As far as I understand C++, you should be able to use static_cast as well. While there are no differences in the binary code of either variant, static_cast is typically preferred a lot as reinterpret_cast is able to do many strange things no one should ever do, whereas static_cast is for the common, more safe things. In case a reinterpret_cast is also valid as static_cast, as is the case here, I *think*, the reinterpret cast is compiled exactly the same way as the corresponding static_cast. It might even be defined that way in the C++ standard, but I am too lazy to look it up now. As your patch is already in, I suggest proceeding this way: 1) Commit a second patch that removes "QtCore" from the include directives (and does *just* that) 2) Commit one patch that rephrases the test for autodetectability and removes the bad "toLatin1" as "minor fixes" patch. I think the ideal thing from a traceability perspective (who did what when and why) would be to have this two patches, as these are two logical changes, caused by different reasons, and even two different severities (one is a code "clean-up" without functional change, the other one is a bug fix), but I understand worries about "commit bloat" for small changes, too. So do it either way you want, or drop the "cleanup" completely, if you decide you want to keep the "+=" construct with the casts to bool. > .: Tested with Qt 4.7 and Qt 5.1 with gcc on Windows XP > _______________________________________________ > linux-minidisc mailing list > linux-minidisc@lists.fu-berlin.de > https://lists.fu-berlin.de/listinfo/linux-minidisc From glaubitz@physik.fu-berlin.de Fri Dec 27 01:39:44 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VwLSp-002Dwx-9P>; Fri, 27 Dec 2013 01:39:43 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1VwLSp-001TYp-61>; Fri, 27 Dec 2013 01:39:43 +0100 Received: from port-92-206-55-189.dynamic.qsc.de ([92.206.55.189] helo=[192.168.178.71]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1VwLSp-000tOl-1e>; Fri, 27 Dec 2013 01:39:43 +0100 Message-ID: <52BCCC4E.6000602@physik.fu-berlin.de> Date: Fri, 27 Dec 2013 01:39:42 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.1.1 MIME-Version: 1.0 To: Michael Karcher , Thomas Arp References: <529BB859.50809@gmx.de> <1388102452.8557.36.camel@localhost> In-Reply-To: <1388102452.8557.36.camel@localhost> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.206.55.189 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1388104783-0000CD40-87070187/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.020277, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Dschibuti.ZEDAT.FU-Berlin.DE X-Spam-Level: Cc: "linux-minidisc@lists.fu-berlin.de" Subject: Re: [linux-minidisc] Qt5 compatibility X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Dec 2013 00:39:44 -0000 On 12/27/2013 01:00 AM, Michael Karcher wrote: > As your patch is already in, I suggest proceeding this way: > 1) Commit a second patch that removes "QtCore" from the include > directives (and does *just* that) > 2) Commit one patch that rephrases the test for autodetectability and > removes the bad "toLatin1" as "minor fixes" patch. I think the ideal > thing from a traceability perspective (who did what when and why) would > be to have this two patches, as these are two logical changes, caused by > different reasons, and even two different severities (one is a code > "clean-up" without functional change, the other one is a bug fix), but I > understand worries about "commit bloat" for small changes, too. So do it > either way you want, or drop the "cleanup" completely, if you decide you > want to keep the "+=" construct with the casts to bool. Note that we can also drop the commits back to 0.9.10 altogether. Thomas can just rework his patches and I create a new history in the git repository. Once the patches are clean, I'll commit them and fix the history. Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From glaubitz@physik.fu-berlin.de Fri Dec 27 01:47:11 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VwLa2-002ELs-SF>; Fri, 27 Dec 2013 01:47:10 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1VwLa2-001UU8-Oj>; Fri, 27 Dec 2013 01:47:10 +0100 Received: from port-92-206-55-189.dynamic.qsc.de ([92.206.55.189] helo=[192.168.178.71]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1VwLa2-000tlN-Ka>; Fri, 27 Dec 2013 01:47:10 +0100 Message-ID: <52BCCE0D.1020209@physik.fu-berlin.de> Date: Fri, 27 Dec 2013 01:47:09 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.1.1 MIME-Version: 1.0 To: Michael Karcher , Thomas Arp References: <529BB859.50809@gmx.de> <1388102452.8557.36.camel@localhost> <52BCCC4E.6000602@physik.fu-berlin.de> In-Reply-To: <52BCCC4E.6000602@physik.fu-berlin.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.206.55.189 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1388105230-0000CD40-1F4AB3F8/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Burundi.ZEDAT.FU-Berlin.DE X-Spam-Level: Cc: "linux-minidisc@lists.fu-berlin.de" Subject: Re: [linux-minidisc] Qt5 compatibility X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Dec 2013 00:47:12 -0000 On 12/27/2013 01:39 AM, John Paul Adrian Glaubitz wrote: > Note that we can also drop the commits back to 0.9.10 altogether. Thomas > can just rework his patches and I create a new history in the git > repository. On second thought, this would actually mess up the version history of the Debian package, so I think Michael's suggestion sounds more reasonable. Thomas, I guess you create patches with Michael's suggestion and I'll commit these and fix the version history on both git repositories, then we'll move on with the NetMD stuff. Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From manner.moe@gmx.de Fri Dec 27 19:29:21 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vwc9w-000llJ-LQ>; Fri, 27 Dec 2013 19:29:20 +0100 Received: from mout.gmx.net ([212.227.15.18]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vwc9w-002qLX-IJ>; Fri, 27 Dec 2013 19:29:20 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0MTvUT-1W56aM0t29-00QnCV for ; Fri, 27 Dec 2013 19:29:19 +0100 Message-ID: <52BDC6FB.2080308@gmx.de> Date: Fri, 27 Dec 2013 19:29:15 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Michael Karcher References: <529BB859.50809@gmx.de> <1388102452.8557.36.camel@localhost> In-Reply-To: <1388102452.8557.36.camel@localhost> Content-Type: multipart/mixed; boundary="------------070002030505080505080009" X-Provags-ID: V03:K0:WM4nFxw/moAJ2ZoLlBxlHYZUSmPNQ1qsykUmHffUsnJa5h6wUDB yrEAi3EeDukH5/qIeDgqg+CiNpm+vgM3HPLQBlXu/yGiEshaNEWRhTyu0TElFqopMZwj0Vd Ccm2uTizfAVYN14AYdA3bq179/ao7sK3Wa9FKzAT93aZ+Z8P6zowvKPKo+jMK3Z1rn4jmhS FevnKdds1khmUcXlxkfXg== X-Originating-IP: 212.227.15.18 X-ZEDAT-Hint: A X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1388168960-0000CD40-C20F22B2/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.181755, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Benin.ZEDAT.FU-Berlin.DE X-Spam-Level: Cc: "linux-minidisc@lists.fu-berlin.de" Subject: Re: [linux-minidisc] Qt5 compatibility X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Dec 2013 18:29:22 -0000 This is a multi-part message in MIME format. --------------070002030505080505080009 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Am 27.12.2013 01:00, schrieb Michael Karcher: > Hi, the evil critic is back... Hi > > As your patch is already in, I suggest proceeding this way: > 1) Commit a second patch that removes "QtCore" from the include > directives (and does *just* that) O.K., here is the patch. > 2) Commit one patch that rephrases the test for autodetectability and > removes the bad "toLatin1" as "minor fixes" patch. I think the ideal > thing from a traceability perspective (who did what when and why) would > be to have this two patches, as these are two logical changes, caused by > different reasons, and even two different severities (one is a code > "clean-up" without functional change, the other one is a bug fix), but I > understand worries about "commit bloat" for small changes, too. So do it > either way you want, or drop the "cleanup" completely, if you decide you > want to keep the "+=" construct with the casts to bool. > In my patches for netmd integration the "+=" with the casts to bool does not exist anymore. Also the trackmodel.open() routine will be changed by taking a pointer to a QMDDevice class as parameter. So the bad toLatin1() does not exist, too. I think it is better to drop the "cleanup" for now until my netmd integration patches have been reviewed completely. Maybe some cleanup or bug fixing is nessessary anyway. Thomas --------------070002030505080505080009 Content-Type: text/x-patch; name="0001-remove-QtCore-from-the-include-directives-let-qmake-.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-remove-QtCore-from-the-include-directives-let-qmake-.pa"; filename*1="tch" >From ef623ed715baa2aa2573c0d4954dbbd796b5cc22 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Fri, 27 Dec 2013 18:59:32 +0100 Subject: [PATCH] remove "QtCore" from the include directives, let qmake add the include paths instead --- qhimdtransfer/main.cpp | 4 ++-- qhimdtransfer/qhimddetection.cpp | 2 +- qhimdtransfer/qhimdmainwindow.cpp | 2 +- qhimdtransfer/qhimdmainwindow.h | 2 +- qhimdtransfer/qhimdmodel.cpp | 4 ++-- qhimdtransfer/qhimdmodel.h | 8 ++++---- qhimdtransfer/qhimdtransfer.pro | 2 +- qhimdtransfer/qhimdwindetection.cpp | 4 ++-- qhimdtransfer/qmdtrack.h | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/qhimdtransfer/main.cpp b/qhimdtransfer/main.cpp index e7a3e2f..b07dfa3 100644 --- a/qhimdtransfer/main.cpp +++ b/qhimdtransfer/main.cpp @@ -1,6 +1,6 @@ #include -#include -#include +#include +#include #include "qhimdmainwindow.h" /* stolen from Qt Creator */ diff --git a/qhimdtransfer/qhimddetection.cpp b/qhimdtransfer/qhimddetection.cpp index d563587..579fd61 100644 --- a/qhimdtransfer/qhimddetection.cpp +++ b/qhimdtransfer/qhimddetection.cpp @@ -1,4 +1,4 @@ -#include +#include #include "qhimddetection.h" QHiMDDetection::QHiMDDetection(QObject *parent) : diff --git a/qhimdtransfer/qhimdmainwindow.cpp b/qhimdtransfer/qhimdmainwindow.cpp index 1b86651..907464e 100644 --- a/qhimdtransfer/qhimdmainwindow.cpp +++ b/qhimdtransfer/qhimdmainwindow.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include QString QHiMDMainWindow::dumpmp3(const QHiMDTrack & trk, QString file) diff --git a/qhimdtransfer/qhimdmainwindow.h b/qhimdtransfer/qhimdmainwindow.h index b9b14f7..3715e05 100644 --- a/qhimdtransfer/qhimdmainwindow.h +++ b/qhimdtransfer/qhimdmainwindow.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include "qhimdaboutdialog.h" #include "qhimdformatdialog.h" #include "qhimduploaddialog.h" diff --git a/qhimdtransfer/qhimdmodel.cpp b/qhimdtransfer/qhimdmodel.cpp index 435a24b..86c2ca4 100644 --- a/qhimdtransfer/qhimdmodel.cpp +++ b/qhimdtransfer/qhimdmodel.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include "qhimdmodel.h" static QString get_himd_str(struct himd * himd, int idx) diff --git a/qhimdtransfer/qhimdmodel.h b/qhimdtransfer/qhimdmodel.h index 9a3a0b7..b921c6a 100644 --- a/qhimdtransfer/qhimdmodel.h +++ b/qhimdtransfer/qhimdmodel.h @@ -1,10 +1,10 @@ #ifndef QHIMDMODEL_H #define QHIMDMODEL_H -#include -#include -#include -#include +#include +#include +#include +#include #include #include "himd.h" diff --git a/qhimdtransfer/qhimdtransfer.pro b/qhimdtransfer/qhimdtransfer.pro index 6d3e39d..9dae0a8 100644 --- a/qhimdtransfer/qhimdtransfer.pro +++ b/qhimdtransfer/qhimdtransfer.pro @@ -6,7 +6,7 @@ DEPENDPATH += . INCLUDEPATH += . # for Qt5 compatibility -QT += gui +QT += gui core greaterThan(QT_MAJOR_VERSION, 4): QT += widgets # determine version number from git diff --git a/qhimdtransfer/qhimdwindetection.cpp b/qhimdtransfer/qhimdwindetection.cpp index 3e79038..04d07c0 100644 --- a/qhimdtransfer/qhimdwindetection.cpp +++ b/qhimdtransfer/qhimdwindetection.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include "qhimddetection.h" diff --git a/qhimdtransfer/qmdtrack.h b/qhimdtransfer/qmdtrack.h index 0ac7e43..569842b 100644 --- a/qhimdtransfer/qmdtrack.h +++ b/qhimdtransfer/qmdtrack.h @@ -1,7 +1,7 @@ #ifndef QMDTRACK_H #define QMDTRACK_H -#include +#include #include "himd.h" #include "sony_oma.h" -- 1.7.10.4 --------------070002030505080505080009-- From Michael.Karcher@fu-berlin.de Fri Dec 27 19:53:09 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VwcWy-000rw9-Oy>; Fri, 27 Dec 2013 19:53:08 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1VwcWy-000Hrq-N1>; Fri, 27 Dec 2013 19:53:08 +0100 Received: from port-92-204-67-74.dynamic.qsc.de ([92.204.67.74] helo=[192.168.178.20]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1VwcWy-001rjI-HP>; Fri, 27 Dec 2013 19:53:08 +0100 Message-ID: <1388129461.8557.41.camel@localhost> From: Michael Karcher To: Thomas Arp In-Reply-To: <52AE1C28.6060007@gmx.de> References: <529BB859.50809@gmx.de> <529BB925.7070906@physik.fu-berlin.de> <529BC0D9.3090509@physik.fu-berlin.de> <52AE1C28.6060007@gmx.de> Content-Type: text/plain; charset="UTF-8" Date: Fri, 27 Dec 2013 08:31:01 +0100 Mime-Version: 1.0 X-Mailer: Evolution 3.8.5-2+b1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.204.67.74 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1388170388-0000CD40-6730FEFC/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-48.9 required=5.0 tests=ALL_TRUSTED, DATE_IN_PAST_06_12 X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Dschibuti.ZEDAT.FU-Berlin.DE X-Spam-Level: Cc: "linux-minidisc@lists.fu-berlin.de" Subject: Re: [linux-minidisc] Qt5 compatibility X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Dec 2013 18:53:09 -0000 Am Sonntag, den 15.12.2013, 22:16 +0100 schrieb Thomas Arp: > there is one more incompatibility with Qt5 in the QTime class. A QTime > object must be initialized before using it, else it will be invalid. > So current source code will not display track length if compiled with Qt5. > I made a small patch fixing this. This patch is already applied as-is, which is what I would have done, too. No problems with the patch or the code it touches. (Although I somehow dislike the Qt choice of using the same class to represent both time spans and time-of-day with the same class, resulting in stuff like "QTime::elapsed() will wrap if the latest call of start() or restart() is more than 24 hours ago", which will make our program show wrong durations if there are tracks longer than 24 hours, sorry, just *had* to dislike something about it...) Regards, Michael Karcher From glaubitz@physik.fu-berlin.de Sat Dec 28 02:38:38 2013 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VwirN-001ZyQ-La>; Sat, 28 Dec 2013 02:38:37 +0100 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1VwirN-001K9H-IH>; Sat, 28 Dec 2013 02:38:37 +0100 Received: from port-92-206-119-243.dynamic.qsc.de ([92.206.119.243] helo=[192.168.178.71]) by inpost2.zedat.fu-berlin.de (Exim 4.82) with esmtpsa (envelope-from ) id <1VwirN-002DMK-E2>; Sat, 28 Dec 2013 02:38:37 +0100 Message-ID: <52BE2B9C.6040909@physik.fu-berlin.de> Date: Sat, 28 Dec 2013 02:38:36 +0100 From: John Paul Adrian Glaubitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.1.1 MIME-Version: 1.0 To: Michael Karcher , Thomas Arp References: <529BB859.50809@gmx.de> <529BB925.7070906@physik.fu-berlin.de> <529BC0D9.3090509@physik.fu-berlin.de> <52AE1C28.6060007@gmx.de> <1388129461.8557.41.camel@localhost> In-Reply-To: <1388129461.8557.41.camel@localhost> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Originating-IP: 92.206.119.243 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1388194717-0000CD40-8DE578A3/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=-50.0 required=5.0 tests=ALL_TRUSTED X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Burundi.ZEDAT.FU-Berlin.DE X-Spam-Level: Cc: "linux-minidisc@lists.fu-berlin.de" Subject: Re: [linux-minidisc] Qt5 compatibility X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Dec 2013 01:38:38 -0000 On 12/27/2013 08:31 AM, Michael Karcher wrote: > Am Sonntag, den 15.12.2013, 22:16 +0100 schrieb Thomas Arp: >> there is one more incompatibility with Qt5 in the QTime class. A QTime >> object must be initialized before using it, else it will be invalid. >> So current source code will not display track length if compiled with Qt5. >> I made a small patch fixing this. > > This patch is already applied as-is, which is what I would have done, > too. No problems with the patch or the code it touches. Which patch are you talking about now? And what do we want to commit now? Should we fix the Qt5 changes first, then synchronize both git repositories and eventually start reviewing the NetMD stuff? Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 From manner.moe@gmx.de Sat Dec 28 20:38:26 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VwziL-000WpL-9R>; Sat, 28 Dec 2013 20:38:25 +0100 Received: from mout.gmx.net ([212.227.15.15]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VwziL-0015yH-6j>; Sat, 28 Dec 2013 20:38:25 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx101) with ESMTPSA (Nemesis) id 0MCggg-1Vnc2n3P7a-009M5K for ; Sat, 28 Dec 2013 20:38:23 +0100 Message-ID: <52BF28A8.7030005@gmx.de> Date: Sat, 28 Dec 2013 20:38:16 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5E60B.7030603@physik.fu-berlin.de> <52B60813.10509@gmx.de> <52B60A05.7060206@physik.fu-berlin.de> <52B60D00.2000200@gmx.de> <52B60FDA.7080102@physik.fu-berlin.de> <52B73D5D.7010509@gmx.de> <52BB390B.2080006@gmx.de> In-Reply-To: <52BB390B.2080006@gmx.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:RhA4g3IegaPUbnP4u0qTlYyjDLbpd3bk/of3J5yuyYxvqnX750t pldfWhT1LcdxQGL5oq/Be76TS9fwZhrN+YeDCLtuDWVC3jUFFpjtR5cYfrjCE9hbZyzmtJg e9ddLOUZviQrSBzeNhb+Q+sUTg/XrReO3Lf2wU5RDelO01fV8ZnusdaImGX96DZYK2/fxdD TIx5HVKiHm2M+qd26DNRA== X-Originating-IP: 212.227.15.15 X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1388259505-0000CD40-FE97A408/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Dschibuti.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Dec 2013 19:38:26 -0000 Am 25.12.2013 20:59, schrieb Thomas Arp: > Hi, > here is a new feature corresponding to my netmd integration patch. This can be applied after patch #10. I know, my patch is not reviewed jet, but i just want this to be added to the "to review list". This includes unix netmd and himd autotetection during application runtime (netmd autodetection at application start is already implemented). Himd autodetection at application start is missing yet, also himd autodetection during application runtime does not work correctly. The detection works, but not the function getting the mountpoint. I can fetch the mountpoint for the detected device from UDisks2 through dbus but the value returned cannot be converted yet (see comments in the files). Thomas From manner.moe@gmx.de Sat Dec 28 20:39:54 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vwzjk-000XSL-LV>; Sat, 28 Dec 2013 20:39:52 +0100 Received: from mout.gmx.net ([212.227.15.15]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1Vwzjk-00164D-H2>; Sat, 28 Dec 2013 20:39:52 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0MN1Gu-1VqP6M4B4K-006ema for ; Sat, 28 Dec 2013 20:39:51 +0100 Message-ID: <52BF28FF.1000302@gmx.de> Date: Sat, 28 Dec 2013 20:39:43 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5E60B.7030603@physik.fu-berlin.de> <52B60813.10509@gmx.de> <52B60A05.7060206@physik.fu-berlin.de> <52B60D00.2000200@gmx.de> <52B60FDA.7080102@physik.fu-berlin.de> <52B73D5D.7010509@gmx.de> <52BB390B.2080006@gmx.de> <52BF28A8.7030005@gmx.de> In-Reply-To: <52BF28A8.7030005@gmx.de> Content-Type: multipart/mixed; boundary="------------070205090702040404020906" X-Provags-ID: V03:K0:wvJ3gkqYFycWkJgUTz4U9uxg7wQB0/WBKmW1hBCQ6EOw+1MdAzP SiaNLpKMfcXDL4Ycmo2Oc+mJRNOfWApNXbKZgJK1iJTd+zDn86Yfo3Ci3DjUNYhsyzaoWZp QvyiO6XRLeTRB5YnVLJmQABYwCcZfl/4minXR9FSHbui0rBIrJQXiD4AcTN96tMssaCJ/D2 N+vdVLS/OoJ7mqJi82pyA== X-Originating-IP: 212.227.15.15 X-ZEDAT-Hint: A X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1388259592-0000CD40-12E0C73E/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Dschibuti.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Dec 2013 19:39:54 -0000 This is a multi-part message in MIME format. --------------070205090702040404020906 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Am 28.12.2013 20:38, schrieb Thomas Arp: > Am 25.12.2013 20:59, schrieb Thomas Arp: >> Hi, >> > here is a new feature corresponding to my netmd integration patch. > This can be applied after patch #10. > Sorry, forgot to atach the file. --------------070205090702040404020906 Content-Type: text/x-patch; name="0012-netmd-support-add-unix-autodetection-during-applicat.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0012-netmd-support-add-unix-autodetection-during-applicat.pa"; filename*1="tch" >From fcf83dfaa1ead86397358129a0f1e7ec24c99fc8 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Sat, 28 Dec 2013 20:05:57 +0100 Subject: [PATCH 12/12] netmd support: add unix autodetection during application runtime, TODO: add unix himd device detection at application start --- netmd/etc/60-minidisc.rules | 116 ++++++++++++++++++++++++++++ netmd/etc/minidisc_notify.sh | 25 ++++++ qhimdtransfer/qhimdtransfer.pro | 5 ++ qhimdtransfer/qhimdunixdetection.cpp | 141 ++++++++++++++++++++++++++++++++++ qhimdtransfer/qhimdunixdetection.h | 71 +++++++++++++++++ 5 files changed, 358 insertions(+) create mode 100644 netmd/etc/60-minidisc.rules create mode 100644 netmd/etc/minidisc_notify.sh create mode 100644 qhimdtransfer/qhimdunixdetection.cpp create mode 100644 qhimdtransfer/qhimdunixdetection.h diff --git a/netmd/etc/60-minidisc.rules b/netmd/etc/60-minidisc.rules new file mode 100644 index 0000000..07ce8b4 --- /dev/null +++ b/netmd/etc/60-minidisc.rules @@ -0,0 +1,116 @@ +## Rules file for Minidisc devices +## based on source: https://usb-ids.gowdy.us/read/UD/054c +## last changed: 2013-12-28 + +# send message through session bus (needs qdbus to be installed), already running qhimdtransfer application will recieve this +# also needs minidisc_notify.sh to be installed in /etc/udev + +# check himd devices +# Sony MZ-NH1 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="017f", GOTO="notify" +# Sony MZ-NH3D +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0181", GOTO="notify" +# Sony MZ-NH900 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0183", GOTO="notify" +# Sony MZ-NH700 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0185", GOTO="notify" +# Sony MZ-NH600 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0187", GOTO="notify" +# Sony LAM-3 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="018a", GOTO="notify" +# Sony MZ-DH10P +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="01ea", GOTO="notify" +# Sony MZ-RH10 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="021a", GOTO="notify" +# Sony MZ-RH910 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="021c", GOTO="notify" +# Sony CMT-AH10 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="022d", GOTO="notify" +# Sony DS-HMD1 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="023d", GOTO="notify" +# Sony MZ-RH1 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0287", GOTO="notify" + +# check himd devices in netmd mode +# Sony MZ-NH1 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="017e", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony MZ-NH3D +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0180", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony MZ-NH900 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0182", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony MZ-NH700/800 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0184", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony MZ-NH600/600D +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0186", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony MZ-DH10P +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="01e9", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony MZ-RH10 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0219", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony MZ-RH910 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="021b", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony CMT-AH10 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="022c", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony DS-HMD1 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="023c", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony MZ-RH1 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0286", MODE="0664", GROUP="plugdev", GOTO="notify" + +# check netmd devices +# Aiwa AM-NX1 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0113", MODE="0664", GROUP="plugdev", GOTO="notify" +# Aiwa AM-NX9 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="014c", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sharp IM-MT880H/MT899H +ATTRS{idVendor}=="04dd", ATTRS{idProduct}=="7202", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sharp IM-DR400/DR410 +ATTRS{idVendor}=="04dd", ATTRS{idProduct}=="9013", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sharp IM-DR420/DR80/DR580 - Kenwood DMC-S9NET +ATTRS{idVendor}=="04dd", ATTRS{idProduct}=="9014", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony NetMD (unknown model) +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0036", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony NetMD MZ-N1 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0075", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony NetMD (unknown model) +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="007c", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony NetMD LAM-1 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0080", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony NetMD MDS-JE780/JB980 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0081", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony MZ-N505 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0084", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony NetMD MZ-S1 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0085", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony NetMD MZ-N707 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0086", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony MZ-N10 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="00c6", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony NetMD MZ-N910 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="00c7", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony NetMD MZ-N710/NF810/NE810 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="00c8", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony NetMD MZ-N510/NF610 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="00c9", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony MZ-N410/NF520D +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="00ca", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony NetMD MZ-NE810/NE910/DN430 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="00eb", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony NetMD LAM-10 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0101", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony MZ-N920 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0188", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony NetMD LAM-3 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="018a", MODE="0664", GROUP="plugdev", GOTO="notify" +# Sony NetMD CMT-AH10 +ATTRS{idVendor}=="054c", ATTRS{idProduct}=="021d", MODE="0664", GROUP="plugdev", GOTO="notify" + +# send all "remove" messages, some usb device specific remove messages does not contain idVendor/idProduct, +# corresponding device will be checked by qhimdtransfer +ACTION=="remove", RUN+="/etc/udev/minidisc_notify.sh" + +# end here if device is not a minidisc device +GOTO="minidisc_end" + +LABEL="notify" +RUN+="/etc/udev/minidisc_notify.sh" + +LABEL="minidisc_end" diff --git a/netmd/etc/minidisc_notify.sh b/netmd/etc/minidisc_notify.sh new file mode 100644 index 0000000..94bf138 --- /dev/null +++ b/netmd/etc/minidisc_notify.sh @@ -0,0 +1,25 @@ +#!/bin/sh -e + + case $ACTION in + add) + ACT=AddMDDevice + ;; + remove) + ACT=RemoveMDDevice + ;; + *) + ;; + esac + +# run as current user, else dbus message cannot be recieved +username=`who | head -n 1 | cut -d " " -f 1` +export HOME=/home/$username +export XAUTHORITY=$HOME/.Xauthority +export DISPLAY=:0.0 + +# convert vendor and product id to int +vid=$(echo $((0x$ID_VENDOR_ID))) +pid=$(echo $((0x$ID_MODEL_ID))) + +# send message to session bus +su $username -c "qdbus --session com.trolltech.Qt /QHiMDUnixDetection $ACT $DEVNAME $vid $pid" -m diff --git a/qhimdtransfer/qhimdtransfer.pro b/qhimdtransfer/qhimdtransfer.pro index 0fc2de1..e70230e 100644 --- a/qhimdtransfer/qhimdtransfer.pro +++ b/qhimdtransfer/qhimdtransfer.pro @@ -73,6 +73,11 @@ SOURCES += main.cpp \ qmdtrack.cpp \ qmddevice.cpp win32:SOURCES += qhimdwindetection.cpp +unix: { + HEADERS += qhimdunixdetection.h + SOURCES += qhimdunixdetection.cpp + QT += dbus +} else:SOURCES += qhimddummydetection.cpp RESOURCES += icons.qrc PKGCONFIG += sox \ diff --git a/qhimdtransfer/qhimdunixdetection.cpp b/qhimdtransfer/qhimdunixdetection.cpp new file mode 100644 index 0000000..3cb59c8 --- /dev/null +++ b/qhimdtransfer/qhimdunixdetection.cpp @@ -0,0 +1,141 @@ +#include "qhimdunixdetection.h" +#include +#include +#include + +QHiMDDetection * createDetection(QObject * parent) +{ + return new QHiMDUnixDetection(parent); +} + +QHiMDUnixDetection::QHiMDUnixDetection(QObject *parent) + : QHiMDDetection(parent), had(new QHiMDAdaptor(this)), + dbus_sys(QDBusConnection::connectToBus( QDBusConnection::SystemBus, "system" ) ), + dbus_ses(QDBusConnection::connectToBus(QDBusConnection::SessionBus, "com.trolltech.Qt")) +{ + if(!dbus_sys.isConnected()) + qDebug() << "cannot connect to system bus"; + if(!dbus_ses.isConnected()) + qDebug() << "cannot connect to session bus"; + + if(!dbus_ses.registerObject("/QHiMDUnixDetection", this, QDBusConnection::ExportAllSlots)) + qDebug() << "cannot register dbus interface object "; + + // register interface to session bus to make it visible to all other connections + dbus_ses.interface()->registerService("com.trolltech.Qt"); + dbus_ses.interface()->startService("com.trolltech.Qt"); + + // now connect method calls to our slots + QDBusConnection::sessionBus().connect("com.trolltech.Qt", "/com/trolltech/Qt/QHiMDUnixDetection", "com.trolltech.Qt", "AddMDDevice", this, SLOT(AddMDDevice(QString, int, int))); + QDBusConnection::sessionBus().connect("com.trolltech.Qt", "/com/trolltech/Qt/QHiMDUnixDetection", "com.trolltech.Qt", "RemoveMDDevice", this, SLOT(RemoveMDDevice(QString,int,int))); +} + +QVariant QHiMDUnixDetection::get_property(QString udiskPath, QString property, QString interface) +{ + QDBusMessage msg = QDBusMessage::createMethodCall(UDISK_SERVICE, udiskPath, UDISK_PROPERTIES, "Get"); + QVariant var; + QList args; + QDBusMessage reply; + + /* set arguments */ + args.append(interface); + args.append(property); + msg.setArguments(args); + + /* send message */ + reply = dbus_sys.call(msg); + + if (!reply.signature().compare(QString(QChar('v'))) && reply.arguments().length() >0) + var = reply.arguments().at(0); + else + return QVariant(); + + return var; +} + +QString QHiMDUnixDetection::mountpoint(QString devpath) +{ + QString udev_path = UDISK_DEVICE_PATH; + QVariant mp; + + // setup correct path for UDisk operations, just need sd* instead fo /dev/sd* + devpath.remove(0, devpath.lastIndexOf("/")+1); + udev_path.append(devpath); + + /* TODO: convert return value of get_property() in order to extract needed data, the returned value is marked as INVALID and cannot be converted, + * it should contain something like this (this is a sample of what qdbusviewer returns, here: "/media/man2/disk"): + * Arguments: [Variant: [Argument: aay {{47, 109, 101, 100, 105, 97, 47, 109, 97, 110, 50, 47, 100, 105, 115, 107, 0}}]] + * so we have to convert the udev "aay" format (array of filepaths) to something readable + */ + mp = get_property(udev_path, PROP_MOUNTPATH, UDISK_FILESYSTEM); + return mp.toString(); +} + +void QHiMDUnixDetection::AddMDDevice(QString deviceFile, int vid, int pid) +{ + QString mountpt; + QString name = QString(identify_usb_device(vid, pid)); + + // check if this is valid minidisc device depending on vendor and product id, for all known devices identify_usb_device() should return a name + if(name.isEmpty()) + return; + + /* check if it is a netmd device, reenumerate netmd devices at this point to make libnetmd find it + */ + if(name.contains("NetMD")) + { + qDebug() << "qhimdtransfer detection: netmd device detected: " + name; + QThread::msleep(5000); // wait for TOC to be loaded by the device, else tracklist may not be shown correctly (no tiltles, unknown codec etc.) + rescan_netmd_devices(); + return; + } + + // check if driver file is /dev/sd*, this is what we need, for future use (formating etc.) also check for /dev/sg* scsi driver file + if(!deviceFile.startsWith("/dev/sd")) + return; + + + qDebug() << QString("qhimdtransfer detection: himd device detected at %1: %2").arg(deviceFile).arg(name); + + // wait for device to be mounted by polling for mountpoint, this could take some time + // break if mount process did not finish within 30 seconds + for(int i = 0; i < 30; i++) + { + QThread::msleep(1000); + QApplication::processEvents(); // prevent application to be blocked completely + if(!(mountpt = mountpoint(deviceFile)).isEmpty()) + break; + } + qDebug() << (mountpt.isEmpty() ? "no mountpoint detected" : QString("device mounted at: %1").arg(mountpt)); + + /* TODO: add new QHiMDDevice object to device list here, + * as mountpoint() function does not work correctly yet, this cannot be done at current stage of the code + */ + +} + +void QHiMDUnixDetection::RemoveMDDevice(QString deviceFile, int vid, int pid) +{ + QString name = QString(identify_usb_device(vid, pid)); + + // check if this is valid minidisc device, for all known devices identify_usb_device() should return a name + if(name.isEmpty()) + return; + + if(name.contains("NetMD")) + { + qDebug() << "qhimdtransfer detection: netmd device removed: " + name; + rescan_netmd_devices(); + return; + } + + // check if driver file is /dev/sd*, this is what we need, for future use (formating etc.) also check for /dev/sg* scsi driver file + if(!deviceFile.startsWith("/dev/sd")) + return; + + qDebug() << QString("qhimdtransfer detection: himd device removed at %1: %2").arg(deviceFile).arg(name); + + /* TODO: remove corresponding QHiMDDevice object from device list here */ + +} + diff --git a/qhimdtransfer/qhimdunixdetection.h b/qhimdtransfer/qhimdunixdetection.h new file mode 100644 index 0000000..74e0fe9 --- /dev/null +++ b/qhimdtransfer/qhimdunixdetection.h @@ -0,0 +1,71 @@ +#ifndef QHIMDUNIXDETECTION_H +#define QHIMDUNIXDETECTION_H + +#include +#include + +/* define constants for udev */ +#define UDISK_SERVICE "org.freedesktop.UDisks2" +#define UDISK_PATH "/org/freedesktop/UDisks2" +#define UDISK_INTERFACE "org.freedesktop.UDisks2" +#define UDISK_PROPERTIES "org.freedesktop.DBus.Properties" +#define UDISK_FILESYSTEM "org.freedesktop.UDisks2.Filesystem" +#define UDISK_DEVICE_PATH "/org/freedesktop/UDisks2/block_devices/" + +#define PROP_MOUNTPATH "MountPoints" + + +/* qhimdtransfer adaptor class, can be accessed through dbus session bus with + * service=com.trolltech.Qt + * path=/QHiMDUnixDetection + * interface=com.trolltech.Qt.QHiMDUnixDetection + * + * following methods provided + * "AddMDDevice" and "RemoveMDDevice" + * with args: QString deviceFile, int vid, int pid + */ +class QHiMDAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "com.trolltech.Qt") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") +public: + QHiMDAdaptor(QObject *parent) : QDBusAbstractAdaptor(parent) {} + virtual ~QHiMDAdaptor() {} +}; + + +class QHiMDUnixDetection : public QHiMDDetection{ + Q_OBJECT + + QHiMDAdaptor *had; + QDBusConnection dbus_sys; // system bus connection: needed for getting mountpoint + QDBusConnection dbus_ses; // session bus connection: needed for providing method calls AddMDDevice and RemoveMDDevice + +public: + QHiMDUnixDetection(QObject * parent = NULL); + ~QHiMDUnixDetection() {} + +private: + QVariant get_property(QString udiskPath, QString property, QString interface); + QString mountpoint(QString devpath); + +public slots: + void AddMDDevice(QString deviceFile, int vid, int pid); + void RemoveMDDevice(QString deviceFile, int vid, int pid); +}; + +#endif // QHIMDUNIXDETECTION_H -- 1.7.10.4 --------------070205090702040404020906-- From manner.moe@gmx.de Sun Dec 29 16:32:19 2013 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by list1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VxILh-002oI9-G9>; Sun, 29 Dec 2013 16:32:17 +0100 Received: from mout.gmx.net ([212.227.17.21]) by relay1.zedat.fu-berlin.de (Exim 4.82) for linux-minidisc@lists.fu-berlin.de with esmtp (envelope-from ) id <1VxILh-002x5a-Ce>; Sun, 29 Dec 2013 16:32:17 +0100 Received: from [192.168.2.100] ([82.83.146.180]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0MK0Np-1VyfvO2u4z-001OZS for ; Sun, 29 Dec 2013 16:32:16 +0100 Message-ID: <52C0407E.5050709@gmx.de> Date: Sun, 29 Dec 2013 16:32:14 +0100 From: Thomas Arp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "linux-minidisc@lists.fu-berlin.de" References: <52B0E208.7090904@gmx.de> <52B0E324.6090408@physik.fu-berlin.de> <52B0E89D.70805@gmx.de> <52B0F78B.3040504@gmx.de> <52B48F66.1090600@gmx.de> <52B4AEA2.7040506@physik.fu-berlin.de> <52B5C351.8000801@gmx.de> <52B5E60B.7030603@physik.fu-berlin.de> <52B60813.10509@gmx.de> <52B60A05.7060206@physik.fu-berlin.de> <52B60D00.2000200@gmx.de> <52B60FDA.7080102@physik.fu-berlin.de> <52B73D5D.7010509@gmx.de> <52BB390B.2080006@gmx.de> <52BF28A8.7030005@gmx.de> In-Reply-To: <52BF28A8.7030005@gmx.de> Content-Type: multipart/mixed; boundary="------------010306020602090402050400" X-Provags-ID: V03:K0:kVFdI67ZoBKnX94MqKHf0I+gDUqW/g5DUX6H8Szh28ykGJ052sT 6+oXXD30io8hCtpQuibALJE95Ozut9jMZNnv4JvdAzIYcI7bL9wT/BzQwRFZAoTRNFq+H9J bvDl3ppDnWD2G2aDAt7q9zVJqc5j0LYYc5q6BPe0L9RMNJmrwJEf0fm3zOEMmedxDXLM96C 9yDgeDFZUtgrCsPAzRkVw== X-Originating-IP: 212.227.17.21 X-ZEDAT-Hint: A X-purgate: clean X-purgate-type: clean X-purgate-ID: 151147::1388331137-0000CD40-747E88B1/0/0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-Spam-Flag: NO X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Checker-Version: SpamAssassin 3.3.3-zedat0a54d5a on Gabun.ZEDAT.FU-Berlin.DE X-Spam-Level: Subject: Re: [linux-minidisc] netmd support for qhimdtransfer gui application X-BeenThere: linux-minidisc@lists.fu-berlin.de X-Mailman-Version: 2.1.16 Precedence: list List-Id: Mailing list for the linux-minidisc project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Dec 2013 15:32:19 -0000 This is a multi-part message in MIME format. --------------010306020602090402050400 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Am 28.12.2013 20:38, schrieb Thomas Arp: > Am 25.12.2013 20:59, schrieb Thomas Arp: >> Hi, >> > here is a new feature corresponding to my netmd integration patch. > This can be applied after patch #10. > > I know, my patch is not reviewed jet, but i just want this to be added > to the "to review list". > > This includes unix netmd and himd autotetection during application > runtime (netmd autodetection at application start is already > implemented). > Himd autodetection at application start is missing yet, also himd > autodetection during application runtime does not work correctly. > The detection works, but not the function getting the mountpoint. > I can fetch the mountpoint for the detected device from UDisks2 > through dbus but the value returned cannot be converted yet (see > comments in the files). > > Thomas > > O.K., I fixed the function for getting the mountpoint, only himd detection at application start is missing now. By examining the qdbusviewer and qdbus source codes, i implemented functions that can convert a QVariant to a QString if the QVariant cannot be converted automatically (unknown/unsupported value). Patch can be applied after the last patch #12 Thomas --------------010306020602090402050400 Content-Type: text/x-patch; name="0013-unix-autodetection-fixed-getting-mountpoit-function-.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0013-unix-autodetection-fixed-getting-mountpoit-function-.pa"; filename*1="tch" >From beb071d936e18c815d7f837f63e80e0638f68b40 Mon Sep 17 00:00:00 2001 From: Thomas Arp Date: Sun, 29 Dec 2013 16:22:52 +0100 Subject: [PATCH 13/13] unix autodetection: fixed getting mountpoit function for himd devices --- netmd/etc/minidisc_notify.sh | 4 +- qhimdtransfer/qhimddetection.cpp | 1 + qhimdtransfer/qhimdunixdetection.cpp | 181 ++++++++++++++++++++++++++++------ qhimdtransfer/qhimdunixdetection.h | 3 + qhimdtransfer/qmddevice.cpp | 13 +++ qhimdtransfer/qmddevice.h | 5 +- 6 files changed, 172 insertions(+), 35 deletions(-) diff --git a/netmd/etc/minidisc_notify.sh b/netmd/etc/minidisc_notify.sh index 94bf138..cd714a5 100644 --- a/netmd/etc/minidisc_notify.sh +++ b/netmd/etc/minidisc_notify.sh @@ -21,5 +21,5 @@ export DISPLAY=:0.0 vid=$(echo $((0x$ID_VENDOR_ID))) pid=$(echo $((0x$ID_MODEL_ID))) -# send message to session bus -su $username -c "qdbus --session com.trolltech.Qt /QHiMDUnixDetection $ACT $DEVNAME $vid $pid" -m +# send message to session bus, do not wait for a reply !!! +su $username -c "qdbus --session com.trolltech.Qt /QHiMDUnixDetection $ACT $DEVNAME $vid $pid &" -m diff --git a/qhimdtransfer/qhimddetection.cpp b/qhimdtransfer/qhimddetection.cpp index e73dc03..fc893ba 100644 --- a/qhimdtransfer/qhimddetection.cpp +++ b/qhimdtransfer/qhimddetection.cpp @@ -84,6 +84,7 @@ void QHiMDDetection::scan_for_minidisc_devices() QHiMDDevice * mddev = new QHiMDDevice(); mddev->setMdInserted(true); mddev->setName("disc image"); + mddev->setDeviceFile(QString()); dlist.append(mddev); emit deviceListChanged(dlist); diff --git a/qhimdtransfer/qhimdunixdetection.cpp b/qhimdtransfer/qhimdunixdetection.cpp index 3cb59c8..454a5bb 100644 --- a/qhimdtransfer/qhimdunixdetection.cpp +++ b/qhimdtransfer/qhimdunixdetection.cpp @@ -1,6 +1,8 @@ #include "qhimdunixdetection.h" #include #include +#include +#include #include QHiMDDetection * createDetection(QObject * parent) @@ -8,18 +10,82 @@ QHiMDDetection * createDetection(QObject * parent) return new QHiMDUnixDetection(parent); } +/* following static functions are stolen from qtdbusutil.cpp, return value of get_property() for the mountpoint is an array of QByteArrays, + * cropped unneeded parts, characters and spaces here and changed the output character type from QString::number() to QChar + * */ +static bool argToString(const QDBusArgument &busArg, QString &out); + +static bool variantToString(const QVariant &arg, QString &out) +{ + int argType = arg.userType(); + + if (argType == QVariant::ByteArray) + { + QByteArray list = arg.toByteArray(); + for (int i = 0; i < list.count(); ++i) + out += QChar(list.at(i)); + } + else if (argType == qMetaTypeId()) + { + argToString(qvariant_cast(arg), out); + } + else if (argType == qMetaTypeId()) + { + const QVariant v = qvariant_cast(arg).variant(); + + if (!variantToString(v, out)) + return false; + } + return true; +} + +static bool argToString(const QDBusArgument &busArg, QString &out) +{ + bool doIterate = false; + QDBusArgument::ElementType elementType = busArg.currentType(); + + switch (elementType) + { + case QDBusArgument::BasicType: + case QDBusArgument::VariantType: + if (!variantToString(busArg.asVariant(), out)) + return false; + break; + case QDBusArgument::ArrayType: + busArg.beginArray(); + doIterate = true; + break; + case QDBusArgument::UnknownType: + default: + return false; + } + + if (doIterate && !busArg.atEnd()) { + while (!busArg.atEnd()) { + if (!argToString(busArg, out)) + return false; + out += QLatin1String(" , "); + } + out.chop(3); + } + + if(elementType == QDBusArgument::ArrayType) + busArg.endArray(); + return true; +} + QHiMDUnixDetection::QHiMDUnixDetection(QObject *parent) : QHiMDDetection(parent), had(new QHiMDAdaptor(this)), dbus_sys(QDBusConnection::connectToBus( QDBusConnection::SystemBus, "system" ) ), dbus_ses(QDBusConnection::connectToBus(QDBusConnection::SessionBus, "com.trolltech.Qt")) { if(!dbus_sys.isConnected()) - qDebug() << "cannot connect to system bus"; + qDebug() << tr("cannot connect to system bus"); if(!dbus_ses.isConnected()) - qDebug() << "cannot connect to session bus"; + qDebug() << tr("cannot connect to session bus"); if(!dbus_ses.registerObject("/QHiMDUnixDetection", this, QDBusConnection::ExportAllSlots)) - qDebug() << "cannot register dbus interface object "; + qDebug() << tr("cannot register dbus interface object "); // register interface to session bus to make it visible to all other connections dbus_ses.interface()->registerService("com.trolltech.Qt"); @@ -33,7 +99,6 @@ QHiMDUnixDetection::QHiMDUnixDetection(QObject *parent) QVariant QHiMDUnixDetection::get_property(QString udiskPath, QString property, QString interface) { QDBusMessage msg = QDBusMessage::createMethodCall(UDISK_SERVICE, udiskPath, UDISK_PROPERTIES, "Get"); - QVariant var; QList args; QDBusMessage reply; @@ -46,29 +111,83 @@ QVariant QHiMDUnixDetection::get_property(QString udiskPath, QString property, Q reply = dbus_sys.call(msg); if (!reply.signature().compare(QString(QChar('v'))) && reply.arguments().length() >0) - var = reply.arguments().at(0); + return reply.arguments().at(0); else return QVariant(); - - return var; } QString QHiMDUnixDetection::mountpoint(QString devpath) { QString udev_path = UDISK_DEVICE_PATH; - QVariant mp; + QVariant ret; + QString mp; // setup correct path for UDisk operations, just need sd* instead fo /dev/sd* devpath.remove(0, devpath.lastIndexOf("/")+1); udev_path.append(devpath); - /* TODO: convert return value of get_property() in order to extract needed data, the returned value is marked as INVALID and cannot be converted, - * it should contain something like this (this is a sample of what qdbusviewer returns, here: "/media/man2/disk"): - * Arguments: [Variant: [Argument: aay {{47, 109, 101, 100, 105, 97, 47, 109, 97, 110, 50, 47, 100, 105, 115, 107, 0}}]] - * so we have to convert the udev "aay" format (array of filepaths) to something readable + ret = get_property(udev_path, PROP_MOUNTPATH, UDISK_FILESYSTEM); + if(!ret.isValid()) + return QString(); + + /* try to read mountpoint as string + * as this is an array of /0 terminatined ByteArrays it returns first mointpoint only because of the terminating /0 character + * this is fine for now and matches our needs */ - mp = get_property(udev_path, PROP_MOUNTPATH, UDISK_FILESYSTEM); - return mp.toString(); + if(!variantToString(ret, mp)) + return QString(); + + return mp; +} + +QMDDevice *QHiMDUnixDetection::find_by_deviceFile(QString file) +{ + QMDDevice * mddev; + + foreach(mddev, dlist) + { + if(mddev->deviceFile() == file) + return mddev; + } + return NULL; +} + +void QHiMDUnixDetection::add_himddevice(QString file, QString path, QString name) +{ + if (find_by_deviceFile(file)) + return; + + QHiMDDevice * new_device = new QHiMDDevice(); + + new_device->setDeviceFile(file); + new_device->setBusy(false); + new_device->setPath(path); + new_device->setName(name); + new_device->setMdInserted(true); + + dlist.append(new_device); + emit deviceListChanged(dlist); +} + +void QHiMDUnixDetection::remove_himddevice(QString file) +{ + int index = -1; + QMDDevice * dev; + + if (!(dev = find_by_deviceFile(file))) + return; + + index = dlist.indexOf(dev); + + if(dev->isOpen()) + dev->close(); + + delete dev; + dev = NULL; + + dlist.removeAt(index); + + emit deviceListChanged(dlist); } void QHiMDUnixDetection::AddMDDevice(QString deviceFile, int vid, int pid) @@ -84,8 +203,8 @@ void QHiMDUnixDetection::AddMDDevice(QString deviceFile, int vid, int pid) */ if(name.contains("NetMD")) { - qDebug() << "qhimdtransfer detection: netmd device detected: " + name; - QThread::msleep(5000); // wait for TOC to be loaded by the device, else tracklist may by shown correctly (no tiltles, unknown codec etc.) + qDebug() << tr("qhimdtransfer detection: netmd device detected: %1").arg(name); + QThread::msleep(5000); // wait for TOC to be loaded by the device, else tracklist may not by shown correctly (no tiltles, unknown codec etc.) rescan_netmd_devices(); return; } @@ -94,23 +213,22 @@ void QHiMDUnixDetection::AddMDDevice(QString deviceFile, int vid, int pid) if(!deviceFile.startsWith("/dev/sd")) return; + qDebug() << tr("qhimdtransfer detection: himd device detected at %1: %2").arg(deviceFile).arg(name); - qDebug() << QString("qhimdtransfer detection: himd device detected at %1: %2").arg(deviceFile).arg(name); - - // wait for device to be mounted by polling for mountpoint, this could take some time - // break if mount process did not finish within 30 seconds - for(int i = 0; i < 30; i++) + // wait for device to be mounted by polling for mountpoint, break if mount process takes too long + for(int i = 0; i < 20; i++) { - QThread::msleep(1000); - QApplication::processEvents(); // prevent application to be blocked completely + QApplication::processEvents(); // prevent application from beeing blocked + QThread::sleep(1); if(!(mountpt = mountpoint(deviceFile)).isEmpty()) - break; + break; } - qDebug() << (mountpt.isEmpty() ? "no mountpoint detected" : QString("device mounted at: %1").arg(mountpt)); - /* TODO: add new QHiMDDevice object to device list here, - * as mountpoint() function does not work correctly yet, this cannot be done at current stage of the code - */ + // if mountpoint detection fails return, alternatively ask user to provide mountpoint with a QFileDialog + if(mountpt.isEmpty()) + return; + + add_himddevice(deviceFile,mountpt,name); } @@ -124,7 +242,7 @@ void QHiMDUnixDetection::RemoveMDDevice(QString deviceFile, int vid, int pid) if(name.contains("NetMD")) { - qDebug() << "qhimdtransfer detection: netmd device removed: " + name; + qDebug() << tr("qhimdtransfer detection: netmd device removed: ").arg(name); rescan_netmd_devices(); return; } @@ -133,9 +251,8 @@ void QHiMDUnixDetection::RemoveMDDevice(QString deviceFile, int vid, int pid) if(!deviceFile.startsWith("/dev/sd")) return; - qDebug() << QString("qhimdtransfer detection: himd device removed at %1: %2").arg(deviceFile).arg(name); - - /* TODO: remove corresponding QHiMDDevice object from device list here */ + qDebug() << tr("qhimdtransfer detection: himd device removed at %1: %2").arg(deviceFile).arg(name); + remove_himddevice(deviceFile); } diff --git a/qhimdtransfer/qhimdunixdetection.h b/qhimdtransfer/qhimdunixdetection.h index 74e0fe9..c6e198b 100644 --- a/qhimdtransfer/qhimdunixdetection.h +++ b/qhimdtransfer/qhimdunixdetection.h @@ -62,6 +62,9 @@ public: private: QVariant get_property(QString udiskPath, QString property, QString interface); QString mountpoint(QString devpath); + QMDDevice *find_by_deviceFile(QString file); + void add_himddevice(QString file, QString path, QString name); + virtual void remove_himddevice(QString file); public slots: void AddMDDevice(QString deviceFile, int vid, int pid); diff --git a/qhimdtransfer/qmddevice.cpp b/qhimdtransfer/qmddevice.cpp index 35e01a8..3f60cb3 100644 --- a/qhimdtransfer/qmddevice.cpp +++ b/qhimdtransfer/qmddevice.cpp @@ -36,6 +36,17 @@ QString QMDDevice::path() return device_path; } +void QMDDevice::setDeviceFile(QString file) +{ + device_file = file; +} + +QString QMDDevice::deviceFile() +{ + return device_file; +} + + void QMDDevice::setName(QString name) { recorder_name = name; @@ -119,6 +130,7 @@ void QMDDevice::checkfile(QString UploadDirectory, QString &filename, QString ex QNetMDDevice::QNetMDDevice() { dev_type = NETMD_DEVICE; + device_file = QString(); devh = NULL; netmd = NULL; is_open = false; @@ -354,6 +366,7 @@ void QNetMDDevice::batchUpload(QMDTrackIndexList tlist, QString path) QHiMDDevice::QHiMDDevice() { dev_type = HIMD_DEVICE; + device_file = QString(); himd = NULL; is_open = false; } diff --git a/qhimdtransfer/qmddevice.h b/qhimdtransfer/qmddevice.h index c413f9c..ef9974e 100644 --- a/qhimdtransfer/qmddevice.h +++ b/qhimdtransfer/qmddevice.h @@ -21,6 +21,7 @@ class QMDDevice : public QObject { bool is_busy; protected: QString device_path; + QString device_file; enum device_type dev_type; bool is_open; unsigned int trk_count; @@ -32,8 +33,10 @@ public: explicit QMDDevice(); virtual ~QMDDevice(); virtual enum device_type deviceType(); - virtual void setPath(QString path); + virtual void setPath(QString path); virtual QString path(); + virtual void setDeviceFile(QString file); + virtual QString deviceFile(); virtual void setName(QString name); virtual QString name(); virtual void setBusy(bool busy); -- 1.7.10.4 --------------010306020602090402050400--