From 75100e3b80d2fa4daa4a1d3b61c5aad48f5d07a3 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Wed, 6 Feb 2013 19:03:14 +0000 Subject: added udisks2 plugin git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3200 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/udisks2/CMakeLists.txt | 66 ++++++ src/plugins/General/udisks2/settingsdialog.cpp | 55 +++++ src/plugins/General/udisks2/settingsdialog.h | 45 ++++ src/plugins/General/udisks2/settingsdialog.ui | 122 ++++++++++ .../General/udisks2/translations/translations.qrc | 24 ++ .../udisks2/translations/udisks2_plugin_cs.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_de.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_es.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_fr.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_he.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_hu.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_it.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_ja.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_kk.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_lt.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_nl.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_pl.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_pl_PL.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_pt_BR.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_ru.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_sk.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_tr.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_uk_UA.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_zh_CN.ts | 83 +++++++ .../udisks2/translations/udisks2_plugin_zh_TW.ts | 83 +++++++ src/plugins/General/udisks2/udisks2.pro | 54 +++++ src/plugins/General/udisks2/udisks2device.cpp | 115 +++++++++ src/plugins/General/udisks2/udisks2device.h | 93 ++++++++ src/plugins/General/udisks2/udisks2factory.cpp | 64 +++++ src/plugins/General/udisks2/udisks2factory.h | 45 ++++ src/plugins/General/udisks2/udisks2manager.cpp | 93 ++++++++ src/plugins/General/udisks2/udisks2manager.h | 59 +++++ src/plugins/General/udisks2/udisks2plugin.cpp | 264 +++++++++++++++++++++ src/plugins/General/udisks2/udisks2plugin.h | 65 +++++ 34 files changed, 2824 insertions(+) create mode 100644 src/plugins/General/udisks2/CMakeLists.txt create mode 100644 src/plugins/General/udisks2/settingsdialog.cpp create mode 100644 src/plugins/General/udisks2/settingsdialog.h create mode 100644 src/plugins/General/udisks2/settingsdialog.ui create mode 100644 src/plugins/General/udisks2/translations/translations.qrc create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_cs.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_de.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_es.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_fr.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_he.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_hu.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_it.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_ja.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_kk.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_lt.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_nl.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_pl.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_pl_PL.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_pt_BR.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_ru.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_sk.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_tr.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_uk_UA.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_zh_CN.ts create mode 100644 src/plugins/General/udisks2/translations/udisks2_plugin_zh_TW.ts create mode 100644 src/plugins/General/udisks2/udisks2.pro create mode 100644 src/plugins/General/udisks2/udisks2device.cpp create mode 100644 src/plugins/General/udisks2/udisks2device.h create mode 100644 src/plugins/General/udisks2/udisks2factory.cpp create mode 100644 src/plugins/General/udisks2/udisks2factory.h create mode 100644 src/plugins/General/udisks2/udisks2manager.cpp create mode 100644 src/plugins/General/udisks2/udisks2manager.h create mode 100644 src/plugins/General/udisks2/udisks2plugin.cpp create mode 100644 src/plugins/General/udisks2/udisks2plugin.h (limited to 'src/plugins/General/udisks2') diff --git a/src/plugins/General/udisks2/CMakeLists.txt b/src/plugins/General/udisks2/CMakeLists.txt new file mode 100644 index 000000000..fde34f804 --- /dev/null +++ b/src/plugins/General/udisks2/CMakeLists.txt @@ -0,0 +1,66 @@ +project(libudisks2) + +cmake_minimum_required(VERSION 2.4.8 FATAL_ERROR) + +SET (QT_USE_QTDBUS TRUE) + +INCLUDE(FindQt4) + +include(${QT_USE_FILE}) + +if(COMMAND cmake_policy) +cmake_policy(SET CMP0003 NEW) +endif(COMMAND cmake_policy) + +# qt plugin +ADD_DEFINITIONS( -Wall ) +ADD_DEFINITIONS(${QT_DEFINITIONS}) +ADD_DEFINITIONS(-DQT_PLUGIN) +ADD_DEFINITIONS(-DQT_NO_DEBUG) +ADD_DEFINITIONS(-DQT_SHARED) +ADD_DEFINITIONS(-DQT_THREAD) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +# libqmmpui & libqmmp +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../) +link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmpui) +link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmp) + +SET(libudisks2_SRCS + udisks2factory.cpp + udisks2manager.cpp + udisks2plugin.cpp + udisks2device.cpp + settingsdialog.cpp +) + +SET(libudisks2_MOC_HDRS + udisks2factory.h + udisks2manager.h + udisks2plugin.h + udisks2device.h + settingsdialog.h +) + +SET(libudisks2_RCCS translations/translations.qrc) + +QT4_ADD_RESOURCES(libudisks2_RCC_SRCS ${libudisks2_RCCS}) + +QT4_WRAP_CPP(libudisks2_MOC_SRCS ${libudisks2_MOC_HDRS}) + +# user interface + +SET(libudisks2_UIS + settingsdialog.ui +) + +QT4_WRAP_UI(libudisks2_UIS_H ${libudisks2_UIS}) +# Don't forget to include output directory, otherwise +# the UI file won't be wrapped! +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +ADD_LIBRARY(udisks2 MODULE ${libudisks2_SRCS} ${libudisks2_MOC_SRCS} ${libudisks2_UIS_H} ${libudisks2_RCC_SRCS}) +add_dependencies(udisks2 qmmpui) +target_link_libraries(udisks2 ${QT_LIBRARIES} -lqmmpui -lqmmp) +install(TARGETS udisks2 DESTINATION ${LIB_DIR}/qmmp/General) diff --git a/src/plugins/General/udisks2/settingsdialog.cpp b/src/plugins/General/udisks2/settingsdialog.cpp new file mode 100644 index 000000000..c83bd772a --- /dev/null +++ b/src/plugins/General/udisks2/settingsdialog.cpp @@ -0,0 +1,55 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#include +#include +#include "settingsdialog.h" + +SettingsDialog::SettingsDialog(QWidget *parent) + : QDialog(parent) +{ + m_ui.setupUi(this); + QSettings settings(Qmmp::configFile(), QSettings::IniFormat); + settings.beginGroup("UDisks2"); + m_ui.cdGroupBox->setChecked(settings.value("cda", true).toBool()); + m_ui.addTracksCheckBox->setChecked(settings.value("add_tracks", false).toBool()); + m_ui.removeTracksCheckBox->setChecked(settings.value("remove_tracks", false).toBool()); + m_ui.removableGroupBox->setChecked(settings.value("removable", true).toBool()); + m_ui.addFilesCheckBox->setChecked(settings.value("add_files", false).toBool()); + m_ui.removeFilesCheckBox->setChecked(settings.value("remove_files", false).toBool()); + settings.endGroup(); +} + + +SettingsDialog::~SettingsDialog() +{} + +void SettingsDialog::accept() +{ + QSettings settings(Qmmp::configFile(), QSettings::IniFormat); + settings.beginGroup("UDisks2"); + settings.setValue("cda", m_ui.cdGroupBox->isChecked()); + settings.setValue("add_tracks", m_ui.addTracksCheckBox->isChecked()); + settings.setValue("remove_tracks", m_ui.removeTracksCheckBox->isChecked()); + settings.setValue("removable", m_ui.removableGroupBox->isChecked()); + settings.setValue("add_files", m_ui.addFilesCheckBox->isChecked()); + settings.setValue("remove_files", m_ui.removeFilesCheckBox->isChecked()); + settings.endGroup(); + QDialog::accept(); +} diff --git a/src/plugins/General/udisks2/settingsdialog.h b/src/plugins/General/udisks2/settingsdialog.h new file mode 100644 index 000000000..6ee3e2b05 --- /dev/null +++ b/src/plugins/General/udisks2/settingsdialog.h @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef SETTINGSDIALOG_H +#define SETTINGSDIALOG_H + +#include +#include "ui_settingsdialog.h" + +/** + @author Ilya Kotov +*/ +class SettingsDialog : public QDialog +{ +Q_OBJECT +public: + SettingsDialog(QWidget *parent = 0); + + ~SettingsDialog(); + + +public slots: + virtual void accept(); + +private: + Ui::SettingsDialog m_ui; +}; + +#endif diff --git a/src/plugins/General/udisks2/settingsdialog.ui b/src/plugins/General/udisks2/settingsdialog.ui new file mode 100644 index 000000000..5b039a88c --- /dev/null +++ b/src/plugins/General/udisks2/settingsdialog.ui @@ -0,0 +1,122 @@ + + + SettingsDialog + + + + 0 + 0 + 348 + 247 + + + + UDisks Plugin Settings + + + + 6 + + + 6 + + + 6 + + + + + CD Audio Detection + + + true + + + + + + Add tracks to playlist automatically + + + + + + + Remove tracks from playlist automatically + + + + + + + + + + Removable Device Detection + + + true + + + + + + Add files to playlist automatically + + + + + + + Remove files from playlist automatically + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + SettingsDialog + accept() + + + 199 + 221 + + + 22 + 242 + + + + + buttonBox + rejected() + SettingsDialog + reject() + + + 247 + 225 + + + 273 + 229 + + + + + diff --git a/src/plugins/General/udisks2/translations/translations.qrc b/src/plugins/General/udisks2/translations/translations.qrc new file mode 100644 index 000000000..dddea0001 --- /dev/null +++ b/src/plugins/General/udisks2/translations/translations.qrc @@ -0,0 +1,24 @@ + + + + udisks2_plugin_ru.qm + udisks2_plugin_uk_UA.qm + udisks2_plugin_zh_CN.qm + udisks2_plugin_zh_TW.qm + udisks2_plugin_tr.qm + udisks2_plugin_cs.qm + udisks2_plugin_pt_BR.qm + udisks2_plugin_de.qm + udisks2_plugin_pl_PL.qm + udisks2_plugin_fr.qm + udisks2_plugin_it.qm + udisks2_plugin_kk.qm + udisks2_plugin_lt.qm + udisks2_plugin_hu.qm + udisks2_plugin_nl.qm + udisks2_plugin_ja.qm + udisks2_plugin_sk.qm + udisks2_plugin_es.qm + udisks2_plugin_he.qm + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_cs.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_cs.ts new file mode 100644 index 000000000..669cf691f --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_cs.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + + + + + CD Audio Detection + Detekce zvukových CD + + + + Add tracks to playlist automatically + Automaticky přidat stopy do seznamu skladeb + + + + Remove tracks from playlist automatically + Automaticky odebrat stopy ze seznamu skladeb + + + + Removable Device Detection + Detekce odpojitelných zařízení + + + + Add files to playlist automatically + Automaticky přidat soubory do seznamu skladeb + + + + Remove files from playlist automatically + Automaticky odebrat stopy ze seznamu skladeb + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + Autor: Ilja Kotov <forkotov02@hotmail.ru> + + + + UDisks2Plugin + + + Add CD "%1" + Přidat CD „%1“ + + + + Add Volume "%1" + Přidat svazek „%1“ + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_de.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_de.ts new file mode 100644 index 000000000..4c074e7e4 --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_de.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + Einstellungen UDisks-Modul + + + + CD Audio Detection + Erkennung von Audio-CDs + + + + Add tracks to playlist automatically + Titel automatisch zur Wiedergabeliste hinzufügen + + + + Remove tracks from playlist automatically + Titel automatisch von der Wiedergabeliste entfernen + + + + Removable Device Detection + Erkennung von Wechseldatenträgern + + + + Add files to playlist automatically + Dateien automatisch zur Wiedergabeliste hinzufügen + + + + Remove files from playlist automatically + Dateien automatisch von der Wiedergabeliste entfernen + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + Autor: Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisks2Plugin + + + Add CD "%1" + CD „%1“ hinzufügen + + + + Add Volume "%1" + Gerät „%1“ hinzufügen + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_es.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_es.ts new file mode 100644 index 000000000..84f544d3b --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_es.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + Configuración del módulo UDisks + + + + CD Audio Detection + Detección de audio CD + + + + Add tracks to playlist automatically + Añadir pistas a la lista de reproducción automáticamente + + + + Remove tracks from playlist automatically + Eliminar pistas de la lista de reproducción automáticamente + + + + Removable Device Detection + Detectar dispositivos extraibles + + + + Add files to playlist automatically + Añadir archivos a la lista de reproducción automáticamente + + + + Remove files from playlist automatically + Eliminar archivos de la lista de reproducción automáticamente + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + Escrito por: Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisks2Plugin + + + Add CD "%1" + Añadir CD "%1" + + + + Add Volume "%1" + Añadir volumen "%1" + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_fr.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_fr.ts new file mode 100644 index 000000000..f1088d85c --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_fr.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + + + + + CD Audio Detection + + + + + Add tracks to playlist automatically + + + + + Remove tracks from playlist automatically + + + + + Removable Device Detection + + + + + Add files to playlist automatically + + + + + Remove files from playlist automatically + + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + + + + + UDisks2Plugin + + + Add CD "%1" + + + + + Add Volume "%1" + + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_he.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_he.ts new file mode 100644 index 000000000..17f5b5058 --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_he.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + הגדרות תוספת UDisks + + + + CD Audio Detection + איתור שמע אוטומטי של CD + + + + Add tracks to playlist automatically + הוסף רצועות אוטומטית אל רשימת השמעה + + + + Remove tracks from playlist automatically + הסר רצועות אוטומטית מן רשימת השמעה + + + + Removable Device Detection + איתור התקנים ברי הזזה + + + + Add files to playlist automatically + הוסף קבצים אוטומטית אל רשימת השמעה + + + + Remove files from playlist automatically + הסר קבצים אוטומטית מן רשימת השמעה + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + חוברה על ידי: Ilya Kotov ‫<forkotov02@hotmail.ru> + + + + UDisks2Plugin + + + Add CD "%1" + הוסף CD ‫"%1" + + + + Add Volume "%1" + הוסף כרך "%1" + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_hu.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_hu.ts new file mode 100644 index 000000000..44a03c848 --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_hu.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + + + + + CD Audio Detection + + + + + Add tracks to playlist automatically + + + + + Remove tracks from playlist automatically + + + + + Removable Device Detection + + + + + Add files to playlist automatically + + + + + Remove files from playlist automatically + + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + + + + + UDisks2Plugin + + + Add CD "%1" + + + + + Add Volume "%1" + + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_it.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_it.ts new file mode 100644 index 000000000..26b4fcc19 --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_it.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + + + + + CD Audio Detection + Rilevamento CD Audio + + + + Add tracks to playlist automatically + Aggiungi automaticamente i titoli alla lista dei brani + + + + Remove tracks from playlist automatically + Rimuovi automaticamente i titoli dalla lista dei brani + + + + Removable Device Detection + Rilevamento dispositivi rimovibili + + + + Add files to playlist automatically + Aggiungi brani automaticamente alla lista + + + + Remove files from playlist automatically + Rimuovi automaticamente i brani dalla lista + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + Autore: Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisks2Plugin + + + Add CD "%1" + Aggiungi CD "%1" + + + + Add Volume "%1" + Aggiungi libreria "%1" + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_ja.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_ja.ts new file mode 100644 index 000000000..33cc827c2 --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_ja.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + UDisks プラグイン設定 + + + + CD Audio Detection + 音楽 CD 検知 + + + + Add tracks to playlist automatically + プレイリストにトラックを自動追加 + + + + Remove tracks from playlist automatically + プレイリストからトラックを自動除去 + + + + Removable Device Detection + 着脱可能なデバイスの検知 + + + + Add files to playlist automatically + プレイリストにファイルを自動追加 + + + + Remove files from playlist automatically + プレイリストからファイルを自動除去 + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + 制作: Илья Котов (Ilya Kotov) <forkotov02@hotmail.ru> + + + + UDisks2Plugin + + + Add CD "%1" + CD "%1" を追加 + + + + Add Volume "%1" + 量目 "%1" を追加 + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_kk.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_kk.ts new file mode 100644 index 000000000..6ffc6af9c --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_kk.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + + + + + CD Audio Detection + + + + + Add tracks to playlist automatically + + + + + Remove tracks from playlist automatically + + + + + Removable Device Detection + + + + + Add files to playlist automatically + + + + + Remove files from playlist automatically + + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + + + + + UDisks2Plugin + + + Add CD "%1" + + + + + Add Volume "%1" + + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_lt.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_lt.ts new file mode 100644 index 000000000..5ec0c154f --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_lt.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + Udisks įskiepio nustatymai + + + + CD Audio Detection + Audio CD aptikimas + + + + Add tracks to playlist automatically + Įdėti takelius į grojaraštį automatiškai + + + + Remove tracks from playlist automatically + Pašalinti takelius iš grojaraščio automatiškai + + + + Removable Device Detection + Išorinių įrenginių aptikimas + + + + Add files to playlist automatically + Įdėti takelius į grojaratį automatiškai + + + + Remove files from playlist automatically + Pašalinti takelius iš grojaraščio automatiškai + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + Sukūrė: Ilya Kotov + + + + UDisks2Plugin + + + Add CD "%1" + Pridėti CD "%1" + + + + Add Volume "%1" + Pridėti tomą "%1" + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_nl.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_nl.ts new file mode 100644 index 000000000..a5d5bc880 --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_nl.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + UDisks Module Instellingen + + + + CD Audio Detection + CD Audio Detectie + + + + Add tracks to playlist automatically + Voeg nummers automatisch toe aan speellijst + + + + Remove tracks from playlist automatically + Verwijder nummers automatisch uit afspeellijst + + + + Removable Device Detection + Detectie van Verwisselbare Stations + + + + Add files to playlist automatically + Voeg bestanden automatisch toe aan afspeellijst + + + + Remove files from playlist automatically + Verwijder bestanden automatisch uit afspeellijst + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + Auteur: Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisks2Plugin + + + Add CD "%1" + Voeg CD "%1" toe + + + + Add Volume "%1" + Voeg Station "%1" toe + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_pl.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_pl.ts new file mode 100644 index 000000000..30c37463d --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_pl.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + Ustawienia wtyczki UDisks + + + + CD Audio Detection + Detekcja płyt CD Audio + + + + Add tracks to playlist automatically + Automatycznie dodaj utwory do listy + + + + Remove tracks from playlist automatically + Automatycznie usuń utwory z listy + + + + Removable Device Detection + Detekcja urządzeń przenośnych + + + + Add files to playlist automatically + Automatycznie dodaj pliki do listy + + + + Remove files from playlist automatically + Automatycznie usuń pliki z listy + + + + UDisksFactory + + + UDisks Plugin + Wtyczka UDisks + + + + About UDisks Plugin + O wtyczce UDisks + + + + Qmmp UDisks Plugin + Wtyczka UDisks dla Qmmp + + + + This plugin provides removable devices detection using UDisks + Ta wtyczka umożliwia wykrywanie urządzeń przenośnych przy użyciu UDisks + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + Autor: Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisksPlugin + + + Add CD "%1" + Dodaj CD "%1" + + + + Add Volume "%1" + Dodaj urządzenie "%1" + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_pl_PL.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_pl_PL.ts new file mode 100644 index 000000000..42ae3fd3f --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_pl_PL.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + Ustawienia wtyczki UDisks + + + + CD Audio Detection + Detekcja płyt CD Audio + + + + Add tracks to playlist automatically + Automatycznie dodaj utwory do listy + + + + Remove tracks from playlist automatically + Automatycznie usuń utwory z listy + + + + Removable Device Detection + Detekcja urządzeń przenośnych + + + + Add files to playlist automatically + Automatycznie dodaj pliki do listy + + + + Remove files from playlist automatically + Automatycznie usuń pliki z listy + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + Autor: Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisks2Plugin + + + Add CD "%1" + Dodaj CD "%1" + + + + Add Volume "%1" + Dodaj urządzenie "%1" + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_pt_BR.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_pt_BR.ts new file mode 100644 index 000000000..109bbdd6c --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_pt_BR.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + + + + + CD Audio Detection + + + + + Add tracks to playlist automatically + + + + + Remove tracks from playlist automatically + + + + + Removable Device Detection + + + + + Add files to playlist automatically + + + + + Remove files from playlist automatically + + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + + + + + UDisks2Plugin + + + Add CD "%1" + + + + + Add Volume "%1" + + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_ru.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_ru.ts new file mode 100644 index 000000000..141e0f214 --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_ru.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + Настройки модуля UDisks + + + + CD Audio Detection + Автоопределение аудио-CD + + + + Add tracks to playlist automatically + Автоматически добавлять треки в список + + + + Remove tracks from playlist automatically + Автоматически удалять треки из списка + + + + Removable Device Detection + Автоопределение съёмных устройств + + + + Add files to playlist automatically + Автоматически добавлять треки в список + + + + Remove files from playlist automatically + Автоматически удалять треки из списка + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + Разработчик: Илья Котов + + + + UDisks2Plugin + + + Add CD "%1" + Добавить CD "%1" + + + + Add Volume "%1" + Добавить том "%1" + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_sk.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_sk.ts new file mode 100644 index 000000000..b399fd529 --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_sk.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + + + + + CD Audio Detection + + + + + Add tracks to playlist automatically + + + + + Remove tracks from playlist automatically + + + + + Removable Device Detection + + + + + Add files to playlist automatically + + + + + Remove files from playlist automatically + + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + + + + + UDisks2Plugin + + + Add CD "%1" + + + + + Add Volume "%1" + + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_tr.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_tr.ts new file mode 100644 index 000000000..fa7ae73b2 --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_tr.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + + + + + CD Audio Detection + CD Ses Algılama + + + + Add tracks to playlist automatically + Parçaları listeye otomatik olarka ekle + + + + Remove tracks from playlist automatically + Parçaları listeden otomatik olarak kaldır + + + + Removable Device Detection + Çıkarılabilir Aygıt Algılama + + + + Add files to playlist automatically + Dosyaları listeye otomatik olarak ekle + + + + Remove files from playlist automatically + Dosyaları listeden otomatik olarak kaldır + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + Yazan: Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisks2Plugin + + + Add CD "%1" + CD "%1" Ekle + + + + Add Volume "%1" + "%1" Aygıtını Ekle + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_uk_UA.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_uk_UA.ts new file mode 100644 index 000000000..de6b8b2d2 --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_uk_UA.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + Налаштування модуля UDisks + + + + CD Audio Detection + Автовизначення аудіо-CD + + + + Add tracks to playlist automatically + Автоматично додавати треки до списку + + + + Remove tracks from playlist automatically + Автоматично видаляти треки зі списку + + + + Removable Device Detection + Виявлення змінних пристроїв + + + + Add files to playlist automatically + Автоматично додавати файли до списку + + + + Remove files from playlist automatically + Автоматично видаляти файли зі списку + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + Розробник: Ілля Котов <forkotov02@hotmail.ru> + + + + UDisks2Plugin + + + Add CD "%1" + Додати CD "%1" + + + + Add Volume "%1" + Додати том "%1" + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_zh_CN.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_zh_CN.ts new file mode 100644 index 000000000..a841ecf4a --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_zh_CN.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + UDisks 插件设置 + + + + CD Audio Detection + CD 音频检测 + + + + Add tracks to playlist automatically + 自动添加音轨到播放列表 + + + + Remove tracks from playlist automatically + 自动从播放列表删除音轨 + + + + Removable Device Detection + 可移动设备检测 + + + + Add files to playlist automatically + 自动添加文件到播放列表 + + + + Remove files from playlist automatically + 自动从播放列表删除文件 + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + 作者:Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisks2Plugin + + + Add CD "%1" + 添加 CD "%1" + + + + Add Volume "%1" + 添加卷 "%1" + + + diff --git a/src/plugins/General/udisks2/translations/udisks2_plugin_zh_TW.ts b/src/plugins/General/udisks2/translations/udisks2_plugin_zh_TW.ts new file mode 100644 index 000000000..5a26cfc09 --- /dev/null +++ b/src/plugins/General/udisks2/translations/udisks2_plugin_zh_TW.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + UDisks Plugin Settings + UDisks 插件設定 + + + + CD Audio Detection + CD 音頻檢測 + + + + Add tracks to playlist automatically + 自動添加音軌到播放清單 + + + + Remove tracks from playlist automatically + 自動從播放清單刪除音軌 + + + + Removable Device Detection + 可移動設備檢測 + + + + Add files to playlist automatically + 自動添加檔案到播放清單 + + + + Remove files from playlist automatically + 自動從播放清單刪除檔案 + + + + UDisks2Factory + + + UDisks2 Plugin + + + + + About UDisks2 Plugin + + + + + Qmmp UDisks2 Plugin + + + + + This plugin provides removable devices detection using UDisks2 + + + + + Written by: Ilya Kotov <forkotov02@hotmail.ru> + 作者:Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisks2Plugin + + + Add CD "%1" + 添加 CD "%1" + + + + Add Volume "%1" + 添加卷 "%1" + + + diff --git a/src/plugins/General/udisks2/udisks2.pro b/src/plugins/General/udisks2/udisks2.pro new file mode 100644 index 000000000..2d3b0a474 --- /dev/null +++ b/src/plugins/General/udisks2/udisks2.pro @@ -0,0 +1,54 @@ +include(../../plugins.pri) + +CONFIG += release \ +warn_on \ +plugin \ + lib \ + qdbus + +TARGET = $$PLUGINS_PREFIX/General/udisks2 +QMAKE_CLEAN = $$PLUGINS_PREFIX/General/libudisks2.so + +TEMPLATE = lib +QMAKE_LIBDIR += ../../../../lib + +TRANSLATIONS = translations/udisks2_plugin_cs.ts \ + translations/udisks2_plugin_de.ts \ + translations/udisks2_plugin_zh_CN.ts \ + translations/udisks2_plugin_zh_TW.ts \ + translations/udisks2_plugin_ru.ts \ + translations/udisks2_plugin_pl.ts \ + translations/udisks2_plugin_uk_UA.ts \ + translations/udisks2_plugin_it.ts \ + translations/udisks2_plugin_tr.ts \ + translations/udisks2_plugin_lt.ts \ + translations/udisks2_plugin_nl.ts \ + translations/udisks2_plugin_ja.ts \ + translations/udisks2_plugin_es.ts + +RESOURCES = translations/translations.qrc + +isEmpty(LIB_DIR){ + LIB_DIR = /lib +} +target.path = $$LIB_DIR/qmmp/General +INSTALLS += target + + +HEADERS += udisks2factory.h \ + udisks2plugin.h \ + udisks2manager.h \ + udisks2device.h \ + settingsdialog.h + +SOURCES += udisks2factory.cpp \ + udisks2plugin.cpp \ + udisks2manager.cpp \ + udisks2device.cpp \ + settingsdialog.cpp + +INCLUDEPATH += ../../../../src + +LIBS += -lqmmpui -lqmmp + +FORMS += settingsdialog.ui diff --git a/src/plugins/General/udisks2/udisks2device.cpp b/src/plugins/General/udisks2/udisks2device.cpp new file mode 100644 index 000000000..0733c9931 --- /dev/null +++ b/src/plugins/General/udisks2/udisks2device.cpp @@ -0,0 +1,115 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include +#include +#include +#include +#include "udisks2device.h" + +UDisks2Device::UDisks2Device(QDBusObjectPath o, QObject *parent) + : QObject(parent) +{ + m_block_interface = new QDBusInterface("org.freedesktop.UDisks2", o.path(), + "org.freedesktop.UDisks2.Block", QDBusConnection::systemBus(), + this); + m_fs_interface = new QDBusInterface("org.freedesktop.UDisks2", o.path(), + "org.freedesktop.UDisks2.Filesystem", QDBusConnection::systemBus(), + this); + QDBusObjectPath drive_object = property("Drive").value(); + + QDBusConnection::systemBus().connect("org.freedesktop.UDisks2", o.path(), + "org.freedesktop.DBus.Properties","PropertiesChanged", + this, SIGNAL(changed())); + + m_drive_interface = new QDBusInterface("org.freedesktop.UDisks2", drive_object.path(), + "org.freedesktop.UDisks2.Drive", QDBusConnection::systemBus(), + this); + m_path = o; +} + +UDisks2Device::~UDisks2Device() +{ +} + +QVariant UDisks2Device::property(const QString &key) const +{ + return m_block_interface->property(key.toAscii().data()); +} + +bool UDisks2Device::isRemovable() const +{ + return m_drive_interface->property("Removable").toBool(); +} + +bool UDisks2Device::isMediaRemovable() const +{ + return m_drive_interface->property("MediaRemovable").toBool(); +} + +bool UDisks2Device::isAudio() const +{ + return m_drive_interface->property("OpticalNumAudioTracks").toInt() > 0; +} + +bool UDisks2Device::isMounted() const +{ + return !mountPoints().isEmpty(); +} + +bool UDisks2Device::isOptical() const +{ + return m_drive_interface->property("Optical").toBool(); +} + +QStringList UDisks2Device::mountPoints() const +{ + QStringList points; + QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.UDisks2", m_path.path(), + "org.freedesktop.DBus.Properties", "Get"); + + QList arguments; + arguments << "org.freedesktop.UDisks2.Filesystem" << "MountPoints"; + message.setArguments(arguments); + + QDBusMessage reply = QDBusConnection::systemBus().call(message); + + QList args = reply.arguments(); + + foreach (QVariant arg, args) + { + QByteArrayList list; + arg.value().variant().value() >> list; + + foreach (QByteArray p, list) + points.append(p); + } + return points; +} + +QString UDisks2Device::deviceFile() const +{ + return QString::fromAscii(m_block_interface->property("Device").toByteArray()); +} + +QDBusObjectPath UDisks2Device::objectPath() const +{ + return m_path; +} diff --git a/src/plugins/General/udisks2/udisks2device.h b/src/plugins/General/udisks2/udisks2device.h new file mode 100644 index 000000000..8d1473fb0 --- /dev/null +++ b/src/plugins/General/udisks2/udisks2device.h @@ -0,0 +1,93 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef UDISKS2DEVICE_H +#define UDISKS2DEVICE_H + +#include +#include +#include +#include +#include +#include +#include + +class QDBusInterface; + +typedef QList QByteArrayList; +Q_DECLARE_METATYPE(QByteArrayList) + +inline const QDBusArgument &operator>>(const QDBusArgument &arg, QByteArrayList &list) +{ + arg.beginArray(); + list.clear(); + + while (!arg.atEnd()) + { + QByteArray element; + arg >> element; + list.append( element ); + } + arg.endArray(); + return arg; +} + +inline QDBusArgument &operator<<(QDBusArgument &arg, const QByteArrayList &list) +{ + arg.beginArray(qMetaTypeId()); + for (int i = 0; i < list.count(); ++i) + arg << list[i]; + arg.endArray(); + return arg; +} + + +/** + @author Ilya Kotov +*/ +class UDisks2Device : public QObject +{ + Q_OBJECT +public: + UDisks2Device(QDBusObjectPath o, QObject *parent = 0); + + ~UDisks2Device(); + + QVariant property(const QString &key) const; + bool isRemovable() const; + bool isMediaRemovable() const; + bool isAudio() const; + bool isMounted() const; + bool isOptical() const; + QStringList mountPoints() const; + QString deviceFile() const; + QDBusObjectPath objectPath() const; + +signals: + void changed(); + + +private: + QDBusInterface *m_block_interface; + QDBusInterface *m_drive_interface; + QDBusInterface *m_fs_interface; + QDBusObjectPath m_path; +}; + +#endif diff --git a/src/plugins/General/udisks2/udisks2factory.cpp b/src/plugins/General/udisks2/udisks2factory.cpp new file mode 100644 index 000000000..58c7ef2de --- /dev/null +++ b/src/plugins/General/udisks2/udisks2factory.cpp @@ -0,0 +1,64 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include +#include +#include "settingsdialog.h" +#include "udisks2plugin.h" +#include "udisks2factory.h" + +const GeneralProperties UDisks2Factory::properties() const +{ + GeneralProperties properties; + properties.name = tr("UDisks2 Plugin"); + properties.shortName = "udisks2"; + properties.hasAbout = true; + properties.hasSettings = true; + properties.visibilityControl = false; + return properties; +} + +QObject *UDisks2Factory::create(QObject *parent) +{ + return new UDisks2Plugin(parent); +} + +QDialog *UDisks2Factory::createConfigDialog(QWidget *parent) +{ + return new SettingsDialog(parent); +} + +void UDisks2Factory::showAbout(QWidget *parent) +{ + QMessageBox::about (parent, tr("About UDisks2 Plugin"), + tr("Qmmp UDisks2 Plugin") + "\n" + + tr("This plugin provides removable devices detection using UDisks2") + "\n" + + tr("Written by: Ilya Kotov ")); +} + +QTranslator *UDisks2Factory::createTranslator(QObject *parent) +{ + QTranslator *translator = new QTranslator(parent); + QString locale = Qmmp::systemLanguageID(); + translator->load(QString(":/udisks2_plugin_") + locale); + return translator; +} + +Q_EXPORT_PLUGIN2(udisks2, UDisks2Factory) diff --git a/src/plugins/General/udisks2/udisks2factory.h b/src/plugins/General/udisks2/udisks2factory.h new file mode 100644 index 000000000..3d28e80a0 --- /dev/null +++ b/src/plugins/General/udisks2/udisks2factory.h @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef UDISKS2FACTORY_H +#define UDISKS2FACTORY_H + +/** + @author Ilya Kotov +*/ +#include +#include + +#include +#include + +class UDisks2Factory : public QObject, public GeneralFactory +{ +Q_OBJECT +Q_INTERFACES(GeneralFactory) +public: + const GeneralProperties properties() const; + QObject *create(QObject *parent); + QDialog *createConfigDialog(QWidget *parent); + void showAbout(QWidget *parent); + QTranslator *createTranslator(QObject *parent); + +}; + +#endif diff --git a/src/plugins/General/udisks2/udisks2manager.cpp b/src/plugins/General/udisks2/udisks2manager.cpp new file mode 100644 index 000000000..48858404e --- /dev/null +++ b/src/plugins/General/udisks2/udisks2manager.cpp @@ -0,0 +1,93 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "udisks2manager.h" + +UDisks2Manager::UDisks2Manager(QObject *parent) + : QObject(parent) +{ + m_interface = new QDBusInterface("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2", + "org.freedesktop.DBus.ObjectManager", + QDBusConnection::systemBus(), this); + + m_interface->connection().connect("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2", + "org.freedesktop.DBus.ObjectManager", "InterfacesAdded", + this, SLOT(onInterfacesAdded(QDBusObjectPath,QVariantMapMap))); + + m_interface->connection().connect("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2", + "org.freedesktop.DBus.ObjectManager", "InterfacesRemoved", + this, SIGNAL(onInterfacesRemoved(QDBusObjectPath, QStringList))); +} + + +UDisks2Manager::~UDisks2Manager() +{ +} + +QList UDisks2Manager::findAllDevices() +{ + QList paths; + QDBusMessage call = QDBusMessage::createMethodCall("org.freedesktop.UDisks2", + "/org/freedesktop/UDisks2/block_devices", + "org.freedesktop.DBus.Introspectable", + "Introspect"); + QDBusPendingReply reply = QDBusConnection::systemBus().call(call); + + + if (!reply.isValid()) + { + qWarning("UDisks2Manager: error: %s", qPrintable(reply.error().name())); + return paths; + } + QXmlStreamReader xml(reply.value()); + while (!xml.atEnd()) + { + xml.readNext(); + if (xml.tokenType() == QXmlStreamReader::StartElement && xml.name().toString() == "node" ) + { + QString name = xml.attributes().value("name").toString(); + if(!name.isEmpty()) + paths << QDBusObjectPath("/org/freedesktop/UDisks2/block_devices/" + name); + } + } + return paths; +} + +void UDisks2Manager::onInterfacesAdded(const QDBusObjectPath &object_path, const QVariantMapMap &) +{ + if(object_path.path().startsWith("/org/freedesktop/UDisks2/jobs")) + return; + qDebug("UDisks2Manager: interfaces added: %s", qPrintable(object_path.path())); + emit deviceAdded(object_path); +} + +void UDisks2Manager::onInterfacesRemoved(const QDBusObjectPath &object_path, const QStringList &) +{ + if(object_path.path().startsWith("/org/freedesktop/UDisks2/jobs")) + return; + qDebug("UDisks2Manager: interfaces removed: %s", qPrintable(object_path.path())); + emit deviceRemoved(object_path); +} diff --git a/src/plugins/General/udisks2/udisks2manager.h b/src/plugins/General/udisks2/udisks2manager.h new file mode 100644 index 000000000..da539bc61 --- /dev/null +++ b/src/plugins/General/udisks2/udisks2manager.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef UDISKS2MANAGER_H +#define UDISKS2MANAGER_H + +#include +#include +#include +#include + +class QDBusInterface; + +typedef QMap QVariantMapMap; +Q_DECLARE_METATYPE(QVariantMapMap) + +/** + @author Ilya Kotov +*/ +class UDisks2Manager : public QObject +{ +Q_OBJECT +public: + UDisks2Manager(QObject *parent = 0); + + ~UDisks2Manager(); + + QList findAllDevices(); + +signals: + void deviceAdded(QDBusObjectPath); + void deviceRemoved(QDBusObjectPath); + +private slots: + void onInterfacesAdded(const QDBusObjectPath &object_path, const QVariantMapMap &); + void onInterfacesRemoved(const QDBusObjectPath &object_path, const QStringList &); + +private: + QDBusInterface *m_interface; + +}; + +#endif diff --git a/src/plugins/General/udisks2/udisks2plugin.cpp b/src/plugins/General/udisks2/udisks2plugin.cpp new file mode 100644 index 000000000..3ee249c79 --- /dev/null +++ b/src/plugins/General/udisks2/udisks2plugin.cpp @@ -0,0 +1,264 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "udisks2device.h" +#include "udisks2manager.h" +#include "udisks2plugin.h" + +UDisks2Plugin::UDisks2Plugin(QObject *parent) : QObject(parent) +{ + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + + m_manager = new UDisks2Manager(this); + m_actions = new QActionGroup(this); + connect(m_manager,SIGNAL(deviceAdded(QDBusObjectPath)), SLOT(addDevice(QDBusObjectPath))); + connect(m_manager,SIGNAL(deviceRemoved(QDBusObjectPath)), SLOT(removeDevice(QDBusObjectPath))); + connect(m_actions,SIGNAL(triggered (QAction *)), SLOT(processAction(QAction *))); + //load settings + QSettings settings(Qmmp::configFile(), QSettings::IniFormat); + settings.beginGroup("UDisks2"); + m_detectCDA = settings.value("cda", true).toBool(); + m_detectRemovable = settings.value("removable", true).toBool(); + m_addTracks = false; //do not load tracks on startup + m_addFiles = false; + //find existing devices + QList devs = m_manager->findAllDevices(); + foreach(QDBusObjectPath o, devs) + addDevice(o); + //load remaining settings + m_addTracks = settings.value("add_tracks", false).toBool(); + m_removeTracks = settings.value("remove_tracks", false).toBool(); + m_addFiles = settings.value("add_files", false).toBool(); + m_removeFiles = settings.value("remove_files", false).toBool(); + settings.endGroup(); +} + +UDisks2Plugin::~UDisks2Plugin() +{ +} + +void UDisks2Plugin::removeDevice(QDBusObjectPath o) +{ + foreach(UDisks2Device *device, m_devices) + { + if (device->objectPath() == o) + { + m_devices.removeAll(device); + delete device; + qDebug("UDisks2Plugin: device \"%s\" removed", qPrintable(o.path())); + updateActions(); + break; + } + } +} + +void UDisks2Plugin::addDevice(QDBusObjectPath o) +{ + foreach(UDisks2Device *device, m_devices) //is it already exists? + { + if (device->objectPath() == o) + return; + } + UDisks2Device *device = new UDisks2Device(o, this); + + //audio cd + if (device->isAudio()) + { + if (m_detectCDA) + { + qDebug("UDisks2Plugin: device \"%s\" added (cd audio)", qPrintable(o.path())); + m_devices << device; + connect(device, SIGNAL(changed()), SLOT(updateActions())); + updateActions(); + } + else + delete device; + return; + } + + if(!device->isRemovable()) + { + delete device; + return; + } + + if (device->property("Size").toLongLong() < 17000000000LL && + (device->property("IdType").toString() == "vfat" || + device->property("IdType").toString() == "iso9660" || + device->property("IdType").toString() == "udf" || + device->property("IdType").toString() == "ext2")) + { + if (m_detectRemovable) + { + qDebug("UDisks2Plugin: device \"%s\" added (removable)", qPrintable(o.path())); + m_devices << device; + updateActions(); + connect(device, SIGNAL(changed()), SLOT(updateActions())); + } + else + delete device; + return; + } + delete device; +} + +void UDisks2Plugin::updateActions() +{ + // add action for cd audio or mounted volume + foreach(UDisks2Device *device, m_devices) + { + QString dev_path; + if (device->isAudio()) //cd audio + { + dev_path = "cdda://" + device->deviceFile(); + qDebug("dev path = %s", qPrintable(dev_path)); + } + else if (device->isMounted()) //mounted volume + dev_path = device->mountPoints().first(); + else + continue; + + if (!findAction(dev_path)) + { + QAction *action = new QAction(this); + QString actionText; + if (device->isAudio()) + actionText = QString(tr("Add CD \"%1\"")).arg(device->deviceFile()); + else + { + QString name = device->property("IdLabel").toString(); + if (name.isEmpty()) + name = dev_path; + + actionText = QString(tr("Add Volume \"%1\"")).arg(name); + } + + if (device->isOptical()) + { + if(device->property("IdType").toString() == "iso9660") + action->setIcon(qApp->style()->standardIcon(QStyle::SP_DriveDVDIcon)); + else + action->setIcon(qApp->style()->standardIcon(QStyle::SP_DriveCDIcon)); + } + else + action->setIcon(qApp->style()->standardIcon(QStyle::SP_DriveHDIcon)); + + action->setText(actionText); + action->setData(dev_path); + m_actions->addAction(action); + UiHelper::instance()->addAction(action, UiHelper::TOOLS_MENU); + addPath(dev_path); + } + } + // remove action if device is unmounted/removed + foreach(QAction *action, m_actions->actions ()) + { + if (!findDevice(action)) + { + m_actions->removeAction(action); + UiHelper::instance()->removeAction(action); + removePath(action->data().toString()); + action->deleteLater(); + } + } +} + +void UDisks2Plugin::processAction(QAction *action) +{ + qDebug("UDisks2Plugin: action triggered: %s", qPrintable(action->data().toString())); + QString path = action->data().toString(); + MediaPlayer::instance()->playListManager()->selectedPlayList()->add(path); +} + +QAction *UDisks2Plugin::findAction(const QString &dev_path) +{ + foreach(QAction *action, m_actions->actions ()) + { + if (action->data().toString() == dev_path) + return action; + } + return 0; +} + +UDisks2Device *UDisks2Plugin::findDevice(QAction *action) +{ + foreach(UDisks2Device *device, m_devices) + { + QString dev_path; + if (device->isAudio()) + { + dev_path = "cdda://" + device->deviceFile(); + if (dev_path == action->data().toString()) + return device; + } + if (device->isMounted()) + { + dev_path = device->mountPoints().first(); + if (dev_path == action->data().toString()) + return device; + } + } + return 0; +} + +void UDisks2Plugin::addPath(const QString &path) +{ + foreach(PlayListItem *item, PlayListManager::instance()->selectedPlayList()->items()) // Is it already exist? + { + if (item->url().startsWith(path)) + return; + } + + if (path.startsWith("cdda://") && m_addTracks) + { + PlayListManager::instance()->selectedPlayList()->add(path); + return; + } + else if (!path.startsWith("cdda://") && m_addFiles) + PlayListManager::instance()->selectedPlayList()->add(path); +} + +void UDisks2Plugin::removePath(const QString &path) +{ + if ((path.startsWith("cdda://") && !m_removeTracks) || + (!path.startsWith("cdda://") && !m_removeFiles)) //process settings + return; + + PlayListModel *model = PlayListManager::instance()->selectedPlayList(); + + int i = 0; + while (model->count() > 0 && i < model->count()) + { + if (model->item(i)->url().startsWith(path)) + model->removeAt (i); + else + ++i; + } +} diff --git a/src/plugins/General/udisks2/udisks2plugin.h b/src/plugins/General/udisks2/udisks2plugin.h new file mode 100644 index 000000000..c545de378 --- /dev/null +++ b/src/plugins/General/udisks2/udisks2plugin.h @@ -0,0 +1,65 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef UDISKS2PLUGIN_H +#define UDISKS2PLUGIN_H + +#include +#include + +class UDisks2Manager; +class UDisks2Device; +class QActionGroup; +class QAction; + +/** + @author Ilya Kotov +*/ + +class UDisks2Plugin : public QObject +{ +Q_OBJECT +public: + UDisks2Plugin(QObject *parent = 0); + + ~UDisks2Plugin(); + +private slots: + void removeDevice(QDBusObjectPath); + void addDevice(QDBusObjectPath); + void processAction(QAction *action); + void updateActions(); + +private: + QAction *findAction(const QString &dev_path); + UDisks2Device *findDevice(QAction *action); + void addPath(const QString &path); + void removePath(const QString &path); + UDisks2Manager *m_manager; + QList m_devices; + QActionGroup *m_actions; + bool m_detectCDA; + bool m_addTracks; + bool m_removeTracks; + bool m_detectRemovable; + bool m_addFiles; + bool m_removeFiles; +}; + +#endif //UDISKS2PLUGIN_H -- cgit v1.2.3-13-gbd6f