summaryrefslogtreecommitdiffstats
path: root/tdeioslave/media/tdefile-plugin
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2013-01-27 01:02:02 -0600
committerTimothy Pearson <[email protected]>2013-01-27 01:02:02 -0600
commitde7e5867a65e0a46f1388e3e50bc7eeddd1aecbf (patch)
treedbb3152c372f8620f9290137d461f3d9f9eba1cb /tdeioslave/media/tdefile-plugin
parent936d3cec490c13f2c5f7dd14f5e364fddaa6da71 (diff)
downloadtdebase-de7e5867a65e0a46f1388e3e50bc7eeddd1aecbf.tar.gz
tdebase-de7e5867a65e0a46f1388e3e50bc7eeddd1aecbf.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdeioslave/media/tdefile-plugin')
-rw-r--r--tdeioslave/media/tdefile-plugin/CMakeLists.txt40
-rw-r--r--tdeioslave/media/tdefile-plugin/Makefile.am13
-rw-r--r--tdeioslave/media/tdefile-plugin/tdefile_media.desktop75
-rw-r--r--tdeioslave/media/tdefile-plugin/tdefilemediaplugin.cpp207
-rw-r--r--tdeioslave/media/tdefile-plugin/tdefilemediaplugin.h47
5 files changed, 382 insertions, 0 deletions
diff --git a/tdeioslave/media/tdefile-plugin/CMakeLists.txt b/tdeioslave/media/tdefile-plugin/CMakeLists.txt
new file mode 100644
index 000000000..88c9220fa
--- /dev/null
+++ b/tdeioslave/media/tdefile-plugin/CMakeLists.txt
@@ -0,0 +1,40 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+check_include_file( "sys/statvfs.h" HAVE_STATVFS )
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}/tdeioslave/media/libmediacommon
+ ${CMAKE_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### other data ################################
+
+install( FILES tdefile_media.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+
+
+##### tdefile_media (module) ######################
+
+set( target tdefile_media )
+
+tde_add_kpart( ${target} AUTOMOC
+ SOURCES tdefilemediaplugin.cpp
+ LINK mediacommon-static tdeio-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/tdeioslave/media/tdefile-plugin/Makefile.am b/tdeioslave/media/tdefile-plugin/Makefile.am
new file mode 100644
index 000000000..15807ea19
--- /dev/null
+++ b/tdeioslave/media/tdefile-plugin/Makefile.am
@@ -0,0 +1,13 @@
+kde_module_LTLIBRARIES = tdefile_media.la
+
+tdefile_media_la_SOURCES = tdefilemediaplugin.cpp
+tdefile_media_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -module $(KDE_PLUGIN)
+tdefile_media_la_LIBADD = $(LIB_KIO) ../libmediacommon/libmediacommon.la
+
+kdelnkdir = $(kde_servicesdir)
+kde_services_DATA = tdefile_media.desktop
+
+INCLUDES = -I$(srcdir)/../libmediacommon $(all_includes)
+
+METASOURCES = AUTO
+noinst_HEADERS = tdefilemediaplugin.h
diff --git a/tdeioslave/media/tdefile-plugin/tdefile_media.desktop b/tdeioslave/media/tdefile-plugin/tdefile_media.desktop
new file mode 100644
index 000000000..7d652e09a
--- /dev/null
+++ b/tdeioslave/media/tdefile-plugin/tdefile_media.desktop
@@ -0,0 +1,75 @@
+[Desktop Entry]
+Type=Service
+Name=Medium Information
+Name[af]=Medium Informasie
+Name[ar]=معلومات عن الوسيط
+Name[az]=Mediyum Mə'lumatı
+Name[be]=Інфармацыя аб носьбітах
+Name[bg]=Информация за устройствата
+Name[bn]=মিডিয়া তথ্য
+Name[bs]=Informacije o mediju
+Name[ca]=Informació de suports
+Name[cs]=Informace o médiu
+Name[csb]=Wëdowiédzô ò zôpisownëch mediach
+Name[da]=Medieinformation
+Name[de]=Medium-Information
+Name[el]=Πληροφορίες μέσου
+Name[eo]=datumportilaj informoj
+Name[es]=Información de recursos
+Name[et]=Andmekandja info
+Name[eu]=Media informazioa
+Name[fa]=اطلاعات رسانه
+Name[fi]=Tallenteiden tiedot
+Name[fr]=Informations sur le média
+Name[fy]=Mediumynformaasje
+Name[ga]=Eolas faoin Mheán
+Name[gl]=Información do Meio
+Name[he]=מידע אודות המדיה
+Name[hi]=माध्यम जानकारी
+Name[hr]=Podaci o mediju
+Name[hu]=Adathordozó-jellemzők
+Name[is]=Upplýsingar um miðil
+Name[it]=Informazioni supporto
+Name[ja]=メディア情報
+Name[ka]=ცნობები მატარებლის შესახებ
+Name[kk]=Тасушының мәліметі
+Name[km]=ព័ត៌មាន​ឧបករណ៍
+Name[ko]=메모리 정보
+Name[lt]=Laikmenos informacija
+Name[lv]=Datu nesēju informācija
+Name[mk]=Информации за носач
+Name[ms]=Maklumat Medium
+Name[mt]=Informazzjoni tal-apparat
+Name[nb]=Medieinformasjon
+Name[nds]=Medium-Informatschoon
+Name[ne]=माध्यम सूचना
+Name[nl]=Mediuminformatie
+Name[nn]=Medieinformasjon
+Name[pa]=ਮਾਧਿਅਮ ਜਾਣਕਾਰੀ
+Name[pl]=Informacje o nośnikach danych
+Name[pt]=Informação do Dispositivo
+Name[pt_BR]=Informações sobre a Mídia
+Name[ro]=Informații mediu
+Name[ru]=Сведения о диске
+Name[rw]=Amakuru y'igitangazamakuru
+Name[se]=Mediumdieđut
+Name[sk]=Informácie o médiu
+Name[sl]=Informacije o mediju
+Name[sr]=Информације о медијуму
+Name[sr@Latn]=Informacije o medijumu
+Name[sv]=Mediainformation
+Name[ta]=சாதனத் தகவல்
+Name[te]=మాధ్యమ సమాచారం
+Name[th]=ข้อมูลของสื่อ
+Name[tr]=Ortam Bilgisi
+Name[tt]=Media Turında
+Name[uk]=Інформація про носій
+Name[uz]=Saqlash uskuna haqida maʼlumot
+Name[uz@cyrillic]=Сақлаш ускуна ҳақида маълумот
+Name[vi]=Thông tin về Ổ lưu trữ
+Name[wa]=Informåcions sol mediom
+Name[zh_CN]=介质信息
+Name[zh_TW]=媒體資訊
+ServiceTypes=KFilePlugin
+X-TDE-Library=tdefile_media
+MimeType=media/audiocd;media/hdd_mounted;media/hdd_mounted_decrypted;media/blankcd;media/hdd_unmounted;media/hdd_unmounted_decrypted;media/blankdvd;media/cdrom_mounted;media/cdrom_mounted_decrypted;media/cdrom_unmounted;media/cdrom_unmounted_decrypted;media/cdwriter_mounted;media/cdwriter_mounted_decrypted;media/nfs_mounted;media/cdwriter_unmounted;media/cdwriter_unmounted_decrypted;media/nfs_unmounted;media/removable_mounted;media/removable_mounted_decrypted;media/dvd_mounted;media/dvd_mounted_decrypted;media/removable_unmounted;media/removable_unmounted_decrypted;media/dvd_unmounted;media/dvd_unmounted_decrypted;media/smb_mounted;media/dvdvideo;media/smb_unmounted;media/floppy5_mounted;media/svcd;media/floppy5_unmounted;media/vcd;media/floppy_mounted;media/zip_mounted;media/floppy_unmounted;media/zip_unmounted;media/gphoto2camera;media/camera_mounted;media/camera_unmounted
diff --git a/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.cpp b/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.cpp
new file mode 100644
index 000000000..20e68e459
--- /dev/null
+++ b/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.cpp
@@ -0,0 +1,207 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 Kevin Ottens <ervin ipsquad net>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "tdefilemediaplugin.h"
+
+#include <kgenericfactory.h>
+
+#include <dcopref.h>
+
+#include <tqpixmap.h>
+#include <tqpainter.h>
+#include <tqstyle.h>
+#include <tqapplication.h>
+#include <tqfile.h>
+
+#ifdef HAVE_STATVFS
+# include <sys/statvfs.h>
+#else
+# include <sys/mount.h>
+# define statvfs statfs
+# define f_frsize f_bsize
+#endif
+
+typedef KGenericFactory<KFileMediaPlugin> KFileMediaPluginFactory;
+K_EXPORT_COMPONENT_FACTORY(tdefile_media, KFileMediaPluginFactory("kio_media"))
+
+KFileMediaPlugin::KFileMediaPlugin(TQObject *parent, const char *name,
+ const TQStringList& args)
+ : KFilePlugin(parent, name, args)
+{
+ addMimeType( "media/audiocd" );
+ addMimeType( "media/hdd_mounted" );
+ addMimeType( "media/hdd_mounted_decrypted" );
+ addMimeType( "media/blankcd" );
+ addMimeType( "media/hdd_unmounted" );
+ addMimeType( "media/hdd_unmounted_decrypted" );
+ addMimeType( "media/blankdvd" );
+ addMimeType( "media/cdrom_mounted" );
+ addMimeType( "media/cdrom_mounted_decrypted" );
+ addMimeType( "media/cdrom_unmounted" );
+ addMimeType( "media/cdrom_unmounted_decrypted" );
+ addMimeType( "media/cdwriter_mounted" );
+ addMimeType( "media/cdwriter_mounted_decrypted" );
+ addMimeType( "media/nfs_mounted" );
+ addMimeType( "media/cdwriter_unmounted" );
+ addMimeType( "media/cdwriter_unmounted_decrypted" );
+ addMimeType( "media/nfs_unmounted" );
+ addMimeType( "media/removable_mounted" );
+ addMimeType( "media/removable_mounted_decrypted" );
+ addMimeType( "media/dvd_mounted" );
+ addMimeType( "media/dvd_mounted_decrypted" );
+ addMimeType( "media/removable_unmounted" );
+ addMimeType( "media/removable_unmounted_decrypted" );
+ addMimeType( "media/dvd_unmounted" );
+ addMimeType( "media/dvd_unmounted_decrypted" );
+ addMimeType( "media/smb_mounted" );
+ addMimeType( "media/dvdvideo" );
+ addMimeType( "media/smb_unmounted" );
+ addMimeType( "media/floppy5_mounted" );
+ addMimeType( "media/svcd" );
+ addMimeType( "media/floppy5_unmounted" );
+ addMimeType( "media/vcd" );
+ addMimeType( "media/floppy_mounted" );
+ addMimeType( "media/zip_mounted" );
+ addMimeType( "media/floppy_unmounted" );
+ addMimeType( "media/zip_unmounted" );
+ addMimeType( "media/gphoto2camera" );
+ addMimeType( "media/camera_mounted" );
+ addMimeType( "media/camera_unmounted" );
+}
+
+bool KFileMediaPlugin::readInfo(KFileMetaInfo &info, uint /*what*/)
+{
+ const Medium medium = askMedium(info);
+
+ kdDebug() << "KFileMediaPlugin::readInfo " << medium.id() << endl;
+
+ if (medium.id().isNull()) return false;
+
+ TQString mount_point = medium.mountPoint();
+ KURL base_url = medium.prettyBaseURL();
+ TQString device_node = medium.deviceNode();
+
+ KFileMetaInfoGroup group = appendGroup(info, "mediumInfo");
+
+ if (base_url.isValid())
+ {
+ appendItem(group, "baseURL", base_url.prettyURL());
+ }
+
+ if (!device_node.isEmpty())
+ {
+ appendItem(group, "deviceNode", device_node);
+ }
+
+ if (!mount_point.isEmpty() && medium.isMounted())
+ {
+ m_total = 0;
+ m_used = 0;
+ m_free = 0;
+
+ struct statvfs vfs;
+ memset(&vfs, 0, sizeof(vfs));
+
+ if ( ::statvfs(TQFile::encodeName(mount_point), &vfs) != -1 )
+ {
+ m_total = static_cast<TDEIO::filesize_t>(vfs.f_blocks) * static_cast<TDEIO::filesize_t>(vfs.f_frsize);
+ m_free = static_cast<TDEIO::filesize_t>(vfs.f_bavail) * static_cast<TDEIO::filesize_t>(vfs.f_frsize);
+ m_used = m_total - m_free;
+
+ int percent = 0;
+ int length = 0;
+
+ if (m_total != 0)
+ {
+ percent = 100 * m_used / m_total;
+ length = 150 * m_used / m_total;
+ }
+
+ appendItem(group, "free", m_free);
+ appendItem(group, "used", m_used);
+ appendItem(group, "total", m_total);
+
+ group = appendGroup(info, "mediumSummary");
+
+ appendItem(group, "percent", TQString("%1%").arg(percent));
+
+ TQPixmap bar(150, 20);
+ TQPainter p(&bar);
+
+ p.fillRect(0, 0, length, 20, Qt::red);
+ p.fillRect(length, 0, 150-length, 20, Qt::green);
+
+ TQColorGroup cg = TQApplication::palette().active();
+
+ TQApplication::style().tqdrawPrimitive(TQStyle::PE_Panel, &p,
+ TQRect(0, 0, 150, 20), cg,
+ TQStyle::Style_Sunken);
+
+ appendItem( group, "thumbnail", bar );
+ }
+ }
+
+ return true;
+}
+
+const Medium KFileMediaPlugin::askMedium(KFileMetaInfo &info)
+{
+ DCOPRef mediamanager("kded", "mediamanager");
+ kdDebug() << "properties " << info.url() << endl;
+ DCOPReply reply = mediamanager.call( "properties", info.url().url() );
+
+ if ( !reply.isValid() )
+ {
+ return Medium(TQString::null, TQString::null, TQString::null);
+ }
+
+ return Medium::create(reply);
+}
+
+void KFileMediaPlugin::addMimeType(const char *mimeType)
+{
+ KFileMimeTypeInfo *info = addMimeTypeInfo( mimeType );
+
+ KFileMimeTypeInfo::GroupInfo *group
+ = addGroupInfo(info, "mediumInfo", i18n("Medium Information"));
+
+ KFileMimeTypeInfo::ItemInfo *item
+ = addItemInfo(group, "free", i18n("Free"), TQVariant::ULongLong);
+ setUnit(item, KFileMimeTypeInfo::Bytes);
+
+ item = addItemInfo(group, "used", i18n("Used"), TQVariant::ULongLong);
+ setUnit(item, KFileMimeTypeInfo::Bytes);
+
+ item = addItemInfo(group, "total", i18n("Total"), TQVariant::ULongLong);
+ setUnit(item, KFileMimeTypeInfo::Bytes);
+
+ item = addItemInfo(group, "baseURL", i18n("Base URL"), TQVariant::String);
+ item = addItemInfo(group, "mountPoint", i18n("Mount Point"), TQVariant::String);
+ item = addItemInfo(group, "deviceNode", i18n("Device Node"), TQVariant::String);
+
+ group = addGroupInfo(info, "mediumSummary", i18n("Medium Summary"));
+
+ item = addItemInfo(group, "percent", i18n("Usage"), TQVariant::String);
+
+ item = addItemInfo( group, "thumbnail", i18n("Bar Graph"), TQVariant::Image );
+ setHint( item, KFileMimeTypeInfo::Thumbnail );
+}
+
+#include "tdefilemediaplugin.moc"
diff --git a/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.h b/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.h
new file mode 100644
index 000000000..e8dc7d26a
--- /dev/null
+++ b/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.h
@@ -0,0 +1,47 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 Kevin Ottens <ervin ipsquad net>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KFILE_MEDIA_H_
+#define _KFILE_MEDIA_H_
+
+#include <tdefilemetainfo.h>
+#include <kurl.h>
+#include <tdeio/global.h>
+
+#include "medium.h"
+
+class KFileMediaPlugin : public KFilePlugin
+{
+Q_OBJECT
+public:
+ KFileMediaPlugin(TQObject *parent, const char *name,
+ const TQStringList &args);
+
+ bool readInfo(KFileMetaInfo &info, uint what = KFileMetaInfo::Fastest);
+
+private:
+ void addMimeType(const char *mimeType);
+ const Medium askMedium(KFileMetaInfo &info);
+
+ TDEIO::filesize_t m_total;
+ TDEIO::filesize_t m_used;
+ TDEIO::filesize_t m_free;
+};
+
+#endif