From dd5a730d8a67b8bd4eb0d906e920c5720f380d37 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sun, 29 Aug 2010 15:59:19 +0000 Subject: added udisks plugin git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1856 90c681e8-e032-0410-971d-27865f9a5e38 --- CMakeLists.txt | 1 + README | 4 +- README.RUS | 4 +- src/plugins/General/CMakeLists.txt | 5 + src/plugins/General/General.pro | 3 +- src/plugins/General/udisks/CMakeLists.txt | 66 ++++++ src/plugins/General/udisks/settingsdialog.cpp | 58 +++++ src/plugins/General/udisks/settingsdialog.h | 46 ++++ src/plugins/General/udisks/settingsdialog.ui | 121 ++++++++++ .../General/udisks/translations/translations.qrc | 18 ++ .../udisks/translations/udisks_plugin_cs.ts | 83 +++++++ .../udisks/translations/udisks_plugin_de.ts | 83 +++++++ .../udisks/translations/udisks_plugin_es.ts | 83 +++++++ .../udisks/translations/udisks_plugin_it.ts | 83 +++++++ .../udisks/translations/udisks_plugin_ja.ts | 83 +++++++ .../udisks/translations/udisks_plugin_lt.ts | 83 +++++++ .../udisks/translations/udisks_plugin_nl.ts | 83 +++++++ .../udisks/translations/udisks_plugin_pl.ts | 83 +++++++ .../udisks/translations/udisks_plugin_ru.ts | 83 +++++++ .../udisks/translations/udisks_plugin_tr.ts | 83 +++++++ .../udisks/translations/udisks_plugin_uk_UA.ts | 83 +++++++ .../udisks/translations/udisks_plugin_zh_CN.ts | 83 +++++++ .../udisks/translations/udisks_plugin_zh_TW.ts | 83 +++++++ src/plugins/General/udisks/udisks.pro | 54 +++++ src/plugins/General/udisks/udisksdevice.cpp | 50 ++++ src/plugins/General/udisks/udisksdevice.h | 54 +++++ src/plugins/General/udisks/udisksfactory.cpp | 64 ++++++ src/plugins/General/udisks/udisksfactory.h | 45 ++++ src/plugins/General/udisks/udisksmanager.cpp | 57 +++++ src/plugins/General/udisks/udisksmanager.h | 51 +++++ src/plugins/General/udisks/udisksplugin.cpp | 255 +++++++++++++++++++++ src/plugins/General/udisks/udisksplugin.h | 65 ++++++ 32 files changed, 2095 insertions(+), 5 deletions(-) create mode 100644 src/plugins/General/udisks/CMakeLists.txt create mode 100644 src/plugins/General/udisks/settingsdialog.cpp create mode 100644 src/plugins/General/udisks/settingsdialog.h create mode 100644 src/plugins/General/udisks/settingsdialog.ui create mode 100644 src/plugins/General/udisks/translations/translations.qrc create mode 100644 src/plugins/General/udisks/translations/udisks_plugin_cs.ts create mode 100644 src/plugins/General/udisks/translations/udisks_plugin_de.ts create mode 100644 src/plugins/General/udisks/translations/udisks_plugin_es.ts create mode 100644 src/plugins/General/udisks/translations/udisks_plugin_it.ts create mode 100644 src/plugins/General/udisks/translations/udisks_plugin_ja.ts create mode 100644 src/plugins/General/udisks/translations/udisks_plugin_lt.ts create mode 100644 src/plugins/General/udisks/translations/udisks_plugin_nl.ts create mode 100644 src/plugins/General/udisks/translations/udisks_plugin_pl.ts create mode 100644 src/plugins/General/udisks/translations/udisks_plugin_ru.ts create mode 100644 src/plugins/General/udisks/translations/udisks_plugin_tr.ts create mode 100644 src/plugins/General/udisks/translations/udisks_plugin_uk_UA.ts create mode 100644 src/plugins/General/udisks/translations/udisks_plugin_zh_CN.ts create mode 100644 src/plugins/General/udisks/translations/udisks_plugin_zh_TW.ts create mode 100644 src/plugins/General/udisks/udisks.pro create mode 100644 src/plugins/General/udisks/udisksdevice.cpp create mode 100644 src/plugins/General/udisks/udisksdevice.h create mode 100644 src/plugins/General/udisks/udisksfactory.cpp create mode 100644 src/plugins/General/udisks/udisksfactory.h create mode 100644 src/plugins/General/udisks/udisksmanager.cpp create mode 100644 src/plugins/General/udisks/udisksmanager.h create mode 100644 src/plugins/General/udisks/udisksplugin.cpp create mode 100644 src/plugins/General/udisks/udisksplugin.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b02bbeb85..2ee2fdf60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,6 +142,7 @@ PRINT_SUMMARY ("Tray support ......................" USE_STATICON 1) PRINT_SUMMARY ("Notifier support .................." USE_NOTIFIER 1) PRINT_SUMMARY ("Lyrics support ...................." USE_LYRICS 1) PRINT_SUMMARY ("HAL support ......................." USE_HAL 1) +PRINT_SUMMARY ("UDisks support ...................." USE_UDISKS 1) PRINT_SUMMARY ("Global hotkey support ............." USE_HOTKEY X11_FOUND) PRINT_SUMMARY ("File operations ..................." USE_FILEOPS 1) PRINT_SUMMARY ("Cover manager ....................." USE_COVER 1) diff --git a/README b/README index f809cc1ce..35397d55e 100644 --- a/README +++ b/README @@ -38,7 +38,7 @@ Other features: - MP3, Vorbis, AAC, AAC+ streams support - mms support (experimental) - MPRIS -- Removable device detection (via HAL) +- Removable device detection (via HAL or UDisks) - Video playback via Mplayer - Lyrics (using lyricsplugin.com) - Cover art support @@ -105,7 +105,7 @@ Available options: - USE_SRC, USE_BS2B, USE_LADSPA (effects); - USE_ANALYZER, USE_PROJECTM (visualization); - USE_MPRIS, USE_SCROBBLER, USE_STATICON, USE_NOTIFIER, USE_LYRICS, USE_HAL, USE_HOTKEY, USE_FILEOPS, USE_COVER, - USE_KDENOTIFY (general plugins); + USE_KDENOTIFY, USE_UDISKS (general plugins); - USE_QMMP_DIALOG (file dialog); - USE_ENCA (automatic charset detection); - USE_SKINNED (standard skinned UI) diff --git a/README.RUS b/README.RUS index ff58ee316..99641a6df 100644 --- a/README.RUS +++ b/README.RUS @@ -38,7 +38,7 @@ Qmmp - Qt-based multimedia player - поддержка потоков MP3, Vorbis, AAC, AAC+ - поддержка протокола MMS (экспериментальная) - MPRIS -- автоопределение съёмных устройств (с помощью HAL) +- автоопределение съёмных устройств (с помощью HAL или UDisks) - воспроизведение видео с помощью Mplayer-а - получение текстов песен с lyricsplugin.com - просмотр обложек @@ -104,7 +104,7 @@ cmake ./ -DUSE_JACK:BOOL=FALSE - USE_SRC, USE_BS2B, USE_LADSPA (эффекты); - USE_ANALYZER, USE_PROJECTM (визуализация); - USE_MPRIS, USE_SCROBBLER, USE_STATICON, USE_NOTIFIER, USE_LYRICS, USE_HAL, USE_HOTKEY, USE_FILEOPS, USE_COVER, - USE_KDENOTIFY (модули общего назначения); + USE_KDENOTIFY, USE_UDISKS (модули общего назначения); - USE_QMMP_DIALOG (файловый диалог); - USE_ENCA (автоматическое определение кодировки); - USE_SKINNED (стандартный пользовательский интерфейс) diff --git a/src/plugins/General/CMakeLists.txt b/src/plugins/General/CMakeLists.txt index 629c741a8..cb8931cc0 100644 --- a/src/plugins/General/CMakeLists.txt +++ b/src/plugins/General/CMakeLists.txt @@ -4,6 +4,7 @@ SET(USE_STATICON TRUE CACHE BOOL "enable/disable status icon plugin") SET(USE_NOTIFIER TRUE CACHE BOOL "enable/disable notifier plugin") SET(USE_LYRICS TRUE CACHE BOOL "enable/disable lyrics version") SET(USE_HAL TRUE CACHE BOOL "enable/disable hal plugin") +SET(USE_UDISKS TRUE CACHE BOOL "enable/disable udisks plugin") SET(USE_HOTKEY TRUE CACHE BOOL "enable/disable global hotkey plugin") SET(USE_FILEOPS TRUE CACHE BOOL "enable/disable fileops plugin") SET(USE_COVER TRUE CACHE BOOL "enable/disable cover manager plugin") @@ -33,6 +34,10 @@ IF(USE_HAL) add_subdirectory(hal) ENDIF(USE_HAL) +IF(USE_UDISKS) +add_subdirectory(udisks) +ENDIF(USE_UDISKS) + IF(USE_HOTKEY) add_subdirectory(hotkey) ENDIF(USE_HOTKEY) diff --git a/src/plugins/General/General.pro b/src/plugins/General/General.pro index 4c935d9a2..4fb1e2f19 100644 --- a/src/plugins/General/General.pro +++ b/src/plugins/General/General.pro @@ -3,8 +3,9 @@ SUBDIRS += statusicon \ lyrics \ scrobbler \ fileops -unix:SUBDIRS += mpris \ +unix:SUBDIRS += mpris \ hal \ + udisks \ hotkey \ covermanager \ kdenotify diff --git a/src/plugins/General/udisks/CMakeLists.txt b/src/plugins/General/udisks/CMakeLists.txt new file mode 100644 index 000000000..186c3ed5e --- /dev/null +++ b/src/plugins/General/udisks/CMakeLists.txt @@ -0,0 +1,66 @@ +project(libudisks) + +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(libudisks_SRCS + udisksfactory.cpp + udisksmanager.cpp + udisksplugin.cpp + udisksdevice.cpp + settingsdialog.cpp +) + +SET(libudisks_MOC_HDRS + udisksfactory.h + udisksmanager.h + udisksplugin.h + udisksdevice.h + settingsdialog.h +) + +SET(libudisks_RCCS translations/translations.qrc) + +QT4_ADD_RESOURCES(libudisks_RCC_SRCS ${libudisks_RCCS}) + +QT4_WRAP_CPP(libudisks_MOC_SRCS ${libudisks_MOC_HDRS}) + +# user interface + +SET(libudisks_UIS + settingsdialog.ui +) + +QT4_WRAP_UI(libudisks_UIS_H ${libudisks_UIS}) +# Don't forget to include output directory, otherwise +# the UI file won't be wrapped! +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +ADD_LIBRARY(udisks MODULE ${libudisks_SRCS} ${libudisks_MOC_SRCS} ${libudisks_UIS_H} ${libudisks_RCC_SRCS}) +add_dependencies(udisks qmmpui) +target_link_libraries(udisks ${QT_LIBRARIES} -lqmmpui -lqmmp) +install(TARGETS udisks DESTINATION ${LIB_DIR}/qmmp/General) diff --git a/src/plugins/General/udisks/settingsdialog.cpp b/src/plugins/General/udisks/settingsdialog.cpp new file mode 100644 index 000000000..3e9b99cfd --- /dev/null +++ b/src/plugins/General/udisks/settingsdialog.cpp @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (C) 2010 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include + +#include + +#include "settingsdialog.h" + +SettingsDialog::SettingsDialog(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + QSettings settings(Qmmp::configFile(), QSettings::IniFormat); + settings.beginGroup("UDisks"); + ui.cdGroupBox->setChecked(settings.value("cda", true).toBool()); + ui.addTracksCheckBox->setChecked(settings.value("add_tracks", false).toBool()); + ui.removeTracksCheckBox->setChecked(settings.value("remove_tracks", false).toBool()); + ui.removableGroupBox->setChecked(settings.value("removable", true).toBool()); + ui.addFilesCheckBox->setChecked(settings.value("add_files", false).toBool()); + ui.removeFilesCheckBox->setChecked(settings.value("remove_files", false).toBool()); + settings.endGroup(); +} + + +SettingsDialog::~SettingsDialog() +{} + +void SettingsDialog::accept() +{ + QSettings settings(Qmmp::configFile(), QSettings::IniFormat); + settings.beginGroup("UDisks"); + settings.setValue("cda", ui.cdGroupBox->isChecked()); + settings.setValue("add_tracks", ui.addTracksCheckBox->isChecked()); + settings.setValue("remove_tracks", ui.removeTracksCheckBox->isChecked()); + settings.setValue("removable", ui.removableGroupBox->isChecked()); + settings.setValue("add_files", ui.addFilesCheckBox->isChecked()); + settings.setValue("remove_files", ui.removeFilesCheckBox->isChecked()); + settings.endGroup(); + QDialog::accept(); +} diff --git a/src/plugins/General/udisks/settingsdialog.h b/src/plugins/General/udisks/settingsdialog.h new file mode 100644 index 000000000..c2dc37d8c --- /dev/null +++ b/src/plugins/General/udisks/settingsdialog.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * Copyright (C) 2010 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 ui; +}; + +#endif diff --git a/src/plugins/General/udisks/settingsdialog.ui b/src/plugins/General/udisks/settingsdialog.ui new file mode 100644 index 000000000..62ef465f4 --- /dev/null +++ b/src/plugins/General/udisks/settingsdialog.ui @@ -0,0 +1,121 @@ + + SettingsDialog + + + + 0 + 0 + 348 + 247 + + + + HAL 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/udisks/translations/translations.qrc b/src/plugins/General/udisks/translations/translations.qrc new file mode 100644 index 000000000..03690dedf --- /dev/null +++ b/src/plugins/General/udisks/translations/translations.qrc @@ -0,0 +1,18 @@ + + + + udisks_plugin_it.qm + udisks_plugin_ru.qm + udisks_plugin_uk_UA.qm + udisks_plugin_zh_CN.qm + udisks_plugin_zh_TW.qm + udisks_plugin_cs.qm + udisks_plugin_de.qm + udisks_plugin_pl.qm + udisks_plugin_tr.qm + udisks_plugin_lt.qm + udisks_plugin_nl.qm + udisks_plugin_ja.qm + udisks_plugin_es.qm + + diff --git a/src/plugins/General/udisks/translations/udisks_plugin_cs.ts b/src/plugins/General/udisks/translations/udisks_plugin_cs.ts new file mode 100644 index 000000000..8c09baf6a --- /dev/null +++ b/src/plugins/General/udisks/translations/udisks_plugin_cs.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + HAL Plugin Settings + Nastavení modulu HAL + + + + 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 + + + + UDisksFactory + + + UDisks Plugin + + + + + About UDisks Plugin + + + + + Qmmp UDisks Plugin + + + + + This plugin provides removable devices detection using UDisks + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + Autor: Ilja Kotov <forkotov02@hotmail.ru> + + + + UDisksPlugin + + + Add CD "%1" + Přidat CD „%1“ + + + + Add Volume "%1" + Přidat svazek „%1“ + + + diff --git a/src/plugins/General/udisks/translations/udisks_plugin_de.ts b/src/plugins/General/udisks/translations/udisks_plugin_de.ts new file mode 100644 index 000000000..3f83b44d5 --- /dev/null +++ b/src/plugins/General/udisks/translations/udisks_plugin_de.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + HAL Plugin Settings + Einstellungen HAL-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 + + + + UDisksFactory + + + UDisks Plugin + + + + + About UDisks Plugin + + + + + Qmmp UDisks Plugin + + + + + This plugin provides removable devices detection using UDisks + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + Autor: Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisksPlugin + + + Add CD "%1" + CD „%1“ hinzufügen + + + + Add Volume "%1" + + + + diff --git a/src/plugins/General/udisks/translations/udisks_plugin_es.ts b/src/plugins/General/udisks/translations/udisks_plugin_es.ts new file mode 100644 index 000000000..fd34828c4 --- /dev/null +++ b/src/plugins/General/udisks/translations/udisks_plugin_es.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + HAL Plugin Settings + Configuración del módulo HAL + + + + 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 + + + + UDisksFactory + + + UDisks Plugin + + + + + About UDisks Plugin + + + + + Qmmp UDisks Plugin + + + + + This plugin provides removable devices detection using UDisks + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + Escrito por: Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisksPlugin + + + Add CD "%1" + Añadir CD "%1" + + + + Add Volume "%1" + Añadir volumen "%1" + + + diff --git a/src/plugins/General/udisks/translations/udisks_plugin_it.ts b/src/plugins/General/udisks/translations/udisks_plugin_it.ts new file mode 100644 index 000000000..41e58e207 --- /dev/null +++ b/src/plugins/General/udisks/translations/udisks_plugin_it.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + HAL Plugin Settings + Impostazioni modulo HAL + + + + 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 + + + + UDisksFactory + + + UDisks Plugin + + + + + About UDisks Plugin + + + + + Qmmp UDisks Plugin + + + + + This plugin provides removable devices detection using UDisks + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + Autore: Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisksPlugin + + + Add CD "%1" + Aggiungi CD "%1" + + + + Add Volume "%1" + Aggiungi libreria "%1" + + + diff --git a/src/plugins/General/udisks/translations/udisks_plugin_ja.ts b/src/plugins/General/udisks/translations/udisks_plugin_ja.ts new file mode 100644 index 000000000..297b80532 --- /dev/null +++ b/src/plugins/General/udisks/translations/udisks_plugin_ja.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + HAL Plugin Settings + HAL プラグイン設定 + + + + 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 + プレイリストからファイルを自動除去 + + + + UDisksFactory + + + UDisks Plugin + + + + + About UDisks Plugin + + + + + Qmmp UDisks Plugin + + + + + This plugin provides removable devices detection using UDisks + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + 制作: Илья Котов (Ilya Kotov) <forkotov02@hotmail.ru> + + + + UDisksPlugin + + + Add CD "%1" + Cd "%1" を追加 + + + + Add Volume "%1" + 量目 "%1" を追加 + + + diff --git a/src/plugins/General/udisks/translations/udisks_plugin_lt.ts b/src/plugins/General/udisks/translations/udisks_plugin_lt.ts new file mode 100644 index 000000000..4c957514f --- /dev/null +++ b/src/plugins/General/udisks/translations/udisks_plugin_lt.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + HAL Plugin Settings + HAL į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 + + + + UDisksFactory + + + UDisks Plugin + + + + + About UDisks Plugin + + + + + Qmmp UDisks Plugin + + + + + This plugin provides removable devices detection using UDisks + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + Sukūrė: Ilya Kotov + + + + UDisksPlugin + + + Add CD "%1" + Pridėti CD "%1" + + + + Add Volume "%1" + Pridėti tomą "%1" + + + diff --git a/src/plugins/General/udisks/translations/udisks_plugin_nl.ts b/src/plugins/General/udisks/translations/udisks_plugin_nl.ts new file mode 100644 index 000000000..1e226aca0 --- /dev/null +++ b/src/plugins/General/udisks/translations/udisks_plugin_nl.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + HAL Plugin Settings + HAL 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 van speellijst + + + + 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 van afspeellijst + + + + UDisksFactory + + + UDisks Plugin + + + + + About UDisks Plugin + + + + + Qmmp UDisks Plugin + + + + + This plugin provides removable devices detection using UDisks + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + Auteur: Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisksPlugin + + + Add CD "%1" + Voeg CD "%1" toe + + + + Add Volume "%1" + Voeg Station "%1" toe + + + diff --git a/src/plugins/General/udisks/translations/udisks_plugin_pl.ts b/src/plugins/General/udisks/translations/udisks_plugin_pl.ts new file mode 100644 index 000000000..e2ea43ba5 --- /dev/null +++ b/src/plugins/General/udisks/translations/udisks_plugin_pl.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + HAL Plugin Settings + Ustawienia wtyczki HAL + + + + 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 + + + + + About UDisks Plugin + + + + + Qmmp UDisks Plugin + + + + + This plugin provides removable devices detection using UDisks + + + + + Writen 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/udisks/translations/udisks_plugin_ru.ts b/src/plugins/General/udisks/translations/udisks_plugin_ru.ts new file mode 100644 index 000000000..d4051be29 --- /dev/null +++ b/src/plugins/General/udisks/translations/udisks_plugin_ru.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + HAL Plugin Settings + Настройки модуля HAL + + + + 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 + Автоматически удалять треки из списка + + + + UDisksFactory + + + UDisks Plugin + + + + + About UDisks Plugin + + + + + Qmmp UDisks Plugin + + + + + This plugin provides removable devices detection using UDisks + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + Разработчик: Илья Котов + + + + UDisksPlugin + + + Add CD "%1" + Добавить CD "%1" + + + + Add Volume "%1" + Добавить том "%1" + + + diff --git a/src/plugins/General/udisks/translations/udisks_plugin_tr.ts b/src/plugins/General/udisks/translations/udisks_plugin_tr.ts new file mode 100644 index 000000000..9598d418f --- /dev/null +++ b/src/plugins/General/udisks/translations/udisks_plugin_tr.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + HAL Plugin Settings + HAL Eklentis Ayarları + + + + 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 + + + + UDisksFactory + + + UDisks Plugin + + + + + About UDisks Plugin + + + + + Qmmp UDisks Plugin + + + + + This plugin provides removable devices detection using UDisks + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + Yazan: Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisksPlugin + + + Add CD "%1" + CD "%1" Ekle + + + + Add Volume "%1" + "%1" Aygıtını Ekle + + + diff --git a/src/plugins/General/udisks/translations/udisks_plugin_uk_UA.ts b/src/plugins/General/udisks/translations/udisks_plugin_uk_UA.ts new file mode 100644 index 000000000..555eb6d9f --- /dev/null +++ b/src/plugins/General/udisks/translations/udisks_plugin_uk_UA.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + HAL Plugin Settings + Налаштування модуля HAL + + + + 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 + Автоматично видаляти файли зі списку + + + + UDisksFactory + + + UDisks Plugin + + + + + About UDisks Plugin + + + + + Qmmp UDisks Plugin + + + + + This plugin provides removable devices detection using UDisks + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + Розробник: Ілля Котов <forkotov02@hotmail.ru> + + + + UDisksPlugin + + + Add CD "%1" + Додати CD "%1" + + + + Add Volume "%1" + Додати том "%1" + + + diff --git a/src/plugins/General/udisks/translations/udisks_plugin_zh_CN.ts b/src/plugins/General/udisks/translations/udisks_plugin_zh_CN.ts new file mode 100644 index 000000000..64a4f47dd --- /dev/null +++ b/src/plugins/General/udisks/translations/udisks_plugin_zh_CN.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + HAL Plugin Settings + HAL 插件设置 + + + + 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 + 自动从播放列表删除文件 + + + + UDisksFactory + + + UDisks Plugin + + + + + About UDisks Plugin + + + + + Qmmp UDisks Plugin + + + + + This plugin provides removable devices detection using UDisks + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + 作者:Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisksPlugin + + + Add CD "%1" + 添加 CD "%1" + + + + Add Volume "%1" + 添加卷 "%1" + + + diff --git a/src/plugins/General/udisks/translations/udisks_plugin_zh_TW.ts b/src/plugins/General/udisks/translations/udisks_plugin_zh_TW.ts new file mode 100644 index 000000000..a51f00fbe --- /dev/null +++ b/src/plugins/General/udisks/translations/udisks_plugin_zh_TW.ts @@ -0,0 +1,83 @@ + + + + + SettingsDialog + + + HAL Plugin Settings + HAL 插件設置 + + + + 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 + 自動從播放清單刪除檔案 + + + + UDisksFactory + + + UDisks Plugin + + + + + About UDisks Plugin + + + + + Qmmp UDisks Plugin + + + + + This plugin provides removable devices detection using UDisks + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + 作者:Ilya Kotov <forkotov02@hotmail.ru> + + + + UDisksPlugin + + + Add CD "%1" + 添加 CD "%1" + + + + Add Volume "%1" + 添加卷 "%1" + + + diff --git a/src/plugins/General/udisks/udisks.pro b/src/plugins/General/udisks/udisks.pro new file mode 100644 index 000000000..90d9a5ad6 --- /dev/null +++ b/src/plugins/General/udisks/udisks.pro @@ -0,0 +1,54 @@ +include(../../plugins.pri) + +CONFIG += release \ +warn_on \ +plugin \ + lib \ + qdbus + +TARGET = $$PLUGINS_PREFIX/General/udisks +QMAKE_CLEAN = $$PLUGINS_PREFIX/General/libudisks.so + +TEMPLATE = lib +QMAKE_LIBDIR += ../../../../lib + +TRANSLATIONS = translations/udisks_plugin_cs.ts \ + translations/udisks_plugin_de.ts \ + translations/udisks_plugin_zh_CN.ts \ + translations/udisks_plugin_zh_TW.ts \ + translations/udisks_plugin_ru.ts \ + translations/udisks_plugin_pl.ts \ + translations/udisks_plugin_uk_UA.ts \ + translations/udisks_plugin_it.ts \ + translations/udisks_plugin_tr.ts \ + translations/udisks_plugin_lt.ts \ + translations/udisks_plugin_nl.ts \ + translations/udisks_plugin_ja.ts \ + translations/udisks_plugin_es.ts + +RESOURCES = translations/translations.qrc + +isEmpty(LIB_DIR){ + LIB_DIR = /lib +} +target.path = $$LIB_DIR/qmmp/General +INSTALLS += target + + +HEADERS += udisksfactory.h \ + udisksplugin.h \ + udisksmanager.h \ + udisksdevice.h \ + settingsdialog.h + +SOURCES += udisksfactory.cpp \ + udisksplugin.cpp \ + udisksmanager.cpp \ + udisksdevice.cpp \ + settingsdialog.cpp + +INCLUDEPATH += ../../../../src + +LIBS += -lqmmpui -lqmmp + +FORMS += settingsdialog.ui diff --git a/src/plugins/General/udisks/udisksdevice.cpp b/src/plugins/General/udisks/udisksdevice.cpp new file mode 100644 index 000000000..d9863bb39 --- /dev/null +++ b/src/plugins/General/udisks/udisksdevice.cpp @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2010 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include + +#include "udisksdevice.h" + + +UDisksDevice::UDisksDevice(QDBusObjectPath o, QObject *parent) + : QObject(parent) +{ + m_interface = new QDBusInterface("org.freedesktop.UDisks", o.path(), + "org.freedesktop.UDisks.Device", QDBusConnection::systemBus(), this); + m_interface->connection().connect("org.freedesktop.UDisks", o.path(), + "org.freedesktop.UDisks.Device","Changed", + this, SIGNAL(changed())); + m_path = o; +} + +QVariant UDisksDevice::property (const QString &key) +{ + return m_interface->property(key.toAscii().data()); +} + +UDisksDevice::~UDisksDevice() +{ +} + +QDBusObjectPath UDisksDevice::objectPath() const +{ + return m_path; +} diff --git a/src/plugins/General/udisks/udisksdevice.h b/src/plugins/General/udisks/udisksdevice.h new file mode 100644 index 000000000..59a1387c8 --- /dev/null +++ b/src/plugins/General/udisks/udisksdevice.h @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) 2010 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef UDISKSDEVICE_H +#define UDISKSDEVICE_H + +#include +#include +#include +#include +#include + +class QDBusInterface; + +/** + @author Ilya Kotov +*/ +class UDisksDevice : public QObject +{ + Q_OBJECT +public: + UDisksDevice(QDBusObjectPath o, QObject *parent = 0); + + ~UDisksDevice(); + + QVariant property (const QString &key); + QDBusObjectPath objectPath() const; + +signals: + void changed(); + + +private: + QDBusInterface *m_interface; + QDBusObjectPath m_path; +}; + +#endif diff --git a/src/plugins/General/udisks/udisksfactory.cpp b/src/plugins/General/udisks/udisksfactory.cpp new file mode 100644 index 000000000..89fcb5e5b --- /dev/null +++ b/src/plugins/General/udisks/udisksfactory.cpp @@ -0,0 +1,64 @@ +/*************************************************************************** + * Copyright (C) 2010 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include +#include "settingsdialog.h" +#include "udisksplugin.h" +#include "udisksfactory.h" + +const GeneralProperties UDisksFactory::properties() const +{ + GeneralProperties properties; + properties.name = tr("UDisks Plugin"); + properties.shortName = "udisks"; + properties.hasAbout = true; + properties.hasSettings = true; + properties.visibilityControl = false; + return properties; +} + +General *UDisksFactory::create(QObject *parent) +{ + return new UDisksPlugin(parent); +} + +QDialog *UDisksFactory::createConfigDialog(QWidget *parent) +{ + return new SettingsDialog(parent); +} + +void UDisksFactory::showAbout(QWidget *parent) +{ + QMessageBox::about (parent, tr("About UDisks Plugin"), + tr("Qmmp UDisks Plugin") + "\n" + + tr("This plugin provides removable devices detection using UDisks") + "\n" + + tr("Writen by: Ilya Kotov ")); +} + +QTranslator *UDisksFactory::createTranslator(QObject *parent) +{ + QTranslator *translator = new QTranslator(parent); + QString locale = Qmmp::systemLanguageID(); + translator->load(QString(":/udisks_plugin_") + locale); + return translator; +} + +Q_EXPORT_PLUGIN2(udisks, UDisksFactory) diff --git a/src/plugins/General/udisks/udisksfactory.h b/src/plugins/General/udisks/udisksfactory.h new file mode 100644 index 000000000..73e7195ce --- /dev/null +++ b/src/plugins/General/udisks/udisksfactory.h @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2010 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef DEVDETECTFACTORY_H +#define DEVDETECTFACTORY_H + +/** + @author Ilya Kotov +*/ +#include +#include + +#include +#include + +class UDisksFactory : public QObject, public GeneralFactory +{ +Q_OBJECT +Q_INTERFACES(GeneralFactory); +public: + const GeneralProperties properties() const; + General *create(QObject *parent); + QDialog *createConfigDialog(QWidget *parent); + void showAbout(QWidget *parent); + QTranslator *createTranslator(QObject *parent); + +}; + +#endif diff --git a/src/plugins/General/udisks/udisksmanager.cpp b/src/plugins/General/udisks/udisksmanager.cpp new file mode 100644 index 000000000..a05b4d0ad --- /dev/null +++ b/src/plugins/General/udisks/udisksmanager.cpp @@ -0,0 +1,57 @@ +/*************************************************************************** + * Copyright (C) 2010 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include +#include + +#include "udisksmanager.h" + +UDisksManager::UDisksManager(QObject *parent) + : QObject(parent) +{ + m_interface = new QDBusInterface("org.freedesktop.UDisks", "/org/freedesktop/UDisks", + "org.freedesktop.UDisks", QDBusConnection::systemBus(), this); + + m_interface->connection().connect("org.freedesktop.UDisks", "/org/freedesktop/UDisks", + "org.freedesktop.UDisks", "DeviceAdded", + this, SIGNAL(deviceAdded(QDBusObjectPath))); + + m_interface->connection().connect("org.freedesktop.UDisks", "/org/freedesktop/UDisks", + "org.freedesktop.UDisks", "DeviceRemoved", + this, SIGNAL(deviceRemoved(QDBusObjectPath))); + +} + + +UDisksManager::~UDisksManager() +{ +} + +QList UDisksManager::findAllDevices() +{ + QDBusReply > reply = m_interface->call("EnumerateDevices"); + if (!reply.isValid()) + { + qWarning("UDisksManager: error: %s", qPrintable(reply.error().name())); + return QList(); + } + return reply.value(); +} diff --git a/src/plugins/General/udisks/udisksmanager.h b/src/plugins/General/udisks/udisksmanager.h new file mode 100644 index 000000000..fb6795b1d --- /dev/null +++ b/src/plugins/General/udisks/udisksmanager.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (C) 2010 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef UDISKSMANAGER_H +#define UDISKSMANAGER_H + +#include +#include +#include + +class QDBusInterface; + +/** + @author Ilya Kotov +*/ +class UDisksManager : public QObject +{ +Q_OBJECT +public: + UDisksManager(QObject *parent = 0); + + ~UDisksManager(); + + QList findAllDevices(); + +signals: + void deviceAdded(QDBusObjectPath); + void deviceRemoved(QDBusObjectPath); + +private: + QDBusInterface *m_interface; + +}; + +#endif diff --git a/src/plugins/General/udisks/udisksplugin.cpp b/src/plugins/General/udisks/udisksplugin.cpp new file mode 100644 index 000000000..1683f095b --- /dev/null +++ b/src/plugins/General/udisks/udisksplugin.cpp @@ -0,0 +1,255 @@ +/*************************************************************************** + * Copyright (C) 2010 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include "udisksdevice.h" +#include "udisksmanager.h" +#include "udisksplugin.h" + +UDisksPlugin::UDisksPlugin(QObject *parent) + : General(parent) +{ + m_manager = new UDisksManager(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("UDisks"); + 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(); +} + + +UDisksPlugin::~UDisksPlugin() +{ +} + +void UDisksPlugin::removeDevice(QDBusObjectPath o) +{ + foreach(UDisksDevice *device, m_devices) + { + if (device->objectPath() == o) + { + m_devices.removeAll(device); + delete device; + qDebug("UDisksPlugin: device \"%s\" removed", qPrintable(o.path())); + updateActions(); + break; + } + } +} + +void UDisksPlugin::addDevice(QDBusObjectPath o) +{ + foreach(UDisksDevice *device, m_devices) //is it already exists? + { + if (device->objectPath() == o) + return; + } + UDisksDevice *device = new UDisksDevice(o, this); + + //audio cd + if (device->property("DeviceIsOpticalDisc").toBool() && + device->property("OpticalDiscNumAudioTracks").toInt()) + { + if (m_detectCDA) + { + qDebug("UDisksPlugin: device \"%s\" added (cd audio)", qPrintable(o.path())); + m_devices << device; + connect(device, SIGNAL(changed()), SLOT(updateActions())); + updateActions(); + } + else + delete device; + return; + } + + // filter mounted partitions + if ((!device->property("DeviceIsPartition").toBool() || + device->property("DeviceIsSystemInternal").toBool()) && + !device->property("DeviceIsOpticalDisc").toBool()) + { + delete device; + return; + } + if (device->property("PartitionSize").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("UDisksPlugin: device \"%s\" added (removable)", qPrintable(o.path())); + m_devices << device; + updateActions(); + connect(device, SIGNAL(changed()), SLOT(updateActions())); + } + else + delete device; + return; + } + delete device; +} + +void UDisksPlugin::updateActions() +{ + // add action for cd audio or mounted volume + foreach(UDisksDevice *device, m_devices) + { + QString dev_path; + if (device->property("DeviceIsOpticalDisc").toBool() && + device->property("OpticalDiscNumAudioTracks").toInt()) //cd audio + dev_path = "cdda://" + device->property("block.device").toString(); + else if (device->property("DeviceIsMounted").toBool()) //mounted volume + dev_path = device->property("DeviceMountPaths").toStringList()[0]; + else + continue; + + if (!findAction(dev_path)) + { + QAction *action = new QAction(this); + QString actionText; + if (device->property("DeviceIsOpticalDisc").toBool() + && device->property("OpticalDiscNumAudioTracks").toInt()) + actionText = QString(tr("Add CD \"%1\"")).arg(device->property("DeviceFile").toString()); + else + { + QString name = device->property("IdLabel").toString(); + if (name.isEmpty()) + name = dev_path; + actionText = QString(tr("Add Volume \"%1\"")).arg(name); + } + action->setText(actionText); + action->setData(dev_path); + m_actions->addAction(action); + GeneralHandler::instance()->addAction(action, GeneralHandler::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); + GeneralHandler::instance()->removeAction(action); + removePath(action->data().toString()); + action->deleteLater(); + } + } +} + +void UDisksPlugin::processAction(QAction *action) +{ + qDebug("UDisksPlugin: action triggered: %s", qPrintable(action->data().toString())); + QString path = action->data().toString(); + if (path.startsWith("cdda://")) + MediaPlayer::instance()->playListManager()->selectedPlayList()->addFile(path); + else + MediaPlayer::instance()->playListManager()->selectedPlayList()->addDirectory(path); +} + +QAction *UDisksPlugin::findAction(const QString &dev_path) +{ + foreach(QAction *action, m_actions->actions ()) + { + if (action->data().toString() == dev_path) + return action; + } + return 0; +} + +UDisksDevice *UDisksPlugin::findDevice(QAction *action) +{ + foreach(UDisksDevice *device, m_devices) + { + QString dev_path; + if (device->property("DeviceIsOpticalDisc").toBool() && + device->property("OpticalDiscNumAudioTracks").toInt()) + { + dev_path = "cdda://" + device->property("DeviceFile").toString(); + if (dev_path == action->data().toString()) + return device; + } + if (device->property("DeviceIsMounted").toBool()) + { + dev_path = device->property("DeviceMountPaths").toStringList()[0]; + if (dev_path == action->data().toString()) + return device; + } + } + return 0; +} + +void UDisksPlugin::addPath(const QString &path) +{ + foreach(PlayListItem *item, MediaPlayer::instance()->playListManager()->selectedPlayList()->items()) // Is it already exist? + { + if (item->url().startsWith(path)) + return; + } + + if (path.startsWith("cdda://") && m_addTracks) + { + MediaPlayer::instance()->playListManager()->selectedPlayList()->addFile(path); + return; + } + else if (!path.startsWith("cdda://") && m_addFiles) + MediaPlayer::instance()->playListManager()->selectedPlayList()->addDirectory(path); +} + +void UDisksPlugin::removePath(const QString &path) +{ + if ((path.startsWith("cdda://") && !m_removeTracks) || + (!path.startsWith("cdda://") && !m_removeFiles)) //process settings + return; + + PlayListModel *model = MediaPlayer::instance()->playListManager()->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/udisks/udisksplugin.h b/src/plugins/General/udisks/udisksplugin.h new file mode 100644 index 000000000..b42f012c6 --- /dev/null +++ b/src/plugins/General/udisks/udisksplugin.h @@ -0,0 +1,65 @@ +/*************************************************************************** + * Copyright (C) 2010 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef UDISKSPLUGIN_H +#define UDISKSPLUGIN_H + +#include +#include + +class UDisksManager; +class UDisksDevice; +class QActionGroup; +class QAction; + +/** + @author Ilya Kotov +*/ + +class UDisksPlugin : public General +{ +Q_OBJECT +public: + UDisksPlugin(QObject *parent = 0); + + ~UDisksPlugin(); + +private slots: + void removeDevice(QDBusObjectPath); + void addDevice(QDBusObjectPath); + void processAction(QAction *action); + void updateActions(); + +private: + QAction *findAction(const QString &dev_path); + UDisksDevice *findDevice(QAction *action); + void addPath(const QString &path); + void removePath(const QString &path); + UDisksManager *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 -- cgit v1.2.3-13-gbd6f