Hello community, here is the log from the commit of package imagewriter for openSUSE:Factory checked in at 2012-11-14 16:38:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/imagewriter (Old) and /work/SRC/openSUSE:Factory/.imagewriter.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "imagewriter", Maintainer is "" Changes: -------- --- /work/SRC/openSUSE:Factory/imagewriter/imagewriter.changes 2012-07-18 11:47:32.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.imagewriter.new/imagewriter.changes 2012-11-14 16:38:44.000000000 +0100 @@ -1,0 +2,5 @@ +Wed Nov 14 13:58:41 UTC 2012 - mbarrin...@suse.com + +- Updating to 1.10, which adds support for udisks2 + +------------------------------------------------------------------- Old: ---- imagewriter-1.9.tar.gz imagewriter-desktop-menu-exec.patch imagewriter-gcc47.patch New: ---- imagewriter-1.10.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ imagewriter.spec ++++++ --- /var/tmp/diff_new_pack.hnRAei/_old 2012-11-14 16:38:45.000000000 +0100 +++ /var/tmp/diff_new_pack.hnRAei/_new 2012-11-14 16:38:45.000000000 +0100 @@ -7,52 +7,72 @@ # # needsrootforbuild -Url: http://kiwi.berlios.de +Url: https://github.com/mbarringer/imagewriter Name: imagewriter BuildRequires: gcc-c++ -%if 0%{?fedora_version} +%if 0%{?rhel_version} == 600 + %define dist el6 + %define breq qt-devel + %define backend hal-devel + %define qmake /usr/bin/qmake-qt4 + %define lrelease /usr/bin/lrelease-qt4 + %define definedbackend USEHAL +%endif + +%if 0%{?fedora} %define breq qt4-devel + %define backend udisks2 %define qmake /usr/bin/qmake-qt4 %define lrelease /usr/bin/lrelease-qt4 -BuildRequires: hal-devel + %define definedbackend USEUDISKS2 %endif + %if 0%{?mandriva_version} %define breq libqt4-devel + %define backend hal-devel %define qmake /usr/lib/qt4/bin/qmake %define lrelease /usr/lib/qt4/bin/lrelease -BuildRequires: hal-devel + %define definedbackend USEHAL %endif + %if 0%{?suse_version} %define breq libqt4-devel update-desktop-files %define qmake /usr/bin/qmake %define lrelease /usr/bin/lrelease %endif -%if 0%{?suse_version} < 1130 -BuildRequires: hal-devel +%if 0%{?suse_version} <= 1130 + %define backend hal-devel + %define definedbackend USEHAL +%endif + +%if 0%{?suse_version} == 1140 || 0%{?suse_version} == 1210 + %define backend udisks + %define definedbackend USEUDISKS +%endif + +%if 0%{?suse_version} >= 1220 + %define backend udisks2 + %define definedbackend USEUDISKS2 %endif -Summary: SUSE Studio Imagewriter -Version: 1.9 +Summary: SUSE Imagewriter +Version: 1.10 Release: 0 Group: Hardware/Other License: GPL-2.0 Source: imagewriter-%{version}.tar.gz -Patch0: imagewriter-gcc47.patch -Patch1: imagewriter-desktop-menu-exec.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: %{breq} +BuildRequires: %{breq} %{backend} %description -Graphical image writer application +A graphical utility for writing raw disk images & hybrid isos to USB keys %prep %setup -%patch0 -p1 -%patch1 -p1 %build -%{qmake} PREFIX=$RPM_BUILD_ROOT/%{_prefix} imagewriter.pro +%{qmake} PREFIX=$RPM_BUILD_ROOT/%{_prefix} DEFINES=%{definedbackend} imagewriter.pro make buildroot=$RPM_BUILD_ROOT CFLAGS="$RPM_OPT_FLAGS -DKIOSKHACK" %install ++++++ imagewriter-1.9.tar.gz -> imagewriter-1.10.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/MainWindow.cpp new/imagewriter-1.10/MainWindow.cpp --- old/imagewriter-1.9/MainWindow.cpp 2011-04-06 16:20:28.000000000 +0200 +++ new/imagewriter-1.10/MainWindow.cpp 2012-11-14 15:00:02.000000000 +0100 @@ -27,11 +27,15 @@ #include <QProgressDialog> #include <QtDBus> #include <QFile> +#include <QDebug> #include <unistd.h> #include <sys/types.h> #include <sys/sysctl.h> +#ifdef USEUDISKS2 +#include "udisks2_interface.h" +#endif #include "MainWindow.h" @@ -86,7 +90,16 @@ "DeviceRemoved", this, SLOT(deviceRemoved(QDBusMessage))); +#elif USEUDISKS2 + qDebug() << "Using udisks2"; + org::freedesktop::DBus::ObjectManager manager("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2", QDBusConnection::systemBus()); + QDBusConnection::systemBus().connect("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2", "org.freedesktop.DBus.ObjectManager", "InterfacesAdded", + this, SLOT(deviceInserted(QDBusObjectPath,QVariantMapMap))); + QDBusConnection::systemBus().connect("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2", "org.freedesktop.DBus.ObjectManager", "InterfacesRemoved", + this, SLOT(deviceRemoved(QDBusObjectPath,QStringList))); + #else + qDebug() << "Using udisks"; dbusConnection.connect("", "/org/freedesktop/UDisks", "org.freedesktop.UDisks", @@ -313,6 +326,61 @@ return(true); } +// UDisks2 insertion handler +void MainWindow::deviceInserted(const QDBusObjectPath &object_path, + const QVariantMapMap &interfaces_and_properties) +{ + Q_UNUSED(interfaces_and_properties); + + QRegExp reg("[0-9]+$"); + QString path = object_path.path(); + + if (!path.startsWith("/org/freedesktop/UDisks2/block_devices")) + return; + + if (path.contains(reg)) + return; + + DeviceItem *device = pPlatform->getNewDevice(path); + if (device != NULL) + if (deviceComboBox->findText(device->getDisplayString()) == -1) + addMenuItem(device->getDisplayString()); + +} + +// UDisks2 removal handler +void MainWindow::deviceRemoved(const QDBusObjectPath &object_path, + const QStringList &interfaces) +{ + Q_UNUSED(interfaces); + + QRegExp reg("[0-9]+$"); + QString path = object_path.path(); + + if (!path.startsWith("/org/freedesktop/UDisks2/block_devices")) + return; + + if (path.contains(reg)) + return; + + QString udi = path.mid(path.lastIndexOf("/") + 1); + QLinkedList<DeviceItem *> list = pPlatform->getDeviceList(); + QLinkedList<DeviceItem *>::iterator i; + for (i = list.begin(); i != list.end(); ++i) + { + if ((*i)->getUDI() == udi) + { + if (removeMenuItem((*i)->getDisplayString()) != -1) + { + pPlatform->removeDeviceFromList(path); + break; + } + } + } + +} + +// UDisks & HAL insertion handler void MainWindow::deviceInserted(QDBusMessage message) { @@ -333,10 +401,10 @@ } } +// UDisks & HAL removal handler void MainWindow::deviceRemoved(QDBusMessage message) { - int index; QString devicePath; #ifdef USEHAL devicePath = message.arguments().at(0).toString(); @@ -554,22 +622,25 @@ void AboutLabel::mousePressEvent(QMouseEvent *event) { + Q_UNUSED(event); QMessageBox about(QMessageBox::Information, "About SUSE Studio Imagewriter", - "The <b>SUSE Studio Imagewriter</b> is (C) 2010 Novell, Inc.<br><br>\ - It is cheerfully released under the GPL v2 license. You can find the source code in the Kiwi project: http://kiwi.berlios.de.<br><br>\ - It was written by Matt Barringer <mbarrin...@suse.de>. Please send complaints directly to him."); + "The <b>SUSE Studio Imagewriter</b> is (C) 2012, SUSE Linux Products GmbH<br><br>\ + It is cheerfully released under the GPL v2 license. You can find the source code on github: https://github.com/mbarringer/imagewriter<br><br>\ + It was written by Matt Barringer <m...@incoherent.de>. Please send complaints directly to him."); about.exec(); } void AboutLabel::enterEvent(QEvent *event) { + Q_UNUSED(event); setCursor(Qt::PointingHandCursor); } void AboutLabel::leaveEvent(QEvent *event) { + Q_UNUSED(event); setCursor(Qt::ArrowCursor); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/MainWindow.h new/imagewriter-1.10/MainWindow.h --- old/imagewriter-1.9/MainWindow.h 2011-04-06 16:20:28.000000000 +0200 +++ new/imagewriter-1.10/MainWindow.h 2012-11-14 15:00:02.000000000 +0100 @@ -28,8 +28,10 @@ #include <QWidget> #include <QDBusMessage> +#include "MetaTypes.h" #include "Platform.h" #include "DeviceItem.h" + #define DROPDOWN_DIRECTIVE "Insert a USB device" class MainWindow : public QWidget @@ -48,6 +50,8 @@ void selectImage(); void deviceInserted(QDBusMessage message); void deviceRemoved(QDBusMessage message); + void deviceInserted(const QDBusObjectPath &object_path, const QVariantMapMap &interfaces_and_properties); + void deviceRemoved(const QDBusObjectPath &object_path, const QStringList &interfaces); private slots: void write(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/MetaTypes.h new/imagewriter-1.10/MetaTypes.h --- old/imagewriter-1.9/MetaTypes.h 1970-01-01 01:00:00.000000000 +0100 +++ new/imagewriter-1.10/MetaTypes.h 2012-11-14 15:00:02.000000000 +0100 @@ -0,0 +1,16 @@ +#ifndef METATYPES_H +#define METATYPES_H + +#include <QtCore> +#include <QtDBus> + +typedef QMap<QString,QVariantMap> QVariantMapMap; +Q_DECLARE_METATYPE(QVariantMapMap) + +typedef QMap<QDBusObjectPath, QVariantMapMap> DBUSManagerStruct; +Q_DECLARE_METATYPE(DBUSManagerStruct) + +typedef QList<QByteArray> ByteArrayList; +Q_DECLARE_METATYPE(ByteArrayList) + +#endif // METATYPES_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/Platform.cpp new/imagewriter-1.10/Platform.cpp --- old/imagewriter-1.9/Platform.cpp 2011-04-06 16:20:28.000000000 +0200 +++ new/imagewriter-1.10/Platform.cpp 2012-11-14 15:00:02.000000000 +0100 @@ -5,15 +5,18 @@ #include <sys/mount.h> #include <sys/types.h> #include <sys/stat.h> +#include <unistd.h> + #include <fcntl.h> #include <errno.h> #define BLOCKSIZE 1048576 #define _GNU_SOURCE -Platform::Platform(bool kioskMode) +Platform::Platform(bool kioskMode, bool unsafe) { mKioskMode = kioskMode; + mUnsafe = unsafe; } bool diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/Platform.h new/imagewriter-1.10/Platform.h --- old/imagewriter-1.9/Platform.h 2011-04-06 16:20:28.000000000 +0200 +++ new/imagewriter-1.10/Platform.h 2012-11-14 15:00:02.000000000 +0100 @@ -33,18 +33,19 @@ { public: - Platform(bool kioskMode = false); + Platform(bool kioskMode = false, bool unsafe = false); bool removeDeviceFromList(const QString &displayName); DeviceItem *findDeviceInList(const QString &displayName); void writeData(QString path, QString fileName, qint64 deviceSize); QLinkedList<DeviceItem *> getDeviceList() { return itemList; } - virtual void findDevices(bool unsafe = false) {} - virtual bool isMounted(QString path) { return false; } - virtual bool unmountDevice(QString path) { return false; } - virtual DeviceItem *getNewDevice(QString devicePath) { return(NULL); } + virtual void findDevices() {} + virtual bool isMounted(QString path) { Q_UNUSED(path); return false; } + virtual bool unmountDevice(QString path) { Q_UNUSED(path); return false; } + virtual DeviceItem *getNewDevice(QString devicePath) { Q_UNUSED(devicePath); return(NULL); } protected: + bool mUnsafe; bool mKioskMode; DeviceItem *pDevice; QLinkedList<DeviceItem *> itemList; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/PlatformHal.cpp new/imagewriter-1.10/PlatformHal.cpp --- old/imagewriter-1.9/PlatformHal.cpp 2011-04-06 16:20:28.000000000 +0200 +++ new/imagewriter-1.10/PlatformHal.cpp 2012-11-14 15:00:02.000000000 +0100 @@ -31,14 +31,14 @@ #include "DeviceItem.h" #include "PlatformHal.h" -PlatformHal::PlatformHal(bool kioskMode) - : Platform(kioskMode) +PlatformHal::PlatformHal(bool kioskMode, bool unsafe) + : Platform(kioskMode, unsafe) { } // Figure out which devices we should allow a user to write to. void -PlatformHal::findDevices(bool unsafe) +PlatformHal::findDevices() { char **drives; int drive_count, i; @@ -56,7 +56,7 @@ // We want to only write to USB drives, unless the user specifies // the unsafe flag on the command line - if (unsafe) + if (mUnsafe) drives = libhal_manager_find_device_string_match(context, "storage.drive_type", "disk", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/PlatformHal.h new/imagewriter-1.10/PlatformHal.h --- old/imagewriter-1.9/PlatformHal.h 2011-04-06 16:20:28.000000000 +0200 +++ new/imagewriter-1.10/PlatformHal.h 2012-11-14 15:00:02.000000000 +0100 @@ -38,8 +38,8 @@ { public: - PlatformHal(bool kioskMode = false); - void findDevices(bool unsafe = false); + PlatformHal(bool kioskMode = false, bool unsafe = false); + void findDevices(); bool isMounted(QString path); void writeData(QString path, QString fileName, qint64 deviceSize); bool unmountDevice(QString path); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/PlatformUdisks.cpp new/imagewriter-1.10/PlatformUdisks.cpp --- old/imagewriter-1.9/PlatformUdisks.cpp 2011-04-06 16:20:28.000000000 +0200 +++ new/imagewriter-1.10/PlatformUdisks.cpp 2012-11-14 15:00:02.000000000 +0100 @@ -36,8 +36,8 @@ #include "DeviceItem.h" #include "PlatformUdisks.h" -PlatformUdisks::PlatformUdisks(bool kioskMode) - : Platform(kioskMode) +PlatformUdisks::PlatformUdisks(bool kioskMode, bool unsafe) + : Platform(kioskMode, unsafe) { } @@ -65,7 +65,7 @@ // Figure out which devices we should allow a user to write to. void -PlatformUdisks::findDevices(bool unsafe) +PlatformUdisks::findDevices() { int i = 0; if (!udiskEnabled()) @@ -75,6 +75,7 @@ msgBox.exec(); return; } + // First get the list of disks QDBusConnection connection = QDBusConnection::systemBus(); QDBusMessage message; @@ -98,7 +99,7 @@ QStringList diskList; // Safe mode (the default) only handles USB devices - if (!unsafe) + if (!mUnsafe) { for (i = 0; i < devList.size(); ++i) if (isUSB(devList.at(i))) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/PlatformUdisks.h new/imagewriter-1.10/PlatformUdisks.h --- old/imagewriter-1.9/PlatformUdisks.h 2011-04-06 16:20:28.000000000 +0200 +++ new/imagewriter-1.10/PlatformUdisks.h 2012-11-14 15:00:02.000000000 +0100 @@ -33,14 +33,14 @@ { public: - PlatformUdisks(bool kioskMode = false); - void findDevices(bool unsafe = false); + PlatformUdisks(bool kioskMode = false, bool unsafe = false); + void findDevices(); bool isMounted(QString path); void writeData(QString path, QString fileName, qint64 deviceSize); bool unmountDevice(QString path); DeviceItem *getNewDevice(QString devicePath); -private: +protected: bool udiskEnabled(); bool isUSB(const QString &udiskPath); bool isPartitionMounted(const QString &partitionPath); @@ -52,7 +52,6 @@ QString getVendor(const QString &devicePath); bool getIsRemovable(const QString &devicePath); long long getSize(const QString &devicePath); - }; #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/PlatformUdisks2.cpp new/imagewriter-1.10/PlatformUdisks2.cpp --- old/imagewriter-1.9/PlatformUdisks2.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/imagewriter-1.10/PlatformUdisks2.cpp 2012-11-14 15:00:02.000000000 +0100 @@ -0,0 +1,315 @@ +#include <sys/mount.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> + +#include <QtCore> +#include <QtGui> +#include <QRegExp> +#include <QDir> +#include <QProgressDialog> + +#include <QtDBus/QDBusConnection> +#include <QtDBus/QDBusPendingReply> + + +#include "DeviceItem.h" +#include "PlatformUdisks2.h" +#include "udisks2_interface.h" +#include "udisks2_mountpoints_interface.h" + +PlatformUdisks2::PlatformUdisks2(bool kioskMode, bool unsafe) + : Platform(kioskMode, unsafe) +{ + qRegisterMetaType<DBUSManagerStruct>("DBUSManagerStruct"); + qDBusRegisterMetaType<DBUSManagerStruct>(); + + qRegisterMetaType<QVariantMapMap>("QVariantMapMap"); + qDBusRegisterMetaType<QVariantMapMap>(); + + qRegisterMetaType<ByteArrayList>("ByteArrayList"); + qDBusRegisterMetaType<ByteArrayList>(); +} + +bool +PlatformUdisks2::udisk2Enabled() +{ + QDBusInterface remoteApp("org.freedesktop.UDisks2", + "/org/freedesktop/UDisks2/Manager", + "org.freedesktop.UDisks2.Manager", + QDBusConnection::systemBus()); + QVariant reply = remoteApp.property("Version"); + if (reply.isNull()) + return false; + return true; +} + +void +PlatformUdisks2::findDevices() +{ + QRegExp reg("[0-9]+$"); + + if (!udisk2Enabled()) + { + QMessageBox msgBox; + msgBox.setText(QObject::tr("You don't have UDisks2 support.")); + msgBox.exec(); + return; + } + + org::freedesktop::DBus::ObjectManager manager("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2", QDBusConnection::systemBus()); + QDBusPendingReply<DBUSManagerStruct> reply = manager.GetManagedObjects(); + reply.waitForFinished(); + if (reply.isError()) { + qDebug() << "Failure: " << reply.error(); + exit(0); + } + + Q_FOREACH(const QDBusObjectPath &path, reply.value().keys()) { + const QString udi = path.path(); + if (!udi.startsWith("/org/freedesktop/UDisks2/block_devices")) + continue; + + // Skip disk slices + if (udi.contains(reg)) + continue; + + QVariantMap blockProperties = getBlockDeviceProperties(udi); + QString drivePath = blockProperties.value("drivePath").toString(); + qlonglong size = blockProperties.value("size").toLongLong(); + QString devicePath = blockProperties.value("path").toString(); + + if (drivePath.isEmpty() || size == 0 || devicePath.isEmpty()) + continue; + + + QVariantMap driveProperties = getDriveProperties(drivePath); + bool isUSB = driveProperties.value("isUSB").toBool(); + + // "Safe mode" only lists USB devices + if (!mUnsafe) + { + if (!isUSB) + continue; + } + + buildDevice(blockProperties, driveProperties); + } +} + +QVariantMap +PlatformUdisks2::getBlockDeviceProperties(const QString &blockDevice) +{ + QVariantMap properties; + + QDBusInterface remoteApp("org.freedesktop.UDisks2", + blockDevice, + "org.freedesktop.UDisks2.Block", + QDBusConnection::systemBus()); + QDBusObjectPath objectPath = qvariant_cast<QDBusObjectPath>(remoteApp.property("Drive")); + QString path = objectPath.path(); + properties.insert("drivePath", path); + properties.insert("path", QString(remoteApp.property("Device").toByteArray())); + properties.insert("size", remoteApp.property("Size")); + return properties; +} + +QVariantMap +PlatformUdisks2::getDriveProperties(const QString &drivePath) +{ + QVariantMap properties; + QDBusInterface remoteApp("org.freedesktop.UDisks2", + drivePath, + "org.freedesktop.UDisks2.Drive", + QDBusConnection::systemBus()); + properties.insert("removable", remoteApp.property("Removable")); + properties.insert("vendor", remoteApp.property("Vendor")); + properties.insert("serial", remoteApp.property("Serial")); + properties.insert("model", remoteApp.property("Model")); + + if (remoteApp.property("ConnectionBus").toString().toLower() == "usb") + properties.insert("isUSB", true); + else + properties.insert("isUSB", false); + + + return properties; +} + +DeviceItem * +PlatformUdisks2::buildDevice(QVariantMap &blockProperties, QVariantMap &driveProperties) { + DeviceItem *devItem = new DeviceItem; + + QString path = blockProperties.value("path").toString(); + devItem->setUDI(path.mid(path.lastIndexOf("/") + 1)); + qDebug() << devItem->getUDI(); + isMounted(devItem->getUDI()); + devItem->setPath(path); + devItem->setIsRemovable(driveProperties.value("removable").toBool()); + devItem->setSize(blockProperties.value("size").toLongLong()); + devItem->setModelString(driveProperties.value("model").toString()); + QString vendor = driveProperties.value("vendor").toString(); + + if (vendor == "") + { + if (mKioskMode) + devItem->setVendorString("SUSE Studio USB Key"); + else + devItem->setVendorString("Unknown Device"); + } + else + { + devItem->setVendorString(vendor); + } + QString newDisplayString = QString("%1 %2 - %3 (%4 MB)") + .arg(devItem->getVendorString()) + .arg(devItem->getModelString()) + .arg(devItem->getPath()) + .arg(devItem->getSize() / 1048576); + devItem->setDisplayString(newDisplayString); + + if (mKioskMode) + { + if((devItem->getSize() / 1048576) > 200000) + { + delete devItem; + return(NULL); + } + } + + // If a device is 0 megs we might as well just not list it + if ((devItem->getSize() / 1048576) > 0) + { + itemList << devItem; + } + else + { + delete devItem; + devItem = NULL; + } + + return(devItem); +} + +DeviceItem * +PlatformUdisks2::getNewDevice(QString newPath) +{ + QVariantMap blockProperties = getBlockDeviceProperties(newPath); + QString drivePath = blockProperties.value("drivePath").toString(); + qlonglong size = blockProperties.value("size").toLongLong(); + QString devicePath = blockProperties.value("path").toString(); + + if (drivePath.isEmpty() || size == 0 || devicePath.isEmpty()) + return NULL; + + QVariantMap driveProperties = getDriveProperties(drivePath); + bool isUSB = driveProperties.value("isUSB").toBool(); + + if (!mUnsafe) + { + if (!isUSB) + return NULL; + } + + return buildDevice(blockProperties, driveProperties); +} + +bool +PlatformUdisks2::isMounted(QString path) +{ + bool mounted = false; + QStringList partitions = getPartitionList(path); + foreach(QString partition, partitions) + { + if (isPartitionMounted(partition)) + { + mounted = true; + break; + } + } + + return mounted; +} + +QStringList +PlatformUdisks2::getPartitionList(const QString &devicePath) +{ + QStringList partitionList; + org::freedesktop::DBus::ObjectManager manager("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2", QDBusConnection::systemBus()); + QDBusPendingReply<DBUSManagerStruct> reply = manager.GetManagedObjects(); + reply.waitForFinished(); + if (reply.isError()) { + qDebug() << "Failure: " << reply.error(); + exit(0); + } + + QRegExp reg(QString("%1[0-9]+$").arg(devicePath)); + + Q_FOREACH(const QDBusObjectPath &path, reply.value().keys()) { + const QString udi = path.path(); + if (!udi.startsWith("/org/freedesktop/UDisks2/block_devices")) + continue; + + if (!udi.contains(reg)) + continue; + partitionList << udi; + } + + return partitionList; +} + +bool +PlatformUdisks2::isPartitionMounted(const QString &partitionPath) +{ + org::freedesktop::UDisks2::Filesystem manager("org.freedesktop.UDisks2", partitionPath, QDBusConnection::systemBus()); + ByteArrayList reply = manager.mountPoints(); + if (reply.isEmpty()) + { + qDebug() << "Not mounted"; + return false; + } + + return true; +} + +bool +PlatformUdisks2::unmountDevice(QString path) +{ + bool res = true; + QStringList partitions = getPartitionList(path); + foreach(QString partition, partitions) + { + if (!doUnmount(partition)) + { + res = false; + break; + } + } + + return(res); +} + +bool +PlatformUdisks2::doUnmount(const QString &partitionPath) +{ + bool ret = true; + QDBusConnection connection = QDBusConnection::systemBus(); + QList<QVariant> args; + QVariantMap map; + args << map; + + QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.UDisks2", partitionPath, "org.freedesktop.UDisks2.Filesystem", "Unmount"); + message.setArguments(args); + QDBusMessage reply = connection.call(message); + + if (reply.type() == QDBusMessage::ErrorMessage) + { + QMessageBox msgBox; + msgBox.setText(QString("DBUS error (%1): %2").arg(partitionPath).arg(reply.errorMessage())); + msgBox.exec(); + ret = false; + } + return(ret); +} + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/PlatformUdisks2.h new/imagewriter-1.10/PlatformUdisks2.h --- old/imagewriter-1.9/PlatformUdisks2.h 1970-01-01 01:00:00.000000000 +0100 +++ new/imagewriter-1.10/PlatformUdisks2.h 2012-11-14 15:00:02.000000000 +0100 @@ -0,0 +1,26 @@ +#ifndef __PLATFORMUDISKS2_H__ +#define __PLATFORMUDISKS2_H__ + +#include "PlatformUdisks.h" + +class PlatformUdisks2 : public Platform +{ +public: + PlatformUdisks2(bool kioskMode = false, bool unsafe = false); + void findDevices(); + DeviceItem *getNewDevice(QString newPath); + bool isMounted(QString path); + bool unmountDevice(QString path); + +private: + bool udisk2Enabled(); + QString getDrivePath(const QString &blockDevice); + QStringList getPartitionList(const QString &devicePath); + bool isPartitionMounted(const QString &partitionPath); + bool doUnmount(const QString &partitionPath); + QVariantMap getBlockDeviceProperties(const QString &blockDevice); + QVariantMap getDriveProperties(const QString &drivePath); + DeviceItem *buildDevice(QVariantMap &blockProperties, QVariantMap &driveProperties); +}; + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/README new/imagewriter-1.10/README --- old/imagewriter-1.9/README 2011-04-06 16:20:28.000000000 +0200 +++ new/imagewriter-1.10/README 1970-01-01 01:00:00.000000000 +0100 @@ -1,17 +0,0 @@ -In order to compile, run - % qmake -to create the make file and then run - % make - -qmake should automatically detect your platform. - -=== Kiosk mode === - -The imagewriter also has the capability to be used in "kiosks" that may have external harddrives. To run in kiosk mode, -which both ignores large hard drives and marks unknown USB sticks as "SUSE Studio", -run imagewriter with the -k option. - -in order to start the imagewriter with sudo, do the following: - % xhost +SI:localuser:root -to allow root access to the current screen and then start the program with: - % sudo DISPLAY=:0 burner diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/README.md new/imagewriter-1.10/README.md --- old/imagewriter-1.9/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/imagewriter-1.10/README.md 2012-11-14 15:00:02.000000000 +0100 @@ -0,0 +1,43 @@ +imagewriter +=========== + +Utility for writing raw disk images & hybrid isos to USB keys + +Linux Installation +=========== + +In order to compile, run + +** HAL ** + + % qmake DEFINES=USEHAL imagewriter.pro + +** udisks1 ** + + % qmake DEFINES=USEUDISKS imagewriter.pro + +** udisks2 ** + + % qmake DEFINES=USEUDISKS2 imagewriter.pro + +Failing to specify the define will likely not work out. + +Then run + + % make + +Linux kiosk mode +=========== + +The imagewriter also has the capability to be used in "kiosks" that may have external harddrives. To run in kiosk mode, +which both ignores large hard drives and marks unknown USB sticks as "SUSE Studio", +run imagewriter with the -k option. + +in order to start the imagewriter with sudo, do the following: + + % xhost +SI:localuser:root + +to allow root access to the current screen and then start the program with: + + % sudo DISPLAY=:0 imagewriter + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/imagewriter.desktop new/imagewriter-1.10/imagewriter.desktop --- old/imagewriter-1.9/imagewriter.desktop 2011-04-06 16:20:28.000000000 +0200 +++ new/imagewriter-1.10/imagewriter.desktop 2012-11-14 15:00:02.000000000 +0100 @@ -1,10 +1,8 @@ [Desktop Entry] Type=Application Categories=System;Utility;Archiving; -X-KDE-RootOnly=true -Exec=imagewriter %F +Exec=/usr/bin/xdg-su -c /usr/bin/imagewriter %f Icon=imagewriter Name=SUSE Studio Imagewriter -GenericName=USB key writer -X-KDE-SubstituteUID=true +GenericName=USB key writer Version=1.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/imagewriter.pro new/imagewriter-1.10/imagewriter.pro --- old/imagewriter-1.9/imagewriter.pro 2011-04-06 16:20:28.000000000 +0200 +++ new/imagewriter-1.10/imagewriter.pro 2012-11-14 15:00:02.000000000 +0100 @@ -6,7 +6,7 @@ TARGET = DEPENDPATH += . INCLUDEPATH += . -VERSION=1.9 +VERSION=1.10 DEFINES += APP_VERSION=\\\"$$VERSION\\\" # Input @@ -14,12 +14,19 @@ MainWindow.h \ Platform.h \ PlatformHal.h \ - PlatformUdisks.h + PlatformUdisks.h \ + PlatformUdisks2.h \ + udisks2_interface.h \ + udisks2_mountpoints_interface.h \ + MetaTypes.h SOURCES += main.cpp \ MainWindow.cpp \ PlatformHal.cpp \ PlatformUdisks.cpp \ - Platform.cpp + Platform.cpp \ + PlatformUdisks2.cpp \ + udisks2_interface.cpp \ + udisks2_mountpoints_interface.cpp CONFIG += link_pkgconfig \ qdbus @@ -28,6 +35,9 @@ PKGCONFIG += hal \ hal-storage DEFINES += USEHAL + DEFINES -= USEUDISKS2 + HEADERS -= PlatformUdisks2.h udisks2_interface.h udisks2_mountpoints_interface.h MetaTypes.h + SOURCES -= PlatformUdisks2.cpp udisks2_interface.cpp udisks2_mountpoints_interface.cpp } QMAKE_EXTRA_TARGETS += distfile @@ -35,7 +45,7 @@ DISTFILE_EXTRAFILES = $$RESOURCES \ COPYING \ imagewriter.pro \ - README \ + README.md \ INSTALL \ *.png \ imagewriter.qrc \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/imagewriter.spec new/imagewriter-1.10/imagewriter.spec --- old/imagewriter-1.9/imagewriter.spec 2011-04-06 16:20:28.000000000 +0200 +++ new/imagewriter-1.10/imagewriter.spec 2012-11-14 15:00:02.000000000 +0100 @@ -7,50 +7,83 @@ # # needsrootforbuild -Url: http://kiwi.berlios.de +Url: https://github.com/mbarringer/imagewriter Name: imagewriter -BuildRequires: hal-devel BuildRequires: gcc-c++ -%if 0%{?fedora_version} - %define breq qt4-devel +%if 0%{?rhel_version} == 600 + %define dist el6 + %define breq qt-devel + %define backend hal-devel + %define qmake /usr/bin/qmake-qt4 + %define lrelease /usr/bin/lrelease-qt4 + %define definedbackend USEHAL +%endif + +%if 0%{?fedora} + %define breq qt4-devel + %define backend udisks2 %define qmake /usr/bin/qmake-qt4 - %define lrelease /usr/bin/lrelease-qt4 -%endif -%if 0%{?mandriva_version} + %define lrelease /usr/bin/lrelease-qt4 + %define definedbackend USEUDISKS2 +%endif + +%if 0%{?mandriva_version} %define breq libqt4-devel + %define backend hal-devel %define qmake /usr/lib/qt4/bin/qmake - %define lrelease /usr/lib/qt4/bin/lrelease + %define lrelease /usr/lib/qt4/bin/lrelease + %define definedbackend USEHAL %endif -%if 0%{?suse_version} - %define breq libqt4-devel + +%if 0%{?suse_version} + %define breq libqt4-devel update-desktop-files %define qmake /usr/bin/qmake - %define lrelease /usr/bin/lrelease + %define lrelease /usr/bin/lrelease +%endif + +%if 0%{?suse_version} <= 1130 + %define backend hal-devel + %define definedbackend USEHAL +%endif + +%if 0%{?suse_version} == 1140 || 0%{?suse_version} == 1210 + %define backend udisks + %define definedbackend USEUDISKS %endif -Summary: SUSE Studio Imagewriter -Version: 1.8 +%if 0%{?suse_version} >= 1220 + %define backend udisks2 + %define definedbackend USEUDISKS2 +%endif + +Summary: SUSE Imagewriter +Version: 1.10 Release: 0 Group: Hardware/Other -License: GPL v2 +License: GPL-2.0 Source: imagewriter-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: %{breq} +BuildRequires: %{breq} %{backend} %description -Graphical image writer application +A graphical utility for writing raw disk images & hybrid isos to USB keys %prep %setup %build -%{qmake} PREFIX=%{_prefix} -makefile imagewriter.pro -make buildroot=$RPM_BUILD_ROOT CFLAGS="$RPM_OPT_FLAGS" +%{qmake} PREFIX=$RPM_BUILD_ROOT/%{_prefix} DEFINES=%{definedbackend} imagewriter.pro +make buildroot=$RPM_BUILD_ROOT CFLAGS="$RPM_OPT_FLAGS -DKIOSKHACK" %install # build -#install -d $RPM_BUILD_ROOT/usr/bin -#install -m 755 -p imagewriter $RPM_BUILD_ROOT/usr/bin +# I don't know why 'make install' ignores the binary when built in OBS +install -d $RPM_BUILD_ROOT/usr/bin +install -m 755 -p imagewriter $RPM_BUILD_ROOT/%{_bindir} make install +%if 0%{?suse_version} + %suse_update_desktop_file imagewriter +%endif %clean rm -rf $RPM_BUILD_ROOT @@ -59,7 +92,11 @@ %defattr(-,root,root) %{_bindir}/imagewriter %{_prefix}/share/applications/imagewriter.desktop -%{_prefix}/share/icons/hicolor/*/apps/imagewriter.png +#%{_prefix}/share/icons/hicolor/*/apps/imagewriter.png +%dir %{_datadir}/icons/hicolor/*/apps/ +%dir %{_datadir}/icons/hicolor/*/ +%dir %{_datadir}/icons/hicolor/ +%{_datadir}/icons/hicolor/*/apps/imagewriter.* %doc COPYING %changelog diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/main.cpp new/imagewriter-1.10/main.cpp --- old/imagewriter-1.9/main.cpp 2011-04-06 16:20:28.000000000 +0200 +++ new/imagewriter-1.10/main.cpp 2012-11-14 15:00:02.000000000 +0100 @@ -27,10 +27,12 @@ #error "Only linux is supported at the moment" #endif - +#include <unistd.h> +#include <sys/types.h> #include "MainWindow.h" #include "PlatformHal.h" #include "PlatformUdisks.h" +#include "PlatformUdisks2.h" #include "DeviceItem.h" @@ -44,6 +46,7 @@ bool maximized = false; bool listMode = false; bool kioskMode = false; + qDebug() << "Starting up..."; #if defined(Q_OS_UNIX) #ifndef KIOSKHACK if (getuid() != 0) @@ -95,11 +98,13 @@ QApplication app(argc, argv); #ifdef USEHAL - PlatformHal *platform = new PlatformHal(kioskMode); + PlatformHal *platform = new PlatformHal(kioskMode, unsafe); +#elif USEUDISKS2 + PlatformUdisks2 *platform = new PlatformUdisks2(kioskMode, unsafe); #else - PlatformUdisks *platform = new PlatformUdisks(kioskMode); + PlatformUdisks *platform = new PlatformUdisks(kioskMode, unsafe); #endif - platform->findDevices(unsafe); + platform->findDevices(); if (listMode) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/udisks2_interface.cpp new/imagewriter-1.10/udisks2_interface.cpp --- old/imagewriter-1.9/udisks2_interface.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/imagewriter-1.10/udisks2_interface.cpp 2012-11-14 15:00:02.000000000 +0100 @@ -0,0 +1,25 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -i MetaTypes.h -p udisks2_interface udisks2_interface.xml + * + * qdbusxml2cpp is Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "udisks2_interface.h" + +/* + * Implementation of interface class OrgFreedesktopDBusObjectManagerInterface + */ + +OrgFreedesktopDBusObjectManagerInterface::OrgFreedesktopDBusObjectManagerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +OrgFreedesktopDBusObjectManagerInterface::~OrgFreedesktopDBusObjectManagerInterface() +{ +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/udisks2_interface.h new/imagewriter-1.10/udisks2_interface.h --- old/imagewriter-1.9/udisks2_interface.h 1970-01-01 01:00:00.000000000 +0100 +++ new/imagewriter-1.10/udisks2_interface.h 2012-11-14 15:00:02.000000000 +0100 @@ -0,0 +1,58 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -i MetaTypes.h -p udisks2_interface udisks2_interface.xml + * + * qdbusxml2cpp is Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef UDISKS2_INTERFACE_H +#define UDISKS2_INTERFACE_H + +#include <QtCore/QObject> +#include <QtCore/QByteArray> +#include <QtCore/QList> +#include <QtCore/QMap> +#include <QtCore/QString> +#include <QtCore/QStringList> +#include <QtCore/QVariant> +#include <QtDBus/QtDBus> +#include "MetaTypes.h" + +/* + * Proxy class for interface org.freedesktop.DBus.ObjectManager + */ +class OrgFreedesktopDBusObjectManagerInterface: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "org.freedesktop.DBus.ObjectManager"; } + +public: + OrgFreedesktopDBusObjectManagerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~OrgFreedesktopDBusObjectManagerInterface(); + +public Q_SLOTS: // METHODS + inline QDBusPendingReply<DBUSManagerStruct> GetManagedObjects() + { + QList<QVariant> argumentList; + return asyncCallWithArgumentList(QLatin1String("GetManagedObjects"), argumentList); + } + +Q_SIGNALS: // SIGNALS + void InterfacesAdded(const QDBusObjectPath &object_path, const QVariantMapMap &interfaces_and_properties); + void InterfacesRemoved(const QDBusObjectPath &object_path, const QStringList &interfaces); +}; + +namespace org { + namespace freedesktop { + namespace DBus { + typedef ::OrgFreedesktopDBusObjectManagerInterface ObjectManager; + } + } +} +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/udisks2_mountpoints_interface.cpp new/imagewriter-1.10/udisks2_mountpoints_interface.cpp --- old/imagewriter-1.9/udisks2_mountpoints_interface.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/imagewriter-1.10/udisks2_mountpoints_interface.cpp 2012-11-14 15:00:02.000000000 +0100 @@ -0,0 +1,25 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -i MetaTypes.h -p udisks2_mountpoints_interface udisks2_mountpoints_interface.xml + * + * qdbusxml2cpp is Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "udisks2_mountpoints_interface.h" + +/* + * Implementation of interface class OrgFreedesktopUDisks2FilesystemInterface + */ + +OrgFreedesktopUDisks2FilesystemInterface::OrgFreedesktopUDisks2FilesystemInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +OrgFreedesktopUDisks2FilesystemInterface::~OrgFreedesktopUDisks2FilesystemInterface() +{ +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imagewriter-1.9/udisks2_mountpoints_interface.h new/imagewriter-1.10/udisks2_mountpoints_interface.h --- old/imagewriter-1.9/udisks2_mountpoints_interface.h 1970-01-01 01:00:00.000000000 +0100 +++ new/imagewriter-1.10/udisks2_mountpoints_interface.h 2012-11-14 15:00:02.000000000 +0100 @@ -0,0 +1,54 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -i MetaTypes.h -p udisks2_mountpoints_interface udisks2_mountpoints_interface.xml + * + * qdbusxml2cpp is Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef UDISKS2_MOUNTPOINTS_INTERFACE_H +#define UDISKS2_MOUNTPOINTS_INTERFACE_H + +#include <QtCore/QObject> +#include <QtCore/QByteArray> +#include <QtCore/QList> +#include <QtCore/QMap> +#include <QtCore/QString> +#include <QtCore/QStringList> +#include <QtCore/QVariant> +#include <QtDBus/QtDBus> +#include "MetaTypes.h" + +/* + * Proxy class for interface org.freedesktop.UDisks2.Filesystem + */ +class OrgFreedesktopUDisks2FilesystemInterface: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "org.freedesktop.UDisks2.Filesystem"; } + +public: + OrgFreedesktopUDisks2FilesystemInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~OrgFreedesktopUDisks2FilesystemInterface(); + + Q_PROPERTY(ByteArrayList MountPoints READ mountPoints) + inline ByteArrayList mountPoints() const + { return qvariant_cast< ByteArrayList >(property("MountPoints")); } + +public Q_SLOTS: // METHODS +Q_SIGNALS: // SIGNALS +}; + +namespace org { + namespace freedesktop { + namespace UDisks2 { + typedef ::OrgFreedesktopUDisks2FilesystemInterface Filesystem; + } + } +} +#endif -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org