summaryrefslogtreecommitdiffstats
path: root/kfile-plugins/rfc822
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
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /kfile-plugins/rfc822
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.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/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kfile-plugins/rfc822')
-rw-r--r--kfile-plugins/rfc822/Makefile.am22
-rw-r--r--kfile-plugins/rfc822/RETURNED_ITEMS14
-rw-r--r--kfile-plugins/rfc822/kfile_rfc822.cpp161
-rw-r--r--kfile-plugins/rfc822/kfile_rfc822.desktop63
-rw-r--r--kfile-plugins/rfc822/kfile_rfc822.h37
5 files changed, 297 insertions, 0 deletions
diff --git a/kfile-plugins/rfc822/Makefile.am b/kfile-plugins/rfc822/Makefile.am
new file mode 100644
index 000000000..f8fa6f941
--- /dev/null
+++ b/kfile-plugins/rfc822/Makefile.am
@@ -0,0 +1,22 @@
+## Makefile.am for rfc822 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_rfc822.h
+
+kde_module_LTLIBRARIES = kfile_rfc822.la
+
+kfile_rfc822_la_SOURCES = kfile_rfc822.cpp
+kfile_rfc822_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+kfile_rfc822_la_LIBADD = $(LIB_KSYCOCA)
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages: rc.cpp
+ $(XGETTEXT) kfile_rfc822.cpp -o $(podir)/kfile_rfc822.pot
+
+services_DATA = kfile_rfc822.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/kfile-plugins/rfc822/RETURNED_ITEMS b/kfile-plugins/rfc822/RETURNED_ITEMS
new file mode 100644
index 000000000..be8c9b7e7
--- /dev/null
+++ b/kfile-plugins/rfc822/RETURNED_ITEMS
@@ -0,0 +1,14 @@
+If you make a new plugin, please add the list of returned items to this list.
+
+
+rfc822 plugin:
+===========
+
+type key W/A details
+------------------------------------------------------------------------
+String From -/- Name/email of sender
+String To -/- Name/email of recipient
+String Subject -/- Subject line of message
+String Date -/- Date stamped in message
+String Content-Type -/- Content type declared in headers
+
diff --git a/kfile-plugins/rfc822/kfile_rfc822.cpp b/kfile-plugins/rfc822/kfile_rfc822.cpp
new file mode 100644
index 000000000..794d335d6
--- /dev/null
+++ b/kfile-plugins/rfc822/kfile_rfc822.cpp
@@ -0,0 +1,161 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Shane Wright <me@shanewright.co.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 "kfile_rfc822.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>
+
+#if !defined(__osf__)
+#include <inttypes.h>
+#else
+typedef unsigned short uint32_t;
+#endif
+
+typedef KGenericFactory<KRfc822Plugin> Rfc822Factory;
+
+K_EXPORT_COMPONENT_FACTORY(kfile_rfc822, Rfc822Factory( "kfile_rfc822" ))
+
+KRfc822Plugin::KRfc822Plugin(QObject *parent, const char *name,
+ const QStringList &args)
+
+ : KFilePlugin(parent, name, args)
+{
+ KFileMimeTypeInfo* info = addMimeTypeInfo( "message/rfc822" );
+
+ KFileMimeTypeInfo::GroupInfo* group = 0L;
+
+ group = addGroupInfo(info, "Technical", i18n("Technical Details"));
+
+ KFileMimeTypeInfo::ItemInfo* item;
+
+ item = addItemInfo(group, "From", i18n("From"), QVariant::String);
+ item = addItemInfo(group, "To", i18n("To"), QVariant::String);
+ item = addItemInfo(group, "Subject", i18n("Subject"), QVariant::String);
+ item = addItemInfo(group, "Date", i18n("Date"), QVariant::String);
+ item = addItemInfo(group, "Content-Type", i18n("Content-Type"), QVariant::String);
+}
+
+
+bool KRfc822Plugin::readInfo( KFileMetaInfo& info, uint /*what*/ )
+{
+
+ QFile file(info.path());
+
+ if (!file.open(IO_ReadOnly))
+ {
+ kdDebug(7034) << "Couldn't open " << QFile::encodeName(info.path()) << endl;
+ return false;
+ }
+
+ /*
+ Note to self: probably should use QCString for all this, but
+ what we're doing is simple and self-contained so never mind..
+ */
+
+ char id_from[] = "From: ";
+ char id_to[] = "To: ";
+ char id_subject[] = "Subject: ";
+ char id_date[] = "Date: ";
+ char id_contenttype[] = "Content-Type: ";
+
+ // we need a buffer for lines
+ char linebuf[4096];
+
+ // we need a buffer for other stuff
+ char buf_from[1000] = "";
+ char buf_to[1000] = "";
+ char buf_subject[1000] = "";
+ char buf_date[1000] = "";
+ char buf_contenttype[1000] = "";
+
+ memset(buf_from, 0, 999);
+ memset(buf_to, 0, 999);
+ memset(buf_subject, 0, 999);
+ memset(buf_date, 0, 999);
+ memset(buf_contenttype, 0, 999);
+ char * myptr;
+
+ bool done=false;
+ while (!done) {
+
+ // read a line
+ file.readLine(linebuf, sizeof( linebuf ));
+
+ // have we got something useful?
+ if (memcmp(linebuf, id_from, 6) == 0) {
+ // we have a name
+ myptr = linebuf + 6;
+ strncpy(buf_from, myptr, sizeof( buf_from ));
+ buf_from[998]='\0';
+ } else if (memcmp(linebuf, id_to, 4) == 0) {
+ // we have a name
+ myptr = linebuf + 4;
+ strncpy(buf_to, myptr, sizeof( buf_to ));
+ buf_to[998]='\0';
+ } else if (memcmp(linebuf, id_subject, 9) == 0) {
+ // we have a name
+ myptr = linebuf + 9;
+ strncpy(buf_subject, myptr, sizeof( buf_subject ));
+ buf_subject[998]='\0';
+ } else if (memcmp(linebuf, id_date, 6) == 0) {
+ // we have a name
+ myptr = linebuf + 6;
+ strncpy(buf_date, myptr, sizeof( buf_date ));
+ buf_date[998]='\0';
+ } else if (memcmp(linebuf, id_contenttype, 14) == 0) {
+ // we have a name
+ myptr = linebuf + 14;
+ strncpy(buf_contenttype, myptr, sizeof( buf_contenttype ));
+ buf_contenttype[998]='\0';
+ }
+
+ // are we done yet?
+ if (
+ ((strlen(buf_from) > 0) && (strlen(buf_to) > 0) &&
+ (strlen(buf_subject) > 0) && (strlen(buf_date) > 0) &&
+ (strlen(buf_contenttype) > 0)) ||
+ (file.atEnd())
+ )
+ done = true;
+
+ };
+
+ KFileMetaInfoGroup group = appendGroup(info, "Technical");
+
+ if (strlen(buf_from) > 0) appendItem(group, "From", buf_from);
+ if (strlen(buf_to) > 0) appendItem(group, "To", buf_to);
+ if (strlen(buf_subject) > 0) appendItem(group, "Subject", buf_subject);
+ if (strlen(buf_date) > 0) appendItem(group, "Date", buf_date);
+ if (strlen(buf_contenttype) > 0) appendItem(group, "Content-Type", buf_contenttype);
+
+ return true;
+}
+
+#include "kfile_rfc822.moc"
diff --git a/kfile-plugins/rfc822/kfile_rfc822.desktop b/kfile-plugins/rfc822/kfile_rfc822.desktop
new file mode 100644
index 000000000..1428c96f8
--- /dev/null
+++ b/kfile-plugins/rfc822/kfile_rfc822.desktop
@@ -0,0 +1,63 @@
+[Desktop Entry]
+Type=Service
+Name=Email Info
+Name[af]=E-pos informasie
+Name[be]=Інфармацыя аб паведамленні электроннай пошты
+Name[bg]=Информация за е-поща
+Name[br]=Titouroù postel
+Name[ca]=Informació de correu-e
+Name[cs]=Informace o emailu
+Name[cy]=Gwybodaeth Ebost
+Name[da]=E-mail-info
+Name[de]=E-Mail-Info
+Name[el]=Πληροφορίες Email
+Name[eo]=Retpoŝt-informo
+Name[es]=Info de correo electrónico
+Name[et]=Kirja info
+Name[eu]=E-posta informazioa
+Name[fa]=اطلاعات رایانامه
+Name[fi]=Sähköpostitiedot
+Name[fr]=Informations sur le courrier électronique
+Name[fy]=E-port-ynformaasje
+Name[gl]=Información de Correo-e
+Name[he]=מידע על דוא"ל
+Name[hi]=ई-मेल जानकारी
+Name[hr]=Email Informacije
+Name[hu]=E-mail-jellemzők
+Name[is]=Tölvupóst upplýsingar
+Name[it]=Informazioni di posta elettronica
+Name[ja]=Eメール 情報
+Name[ka]=ელფოსტის ინფორმაცია
+Name[kk]=Эл.пошта мәліметі
+Name[km]=ព័ត៌មាន​អ៊ីមែល
+Name[lt]=E. pašto info
+Name[mk]=Информации за е-пошта
+Name[ms]=Info Emel
+Name[nb]=E-post-info
+Name[nds]=Nettbreef-Informatschonen
+Name[ne]=इमेल सूचना
+Name[nl]=E-mail-informatie
+Name[nn]=Epost-info
+Name[pa]=ਈ-ਪੱਤਰ ਜਾਣਕਾਰੀ
+Name[pl]=Informacja o e-mailu
+Name[pt]=Informação do E-Mail
+Name[pt_BR]=Informações sobre E-mail
+Name[ro]=Informaţii e-mail
+Name[ru]=Сведения об электронной почте
+Name[se]=E-boastadieđut
+Name[sk]=Informácie o emaily
+Name[sl]=Informacije o e-pošti
+Name[sr]=Е-поштанске информације
+Name[sr@Latn]=E-poštanske informacije
+Name[sv]=E-postinformation
+Name[ta]=மின்னஞ்சல் தகவல்
+Name[tg]=Иттилоот дар бораи почтаи электронӣ
+Name[tr]=E-Posta Bilgisi
+Name[uk]=Інформація про повідомлення ел. пошти
+Name[zh_CN]=电子邮件信息
+Name[zh_TW]=電子郵件資訊
+ServiceTypes=KFilePlugin
+X-KDE-Library=kfile_rfc822
+MimeType=message/rfc822
+PreferredGroups=Technical
+PreferredItems=From,To,Subject,Date,Content-Type
diff --git a/kfile-plugins/rfc822/kfile_rfc822.h b/kfile-plugins/rfc822/kfile_rfc822.h
new file mode 100644
index 000000000..f2066754a
--- /dev/null
+++ b/kfile-plugins/rfc822/kfile_rfc822.h
@@ -0,0 +1,37 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Shane Wright <me@shanewright.co.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_RFC822_H__
+#define __KFILE_RFC822_H__
+
+#include <kfilemetainfo.h>
+
+class QStringList;
+
+class KRfc822Plugin: public KFilePlugin
+{
+ Q_OBJECT
+
+public:
+ KRfc822Plugin( QObject *parent, const char *name, const QStringList& args );
+
+ virtual bool readInfo( KFileMetaInfo& info, uint what);
+};
+
+#endif