summaryrefslogtreecommitdiffstats
path: root/kfile-plugins/deb
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit37333bf25ad9a4c538250f5af2f9f1d666362883 (patch)
treec45e8df5b9efbffe07eb3d9340df7811c7e16943 /kfile-plugins/deb
downloadtdeadmin-37333bf25ad9a4c538250f5af2f9f1d666362883.tar.gz
tdeadmin-37333bf25ad9a4c538250f5af2f9f1d666362883.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeadmin@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kfile-plugins/deb')
-rw-r--r--kfile-plugins/deb/Makefile.am22
-rw-r--r--kfile-plugins/deb/kfile_deb.cpp130
-rw-r--r--kfile-plugins/deb/kfile_deb.desktop69
-rw-r--r--kfile-plugins/deb/kfile_deb.h38
4 files changed, 259 insertions, 0 deletions
diff --git a/kfile-plugins/deb/Makefile.am b/kfile-plugins/deb/Makefile.am
new file mode 100644
index 0000000..65e69c3
--- /dev/null
+++ b/kfile-plugins/deb/Makefile.am
@@ -0,0 +1,22 @@
+## Makefile.am for deb file meta info plugin
+
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes)
+
+# these are the headers for your project
+noinst_HEADERS = kfile_deb.h
+
+kde_module_LTLIBRARIES = kfile_deb.la
+
+kfile_deb_la_SOURCES = kfile_deb.cpp
+kfile_deb_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+kfile_deb_la_LIBADD = $(LIB_KSYCOCA)
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages:
+ $(XGETTEXT) *.cpp *.h -o $(podir)/kfile_deb.pot
+
+services_DATA = kfile_deb.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/kfile-plugins/deb/kfile_deb.cpp b/kfile-plugins/deb/kfile_deb.cpp
new file mode 100644
index 0000000..b66e062
--- /dev/null
+++ b/kfile-plugins/deb/kfile_deb.cpp
@@ -0,0 +1,130 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Laurence Anderson <l.d.anderson@warwick.ac.uk>
+ *
+ * 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 version 2.
+ *
+ * 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; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h>
+
+#include <kprocess.h>
+#include <klocale.h>
+#include <kgenericfactory.h>
+#include <kstringvalidator.h>
+#include <kdebug.h>
+
+#include <qdict.h>
+#include <qvalidator.h>
+#include <qcstring.h>
+#include <qfile.h>
+#include <qdatetime.h>
+#include <qbuffer.h>
+#include <kfilterdev.h>
+#include <qregexp.h>
+#include <karchive.h>
+#include <ktar.h>
+#include <kar.h>
+
+#include "kfile_deb.h"
+
+typedef KGenericFactory<KDebPlugin> DebFactory;
+
+K_EXPORT_COMPONENT_FACTORY(kfile_deb, DebFactory( "kfile_deb" ))
+
+KDebPlugin::KDebPlugin(QObject *parent, const char *name,
+ const QStringList &args)
+
+ : KFilePlugin(parent, name, args)
+{
+ KFileMimeTypeInfo* info = addMimeTypeInfo( "application/x-deb" );
+ KFileMimeTypeInfo::GroupInfo* group = 0L;
+ group = addGroupInfo(info, "General", i18n("General"));
+ KFileMimeTypeInfo::ItemInfo* item;
+
+ item = addItemInfo(group, "Name", i18n("Name"), QVariant::String);
+ item = addItemInfo(group, "Version", i18n("Version"), QVariant::String);
+ item = addItemInfo(group, "Summary", i18n("Summary"), QVariant::String);
+ item = addItemInfo(group, "Size", i18n("Size"), QVariant::Int);
+}
+
+bool KDebPlugin::readInfo( KFileMetaInfo& info, uint /*what*/)
+{
+ KAr debfile (info.path());
+
+ if ( !debfile.open( IO_ReadOnly ) ) {
+ kdDebug(7034) << "Couldn't open " << QFile::encodeName(info.path()) << endl;
+ return false;
+ }
+
+ const KArchiveDirectory* debdir = debfile.directory();
+ const KArchiveEntry* controlentry = debdir->entry( "control.tar.gz" );
+ if ( !controlentry || !controlentry->isFile() ) {
+ kdWarning(7034) << "control.tar.gz not found" << endl;
+ return false;
+ }
+
+ QIODevice* filterDev = KFilterDev::device( static_cast<const KArchiveFile *>( controlentry )->device(), "application/x-gzip" );
+ if ( !filterDev ) {
+ kdWarning(7034) << "Couldn't create filter device for control.tar.gz" << endl;
+ return false;
+ }
+ KTar tarfile( filterDev );
+
+ if ( !tarfile.open( IO_ReadOnly ) ) {
+ kdWarning(7034) << "Couldn't open control.tar.gz" << endl;
+ return false;
+ }
+
+ const KArchiveDirectory* controldir = tarfile.directory();
+ Q_ASSERT( controldir );
+
+ const KArchiveEntry* controlfile = controldir->entry( "control" );
+
+ Q_ASSERT( controlfile );
+ if (controlfile) {
+ KFileMetaInfoGroup group = appendGroup(info, "General");
+ QByteArray control( static_cast<const KArchiveFile *>(controlfile)->data() );
+
+ // Now process control array
+ QBuffer controldev(control);
+ controldev.open( IO_ReadOnly );
+ while (!controldev.atEnd()) {
+ char linebuf[100];
+ controldev.readLine(linebuf, sizeof( linebuf ));
+ QString line(linebuf);
+ int fieldstart = line.find(QRegExp(":"), 0) + 2;
+ if (fieldstart == 1) break;
+ QString fieldname = line.mid(0, fieldstart - 2);
+ QString fielddata = line.mid(fieldstart, line.length() - fieldstart - 1);
+
+ if (fieldname == "Package") appendItem(group, "Name", fielddata);
+ else if (fieldname == "Version") appendItem(group, "Version", fielddata);
+ else if (fieldname == "Description") appendItem(group, "Summary", fielddata);
+ else if (fieldname == "Installed-Size") appendItem(group, "Size", int(fielddata.toInt()));
+
+ kdDebug(7034) << "Name: [" << fieldname << "] Data: [" << fielddata << "]" << endl;
+ }
+ } else {
+ kdDebug(7034) << "Couldn't read control file" << endl;
+ return false;
+ }
+
+ tarfile.close();
+ debfile.close();
+
+ return true;
+}
+
+#include "kfile_deb.moc"
diff --git a/kfile-plugins/deb/kfile_deb.desktop b/kfile-plugins/deb/kfile_deb.desktop
new file mode 100644
index 0000000..1ae6ab9
--- /dev/null
+++ b/kfile-plugins/deb/kfile_deb.desktop
@@ -0,0 +1,69 @@
+[Desktop Entry]
+Type=Service
+Name=DEB Stats
+Name[af]=Deb Statistiek
+Name[ar]=إحصائيَات DEB
+Name[az]=DEB Statistikaları
+Name[be]=Cтатыстыка DEB
+Name[bn]=ডেব পরিসংখ্যান
+Name[br]=Stadegoù gant DEB
+Name[bs]=DEB statistika
+Name[ca]=L'estat dels DEB
+Name[cs]=DEB statistiky
+Name[cy]=Ystadegau DEB
+Name[da]=DEB-stats
+Name[el]=Στατιστικά DEB
+Name[eo]=DEB statistikoj
+Name[es]=Estadísticas DEB
+Name[et]=DEB statistika
+Name[eu]=DEB estadistikak
+Name[fa]=آمار DEB
+Name[fi]=DEB-tilastot
+Name[fo]=DEB-hagtøl
+Name[fr]=État DEB
+Name[ga]=Staitistic DEB
+Name[gl]=Estatísticas DEB
+Name[he]=סטטיסטיקת DEB
+Name[hi]=डीईबी स्टेट्स
+Name[hr]=DEB statistike
+Name[hu]=DEB-statisztika
+Name[it]=Statistiche DEB
+Name[ka]=DEB სტატისტიკა
+Name[kk]=DEB статистикасы
+Name[km]=សភាព DEB
+Name[ko]=DEB 상태
+Name[lt]=DEB statistika
+Name[lv]=DEB Statusi
+Name[mn]=ДЕВ Төлөв
+Name[mt]=Statistika DEB
+Name[nb]=DEB statistikk
+Name[ne]=डीईबी तथ्याङ्क
+Name[nl]=DEB-statistieken
+Name[nn]=DEB-statistikk
+Name[pa]=DEB ਸਥਿਤੀ
+Name[pl]=Dane pakietów DEB
+Name[pt]=Informações de DEBs
+Name[pt_BR]=Estados DEB
+Name[ro]=Statistici DEB
+Name[ru]=Статистика DEB
+Name[se]=DEB-statistihkka
+Name[sk]=Štatistiky DEB
+Name[sl]=Statistike DEB
+Name[sr]=DEB Статистике
+Name[sr@Latn]=DEB Statistike
+Name[sv]=DEB-statistik
+Name[ta]=DEB புள்ளி விவரம்
+Name[tg]=Статистикаи DEB
+Name[th]=สถิติของ DEB
+Name[tr]=DEB İstatistikleri
+Name[uk]=Дані DEB
+Name[ven]=Mbalo dza DEB
+Name[vi]=Thống kê DEB
+Name[wa]=Sitatistikes DEB
+Name[zh_CN]=DEB 统计
+Name[zh_HK]=DEB 統計
+Name[zh_TW]=DEB 統計
+ServiceTypes=KFilePlugin
+X-KDE-Library=kfile_deb
+MimeType=application/x-deb
+PreferredItems=Name,Version,Summary,Size
diff --git a/kfile-plugins/deb/kfile_deb.h b/kfile-plugins/deb/kfile_deb.h
new file mode 100644
index 0000000..9fd1bb0
--- /dev/null
+++ b/kfile-plugins/deb/kfile_deb.h
@@ -0,0 +1,38 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Laurence Anderson <l.d.anderson@warwick.ac.uk>
+ *
+ * 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 version 2.
+ *
+ * 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; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __KFILE_DEB_H__
+#define __KFILE_DEB_H__
+
+#include <kfilemetainfo.h>
+
+class QStringList;
+
+class KDebPlugin: public KFilePlugin
+{
+ Q_OBJECT
+
+public:
+ KDebPlugin( QObject *parent, const char *name, const QStringList& args );
+
+ virtual bool readInfo( KFileMetaInfo& info, uint what);
+
+};
+
+#endif