summaryrefslogtreecommitdiffstats
path: root/kfile-plugins/ics
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/ics
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/ics')
-rw-r--r--kfile-plugins/ics/Makefile.am24
-rw-r--r--kfile-plugins/ics/kfile_ics.cpp96
-rw-r--r--kfile-plugins/ics/kfile_ics.desktop57
-rw-r--r--kfile-plugins/ics/kfile_ics.h36
4 files changed, 213 insertions, 0 deletions
diff --git a/kfile-plugins/ics/Makefile.am b/kfile-plugins/ics/Makefile.am
new file mode 100644
index 00000000..7ff0281c
--- /dev/null
+++ b/kfile-plugins/ics/Makefile.am
@@ -0,0 +1,24 @@
+# Makefile.am for ics file meta info plugin
+
+# set the include path for X, kdepim, qt and KDE
+INCLUDES = \
+ -I$(top_srcdir) \
+ $(all_includes)
+
+# these are the headers for your project
+noinst_HEADERS = kfile_ics.h
+
+kde_module_LTLIBRARIES = kfile_ics.la
+
+kfile_ics_la_SOURCES = kfile_ics.cpp
+kfile_ics_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+kfile_ics_la_LIBADD = $(top_builddir)/libkcal/libkcal.la $(LIB_KSYCOCA)
+
+
+METASOURCES = AUTO
+
+messages: rc.cpp
+ $(XGETTEXT) kfile_ics.cpp -o $(podir)/kfile_ics.pot
+
+services_DATA = kfile_ics.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/kfile-plugins/ics/kfile_ics.cpp b/kfile-plugins/ics/kfile_ics.cpp
new file mode 100644
index 00000000..a78ec040
--- /dev/null
+++ b/kfile-plugins/ics/kfile_ics.cpp
@@ -0,0 +1,96 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2004 Bram Schoenmakers <bramschoenmakers@kde.nl>
+ *
+ * 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
+t 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 <qdatetime.h>
+#include <qfile.h>
+
+#include <libkcal/calendarlocal.h>
+#include <libkcal/todo.h>
+
+#include "kfile_ics.h"
+
+#include <kgenericfactory.h>
+
+using namespace KCal;
+
+typedef KGenericFactory<ICSPlugin> ICSFactory;
+K_EXPORT_COMPONENT_FACTORY(kfile_ics, ICSFactory( "kfile_ics" ))
+
+ICSPlugin::ICSPlugin( QObject *parent, const char *name, const QStringList& args )
+ : KFilePlugin( parent, name, args )
+{
+ KFileMimeTypeInfo* info = addMimeTypeInfo( "text/calendar" ); //TODO: vcs !!
+
+ KFileMimeTypeInfo::GroupInfo* group = 0L;
+ group = addGroupInfo(info, "ICSInfo", i18n("Calendar Statistics"));
+
+ addItemInfo( group, "ProductID", i18n("Product ID"), QVariant::String );
+ addItemInfo( group, "Events", i18n("Events"), QVariant::Int );
+ addItemInfo( group, "Todos", i18n("To-dos"), QVariant::Int );
+ addItemInfo( group, "TodoCompleted", i18n("Completed To-dos"), QVariant::Int );
+ addItemInfo( group, "TodoOverdue", i18n("Overdue To-dos"), QVariant::Int );
+ addItemInfo( group, "Journals", i18n("Journals"), QVariant::Int );
+// addItemInfo( group, "Reminders", i18n("Reminders"), QVariant::Int );
+
+}
+
+/*
+I chose to use libkcal instead of reading the calendar manually. It's easier to
+maintain this way.
+*/
+bool ICSPlugin::readInfo( KFileMetaInfo& info, uint /*what*/ )
+{
+ KFileMetaInfoGroup group = appendGroup( info, "ICSInfo");
+
+ CalendarLocal cal ( QString::fromLatin1( "UTC" ) );
+ if( !cal.load( info.path() ) ) {
+ kdDebug() << "Could not load calendar" << endl;
+ return false;
+ }
+
+ appendItem( group, "ProductID", QVariant( cal.productId() ) );
+ appendItem( group, "Events", QVariant( int( cal.events().count() ) ) );
+ appendItem( group, "Journals", QVariant( int( cal.journals().count() ) ) );
+ Todo::List todos = cal.todos();
+
+ // count completed and overdue
+ Todo::List::ConstIterator it = todos.begin();
+ Todo::List::ConstIterator end = todos.end();
+
+ int completed = 0;
+ int overdue = 0;
+ for ( ; it != end ; ++it ) {
+ Todo *todo = *it;
+ if ( todo->isCompleted() )
+ ++completed;
+ else if ( todo->hasDueDate() && todo->dtDue().date() < QDate::currentDate() )
+ ++overdue;
+ }
+
+ appendItem( group, "Todos", QVariant( int(todos.count() ) ) );
+ appendItem( group, "TodoCompleted", QVariant( completed ) );
+ appendItem( group, "TodoOverdue", QVariant( overdue ) );
+
+ cal.close();
+
+ return true;
+}
+
+#include "kfile_ics.moc"
diff --git a/kfile-plugins/ics/kfile_ics.desktop b/kfile-plugins/ics/kfile_ics.desktop
new file mode 100644
index 00000000..2a530ce2
--- /dev/null
+++ b/kfile-plugins/ics/kfile_ics.desktop
@@ -0,0 +1,57 @@
+[Desktop Entry]
+Type=Service
+Name=ICS information
+Name[af]=ICS informasie
+Name[be]=Інфармацыя аб ICS
+Name[bg]=ICS информация
+Name[br]=Titouroù ICS
+Name[ca]=Informació ICS
+Name[cs]=Informace o ICS
+Name[da]=ICS-information
+Name[de]=ICS-Information
+Name[el]=Πληροφορίες ICS
+Name[eo]=ICS-Informo
+Name[es]=Información ICS
+Name[et]=ICS info
+Name[eu]=ICS informazioa
+Name[fa]=اطلاعات ICS
+Name[fi]=ICS-tiedot
+Name[fr]=Information sur ICS
+Name[fy]=ICS-ynformaasje
+Name[gl]=Información ICS
+Name[he]=מידע של ICS
+Name[hu]=ICS-jellemzők
+Name[is]=ICS upplýsingar
+Name[it]=Informazioni ICS
+Name[ja]=ICS 情報
+Name[ka]=ICS ინფორმაცია
+Name[kk]=ICS ақпараты
+Name[km]=ព័ត៌មាន ICS
+Name[lt]=ICS informacija
+Name[mk]=Информација за ICS
+Name[ms]=Maklumat ICS
+Name[nb]=ICS-informasjon
+Name[nds]=ICS-Informatschoon
+Name[ne]=ICS सूचना
+Name[nl]=ICS-informatie
+Name[nn]=ICS-informasjon
+Name[pa]=ICS ਜਾਣਕਾਰੀ
+Name[pl]=Informacja ICS
+Name[pt]=Informação ICS
+Name[pt_BR]=Informações ICS
+Name[ru]=Информация ICS
+Name[sk]=Informácie o ICS
+Name[sl]=Podatki ICS
+Name[sr]=ICS информације
+Name[sr@Latn]=ICS informacije
+Name[sv]=ICS-information
+Name[ta]=ICS தகவல்
+Name[tr]=ICS bilgisi
+Name[uk]=Інформація про ICS
+Name[zh_CN]=ICS 信息
+Name[zh_TW]=ICS 資訊
+ServiceTypes=KFilePlugin
+X-KDE-Library=kfile_ics
+MimeType=text/calendar
+PreferredGroups=ICSInfo
+PreferredItems=Events,Todos,Journals
diff --git a/kfile-plugins/ics/kfile_ics.h b/kfile-plugins/ics/kfile_ics.h
new file mode 100644
index 00000000..27e7e43d
--- /dev/null
+++ b/kfile-plugins/ics/kfile_ics.h
@@ -0,0 +1,36 @@
+ /* This file is part of the KDE project
+ * Copyright (C) 2004 Bram Schoenmakers <bramschoenmakers@kde.nl>
+ *
+ * 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_ICS_H
+#define KFILE_ICS_H
+
+#include <kfilemetainfo.h>
+
+class QStringList;
+
+class ICSPlugin : public KFilePlugin
+{
+ Q_OBJECT
+public:
+ ICSPlugin( QObject *parent, const char *name, const QStringList& args );
+
+ virtual bool readInfo( KFileMetaInfo& info, uint what );
+};
+
+#endif