summaryrefslogtreecommitdiffstats
path: root/tdefile-plugins/xbm
diff options
context:
space:
mode:
Diffstat (limited to 'tdefile-plugins/xbm')
-rw-r--r--tdefile-plugins/xbm/CMakeLists.txt35
-rw-r--r--tdefile-plugins/xbm/Makefile.am22
-rw-r--r--tdefile-plugins/xbm/tdefile_xbm.cpp128
-rw-r--r--tdefile-plugins/xbm/tdefile_xbm.desktop65
-rw-r--r--tdefile-plugins/xbm/tdefile_xbm.h43
5 files changed, 293 insertions, 0 deletions
diff --git a/tdefile-plugins/xbm/CMakeLists.txt b/tdefile-plugins/xbm/CMakeLists.txt
new file mode 100644
index 00000000..4b96ade8
--- /dev/null
+++ b/tdefile-plugins/xbm/CMakeLists.txt
@@ -0,0 +1,35 @@
+#################################################
+#
+# (C) 2010-2011 Calvin Morrison
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+#### other data #################################
+
+install( FILES tdefile_xbm.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+
+
+#### tdefile_xbm (module) ########################
+
+tde_add_kpart( tdefile_xbm AUTOMOC
+ SOURCES tdefile_xbm.cpp
+ LINK tdeio-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/tdefile-plugins/xbm/Makefile.am b/tdefile-plugins/xbm/Makefile.am
new file mode 100644
index 00000000..90abdc8e
--- /dev/null
+++ b/tdefile-plugins/xbm/Makefile.am
@@ -0,0 +1,22 @@
+## Makefile.am for xbm 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 = tdefile_xbm.h
+
+kde_module_LTLIBRARIES = tdefile_xbm.la
+
+tdefile_xbm_la_SOURCES = tdefile_xbm.cpp
+tdefile_xbm_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+tdefile_xbm_la_LIBADD = $(LIB_KSYCOCA)
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages: rc.cpp
+ $(XGETTEXT) tdefile_xbm.cpp -o $(podir)/tdefile_xbm.pot
+
+services_DATA = tdefile_xbm.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/tdefile-plugins/xbm/tdefile_xbm.cpp b/tdefile-plugins/xbm/tdefile_xbm.cpp
new file mode 100644
index 00000000..d4871d6f
--- /dev/null
+++ b/tdefile-plugins/xbm/tdefile_xbm.cpp
@@ -0,0 +1,128 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Shane Wright <[email protected]>
+ *
+ * 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 "tdefile_xbm.h"
+
+#include <kprocess.h>
+#include <klocale.h>
+#include <kgenericfactory.h>
+#include <kstringvalidator.h>
+#include <kdebug.h>
+
+#include <tqdict.h>
+#include <tqvalidator.h>
+#include <tqcstring.h>
+#include <tqfile.h>
+#include <tqdatetime.h>
+
+#if !defined(__osf__)
+#include <inttypes.h>
+#else
+typedef unsigned short uint32_t;
+#endif
+
+typedef KGenericFactory<KXbmPlugin> XbmFactory;
+
+K_EXPORT_COMPONENT_FACTORY(tdefile_xbm, XbmFactory( "tdefile_xbm" ))
+
+KXbmPlugin::KXbmPlugin(TQObject *parent, const char *name,
+ const TQStringList &args)
+
+ : KFilePlugin(parent, name, args)
+{
+ KFileMimeTypeInfo* info = addMimeTypeInfo( "image/x-xbm" );
+
+ KFileMimeTypeInfo::GroupInfo* group = 0L;
+
+ group = addGroupInfo(info, "Technical", i18n("Technical Details"));
+
+ KFileMimeTypeInfo::ItemInfo* item;
+
+ item = addItemInfo(group, "Dimensions", i18n("Dimensions"), TQVariant::Size);
+ setHint( item, KFileMimeTypeInfo::Size );
+ setUnit(item, KFileMimeTypeInfo::Pixels);
+}
+
+
+unsigned long KXbmPlugin::xbm_processLine(char * linebuf)
+{
+ const char * fsig = "#define ";
+
+ // check it starts with #define
+ if (memcmp(linebuf, fsig, 8))
+ return 0;
+
+ // scan for the 2nd space and set up a pointer
+ uint32_t slen = strlen(linebuf);
+ bool done = false;
+ uint32_t spos = 0;
+ unsigned char spacecount = 0;
+ do {
+
+ if (linebuf[spos] == 0x00)
+ return 0;
+
+ if (linebuf[spos] == ' ')
+ ++spacecount;
+
+ if (spacecount == 2)
+ done = true;
+ else
+ ++spos;
+
+ } while (!done);
+
+ return atoi(linebuf + spos);
+}
+
+
+bool KXbmPlugin::readInfo( KFileMetaInfo& info, uint what)
+{
+
+ TQFile file(info.path());
+
+ if (!file.open(IO_ReadOnly))
+ {
+ kdDebug(7034) << "Couldn't open " << TQFile::encodeName(info.path()).data() << endl;
+ return false;
+ }
+
+ // we need a buffer for lines
+ char linebuf[1000];
+
+ // read the first line
+ file.readLine(linebuf, sizeof( linebuf ));
+ uint32_t width = xbm_processLine(linebuf);
+
+ // read the 2nd line
+ file.readLine(linebuf, sizeof( linebuf ));
+ uint32_t height = xbm_processLine(linebuf);
+
+ if ((width > 0) && (height > 0)) {
+ // we have valid looking data
+ KFileMetaInfoGroup group = appendGroup(info, "Technical");
+ appendItem(group, "Dimensions", TQSize(width, height));
+ return true;
+ }
+
+ return false;
+}
+
+#include "tdefile_xbm.moc"
diff --git a/tdefile-plugins/xbm/tdefile_xbm.desktop b/tdefile-plugins/xbm/tdefile_xbm.desktop
new file mode 100644
index 00000000..76102cea
--- /dev/null
+++ b/tdefile-plugins/xbm/tdefile_xbm.desktop
@@ -0,0 +1,65 @@
+[Desktop Entry]
+Type=Service
+Name=XBM Info
+Name[af]=Xbm Inligting
+Name[ar]=معلومات XBM
+Name[br]=Titouroù XBM
+Name[ca]=Informació d'XBM
+Name[cs]=XBM info
+Name[cy]=Gwybodaeth XBM
+Name[da]=XBM-info
+Name[de]=XBM-Info
+Name[el]=Πληροφορίες XBM
+Name[eo]=XBM-informo
+Name[es]=Info XBM
+Name[et]=XBM info
+Name[fa]=اطلاعات XBM
+Name[fi]=XBM-tiedot
+Name[fr]=Informations sur XBM
+Name[gl]=Inf. XBM
+Name[he]=מידע XBM
+Name[hi]=XBM जानकारी
+Name[hr]=XBM Infoformacije
+Name[hu]=XBM-jellemzők
+Name[is]=XBM upplýsingar
+Name[it]=Informazioni XBM
+Name[ja]=XBM 情報
+Name[kk]=XBM мәліметі
+Name[km]=ព័ត៌មាន XBM
+Name[lt]=XBM informacija
+Name[ms]=Maklumat XBM
+Name[nds]=XBM-Info
+Name[ne]=XBM सूचना
+Name[nl]=XBM-info
+Name[nn]=XBM-info
+Name[nso]=Tshedimoso ya XBM
+Name[pa]=XBM ਜਾਣਕਾਰੀ
+Name[pl]=Informacja o pliku XBM
+Name[pt]=Informação do XBM
+Name[pt_BR]=Informação sobre XBM
+Name[ro]=Informaţii XBM
+Name[ru]=Информация о XBM
+Name[se]=XBM-dieđut
+Name[sl]=Podatki o XBM
+Name[sr]=XBM информације
+Name[sr@Latn]=XBM informacije
+Name[sv]=XBM-information
+Name[ta]=XBM தகவல்
+Name[tg]=Иттилоот оиди XBM
+Name[th]=ข้อมูลแฟ้ม XBM
+Name[tr]=XBM Bilgisi
+Name[uk]=Інформація по XBM
+Name[uz]=XBM haqida maʼlumot
+Name[uz@cyrillic]=XBM ҳақида маълумот
+Name[ven]=Mafhungo a XBM
+Name[wa]=Informåcion sol imådje XBM
+Name[xh]=Ulwazi lwe XBM
+Name[zh_CN]=XBM 信息
+Name[zh_HK]=XBM 資訊
+Name[zh_TW]=XBM 資訊
+Name[zu]=Ulwazi lwe-XBM
+ServiceTypes=KFilePlugin
+X-TDE-Library=tdefile_xbm
+MimeType=image/x-xbm
+PreferredGroups=Technical
+PreferredItems=Resolution
diff --git a/tdefile-plugins/xbm/tdefile_xbm.h b/tdefile-plugins/xbm/tdefile_xbm.h
new file mode 100644
index 00000000..5e7f6429
--- /dev/null
+++ b/tdefile-plugins/xbm/tdefile_xbm.h
@@ -0,0 +1,43 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Shane Wright <[email protected]>
+ *
+ * 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_XBM_H__
+#define __KFILE_XBM_H__
+
+#include <tdefilemetainfo.h>
+
+class TQStringList;
+
+class KXbmPlugin: public KFilePlugin
+{
+ Q_OBJECT
+
+
+public:
+ KXbmPlugin( TQObject *parent, const char *name, const TQStringList& args );
+
+ virtual bool readInfo( KFileMetaInfo& info, uint what);
+
+private:
+
+ unsigned long xbm_processLine(char * linebuf);
+
+};
+
+#endif