summaryrefslogtreecommitdiffstats
path: root/tdefile-plugins/dvi
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:03:37 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:03:37 -0600
commit2e25fa39cd67cca2472d3eabdb478feb517d72a5 (patch)
tree63725962f632d152cbf20709191d39f6fc865966 /tdefile-plugins/dvi
parent190d88dfc662f3fc466c9d1f53acbbea65f33c49 (diff)
downloadtdegraphics-2e25fa39cd67cca2472d3eabdb478feb517d72a5.tar.gz
tdegraphics-2e25fa39cd67cca2472d3eabdb478feb517d72a5.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdefile-plugins/dvi')
-rw-r--r--tdefile-plugins/dvi/CMakeLists.txt35
-rw-r--r--tdefile-plugins/dvi/Makefile.am22
-rw-r--r--tdefile-plugins/dvi/tdefile_dvi.cpp150
-rw-r--r--tdefile-plugins/dvi/tdefile_dvi.desktop60
-rw-r--r--tdefile-plugins/dvi/tdefile_dvi.h38
5 files changed, 305 insertions, 0 deletions
diff --git a/tdefile-plugins/dvi/CMakeLists.txt b/tdefile-plugins/dvi/CMakeLists.txt
new file mode 100644
index 00000000..beb5d8e2
--- /dev/null
+++ b/tdefile-plugins/dvi/CMakeLists.txt
@@ -0,0 +1,35 @@
+#################################################
+#
+# (C) 2010-2011 Calvin Morrison
+# mutantturkey@gmail.com
+#
+# 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_dvi.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+
+
+#### tdefile_dvi (module) #########################
+
+tde_add_kpart( tdefile_dvi AUTOMOC
+ SOURCES tdefile_dvi.cpp
+ LINK tdeio-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/tdefile-plugins/dvi/Makefile.am b/tdefile-plugins/dvi/Makefile.am
new file mode 100644
index 00000000..116d7a0d
--- /dev/null
+++ b/tdefile-plugins/dvi/Makefile.am
@@ -0,0 +1,22 @@
+## Makefile.am for the dvi 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_dvi.h
+
+kde_module_LTLIBRARIES = tdefile_dvi.la
+
+tdefile_dvi_la_SOURCES = tdefile_dvi.cpp
+tdefile_dvi_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+tdefile_dvi_la_LIBADD = $(LIB_KIO)
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages:
+ $(XGETTEXT) *.cpp -o $(podir)/tdefile_dvi.pot
+
+services_DATA = tdefile_dvi.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/tdefile-plugins/dvi/tdefile_dvi.cpp b/tdefile-plugins/dvi/tdefile_dvi.cpp
new file mode 100644
index 00000000..374e5e54
--- /dev/null
+++ b/tdefile-plugins/dvi/tdefile_dvi.cpp
@@ -0,0 +1,150 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Matthias Witzgall <witzi@gmx.net>
+ *
+ * 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.
+ *
+ */
+
+
+/* further informations about the dvi file format could be downloaded from: http://www.rpi.edu/~sofkam/DVI/archive/standards/dvistd0.dvi */
+
+#include "tdefile_dvi.h"
+
+#include <kgenericfactory.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <tdefilemetainfo.h>
+
+#include <tqstring.h>
+#include <tqvariant.h>
+#include <tqdatetime.h>
+#include <tqfile.h>
+#include <tqfileinfo.h>
+#include <tqregexp.h>
+
+
+// preprocessormacro K_EXPORT_COMPONENT_FACTORY loads shared library 'tdefile_dvi.so' dynamic if necessary
+typedef KGenericFactory<KDviPlugin> DviFactory;
+K_EXPORT_COMPONENT_FACTORY(tdefile_dvi, DviFactory("tdefile_dvi"))
+
+KDviPlugin::KDviPlugin (TQObject * parent, const char * name, const TQStringList & preferredItems)
+ : KFilePlugin(parent, name, preferredItems)
+{
+ kdDebug(7034) << "dvi plugin" << endl;
+
+ // set up our mime type
+ KFileMimeTypeInfo * info = this->addMimeTypeInfo("application/x-dvi");
+
+
+ KFileMimeTypeInfo::GroupInfo * group = this->addGroupInfo(info, "General", "General");
+
+ this->addItemInfo(group, "3_Created", i18n("Created"), TQVariant::String);
+ this->addItemInfo(group, "6_Comment", i18n("Comment"), TQVariant::String);
+ this->addItemInfo(group, "7_Pages", i18n("Pages"), TQVariant::UInt);
+}
+
+bool KDviPlugin::readInfo (KFileMetaInfo & info, uint /* what (unused in this plugin) */)
+{
+ if ( info.path().isEmpty() )
+ return false;
+ KFileMetaInfoGroup GeneralGroup = appendGroup(info, "General");
+ TQFile f(info.path());
+ TQFileInfo f_info;
+ TQ_UINT16 bytes_to_read;
+ TQ_UINT8 comment_length;
+ TQString comment;
+ TQ_UINT16 pages;
+ TQ_UINT8 buffer[270]; // buffer for reading data; no data is read with more than 270 bytes
+ TQ_UINT32 ptr;
+ int i; // running index
+
+ // open file and try to get the comment
+ f.open(IO_ReadOnly);
+
+ if ( f.isOpen() == false ){
+ kdDebug(7034) << "cannot open file" << endl;
+ return false;
+ }
+
+ f_info.setFile(f); // create fileinfoobject
+ bytes_to_read = TQMIN(f_info.size(), 270); // check, if the file size is smaller than 270 bytes
+ // (if the comment is as large as possible, we don't have to
+ // read more than 270 bytes)
+
+ if ( f.readBlock((char *)buffer, bytes_to_read) != bytes_to_read ){ // cast to (char *) is necessary
+ kdDebug(7034) << "read error (1)" << endl;
+ return false;
+ }
+
+ if ( (buffer[0] != 247) || (buffer[1] != 2) ){
+ // magic numbers are not right
+ kdDebug(7034) << "wrong file format" << endl;;
+ return false;
+ }
+
+ comment_length = buffer[14]; // set up length of comment
+ comment.setLength(comment_length); // used to avoid permanent reallocation when extracting the comment from buffer
+
+ for ( i = 15; i <= 14+comment_length; ++i ) // extract comment from buffer
+ comment[i-15] = (char)buffer[i];
+
+ appendItem(GeneralGroup, "6_Comment", comment.simplifyWhiteSpace() );
+
+ // comment is ok, now get total number of pages
+ f.at( f.size() - 13);
+ if ( f.readBlock((char *)buffer, 13) != 13 ){
+ kdDebug(7034) << "read error (2)" << endl;
+ return false;
+ }
+
+ i = 12; // reset running index i
+ while ( buffer[i] == 223 ){ --i; } // skip all trailing bytes
+
+ if ( (buffer[i] != 2) || (i > 8) || (i < 5) ){
+ kdDebug(7034) << "wrong file formatx" << endl;
+ return false;
+ }
+
+ // now we know the position of the pointer to the beginning of the postamble and we can read it
+ ptr = buffer[i-4];
+ ptr = (ptr << 8) | buffer[i-3];
+ ptr = (ptr << 8) | buffer[i-2];
+ ptr = (ptr << 8) | buffer[i-1];
+
+ // bytes for total number of pages have a offset of 27 to the beginning of the postamble
+ f.at(ptr + 27);
+
+ // now read total number of pages from file
+ if ( f.readBlock((char *)buffer, 2) != 2 ){
+ kdDebug(7034) << "read error (3)" << endl;
+ return false;
+ }
+ pages = buffer[0];
+ pages = (pages << 8) | buffer[1];
+
+ appendItem(GeneralGroup, "7_Pages", TQVariant(pages) );
+
+ f.close();
+
+ // now get and set up some basic informations about the file (same informations would be displayed, if there is no dvi-plugin)
+ appendItem(GeneralGroup, "1_Type", TQVariant( i18n("TeX Device Independent file") ) ); // set up type of file
+
+ appendItem(GeneralGroup, "4_Modified", TQVariant(f_info.lastModified().toString("yyyy-MM-dd hh:mm")) );
+ // ISO 8601 date format (without seconds)
+
+ return true;
+}
+
+#include "tdefile_dvi.moc"
diff --git a/tdefile-plugins/dvi/tdefile_dvi.desktop b/tdefile-plugins/dvi/tdefile_dvi.desktop
new file mode 100644
index 00000000..e3bade83
--- /dev/null
+++ b/tdefile-plugins/dvi/tdefile_dvi.desktop
@@ -0,0 +1,60 @@
+[Desktop Entry]
+Icon=
+MimeType=application/x-dvi
+Name=DVI Info
+Name[ar]=معلومات DVI
+Name[br]=Titouroù DVI
+Name[ca]=Informació de DVI
+Name[cs]=DVI info
+Name[cy]=Gwybodaeth DVI
+Name[da]=DVI-info
+Name[de]=DVI-Info
+Name[el]=Πληροφορίες DVI
+Name[eo]=DVI-informo
+Name[es]=Info DVI
+Name[et]=DVI info
+Name[fa]=اطلاعات DVI
+Name[fi]=DVI-tiedot
+Name[fr]=Informations DVI
+Name[ga]=Eolas faoi DVI
+Name[gl]=Inf. DVI
+Name[he]=מידע DVI
+Name[hi]=DVI जानकारी
+Name[hu]=DVI-jellemzők
+Name[is]=DVI upplýsingar
+Name[it]=Informazioni DVI
+Name[ja]=DVI 情報
+Name[kk]=DVI мәліметі
+Name[km]=ព័ត៌មាន DVI
+Name[lt]=DVI informacija
+Name[ms]=Maklumat DVI
+Name[nds]=DVI-Info
+Name[ne]=DVI सूचना
+Name[nl]=DVI-info
+Name[nn]=DVI-info
+Name[pa]=DVI ਜਾਣਕਾਰੀ
+Name[pl]=Informacja o pliku DVI
+Name[pt]=Informação do DVI
+Name[pt_BR]=Informação sobre DVI
+Name[ro]=Informaţii DVI
+Name[ru]=Информация о DVI
+Name[se]=DVI-dieđut
+Name[sl]=Podatki o DVI
+Name[sr]=DVI информације
+Name[sr@Latn]=DVI informacije
+Name[sv]=DVI-information
+Name[ta]=DVI தகவல்
+Name[tg]=Иттилоот оиди DVI
+Name[th]=ข้อมูลแฟ้ม DVI
+Name[tr]=DVI Bilgisi
+Name[uk]=Інформація по DVI
+Name[uz]=DVI haqida maʼlumot
+Name[uz@cyrillic]=DVI ҳақида маълумот
+Name[wa]=Informåcion sol documint DVI
+Name[zh_CN]=DVI 信息
+Name[zh_HK]=DVI 資訊
+Name[zh_TW]=DVI 資訊
+ServiceTypes=KFilePlugin
+Type=Service
+X-TDE-Library=tdefile_dvi
+PreferredItems=Title,Author,Subject,Creator,Producer,CreationDate,ModDate,Keywords
diff --git a/tdefile-plugins/dvi/tdefile_dvi.h b/tdefile-plugins/dvi/tdefile_dvi.h
new file mode 100644
index 00000000..da4bc6fe
--- /dev/null
+++ b/tdefile-plugins/dvi/tdefile_dvi.h
@@ -0,0 +1,38 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Matthias Witzgall <witzi@gmx.net>
+ *
+ * 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_DVI_H__
+#define __KFILE_DVI_H__
+
+#include <tdefilemetainfo.h>
+
+class TQStringList;
+
+class KDviPlugin : public KFilePlugin
+{
+ Q_OBJECT
+
+public:
+ KDviPlugin ( TQObject * parent, const char * name, const TQStringList & preferredItems );
+
+ virtual bool readInfo (KFileMetaInfo & info, uint what);
+};
+
+#endif