summaryrefslogtreecommitdiffstats
path: root/tdefile-plugins/vcf
diff options
context:
space:
mode:
Diffstat (limited to 'tdefile-plugins/vcf')
-rw-r--r--tdefile-plugins/vcf/CMakeLists.txt35
-rw-r--r--tdefile-plugins/vcf/Makefile.am22
-rw-r--r--tdefile-plugins/vcf/tdefile_vcf.cpp103
-rw-r--r--tdefile-plugins/vcf/tdefile_vcf.desktop65
-rw-r--r--tdefile-plugins/vcf/tdefile_vcf.h38
5 files changed, 263 insertions, 0 deletions
diff --git a/tdefile-plugins/vcf/CMakeLists.txt b/tdefile-plugins/vcf/CMakeLists.txt
new file mode 100644
index 000000000..4cf771d26
--- /dev/null
+++ b/tdefile-plugins/vcf/CMakeLists.txt
@@ -0,0 +1,35 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) 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_vcf.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+
+
+##### tdefile_vcf (module) ########################
+
+tde_add_kpart( tdefile_vcf AUTOMOC
+ SOURCES tdefile_vcf.cpp
+ LINK kabc-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/tdefile-plugins/vcf/Makefile.am b/tdefile-plugins/vcf/Makefile.am
new file mode 100644
index 000000000..61b306d5f
--- /dev/null
+++ b/tdefile-plugins/vcf/Makefile.am
@@ -0,0 +1,22 @@
+## Makefile.am for vcf 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_vcf.h
+
+kde_module_LTLIBRARIES = tdefile_vcf.la
+
+tdefile_vcf_la_SOURCES = tdefile_vcf.cpp
+tdefile_vcf_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_QT) -ltdecore
+tdefile_vcf_la_LIBADD = $(LIB_KSYCOCA) $(LIB_KABC)
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages: rc.cpp
+ $(XGETTEXT) tdefile_vcf.cpp -o $(podir)/tdefile_vcf.pot
+
+services_DATA = tdefile_vcf.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/tdefile-plugins/vcf/tdefile_vcf.cpp b/tdefile-plugins/vcf/tdefile_vcf.cpp
new file mode 100644
index 000000000..e8746c56a
--- /dev/null
+++ b/tdefile-plugins/vcf/tdefile_vcf.cpp
@@ -0,0 +1,103 @@
+/* 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 <kdebug.h>
+#include <config.h>
+#include "tdefile_vcf.h"
+
+#include <kprocess.h>
+#include <klocale.h>
+#include <kgenericfactory.h>
+#include <kabc/vcardconverter.h>
+
+#include <tqdict.h>
+#include <tqfile.h>
+
+typedef KGenericFactory<KVcfPlugin> VcfFactory;
+
+K_EXPORT_COMPONENT_FACTORY(tdefile_vcf, VcfFactory( "tdefile_vcf" ))
+
+KVcfPlugin::KVcfPlugin(TQObject *parent, const char *name,
+ const TQStringList &args)
+
+ : KFilePlugin(parent, name, args)
+{
+ KFileMimeTypeInfo* info = addMimeTypeInfo( "text/x-vcard" );
+
+ KFileMimeTypeInfo::GroupInfo* group = 0L;
+
+ group = addGroupInfo(info, "Technical", i18n("Technical Details"));
+
+ KFileMimeTypeInfo::ItemInfo* item;
+
+ item = addItemInfo(group, "Name", i18n("Name"), TQVariant::String);
+ item = addItemInfo(group, "Email", i18n("Email"), TQVariant::String);
+ item = addItemInfo(group, "Telephone", i18n("Telephone"), TQVariant::String);
+}
+
+
+bool KVcfPlugin::readInfo( KFileMetaInfo& info, uint /*what*/ )
+{
+ TQFile file(info.path());
+
+ if (!file.open(IO_ReadOnly))
+ {
+ kdDebug(7034) << "Couldn't open " << TQString(TQFile::encodeName(info.path())) << endl;
+ return false;
+ }
+
+ // even the vcard thumbnail TQString::fromUtf8(buf_name));creator reads the full file ...
+ // The following is partly copied from there
+ TQString contents = file.readAll();
+ file.close();
+
+ KABC::VCardConverter converter;
+#if defined(KABC_VCARD_ENCODING_FIX)
+ KABC::Addressee addr = converter.parseVCardRaw( contents.utf8() );
+#else
+ KABC::Addressee addr = converter.parseVCard( contents );
+#endif
+ KFileMetaInfoGroup group = appendGroup(info, "Technical");
+
+ // prepare the text
+ TQString name = addr.formattedName().simplifyWhiteSpace();
+ if ( name.isEmpty() )
+ name = addr.givenName() + " " + addr.familyName();
+ name = name.simplifyWhiteSpace();
+
+ if ( ! name.isEmpty() )
+ appendItem(group, "Name", name);
+
+ if ( ! addr.preferredEmail().isEmpty() )
+ appendItem(group, "Email", addr.preferredEmail());
+
+ KABC::PhoneNumber::List pnList = addr.phoneNumbers();
+ TQStringList phoneNumbers;
+ for (unsigned int no=0; no<pnList.count(); ++no) {
+ TQString pn = pnList[no].number().simplifyWhiteSpace();
+ if (!pn.isEmpty() && !phoneNumbers.contains(pn))
+ phoneNumbers.append(pn);
+ }
+ if ( !phoneNumbers.isEmpty() )
+ appendItem(group, "Telephone", phoneNumbers.join("\n"));
+
+ return true;
+}
+
+#include "tdefile_vcf.moc"
diff --git a/tdefile-plugins/vcf/tdefile_vcf.desktop b/tdefile-plugins/vcf/tdefile_vcf.desktop
new file mode 100644
index 000000000..730d731ab
--- /dev/null
+++ b/tdefile-plugins/vcf/tdefile_vcf.desktop
@@ -0,0 +1,65 @@
+[Desktop Entry]
+Type=Service
+Name=vCard Info
+Name[af]=Vkaart Inligting
+Name[be]=Інфармацыя аб vCard
+Name[bg]=Информация за vCard
+Name[br]=Titouroù diwar-benn vCard
+Name[ca]=Informació de vCard
+Name[cs]=VCard info
+Name[cy]=Gwybodaeth vCard
+Name[da]=VCard-info
+Name[de]=vCard-Info
+Name[el]=Πληροφορίες vCard
+Name[eo]=vCard-informo
+Name[es]=Info de vCard
+Name[et]=vCardi info
+Name[eu]=vCard informazioa
+Name[fa]=اطلاعات vCard
+Name[fi]=vCard-tiedot
+Name[fr]=Informations vCard
+Name[fy]=vCard-ynformaasje
+Name[gl]=Información de vCard
+Name[he]=מידע vCard
+Name[hi]=वी-कार्ड जानकारी
+Name[hu]=VCard-jellemzők
+Name[is]=vCard upplýsingar
+Name[it]=Informazioni vCard
+Name[ja]=vCard 情報
+Name[kk]=vCard мәліметі
+Name[km]=ព័ត៌មាន vCard
+Name[lt]=vCard informacija
+Name[mk]=Информации за vCard
+Name[ms]=Info vCard
+Name[mt]=Informazzjoni vCard
+Name[nb]=vCard info
+Name[nds]=vCard-Informatschonen
+Name[ne]=भी कार्ड सुचना
+Name[nl]=vCard-informatie
+Name[nn]=vCard-info
+Name[nso]=Tshedimoso ya vKarata
+Name[pa]=vCard ਜਾਣਕਾਰੀ
+Name[pl]=Informacja vCard
+Name[pt]=Informação do vCard
+Name[pt_BR]=Informações sobre vCard
+Name[ro]=Informaţii vCard
+Name[ru]=Сведения о визитке vCard
+Name[se]=vCard-dieđut
+Name[sl]=Informacije o vCard
+Name[sr]=vCard информације
+Name[sr@Latn]=vCard informacije
+Name[sv]=vCard-information
+Name[ta]=விஅட்டை தகவல்
+Name[tg]=Иттилоот дар бораи визиткаи vCard
+Name[tr]=VCard Bilgisi
+Name[uk]=Інформація про vCard
+Name[ven]=Mafhungo a vCard
+Name[xh]=Inkcukacha ye vCard
+Name[zh_CN]=vCard 信息
+Name[zh_TW]=vCard 資訊
+Name[zu]=Ulwazi lwe-vCard
+ServiceTypes=KFilePlugin
+X-TDE-Library=tdefile_vcf
+MimeType=text/x-vcard
+PreferredGroups=Technical
+PreferredItems=Name,Email,Telephone
diff --git a/tdefile-plugins/vcf/tdefile_vcf.h b/tdefile-plugins/vcf/tdefile_vcf.h
new file mode 100644
index 000000000..19866d8b8
--- /dev/null
+++ b/tdefile-plugins/vcf/tdefile_vcf.h
@@ -0,0 +1,38 @@
+/* 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_VCF_H__
+#define __KFILE_VCF_H__
+
+#include <tdefilemetainfo.h>
+
+class TQStringList;
+
+class KVcfPlugin: public KFilePlugin
+{
+ Q_OBJECT
+
+
+public:
+ KVcfPlugin( TQObject *parent, const char *name, const TQStringList& args );
+
+ virtual bool readInfo( KFileMetaInfo& info, uint what);
+};
+
+#endif