From 10251f9a2a51f37c2a42833c1d05cd5a8fdf6bb5 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 17 Feb 2013 02:06:43 -0600 Subject: Fix FTBFS --- tderesources/birthdays/Makefile.am | 6 +- tderesources/carddav/kabc_carddav.desktop | 52 -- tderesources/carddav/plugin.cpp | 2 +- tderesources/carddav/tdeabc_carddav.desktop | 52 ++ tderesources/egroupware/kabc_egroupwareprefs.kcfgc | 11 - tderesources/egroupware/kabc_resourcexmlrpc.cpp | 774 --------------------- tderesources/egroupware/kabc_resourcexmlrpc.h | 115 --- .../egroupware/kabc_resourcexmlrpcconfig.cpp | 97 --- .../egroupware/kabc_resourcexmlrpcconfig.h | 53 -- .../egroupware/kabc_resourcexmlrpcplugin.cpp | 40 -- tderesources/egroupware/kabc_xmlrpc.desktop | 50 -- .../egroupware/tdeabc_egroupwareprefs.kcfgc | 11 + tderesources/egroupware/tdeabc_resourcexmlrpc.cpp | 774 +++++++++++++++++++++ tderesources/egroupware/tdeabc_resourcexmlrpc.h | 115 +++ .../egroupware/tdeabc_resourcexmlrpcconfig.cpp | 97 +++ .../egroupware/tdeabc_resourcexmlrpcconfig.h | 53 ++ .../egroupware/tdeabc_resourcexmlrpcplugin.cpp | 40 ++ tderesources/egroupware/tdeabc_xmlrpc.desktop | 50 ++ .../egroupware/tderesources_kabc_egroupware.kcfg | 24 - .../egroupware/tderesources_tdeabc_egroupware.kcfg | 24 + tderesources/groupdav/kabc_groupdav.desktop | 52 -- tderesources/groupdav/kabc_resourcegroupdav.cpp | 47 -- tderesources/groupdav/kabc_resourcegroupdav.h | 45 -- .../groupdav/kabc_resourcegroupdav_plugin.cpp | 42 -- tderesources/groupdav/tdeabc_groupdav.desktop | 52 ++ tderesources/groupdav/tdeabc_resourcegroupdav.cpp | 47 ++ tderesources/groupdav/tdeabc_resourcegroupdav.h | 45 ++ .../groupdav/tdeabc_resourcegroupdav_plugin.cpp | 42 ++ tderesources/groupware/kabc_groupware.desktop | 49 -- tderesources/groupware/kabc_groupwareprefs.kcfgc | 8 - tderesources/groupware/kabc_resourcegroupware.cpp | 365 ---------- tderesources/groupware/kabc_resourcegroupware.h | 87 --- .../groupware/kabc_resourcegroupware_plugin.cpp | 39 -- .../groupware/kabc_resourcegroupwareconfig.cpp | 208 ------ .../groupware/kabc_resourcegroupwareconfig.h | 71 -- tderesources/groupware/tdeabc_groupware.desktop | 49 ++ tderesources/groupware/tdeabc_groupwareprefs.kcfgc | 8 + .../groupware/tdeabc_resourcegroupware.cpp | 365 ++++++++++ tderesources/groupware/tdeabc_resourcegroupware.h | 87 +++ .../groupware/tdeabc_resourcegroupware_plugin.cpp | 39 ++ .../groupware/tdeabc_resourcegroupwareconfig.cpp | 208 ++++++ .../groupware/tdeabc_resourcegroupwareconfig.h | 71 ++ .../groupware/tderesources_kabc_groupware.kcfg | 18 - .../groupware/tderesources_tdeabc_groupware.kcfg | 18 + tderesources/groupwise/kabc_groupwise.desktop | 50 -- tderesources/groupwise/kabc_groupwiseprefs.kcfgc | 8 - tderesources/groupwise/kabc_resourcegroupwise.cpp | 743 -------------------- tderesources/groupwise/kabc_resourcegroupwise.h | 169 ----- .../groupwise/kabc_resourcegroupwise_plugin.cpp | 40 -- .../groupwise/kabc_resourcegroupwiseconfig.cpp | 209 ------ .../groupwise/kabc_resourcegroupwiseconfig.h | 74 -- tderesources/groupwise/tdeabc_groupwise.desktop | 50 ++ tderesources/groupwise/tdeabc_groupwiseprefs.kcfgc | 8 + .../groupwise/tdeabc_resourcegroupwise.cpp | 743 ++++++++++++++++++++ tderesources/groupwise/tdeabc_resourcegroupwise.h | 169 +++++ .../groupwise/tdeabc_resourcegroupwise_plugin.cpp | 40 ++ .../groupwise/tdeabc_resourcegroupwiseconfig.cpp | 209 ++++++ .../groupwise/tdeabc_resourcegroupwiseconfig.h | 74 ++ .../groupwise/tderesources_kabc_groupwise.kcfg | 55 -- .../groupwise/tderesources_tdeabc_groupwise.kcfg | 55 ++ tderesources/lib/kabc_resourcegroupwarebase.cpp | 262 ------- tderesources/lib/kabc_resourcegroupwarebase.h | 99 --- .../lib/kabc_resourcegroupwarebaseconfig.cpp | 117 ---- .../lib/kabc_resourcegroupwarebaseconfig.h | 65 -- tderesources/lib/tdeabc_resourcegroupwarebase.cpp | 262 +++++++ tderesources/lib/tdeabc_resourcegroupwarebase.h | 99 +++ .../lib/tdeabc_resourcegroupwarebaseconfig.cpp | 117 ++++ .../lib/tdeabc_resourcegroupwarebaseconfig.h | 65 ++ tderesources/newexchange/kabc_newexchange.desktop | 51 -- .../newexchange/kabc_newexchange_final.desktop | 48 -- tderesources/newexchange/kabc_resourceexchange.cpp | 54 -- tderesources/newexchange/kabc_resourceexchange.h | 43 -- .../newexchange/kabc_resourceexchange_plugin.cpp | 27 - .../newexchange/tdeabc_newexchange.desktop | 51 ++ .../newexchange/tdeabc_newexchange_final.desktop | 48 ++ .../newexchange/tdeabc_resourceexchange.cpp | 54 ++ tderesources/newexchange/tdeabc_resourceexchange.h | 43 ++ .../newexchange/tdeabc_resourceexchange_plugin.cpp | 27 + tderesources/slox/kabc_ox.desktop | 46 -- tderesources/slox/kabc_slox.desktop | 51 -- tderesources/slox/kabcresourceslox.cpp | 8 +- tderesources/slox/kabcresourceslox_plugin.cpp | 2 +- tderesources/slox/kabcsloxprefs.kcfgc | 2 +- tderesources/slox/tdeabc_ox.desktop | 46 ++ tderesources/slox/tdeabc_slox.desktop | 51 ++ tderesources/slox/tderesources_kabc_slox.kcfg | 31 - tderesources/slox/tderesources_tdeabc_slox.kcfg | 31 + 87 files changed, 4499 insertions(+), 4499 deletions(-) delete mode 100644 tderesources/carddav/kabc_carddav.desktop create mode 100644 tderesources/carddav/tdeabc_carddav.desktop delete mode 100644 tderesources/egroupware/kabc_egroupwareprefs.kcfgc delete mode 100644 tderesources/egroupware/kabc_resourcexmlrpc.cpp delete mode 100644 tderesources/egroupware/kabc_resourcexmlrpc.h delete mode 100644 tderesources/egroupware/kabc_resourcexmlrpcconfig.cpp delete mode 100644 tderesources/egroupware/kabc_resourcexmlrpcconfig.h delete mode 100644 tderesources/egroupware/kabc_resourcexmlrpcplugin.cpp delete mode 100644 tderesources/egroupware/kabc_xmlrpc.desktop create mode 100644 tderesources/egroupware/tdeabc_egroupwareprefs.kcfgc create mode 100644 tderesources/egroupware/tdeabc_resourcexmlrpc.cpp create mode 100644 tderesources/egroupware/tdeabc_resourcexmlrpc.h create mode 100644 tderesources/egroupware/tdeabc_resourcexmlrpcconfig.cpp create mode 100644 tderesources/egroupware/tdeabc_resourcexmlrpcconfig.h create mode 100644 tderesources/egroupware/tdeabc_resourcexmlrpcplugin.cpp create mode 100644 tderesources/egroupware/tdeabc_xmlrpc.desktop delete mode 100644 tderesources/egroupware/tderesources_kabc_egroupware.kcfg create mode 100644 tderesources/egroupware/tderesources_tdeabc_egroupware.kcfg delete mode 100644 tderesources/groupdav/kabc_groupdav.desktop delete mode 100644 tderesources/groupdav/kabc_resourcegroupdav.cpp delete mode 100644 tderesources/groupdav/kabc_resourcegroupdav.h delete mode 100644 tderesources/groupdav/kabc_resourcegroupdav_plugin.cpp create mode 100644 tderesources/groupdav/tdeabc_groupdav.desktop create mode 100644 tderesources/groupdav/tdeabc_resourcegroupdav.cpp create mode 100644 tderesources/groupdav/tdeabc_resourcegroupdav.h create mode 100644 tderesources/groupdav/tdeabc_resourcegroupdav_plugin.cpp delete mode 100644 tderesources/groupware/kabc_groupware.desktop delete mode 100644 tderesources/groupware/kabc_groupwareprefs.kcfgc delete mode 100644 tderesources/groupware/kabc_resourcegroupware.cpp delete mode 100644 tderesources/groupware/kabc_resourcegroupware.h delete mode 100644 tderesources/groupware/kabc_resourcegroupware_plugin.cpp delete mode 100644 tderesources/groupware/kabc_resourcegroupwareconfig.cpp delete mode 100644 tderesources/groupware/kabc_resourcegroupwareconfig.h create mode 100644 tderesources/groupware/tdeabc_groupware.desktop create mode 100644 tderesources/groupware/tdeabc_groupwareprefs.kcfgc create mode 100644 tderesources/groupware/tdeabc_resourcegroupware.cpp create mode 100644 tderesources/groupware/tdeabc_resourcegroupware.h create mode 100644 tderesources/groupware/tdeabc_resourcegroupware_plugin.cpp create mode 100644 tderesources/groupware/tdeabc_resourcegroupwareconfig.cpp create mode 100644 tderesources/groupware/tdeabc_resourcegroupwareconfig.h delete mode 100644 tderesources/groupware/tderesources_kabc_groupware.kcfg create mode 100644 tderesources/groupware/tderesources_tdeabc_groupware.kcfg delete mode 100644 tderesources/groupwise/kabc_groupwise.desktop delete mode 100644 tderesources/groupwise/kabc_groupwiseprefs.kcfgc delete mode 100644 tderesources/groupwise/kabc_resourcegroupwise.cpp delete mode 100644 tderesources/groupwise/kabc_resourcegroupwise.h delete mode 100644 tderesources/groupwise/kabc_resourcegroupwise_plugin.cpp delete mode 100644 tderesources/groupwise/kabc_resourcegroupwiseconfig.cpp delete mode 100644 tderesources/groupwise/kabc_resourcegroupwiseconfig.h create mode 100644 tderesources/groupwise/tdeabc_groupwise.desktop create mode 100644 tderesources/groupwise/tdeabc_groupwiseprefs.kcfgc create mode 100644 tderesources/groupwise/tdeabc_resourcegroupwise.cpp create mode 100644 tderesources/groupwise/tdeabc_resourcegroupwise.h create mode 100644 tderesources/groupwise/tdeabc_resourcegroupwise_plugin.cpp create mode 100644 tderesources/groupwise/tdeabc_resourcegroupwiseconfig.cpp create mode 100644 tderesources/groupwise/tdeabc_resourcegroupwiseconfig.h delete mode 100644 tderesources/groupwise/tderesources_kabc_groupwise.kcfg create mode 100644 tderesources/groupwise/tderesources_tdeabc_groupwise.kcfg delete mode 100644 tderesources/lib/kabc_resourcegroupwarebase.cpp delete mode 100644 tderesources/lib/kabc_resourcegroupwarebase.h delete mode 100644 tderesources/lib/kabc_resourcegroupwarebaseconfig.cpp delete mode 100644 tderesources/lib/kabc_resourcegroupwarebaseconfig.h create mode 100644 tderesources/lib/tdeabc_resourcegroupwarebase.cpp create mode 100644 tderesources/lib/tdeabc_resourcegroupwarebase.h create mode 100644 tderesources/lib/tdeabc_resourcegroupwarebaseconfig.cpp create mode 100644 tderesources/lib/tdeabc_resourcegroupwarebaseconfig.h delete mode 100644 tderesources/newexchange/kabc_newexchange.desktop delete mode 100644 tderesources/newexchange/kabc_newexchange_final.desktop delete mode 100644 tderesources/newexchange/kabc_resourceexchange.cpp delete mode 100644 tderesources/newexchange/kabc_resourceexchange.h delete mode 100644 tderesources/newexchange/kabc_resourceexchange_plugin.cpp create mode 100644 tderesources/newexchange/tdeabc_newexchange.desktop create mode 100644 tderesources/newexchange/tdeabc_newexchange_final.desktop create mode 100644 tderesources/newexchange/tdeabc_resourceexchange.cpp create mode 100644 tderesources/newexchange/tdeabc_resourceexchange.h create mode 100644 tderesources/newexchange/tdeabc_resourceexchange_plugin.cpp delete mode 100644 tderesources/slox/kabc_ox.desktop delete mode 100644 tderesources/slox/kabc_slox.desktop create mode 100644 tderesources/slox/tdeabc_ox.desktop create mode 100644 tderesources/slox/tdeabc_slox.desktop delete mode 100644 tderesources/slox/tderesources_kabc_slox.kcfg create mode 100644 tderesources/slox/tderesources_tdeabc_slox.kcfg (limited to 'tderesources') diff --git a/tderesources/birthdays/Makefile.am b/tderesources/birthdays/Makefile.am index 6a5830052..c31fc0472 100644 --- a/tderesources/birthdays/Makefile.am +++ b/tderesources/birthdays/Makefile.am @@ -5,9 +5,9 @@ INCLUDES = -I$(top_srcdir) -I$(top_builddir) \ kde_module_LTLIBRARIES = kcal_kabc.la -kcal_kabc_la_SOURCES = resourcekabc.cpp resourcekabcconfig.cpp -kcal_kabc_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) -kcal_kabc_la_LIBADD = $(top_builddir)/libkcal/libkcal.la \ +kcal_tdeabc_la_SOURCES = resourcekabc.cpp resourcekabcconfig.cpp +kcal_tdeabc_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +kcal_tdeabc_la_LIBADD = $(top_builddir)/libkcal/libkcal.la \ $(top_builddir)/kaddressbook/common/libkabcommon.la libkcalincludedir = $(includedir)/libkcal diff --git a/tderesources/carddav/kabc_carddav.desktop b/tderesources/carddav/kabc_carddav.desktop deleted file mode 100644 index 585d11b36..000000000 --- a/tderesources/carddav/kabc_carddav.desktop +++ /dev/null @@ -1,52 +0,0 @@ -[Desktop Entry] -Name=CardDAV Server (e.g. Zimbra Contacts) -Name[af]=CardDAV bediener (bv. Zimbra Contacts) -Name[bg]=Сървър CardDAV (e.g. Zimbra Contacts) -Name[br]=Servijer CardDAV (e.g. Zimbra Contacts) -Name[ca]=Servidor CardDAV (p.ex. Zimbra Contacts) -Name[cs]=CardDAV server (např. Zimbra Contacts) -Name[da]=CardDAV-server (f.eks. Zimbra Contacts) -Name[de]=CardDAV-Server (z. B. Zimbra Contacts) -Name[el]=Εξυπηρετητής CardDAV (π.χ. Zimbra Contacts) -Name[es]=Servidor CardDAV (por ejemplo, Zimbra Contacts) -Name[et]=CardDAV server (nt. Zimbra Contacts) -Name[eu]=CardDAV zerbitzaria (adib. Zimbra Contacts) -Name[fa]=کارساز CardDAV (مثلاً Zimbra Contacts) -Name[fi]=CardDAV-palvelin (esim. Zimbra Contacts) -Name[fr]=CardDAV Serveur (ex. Zimbra Contacts) -Name[fy]=CardDAV-tsjinner (Zimbra Contacts) -Name[ga]=Freastalaí CardDAV (m.sh. Zimbra Contacts) -Name[gl]=Servidor CardDAV (e.g. Zimbra Contacts) -Name[hu]=CardDAV-kiszolgáló (pl. Zimbra Contacts) -Name[is]=CardDAV þjónn (t.d. Zimbra Contacts) -Name[it]=Server CardDAV (per es. Zimbra Contacts) -Name[ja]=CardDAV サーバ (例 Zimbra Contacts) -Name[ka]=სერვერი CardDAV (მაგ., Zimbra Contacts) -Name[kk]=CardDAV сервері (мысалы Zimbra Contacts) -Name[km]=ម៉ាស៊ីន​បម្រើ CardDAV (ឧ. Zimbra Contacts) -Name[lt]=CardDAV serveris (pvz.: Zimbra Contacts) -Name[ms]=Pelayan CardDAV (misalnya Zimbra Contacts) -Name[nb]=CardDAV-tjener (f.eks. Zimbra Contacts) -Name[nds]=CardDAV-Server (t.B. Zimbra Contacts) -Name[ne]=समूह DAV सर्भर (जस्तै: खुला ग्रुपवेयर) -Name[nl]=CardDAV-server (Zimbra Contacts) -Name[nn]=CardDAV-tenar (t.d. Zimbra Contacts) -Name[pl]=Serwer CardDAV (np. Zimbra Contacts) -Name[pt]=Servidor CardDAV (por exemplo Zimbra Contacts) -Name[pt_BR]=Servidor GroupDav (p. ex. Zimbra Contacts) -Name[ru]=Сервер CardDAV (например, Zimbra Contacts) -Name[sk]=CardDAV Server (napr. Zimbra Contacts) -Name[sl]=Strežnik CardDAV (npr. Zimbra Contacts) -Name[sr]=CardDAV сервер (нпр. Zimbra Contacts) -Name[sr@Latn]=CardDAV server (npr. Zimbra Contacts) -Name[sv]=CardDAV-server (t.ex. Zimbra Contacts) -Name[ta]=CardDAV சேவகன் (e.g. Zimbra Contacts) -Name[tr]=CardDAV Sunucusu (ör. Zimbra Contacts) -Name[uk]=Сервер CardDAV (напр., Zimbra Contacts) -Name[zh_CN]=CardDAV 服务器(如 Zimbra Contacts) -Name[zh_TW]=CardDAV 伺服器 (如: Zimbra Contacts) -X-TDE-Library=kabc_carddav -Type=Service -ServiceTypes=KResources/Plugin -X-TDE-ResourceFamily=contact -X-TDE-ResourceType=carddav diff --git a/tderesources/carddav/plugin.cpp b/tderesources/carddav/plugin.cpp index 9079ecd33..8b19e49a0 100644 --- a/tderesources/carddav/plugin.cpp +++ b/tderesources/carddav/plugin.cpp @@ -36,7 +36,7 @@ typedef KRES::PluginFactory CardDavFacto extern "C" { - void *init_kabc_carddav() + void *init_tdeabc_carddav() { TDEGlobal::locale()->insertCatalogue( "tdepimresources" ); TDEGlobal::locale()->insertCatalogue( "kres_caldav" ); diff --git a/tderesources/carddav/tdeabc_carddav.desktop b/tderesources/carddav/tdeabc_carddav.desktop new file mode 100644 index 000000000..585d11b36 --- /dev/null +++ b/tderesources/carddav/tdeabc_carddav.desktop @@ -0,0 +1,52 @@ +[Desktop Entry] +Name=CardDAV Server (e.g. Zimbra Contacts) +Name[af]=CardDAV bediener (bv. Zimbra Contacts) +Name[bg]=Сървър CardDAV (e.g. Zimbra Contacts) +Name[br]=Servijer CardDAV (e.g. Zimbra Contacts) +Name[ca]=Servidor CardDAV (p.ex. Zimbra Contacts) +Name[cs]=CardDAV server (např. Zimbra Contacts) +Name[da]=CardDAV-server (f.eks. Zimbra Contacts) +Name[de]=CardDAV-Server (z. B. Zimbra Contacts) +Name[el]=Εξυπηρετητής CardDAV (π.χ. Zimbra Contacts) +Name[es]=Servidor CardDAV (por ejemplo, Zimbra Contacts) +Name[et]=CardDAV server (nt. Zimbra Contacts) +Name[eu]=CardDAV zerbitzaria (adib. Zimbra Contacts) +Name[fa]=کارساز CardDAV (مثلاً Zimbra Contacts) +Name[fi]=CardDAV-palvelin (esim. Zimbra Contacts) +Name[fr]=CardDAV Serveur (ex. Zimbra Contacts) +Name[fy]=CardDAV-tsjinner (Zimbra Contacts) +Name[ga]=Freastalaí CardDAV (m.sh. Zimbra Contacts) +Name[gl]=Servidor CardDAV (e.g. Zimbra Contacts) +Name[hu]=CardDAV-kiszolgáló (pl. Zimbra Contacts) +Name[is]=CardDAV þjónn (t.d. Zimbra Contacts) +Name[it]=Server CardDAV (per es. Zimbra Contacts) +Name[ja]=CardDAV サーバ (例 Zimbra Contacts) +Name[ka]=სერვერი CardDAV (მაგ., Zimbra Contacts) +Name[kk]=CardDAV сервері (мысалы Zimbra Contacts) +Name[km]=ម៉ាស៊ីន​បម្រើ CardDAV (ឧ. Zimbra Contacts) +Name[lt]=CardDAV serveris (pvz.: Zimbra Contacts) +Name[ms]=Pelayan CardDAV (misalnya Zimbra Contacts) +Name[nb]=CardDAV-tjener (f.eks. Zimbra Contacts) +Name[nds]=CardDAV-Server (t.B. Zimbra Contacts) +Name[ne]=समूह DAV सर्भर (जस्तै: खुला ग्रुपवेयर) +Name[nl]=CardDAV-server (Zimbra Contacts) +Name[nn]=CardDAV-tenar (t.d. Zimbra Contacts) +Name[pl]=Serwer CardDAV (np. Zimbra Contacts) +Name[pt]=Servidor CardDAV (por exemplo Zimbra Contacts) +Name[pt_BR]=Servidor GroupDav (p. ex. Zimbra Contacts) +Name[ru]=Сервер CardDAV (например, Zimbra Contacts) +Name[sk]=CardDAV Server (napr. Zimbra Contacts) +Name[sl]=Strežnik CardDAV (npr. Zimbra Contacts) +Name[sr]=CardDAV сервер (нпр. Zimbra Contacts) +Name[sr@Latn]=CardDAV server (npr. Zimbra Contacts) +Name[sv]=CardDAV-server (t.ex. Zimbra Contacts) +Name[ta]=CardDAV சேவகன் (e.g. Zimbra Contacts) +Name[tr]=CardDAV Sunucusu (ör. Zimbra Contacts) +Name[uk]=Сервер CardDAV (напр., Zimbra Contacts) +Name[zh_CN]=CardDAV 服务器(如 Zimbra Contacts) +Name[zh_TW]=CardDAV 伺服器 (如: Zimbra Contacts) +X-TDE-Library=kabc_carddav +Type=Service +ServiceTypes=KResources/Plugin +X-TDE-ResourceFamily=contact +X-TDE-ResourceType=carddav diff --git a/tderesources/egroupware/kabc_egroupwareprefs.kcfgc b/tderesources/egroupware/kabc_egroupwareprefs.kcfgc deleted file mode 100644 index 10adb19b2..000000000 --- a/tderesources/egroupware/kabc_egroupwareprefs.kcfgc +++ /dev/null @@ -1,11 +0,0 @@ -# Code generation options for tdeconfig_compiler -File=tderesources_kabc_egroupware.kcfg -ClassName=EGroupwarePrefs -NameSpace=KABC -Singleton=false -Mutators=true -Inherits=KResourcePrefs -IncludeFiles=libtdepim/kresourceprefs.h -GlobalEnums=true -#ItemAccessors=true -#SetUserTexts=true diff --git a/tderesources/egroupware/kabc_resourcexmlrpc.cpp b/tderesources/egroupware/kabc_resourcexmlrpc.cpp deleted file mode 100644 index 587ebc84d..000000000 --- a/tderesources/egroupware/kabc_resourcexmlrpc.cpp +++ /dev/null @@ -1,774 +0,0 @@ -/* - This file is part of tdepim. - Copyright (c) 2003 - 2004 Tobias Koenig - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "kabc_egroupwareprefs.h" -#include "kabc_resourcexmlrpc.h" -#include "kabc_resourcexmlrpcconfig.h" - -#include "access.h" -#include "synchronizer.h" -#include "xmlrpciface.h" - -using namespace KABC; - -static const TQString SearchContactsCommand = "addressbook.boaddressbook.search"; -static const TQString AddContactCommand = "addressbook.boaddressbook.write"; -static const TQString DeleteContactCommand = "addressbook.boaddressbook.delete"; -static const TQString LoadCategoriesCommand = "addressbook.boaddressbook.categories"; -static const TQString LoadCustomFieldsCommand = "addressbook.boaddressbook.customfields"; - -static void setRights( KABC::Addressee &addr, int rights ) -{ - addr.insertCustom( "EGWRESOURCE", "RIGHTS", TQString::number( rights ) ); -} - -static int rights( const KABC::Addressee &addr ) -{ - return addr.custom( "EGWRESOURCE", "RIGHTS" ).toInt(); -} - -ResourceXMLRPC::ResourceXMLRPC( const TDEConfig *config ) - : ResourceCached( config ), mServer( 0 ) -{ - init(); - - mPrefs->addGroupPrefix( identifier() ); - - if ( config ) { - mPrefs->readConfig(); - } else { - setResourceName( i18n( "eGroupware Server" ) ); - } - - initEGroupware(); -} - -ResourceXMLRPC::ResourceXMLRPC( const TQString &url, const TQString &domain, - const TQString &user, const TQString &password ) - : ResourceCached( 0 ), mServer( 0 ) -{ - init(); - - mPrefs->addGroupPrefix( identifier() ); - - mPrefs->setUrl( url ); - mPrefs->setDomain( domain ); - mPrefs->setUser( user ); - mPrefs->setPassword( password ); - - initEGroupware(); -} - -void ResourceXMLRPC::init() -{ - setType( "xmlrpc" ); - - mSynchronizer = new Synchronizer; - - mPrefs = new EGroupwarePrefs; -} - -void ResourceXMLRPC::initEGroupware() -{ - KURL url( mPrefs->url() ); - - mAddrTypes.insert( "dom", Address::Dom ); - mAddrTypes.insert( "intl", Address::Intl ); - mAddrTypes.insert( "parcel", Address::Parcel ); - mAddrTypes.insert( "postal", Address::Postal ); -} - -ResourceXMLRPC::~ResourceXMLRPC() -{ - saveCache(); - - delete mServer; - mServer = 0; - - delete mPrefs; - mPrefs = 0; - - delete mSynchronizer; - mSynchronizer = 0; -} - -void ResourceXMLRPC::writeConfig( TDEConfig *config ) -{ - Resource::writeConfig( config ); - - mPrefs->writeConfig(); -} - -Ticket *ResourceXMLRPC::requestSaveTicket() -{ - if ( !addressBook() ) { - kdDebug(5700) << "no addressbook" << endl; - return 0; - } - - return createTicket( this ); -} - -void ResourceXMLRPC::releaseSaveTicket( Ticket *ticket ) -{ - delete ticket; -} - -bool ResourceXMLRPC::doOpen() -{ - if ( mServer ) - delete mServer; - - mServer = new KXMLRPC::Server( KURL(), this ); - mServer->setUrl( KURL( mPrefs->url() ) ); - mServer->setUserAgent( "KDE-AddressBook" ); - - TQMap args; - args.insert( "domain", mPrefs->domain() ); - args.insert( "username", mPrefs->user() ); - args.insert( "password", mPrefs->password() ); - - mServer->call( "system.login", TQVariant( args ), - this, TQT_SLOT( loginFinished( const TQValueList&, const TQVariant& ) ), - this, TQT_SLOT( fault( int, const TQString&, const TQVariant& ) ) ); - - mSynchronizer->start(); - - return true; -} - -void ResourceXMLRPC::doClose() -{ - TQMap args; - args.insert( "sessionid", mSessionID ); - args.insert( "kp3", mKp3 ); - - mServer->call( "system.logout", TQVariant( args ), - this, TQT_SLOT( logoutFinished( const TQValueList&, const TQVariant& ) ), - this, TQT_SLOT( fault( int, const TQString&, const TQVariant& ) ) ); - - mSynchronizer->start(); -} - -bool ResourceXMLRPC::load() -{ - mAddrMap.clear(); - - return true; -} - -bool ResourceXMLRPC::asyncLoad() -{ - if ( !mServer ) - return false; - - mAddrMap.clear(); - - loadCache(); - - TQMap args; - args.insert( "start", "0" ); - args.insert( "query", "" ); - args.insert( "filter", "" ); - args.insert( "sort", "" ); - args.insert( "order", "" ); - args.insert( "include_users", "calendar" ); - - mServer->call( SearchContactsCommand, args, - this, TQT_SLOT( listContactsFinished( const TQValueList&, const TQVariant& ) ), - this, TQT_SLOT( fault( int, const TQString&, const TQVariant& ) ) ); - - mServer->call( LoadCategoriesCommand, TQVariant( false, 0 ), - this, TQT_SLOT( loadCategoriesFinished( const TQValueList&, const TQVariant& ) ), - this, TQT_SLOT( fault( int, const TQString&, const TQVariant& ) ) ); - - mServer->call( LoadCustomFieldsCommand, TQVariant( TQValueList() ), - this, TQT_SLOT( loadCustomFieldsFinished( const TQValueList&, const TQVariant& ) ), - this, TQT_SLOT( fault( int, const TQString&, const TQVariant& ) ) ); - - return true; -} - - -bool ResourceXMLRPC::save( Ticket *ticket ) -{ - return asyncSave( ticket ); -} - -bool ResourceXMLRPC::asyncSave( Ticket* ) -{ - KABC::Addressee::List::ConstIterator it; - - const KABC::Addressee::List addedList = addedAddressees(); - for ( it = addedList.begin(); it != addedList.end(); ++it ) { - addContact( *it ); - } - - const KABC::Addressee::List changedList = changedAddressees(); - for ( it = changedList.begin(); it != changedList.end(); ++it ) { - updateContact( *it ); - } - - const KABC::Addressee::List deletedList = deletedAddressees(); - for ( it = deletedList.begin(); it != deletedList.end(); ++it ) { - deleteContact( *it ); - } - - return true; -} - -void ResourceXMLRPC::addContact( const Addressee& addr ) -{ - TQMap args; - writeContact( addr, args ); - - mServer->call( AddContactCommand, args, - this, TQT_SLOT( addContactFinished( const TQValueList&, const TQVariant& ) ), - this, TQT_SLOT( addContactFault( int, const TQString&, const TQVariant& ) ), - TQVariant( addr.uid() ) ); -} - -void ResourceXMLRPC::updateContact( const Addressee& addr ) -{ - if ( !(rights( addr ) & EGW_ACCESS_DELETE) && (rights( addr ) != -1) ) { - clearChange( addr.uid() ); - return; - } - - TQMap args; - writeContact( addr, args ); - - args.insert( "id", idMapper().remoteId( addr.uid() ) ); - mServer->call( AddContactCommand, args, - this, TQT_SLOT( updateContactFinished( const TQValueList&, const TQVariant& ) ), - this, TQT_SLOT( updateContactFault( int, const TQString&, const TQVariant& ) ), - TQVariant( addr.uid() ) ); -} - -void ResourceXMLRPC::deleteContact( const Addressee& addr ) -{ - if ( !(rights( addr ) & EGW_ACCESS_DELETE) && rights( addr ) != -1 ) { - clearChange( addr.uid() ); - idMapper().removeRemoteId( idMapper().remoteId( addr.uid() ) ); - return; - } - - mServer->call( DeleteContactCommand, idMapper().remoteId( addr.uid() ), - this, TQT_SLOT( deleteContactFinished( const TQValueList&, const TQVariant& ) ), - this, TQT_SLOT( deleteContactFault( int, const TQString&, const TQVariant& ) ), - TQVariant( addr.uid() ) ); -} - -void ResourceXMLRPC::loginFinished( const TQValueList &variant, - const TQVariant& ) -{ - TQMap map = variant[0].toMap(); - - KURL url( mPrefs->url() ); - if ( map[ "GOAWAY" ].toString() == "XOXO" ) { // failed - mSessionID = mKp3 = ""; - addressBook()->error( i18n( "Login failed, please check your username and password." ) ); - } else { - mSessionID = map[ "sessionid" ].toString(); - mKp3 = map[ "kp3" ].toString(); - } - - url.setUser( mSessionID ); - url.setPass( mKp3 ); - mServer->setUrl( url ); - - mSynchronizer->stop(); -} - -void ResourceXMLRPC::logoutFinished( const TQValueList &variant, - const TQVariant& ) -{ - TQMap map = variant[0].toMap(); - - if ( map[ "GOODBYE" ].toString() != "XOXO" ) - addressBook()->error( i18n( "Logout failed, please check your username and password." ) ); - - KURL url( mPrefs->url() ); - mSessionID = mKp3 = ""; - url.setUser( mSessionID ); - url.setPass( mKp3 ); - mServer->setUrl( url ); - - mSynchronizer->stop(); -} - -void ResourceXMLRPC::listContactsFinished( const TQValueList &mapList, - const TQVariant& ) -{ - const TQValueList contactList = mapList[ 0 ].toList(); - TQValueList::ConstIterator contactIt; - - KABC::Addressee::List serverContacts; - for ( contactIt = contactList.begin(); contactIt != contactList.end(); ++contactIt ) { - const TQMap map = (*contactIt).toMap(); - - Addressee addr; - TQString uid; - - readContact( map, addr, uid ); - - if ( !addr.isEmpty() ) { - addr.setResource( this ); - addr.setChanged( false ); - - TQString local = idMapper().localId( uid ); - if ( local.isEmpty() ) { // new entry - idMapper().setRemoteId( addr.uid(), uid ); - } else { - addr.setUid( local ); - } - - mAddrMap.insert( addr.uid(), addr ); - serverContacts.append( addr ); - } - } - - cleanUpCache( serverContacts ); - saveCache(); - - emit loadingFinished( this ); -} - -void ResourceXMLRPC::addContactFinished( const TQValueList &list, - const TQVariant &id ) -{ - clearChange( id.toString() ); - idMapper().setRemoteId( id.toString(), list[ 0 ].toString() ); - - saveCache(); -} - -void ResourceXMLRPC::updateContactFinished( const TQValueList&, - const TQVariant &id ) -{ - clearChange( id.toString() ); - - saveCache(); -} - -void ResourceXMLRPC::deleteContactFinished( const TQValueList&, - const TQVariant &id ) -{ - clearChange( id.toString() ); - idMapper().removeRemoteId( idMapper().remoteId( id.toString() ) ); - - saveCache(); -} - -void ResourceXMLRPC::fault( int error, const TQString &errorMsg, - const TQVariant& ) -{ - TQString msg = i18n( "Server sent error %1: %2" ).arg( error ).arg( errorMsg ); - if ( addressBook() ) - addressBook()->error( msg ); - - mSynchronizer->stop(); -} - -void ResourceXMLRPC::addContactFault( int, const TQString &errorMsg, - const TQVariant &id ) -{ - KABC::Addressee addr = mAddrMap[ id.toString() ]; - - mAddrMap.remove( addr.uid() ); - - TQString msg = i18n( "Unable to add contact %1 to server. (%2)" ); - addressBook()->error( msg.arg( addr.formattedName(), errorMsg ) ); -} - -void ResourceXMLRPC::updateContactFault( int, const TQString &errorMsg, - const TQVariant &id ) -{ - KABC::Addressee addr = mAddrMap[ id.toString() ]; - - TQString msg = i18n( "Unable to update contact %1 on server. (%2)" ); - addressBook()->error( msg.arg( addr.formattedName(), errorMsg ) ); -} - -void ResourceXMLRPC::deleteContactFault( int, const TQString &errorMsg, - const TQVariant &id ) -{ - KABC::Addressee addr; - - const KABC::Addressee::List deletedList = deletedAddressees(); - KABC::Addressee::List::ConstIterator it; - for ( it = deletedList.begin(); it != deletedList.end(); ++it ) { - if ( (*it).uid() == id.toString() ) { - addr = *it; - break; - } - } - - mAddrMap.insert( addr.uid(), addr ); - - TQString msg = i18n( "Unable to delete contact %1 from server. (%2)" ); - addressBook()->error( msg.arg( addr.formattedName(), errorMsg ) ); -} - -TQString ResourceXMLRPC::addrTypesToTypeStr( int typeMask ) -{ - TQStringList types; - TQMap::ConstIterator it; - for ( it = mAddrTypes.begin(); it != mAddrTypes.end(); ++it ) - if ( it.data() & typeMask ) - types.append( it.key() ); - - return types.join( ";" ); -} - -void ResourceXMLRPC::writeContact( const Addressee &addr, TQMap &args ) -{ - args.insert( "access", ( addr.secrecy().type() == Secrecy::Private ? "private" : "public" ) ); - args.insert( "fn", addr.formattedName() ); - args.insert( "n_given", addr.givenName() ); - args.insert( "n_family", addr.familyName() ); - args.insert( "n_middle", addr.additionalName() ); - args.insert( "n_prefix", addr.prefix() ); - args.insert( "n_suffix", addr.suffix() ); -// args.insert( "sound", "sound" ); - args.insert( "bday", addr.birthday() ); - args.insert( "note", addr.note() ); - int hours = addr.timeZone().offset() / 60; - args.insert( "tz", hours ); -// args.insert( "geo", "geo" ); - args.insert( "url", addr.url().url() ); -// args.insert( "pubkey", "pubkey" ); - args.insert( "org_name", addr.organization() ); -// args.insert( "org_unit", "org_unit" ); - args.insert( "title", addr.title() ); - - // CATEGORIES - TQStringList::ConstIterator catIt; - const TQStringList categories = addr.categories(); - - TQMap catMap; - int counter = 0; - for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { - TQMap::ConstIterator it = mCategoryMap.find( *catIt ); - if ( it == mCategoryMap.end() ) // new category - catMap.insert( TQString::number( counter-- ), *catIt ); - else - catMap.insert( TQString::number( it.data() ), *catIt ); - } - args.insert( "cat_id", catMap ); - - Address workAddr = addr.address( Address::Work ); - if ( !workAddr.isEmpty() ) { - args.insert( "adr_one_street", workAddr.street() ); - args.insert( "adr_one_locality", workAddr.locality() ); - args.insert( "adr_one_region", workAddr.region() ); - args.insert( "adr_one_postalcode", workAddr.postalCode() ); - args.insert( "adr_one_countryname", workAddr.country() ); - - args.insert( "adr_one_type", addrTypesToTypeStr( workAddr.type() ) ); - args.insert( "label", workAddr.label() ); - } - - Address homeAddr = addr.address( Address::Home ); - if ( !homeAddr.isEmpty() ) { - args.insert( "adr_two_street", homeAddr.street() ); - args.insert( "adr_two_locality", homeAddr.locality() ); - args.insert( "adr_two_region", homeAddr.region() ); - args.insert( "adr_two_postalcode", homeAddr.postalCode() ); - args.insert( "adr_two_countryname", homeAddr.country() ); - args.insert( "adr_two_type", addrTypesToTypeStr( homeAddr.type() ) ); - } - - PhoneNumber phone = addr.phoneNumber( PhoneNumber::Work ); - if ( !phone.number().isEmpty() ) - args.insert( "tel_work", phone.number() ); - - phone = addr.phoneNumber( PhoneNumber::Home ); - if ( !phone.number().isEmpty() ) - args.insert( "tel_home", phone.number() ); - - phone = addr.phoneNumber( PhoneNumber::Voice ); - if ( !phone.number().isEmpty() ) - args.insert( "tel_voice", phone.number() ); - - phone = addr.phoneNumber( PhoneNumber::Fax ); - if ( !phone.number().isEmpty() ) - args.insert( "tel_fax", phone.number() ); - - phone = addr.phoneNumber( PhoneNumber::Msg ); - if ( !phone.number().isEmpty() ) - args.insert( "tel_msg", phone.number() ); - - phone = addr.phoneNumber( PhoneNumber::Cell ); - if ( !phone.number().isEmpty() ) - args.insert( "tel_cell", phone.number() ); - - phone = addr.phoneNumber( PhoneNumber::Pager ); - if ( !phone.number().isEmpty() ) - args.insert( "tel_pager", phone.number() ); - - phone = addr.phoneNumber( PhoneNumber::Bbs ); - if ( !phone.number().isEmpty() ) - args.insert( "tel_bbs", phone.number() ); - - phone = addr.phoneNumber( PhoneNumber::Modem ); - if ( !phone.number().isEmpty() ) - args.insert( "tel_modem", phone.number() ); - - phone = addr.phoneNumber( PhoneNumber::Car ); - if ( !phone.number().isEmpty() ) - args.insert( "tel_car", phone.number() ); - - phone = addr.phoneNumber( PhoneNumber::Isdn ); - if ( !phone.number().isEmpty() ) - args.insert( "tel_isdn", phone.number() ); - - phone = addr.phoneNumber( PhoneNumber::Video ); - if ( !phone.number().isEmpty() ) - args.insert( "tel_video", phone.number() ); - - phone = addr.phoneNumber( PhoneNumber::Pref ); - if ( !phone.number().isEmpty() ) - args.insert( "tel_prefer", phone.number() ); - - if ( !addr.preferredEmail().isEmpty() ) { - args.insert( "email", addr.preferredEmail() ); - args.insert( "email_type", "INTERNET" ); - } - - if ( addr.emails().count() > 1 ) { - args.insert( "email_home", addr.emails()[ 1 ] ); - args.insert( "email_home_type", "INTERNET" ); - } - - - const TQStringList customFields = addr.customs(); - TQStringList::ConstIterator it; - for ( it = customFields.begin(); it != customFields.end(); ++it ) { - int colon = (*it).find( ":" ); - TQString identifier = (*it).left( colon ); - int dash = identifier.find( "-" ); - TQString app = identifier.left( dash ); - TQString name = identifier.mid( dash + 1 ); - TQString value = (*it).mid( colon + 1 ); - if ( value.isEmpty() ) - continue; - - if ( app == "XMLRPCResource" ) - args.insert( name, value ); - } - - TQString url = KCal::FreeBusyUrlStore::self()->readUrl( addr.preferredEmail() ); - if ( !url.isEmpty() ) - args.insert( "freebusy_url", url ); -} - -void ResourceXMLRPC::readContact( const TQMap &args, Addressee &addr, TQString &uid ) -{ - Address addrOne, addrTwo; - - TQMap::ConstIterator it; - for ( it = args.begin(); it != args.end(); ++it ) { - if ( it.key() == "id" ) { - uid = it.data().toString(); - } else if ( it.key() == "access" ) { - Secrecy secrecy; - if ( it.data().toString() == "private" ) - secrecy.setType( Secrecy::Private ); - else - secrecy.setType( Secrecy::Public ); - - addr.setSecrecy( secrecy ); - } else if ( it.key() == "fn" ) { - addr.setFormattedName( it.data().toString() ); - } else if ( it.key() == "n_given" ) { - addr.setGivenName( it.data().toString() ); - } else if ( it.key() == "n_family" ) { - addr.setFamilyName( it.data().toString() ); - } else if ( it.key() == "n_middle" ) { - addr.setAdditionalName( it.data().toString() ); - } else if ( it.key() == "n_prefix" ) { - addr.setPrefix( it.data().toString() ); - } else if ( it.key() == "n_suffix" ) { - addr.setSuffix( it.data().toString() ); - } else if ( it.key() == "sound" ) { - } else if ( it.key() == "bday" ) { - addr.setBirthday( it.data().toDateTime() ); - } else if ( it.key() == "note" ) { - addr.setNote( it.data().toString() ); - } else if ( it.key() == "tz" ) { - int hour = it.data().toInt(); - TimeZone timeZone( hour * 60 ); - addr.setTimeZone( timeZone ); - } else if ( it.key() == "geo" ) { - } else if ( it.key() == "url" ) { - addr.setUrl( KURL( it.data().toString() ) ); - } else if ( it.key() == "pubkey" ) { - } else if ( it.key() == "org_name" ) { - addr.setOrganization( it.data().toString() ); - } else if ( it.key() == "org_unit" ) { - } else if ( it.key() == "title" ) { - addr.setTitle( it.data().toString() ); - } else if ( it.key() == "adr_one_street" ) { - addrOne.setStreet( it.data().toString() ); - } else if ( it.key() == "adr_one_locality" ) { - addrOne.setLocality( it.data().toString() ); - } else if ( it.key() == "adr_one_region" ) { - addrOne.setRegion( it.data().toString() ); - } else if ( it.key() == "adr_one_postalcode" ) { - addrOne.setPostalCode( it.data().toString() ); - } else if ( it.key() == "adr_one_countryname" ) { - addrOne.setCountry( it.data().toString() ); - } else if ( it.key() == "adr_one_type" ) { - TQStringList types = TQStringList::split( ';', it.data().toString() ); - - int type = Address::Work; - for ( uint i = 0; i < types.count(); ++i ) - type += mAddrTypes[ types[ i ] ]; - - addrOne.setType( type ); - } else if ( it.key() == "label" ) { - addrOne.setLabel( it.data().toString() ); - } else if ( it.key() == "adr_two_street" ) { - addrTwo.setStreet( it.data().toString() ); - } else if ( it.key() == "adr_two_locality" ) { - addrTwo.setLocality( it.data().toString() ); - } else if ( it.key() == "adr_two_region" ) { - addrTwo.setRegion( it.data().toString() ); - } else if ( it.key() == "adr_two_postalcode" ) { - addrTwo.setPostalCode( it.data().toString() ); - } else if ( it.key() == "adr_two_countryname" ) { - addrTwo.setCountry( it.data().toString() ); - } else if ( it.key() == "adr_two_type" ) { - TQStringList types = TQStringList::split( ';', it.data().toString() ); - - int type = Address::Home; - for ( uint i = 0; i < types.count(); ++i ) - type += mAddrTypes[ types[ i ] ]; - - addrTwo.setType( type ); - } else if ( it.key() == "tel_work" ) { - addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Work ) ); - } else if ( it.key() == "tel_home" ) { - addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Home ) ); - } else if ( it.key() == "tel_voice" ) { - addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Voice ) ); - } else if ( it.key() == "tel_fax" ) { - addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Fax ) ); - } else if ( it.key() == "tel_msg" ) { - addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Msg ) ); - } else if ( it.key() == "tel_cell" ) { - addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Cell ) ); - } else if ( it.key() == "tel_pager" ) { - addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Pager ) ); - } else if ( it.key() == "tel_bbs" ) { - addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Bbs ) ); - } else if ( it.key() == "tel_modem" ) { - addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Modem ) ); - } else if ( it.key() == "tel_car" ) { - addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Car ) ); - } else if ( it.key() == "tel_isdn" ) { - addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Isdn ) ); - } else if ( it.key() == "tel_video" ) { - addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Video ) ); - } else if ( it.key() == "tel_prefer" ) { - addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Pref ) ); - } else if ( it.key() == "email" ) { - addr.insertEmail( it.data().toString(), true ); - } else if ( it.key() == "email_type" ) { - } else if ( it.key() == "email_home" ) { - addr.insertEmail( it.data().toString(), false ); - } else if ( it.key() == "email_home_type" ) { - } else if ( it.key() == "cat_id" ) { - const TQMap categories = it.data().toMap(); - TQMap::ConstIterator it; - - for ( it = categories.begin(); it != categories.end(); ++it ) - addr.insertCategory( it.data().toString() ); - } else if ( it.key() == "rights" ) { - setRights( addr, it.data().toInt() ); - } - } - - TQMap::ConstIterator cfIt; - for ( cfIt = mCustomFieldsMap.begin(); cfIt != mCustomFieldsMap.end(); ++cfIt ) { - if ( args[ cfIt.key() ].toString().isEmpty() ) - continue; - - if ( cfIt.key() == "freebusy_url" ) { - KCal::FreeBusyUrlStore::self()->writeUrl( addr.preferredEmail(), - args[ cfIt.key() ].toString() ); - KCal::FreeBusyUrlStore::self()->sync(); - } else - addr.insertCustom( "XMLRPCResource", cfIt.key(), cfIt.data() ); - } - - if ( !addrOne.isEmpty() ) - addr.insertAddress( addrOne ); - if ( !addrTwo.isEmpty() ) - addr.insertAddress( addrTwo ); -} - -void ResourceXMLRPC::loadCategoriesFinished( const TQValueList &mapList, - const TQVariant& ) -{ - mCategoryMap.clear(); - - const TQMap map = mapList[ 0 ].toMap(); - TQMap::ConstIterator it; - - KABPrefs *prefs = KABPrefs::instance(); - for ( it = map.begin(); it != map.end(); ++it ) { - mCategoryMap.insert( it.data().toString(), it.key().toInt() ); - - TQStringList categories = prefs->customCategories(); - if ( categories.find( it.data().toString() ) == categories.end() ) - categories.append( it.data().toString() ); - - prefs->mCustomCategories = categories; - } -} - -void ResourceXMLRPC::loadCustomFieldsFinished( const TQValueList &mapList, - const TQVariant& ) -{ - mCustomFieldsMap.clear(); - - const TQMap map = mapList[ 0 ].toMap(); - TQMap::ConstIterator it; - - for ( it = map.begin(); it != map.end(); ++it ) - mCustomFieldsMap.insert( it.key(), it.data().toString() ); -} - -#include "kabc_resourcexmlrpc.moc" diff --git a/tderesources/egroupware/kabc_resourcexmlrpc.h b/tderesources/egroupware/kabc_resourcexmlrpc.h deleted file mode 100644 index b4b6411a4..000000000 --- a/tderesources/egroupware/kabc_resourcexmlrpc.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - This file is part of tdepim. - Copyright (c) 2003 - 2004 Tobias Koenig - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KABC_RESOURCEXMLRPC_H -#define KABC_RESOURCEXMLRPC_H - -#include -#include - -#include "libtdepim/tdeabcresourcecached.h" - -class TDEConfig; -class Synchronizer; - -namespace KXMLRPC { -class Server; -} - -namespace KABC { - -class EGroupwarePrefs; - -class KDE_EXPORT ResourceXMLRPC : public ResourceCached -{ - Q_OBJECT - - - public: - ResourceXMLRPC( const TDEConfig* ); - ResourceXMLRPC( const TQString &url, const TQString &domain, - const TQString &user, const TQString &password ); - ~ResourceXMLRPC(); - - virtual void writeConfig( TDEConfig* ); - - EGroupwarePrefs *prefs() const { return mPrefs; } - - virtual bool doOpen(); - virtual void doClose(); - - virtual Ticket *requestSaveTicket(); - virtual void releaseSaveTicket( Ticket* ); - - virtual bool load(); - virtual bool asyncLoad(); - virtual bool save( Ticket * ); - virtual bool asyncSave( Ticket * ); - - protected: - void init(); - - protected slots: - void loginFinished( const TQValueList&, const TQVariant& ); - void logoutFinished( const TQValueList&, const TQVariant& ); - - void listContactsFinished( const TQValueList&, const TQVariant& ); - void addContactFinished( const TQValueList&, const TQVariant& ); - void updateContactFinished( const TQValueList&, const TQVariant& ); - void deleteContactFinished( const TQValueList&, const TQVariant& ); - void loadCategoriesFinished( const TQValueList&, const TQVariant& ); - void loadCustomFieldsFinished( const TQValueList&, const TQVariant& ); - - void fault( int, const TQString&, const TQVariant& ); - void addContactFault( int, const TQString&, const TQVariant& ); - void updateContactFault( int, const TQString&, const TQVariant& ); - void deleteContactFault( int, const TQString&, const TQVariant& ); - - void addContact( const KABC::Addressee& ); - void updateContact( const KABC::Addressee& ); - void deleteContact( const KABC::Addressee& ); - - private: - void initEGroupware(); - - TQString addrTypesToTypeStr( int ); - - void writeContact( const Addressee&, TQMap& ); - void readContact( const TQMap&, Addressee &addr, TQString& ); - - EGroupwarePrefs *mPrefs; - - TQString mSessionID; - TQString mKp3; - - TQMap mCategoryMap; - TQMap mAddrTypes; - TQMap mCustomFieldsMap; - - KXMLRPC::Server *mServer; - Synchronizer *mSynchronizer; - - class ResourceXMLRPCPrivate; - ResourceXMLRPCPrivate *d; -}; - -} - -#endif diff --git a/tderesources/egroupware/kabc_resourcexmlrpcconfig.cpp b/tderesources/egroupware/kabc_resourcexmlrpcconfig.cpp deleted file mode 100644 index 03665e75d..000000000 --- a/tderesources/egroupware/kabc_resourcexmlrpcconfig.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - This file is part of tdepim. - Copyright (c) 2002 - 2004 Tobias Koenig - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include -#include - -#include -#include -#include -#include -#include - -#include "kabc_egroupwareprefs.h" -#include "kabc_resourcexmlrpc.h" -#include "kabc_resourcexmlrpcconfig.h" - -using namespace KABC; - -ResourceXMLRPCConfig::ResourceXMLRPCConfig( TQWidget* parent, const char* name ) - : KRES::ConfigWidget( parent, name ) -{ - TQGridLayout *mainLayout = new TQGridLayout( this, 4, 2, 0, KDialog::spacingHint() ); - - TQLabel *label = new TQLabel( i18n( "URL:" ), this ); - mURL = new KURLRequester( this ); - - mainLayout->addWidget( label, 0, 0 ); - mainLayout->addWidget( mURL, 0, 1 ); - - label = new TQLabel( i18n( "Domain:" ), this ); - mDomain = new KLineEdit( this ); - - mainLayout->addWidget( label, 1, 0 ); - mainLayout->addWidget( mDomain, 1, 1 ); - - label = new TQLabel( i18n( "User:" ), this ); - mUser = new KLineEdit( this ); - - mainLayout->addWidget( label, 2, 0 ); - mainLayout->addWidget( mUser, 2, 1 ); - - label = new TQLabel( i18n( "Password:" ), this ); - mPassword = new KLineEdit( this ); - mPassword->setEchoMode( TQLineEdit::Password ); - - mainLayout->addWidget( label, 3, 0 ); - mainLayout->addWidget( mPassword, 3, 1 ); -} - -void ResourceXMLRPCConfig::loadSettings( KRES::Resource *res ) -{ - ResourceXMLRPC *resource = dynamic_cast( res ); - - if ( !resource ) { - kdDebug(5700) << "ResourceXMLRPCConfig::loadSettings(): cast failed" << endl; - return; - } - - mURL->setURL( resource->prefs()->url() ); - mDomain->setText( resource->prefs()->domain() ); - mUser->setText( resource->prefs()->user() ); - mPassword->setText( resource->prefs()->password() ); -} - -void ResourceXMLRPCConfig::saveSettings( KRES::Resource *res ) -{ - ResourceXMLRPC *resource = dynamic_cast( res ); - - if ( !resource ) { - kdDebug(5700) << "ResourceXMLRPCConfig::saveSettings(): cast failed" << endl; - return; - } - - resource->prefs()->setUrl( mURL->url() ); - resource->prefs()->setDomain( mDomain->text() ); - resource->prefs()->setUser( mUser->text() ); - resource->prefs()->setPassword( mPassword->text() ); -} - -#include "kabc_resourcexmlrpcconfig.moc" diff --git a/tderesources/egroupware/kabc_resourcexmlrpcconfig.h b/tderesources/egroupware/kabc_resourcexmlrpcconfig.h deleted file mode 100644 index 0a9dc9f06..000000000 --- a/tderesources/egroupware/kabc_resourcexmlrpcconfig.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - This file is part of tdepim. - Copyright (c) 2002 - 2004 Tobias Koenig - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef RESOURCEXMLRPCCONFIG_H -#define RESOURCEXMLRPCCONFIG_H - -#include -#include - -class KLineEdit; -class KURLRequester; - -namespace KABC { - -class KDE_EXPORT ResourceXMLRPCConfig : public KRES::ConfigWidget -{ - Q_OBJECT - - - public: - ResourceXMLRPCConfig( TQWidget* parent = 0, const char* name = 0 ); - - public slots: - void loadSettings( KRES::Resource* ); - void saveSettings( KRES::Resource* ); - - private: - KURLRequester *mURL; - KLineEdit *mDomain; - KLineEdit *mUser; - KLineEdit *mPassword; -}; - -} - -#endif diff --git a/tderesources/egroupware/kabc_resourcexmlrpcplugin.cpp b/tderesources/egroupware/kabc_resourcexmlrpcplugin.cpp deleted file mode 100644 index c14a8f679..000000000 --- a/tderesources/egroupware/kabc_resourcexmlrpcplugin.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - This file is part of tdepim. - Copyright (c) 2003 - 2004 Tobias Koenig - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kabc_resourcexmlrpc.h" -#include "kabc_resourcexmlrpcconfig.h" - -#include -#include - -using namespace KABC; - -typedef KRES::PluginFactory< ResourceXMLRPC, ResourceXMLRPCConfig > XMLRPCFactory; - -// FIXME: Use K_EXPORT_COMPONENT_FACTORY( kabc_xmlrpc, XMLRPCFactory ); here -// Problem: How to insert the catalogue! -extern "C" -{ - void *init_kabc_xmlrpc() - { - TDEGlobal::locale()->insertCatalogue( "kres_xmlrpc" ); - return new XMLRPCFactory; - } -} diff --git a/tderesources/egroupware/kabc_xmlrpc.desktop b/tderesources/egroupware/kabc_xmlrpc.desktop deleted file mode 100644 index 6eeb94f33..000000000 --- a/tderesources/egroupware/kabc_xmlrpc.desktop +++ /dev/null @@ -1,50 +0,0 @@ -[Desktop Entry] -Name=eGroupware Server (via XML-RPC) -Name[af]=eGroupware Bediener (via XML-RPC) -Name[bg]=Сървър eGroupware (чрез XML-RPC) -Name[br]=Servijer eGroupware (gant XML-RPC) -Name[ca]=Servidor eGroupware (via XML-RPC) -Name[cs]=eGroupware Server (přes XML-RPC) -Name[da]=eGroupware server (via XML-RPC) -Name[el]=Εξυπηρετητής eGroupware (μέσω XML-RPC) -Name[es]=Servidor de eGroupware (por medio de XML-RPC) -Name[et]=eGroupware server (XML-RPC vahendusel) -Name[eu]=eGroupware zerbitzaria (XML-RPC bidez) -Name[fa]=کارساز eGroupware (از طریق XML-RPC) -Name[fi]=eGroupware-palvelin (XML-RPC kautta) -Name[fr]=Serveur eGroupware (via XML-RPC) -Name[fy]=eGroupware-tsjinner (fia XML-RPC) -Name[ga]=Freastalaí eGroupware (via XML-RPC) -Name[gl]=Servidor eGroupware (mediante XML-RPC) -Name[hu]=eGroupware-kiszolgáló (XML-RPC-n keresztül) -Name[is]=eGroupware þjónn (gegnum XML-RPC) -Name[it]=Server eGroupware (via XML-RPC) -Name[ja]=eGroupware サーバ (XML-RPC 経由) -Name[kk]=eGroupware сервері (XML-RPC арқылы) -Name[km]=ម៉ាស៊ីន​បម្រើ eGroupware (តាម​រយៈ XML-RPC) -Name[lt]=eGroupware serveris (per XML-RPC) -Name[ms]=Pelayan eGroupware (melalui XML-RPC) -Name[nb]=eGroupware-tjener (via XML-RPPC) -Name[nds]=eGroupware-Server (över XML-RPC) -Name[ne]=(XML-RPC मार्फत) eGroupware सर्भर -Name[nl]=eGroupware-server (via XML-RPC) -Name[nn]=eGroupware-tenar (via XML-RPC) -Name[pl]=Serwer eGroupware (poprzez XML-RPC) -Name[pt]=Servidor eGroupware (via XML-RPC) -Name[pt_BR]=Servidor eGroupware (via XML-RPC) -Name[ru]=Сервер eGroupware (через XML-RPC) -Name[sk]=eGroupware Server (cez XML-RPC) -Name[sl]=Strežnik eGroupware (preko XML-RPC) -Name[sr]=eGroupware сервер (преко XML-RPC) -Name[sr@Latn]=eGroupware server (preko XML-RPC) -Name[sv]=eGroupware-server (via XML-RPC) -Name[ta]=eGroupware சேவகன் (via XML-RPC) -Name[tr]=eGroupware Sunucusu (XML-RPC ile) -Name[uk]=Сервер eGroupware (через XML-RPC) -Name[zh_CN]=eGroupware 服务器(通过 XML-RPC) -Name[zh_TW]=eGroupware 伺服器(透過 XML-RPC) -X-TDE-Library=kabc_xmlrpc -Type=Service -ServiceTypes=KResources/Plugin -X-TDE-ResourceFamily=contact -X-TDE-ResourceType=xmlrpc diff --git a/tderesources/egroupware/tdeabc_egroupwareprefs.kcfgc b/tderesources/egroupware/tdeabc_egroupwareprefs.kcfgc new file mode 100644 index 000000000..50c0d2394 --- /dev/null +++ b/tderesources/egroupware/tdeabc_egroupwareprefs.kcfgc @@ -0,0 +1,11 @@ +# Code generation options for tdeconfig_compiler +File=tderesources_tdeabc_egroupware.kcfg +ClassName=EGroupwarePrefs +NameSpace=KABC +Singleton=false +Mutators=true +Inherits=KResourcePrefs +IncludeFiles=libtdepim/kresourceprefs.h +GlobalEnums=true +#ItemAccessors=true +#SetUserTexts=true diff --git a/tderesources/egroupware/tdeabc_resourcexmlrpc.cpp b/tderesources/egroupware/tdeabc_resourcexmlrpc.cpp new file mode 100644 index 000000000..587ebc84d --- /dev/null +++ b/tderesources/egroupware/tdeabc_resourcexmlrpc.cpp @@ -0,0 +1,774 @@ +/* + This file is part of tdepim. + Copyright (c) 2003 - 2004 Tobias Koenig + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "kabc_egroupwareprefs.h" +#include "kabc_resourcexmlrpc.h" +#include "kabc_resourcexmlrpcconfig.h" + +#include "access.h" +#include "synchronizer.h" +#include "xmlrpciface.h" + +using namespace KABC; + +static const TQString SearchContactsCommand = "addressbook.boaddressbook.search"; +static const TQString AddContactCommand = "addressbook.boaddressbook.write"; +static const TQString DeleteContactCommand = "addressbook.boaddressbook.delete"; +static const TQString LoadCategoriesCommand = "addressbook.boaddressbook.categories"; +static const TQString LoadCustomFieldsCommand = "addressbook.boaddressbook.customfields"; + +static void setRights( KABC::Addressee &addr, int rights ) +{ + addr.insertCustom( "EGWRESOURCE", "RIGHTS", TQString::number( rights ) ); +} + +static int rights( const KABC::Addressee &addr ) +{ + return addr.custom( "EGWRESOURCE", "RIGHTS" ).toInt(); +} + +ResourceXMLRPC::ResourceXMLRPC( const TDEConfig *config ) + : ResourceCached( config ), mServer( 0 ) +{ + init(); + + mPrefs->addGroupPrefix( identifier() ); + + if ( config ) { + mPrefs->readConfig(); + } else { + setResourceName( i18n( "eGroupware Server" ) ); + } + + initEGroupware(); +} + +ResourceXMLRPC::ResourceXMLRPC( const TQString &url, const TQString &domain, + const TQString &user, const TQString &password ) + : ResourceCached( 0 ), mServer( 0 ) +{ + init(); + + mPrefs->addGroupPrefix( identifier() ); + + mPrefs->setUrl( url ); + mPrefs->setDomain( domain ); + mPrefs->setUser( user ); + mPrefs->setPassword( password ); + + initEGroupware(); +} + +void ResourceXMLRPC::init() +{ + setType( "xmlrpc" ); + + mSynchronizer = new Synchronizer; + + mPrefs = new EGroupwarePrefs; +} + +void ResourceXMLRPC::initEGroupware() +{ + KURL url( mPrefs->url() ); + + mAddrTypes.insert( "dom", Address::Dom ); + mAddrTypes.insert( "intl", Address::Intl ); + mAddrTypes.insert( "parcel", Address::Parcel ); + mAddrTypes.insert( "postal", Address::Postal ); +} + +ResourceXMLRPC::~ResourceXMLRPC() +{ + saveCache(); + + delete mServer; + mServer = 0; + + delete mPrefs; + mPrefs = 0; + + delete mSynchronizer; + mSynchronizer = 0; +} + +void ResourceXMLRPC::writeConfig( TDEConfig *config ) +{ + Resource::writeConfig( config ); + + mPrefs->writeConfig(); +} + +Ticket *ResourceXMLRPC::requestSaveTicket() +{ + if ( !addressBook() ) { + kdDebug(5700) << "no addressbook" << endl; + return 0; + } + + return createTicket( this ); +} + +void ResourceXMLRPC::releaseSaveTicket( Ticket *ticket ) +{ + delete ticket; +} + +bool ResourceXMLRPC::doOpen() +{ + if ( mServer ) + delete mServer; + + mServer = new KXMLRPC::Server( KURL(), this ); + mServer->setUrl( KURL( mPrefs->url() ) ); + mServer->setUserAgent( "KDE-AddressBook" ); + + TQMap args; + args.insert( "domain", mPrefs->domain() ); + args.insert( "username", mPrefs->user() ); + args.insert( "password", mPrefs->password() ); + + mServer->call( "system.login", TQVariant( args ), + this, TQT_SLOT( loginFinished( const TQValueList&, const TQVariant& ) ), + this, TQT_SLOT( fault( int, const TQString&, const TQVariant& ) ) ); + + mSynchronizer->start(); + + return true; +} + +void ResourceXMLRPC::doClose() +{ + TQMap args; + args.insert( "sessionid", mSessionID ); + args.insert( "kp3", mKp3 ); + + mServer->call( "system.logout", TQVariant( args ), + this, TQT_SLOT( logoutFinished( const TQValueList&, const TQVariant& ) ), + this, TQT_SLOT( fault( int, const TQString&, const TQVariant& ) ) ); + + mSynchronizer->start(); +} + +bool ResourceXMLRPC::load() +{ + mAddrMap.clear(); + + return true; +} + +bool ResourceXMLRPC::asyncLoad() +{ + if ( !mServer ) + return false; + + mAddrMap.clear(); + + loadCache(); + + TQMap args; + args.insert( "start", "0" ); + args.insert( "query", "" ); + args.insert( "filter", "" ); + args.insert( "sort", "" ); + args.insert( "order", "" ); + args.insert( "include_users", "calendar" ); + + mServer->call( SearchContactsCommand, args, + this, TQT_SLOT( listContactsFinished( const TQValueList&, const TQVariant& ) ), + this, TQT_SLOT( fault( int, const TQString&, const TQVariant& ) ) ); + + mServer->call( LoadCategoriesCommand, TQVariant( false, 0 ), + this, TQT_SLOT( loadCategoriesFinished( const TQValueList&, const TQVariant& ) ), + this, TQT_SLOT( fault( int, const TQString&, const TQVariant& ) ) ); + + mServer->call( LoadCustomFieldsCommand, TQVariant( TQValueList() ), + this, TQT_SLOT( loadCustomFieldsFinished( const TQValueList&, const TQVariant& ) ), + this, TQT_SLOT( fault( int, const TQString&, const TQVariant& ) ) ); + + return true; +} + + +bool ResourceXMLRPC::save( Ticket *ticket ) +{ + return asyncSave( ticket ); +} + +bool ResourceXMLRPC::asyncSave( Ticket* ) +{ + KABC::Addressee::List::ConstIterator it; + + const KABC::Addressee::List addedList = addedAddressees(); + for ( it = addedList.begin(); it != addedList.end(); ++it ) { + addContact( *it ); + } + + const KABC::Addressee::List changedList = changedAddressees(); + for ( it = changedList.begin(); it != changedList.end(); ++it ) { + updateContact( *it ); + } + + const KABC::Addressee::List deletedList = deletedAddressees(); + for ( it = deletedList.begin(); it != deletedList.end(); ++it ) { + deleteContact( *it ); + } + + return true; +} + +void ResourceXMLRPC::addContact( const Addressee& addr ) +{ + TQMap args; + writeContact( addr, args ); + + mServer->call( AddContactCommand, args, + this, TQT_SLOT( addContactFinished( const TQValueList&, const TQVariant& ) ), + this, TQT_SLOT( addContactFault( int, const TQString&, const TQVariant& ) ), + TQVariant( addr.uid() ) ); +} + +void ResourceXMLRPC::updateContact( const Addressee& addr ) +{ + if ( !(rights( addr ) & EGW_ACCESS_DELETE) && (rights( addr ) != -1) ) { + clearChange( addr.uid() ); + return; + } + + TQMap args; + writeContact( addr, args ); + + args.insert( "id", idMapper().remoteId( addr.uid() ) ); + mServer->call( AddContactCommand, args, + this, TQT_SLOT( updateContactFinished( const TQValueList&, const TQVariant& ) ), + this, TQT_SLOT( updateContactFault( int, const TQString&, const TQVariant& ) ), + TQVariant( addr.uid() ) ); +} + +void ResourceXMLRPC::deleteContact( const Addressee& addr ) +{ + if ( !(rights( addr ) & EGW_ACCESS_DELETE) && rights( addr ) != -1 ) { + clearChange( addr.uid() ); + idMapper().removeRemoteId( idMapper().remoteId( addr.uid() ) ); + return; + } + + mServer->call( DeleteContactCommand, idMapper().remoteId( addr.uid() ), + this, TQT_SLOT( deleteContactFinished( const TQValueList&, const TQVariant& ) ), + this, TQT_SLOT( deleteContactFault( int, const TQString&, const TQVariant& ) ), + TQVariant( addr.uid() ) ); +} + +void ResourceXMLRPC::loginFinished( const TQValueList &variant, + const TQVariant& ) +{ + TQMap map = variant[0].toMap(); + + KURL url( mPrefs->url() ); + if ( map[ "GOAWAY" ].toString() == "XOXO" ) { // failed + mSessionID = mKp3 = ""; + addressBook()->error( i18n( "Login failed, please check your username and password." ) ); + } else { + mSessionID = map[ "sessionid" ].toString(); + mKp3 = map[ "kp3" ].toString(); + } + + url.setUser( mSessionID ); + url.setPass( mKp3 ); + mServer->setUrl( url ); + + mSynchronizer->stop(); +} + +void ResourceXMLRPC::logoutFinished( const TQValueList &variant, + const TQVariant& ) +{ + TQMap map = variant[0].toMap(); + + if ( map[ "GOODBYE" ].toString() != "XOXO" ) + addressBook()->error( i18n( "Logout failed, please check your username and password." ) ); + + KURL url( mPrefs->url() ); + mSessionID = mKp3 = ""; + url.setUser( mSessionID ); + url.setPass( mKp3 ); + mServer->setUrl( url ); + + mSynchronizer->stop(); +} + +void ResourceXMLRPC::listContactsFinished( const TQValueList &mapList, + const TQVariant& ) +{ + const TQValueList contactList = mapList[ 0 ].toList(); + TQValueList::ConstIterator contactIt; + + KABC::Addressee::List serverContacts; + for ( contactIt = contactList.begin(); contactIt != contactList.end(); ++contactIt ) { + const TQMap map = (*contactIt).toMap(); + + Addressee addr; + TQString uid; + + readContact( map, addr, uid ); + + if ( !addr.isEmpty() ) { + addr.setResource( this ); + addr.setChanged( false ); + + TQString local = idMapper().localId( uid ); + if ( local.isEmpty() ) { // new entry + idMapper().setRemoteId( addr.uid(), uid ); + } else { + addr.setUid( local ); + } + + mAddrMap.insert( addr.uid(), addr ); + serverContacts.append( addr ); + } + } + + cleanUpCache( serverContacts ); + saveCache(); + + emit loadingFinished( this ); +} + +void ResourceXMLRPC::addContactFinished( const TQValueList &list, + const TQVariant &id ) +{ + clearChange( id.toString() ); + idMapper().setRemoteId( id.toString(), list[ 0 ].toString() ); + + saveCache(); +} + +void ResourceXMLRPC::updateContactFinished( const TQValueList&, + const TQVariant &id ) +{ + clearChange( id.toString() ); + + saveCache(); +} + +void ResourceXMLRPC::deleteContactFinished( const TQValueList&, + const TQVariant &id ) +{ + clearChange( id.toString() ); + idMapper().removeRemoteId( idMapper().remoteId( id.toString() ) ); + + saveCache(); +} + +void ResourceXMLRPC::fault( int error, const TQString &errorMsg, + const TQVariant& ) +{ + TQString msg = i18n( "Server sent error %1: %2" ).arg( error ).arg( errorMsg ); + if ( addressBook() ) + addressBook()->error( msg ); + + mSynchronizer->stop(); +} + +void ResourceXMLRPC::addContactFault( int, const TQString &errorMsg, + const TQVariant &id ) +{ + KABC::Addressee addr = mAddrMap[ id.toString() ]; + + mAddrMap.remove( addr.uid() ); + + TQString msg = i18n( "Unable to add contact %1 to server. (%2)" ); + addressBook()->error( msg.arg( addr.formattedName(), errorMsg ) ); +} + +void ResourceXMLRPC::updateContactFault( int, const TQString &errorMsg, + const TQVariant &id ) +{ + KABC::Addressee addr = mAddrMap[ id.toString() ]; + + TQString msg = i18n( "Unable to update contact %1 on server. (%2)" ); + addressBook()->error( msg.arg( addr.formattedName(), errorMsg ) ); +} + +void ResourceXMLRPC::deleteContactFault( int, const TQString &errorMsg, + const TQVariant &id ) +{ + KABC::Addressee addr; + + const KABC::Addressee::List deletedList = deletedAddressees(); + KABC::Addressee::List::ConstIterator it; + for ( it = deletedList.begin(); it != deletedList.end(); ++it ) { + if ( (*it).uid() == id.toString() ) { + addr = *it; + break; + } + } + + mAddrMap.insert( addr.uid(), addr ); + + TQString msg = i18n( "Unable to delete contact %1 from server. (%2)" ); + addressBook()->error( msg.arg( addr.formattedName(), errorMsg ) ); +} + +TQString ResourceXMLRPC::addrTypesToTypeStr( int typeMask ) +{ + TQStringList types; + TQMap::ConstIterator it; + for ( it = mAddrTypes.begin(); it != mAddrTypes.end(); ++it ) + if ( it.data() & typeMask ) + types.append( it.key() ); + + return types.join( ";" ); +} + +void ResourceXMLRPC::writeContact( const Addressee &addr, TQMap &args ) +{ + args.insert( "access", ( addr.secrecy().type() == Secrecy::Private ? "private" : "public" ) ); + args.insert( "fn", addr.formattedName() ); + args.insert( "n_given", addr.givenName() ); + args.insert( "n_family", addr.familyName() ); + args.insert( "n_middle", addr.additionalName() ); + args.insert( "n_prefix", addr.prefix() ); + args.insert( "n_suffix", addr.suffix() ); +// args.insert( "sound", "sound" ); + args.insert( "bday", addr.birthday() ); + args.insert( "note", addr.note() ); + int hours = addr.timeZone().offset() / 60; + args.insert( "tz", hours ); +// args.insert( "geo", "geo" ); + args.insert( "url", addr.url().url() ); +// args.insert( "pubkey", "pubkey" ); + args.insert( "org_name", addr.organization() ); +// args.insert( "org_unit", "org_unit" ); + args.insert( "title", addr.title() ); + + // CATEGORIES + TQStringList::ConstIterator catIt; + const TQStringList categories = addr.categories(); + + TQMap catMap; + int counter = 0; + for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { + TQMap::ConstIterator it = mCategoryMap.find( *catIt ); + if ( it == mCategoryMap.end() ) // new category + catMap.insert( TQString::number( counter-- ), *catIt ); + else + catMap.insert( TQString::number( it.data() ), *catIt ); + } + args.insert( "cat_id", catMap ); + + Address workAddr = addr.address( Address::Work ); + if ( !workAddr.isEmpty() ) { + args.insert( "adr_one_street", workAddr.street() ); + args.insert( "adr_one_locality", workAddr.locality() ); + args.insert( "adr_one_region", workAddr.region() ); + args.insert( "adr_one_postalcode", workAddr.postalCode() ); + args.insert( "adr_one_countryname", workAddr.country() ); + + args.insert( "adr_one_type", addrTypesToTypeStr( workAddr.type() ) ); + args.insert( "label", workAddr.label() ); + } + + Address homeAddr = addr.address( Address::Home ); + if ( !homeAddr.isEmpty() ) { + args.insert( "adr_two_street", homeAddr.street() ); + args.insert( "adr_two_locality", homeAddr.locality() ); + args.insert( "adr_two_region", homeAddr.region() ); + args.insert( "adr_two_postalcode", homeAddr.postalCode() ); + args.insert( "adr_two_countryname", homeAddr.country() ); + args.insert( "adr_two_type", addrTypesToTypeStr( homeAddr.type() ) ); + } + + PhoneNumber phone = addr.phoneNumber( PhoneNumber::Work ); + if ( !phone.number().isEmpty() ) + args.insert( "tel_work", phone.number() ); + + phone = addr.phoneNumber( PhoneNumber::Home ); + if ( !phone.number().isEmpty() ) + args.insert( "tel_home", phone.number() ); + + phone = addr.phoneNumber( PhoneNumber::Voice ); + if ( !phone.number().isEmpty() ) + args.insert( "tel_voice", phone.number() ); + + phone = addr.phoneNumber( PhoneNumber::Fax ); + if ( !phone.number().isEmpty() ) + args.insert( "tel_fax", phone.number() ); + + phone = addr.phoneNumber( PhoneNumber::Msg ); + if ( !phone.number().isEmpty() ) + args.insert( "tel_msg", phone.number() ); + + phone = addr.phoneNumber( PhoneNumber::Cell ); + if ( !phone.number().isEmpty() ) + args.insert( "tel_cell", phone.number() ); + + phone = addr.phoneNumber( PhoneNumber::Pager ); + if ( !phone.number().isEmpty() ) + args.insert( "tel_pager", phone.number() ); + + phone = addr.phoneNumber( PhoneNumber::Bbs ); + if ( !phone.number().isEmpty() ) + args.insert( "tel_bbs", phone.number() ); + + phone = addr.phoneNumber( PhoneNumber::Modem ); + if ( !phone.number().isEmpty() ) + args.insert( "tel_modem", phone.number() ); + + phone = addr.phoneNumber( PhoneNumber::Car ); + if ( !phone.number().isEmpty() ) + args.insert( "tel_car", phone.number() ); + + phone = addr.phoneNumber( PhoneNumber::Isdn ); + if ( !phone.number().isEmpty() ) + args.insert( "tel_isdn", phone.number() ); + + phone = addr.phoneNumber( PhoneNumber::Video ); + if ( !phone.number().isEmpty() ) + args.insert( "tel_video", phone.number() ); + + phone = addr.phoneNumber( PhoneNumber::Pref ); + if ( !phone.number().isEmpty() ) + args.insert( "tel_prefer", phone.number() ); + + if ( !addr.preferredEmail().isEmpty() ) { + args.insert( "email", addr.preferredEmail() ); + args.insert( "email_type", "INTERNET" ); + } + + if ( addr.emails().count() > 1 ) { + args.insert( "email_home", addr.emails()[ 1 ] ); + args.insert( "email_home_type", "INTERNET" ); + } + + + const TQStringList customFields = addr.customs(); + TQStringList::ConstIterator it; + for ( it = customFields.begin(); it != customFields.end(); ++it ) { + int colon = (*it).find( ":" ); + TQString identifier = (*it).left( colon ); + int dash = identifier.find( "-" ); + TQString app = identifier.left( dash ); + TQString name = identifier.mid( dash + 1 ); + TQString value = (*it).mid( colon + 1 ); + if ( value.isEmpty() ) + continue; + + if ( app == "XMLRPCResource" ) + args.insert( name, value ); + } + + TQString url = KCal::FreeBusyUrlStore::self()->readUrl( addr.preferredEmail() ); + if ( !url.isEmpty() ) + args.insert( "freebusy_url", url ); +} + +void ResourceXMLRPC::readContact( const TQMap &args, Addressee &addr, TQString &uid ) +{ + Address addrOne, addrTwo; + + TQMap::ConstIterator it; + for ( it = args.begin(); it != args.end(); ++it ) { + if ( it.key() == "id" ) { + uid = it.data().toString(); + } else if ( it.key() == "access" ) { + Secrecy secrecy; + if ( it.data().toString() == "private" ) + secrecy.setType( Secrecy::Private ); + else + secrecy.setType( Secrecy::Public ); + + addr.setSecrecy( secrecy ); + } else if ( it.key() == "fn" ) { + addr.setFormattedName( it.data().toString() ); + } else if ( it.key() == "n_given" ) { + addr.setGivenName( it.data().toString() ); + } else if ( it.key() == "n_family" ) { + addr.setFamilyName( it.data().toString() ); + } else if ( it.key() == "n_middle" ) { + addr.setAdditionalName( it.data().toString() ); + } else if ( it.key() == "n_prefix" ) { + addr.setPrefix( it.data().toString() ); + } else if ( it.key() == "n_suffix" ) { + addr.setSuffix( it.data().toString() ); + } else if ( it.key() == "sound" ) { + } else if ( it.key() == "bday" ) { + addr.setBirthday( it.data().toDateTime() ); + } else if ( it.key() == "note" ) { + addr.setNote( it.data().toString() ); + } else if ( it.key() == "tz" ) { + int hour = it.data().toInt(); + TimeZone timeZone( hour * 60 ); + addr.setTimeZone( timeZone ); + } else if ( it.key() == "geo" ) { + } else if ( it.key() == "url" ) { + addr.setUrl( KURL( it.data().toString() ) ); + } else if ( it.key() == "pubkey" ) { + } else if ( it.key() == "org_name" ) { + addr.setOrganization( it.data().toString() ); + } else if ( it.key() == "org_unit" ) { + } else if ( it.key() == "title" ) { + addr.setTitle( it.data().toString() ); + } else if ( it.key() == "adr_one_street" ) { + addrOne.setStreet( it.data().toString() ); + } else if ( it.key() == "adr_one_locality" ) { + addrOne.setLocality( it.data().toString() ); + } else if ( it.key() == "adr_one_region" ) { + addrOne.setRegion( it.data().toString() ); + } else if ( it.key() == "adr_one_postalcode" ) { + addrOne.setPostalCode( it.data().toString() ); + } else if ( it.key() == "adr_one_countryname" ) { + addrOne.setCountry( it.data().toString() ); + } else if ( it.key() == "adr_one_type" ) { + TQStringList types = TQStringList::split( ';', it.data().toString() ); + + int type = Address::Work; + for ( uint i = 0; i < types.count(); ++i ) + type += mAddrTypes[ types[ i ] ]; + + addrOne.setType( type ); + } else if ( it.key() == "label" ) { + addrOne.setLabel( it.data().toString() ); + } else if ( it.key() == "adr_two_street" ) { + addrTwo.setStreet( it.data().toString() ); + } else if ( it.key() == "adr_two_locality" ) { + addrTwo.setLocality( it.data().toString() ); + } else if ( it.key() == "adr_two_region" ) { + addrTwo.setRegion( it.data().toString() ); + } else if ( it.key() == "adr_two_postalcode" ) { + addrTwo.setPostalCode( it.data().toString() ); + } else if ( it.key() == "adr_two_countryname" ) { + addrTwo.setCountry( it.data().toString() ); + } else if ( it.key() == "adr_two_type" ) { + TQStringList types = TQStringList::split( ';', it.data().toString() ); + + int type = Address::Home; + for ( uint i = 0; i < types.count(); ++i ) + type += mAddrTypes[ types[ i ] ]; + + addrTwo.setType( type ); + } else if ( it.key() == "tel_work" ) { + addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Work ) ); + } else if ( it.key() == "tel_home" ) { + addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Home ) ); + } else if ( it.key() == "tel_voice" ) { + addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Voice ) ); + } else if ( it.key() == "tel_fax" ) { + addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Fax ) ); + } else if ( it.key() == "tel_msg" ) { + addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Msg ) ); + } else if ( it.key() == "tel_cell" ) { + addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Cell ) ); + } else if ( it.key() == "tel_pager" ) { + addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Pager ) ); + } else if ( it.key() == "tel_bbs" ) { + addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Bbs ) ); + } else if ( it.key() == "tel_modem" ) { + addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Modem ) ); + } else if ( it.key() == "tel_car" ) { + addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Car ) ); + } else if ( it.key() == "tel_isdn" ) { + addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Isdn ) ); + } else if ( it.key() == "tel_video" ) { + addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Video ) ); + } else if ( it.key() == "tel_prefer" ) { + addr.insertPhoneNumber( PhoneNumber( it.data().toString(), PhoneNumber::Pref ) ); + } else if ( it.key() == "email" ) { + addr.insertEmail( it.data().toString(), true ); + } else if ( it.key() == "email_type" ) { + } else if ( it.key() == "email_home" ) { + addr.insertEmail( it.data().toString(), false ); + } else if ( it.key() == "email_home_type" ) { + } else if ( it.key() == "cat_id" ) { + const TQMap categories = it.data().toMap(); + TQMap::ConstIterator it; + + for ( it = categories.begin(); it != categories.end(); ++it ) + addr.insertCategory( it.data().toString() ); + } else if ( it.key() == "rights" ) { + setRights( addr, it.data().toInt() ); + } + } + + TQMap::ConstIterator cfIt; + for ( cfIt = mCustomFieldsMap.begin(); cfIt != mCustomFieldsMap.end(); ++cfIt ) { + if ( args[ cfIt.key() ].toString().isEmpty() ) + continue; + + if ( cfIt.key() == "freebusy_url" ) { + KCal::FreeBusyUrlStore::self()->writeUrl( addr.preferredEmail(), + args[ cfIt.key() ].toString() ); + KCal::FreeBusyUrlStore::self()->sync(); + } else + addr.insertCustom( "XMLRPCResource", cfIt.key(), cfIt.data() ); + } + + if ( !addrOne.isEmpty() ) + addr.insertAddress( addrOne ); + if ( !addrTwo.isEmpty() ) + addr.insertAddress( addrTwo ); +} + +void ResourceXMLRPC::loadCategoriesFinished( const TQValueList &mapList, + const TQVariant& ) +{ + mCategoryMap.clear(); + + const TQMap map = mapList[ 0 ].toMap(); + TQMap::ConstIterator it; + + KABPrefs *prefs = KABPrefs::instance(); + for ( it = map.begin(); it != map.end(); ++it ) { + mCategoryMap.insert( it.data().toString(), it.key().toInt() ); + + TQStringList categories = prefs->customCategories(); + if ( categories.find( it.data().toString() ) == categories.end() ) + categories.append( it.data().toString() ); + + prefs->mCustomCategories = categories; + } +} + +void ResourceXMLRPC::loadCustomFieldsFinished( const TQValueList &mapList, + const TQVariant& ) +{ + mCustomFieldsMap.clear(); + + const TQMap map = mapList[ 0 ].toMap(); + TQMap::ConstIterator it; + + for ( it = map.begin(); it != map.end(); ++it ) + mCustomFieldsMap.insert( it.key(), it.data().toString() ); +} + +#include "kabc_resourcexmlrpc.moc" diff --git a/tderesources/egroupware/tdeabc_resourcexmlrpc.h b/tderesources/egroupware/tdeabc_resourcexmlrpc.h new file mode 100644 index 000000000..b4b6411a4 --- /dev/null +++ b/tderesources/egroupware/tdeabc_resourcexmlrpc.h @@ -0,0 +1,115 @@ +/* + This file is part of tdepim. + Copyright (c) 2003 - 2004 Tobias Koenig + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KABC_RESOURCEXMLRPC_H +#define KABC_RESOURCEXMLRPC_H + +#include +#include + +#include "libtdepim/tdeabcresourcecached.h" + +class TDEConfig; +class Synchronizer; + +namespace KXMLRPC { +class Server; +} + +namespace KABC { + +class EGroupwarePrefs; + +class KDE_EXPORT ResourceXMLRPC : public ResourceCached +{ + Q_OBJECT + + + public: + ResourceXMLRPC( const TDEConfig* ); + ResourceXMLRPC( const TQString &url, const TQString &domain, + const TQString &user, const TQString &password ); + ~ResourceXMLRPC(); + + virtual void writeConfig( TDEConfig* ); + + EGroupwarePrefs *prefs() const { return mPrefs; } + + virtual bool doOpen(); + virtual void doClose(); + + virtual Ticket *requestSaveTicket(); + virtual void releaseSaveTicket( Ticket* ); + + virtual bool load(); + virtual bool asyncLoad(); + virtual bool save( Ticket * ); + virtual bool asyncSave( Ticket * ); + + protected: + void init(); + + protected slots: + void loginFinished( const TQValueList&, const TQVariant& ); + void logoutFinished( const TQValueList&, const TQVariant& ); + + void listContactsFinished( const TQValueList&, const TQVariant& ); + void addContactFinished( const TQValueList&, const TQVariant& ); + void updateContactFinished( const TQValueList&, const TQVariant& ); + void deleteContactFinished( const TQValueList&, const TQVariant& ); + void loadCategoriesFinished( const TQValueList&, const TQVariant& ); + void loadCustomFieldsFinished( const TQValueList&, const TQVariant& ); + + void fault( int, const TQString&, const TQVariant& ); + void addContactFault( int, const TQString&, const TQVariant& ); + void updateContactFault( int, const TQString&, const TQVariant& ); + void deleteContactFault( int, const TQString&, const TQVariant& ); + + void addContact( const KABC::Addressee& ); + void updateContact( const KABC::Addressee& ); + void deleteContact( const KABC::Addressee& ); + + private: + void initEGroupware(); + + TQString addrTypesToTypeStr( int ); + + void writeContact( const Addressee&, TQMap& ); + void readContact( const TQMap&, Addressee &addr, TQString& ); + + EGroupwarePrefs *mPrefs; + + TQString mSessionID; + TQString mKp3; + + TQMap mCategoryMap; + TQMap mAddrTypes; + TQMap mCustomFieldsMap; + + KXMLRPC::Server *mServer; + Synchronizer *mSynchronizer; + + class ResourceXMLRPCPrivate; + ResourceXMLRPCPrivate *d; +}; + +} + +#endif diff --git a/tderesources/egroupware/tdeabc_resourcexmlrpcconfig.cpp b/tderesources/egroupware/tdeabc_resourcexmlrpcconfig.cpp new file mode 100644 index 000000000..03665e75d --- /dev/null +++ b/tderesources/egroupware/tdeabc_resourcexmlrpcconfig.cpp @@ -0,0 +1,97 @@ +/* + This file is part of tdepim. + Copyright (c) 2002 - 2004 Tobias Koenig + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include + +#include +#include +#include +#include +#include + +#include "kabc_egroupwareprefs.h" +#include "kabc_resourcexmlrpc.h" +#include "kabc_resourcexmlrpcconfig.h" + +using namespace KABC; + +ResourceXMLRPCConfig::ResourceXMLRPCConfig( TQWidget* parent, const char* name ) + : KRES::ConfigWidget( parent, name ) +{ + TQGridLayout *mainLayout = new TQGridLayout( this, 4, 2, 0, KDialog::spacingHint() ); + + TQLabel *label = new TQLabel( i18n( "URL:" ), this ); + mURL = new KURLRequester( this ); + + mainLayout->addWidget( label, 0, 0 ); + mainLayout->addWidget( mURL, 0, 1 ); + + label = new TQLabel( i18n( "Domain:" ), this ); + mDomain = new KLineEdit( this ); + + mainLayout->addWidget( label, 1, 0 ); + mainLayout->addWidget( mDomain, 1, 1 ); + + label = new TQLabel( i18n( "User:" ), this ); + mUser = new KLineEdit( this ); + + mainLayout->addWidget( label, 2, 0 ); + mainLayout->addWidget( mUser, 2, 1 ); + + label = new TQLabel( i18n( "Password:" ), this ); + mPassword = new KLineEdit( this ); + mPassword->setEchoMode( TQLineEdit::Password ); + + mainLayout->addWidget( label, 3, 0 ); + mainLayout->addWidget( mPassword, 3, 1 ); +} + +void ResourceXMLRPCConfig::loadSettings( KRES::Resource *res ) +{ + ResourceXMLRPC *resource = dynamic_cast( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceXMLRPCConfig::loadSettings(): cast failed" << endl; + return; + } + + mURL->setURL( resource->prefs()->url() ); + mDomain->setText( resource->prefs()->domain() ); + mUser->setText( resource->prefs()->user() ); + mPassword->setText( resource->prefs()->password() ); +} + +void ResourceXMLRPCConfig::saveSettings( KRES::Resource *res ) +{ + ResourceXMLRPC *resource = dynamic_cast( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceXMLRPCConfig::saveSettings(): cast failed" << endl; + return; + } + + resource->prefs()->setUrl( mURL->url() ); + resource->prefs()->setDomain( mDomain->text() ); + resource->prefs()->setUser( mUser->text() ); + resource->prefs()->setPassword( mPassword->text() ); +} + +#include "kabc_resourcexmlrpcconfig.moc" diff --git a/tderesources/egroupware/tdeabc_resourcexmlrpcconfig.h b/tderesources/egroupware/tdeabc_resourcexmlrpcconfig.h new file mode 100644 index 000000000..0a9dc9f06 --- /dev/null +++ b/tderesources/egroupware/tdeabc_resourcexmlrpcconfig.h @@ -0,0 +1,53 @@ +/* + This file is part of tdepim. + Copyright (c) 2002 - 2004 Tobias Koenig + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef RESOURCEXMLRPCCONFIG_H +#define RESOURCEXMLRPCCONFIG_H + +#include +#include + +class KLineEdit; +class KURLRequester; + +namespace KABC { + +class KDE_EXPORT ResourceXMLRPCConfig : public KRES::ConfigWidget +{ + Q_OBJECT + + + public: + ResourceXMLRPCConfig( TQWidget* parent = 0, const char* name = 0 ); + + public slots: + void loadSettings( KRES::Resource* ); + void saveSettings( KRES::Resource* ); + + private: + KURLRequester *mURL; + KLineEdit *mDomain; + KLineEdit *mUser; + KLineEdit *mPassword; +}; + +} + +#endif diff --git a/tderesources/egroupware/tdeabc_resourcexmlrpcplugin.cpp b/tderesources/egroupware/tdeabc_resourcexmlrpcplugin.cpp new file mode 100644 index 000000000..e1f25bdcb --- /dev/null +++ b/tderesources/egroupware/tdeabc_resourcexmlrpcplugin.cpp @@ -0,0 +1,40 @@ +/* + This file is part of tdepim. + Copyright (c) 2003 - 2004 Tobias Koenig + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "kabc_resourcexmlrpc.h" +#include "kabc_resourcexmlrpcconfig.h" + +#include +#include + +using namespace KABC; + +typedef KRES::PluginFactory< ResourceXMLRPC, ResourceXMLRPCConfig > XMLRPCFactory; + +// FIXME: Use K_EXPORT_COMPONENT_FACTORY( kabc_xmlrpc, XMLRPCFactory ); here +// Problem: How to insert the catalogue! +extern "C" +{ + void *init_tdeabc_xmlrpc() + { + TDEGlobal::locale()->insertCatalogue( "kres_xmlrpc" ); + return new XMLRPCFactory; + } +} diff --git a/tderesources/egroupware/tdeabc_xmlrpc.desktop b/tderesources/egroupware/tdeabc_xmlrpc.desktop new file mode 100644 index 000000000..6eeb94f33 --- /dev/null +++ b/tderesources/egroupware/tdeabc_xmlrpc.desktop @@ -0,0 +1,50 @@ +[Desktop Entry] +Name=eGroupware Server (via XML-RPC) +Name[af]=eGroupware Bediener (via XML-RPC) +Name[bg]=Сървър eGroupware (чрез XML-RPC) +Name[br]=Servijer eGroupware (gant XML-RPC) +Name[ca]=Servidor eGroupware (via XML-RPC) +Name[cs]=eGroupware Server (přes XML-RPC) +Name[da]=eGroupware server (via XML-RPC) +Name[el]=Εξυπηρετητής eGroupware (μέσω XML-RPC) +Name[es]=Servidor de eGroupware (por medio de XML-RPC) +Name[et]=eGroupware server (XML-RPC vahendusel) +Name[eu]=eGroupware zerbitzaria (XML-RPC bidez) +Name[fa]=کارساز eGroupware (از طریق XML-RPC) +Name[fi]=eGroupware-palvelin (XML-RPC kautta) +Name[fr]=Serveur eGroupware (via XML-RPC) +Name[fy]=eGroupware-tsjinner (fia XML-RPC) +Name[ga]=Freastalaí eGroupware (via XML-RPC) +Name[gl]=Servidor eGroupware (mediante XML-RPC) +Name[hu]=eGroupware-kiszolgáló (XML-RPC-n keresztül) +Name[is]=eGroupware þjónn (gegnum XML-RPC) +Name[it]=Server eGroupware (via XML-RPC) +Name[ja]=eGroupware サーバ (XML-RPC 経由) +Name[kk]=eGroupware сервері (XML-RPC арқылы) +Name[km]=ម៉ាស៊ីន​បម្រើ eGroupware (តាម​រយៈ XML-RPC) +Name[lt]=eGroupware serveris (per XML-RPC) +Name[ms]=Pelayan eGroupware (melalui XML-RPC) +Name[nb]=eGroupware-tjener (via XML-RPPC) +Name[nds]=eGroupware-Server (över XML-RPC) +Name[ne]=(XML-RPC मार्फत) eGroupware सर्भर +Name[nl]=eGroupware-server (via XML-RPC) +Name[nn]=eGroupware-tenar (via XML-RPC) +Name[pl]=Serwer eGroupware (poprzez XML-RPC) +Name[pt]=Servidor eGroupware (via XML-RPC) +Name[pt_BR]=Servidor eGroupware (via XML-RPC) +Name[ru]=Сервер eGroupware (через XML-RPC) +Name[sk]=eGroupware Server (cez XML-RPC) +Name[sl]=Strežnik eGroupware (preko XML-RPC) +Name[sr]=eGroupware сервер (преко XML-RPC) +Name[sr@Latn]=eGroupware server (preko XML-RPC) +Name[sv]=eGroupware-server (via XML-RPC) +Name[ta]=eGroupware சேவகன் (via XML-RPC) +Name[tr]=eGroupware Sunucusu (XML-RPC ile) +Name[uk]=Сервер eGroupware (через XML-RPC) +Name[zh_CN]=eGroupware 服务器(通过 XML-RPC) +Name[zh_TW]=eGroupware 伺服器(透過 XML-RPC) +X-TDE-Library=kabc_xmlrpc +Type=Service +ServiceTypes=KResources/Plugin +X-TDE-ResourceFamily=contact +X-TDE-ResourceType=xmlrpc diff --git a/tderesources/egroupware/tderesources_kabc_egroupware.kcfg b/tderesources/egroupware/tderesources_kabc_egroupware.kcfg deleted file mode 100644 index 5ada19426..000000000 --- a/tderesources/egroupware/tderesources_kabc_egroupware.kcfg +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - default - - - - - - - - - - diff --git a/tderesources/egroupware/tderesources_tdeabc_egroupware.kcfg b/tderesources/egroupware/tderesources_tdeabc_egroupware.kcfg new file mode 100644 index 000000000..af0f07474 --- /dev/null +++ b/tderesources/egroupware/tderesources_tdeabc_egroupware.kcfg @@ -0,0 +1,24 @@ + + + + + + + + + + + default + + + + + + + + + + diff --git a/tderesources/groupdav/kabc_groupdav.desktop b/tderesources/groupdav/kabc_groupdav.desktop deleted file mode 100644 index c10ea97c2..000000000 --- a/tderesources/groupdav/kabc_groupdav.desktop +++ /dev/null @@ -1,52 +0,0 @@ -[Desktop Entry] -Name=GroupDAV Server (e.g. OpenGroupware) -Name[af]=GroupDAV bediener (bv. OpenGroupware) -Name[bg]=Сървър GroupDAV (e.g. OpenGroupware) -Name[br]=Servijer GroupDAV (e.g. OpenGroupware) -Name[ca]=Servidor GroupDAV (p.ex. OpenGroupware) -Name[cs]=GroupDAV server (např. OpenGroupware) -Name[da]=GroupDAV-server (f.eks. OpenGroupware) -Name[de]=GroupDAV-Server (z. B. OpenGroupware) -Name[el]=Εξυπηρετητής GroupDAV (π.χ. OpenGroupware) -Name[es]=Servidor GroupDAV (por ejemplo, OpenGroupware) -Name[et]=GroupDAV server (nt. OpenGroupware) -Name[eu]=GroupDAV zerbitzaria (adib. OpenGroupware) -Name[fa]=کارساز GroupDAV (مثلاً OpenGroupware) -Name[fi]=GroupDAV-palvelin (esim. OpenGroupware) -Name[fr]=GroupDAV Serveur (ex. OpenGroupware) -Name[fy]=GroupDAV-tsjinner (OpenGroupware) -Name[ga]=Freastalaí GroupDAV (m.sh. OpenGroupware) -Name[gl]=Servidor GroupDAV (e.g. OpenGroupware) -Name[hu]=GroupDAV-kiszolgáló (pl. OpenGroupware) -Name[is]=GroupDAV þjónn (t.d. OpenGroupware) -Name[it]=Server GroupDAV (per es. OpenGroupware) -Name[ja]=GroupDAV サーバ (例 OpenGroupware) -Name[ka]=სერვერი GroupDAV (მაგ., OpenGroupware) -Name[kk]=GroupDAV сервері (мысалы OpenGroupware) -Name[km]=ម៉ាស៊ីន​បម្រើ GroupDAV (ឧ. OpenGroupware) -Name[lt]=GroupDAV serveris (pvz.: OpenGroupware) -Name[ms]=Pelayan GroupDAV (misalnya OpenGroupware) -Name[nb]=GroupDAV-tjener (f.eks. OpenGroupware) -Name[nds]=GroupDAV-Server (t.B. OpenGroupware) -Name[ne]=समूह DAV सर्भर (जस्तै: खुला ग्रुपवेयर) -Name[nl]=GroupDAV-server (OpenGroupware) -Name[nn]=GroupDAV-tenar (t.d. OpenGroupware) -Name[pl]=Serwer GroupDAV (np. OpenGroupware) -Name[pt]=Servidor GroupDAV (por exemplo OpenGroupware) -Name[pt_BR]=Servidor GroupDav (p. ex. OpenGroupware) -Name[ru]=Сервер GroupDAV (например, OpenGroupware) -Name[sk]=GroupDAV Server (napr. OpenGroupware) -Name[sl]=Strežnik GroupDAV (npr. OpenGroupware) -Name[sr]=GroupDAV сервер (нпр. OpenGroupware) -Name[sr@Latn]=GroupDAV server (npr. OpenGroupware) -Name[sv]=GroupDAV-server (t.ex. OpenGroupware) -Name[ta]=GroupDAV சேவகன் (e.g. OpenGroupware) -Name[tr]=GroupDAV Sunucusu (ör. OpenGroupware) -Name[uk]=Сервер GroupDAV (напр., OpenGroupware) -Name[zh_CN]=GroupDAV 服务器(如 OpenGroupware) -Name[zh_TW]=GroupDAV 伺服器 (如: OpenGroupware) -X-TDE-Library=kabc_groupdav -Type=Service -ServiceTypes=KResources/Plugin -X-TDE-ResourceFamily=contact -X-TDE-ResourceType=groupdav diff --git a/tderesources/groupdav/kabc_resourcegroupdav.cpp b/tderesources/groupdav/kabc_resourcegroupdav.cpp deleted file mode 100644 index 1f50e04bb..000000000 --- a/tderesources/groupdav/kabc_resourcegroupdav.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - Copyright (c) 2004 Till Adam - Copyright (c) 2005 Reinhold Kainhofer - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "groupdavaddressbookadaptor.h" -#include "tderesources_groupwareprefs.h" - -#include "kabc_resourcegroupdav.h" - -using namespace KABC; - -ResourceGroupDav::ResourceGroupDav( const TDEConfig *config ) - : ResourceGroupwareBase( config ) -{ - init(); - if ( config ) readConfig( config ); -} - -void ResourceGroupDav::init() -{ - setType( "ResourceGroupDav" ); - setPrefs( createPrefs() ); - setFolderLister( new KPIM::FolderLister( KPIM::FolderLister::AddressBook ) ); - setAdaptor( new GroupDavAddressBookAdaptor() ); - - ResourceGroupwareBase::init(); -} - -#include "kabc_resourcegroupdav.moc" diff --git a/tderesources/groupdav/kabc_resourcegroupdav.h b/tderesources/groupdav/kabc_resourcegroupdav.h deleted file mode 100644 index ca7ed96d3..000000000 --- a/tderesources/groupdav/kabc_resourcegroupdav.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - Copyright (c) 2004 Till Adam - Copyright (c) 2005 Reinhold Kainhofer - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#ifndef KABC_RESOURCEGROUPDAV_H -#define KABC_RESOURCEGROUPDAV_H - -#include "kabc_resourcegroupwarebase.h" -#include - -namespace KABC { - -class KDE_EXPORT ResourceGroupDav : public ResourceGroupwareBase -{ - Q_OBJECT - - - public: - ResourceGroupDav( const TDEConfig * ); -// ResourceGroupDav( const KURL &url, -// const TQString &user, const TQString &password ); - protected: - void init(); -}; - -} - -#endif diff --git a/tderesources/groupdav/kabc_resourcegroupdav_plugin.cpp b/tderesources/groupdav/kabc_resourcegroupdav_plugin.cpp deleted file mode 100644 index 2377808a2..000000000 --- a/tderesources/groupdav/kabc_resourcegroupdav_plugin.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - Copyright (c) 2004 Till Adam - Copyright (c) 2005 Reinhold Kainhofer - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "kabc_resourcegroupdav.h" -#include "kabc_resourcegroupwarebaseconfig.h" - -#include -#include - -using namespace KABC; - -typedef KRES::PluginFactory< ResourceGroupDav, ResourceGroupwareBaseConfig > GroupDavFactory; -// FIXME: Use K_EXPORT_COMPONENT_FACTORY( kabc_groupdav, GroupDavFactory ); here -// Problem: How do I insert the catalogue??? -extern "C" -{ - void *init_kabc_groupdav() - { - TDEGlobal::locale()->insertCatalogue( "tdepimresources" ); - TDEGlobal::locale()->insertCatalogue( "kres_groupdav" ); - return new GroupDavFactory; - } -} diff --git a/tderesources/groupdav/tdeabc_groupdav.desktop b/tderesources/groupdav/tdeabc_groupdav.desktop new file mode 100644 index 000000000..c10ea97c2 --- /dev/null +++ b/tderesources/groupdav/tdeabc_groupdav.desktop @@ -0,0 +1,52 @@ +[Desktop Entry] +Name=GroupDAV Server (e.g. OpenGroupware) +Name[af]=GroupDAV bediener (bv. OpenGroupware) +Name[bg]=Сървър GroupDAV (e.g. OpenGroupware) +Name[br]=Servijer GroupDAV (e.g. OpenGroupware) +Name[ca]=Servidor GroupDAV (p.ex. OpenGroupware) +Name[cs]=GroupDAV server (např. OpenGroupware) +Name[da]=GroupDAV-server (f.eks. OpenGroupware) +Name[de]=GroupDAV-Server (z. B. OpenGroupware) +Name[el]=Εξυπηρετητής GroupDAV (π.χ. OpenGroupware) +Name[es]=Servidor GroupDAV (por ejemplo, OpenGroupware) +Name[et]=GroupDAV server (nt. OpenGroupware) +Name[eu]=GroupDAV zerbitzaria (adib. OpenGroupware) +Name[fa]=کارساز GroupDAV (مثلاً OpenGroupware) +Name[fi]=GroupDAV-palvelin (esim. OpenGroupware) +Name[fr]=GroupDAV Serveur (ex. OpenGroupware) +Name[fy]=GroupDAV-tsjinner (OpenGroupware) +Name[ga]=Freastalaí GroupDAV (m.sh. OpenGroupware) +Name[gl]=Servidor GroupDAV (e.g. OpenGroupware) +Name[hu]=GroupDAV-kiszolgáló (pl. OpenGroupware) +Name[is]=GroupDAV þjónn (t.d. OpenGroupware) +Name[it]=Server GroupDAV (per es. OpenGroupware) +Name[ja]=GroupDAV サーバ (例 OpenGroupware) +Name[ka]=სერვერი GroupDAV (მაგ., OpenGroupware) +Name[kk]=GroupDAV сервері (мысалы OpenGroupware) +Name[km]=ម៉ាស៊ីន​បម្រើ GroupDAV (ឧ. OpenGroupware) +Name[lt]=GroupDAV serveris (pvz.: OpenGroupware) +Name[ms]=Pelayan GroupDAV (misalnya OpenGroupware) +Name[nb]=GroupDAV-tjener (f.eks. OpenGroupware) +Name[nds]=GroupDAV-Server (t.B. OpenGroupware) +Name[ne]=समूह DAV सर्भर (जस्तै: खुला ग्रुपवेयर) +Name[nl]=GroupDAV-server (OpenGroupware) +Name[nn]=GroupDAV-tenar (t.d. OpenGroupware) +Name[pl]=Serwer GroupDAV (np. OpenGroupware) +Name[pt]=Servidor GroupDAV (por exemplo OpenGroupware) +Name[pt_BR]=Servidor GroupDav (p. ex. OpenGroupware) +Name[ru]=Сервер GroupDAV (например, OpenGroupware) +Name[sk]=GroupDAV Server (napr. OpenGroupware) +Name[sl]=Strežnik GroupDAV (npr. OpenGroupware) +Name[sr]=GroupDAV сервер (нпр. OpenGroupware) +Name[sr@Latn]=GroupDAV server (npr. OpenGroupware) +Name[sv]=GroupDAV-server (t.ex. OpenGroupware) +Name[ta]=GroupDAV சேவகன் (e.g. OpenGroupware) +Name[tr]=GroupDAV Sunucusu (ör. OpenGroupware) +Name[uk]=Сервер GroupDAV (напр., OpenGroupware) +Name[zh_CN]=GroupDAV 服务器(如 OpenGroupware) +Name[zh_TW]=GroupDAV 伺服器 (如: OpenGroupware) +X-TDE-Library=kabc_groupdav +Type=Service +ServiceTypes=KResources/Plugin +X-TDE-ResourceFamily=contact +X-TDE-ResourceType=groupdav diff --git a/tderesources/groupdav/tdeabc_resourcegroupdav.cpp b/tderesources/groupdav/tdeabc_resourcegroupdav.cpp new file mode 100644 index 000000000..1f50e04bb --- /dev/null +++ b/tderesources/groupdav/tdeabc_resourcegroupdav.cpp @@ -0,0 +1,47 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + Copyright (c) 2004 Till Adam + Copyright (c) 2005 Reinhold Kainhofer + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "groupdavaddressbookadaptor.h" +#include "tderesources_groupwareprefs.h" + +#include "kabc_resourcegroupdav.h" + +using namespace KABC; + +ResourceGroupDav::ResourceGroupDav( const TDEConfig *config ) + : ResourceGroupwareBase( config ) +{ + init(); + if ( config ) readConfig( config ); +} + +void ResourceGroupDav::init() +{ + setType( "ResourceGroupDav" ); + setPrefs( createPrefs() ); + setFolderLister( new KPIM::FolderLister( KPIM::FolderLister::AddressBook ) ); + setAdaptor( new GroupDavAddressBookAdaptor() ); + + ResourceGroupwareBase::init(); +} + +#include "kabc_resourcegroupdav.moc" diff --git a/tderesources/groupdav/tdeabc_resourcegroupdav.h b/tderesources/groupdav/tdeabc_resourcegroupdav.h new file mode 100644 index 000000000..ca7ed96d3 --- /dev/null +++ b/tderesources/groupdav/tdeabc_resourcegroupdav.h @@ -0,0 +1,45 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + Copyright (c) 2004 Till Adam + Copyright (c) 2005 Reinhold Kainhofer + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_RESOURCEGROUPDAV_H +#define KABC_RESOURCEGROUPDAV_H + +#include "kabc_resourcegroupwarebase.h" +#include + +namespace KABC { + +class KDE_EXPORT ResourceGroupDav : public ResourceGroupwareBase +{ + Q_OBJECT + + + public: + ResourceGroupDav( const TDEConfig * ); +// ResourceGroupDav( const KURL &url, +// const TQString &user, const TQString &password ); + protected: + void init(); +}; + +} + +#endif diff --git a/tderesources/groupdav/tdeabc_resourcegroupdav_plugin.cpp b/tderesources/groupdav/tdeabc_resourcegroupdav_plugin.cpp new file mode 100644 index 000000000..1ef588dfd --- /dev/null +++ b/tderesources/groupdav/tdeabc_resourcegroupdav_plugin.cpp @@ -0,0 +1,42 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + Copyright (c) 2004 Till Adam + Copyright (c) 2005 Reinhold Kainhofer + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "kabc_resourcegroupdav.h" +#include "kabc_resourcegroupwarebaseconfig.h" + +#include +#include + +using namespace KABC; + +typedef KRES::PluginFactory< ResourceGroupDav, ResourceGroupwareBaseConfig > GroupDavFactory; +// FIXME: Use K_EXPORT_COMPONENT_FACTORY( kabc_groupdav, GroupDavFactory ); here +// Problem: How do I insert the catalogue??? +extern "C" +{ + void *init_tdeabc_groupdav() + { + TDEGlobal::locale()->insertCatalogue( "tdepimresources" ); + TDEGlobal::locale()->insertCatalogue( "kres_groupdav" ); + return new GroupDavFactory; + } +} diff --git a/tderesources/groupware/kabc_groupware.desktop b/tderesources/groupware/kabc_groupware.desktop deleted file mode 100644 index dee5d9c24..000000000 --- a/tderesources/groupware/kabc_groupware.desktop +++ /dev/null @@ -1,49 +0,0 @@ -[Desktop Entry] -Name=Groupware Server -Name[af]=Groupware bediener -Name[ar]=خادم البرمجيات الجماعية -Name[bg]=Сървър Groupware -Name[br]=Servijer strollant -Name[ca]=Servidor Groupware -Name[cs]=Groupware server -Name[el]=Εξυπηρετητής Groupware -Name[es]=Servidor de Groupware -Name[et]=Grupitöö server -Name[eu]=Groupware zerbitzaria -Name[fa]=کارساز Groupware -Name[fi]=Groupware-palvelin -Name[fr]=Serveur de travail collaboratif -Name[fy]=Groupware-tsjinner -Name[ga]=Freastalaí Groupware -Name[gl]=Servidor de Traballo en Grupo -Name[hu]=Groupware kiszolgáló -Name[is]=Groupware þjónn -Name[it]=Server Groupware -Name[ja]=グループウェアサーバ -Name[kk]=Groupware сервері -Name[km]=ម៉ាស៊ីន​បម្រើ​កម្មវិធី​ពហុ​អ្នកប្រើ -Name[lt]=Grupinio darbo serveris -Name[ms]=Pelayan Groupware -Name[nb]=Groupware-tjener -Name[nds]=Groupware-Server -Name[ne]=ग्रुपवेयर सर्भर -Name[nl]=Groupware-server -Name[nn]=Groupware-tenar -Name[pl]=Serwer Groupware -Name[pt]=Servidor de Groupware -Name[pt_BR]=Servidor Groupware -Name[ru]=Сервер Groupware -Name[sl]=Strežnik za skupinsko delo -Name[sr]=Groupware сервер -Name[sr@Latn]=Groupware server -Name[sv]=Grupprogramserver -Name[ta]=குழுவாரி சேவகன் -Name[tr]=Grupyazılımı(Groupware) Sunucusu -Name[uk]=Сервер Groupware -Name[zh_CN]=群件服务器 -Name[zh_TW]=群組伺服器 -X-TDE-Library=kabc_groupware -Type=Service -ServiceTypes=KResources/Plugin -X-TDE-ResourceFamily=contact -X-TDE-ResourceType=groupware diff --git a/tderesources/groupware/kabc_groupwareprefs.kcfgc b/tderesources/groupware/kabc_groupwareprefs.kcfgc deleted file mode 100644 index 771ddccf4..000000000 --- a/tderesources/groupware/kabc_groupwareprefs.kcfgc +++ /dev/null @@ -1,8 +0,0 @@ -ClassName=GroupwarePrefs -File=tderesources_kabc_groupware.kcfg -GlobalEnums=true -IncludeFiles=libtdepim/kresourceprefs.h -Inherits=KResourcePrefs -Mutators=true -NameSpace=KABC -Singleton=false diff --git a/tderesources/groupware/kabc_resourcegroupware.cpp b/tderesources/groupware/kabc_resourcegroupware.cpp deleted file mode 100644 index e2503b83d..000000000 --- a/tderesources/groupware/kabc_resourcegroupware.cpp +++ /dev/null @@ -1,365 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include - -#include -#include -#include -#include -#include - -#include - -#include "kabc_groupwareprefs.h" - -#include "kabc_resourcegroupware.h" - -using namespace KABC; - -ResourceGroupware::ResourceGroupware( const TDEConfig *config ) - : ResourceCached( config ) -{ - init(); - - mPrefs->addGroupPrefix( identifier() ); - - if ( config ) { - readConfig( config ); - } else { - setResourceName( i18n( "Groupware Server" ) ); - } -} - -ResourceGroupware::ResourceGroupware( const KURL &url, - const TQString &user, - const TQString &password ) - : ResourceCached( 0 ) -{ - init(); - - mPrefs->addGroupPrefix( identifier() ); - - mPrefs->setUrl( url.url() ); - mPrefs->setUser( user ); - mPrefs->setPassword( password ); -} - -void ResourceGroupware::init() -{ - mDownloadJob = 0; - mProgress = 0; - - mPrefs = new GroupwarePrefs; - - setType( "groupware" ); -} - -ResourceGroupware::~ResourceGroupware() -{ - delete mPrefs; - mPrefs = 0; -} - -void ResourceGroupware::readConfig( const TDEConfig * ) -{ - mPrefs->readConfig(); - - readAddressBooks(); -} - -void ResourceGroupware::writeConfig( TDEConfig *config ) -{ - Resource::writeConfig( config ); - - writeAddressBooks(); - - mPrefs->writeConfig(); -} - -void ResourceGroupware::readAddressBooks() -{ -#if 0 - TQStringList ids = prefs()->ids(); - TQStringList names = prefs()->names(); - TQStringList personals = prefs()->personals(); - TQStringList frequents = prefs()->frequents(); - - if ( ids.count() != names.count() || ids.count() != personals.count() || - ids.count() != frequents.count() ) { - kdError() << "Corrupt addressbook configuration" << endl; - return; - } - - mAddressBooks.clear(); - - for( uint i = 0; i < ids.count(); ++i ) { - Groupware::AddressBook ab; - ab.id = ids[ i ]; - ab.name = names[ i ]; - ab.isPersonal = personals[ i ] == "1"; - ab.isFrequentContacts = frequents[ i ] == "1"; - - mAddressBooks.append( ab ); - } -#endif -} - -void ResourceGroupware::writeAddressBooks() -{ -#if 0 - TQStringList ids; - TQStringList names; - TQStringList personals; - TQStringList frequents; - Groupware::AddressBook::List::ConstIterator it; - for( it = mAddressBooks.begin(); it != mAddressBooks.end(); ++it ) { - ids.append( (*it).id ); - names.append( (*it).name ); - personals.append( (*it).isPersonal ? "1" : "0" ); - frequents.append( (*it).isFrequentContacts ? "1" : "0" ); - } - prefs()->setIds( ids ); - prefs()->setNames( names ); - prefs()->setPersonals( personals ); - prefs()->setFrequents( frequents ); -#endif -} - -void ResourceGroupware::retrieveAddressBooks() -{ -#if 0 - bool firstRetrieve = mAddressBooks.isEmpty(); - - GroupwareServer server( prefs()->url(), - prefs()->user(), - prefs()->password(), this ); - - server.login(); - mAddressBooks = server.addressBookList(); - server.logout(); - - if ( firstRetrieve ) { - TQStringList reads; - TQString write; - - Groupware::AddressBook::List::ConstIterator it; - for( it = mAddressBooks.begin(); it != mAddressBooks.end(); ++it ) { - if ( (*it).isPersonal ) { - reads.append( (*it).id ); - if ( write.isEmpty() ) write = (*it).id; - } - } - - prefs()->setReadAddressBooks( reads ); - prefs()->setWriteAddressBook( write ); - } -#endif -} - -Ticket *ResourceGroupware::requestSaveTicket() -{ - if ( !addressBook() ) { - kdDebug(5700) << "no addressbook" << endl; - return 0; - } - - return createTicket( this ); -} - -void ResourceGroupware::releaseSaveTicket( Ticket *ticket ) -{ - delete ticket; -} - -bool ResourceGroupware::doOpen() -{ - return true; -} - -void ResourceGroupware::doClose() -{ - kdDebug() << "ResourceGroupware::doClose()" << endl; - - cancelLoad(); -} - -bool ResourceGroupware::load() -{ - return asyncLoad(); -} - -bool ResourceGroupware::asyncLoad() -{ - if ( mDownloadJob ) { - kdWarning() << "Download still in progress" << endl; - return false; - } - - mAddrMap.clear(); - loadCache(); - -#if 0 - if ( addressBooks().isEmpty() ) { - kdDebug() << "Retrieving default addressbook list." << endl; - retrieveAddressBooks(); - writeAddressBooks(); - } -#endif - - KURL url( prefs()->url() ); - url.setUser( prefs()->user() ); - url.setPass( prefs()->password() ); - -#if 0 - TQString query = "?"; - TQStringList ids = mPrefs->readAddressBooks(); - TQStringList::ConstIterator it; - for( it = ids.begin(); it != ids.end(); ++it ) { - if ( it != ids.begin() ) query += "&"; - query += "addressbookid=" + *it; - } - url.setQuery( query ); -#endif - - kdDebug() << "Download URL: " << url << endl; - - mJobData = TQString(); - - mDownloadJob = KPIM::GroupwareJob::getAddressBook( url ); - connect( mDownloadJob, TQT_SIGNAL( result( TDEIO::Job * ) ), - TQT_SLOT( slotJobResult( TDEIO::Job * ) ) ); - connect( mDownloadJob, TQT_SIGNAL( data( TDEIO::Job *, const TQByteArray & ) ), - TQT_SLOT( slotJobData( TDEIO::Job *, const TQByteArray & ) ) ); - connect( mDownloadJob, TQT_SIGNAL( percent( TDEIO::Job *, unsigned long ) ), - TQT_SLOT( slotJobPercent( TDEIO::Job *, unsigned long ) ) ); - - mProgress = KPIM::ProgressManager::instance()->createProgressItem( - KPIM::ProgressManager::getUniqueID(), i18n("Downloading addressbook") ); - connect( mProgress, - TQT_SIGNAL( progressItemCanceled( KPIM::ProgressItem * ) ), - TQT_SLOT( cancelLoad() ) ); - - return true; -} - -bool ResourceGroupware::save( Ticket *ticket ) -{ - return asyncSave( ticket ); -} - -bool ResourceGroupware::asyncSave( Ticket* ) -{ -#if 0 - if ( !mServer->login() ) return false; - - KABC::Addressee::List::Iterator it; - - KABC::Addressee::List addedList = addedAddressees(); - for ( it = addedList.begin(); it != addedList.end(); ++it ) { - if ( mServer->insertAddressee( mPrefs->writeAddressBook(), *it ) ) { - clearChange( *it ); - idMapper().setRemoteId( (*it).uid(), (*it).custom( "GWRESOURCE", "UID" ) ); - } - } - - KABC::Addressee::List changedList = changedAddressees(); - for ( it = changedList.begin(); it != changedList.end(); ++it ) { - if ( mServer->changeAddressee( *it ) ) - clearChange( *it ); - } - - KABC::Addressee::List deletedList = deletedAddressees(); - for ( it = deletedList.begin(); it != deletedList.end(); ++it ) { - if ( mServer->removeAddressee( *it ) ) - clearChange( *it ); - } - - saveCache(); - - mServer->logout(); -#endif - - return true; -} - -void ResourceGroupware::slotJobResult( TDEIO::Job *job ) -{ - kdDebug() << "ResourceGroupware::slotJobResult(): " << endl; - - if ( job->error() ) { - kdError() << job->errorString() << endl; - emit loadingError( this, job->errorString() ); - } else { - mAddrMap.clear(); - - KABC::VCardConverter conv; - Addressee::List addressees = conv.parseVCards( mJobData ); - Addressee::List::ConstIterator it; - for( it = addressees.begin(); it != addressees.end(); ++it ) { - KABC::Addressee addr = *it; - if ( !addr.isEmpty() ) { - addr.setResource( this ); - - TQString remote = addr.custom( "GWRESOURCE", "UID" ); - TQString local = idMapper().localId( remote ); - if ( local.isEmpty() ) { - idMapper().setRemoteId( addr.uid(), remote ); - } else { - addr.setUid( local ); - } - - insertAddressee( addr ); - clearChange( addr ); - } - } - } - - saveCache(); - - emit loadingFinished( this ); - - mDownloadJob = 0; - if ( mProgress ) mProgress->setComplete(); - mProgress = 0; -} - -void ResourceGroupware::slotJobData( TDEIO::Job *, const TQByteArray &data ) -{ -// kdDebug() << "ResourceGroupware::slotJobData()" << endl; - - mJobData.append( data.data() ); -} - -void ResourceGroupware::slotJobPercent( TDEIO::Job *, unsigned long percent ) -{ - kdDebug() << "ResourceGroupware::slotJobPercent() " << percent << endl; - if ( mProgress ) mProgress->setProgress( percent ); -} - -void ResourceGroupware::cancelLoad() -{ - if ( mDownloadJob ) mDownloadJob->kill(); - mDownloadJob = 0; - if ( mProgress ) mProgress->setComplete(); - mProgress = 0; -} - -#include "kabc_resourcegroupware.moc" diff --git a/tderesources/groupware/kabc_resourcegroupware.h b/tderesources/groupware/kabc_resourcegroupware.h deleted file mode 100644 index 1c5feb847..000000000 --- a/tderesources/groupware/kabc_resourcegroupware.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#ifndef KABC_RESOURCEGROUPWARE_H -#define KABC_RESOURCEGROUPWARE_H - -#include - -#include - -#include - -class TDEConfig; - -namespace KABC { - -class GroupwarePrefs; - -class ResourceGroupware : public ResourceCached -{ - Q_OBJECT - - - public: - ResourceGroupware( const TDEConfig * ); - ResourceGroupware( const KURL &url, - const TQString &user, const TQString &password ); - ~ResourceGroupware(); - - void readConfig( const TDEConfig * ); - void writeConfig( TDEConfig * ); - - void readAddressBooks(); - void writeAddressBooks(); - - void retrieveAddressBooks(); - - GroupwarePrefs *prefs() const { return mPrefs; } - - bool doOpen(); - void doClose(); - - Ticket *requestSaveTicket(); - void releaseSaveTicket( Ticket* ); - - bool load(); - bool asyncLoad(); - bool save( Ticket * ); - bool asyncSave( Ticket * ); - - protected: - void init(); - - private slots: - void slotJobResult( TDEIO::Job * ); - void slotJobData( TDEIO::Job *, const TQByteArray & ); - void slotJobPercent( TDEIO::Job *job, unsigned long percent ); - - void cancelLoad(); - - private: - GroupwarePrefs *mPrefs; - - TDEIO::TransferJob *mDownloadJob; - KPIM::ProgressItem *mProgress; - TQString mJobData; -}; - -} - -#endif diff --git a/tderesources/groupware/kabc_resourcegroupware_plugin.cpp b/tderesources/groupware/kabc_resourcegroupware_plugin.cpp deleted file mode 100644 index 12f3233b6..000000000 --- a/tderesources/groupware/kabc_resourcegroupware_plugin.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "kabc_resourcegroupware.h" -#include "kabc_resourcegroupwareconfig.h" - -#include -#include - -using namespace KABC; - -typedef KRES::PluginFactory GroupwareFactory; - -extern "C" -{ - void *init_kabc_groupware() - { - TDEGlobal::locale()->insertCatalogue( "libkcal" ); - TDEGlobal::locale()->insertCatalogue( "kres_groupware" ); - return new ResourceGroupware; - } -} diff --git a/tderesources/groupware/kabc_resourcegroupwareconfig.cpp b/tderesources/groupware/kabc_resourcegroupwareconfig.cpp deleted file mode 100644 index 35ca8596f..000000000 --- a/tderesources/groupware/kabc_resourcegroupwareconfig.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "kabc_resourcegroupwareconfig.h" - -#include "kabc_resourcegroupware.h" -#include "kabc_groupwareprefs.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -using namespace KABC; - -class AddressBookItem : public TQCheckListItem -{ - public: - AddressBookItem( TDEListView *parent, const TQString &id ) - : TQCheckListItem( parent, "", CheckBox ), - mId( id ) - { - setText( 0, mId ); -#if 0 - if ( ab.isPersonal ) setText( 1, "Yes" ); - else setText( 1, "No" ); - if ( ab.isFrequentContacts ) setText( 2, "Yes" ); - else setText( 2, "No" ); -#endif - } - - TQString id() const { return mId; } - - private: - TQString mId; -}; - -ResourceGroupwareConfig::ResourceGroupwareConfig( TQWidget* parent, const char* name ) - : KRES::ConfigWidget( parent, name ) -{ - TQGridLayout *mainLayout = new TQGridLayout( this, 7, 2, 0, KDialog::spacingHint() ); - - TQLabel *label = new TQLabel( i18n( "URL:" ), this ); - mURL = new KURLRequester( this ); - - mainLayout->addWidget( label, 0, 0 ); - mainLayout->addWidget( mURL, 0, 1 ); - - label = new TQLabel( i18n( "User:" ), this ); - mUser = new KLineEdit( this ); - - mainLayout->addWidget( label, 1, 0 ); - mainLayout->addWidget( mUser, 1, 1 ); - - label = new TQLabel( i18n( "Password:" ), this ); - mPassword = new KLineEdit( this ); - mPassword->setEchoMode( TQLineEdit::Password ); - - mainLayout->addWidget( label, 2, 0 ); - mainLayout->addWidget( mPassword, 2, 1 ); - - TQFrame *hline = new TQFrame( this ); - hline->setFrameStyle( TQFrame::HLine | TQFrame::Sunken ); - - mainLayout->addMultiCellWidget( hline, 3, 3, 0, 1 ); - - TQPushButton *updateButton = new TQPushButton( i18n( "Retrieve Address Book List From Server" ), this ); - mainLayout->addMultiCellWidget( updateButton, 4, 4, 0, 1 ); - - mAddressBookView = new TDEListView( this ); - mAddressBookView->addColumn( i18n( "Address Book" ) ); -#if 0 - mAddressBookView->addColumn( i18n( "Personal" ) ); - mAddressBookView->addColumn( i18n( "Frequent Contacts" ) ); -#endif - mAddressBookView->setFullWidth( true ); - - mainLayout->addMultiCellWidget( mAddressBookView, 5, 5, 0, 1 ); - - label = new TQLabel( i18n( "Address book for new contacts:" ), this ); - mAddressBookBox = new KComboBox( this ); - - mainLayout->addWidget( label, 6, 0 ); - mainLayout->addWidget( mAddressBookBox, 6, 1 ); - - connect( updateButton, TQT_SIGNAL( clicked() ), TQT_SLOT( updateAddressBookList() ) ); -} - -void ResourceGroupwareConfig::loadSettings( KRES::Resource *res ) -{ - mResource = dynamic_cast( res ); - - if ( !mResource ) { - kdDebug(5700) << "ResourceGroupwareConfig::loadSettings(): cast failed" << endl; - return; - } - - mURL->setURL( mResource->prefs()->url() ); - mUser->setText( mResource->prefs()->user() ); - mPassword->setText( mResource->prefs()->password() ); - - updateAddressBookView(); -} - -void ResourceGroupwareConfig::saveSettings( KRES::Resource *res ) -{ - ResourceGroupware *resource = dynamic_cast( res ); - - if ( !resource ) { - kdDebug(5700) << "ResourceGroupwareConfig::saveSettings(): cast failed" << endl; - return; - } - - saveServerSettings( resource ); - - saveAddressBookSettings(); -} - -void ResourceGroupwareConfig::saveServerSettings( ResourceGroupware *resource ) -{ - resource->prefs()->setUrl( mURL->url() ); - resource->prefs()->setUser( mUser->text() ); - resource->prefs()->setPassword( mPassword->text() ); -} - -void ResourceGroupwareConfig::updateAddressBookList() -{ - saveServerSettings( mResource ); - - mResource->retrieveAddressBooks(); - - updateAddressBookView(); -} - -void ResourceGroupwareConfig::saveAddressBookSettings() -{ -#if 0 - TQStringList selectedRead; - TQString selectedWrite; - - TQListViewItemIterator it2( mAddressBookView ); - while ( it2.current() ) { - AddressBookItem *item = static_cast( it2.current() ); - if ( item->isOn() ) - selectedRead.append( item->id() ); - - ++it2; - } - - selectedWrite = mWriteAddressBookIds[ mAddressBookBox->currentItem() ]; - - mResource->prefs()->setReadAddressBooks( selectedRead ); - mResource->prefs()->setWriteAddressBook( selectedWrite ); -#endif -} - -void ResourceGroupwareConfig::updateAddressBookView() -{ - if ( mAddressBookBox->count() != 0 ) // we loaded it already - saveAddressBookSettings(); - - mAddressBookView->clear(); - mAddressBookBox->clear(); - mWriteAddressBookIds.clear(); - -#if 0 - TQStringList selectedRead = mResource->prefs()->readAddressBooks(); - - Groupware::AddressBook::List addressBooks = mResource->addressBooks(); - Groupware::AddressBook::List::ConstIterator abIt; - for ( abIt = addressBooks.begin(); abIt != addressBooks.end(); ++abIt ) { - AddressBookItem *item = new AddressBookItem( mAddressBookView, *abIt ); - if ( selectedRead.find( (*abIt).id ) != selectedRead.end() ) - item->setOn( true ); - - mAddressBookBox->insertItem( (*abIt).name ); - mWriteAddressBookIds.append( (*abIt).id ); - } - - int index = mWriteAddressBookIds.findIndex( mResource->prefs()->writeAddressBook() ); - mAddressBookBox->setCurrentItem( index ); -#endif -} - -#include "kabc_resourcegroupwareconfig.moc" diff --git a/tderesources/groupware/kabc_resourcegroupwareconfig.h b/tderesources/groupware/kabc_resourcegroupwareconfig.h deleted file mode 100644 index c07c4d0b4..000000000 --- a/tderesources/groupware/kabc_resourcegroupwareconfig.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#ifndef KABC_RESOURCEGROUPWARECONFIG_H -#define KABC_RESOURCEGROUPWARECONFIG_H - -#include - -#include - -class KComboBox; -class KLineEdit; -class TDEListView; -class KURLRequester; - -namespace KABC { - -class ResourceGroupware; - -class ResourceGroupwareConfig : public KRES::ConfigWidget -{ - Q_OBJECT - - - public: - ResourceGroupwareConfig( TQWidget* parent = 0, const char* name = 0 ); - - public slots: - void loadSettings( KRES::Resource* ); - void saveSettings( KRES::Resource* ); - - protected slots: - void updateAddressBookList(); - - private: - void updateAddressBookView(); - void saveAddressBookSettings(); - void loadAddressBookSettings(); - void saveServerSettings( ResourceGroupware *resource ); - - KURLRequester *mURL; - KLineEdit *mUser; - KLineEdit *mPassword; - - TDEListView *mAddressBookView; - KComboBox *mAddressBookBox; - - TQStringList mWriteAddressBookIds; - - ResourceGroupware *mResource; -}; - -} - -#endif diff --git a/tderesources/groupware/tdeabc_groupware.desktop b/tderesources/groupware/tdeabc_groupware.desktop new file mode 100644 index 000000000..dee5d9c24 --- /dev/null +++ b/tderesources/groupware/tdeabc_groupware.desktop @@ -0,0 +1,49 @@ +[Desktop Entry] +Name=Groupware Server +Name[af]=Groupware bediener +Name[ar]=خادم البرمجيات الجماعية +Name[bg]=Сървър Groupware +Name[br]=Servijer strollant +Name[ca]=Servidor Groupware +Name[cs]=Groupware server +Name[el]=Εξυπηρετητής Groupware +Name[es]=Servidor de Groupware +Name[et]=Grupitöö server +Name[eu]=Groupware zerbitzaria +Name[fa]=کارساز Groupware +Name[fi]=Groupware-palvelin +Name[fr]=Serveur de travail collaboratif +Name[fy]=Groupware-tsjinner +Name[ga]=Freastalaí Groupware +Name[gl]=Servidor de Traballo en Grupo +Name[hu]=Groupware kiszolgáló +Name[is]=Groupware þjónn +Name[it]=Server Groupware +Name[ja]=グループウェアサーバ +Name[kk]=Groupware сервері +Name[km]=ម៉ាស៊ីន​បម្រើ​កម្មវិធី​ពហុ​អ្នកប្រើ +Name[lt]=Grupinio darbo serveris +Name[ms]=Pelayan Groupware +Name[nb]=Groupware-tjener +Name[nds]=Groupware-Server +Name[ne]=ग्रुपवेयर सर्भर +Name[nl]=Groupware-server +Name[nn]=Groupware-tenar +Name[pl]=Serwer Groupware +Name[pt]=Servidor de Groupware +Name[pt_BR]=Servidor Groupware +Name[ru]=Сервер Groupware +Name[sl]=Strežnik za skupinsko delo +Name[sr]=Groupware сервер +Name[sr@Latn]=Groupware server +Name[sv]=Grupprogramserver +Name[ta]=குழுவாரி சேவகன் +Name[tr]=Grupyazılımı(Groupware) Sunucusu +Name[uk]=Сервер Groupware +Name[zh_CN]=群件服务器 +Name[zh_TW]=群組伺服器 +X-TDE-Library=kabc_groupware +Type=Service +ServiceTypes=KResources/Plugin +X-TDE-ResourceFamily=contact +X-TDE-ResourceType=groupware diff --git a/tderesources/groupware/tdeabc_groupwareprefs.kcfgc b/tderesources/groupware/tdeabc_groupwareprefs.kcfgc new file mode 100644 index 000000000..10abd7af8 --- /dev/null +++ b/tderesources/groupware/tdeabc_groupwareprefs.kcfgc @@ -0,0 +1,8 @@ +ClassName=GroupwarePrefs +File=tderesources_tdeabc_groupware.kcfg +GlobalEnums=true +IncludeFiles=libtdepim/kresourceprefs.h +Inherits=KResourcePrefs +Mutators=true +NameSpace=KABC +Singleton=false diff --git a/tderesources/groupware/tdeabc_resourcegroupware.cpp b/tderesources/groupware/tdeabc_resourcegroupware.cpp new file mode 100644 index 000000000..e2503b83d --- /dev/null +++ b/tderesources/groupware/tdeabc_resourcegroupware.cpp @@ -0,0 +1,365 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include + +#include +#include +#include +#include +#include + +#include + +#include "kabc_groupwareprefs.h" + +#include "kabc_resourcegroupware.h" + +using namespace KABC; + +ResourceGroupware::ResourceGroupware( const TDEConfig *config ) + : ResourceCached( config ) +{ + init(); + + mPrefs->addGroupPrefix( identifier() ); + + if ( config ) { + readConfig( config ); + } else { + setResourceName( i18n( "Groupware Server" ) ); + } +} + +ResourceGroupware::ResourceGroupware( const KURL &url, + const TQString &user, + const TQString &password ) + : ResourceCached( 0 ) +{ + init(); + + mPrefs->addGroupPrefix( identifier() ); + + mPrefs->setUrl( url.url() ); + mPrefs->setUser( user ); + mPrefs->setPassword( password ); +} + +void ResourceGroupware::init() +{ + mDownloadJob = 0; + mProgress = 0; + + mPrefs = new GroupwarePrefs; + + setType( "groupware" ); +} + +ResourceGroupware::~ResourceGroupware() +{ + delete mPrefs; + mPrefs = 0; +} + +void ResourceGroupware::readConfig( const TDEConfig * ) +{ + mPrefs->readConfig(); + + readAddressBooks(); +} + +void ResourceGroupware::writeConfig( TDEConfig *config ) +{ + Resource::writeConfig( config ); + + writeAddressBooks(); + + mPrefs->writeConfig(); +} + +void ResourceGroupware::readAddressBooks() +{ +#if 0 + TQStringList ids = prefs()->ids(); + TQStringList names = prefs()->names(); + TQStringList personals = prefs()->personals(); + TQStringList frequents = prefs()->frequents(); + + if ( ids.count() != names.count() || ids.count() != personals.count() || + ids.count() != frequents.count() ) { + kdError() << "Corrupt addressbook configuration" << endl; + return; + } + + mAddressBooks.clear(); + + for( uint i = 0; i < ids.count(); ++i ) { + Groupware::AddressBook ab; + ab.id = ids[ i ]; + ab.name = names[ i ]; + ab.isPersonal = personals[ i ] == "1"; + ab.isFrequentContacts = frequents[ i ] == "1"; + + mAddressBooks.append( ab ); + } +#endif +} + +void ResourceGroupware::writeAddressBooks() +{ +#if 0 + TQStringList ids; + TQStringList names; + TQStringList personals; + TQStringList frequents; + Groupware::AddressBook::List::ConstIterator it; + for( it = mAddressBooks.begin(); it != mAddressBooks.end(); ++it ) { + ids.append( (*it).id ); + names.append( (*it).name ); + personals.append( (*it).isPersonal ? "1" : "0" ); + frequents.append( (*it).isFrequentContacts ? "1" : "0" ); + } + prefs()->setIds( ids ); + prefs()->setNames( names ); + prefs()->setPersonals( personals ); + prefs()->setFrequents( frequents ); +#endif +} + +void ResourceGroupware::retrieveAddressBooks() +{ +#if 0 + bool firstRetrieve = mAddressBooks.isEmpty(); + + GroupwareServer server( prefs()->url(), + prefs()->user(), + prefs()->password(), this ); + + server.login(); + mAddressBooks = server.addressBookList(); + server.logout(); + + if ( firstRetrieve ) { + TQStringList reads; + TQString write; + + Groupware::AddressBook::List::ConstIterator it; + for( it = mAddressBooks.begin(); it != mAddressBooks.end(); ++it ) { + if ( (*it).isPersonal ) { + reads.append( (*it).id ); + if ( write.isEmpty() ) write = (*it).id; + } + } + + prefs()->setReadAddressBooks( reads ); + prefs()->setWriteAddressBook( write ); + } +#endif +} + +Ticket *ResourceGroupware::requestSaveTicket() +{ + if ( !addressBook() ) { + kdDebug(5700) << "no addressbook" << endl; + return 0; + } + + return createTicket( this ); +} + +void ResourceGroupware::releaseSaveTicket( Ticket *ticket ) +{ + delete ticket; +} + +bool ResourceGroupware::doOpen() +{ + return true; +} + +void ResourceGroupware::doClose() +{ + kdDebug() << "ResourceGroupware::doClose()" << endl; + + cancelLoad(); +} + +bool ResourceGroupware::load() +{ + return asyncLoad(); +} + +bool ResourceGroupware::asyncLoad() +{ + if ( mDownloadJob ) { + kdWarning() << "Download still in progress" << endl; + return false; + } + + mAddrMap.clear(); + loadCache(); + +#if 0 + if ( addressBooks().isEmpty() ) { + kdDebug() << "Retrieving default addressbook list." << endl; + retrieveAddressBooks(); + writeAddressBooks(); + } +#endif + + KURL url( prefs()->url() ); + url.setUser( prefs()->user() ); + url.setPass( prefs()->password() ); + +#if 0 + TQString query = "?"; + TQStringList ids = mPrefs->readAddressBooks(); + TQStringList::ConstIterator it; + for( it = ids.begin(); it != ids.end(); ++it ) { + if ( it != ids.begin() ) query += "&"; + query += "addressbookid=" + *it; + } + url.setQuery( query ); +#endif + + kdDebug() << "Download URL: " << url << endl; + + mJobData = TQString(); + + mDownloadJob = KPIM::GroupwareJob::getAddressBook( url ); + connect( mDownloadJob, TQT_SIGNAL( result( TDEIO::Job * ) ), + TQT_SLOT( slotJobResult( TDEIO::Job * ) ) ); + connect( mDownloadJob, TQT_SIGNAL( data( TDEIO::Job *, const TQByteArray & ) ), + TQT_SLOT( slotJobData( TDEIO::Job *, const TQByteArray & ) ) ); + connect( mDownloadJob, TQT_SIGNAL( percent( TDEIO::Job *, unsigned long ) ), + TQT_SLOT( slotJobPercent( TDEIO::Job *, unsigned long ) ) ); + + mProgress = KPIM::ProgressManager::instance()->createProgressItem( + KPIM::ProgressManager::getUniqueID(), i18n("Downloading addressbook") ); + connect( mProgress, + TQT_SIGNAL( progressItemCanceled( KPIM::ProgressItem * ) ), + TQT_SLOT( cancelLoad() ) ); + + return true; +} + +bool ResourceGroupware::save( Ticket *ticket ) +{ + return asyncSave( ticket ); +} + +bool ResourceGroupware::asyncSave( Ticket* ) +{ +#if 0 + if ( !mServer->login() ) return false; + + KABC::Addressee::List::Iterator it; + + KABC::Addressee::List addedList = addedAddressees(); + for ( it = addedList.begin(); it != addedList.end(); ++it ) { + if ( mServer->insertAddressee( mPrefs->writeAddressBook(), *it ) ) { + clearChange( *it ); + idMapper().setRemoteId( (*it).uid(), (*it).custom( "GWRESOURCE", "UID" ) ); + } + } + + KABC::Addressee::List changedList = changedAddressees(); + for ( it = changedList.begin(); it != changedList.end(); ++it ) { + if ( mServer->changeAddressee( *it ) ) + clearChange( *it ); + } + + KABC::Addressee::List deletedList = deletedAddressees(); + for ( it = deletedList.begin(); it != deletedList.end(); ++it ) { + if ( mServer->removeAddressee( *it ) ) + clearChange( *it ); + } + + saveCache(); + + mServer->logout(); +#endif + + return true; +} + +void ResourceGroupware::slotJobResult( TDEIO::Job *job ) +{ + kdDebug() << "ResourceGroupware::slotJobResult(): " << endl; + + if ( job->error() ) { + kdError() << job->errorString() << endl; + emit loadingError( this, job->errorString() ); + } else { + mAddrMap.clear(); + + KABC::VCardConverter conv; + Addressee::List addressees = conv.parseVCards( mJobData ); + Addressee::List::ConstIterator it; + for( it = addressees.begin(); it != addressees.end(); ++it ) { + KABC::Addressee addr = *it; + if ( !addr.isEmpty() ) { + addr.setResource( this ); + + TQString remote = addr.custom( "GWRESOURCE", "UID" ); + TQString local = idMapper().localId( remote ); + if ( local.isEmpty() ) { + idMapper().setRemoteId( addr.uid(), remote ); + } else { + addr.setUid( local ); + } + + insertAddressee( addr ); + clearChange( addr ); + } + } + } + + saveCache(); + + emit loadingFinished( this ); + + mDownloadJob = 0; + if ( mProgress ) mProgress->setComplete(); + mProgress = 0; +} + +void ResourceGroupware::slotJobData( TDEIO::Job *, const TQByteArray &data ) +{ +// kdDebug() << "ResourceGroupware::slotJobData()" << endl; + + mJobData.append( data.data() ); +} + +void ResourceGroupware::slotJobPercent( TDEIO::Job *, unsigned long percent ) +{ + kdDebug() << "ResourceGroupware::slotJobPercent() " << percent << endl; + if ( mProgress ) mProgress->setProgress( percent ); +} + +void ResourceGroupware::cancelLoad() +{ + if ( mDownloadJob ) mDownloadJob->kill(); + mDownloadJob = 0; + if ( mProgress ) mProgress->setComplete(); + mProgress = 0; +} + +#include "kabc_resourcegroupware.moc" diff --git a/tderesources/groupware/tdeabc_resourcegroupware.h b/tderesources/groupware/tdeabc_resourcegroupware.h new file mode 100644 index 000000000..1c5feb847 --- /dev/null +++ b/tderesources/groupware/tdeabc_resourcegroupware.h @@ -0,0 +1,87 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_RESOURCEGROUPWARE_H +#define KABC_RESOURCEGROUPWARE_H + +#include + +#include + +#include + +class TDEConfig; + +namespace KABC { + +class GroupwarePrefs; + +class ResourceGroupware : public ResourceCached +{ + Q_OBJECT + + + public: + ResourceGroupware( const TDEConfig * ); + ResourceGroupware( const KURL &url, + const TQString &user, const TQString &password ); + ~ResourceGroupware(); + + void readConfig( const TDEConfig * ); + void writeConfig( TDEConfig * ); + + void readAddressBooks(); + void writeAddressBooks(); + + void retrieveAddressBooks(); + + GroupwarePrefs *prefs() const { return mPrefs; } + + bool doOpen(); + void doClose(); + + Ticket *requestSaveTicket(); + void releaseSaveTicket( Ticket* ); + + bool load(); + bool asyncLoad(); + bool save( Ticket * ); + bool asyncSave( Ticket * ); + + protected: + void init(); + + private slots: + void slotJobResult( TDEIO::Job * ); + void slotJobData( TDEIO::Job *, const TQByteArray & ); + void slotJobPercent( TDEIO::Job *job, unsigned long percent ); + + void cancelLoad(); + + private: + GroupwarePrefs *mPrefs; + + TDEIO::TransferJob *mDownloadJob; + KPIM::ProgressItem *mProgress; + TQString mJobData; +}; + +} + +#endif diff --git a/tderesources/groupware/tdeabc_resourcegroupware_plugin.cpp b/tderesources/groupware/tdeabc_resourcegroupware_plugin.cpp new file mode 100644 index 000000000..08a415745 --- /dev/null +++ b/tderesources/groupware/tdeabc_resourcegroupware_plugin.cpp @@ -0,0 +1,39 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "kabc_resourcegroupware.h" +#include "kabc_resourcegroupwareconfig.h" + +#include +#include + +using namespace KABC; + +typedef KRES::PluginFactory GroupwareFactory; + +extern "C" +{ + void *init_tdeabc_groupware() + { + TDEGlobal::locale()->insertCatalogue( "libkcal" ); + TDEGlobal::locale()->insertCatalogue( "kres_groupware" ); + return new ResourceGroupware; + } +} diff --git a/tderesources/groupware/tdeabc_resourcegroupwareconfig.cpp b/tderesources/groupware/tdeabc_resourcegroupwareconfig.cpp new file mode 100644 index 000000000..35ca8596f --- /dev/null +++ b/tderesources/groupware/tdeabc_resourcegroupwareconfig.cpp @@ -0,0 +1,208 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "kabc_resourcegroupwareconfig.h" + +#include "kabc_resourcegroupware.h" +#include "kabc_groupwareprefs.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace KABC; + +class AddressBookItem : public TQCheckListItem +{ + public: + AddressBookItem( TDEListView *parent, const TQString &id ) + : TQCheckListItem( parent, "", CheckBox ), + mId( id ) + { + setText( 0, mId ); +#if 0 + if ( ab.isPersonal ) setText( 1, "Yes" ); + else setText( 1, "No" ); + if ( ab.isFrequentContacts ) setText( 2, "Yes" ); + else setText( 2, "No" ); +#endif + } + + TQString id() const { return mId; } + + private: + TQString mId; +}; + +ResourceGroupwareConfig::ResourceGroupwareConfig( TQWidget* parent, const char* name ) + : KRES::ConfigWidget( parent, name ) +{ + TQGridLayout *mainLayout = new TQGridLayout( this, 7, 2, 0, KDialog::spacingHint() ); + + TQLabel *label = new TQLabel( i18n( "URL:" ), this ); + mURL = new KURLRequester( this ); + + mainLayout->addWidget( label, 0, 0 ); + mainLayout->addWidget( mURL, 0, 1 ); + + label = new TQLabel( i18n( "User:" ), this ); + mUser = new KLineEdit( this ); + + mainLayout->addWidget( label, 1, 0 ); + mainLayout->addWidget( mUser, 1, 1 ); + + label = new TQLabel( i18n( "Password:" ), this ); + mPassword = new KLineEdit( this ); + mPassword->setEchoMode( TQLineEdit::Password ); + + mainLayout->addWidget( label, 2, 0 ); + mainLayout->addWidget( mPassword, 2, 1 ); + + TQFrame *hline = new TQFrame( this ); + hline->setFrameStyle( TQFrame::HLine | TQFrame::Sunken ); + + mainLayout->addMultiCellWidget( hline, 3, 3, 0, 1 ); + + TQPushButton *updateButton = new TQPushButton( i18n( "Retrieve Address Book List From Server" ), this ); + mainLayout->addMultiCellWidget( updateButton, 4, 4, 0, 1 ); + + mAddressBookView = new TDEListView( this ); + mAddressBookView->addColumn( i18n( "Address Book" ) ); +#if 0 + mAddressBookView->addColumn( i18n( "Personal" ) ); + mAddressBookView->addColumn( i18n( "Frequent Contacts" ) ); +#endif + mAddressBookView->setFullWidth( true ); + + mainLayout->addMultiCellWidget( mAddressBookView, 5, 5, 0, 1 ); + + label = new TQLabel( i18n( "Address book for new contacts:" ), this ); + mAddressBookBox = new KComboBox( this ); + + mainLayout->addWidget( label, 6, 0 ); + mainLayout->addWidget( mAddressBookBox, 6, 1 ); + + connect( updateButton, TQT_SIGNAL( clicked() ), TQT_SLOT( updateAddressBookList() ) ); +} + +void ResourceGroupwareConfig::loadSettings( KRES::Resource *res ) +{ + mResource = dynamic_cast( res ); + + if ( !mResource ) { + kdDebug(5700) << "ResourceGroupwareConfig::loadSettings(): cast failed" << endl; + return; + } + + mURL->setURL( mResource->prefs()->url() ); + mUser->setText( mResource->prefs()->user() ); + mPassword->setText( mResource->prefs()->password() ); + + updateAddressBookView(); +} + +void ResourceGroupwareConfig::saveSettings( KRES::Resource *res ) +{ + ResourceGroupware *resource = dynamic_cast( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceGroupwareConfig::saveSettings(): cast failed" << endl; + return; + } + + saveServerSettings( resource ); + + saveAddressBookSettings(); +} + +void ResourceGroupwareConfig::saveServerSettings( ResourceGroupware *resource ) +{ + resource->prefs()->setUrl( mURL->url() ); + resource->prefs()->setUser( mUser->text() ); + resource->prefs()->setPassword( mPassword->text() ); +} + +void ResourceGroupwareConfig::updateAddressBookList() +{ + saveServerSettings( mResource ); + + mResource->retrieveAddressBooks(); + + updateAddressBookView(); +} + +void ResourceGroupwareConfig::saveAddressBookSettings() +{ +#if 0 + TQStringList selectedRead; + TQString selectedWrite; + + TQListViewItemIterator it2( mAddressBookView ); + while ( it2.current() ) { + AddressBookItem *item = static_cast( it2.current() ); + if ( item->isOn() ) + selectedRead.append( item->id() ); + + ++it2; + } + + selectedWrite = mWriteAddressBookIds[ mAddressBookBox->currentItem() ]; + + mResource->prefs()->setReadAddressBooks( selectedRead ); + mResource->prefs()->setWriteAddressBook( selectedWrite ); +#endif +} + +void ResourceGroupwareConfig::updateAddressBookView() +{ + if ( mAddressBookBox->count() != 0 ) // we loaded it already + saveAddressBookSettings(); + + mAddressBookView->clear(); + mAddressBookBox->clear(); + mWriteAddressBookIds.clear(); + +#if 0 + TQStringList selectedRead = mResource->prefs()->readAddressBooks(); + + Groupware::AddressBook::List addressBooks = mResource->addressBooks(); + Groupware::AddressBook::List::ConstIterator abIt; + for ( abIt = addressBooks.begin(); abIt != addressBooks.end(); ++abIt ) { + AddressBookItem *item = new AddressBookItem( mAddressBookView, *abIt ); + if ( selectedRead.find( (*abIt).id ) != selectedRead.end() ) + item->setOn( true ); + + mAddressBookBox->insertItem( (*abIt).name ); + mWriteAddressBookIds.append( (*abIt).id ); + } + + int index = mWriteAddressBookIds.findIndex( mResource->prefs()->writeAddressBook() ); + mAddressBookBox->setCurrentItem( index ); +#endif +} + +#include "kabc_resourcegroupwareconfig.moc" diff --git a/tderesources/groupware/tdeabc_resourcegroupwareconfig.h b/tderesources/groupware/tdeabc_resourcegroupwareconfig.h new file mode 100644 index 000000000..c07c4d0b4 --- /dev/null +++ b/tderesources/groupware/tdeabc_resourcegroupwareconfig.h @@ -0,0 +1,71 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_RESOURCEGROUPWARECONFIG_H +#define KABC_RESOURCEGROUPWARECONFIG_H + +#include + +#include + +class KComboBox; +class KLineEdit; +class TDEListView; +class KURLRequester; + +namespace KABC { + +class ResourceGroupware; + +class ResourceGroupwareConfig : public KRES::ConfigWidget +{ + Q_OBJECT + + + public: + ResourceGroupwareConfig( TQWidget* parent = 0, const char* name = 0 ); + + public slots: + void loadSettings( KRES::Resource* ); + void saveSettings( KRES::Resource* ); + + protected slots: + void updateAddressBookList(); + + private: + void updateAddressBookView(); + void saveAddressBookSettings(); + void loadAddressBookSettings(); + void saveServerSettings( ResourceGroupware *resource ); + + KURLRequester *mURL; + KLineEdit *mUser; + KLineEdit *mPassword; + + TDEListView *mAddressBookView; + KComboBox *mAddressBookBox; + + TQStringList mWriteAddressBookIds; + + ResourceGroupware *mResource; +}; + +} + +#endif diff --git a/tderesources/groupware/tderesources_kabc_groupware.kcfg b/tderesources/groupware/tderesources_kabc_groupware.kcfg deleted file mode 100644 index 9beca9c98..000000000 --- a/tderesources/groupware/tderesources_kabc_groupware.kcfg +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/tderesources/groupware/tderesources_tdeabc_groupware.kcfg b/tderesources/groupware/tderesources_tdeabc_groupware.kcfg new file mode 100644 index 000000000..2c6c57dc9 --- /dev/null +++ b/tderesources/groupware/tderesources_tdeabc_groupware.kcfg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/tderesources/groupwise/kabc_groupwise.desktop b/tderesources/groupwise/kabc_groupwise.desktop deleted file mode 100644 index 695ab445b..000000000 --- a/tderesources/groupwise/kabc_groupwise.desktop +++ /dev/null @@ -1,50 +0,0 @@ -[Desktop Entry] -Name=Novell GroupWise Server -Name[af]=Novell GroupWise bediener -Name[bg]=Сървър Novell GroupWise -Name[br]=Servijer Novell GroupWise -Name[ca]=Servidor Novell GroupWise -Name[cs]=Novell GroupWise server -Name[da]=Novell GroupWise server -Name[el]=Εξυπηρετητής Novell GroupWise -Name[es]=Servidor de Novell GroupWise -Name[et]=Novelli GroupWise server -Name[eu]=Novell GroupWise zerbitzaria -Name[fa]=کارساز Novell GroupWise -Name[fi]=Novell GroupWise -palvelin -Name[fr]=Serveur de travail collaboratif GroupWise de Novell -Name[fy]=Novell GroupWise-tsjinner -Name[ga]=Freastalaí Novell GroupWise -Name[gl]=Servidor Novell GroupWise -Name[hu]=Novell GroupWise kiszolgáló -Name[is]=Novell GroupWise þjónn -Name[it]=Server Novell GroupWise -Name[ja]=Novell GroupWise サーバ -Name[ka]=სერვერი Novell GroupWise -Name[kk]=Novell GroupWise сервері -Name[km]=ម៉ាស៊ីន​បម្រើ GroupWise របស់​ណូវែល -Name[lt]=Novell GroupWise serveris -Name[ms]=Pelayan Novell GroupWise -Name[nb]=Novell GroupWise-tjener -Name[nds]=Novell-GroupWise-Server -Name[ne]=नोभेल समूहगत सर्भर -Name[nl]=Novell GroupWise-server -Name[nn]=Novell GroupWise-tenar -Name[pl]=Serwer Novell GroupWise -Name[pt]=Servidor Novell GroupWise -Name[pt_BR]=Servidor GroupWise da Novell -Name[ru]=Сервер Novell GroupWise -Name[sl]=Strežnik Novell GroupWise -Name[sr]=Novell-ов GroupWise сервер -Name[sr@Latn]=Novell-ov GroupWise server -Name[sv]=Novell Groupwise-server -Name[ta]=Novell குழுவாரிச் சேவகன் -Name[tr]=Novell GroupWise Sunucusu -Name[uk]=Сервер Novell GroupWise -Name[zh_CN]=Novell GroupWise 服务器 -Name[zh_TW]=Novell 群組伺服器 -X-TDE-Library=kabc_groupwise -Type=Service -ServiceTypes=KResources/Plugin -X-TDE-ResourceFamily=contact -X-TDE-ResourceType=groupwise diff --git a/tderesources/groupwise/kabc_groupwiseprefs.kcfgc b/tderesources/groupwise/kabc_groupwiseprefs.kcfgc deleted file mode 100644 index 08e997f64..000000000 --- a/tderesources/groupwise/kabc_groupwiseprefs.kcfgc +++ /dev/null @@ -1,8 +0,0 @@ -ClassName=GroupwisePrefs -File=tderesources_kabc_groupwise.kcfg -GlobalEnums=true -IncludeFiles=libtdepim/kresourceprefs.h -Inherits=KResourcePrefs -Mutators=true -NameSpace=KABC -Singleton=false diff --git a/tderesources/groupwise/kabc_resourcegroupwise.cpp b/tderesources/groupwise/kabc_resourcegroupwise.cpp deleted file mode 100644 index 8499aa9ff..000000000 --- a/tderesources/groupwise/kabc_resourcegroupwise.cpp +++ /dev/null @@ -1,743 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include - -#include -#include -#include -#include -#include - -#include "kabc_groupwiseprefs.h" - -#include "kabc_resourcegroupwise.h" - -using namespace KABC; - -ResourceGroupwise::ResourceGroupwise( const TDEConfig *config ) - : ResourceCached( config ) -{ - init(); - - mPrefs->addGroupPrefix( identifier() ); - - if ( config ) { - readConfig( config ); - } - initGroupwise(); -} - -ResourceGroupwise::ResourceGroupwise( const KURL &url, - const TQString &user, - const TQString &password, - const TQStringList &readAddressBooks, - const TQString &writeAddressBook ) - : ResourceCached( 0 ) -{ - init(); - - mPrefs->addGroupPrefix( identifier() ); - - mPrefs->setUrl( url.url() ); - mPrefs->setUser( user ); - mPrefs->setPassword( password ); - mPrefs->setReadAddressBooks( readAddressBooks ); - mPrefs->setWriteAddressBook( writeAddressBook ); - - initGroupwise(); -} - -void ResourceGroupwise::init() -{ - mJob = 0; - mProgress = 0; - mSABProgress = 0; - mUABProgress = 0; - mServerFirstSequence = 0; - mServerLastSequence = 0; - mServerLastPORebuildTime = 0; - mPrefs = new GroupwisePrefs; - mState = Start; - setType( "groupwise" ); -} - -void ResourceGroupwise::initGroupwise() -{ - mServer = new GroupwiseServer( mPrefs->url(), mPrefs->user(), - mPrefs->password(), this ); -} - -ResourceGroupwise::~ResourceGroupwise() -{ - delete mServer; - mServer = 0; - - delete mPrefs; - mPrefs = 0; -} - -void ResourceGroupwise::readConfig( const TDEConfig * ) -{ - mPrefs->readConfig(); - - readAddressBooks(); -} - -void ResourceGroupwise::writeConfig( TDEConfig *config ) -{ - Resource::writeConfig( config ); - - writeAddressBooks(); - - mPrefs->writeConfig(); -} - -void ResourceGroupwise::clearCache() -{ - idMapper().clear(); - mAddrMap.clear(); - TQFile file( cacheFile() ); - file.remove(); -} - -void ResourceGroupwise::readAddressBooks() -{ - TQStringList ids = prefs()->ids(); - TQStringList names = prefs()->names(); - TQStringList personals = prefs()->personals(); - TQStringList frequents = prefs()->frequents(); - - if ( ids.count() != names.count() || ids.count() != personals.count() || - ids.count() != frequents.count() ) { - kdError() << "Corrupt addressbook configuration" << endl; - return; - } - - mAddressBooks.clear(); - - for( uint i = 0; i < ids.count(); ++i ) { - GroupWise::AddressBook ab; - ab.id = ids[ i ]; - ab.name = names[ i ]; - ab.isPersonal = personals[ i ] == "1"; - ab.isFrequentContacts = frequents[ i ] == "1"; - - mAddressBooks.append( ab ); - } -} - -void ResourceGroupwise::writeAddressBooks() -{ - TQStringList ids; - TQStringList names; - TQStringList personals; - TQStringList frequents; - GroupWise::AddressBook::List::ConstIterator it; - for( it = mAddressBooks.begin(); it != mAddressBooks.end(); ++it ) { - ids.append( (*it).id ); - names.append( (*it).name ); - personals.append( (*it).isPersonal ? "1" : "0" ); - frequents.append( (*it).isFrequentContacts ? "1" : "0" ); - } - prefs()->setIds( ids ); - prefs()->setNames( names ); - prefs()->setPersonals( personals ); - prefs()->setFrequents( frequents ); -} - -void ResourceGroupwise::retrieveAddressBooks() -{ - bool firstRetrieve = mAddressBooks.isEmpty(); - - GroupwiseServer server( prefs()->url(), - prefs()->user(), - prefs()->password(), this ); - - if ( server.login() ) - { - mAddressBooks = server.addressBookList(); - server.logout(); - - TQStringList reads; - TQString write; - - GroupWise::AddressBook::List::ConstIterator it; - for( it = mAddressBooks.begin(); it != mAddressBooks.end(); ++it ) { - reads.append( (*it).id ); - if ( (*it).isPersonal ) { - if ( write.isEmpty() ) write = (*it).id; - } - else - prefs()->setSystemAddressBook( (*it).id ); - } - - if ( firstRetrieve ) { - prefs()->setReadAddressBooks( reads ); - prefs()->setWriteAddressBook( write ); - } - } - else - emit loadingError( this, server.errorText() ); -} - -Ticket *ResourceGroupwise::requestSaveTicket() -{ - if ( !addressBook() ) { - kdDebug(5700) << "no addressbook" << endl; - return 0; - } - - return createTicket( this ); -} - -void ResourceGroupwise::releaseSaveTicket( Ticket *ticket ) -{ - delete ticket; -} - -bool ResourceGroupwise::doOpen() -{ - return true; -} - -void ResourceGroupwise::doClose() -{ - kdDebug() << "ResourceGroupwise::doClose()" << endl; - - cancelLoad(); -} - -bool ResourceGroupwise::save( Ticket *ticket ) -{ - return asyncSave( ticket ); -} - -bool ResourceGroupwise::asyncSave( Ticket* ) -{ - if ( !mServer->login() ) return false; - - KABC::Addressee::List::Iterator it; - - KABC::Addressee::List addedList = addedAddressees(); - for ( it = addedList.begin(); it != addedList.end(); ++it ) { - if ( mServer->insertAddressee( mPrefs->writeAddressBook(), *it ) ) { - clearChange( *it ); - idMapper().setRemoteId( (*it).uid(), (*it).custom( "GWRESOURCE", "UID" ) ); - } - } - - KABC::Addressee::List changedList = changedAddressees(); - for ( it = changedList.begin(); it != changedList.end(); ++it ) { - if ( mServer->changeAddressee( *it ) ) - clearChange( *it ); - } - - KABC::Addressee::List deletedList = deletedAddressees(); - for ( it = deletedList.begin(); it != deletedList.end(); ++it ) { - if ( mServer->removeAddressee( *it ) ) - clearChange( *it ); - } - - if ( appIsWhiteListedForSAB() ) - saveCache(); - - mServer->logout(); - - return true; -} - -bool ResourceGroupwise::load() -{ - return asyncLoad(); -} - -bool ResourceGroupwise::asyncLoad() -{ - kdDebug() << "ResourceGroupwise::asyncLoad()" << endl; - //mPrefs->readConfig(); TODO: remove if the system addressbook is not read when disabled in config - - if ( mState != Start ) - { - kdDebug() << " Download still in progress" << endl; - return true; - } - - if ( appIsWhiteListedForSAB() ) - loadCache(); - - if ( !mProgress ) - { - mProgress = KPIM::ProgressManager::instance()->createProgressItem( - KPIM::ProgressManager::getUniqueID(), i18n( "Loading GroupWise resource %1" ).arg( resourceName() ), TQString(), true /*CanBeCancelled*/, mPrefs->url().startsWith("https" ) ); - connect( mProgress, TQT_SIGNAL( progressItemCanceled( KPIM::ProgressItem * ) ), - TQT_SLOT( cancelLoad() ) ); - } - - if ( addressBooks().isEmpty() ) { - kdDebug() << " Retrieving default addressbook list." << endl; - retrieveAddressBooks(); - writeAddressBooks(); - } - - SABState sabState = systemAddressBookState(); - if ( shouldFetchSystemAddressBook() ) - { - if ( sabState == RefreshNeeded ) - { - kdDebug() << " Fetching system addressbook" << endl; - fetchAddressBooks( System ); - return true; - } - else if ( sabState == Stale ) - { - kdDebug() << " Updating system addressbook" << endl; - updateSystemAddressBook(); // we then fetch the user address books after doing this - return true; - } - } - else if ( shouldFetchUserAddressBooks() ) - { - kdDebug() << " Fetching user addressbook" << endl; - fetchAddressBooks( User ); - return true; - } - return true; -} - -void ResourceGroupwise::fetchAddressBooks( const BookType bookType ) -{ - KURL url = createAccessUrl( bookType, Fetch ); - if ( !url.isValid() ) - return; - - kdDebug() << k_funcinfo << ( bookType == System ? " System" : " User" ) << " URL: " << url << endl; - // sanity check - if ( bookType == User && !( mState == SABUptodate || mState == Start ) ) - { - kdDebug() << " **ERROR** - fetchAddressBooks( User ) called when SAB not up to date" << endl; - return; - } - - mState = ( bookType == System ? FetchingSAB : FetchingUAB ); - mJobData = TQString(); - - if ( mJob ) - { - kdDebug() << " **ERROR** - fetchAddressBooks() called when a job was already running!" << endl; - return; - } - - mJob = TDEIO::get( url, false, false ); // TODO: make the GW jobs call finished if the URL - // contains no address book IDs - kdDebug() << " Job address: " << mJob << endl; - connect( mJob, TQT_SIGNAL( data( TDEIO::Job *, const TQByteArray & ) ), - TQT_SLOT( slotReadJobData( TDEIO::Job *, const TQByteArray & ) ) ); - connect( mJob, TQT_SIGNAL( percent( TDEIO::Job *, unsigned long ) ), - TQT_SLOT( slotJobPercent( TDEIO::Job *, unsigned long ) ) ); - - if ( bookType == System ) - { - connect( mJob, TQT_SIGNAL( result( TDEIO::Job * ) ), - TQT_SLOT( fetchSABResult( TDEIO::Job * ) ) ); - mSABProgress = KPIM::ProgressManager::instance()->createProgressItem( - mProgress, KPIM::ProgressManager::getUniqueID(), - i18n( "Fetching System Address Book" ), TQString(), - false /*CannotBeCancelled*/, - mPrefs->url().startsWith("https" ) ); - } - else - { - connect( mJob, TQT_SIGNAL( result( TDEIO::Job * ) ), - TQT_SLOT( fetchUABResult( TDEIO::Job * ) ) ); - mUABProgress = KPIM::ProgressManager::instance()->createProgressItem( - mProgress, KPIM::ProgressManager::getUniqueID(), - i18n( "Fetching User Address Books" ), TQString(), - false /*CannotBeCancelled*/, - mPrefs->url().startsWith("https" ) ); - } - - return; -} - -void ResourceGroupwise::fetchSABResult( TDEIO::Job *job ) -{ - kdDebug() << "ResourceGroupwise::fetchSABResult() " << endl; - - if ( job->error() ) { - kdError() << job->errorString() << endl; - emit loadingError( this, job->errorString() ); - // TODO kill the rest of the load sequence as well - } - - mJob->disconnect( this ); - mJob = 0; - mState = SABUptodate; - if ( mSABProgress ) - mSABProgress->setComplete(); - - storeDeltaInfo(); - - if ( shouldFetchUserAddressBooks() ) - fetchAddressBooks( User ); - else - loadCompleted(); -} - -void ResourceGroupwise::fetchUABResult( TDEIO::Job *job ) -{ - kdDebug() << "ResourceGroupwise::fetchUABResult() " << endl; - - if ( job->error() ) { - kdError() << job->errorString() << endl; - emit loadingError( this, job->errorString() ); - } - - mJob->disconnect( this ); - mJob = 0; - mState = Uptodate; - if ( mUABProgress ) - mUABProgress->setComplete(); - loadCompleted(); -} - -void ResourceGroupwise::updateSystemAddressBook() -{ - kdDebug() << "ResourceGroupwise::updateSystemAddressBook()" << endl; - - if ( mState != Start ) { - kdWarning() << " Action already in progress" << endl; - return; - } - - if ( addressBooks().isEmpty() ) { - kdDebug() << " Retrieving default addressbook list." << endl; - retrieveAddressBooks(); - writeAddressBooks(); - } - - KURL url = createAccessUrl( System, Update, mPrefs->lastSequenceNumber(), mPrefs->lastTimePORebuild() ); - kdDebug() << " Update URL: " << url << endl; - - mJobData = TQString(); - mSABProgress = KPIM::ProgressManager::instance()->createProgressItem( - mProgress, KPIM::ProgressManager::getUniqueID(), - i18n( "Updating System Address Book" ), TQString(), - false /*CannotBeCancelled*/, - mPrefs->url().startsWith("https" ) ); - - mJob = TDEIO::get( url, false, false ); - mJob->setInteractive( false ); - connect( mJob, TQT_SIGNAL( result( TDEIO::Job * ) ), - TQT_SLOT( updateSABResult( TDEIO::Job * ) ) ); - connect( mJob, TQT_SIGNAL( data( TDEIO::Job *, const TQByteArray & ) ), - TQT_SLOT( slotUpdateJobData( TDEIO::Job *, const TQByteArray & ) ) ); - connect( mJob, TQT_SIGNAL( percent( TDEIO::Job *, unsigned long ) ), - TQT_SLOT( slotJobPercent( TDEIO::Job *, unsigned long ) ) ); - - return; -} - -void ResourceGroupwise::updateSABResult( TDEIO::Job *job ) -{ - kdDebug() << "ResourceGroupwise::updateSABResult() " << endl; - - mSABProgress->setComplete(); - mSABProgress = 0; - mJob->disconnect( this ); - mJob = 0; - - int errorCode = job->error(); - if ( errorCode != 0 ) { - if ( errorCode == TDEIO::ERR_NO_CONTENT ) // we need to refresh the SAB - { - kdDebug() << " update SAB failed, fetching all of it again" << endl; - mPrefs->setLastSequenceNumber( 0 ); - mPrefs->setFirstSequenceNumber( 0 ); - fetchAddressBooks( System ); - return; - } - } - - mState = SABUptodate; - storeDeltaInfo(); - - if ( shouldFetchUserAddressBooks() ) - fetchAddressBooks( User ); - else - loadCompleted(); -} - -void ResourceGroupwise::slotReadJobData( TDEIO::Job *job , const TQByteArray &data ) -{ - kdDebug() << "ResourceGroupwise::slotReadJobData()" << endl; - Q_UNUSED( job ); - - mJobData.append( data.data() ); - - KABC::VCardConverter conv; - TQTime profile; - profile.start(); - Addressee::List addressees = conv.parseVCards( mJobData ); - // kdDebug() << " parsed " << addressees.count() << " contacts in " << profile.elapsed() << "ms, now adding to resource..." << endl; - - Addressee::List::ConstIterator it; - for( it = addressees.begin(); it != addressees.end(); ++it ) { - KABC::Addressee addr = *it; - if ( !addr.isEmpty() ) { - addr.setResource( this ); - - TQString remote = addr.custom( "GWRESOURCE", "UID" ); - TQString local = idMapper().localId( remote ); - if ( local.isEmpty() ) { - idMapper().setRemoteId( addr.uid(), remote ); - } else { - addr.setUid( local ); - } - - insertAddressee( addr ); - clearChange( addr ); - } - } - mJobData = TQString(); -} - -void ResourceGroupwise::slotUpdateJobData( TDEIO::Job *job, const TQByteArray &data ) -{ - kdDebug() << "ResourceGroupwise::slotUpdateJobData()" << endl; - kdDebug() << " Job address: " << job << endl; - KABC::VCardConverter conv; - mJobData.append( data.data() ); - - Addressee::List addressees = conv.parseVCards( mJobData ); - Addressee::List::ConstIterator it; - - for( it = addressees.begin(); it != addressees.end(); ++it ) { - KABC::Addressee addr = *it; - if ( !addr.isEmpty() ) { - // if added or changed - TQString syncType = addr.custom( "GWRESOURCE", "SYNC" ); - TQString remote = addr.custom( "GWRESOURCE", "UID" ); - TQString local = idMapper().localId( remote ); - - if ( syncType == "ADD" || syncType == "UPD" ) - { - addr.setResource( this ); - if ( local.isEmpty() ) { - idMapper().setRemoteId( addr.uid(), remote ); - } else { - addr.setUid( local ); - } - - insertAddressee( addr ); - clearChange( addr ); - } - else if ( syncType == "DEL" ) - { - // if deleted - if ( !remote.isEmpty() ) - { - if ( !local.isEmpty() ) - { - idMapper().removeRemoteId( remote ); - KABC::Addressee addrToDelete = findByUid( local ); - removeAddressee( addrToDelete ); - } - } - else - kdError() << "Addressee to delete did not have a remote UID, unable to find the corresponding local contact" << endl; - } - } - } - mJobData = TQString(); -} - -void ResourceGroupwise::loadCompleted() -{ - kdDebug() << "ResourceGroupwise::loadCompleted()" << endl; - if ( mProgress ) - mProgress->setComplete(); - mProgress = 0; - mSABProgress = 0; - mUABProgress = 0; - mState = Start; - if ( appIsWhiteListedForSAB() ) - saveCache(); - emit loadingFinished( this ); - addressBook()->emitAddressBookChanged(); -} - -void ResourceGroupwise::slotJobPercent( TDEIO::Job *, unsigned long percent ) -{ - // TODO: make this act on the correct progress item - kdDebug() << "ResourceGroupwise::slotJobPercent() " << percent << endl; - if ( mProgress ) mProgress->setProgress( percent ); -} - -void ResourceGroupwise::cancelLoad() -{ - if ( mJob ) - { - mJob->disconnect( this ); - mJob->kill(); - } - mJob = 0; - if ( mProgress ) mProgress->setComplete(); - mProgress = 0; - mState = Start; -} - -ResourceGroupwise::SABState ResourceGroupwise::systemAddressBookState() -{ - unsigned long storedFirstSequence = mPrefs->firstSequenceNumber(); - unsigned long storedLastSequence = mPrefs->lastSequenceNumber(); - unsigned long storedLastPORebuildTime = mPrefs->lastTimePORebuild(); - - kdDebug() << "ResourceGroupwise::systemAddressBookState()" << endl; - kdDebug() << " Stored first seq no: " << storedFirstSequence << endl; - kdDebug() << " Stored last seq no: " << storedLastSequence << endl; - kdDebug() << " Stored last PO Rebuild time: " << storedLastPORebuildTime << endl; - - kdDebug() << " Fetching delta info to check if update possible" << endl; - if ( mServer->login() ) - { - GroupWise::DeltaInfo deltaInfo = mServer->getDeltaInfo( mPrefs->systemAddressBook() ); - mServer->logout(); - - mServerFirstSequence = deltaInfo.firstSequence; - mServerLastSequence = deltaInfo.lastSequence; - mServerLastPORebuildTime = deltaInfo.lastTimePORebuild; - - kdDebug() << " Server first seq no: " << mServerFirstSequence << endl; - kdDebug() << " Server last seq no: " << mServerLastSequence << endl; - kdDebug() << " Server last PO Rebuild time: " << mServerLastPORebuildTime << endl; - - if ( storedFirstSequence == 0 || storedLastSequence == 0 ) - { - kdDebug() << " no fetched SAB exists yet, can't update" << endl; - return RefreshNeeded; - } - - if ( mServerFirstSequence > storedLastSequence || storedLastPORebuildTime != mServerLastPORebuildTime) - { - kdDebug() << " New entries since the last fetch are no longer available as deltas, or the PO was rebuilt, refresh needed" << endl; - return RefreshNeeded; - } - - if ( mServerLastSequence == storedLastSequence ) - { - kdDebug() << " The local data is up to date" << endl; - return InSync; - } - } - else - emit loadingError( this, mServer->errorText() ); - - if ( storedFirstSequence == 0 || storedLastSequence == 0 ) - { - kdDebug() << " Fallthrough - no fetched SAB exists yet, refresh" << endl; - return RefreshNeeded; - } - else - kdDebug() << " Fallthrough - returning Stale" << endl; - return Stale; -} - -bool ResourceGroupwise::shouldFetchSystemAddressBook() -{ - - TQStringList ids = mPrefs->readAddressBooks(); - return ( appIsWhiteListedForSAB() && ids.find( mPrefs->systemAddressBook() ) != ids.end() ); -} - -bool ResourceGroupwise::shouldFetchUserAddressBooks() -{ - TQStringList ids = mPrefs->readAddressBooks(); - return ( ids.count() > 1 || ids.find( mPrefs->systemAddressBook() ) == ids.end() ); -} - -KURL ResourceGroupwise::createAccessUrl( BookType bookType, AccessMode mode, unsigned long lastSequenceNumber, unsigned long lastPORebuildTime ) -{ - // set up list of address book IDs to fetch - TQStringList ids; - if ( bookType == System ) - ids.append( mPrefs->systemAddressBook() ); - else - { - ids = mPrefs->readAddressBooks(); - ids.remove( mPrefs->systemAddressBook() ); - } - - if ( ids.isEmpty() ) - return KURL(); - - KURL url( prefs()->url() ); - if ( url.protocol() == "http" ) - url.setProtocol( "groupwise" ); - else - url.setProtocol( "groupwises" ); - - url.setPath( url.path() + "/addressbook/" ); - url.setUser( prefs()->user() ); - url.setPass( prefs()->password() ); - - TQString query = "?"; - TQStringList::ConstIterator it; - for( it = ids.begin(); it != ids.end(); ++it ) { - if ( it != ids.begin() ) query += "&"; - query += "addressbookid=" + *it; - } - - if ( mode == Update && lastSequenceNumber > 0 && lastPORebuildTime > 0 ) - { - query += TQString::fromLatin1( "&update=true&lastSeqNo=%1&PORebuildTime=%2" ).arg( lastSequenceNumber ).arg( lastPORebuildTime );; - } - url.setQuery( query ); - return url; -} - -void ResourceGroupwise::storeDeltaInfo() -{ - // update SAB delta info - kdDebug() << "ResourceGroupwise::storeDeltaInfo()" << endl; - kdDebug() << " Server first seq no: " << mServerFirstSequence << endl; - kdDebug() << " Server last seq no: " << mServerLastSequence << endl; - kdDebug() << " Server last PO Rebuild time: " << mServerLastPORebuildTime << endl; - - if ( mServerFirstSequence == 0 || mServerLastSequence == 0 || mServerLastPORebuildTime == 0 ) - return; - mPrefs->setFirstSequenceNumber( mServerFirstSequence ); - mPrefs->setLastSequenceNumber( mServerLastSequence ); - mPrefs->setLastTimePORebuild( mServerLastPORebuildTime ); - mPrefs->writeConfig(); -} - -bool ResourceGroupwise::appIsWhiteListedForSAB() -{ - if ( !mPrefs->systemAddressBookWhiteList().contains( tqApp->argv()[ 0 ] ) ) - { - kdDebug() << "Application " << tqApp->argv()[ 0 ] << " is _blacklisted_ to load the SAB" << endl; - return false; - } - return true; -} - -#include "kabc_resourcegroupwise.moc" diff --git a/tderesources/groupwise/kabc_resourcegroupwise.h b/tderesources/groupwise/kabc_resourcegroupwise.h deleted file mode 100644 index 0c7533eef..000000000 --- a/tderesources/groupwise/kabc_resourcegroupwise.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#ifndef KABC_RESOURCEGROUPWISE_H -#define KABC_RESOURCEGROUPWISE_H - -#include "soap/groupwiseserver.h" - -#include -#include - -#include - -#include - -class TDEConfig; - -class GroupwiseServer; - -namespace KABC { - -class GroupwisePrefs; - -class KDE_EXPORT ResourceGroupwise : public ResourceCached -{ - friend class ResourceGroupwiseConfig; - - Q_OBJECT - - - public: - ResourceGroupwise( const TDEConfig * ); - ResourceGroupwise( const KURL &url, - const TQString &user, const TQString &password, - const TQStringList &readAddressBooks, - const TQString &writeAddressBook ); - ~ResourceGroupwise(); - - void readConfig( const TDEConfig * ); - void writeConfig( TDEConfig * ); - - void readAddressBooks(); - void writeAddressBooks(); - - void retrieveAddressBooks(); - - GroupwisePrefs *prefs() const { return mPrefs; } - - GroupWise::AddressBook::List addressBooks() const { return mAddressBooks; } - - bool doOpen(); - void doClose(); - - Ticket *requestSaveTicket(); - void releaseSaveTicket( Ticket* ); - - bool load(); - bool asyncLoad(); - bool save( Ticket * ); - bool asyncSave( Ticket * ); - enum SABState { Error, Stale, InSync, RefreshNeeded }; - - /** - * Clears the cached data, in memory and on disk - */ - void clearCache(); - protected: - enum ResourceState { Start, FetchingSAB, SABUptodate, FetchingUAB, Uptodate }; - enum BookType { System, User }; - enum AccessMode { Fetch, Update }; - void init(); - void initGroupwise(); - - /* STATE CHANGING METHODS */ - /** - * Begin asynchronously fetching the system address book , replacing the cached copy - */ - void fetchAddressBooks( const BookType booktype ); - /** - * Asynchronously update the system address book - */ - void updateSystemAddressBook(); - /** - * Wrap up the load sequence - */ - void loadCompleted(); - - /** HELPER METHODS **/ - /** - * Check to see if a local download of the SAB already exists - */ - SABState systemAddressBookState(); - /** - * Check if the resource is configured to download the SAB - */ - bool shouldFetchSystemAddressBook(); - /** - * Check if the resource is configured to download personal address - * books - */ - bool shouldFetchUserAddressBooks(); - - /** - * Create a URL for a single addressbook access. - * To fetch an address book completely, use mode = Fetch - * To just update an addressbook, use mode = Update and give the ast sequence number already held - * If Update is given without a sequence number, the mode falls back to Fetch - */ - KURL createAccessUrl( BookType bookType, AccessMode mode, unsigned long lastSequenceNumber = 0, unsigned long lastPORebuildTime = 0 ); - - /** - * Persist the last known delta info. Call after the SAB is up to date. - */ - void storeDeltaInfo(); - - /** - * Check if the application which has loaded this resource is whitelisted - * to load the System Address Book (time-consuming) - */ - bool appIsWhiteListedForSAB(); - - private slots: - /** STATE CHANGING SLOTS **/ - void fetchSABResult( TDEIO::Job * ); - void fetchUABResult( TDEIO::Job * ); - void updateSABResult( TDEIO::Job * ); - /** DATA PROCESSING SLOTS **/ - void slotReadJobData( TDEIO::Job *, const TQByteArray & ); - void slotUpdateJobData( TDEIO::Job *, const TQByteArray & ); - /** HELPER TQT_SLOT **/ - void slotJobPercent( TDEIO::Job *job, unsigned long percent ); - - void cancelLoad(); - private: - GroupwisePrefs *mPrefs; - GroupWise::AddressBook::List mAddressBooks; - - GroupwiseServer *mServer; - - TDEIO::TransferJob *mJob; - KPIM::ProgressItem *mProgress; - KPIM::ProgressItem *mSABProgress; - KPIM::ProgressItem *mUABProgress; - TQString mJobData; - ResourceState mState; - unsigned long mServerFirstSequence, mServerLastSequence, mServerLastPORebuildTime; - - bool mLimitedMode; -}; - -} - -#endif diff --git a/tderesources/groupwise/kabc_resourcegroupwise_plugin.cpp b/tderesources/groupwise/kabc_resourcegroupwise_plugin.cpp deleted file mode 100644 index e71a66e5e..000000000 --- a/tderesources/groupwise/kabc_resourcegroupwise_plugin.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "kabc_resourcegroupwise.h" -#include "kabc_resourcegroupwiseconfig.h" - -#include -#include - -using namespace KABC; - -typedef KRES::PluginFactory GroupwiseFactory; -// FIXME: Use K_EXPORT_COMPONENT_FACTORY( kabc_groupwise, GroupwiseFactory ); here -// Problem: How do I insert the catalogue??? -extern "C" -{ - void *init_kabc_groupwise() - { - TDEGlobal::locale()->insertCatalogue( "libkcal" ); - TDEGlobal::locale()->insertCatalogue( "kres_groupwise" ); - return new GroupwiseFactory; - } -} diff --git a/tderesources/groupwise/kabc_resourcegroupwiseconfig.cpp b/tderesources/groupwise/kabc_resourcegroupwiseconfig.cpp deleted file mode 100644 index 1212a6bc5..000000000 --- a/tderesources/groupwise/kabc_resourcegroupwiseconfig.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "kabc_resourcegroupwiseconfig.h" - -#include "kabc_resourcegroupwise.h" -#include "kabc_groupwiseprefs.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -using namespace KABC; - -class AddressBookItem : public TQCheckListItem -{ - public: - AddressBookItem( TDEListView *parent, GroupWise::AddressBook ab ) - : TQCheckListItem( parent, "", CheckBox ), - mId( ab.id ) - { - setText( 0, ab.name ); - if ( ab.isPersonal ) setText( 1, i18n("Yes") ); - else setText( 1, i18n("No") ); - if ( ab.isFrequentContacts ) setText( 2, i18n("Yes") ); - else setText( 2, i18n("No") ); - } - - TQString id() const { return mId; } - - private: - TQString mId; -}; - -ResourceGroupwiseConfig::ResourceGroupwiseConfig( TQWidget* parent, const char* name ) - : KRES::ConfigWidget( parent, name ) -{ - TQGridLayout *mainLayout = new TQGridLayout( this, 7, 2, 0, KDialog::spacingHint() ); - - TQLabel *label = new TQLabel( i18n( "URL:" ), this ); - mURL = new KURLRequester( this ); - - mainLayout->addWidget( label, 0, 0 ); - mainLayout->addWidget( mURL, 0, 1 ); - - label = new TQLabel( i18n( "User:" ), this ); - mUser = new KLineEdit( this ); - - mainLayout->addWidget( label, 1, 0 ); - mainLayout->addWidget( mUser, 1, 1 ); - - label = new TQLabel( i18n( "Password:" ), this ); - mPassword = new KLineEdit( this ); - mPassword->setEchoMode( TQLineEdit::Password ); - - mainLayout->addWidget( label, 2, 0 ); - mainLayout->addWidget( mPassword, 2, 1 ); - - TQFrame *hline = new TQFrame( this ); - hline->setFrameStyle( TQFrame::HLine | TQFrame::Sunken ); - - mainLayout->addMultiCellWidget( hline, 3, 3, 0, 1 ); - - TQPushButton *updateButton = new TQPushButton( i18n( "Retrieve Address Book List From Server" ), this ); - mainLayout->addMultiCellWidget( updateButton, 4, 4, 0, 1 ); - - mAddressBookView = new TDEListView( this ); - mAddressBookView->addColumn( i18n( "Address Book" ) ); - mAddressBookView->addColumn( i18n( "Personal" ) ); - mAddressBookView->addColumn( i18n( "Frequent Contacts" ) ); - mAddressBookView->setFullWidth( true ); - - mainLayout->addMultiCellWidget( mAddressBookView, 5, 5, 0, 1 ); - - label = new TQLabel( i18n( "Address book for new contacts:" ), this ); - mAddressBookBox = new KComboBox( this ); - - mainLayout->addWidget( label, 6, 0 ); - mainLayout->addWidget( mAddressBookBox, 6, 1 ); - - connect( updateButton, TQT_SIGNAL( clicked() ), TQT_SLOT( updateAddressBookList() ) ); -} - -void ResourceGroupwiseConfig::loadSettings( KRES::Resource *res ) -{ - mResource = dynamic_cast( res ); - - if ( !mResource ) { - kdDebug(5700) << "ResourceGroupwiseConfig::loadSettings(): cast failed" << endl; - return; - } - - mURL->setURL( mResource->prefs()->url() ); - mUser->setText( mResource->prefs()->user() ); - mPassword->setText( mResource->prefs()->password() ); - mReadAddressBookIds = mResource->prefs()->readAddressBooks(); - updateAddressBookView(); -} - -void ResourceGroupwiseConfig::saveSettings( KRES::Resource *res ) -{ - ResourceGroupwise *resource = dynamic_cast( res ); - - if ( !resource ) { - kdDebug(5700) << "ResourceGroupwiseConfig::saveSettings(): cast failed" << endl; - return; - } - - saveServerSettings( resource ); - - saveAddressBookSettings(); -} - -void ResourceGroupwiseConfig::saveServerSettings( ResourceGroupwise *resource ) -{ - resource->prefs()->setUrl( mURL->url() ); - resource->prefs()->setUser( mUser->text() ); - resource->prefs()->setPassword( mPassword->text() ); -} - -void ResourceGroupwiseConfig::updateAddressBookList() -{ - saveServerSettings( mResource ); - - mResource->retrieveAddressBooks(); - - updateAddressBookView(); -} - -void ResourceGroupwiseConfig::saveAddressBookSettings() -{ - TQStringList selectedRead; - TQString selectedWrite; - - TQListViewItemIterator it2( mAddressBookView ); - while ( it2.current() ) { - AddressBookItem *item = static_cast( it2.current() ); - if ( item->isOn() ) - selectedRead.append( item->id() ); - - ++it2; - } - // check if the SAB was selected when the settings were loaded and is not selected now, - // if so, clear the resource to clear the SAB data that is no longer required. - // also, set the sequence numbers to 0 so that we know the SAB should be re-fetched in its entirety the next time we do load it - TQString sab = mResource->prefs()->systemAddressBook(); - if ( ( mReadAddressBookIds.find( sab ) != mReadAddressBookIds.end() ) && ( selectedRead.find( sab ) == selectedRead.end() ) ) - { - mResource->clearCache(); - mResource->prefs()->setLastSequenceNumber( 0 ); - mResource->prefs()->setFirstSequenceNumber( 0 ); - } - selectedWrite = mWriteAddressBookIds[ mAddressBookBox->currentItem() ]; - - mResource->prefs()->setReadAddressBooks( selectedRead ); - mResource->prefs()->setWriteAddressBook( selectedWrite ); -} - -void ResourceGroupwiseConfig::updateAddressBookView() -{ - if ( mAddressBookBox->count() != 0 ) // we loaded it already - saveAddressBookSettings(); - - mAddressBookView->clear(); - mAddressBookBox->clear(); - mWriteAddressBookIds.clear(); - - TQStringList selectedRead = mResource->prefs()->readAddressBooks(); - - GroupWise::AddressBook::List addressBooks = mResource->addressBooks(); - GroupWise::AddressBook::List::ConstIterator abIt; - for ( abIt = addressBooks.begin(); abIt != addressBooks.end(); ++abIt ) { - AddressBookItem *item = new AddressBookItem( mAddressBookView, *abIt ); - if ( selectedRead.find( (*abIt).id ) != selectedRead.end() ) - item->setOn( true ); - - mAddressBookBox->insertItem( (*abIt).name ); - mWriteAddressBookIds.append( (*abIt).id ); - } - - int index = mWriteAddressBookIds.findIndex( mResource->prefs()->writeAddressBook() ); - mAddressBookBox->setCurrentItem( index ); -} - -#include "kabc_resourcegroupwiseconfig.moc" diff --git a/tderesources/groupwise/kabc_resourcegroupwiseconfig.h b/tderesources/groupwise/kabc_resourcegroupwiseconfig.h deleted file mode 100644 index eb54803c0..000000000 --- a/tderesources/groupwise/kabc_resourcegroupwiseconfig.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#ifndef KABC_RESOURCEGROUPWISECONFIG_H -#define KABC_RESOURCEGROUPWISECONFIG_H - -#include "soap/groupwiseserver.h" - -#include -#include - -#include - -class KComboBox; -class KLineEdit; -class TDEListView; -class KURLRequester; - -namespace KABC { - -class ResourceGroupwise; - -class KDE_EXPORT ResourceGroupwiseConfig : public KRES::ConfigWidget -{ - Q_OBJECT - - - public: - ResourceGroupwiseConfig( TQWidget* parent = 0, const char* name = 0 ); - - public slots: - void loadSettings( KRES::Resource* ); - void saveSettings( KRES::Resource* ); - - protected slots: - void updateAddressBookList(); - - private: - void updateAddressBookView(); - void saveAddressBookSettings(); - void loadAddressBookSettings(); - void saveServerSettings( ResourceGroupwise *resource ); - - KURLRequester *mURL; - KLineEdit *mUser; - KLineEdit *mPassword; - - TDEListView *mAddressBookView; - KComboBox *mAddressBookBox; - - TQStringList mWriteAddressBookIds; - TQStringList mReadAddressBookIds; - ResourceGroupwise *mResource; -}; - -} - -#endif diff --git a/tderesources/groupwise/tdeabc_groupwise.desktop b/tderesources/groupwise/tdeabc_groupwise.desktop new file mode 100644 index 000000000..695ab445b --- /dev/null +++ b/tderesources/groupwise/tdeabc_groupwise.desktop @@ -0,0 +1,50 @@ +[Desktop Entry] +Name=Novell GroupWise Server +Name[af]=Novell GroupWise bediener +Name[bg]=Сървър Novell GroupWise +Name[br]=Servijer Novell GroupWise +Name[ca]=Servidor Novell GroupWise +Name[cs]=Novell GroupWise server +Name[da]=Novell GroupWise server +Name[el]=Εξυπηρετητής Novell GroupWise +Name[es]=Servidor de Novell GroupWise +Name[et]=Novelli GroupWise server +Name[eu]=Novell GroupWise zerbitzaria +Name[fa]=کارساز Novell GroupWise +Name[fi]=Novell GroupWise -palvelin +Name[fr]=Serveur de travail collaboratif GroupWise de Novell +Name[fy]=Novell GroupWise-tsjinner +Name[ga]=Freastalaí Novell GroupWise +Name[gl]=Servidor Novell GroupWise +Name[hu]=Novell GroupWise kiszolgáló +Name[is]=Novell GroupWise þjónn +Name[it]=Server Novell GroupWise +Name[ja]=Novell GroupWise サーバ +Name[ka]=სერვერი Novell GroupWise +Name[kk]=Novell GroupWise сервері +Name[km]=ម៉ាស៊ីន​បម្រើ GroupWise របស់​ណូវែល +Name[lt]=Novell GroupWise serveris +Name[ms]=Pelayan Novell GroupWise +Name[nb]=Novell GroupWise-tjener +Name[nds]=Novell-GroupWise-Server +Name[ne]=नोभेल समूहगत सर्भर +Name[nl]=Novell GroupWise-server +Name[nn]=Novell GroupWise-tenar +Name[pl]=Serwer Novell GroupWise +Name[pt]=Servidor Novell GroupWise +Name[pt_BR]=Servidor GroupWise da Novell +Name[ru]=Сервер Novell GroupWise +Name[sl]=Strežnik Novell GroupWise +Name[sr]=Novell-ов GroupWise сервер +Name[sr@Latn]=Novell-ov GroupWise server +Name[sv]=Novell Groupwise-server +Name[ta]=Novell குழுவாரிச் சேவகன் +Name[tr]=Novell GroupWise Sunucusu +Name[uk]=Сервер Novell GroupWise +Name[zh_CN]=Novell GroupWise 服务器 +Name[zh_TW]=Novell 群組伺服器 +X-TDE-Library=kabc_groupwise +Type=Service +ServiceTypes=KResources/Plugin +X-TDE-ResourceFamily=contact +X-TDE-ResourceType=groupwise diff --git a/tderesources/groupwise/tdeabc_groupwiseprefs.kcfgc b/tderesources/groupwise/tdeabc_groupwiseprefs.kcfgc new file mode 100644 index 000000000..0dd55c2f6 --- /dev/null +++ b/tderesources/groupwise/tdeabc_groupwiseprefs.kcfgc @@ -0,0 +1,8 @@ +ClassName=GroupwisePrefs +File=tderesources_tdeabc_groupwise.kcfg +GlobalEnums=true +IncludeFiles=libtdepim/kresourceprefs.h +Inherits=KResourcePrefs +Mutators=true +NameSpace=KABC +Singleton=false diff --git a/tderesources/groupwise/tdeabc_resourcegroupwise.cpp b/tderesources/groupwise/tdeabc_resourcegroupwise.cpp new file mode 100644 index 000000000..8499aa9ff --- /dev/null +++ b/tderesources/groupwise/tdeabc_resourcegroupwise.cpp @@ -0,0 +1,743 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include +#include + +#include +#include +#include +#include +#include + +#include "kabc_groupwiseprefs.h" + +#include "kabc_resourcegroupwise.h" + +using namespace KABC; + +ResourceGroupwise::ResourceGroupwise( const TDEConfig *config ) + : ResourceCached( config ) +{ + init(); + + mPrefs->addGroupPrefix( identifier() ); + + if ( config ) { + readConfig( config ); + } + initGroupwise(); +} + +ResourceGroupwise::ResourceGroupwise( const KURL &url, + const TQString &user, + const TQString &password, + const TQStringList &readAddressBooks, + const TQString &writeAddressBook ) + : ResourceCached( 0 ) +{ + init(); + + mPrefs->addGroupPrefix( identifier() ); + + mPrefs->setUrl( url.url() ); + mPrefs->setUser( user ); + mPrefs->setPassword( password ); + mPrefs->setReadAddressBooks( readAddressBooks ); + mPrefs->setWriteAddressBook( writeAddressBook ); + + initGroupwise(); +} + +void ResourceGroupwise::init() +{ + mJob = 0; + mProgress = 0; + mSABProgress = 0; + mUABProgress = 0; + mServerFirstSequence = 0; + mServerLastSequence = 0; + mServerLastPORebuildTime = 0; + mPrefs = new GroupwisePrefs; + mState = Start; + setType( "groupwise" ); +} + +void ResourceGroupwise::initGroupwise() +{ + mServer = new GroupwiseServer( mPrefs->url(), mPrefs->user(), + mPrefs->password(), this ); +} + +ResourceGroupwise::~ResourceGroupwise() +{ + delete mServer; + mServer = 0; + + delete mPrefs; + mPrefs = 0; +} + +void ResourceGroupwise::readConfig( const TDEConfig * ) +{ + mPrefs->readConfig(); + + readAddressBooks(); +} + +void ResourceGroupwise::writeConfig( TDEConfig *config ) +{ + Resource::writeConfig( config ); + + writeAddressBooks(); + + mPrefs->writeConfig(); +} + +void ResourceGroupwise::clearCache() +{ + idMapper().clear(); + mAddrMap.clear(); + TQFile file( cacheFile() ); + file.remove(); +} + +void ResourceGroupwise::readAddressBooks() +{ + TQStringList ids = prefs()->ids(); + TQStringList names = prefs()->names(); + TQStringList personals = prefs()->personals(); + TQStringList frequents = prefs()->frequents(); + + if ( ids.count() != names.count() || ids.count() != personals.count() || + ids.count() != frequents.count() ) { + kdError() << "Corrupt addressbook configuration" << endl; + return; + } + + mAddressBooks.clear(); + + for( uint i = 0; i < ids.count(); ++i ) { + GroupWise::AddressBook ab; + ab.id = ids[ i ]; + ab.name = names[ i ]; + ab.isPersonal = personals[ i ] == "1"; + ab.isFrequentContacts = frequents[ i ] == "1"; + + mAddressBooks.append( ab ); + } +} + +void ResourceGroupwise::writeAddressBooks() +{ + TQStringList ids; + TQStringList names; + TQStringList personals; + TQStringList frequents; + GroupWise::AddressBook::List::ConstIterator it; + for( it = mAddressBooks.begin(); it != mAddressBooks.end(); ++it ) { + ids.append( (*it).id ); + names.append( (*it).name ); + personals.append( (*it).isPersonal ? "1" : "0" ); + frequents.append( (*it).isFrequentContacts ? "1" : "0" ); + } + prefs()->setIds( ids ); + prefs()->setNames( names ); + prefs()->setPersonals( personals ); + prefs()->setFrequents( frequents ); +} + +void ResourceGroupwise::retrieveAddressBooks() +{ + bool firstRetrieve = mAddressBooks.isEmpty(); + + GroupwiseServer server( prefs()->url(), + prefs()->user(), + prefs()->password(), this ); + + if ( server.login() ) + { + mAddressBooks = server.addressBookList(); + server.logout(); + + TQStringList reads; + TQString write; + + GroupWise::AddressBook::List::ConstIterator it; + for( it = mAddressBooks.begin(); it != mAddressBooks.end(); ++it ) { + reads.append( (*it).id ); + if ( (*it).isPersonal ) { + if ( write.isEmpty() ) write = (*it).id; + } + else + prefs()->setSystemAddressBook( (*it).id ); + } + + if ( firstRetrieve ) { + prefs()->setReadAddressBooks( reads ); + prefs()->setWriteAddressBook( write ); + } + } + else + emit loadingError( this, server.errorText() ); +} + +Ticket *ResourceGroupwise::requestSaveTicket() +{ + if ( !addressBook() ) { + kdDebug(5700) << "no addressbook" << endl; + return 0; + } + + return createTicket( this ); +} + +void ResourceGroupwise::releaseSaveTicket( Ticket *ticket ) +{ + delete ticket; +} + +bool ResourceGroupwise::doOpen() +{ + return true; +} + +void ResourceGroupwise::doClose() +{ + kdDebug() << "ResourceGroupwise::doClose()" << endl; + + cancelLoad(); +} + +bool ResourceGroupwise::save( Ticket *ticket ) +{ + return asyncSave( ticket ); +} + +bool ResourceGroupwise::asyncSave( Ticket* ) +{ + if ( !mServer->login() ) return false; + + KABC::Addressee::List::Iterator it; + + KABC::Addressee::List addedList = addedAddressees(); + for ( it = addedList.begin(); it != addedList.end(); ++it ) { + if ( mServer->insertAddressee( mPrefs->writeAddressBook(), *it ) ) { + clearChange( *it ); + idMapper().setRemoteId( (*it).uid(), (*it).custom( "GWRESOURCE", "UID" ) ); + } + } + + KABC::Addressee::List changedList = changedAddressees(); + for ( it = changedList.begin(); it != changedList.end(); ++it ) { + if ( mServer->changeAddressee( *it ) ) + clearChange( *it ); + } + + KABC::Addressee::List deletedList = deletedAddressees(); + for ( it = deletedList.begin(); it != deletedList.end(); ++it ) { + if ( mServer->removeAddressee( *it ) ) + clearChange( *it ); + } + + if ( appIsWhiteListedForSAB() ) + saveCache(); + + mServer->logout(); + + return true; +} + +bool ResourceGroupwise::load() +{ + return asyncLoad(); +} + +bool ResourceGroupwise::asyncLoad() +{ + kdDebug() << "ResourceGroupwise::asyncLoad()" << endl; + //mPrefs->readConfig(); TODO: remove if the system addressbook is not read when disabled in config + + if ( mState != Start ) + { + kdDebug() << " Download still in progress" << endl; + return true; + } + + if ( appIsWhiteListedForSAB() ) + loadCache(); + + if ( !mProgress ) + { + mProgress = KPIM::ProgressManager::instance()->createProgressItem( + KPIM::ProgressManager::getUniqueID(), i18n( "Loading GroupWise resource %1" ).arg( resourceName() ), TQString(), true /*CanBeCancelled*/, mPrefs->url().startsWith("https" ) ); + connect( mProgress, TQT_SIGNAL( progressItemCanceled( KPIM::ProgressItem * ) ), + TQT_SLOT( cancelLoad() ) ); + } + + if ( addressBooks().isEmpty() ) { + kdDebug() << " Retrieving default addressbook list." << endl; + retrieveAddressBooks(); + writeAddressBooks(); + } + + SABState sabState = systemAddressBookState(); + if ( shouldFetchSystemAddressBook() ) + { + if ( sabState == RefreshNeeded ) + { + kdDebug() << " Fetching system addressbook" << endl; + fetchAddressBooks( System ); + return true; + } + else if ( sabState == Stale ) + { + kdDebug() << " Updating system addressbook" << endl; + updateSystemAddressBook(); // we then fetch the user address books after doing this + return true; + } + } + else if ( shouldFetchUserAddressBooks() ) + { + kdDebug() << " Fetching user addressbook" << endl; + fetchAddressBooks( User ); + return true; + } + return true; +} + +void ResourceGroupwise::fetchAddressBooks( const BookType bookType ) +{ + KURL url = createAccessUrl( bookType, Fetch ); + if ( !url.isValid() ) + return; + + kdDebug() << k_funcinfo << ( bookType == System ? " System" : " User" ) << " URL: " << url << endl; + // sanity check + if ( bookType == User && !( mState == SABUptodate || mState == Start ) ) + { + kdDebug() << " **ERROR** - fetchAddressBooks( User ) called when SAB not up to date" << endl; + return; + } + + mState = ( bookType == System ? FetchingSAB : FetchingUAB ); + mJobData = TQString(); + + if ( mJob ) + { + kdDebug() << " **ERROR** - fetchAddressBooks() called when a job was already running!" << endl; + return; + } + + mJob = TDEIO::get( url, false, false ); // TODO: make the GW jobs call finished if the URL + // contains no address book IDs + kdDebug() << " Job address: " << mJob << endl; + connect( mJob, TQT_SIGNAL( data( TDEIO::Job *, const TQByteArray & ) ), + TQT_SLOT( slotReadJobData( TDEIO::Job *, const TQByteArray & ) ) ); + connect( mJob, TQT_SIGNAL( percent( TDEIO::Job *, unsigned long ) ), + TQT_SLOT( slotJobPercent( TDEIO::Job *, unsigned long ) ) ); + + if ( bookType == System ) + { + connect( mJob, TQT_SIGNAL( result( TDEIO::Job * ) ), + TQT_SLOT( fetchSABResult( TDEIO::Job * ) ) ); + mSABProgress = KPIM::ProgressManager::instance()->createProgressItem( + mProgress, KPIM::ProgressManager::getUniqueID(), + i18n( "Fetching System Address Book" ), TQString(), + false /*CannotBeCancelled*/, + mPrefs->url().startsWith("https" ) ); + } + else + { + connect( mJob, TQT_SIGNAL( result( TDEIO::Job * ) ), + TQT_SLOT( fetchUABResult( TDEIO::Job * ) ) ); + mUABProgress = KPIM::ProgressManager::instance()->createProgressItem( + mProgress, KPIM::ProgressManager::getUniqueID(), + i18n( "Fetching User Address Books" ), TQString(), + false /*CannotBeCancelled*/, + mPrefs->url().startsWith("https" ) ); + } + + return; +} + +void ResourceGroupwise::fetchSABResult( TDEIO::Job *job ) +{ + kdDebug() << "ResourceGroupwise::fetchSABResult() " << endl; + + if ( job->error() ) { + kdError() << job->errorString() << endl; + emit loadingError( this, job->errorString() ); + // TODO kill the rest of the load sequence as well + } + + mJob->disconnect( this ); + mJob = 0; + mState = SABUptodate; + if ( mSABProgress ) + mSABProgress->setComplete(); + + storeDeltaInfo(); + + if ( shouldFetchUserAddressBooks() ) + fetchAddressBooks( User ); + else + loadCompleted(); +} + +void ResourceGroupwise::fetchUABResult( TDEIO::Job *job ) +{ + kdDebug() << "ResourceGroupwise::fetchUABResult() " << endl; + + if ( job->error() ) { + kdError() << job->errorString() << endl; + emit loadingError( this, job->errorString() ); + } + + mJob->disconnect( this ); + mJob = 0; + mState = Uptodate; + if ( mUABProgress ) + mUABProgress->setComplete(); + loadCompleted(); +} + +void ResourceGroupwise::updateSystemAddressBook() +{ + kdDebug() << "ResourceGroupwise::updateSystemAddressBook()" << endl; + + if ( mState != Start ) { + kdWarning() << " Action already in progress" << endl; + return; + } + + if ( addressBooks().isEmpty() ) { + kdDebug() << " Retrieving default addressbook list." << endl; + retrieveAddressBooks(); + writeAddressBooks(); + } + + KURL url = createAccessUrl( System, Update, mPrefs->lastSequenceNumber(), mPrefs->lastTimePORebuild() ); + kdDebug() << " Update URL: " << url << endl; + + mJobData = TQString(); + mSABProgress = KPIM::ProgressManager::instance()->createProgressItem( + mProgress, KPIM::ProgressManager::getUniqueID(), + i18n( "Updating System Address Book" ), TQString(), + false /*CannotBeCancelled*/, + mPrefs->url().startsWith("https" ) ); + + mJob = TDEIO::get( url, false, false ); + mJob->setInteractive( false ); + connect( mJob, TQT_SIGNAL( result( TDEIO::Job * ) ), + TQT_SLOT( updateSABResult( TDEIO::Job * ) ) ); + connect( mJob, TQT_SIGNAL( data( TDEIO::Job *, const TQByteArray & ) ), + TQT_SLOT( slotUpdateJobData( TDEIO::Job *, const TQByteArray & ) ) ); + connect( mJob, TQT_SIGNAL( percent( TDEIO::Job *, unsigned long ) ), + TQT_SLOT( slotJobPercent( TDEIO::Job *, unsigned long ) ) ); + + return; +} + +void ResourceGroupwise::updateSABResult( TDEIO::Job *job ) +{ + kdDebug() << "ResourceGroupwise::updateSABResult() " << endl; + + mSABProgress->setComplete(); + mSABProgress = 0; + mJob->disconnect( this ); + mJob = 0; + + int errorCode = job->error(); + if ( errorCode != 0 ) { + if ( errorCode == TDEIO::ERR_NO_CONTENT ) // we need to refresh the SAB + { + kdDebug() << " update SAB failed, fetching all of it again" << endl; + mPrefs->setLastSequenceNumber( 0 ); + mPrefs->setFirstSequenceNumber( 0 ); + fetchAddressBooks( System ); + return; + } + } + + mState = SABUptodate; + storeDeltaInfo(); + + if ( shouldFetchUserAddressBooks() ) + fetchAddressBooks( User ); + else + loadCompleted(); +} + +void ResourceGroupwise::slotReadJobData( TDEIO::Job *job , const TQByteArray &data ) +{ + kdDebug() << "ResourceGroupwise::slotReadJobData()" << endl; + Q_UNUSED( job ); + + mJobData.append( data.data() ); + + KABC::VCardConverter conv; + TQTime profile; + profile.start(); + Addressee::List addressees = conv.parseVCards( mJobData ); + // kdDebug() << " parsed " << addressees.count() << " contacts in " << profile.elapsed() << "ms, now adding to resource..." << endl; + + Addressee::List::ConstIterator it; + for( it = addressees.begin(); it != addressees.end(); ++it ) { + KABC::Addressee addr = *it; + if ( !addr.isEmpty() ) { + addr.setResource( this ); + + TQString remote = addr.custom( "GWRESOURCE", "UID" ); + TQString local = idMapper().localId( remote ); + if ( local.isEmpty() ) { + idMapper().setRemoteId( addr.uid(), remote ); + } else { + addr.setUid( local ); + } + + insertAddressee( addr ); + clearChange( addr ); + } + } + mJobData = TQString(); +} + +void ResourceGroupwise::slotUpdateJobData( TDEIO::Job *job, const TQByteArray &data ) +{ + kdDebug() << "ResourceGroupwise::slotUpdateJobData()" << endl; + kdDebug() << " Job address: " << job << endl; + KABC::VCardConverter conv; + mJobData.append( data.data() ); + + Addressee::List addressees = conv.parseVCards( mJobData ); + Addressee::List::ConstIterator it; + + for( it = addressees.begin(); it != addressees.end(); ++it ) { + KABC::Addressee addr = *it; + if ( !addr.isEmpty() ) { + // if added or changed + TQString syncType = addr.custom( "GWRESOURCE", "SYNC" ); + TQString remote = addr.custom( "GWRESOURCE", "UID" ); + TQString local = idMapper().localId( remote ); + + if ( syncType == "ADD" || syncType == "UPD" ) + { + addr.setResource( this ); + if ( local.isEmpty() ) { + idMapper().setRemoteId( addr.uid(), remote ); + } else { + addr.setUid( local ); + } + + insertAddressee( addr ); + clearChange( addr ); + } + else if ( syncType == "DEL" ) + { + // if deleted + if ( !remote.isEmpty() ) + { + if ( !local.isEmpty() ) + { + idMapper().removeRemoteId( remote ); + KABC::Addressee addrToDelete = findByUid( local ); + removeAddressee( addrToDelete ); + } + } + else + kdError() << "Addressee to delete did not have a remote UID, unable to find the corresponding local contact" << endl; + } + } + } + mJobData = TQString(); +} + +void ResourceGroupwise::loadCompleted() +{ + kdDebug() << "ResourceGroupwise::loadCompleted()" << endl; + if ( mProgress ) + mProgress->setComplete(); + mProgress = 0; + mSABProgress = 0; + mUABProgress = 0; + mState = Start; + if ( appIsWhiteListedForSAB() ) + saveCache(); + emit loadingFinished( this ); + addressBook()->emitAddressBookChanged(); +} + +void ResourceGroupwise::slotJobPercent( TDEIO::Job *, unsigned long percent ) +{ + // TODO: make this act on the correct progress item + kdDebug() << "ResourceGroupwise::slotJobPercent() " << percent << endl; + if ( mProgress ) mProgress->setProgress( percent ); +} + +void ResourceGroupwise::cancelLoad() +{ + if ( mJob ) + { + mJob->disconnect( this ); + mJob->kill(); + } + mJob = 0; + if ( mProgress ) mProgress->setComplete(); + mProgress = 0; + mState = Start; +} + +ResourceGroupwise::SABState ResourceGroupwise::systemAddressBookState() +{ + unsigned long storedFirstSequence = mPrefs->firstSequenceNumber(); + unsigned long storedLastSequence = mPrefs->lastSequenceNumber(); + unsigned long storedLastPORebuildTime = mPrefs->lastTimePORebuild(); + + kdDebug() << "ResourceGroupwise::systemAddressBookState()" << endl; + kdDebug() << " Stored first seq no: " << storedFirstSequence << endl; + kdDebug() << " Stored last seq no: " << storedLastSequence << endl; + kdDebug() << " Stored last PO Rebuild time: " << storedLastPORebuildTime << endl; + + kdDebug() << " Fetching delta info to check if update possible" << endl; + if ( mServer->login() ) + { + GroupWise::DeltaInfo deltaInfo = mServer->getDeltaInfo( mPrefs->systemAddressBook() ); + mServer->logout(); + + mServerFirstSequence = deltaInfo.firstSequence; + mServerLastSequence = deltaInfo.lastSequence; + mServerLastPORebuildTime = deltaInfo.lastTimePORebuild; + + kdDebug() << " Server first seq no: " << mServerFirstSequence << endl; + kdDebug() << " Server last seq no: " << mServerLastSequence << endl; + kdDebug() << " Server last PO Rebuild time: " << mServerLastPORebuildTime << endl; + + if ( storedFirstSequence == 0 || storedLastSequence == 0 ) + { + kdDebug() << " no fetched SAB exists yet, can't update" << endl; + return RefreshNeeded; + } + + if ( mServerFirstSequence > storedLastSequence || storedLastPORebuildTime != mServerLastPORebuildTime) + { + kdDebug() << " New entries since the last fetch are no longer available as deltas, or the PO was rebuilt, refresh needed" << endl; + return RefreshNeeded; + } + + if ( mServerLastSequence == storedLastSequence ) + { + kdDebug() << " The local data is up to date" << endl; + return InSync; + } + } + else + emit loadingError( this, mServer->errorText() ); + + if ( storedFirstSequence == 0 || storedLastSequence == 0 ) + { + kdDebug() << " Fallthrough - no fetched SAB exists yet, refresh" << endl; + return RefreshNeeded; + } + else + kdDebug() << " Fallthrough - returning Stale" << endl; + return Stale; +} + +bool ResourceGroupwise::shouldFetchSystemAddressBook() +{ + + TQStringList ids = mPrefs->readAddressBooks(); + return ( appIsWhiteListedForSAB() && ids.find( mPrefs->systemAddressBook() ) != ids.end() ); +} + +bool ResourceGroupwise::shouldFetchUserAddressBooks() +{ + TQStringList ids = mPrefs->readAddressBooks(); + return ( ids.count() > 1 || ids.find( mPrefs->systemAddressBook() ) == ids.end() ); +} + +KURL ResourceGroupwise::createAccessUrl( BookType bookType, AccessMode mode, unsigned long lastSequenceNumber, unsigned long lastPORebuildTime ) +{ + // set up list of address book IDs to fetch + TQStringList ids; + if ( bookType == System ) + ids.append( mPrefs->systemAddressBook() ); + else + { + ids = mPrefs->readAddressBooks(); + ids.remove( mPrefs->systemAddressBook() ); + } + + if ( ids.isEmpty() ) + return KURL(); + + KURL url( prefs()->url() ); + if ( url.protocol() == "http" ) + url.setProtocol( "groupwise" ); + else + url.setProtocol( "groupwises" ); + + url.setPath( url.path() + "/addressbook/" ); + url.setUser( prefs()->user() ); + url.setPass( prefs()->password() ); + + TQString query = "?"; + TQStringList::ConstIterator it; + for( it = ids.begin(); it != ids.end(); ++it ) { + if ( it != ids.begin() ) query += "&"; + query += "addressbookid=" + *it; + } + + if ( mode == Update && lastSequenceNumber > 0 && lastPORebuildTime > 0 ) + { + query += TQString::fromLatin1( "&update=true&lastSeqNo=%1&PORebuildTime=%2" ).arg( lastSequenceNumber ).arg( lastPORebuildTime );; + } + url.setQuery( query ); + return url; +} + +void ResourceGroupwise::storeDeltaInfo() +{ + // update SAB delta info + kdDebug() << "ResourceGroupwise::storeDeltaInfo()" << endl; + kdDebug() << " Server first seq no: " << mServerFirstSequence << endl; + kdDebug() << " Server last seq no: " << mServerLastSequence << endl; + kdDebug() << " Server last PO Rebuild time: " << mServerLastPORebuildTime << endl; + + if ( mServerFirstSequence == 0 || mServerLastSequence == 0 || mServerLastPORebuildTime == 0 ) + return; + mPrefs->setFirstSequenceNumber( mServerFirstSequence ); + mPrefs->setLastSequenceNumber( mServerLastSequence ); + mPrefs->setLastTimePORebuild( mServerLastPORebuildTime ); + mPrefs->writeConfig(); +} + +bool ResourceGroupwise::appIsWhiteListedForSAB() +{ + if ( !mPrefs->systemAddressBookWhiteList().contains( tqApp->argv()[ 0 ] ) ) + { + kdDebug() << "Application " << tqApp->argv()[ 0 ] << " is _blacklisted_ to load the SAB" << endl; + return false; + } + return true; +} + +#include "kabc_resourcegroupwise.moc" diff --git a/tderesources/groupwise/tdeabc_resourcegroupwise.h b/tderesources/groupwise/tdeabc_resourcegroupwise.h new file mode 100644 index 000000000..0c7533eef --- /dev/null +++ b/tderesources/groupwise/tdeabc_resourcegroupwise.h @@ -0,0 +1,169 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_RESOURCEGROUPWISE_H +#define KABC_RESOURCEGROUPWISE_H + +#include "soap/groupwiseserver.h" + +#include +#include + +#include + +#include + +class TDEConfig; + +class GroupwiseServer; + +namespace KABC { + +class GroupwisePrefs; + +class KDE_EXPORT ResourceGroupwise : public ResourceCached +{ + friend class ResourceGroupwiseConfig; + + Q_OBJECT + + + public: + ResourceGroupwise( const TDEConfig * ); + ResourceGroupwise( const KURL &url, + const TQString &user, const TQString &password, + const TQStringList &readAddressBooks, + const TQString &writeAddressBook ); + ~ResourceGroupwise(); + + void readConfig( const TDEConfig * ); + void writeConfig( TDEConfig * ); + + void readAddressBooks(); + void writeAddressBooks(); + + void retrieveAddressBooks(); + + GroupwisePrefs *prefs() const { return mPrefs; } + + GroupWise::AddressBook::List addressBooks() const { return mAddressBooks; } + + bool doOpen(); + void doClose(); + + Ticket *requestSaveTicket(); + void releaseSaveTicket( Ticket* ); + + bool load(); + bool asyncLoad(); + bool save( Ticket * ); + bool asyncSave( Ticket * ); + enum SABState { Error, Stale, InSync, RefreshNeeded }; + + /** + * Clears the cached data, in memory and on disk + */ + void clearCache(); + protected: + enum ResourceState { Start, FetchingSAB, SABUptodate, FetchingUAB, Uptodate }; + enum BookType { System, User }; + enum AccessMode { Fetch, Update }; + void init(); + void initGroupwise(); + + /* STATE CHANGING METHODS */ + /** + * Begin asynchronously fetching the system address book , replacing the cached copy + */ + void fetchAddressBooks( const BookType booktype ); + /** + * Asynchronously update the system address book + */ + void updateSystemAddressBook(); + /** + * Wrap up the load sequence + */ + void loadCompleted(); + + /** HELPER METHODS **/ + /** + * Check to see if a local download of the SAB already exists + */ + SABState systemAddressBookState(); + /** + * Check if the resource is configured to download the SAB + */ + bool shouldFetchSystemAddressBook(); + /** + * Check if the resource is configured to download personal address + * books + */ + bool shouldFetchUserAddressBooks(); + + /** + * Create a URL for a single addressbook access. + * To fetch an address book completely, use mode = Fetch + * To just update an addressbook, use mode = Update and give the ast sequence number already held + * If Update is given without a sequence number, the mode falls back to Fetch + */ + KURL createAccessUrl( BookType bookType, AccessMode mode, unsigned long lastSequenceNumber = 0, unsigned long lastPORebuildTime = 0 ); + + /** + * Persist the last known delta info. Call after the SAB is up to date. + */ + void storeDeltaInfo(); + + /** + * Check if the application which has loaded this resource is whitelisted + * to load the System Address Book (time-consuming) + */ + bool appIsWhiteListedForSAB(); + + private slots: + /** STATE CHANGING SLOTS **/ + void fetchSABResult( TDEIO::Job * ); + void fetchUABResult( TDEIO::Job * ); + void updateSABResult( TDEIO::Job * ); + /** DATA PROCESSING SLOTS **/ + void slotReadJobData( TDEIO::Job *, const TQByteArray & ); + void slotUpdateJobData( TDEIO::Job *, const TQByteArray & ); + /** HELPER TQT_SLOT **/ + void slotJobPercent( TDEIO::Job *job, unsigned long percent ); + + void cancelLoad(); + private: + GroupwisePrefs *mPrefs; + GroupWise::AddressBook::List mAddressBooks; + + GroupwiseServer *mServer; + + TDEIO::TransferJob *mJob; + KPIM::ProgressItem *mProgress; + KPIM::ProgressItem *mSABProgress; + KPIM::ProgressItem *mUABProgress; + TQString mJobData; + ResourceState mState; + unsigned long mServerFirstSequence, mServerLastSequence, mServerLastPORebuildTime; + + bool mLimitedMode; +}; + +} + +#endif diff --git a/tderesources/groupwise/tdeabc_resourcegroupwise_plugin.cpp b/tderesources/groupwise/tdeabc_resourcegroupwise_plugin.cpp new file mode 100644 index 000000000..b3a94a901 --- /dev/null +++ b/tderesources/groupwise/tdeabc_resourcegroupwise_plugin.cpp @@ -0,0 +1,40 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "kabc_resourcegroupwise.h" +#include "kabc_resourcegroupwiseconfig.h" + +#include +#include + +using namespace KABC; + +typedef KRES::PluginFactory GroupwiseFactory; +// FIXME: Use K_EXPORT_COMPONENT_FACTORY( kabc_groupwise, GroupwiseFactory ); here +// Problem: How do I insert the catalogue??? +extern "C" +{ + void *init_tdeabc_groupwise() + { + TDEGlobal::locale()->insertCatalogue( "libkcal" ); + TDEGlobal::locale()->insertCatalogue( "kres_groupwise" ); + return new GroupwiseFactory; + } +} diff --git a/tderesources/groupwise/tdeabc_resourcegroupwiseconfig.cpp b/tderesources/groupwise/tdeabc_resourcegroupwiseconfig.cpp new file mode 100644 index 000000000..1212a6bc5 --- /dev/null +++ b/tderesources/groupwise/tdeabc_resourcegroupwiseconfig.cpp @@ -0,0 +1,209 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "kabc_resourcegroupwiseconfig.h" + +#include "kabc_resourcegroupwise.h" +#include "kabc_groupwiseprefs.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace KABC; + +class AddressBookItem : public TQCheckListItem +{ + public: + AddressBookItem( TDEListView *parent, GroupWise::AddressBook ab ) + : TQCheckListItem( parent, "", CheckBox ), + mId( ab.id ) + { + setText( 0, ab.name ); + if ( ab.isPersonal ) setText( 1, i18n("Yes") ); + else setText( 1, i18n("No") ); + if ( ab.isFrequentContacts ) setText( 2, i18n("Yes") ); + else setText( 2, i18n("No") ); + } + + TQString id() const { return mId; } + + private: + TQString mId; +}; + +ResourceGroupwiseConfig::ResourceGroupwiseConfig( TQWidget* parent, const char* name ) + : KRES::ConfigWidget( parent, name ) +{ + TQGridLayout *mainLayout = new TQGridLayout( this, 7, 2, 0, KDialog::spacingHint() ); + + TQLabel *label = new TQLabel( i18n( "URL:" ), this ); + mURL = new KURLRequester( this ); + + mainLayout->addWidget( label, 0, 0 ); + mainLayout->addWidget( mURL, 0, 1 ); + + label = new TQLabel( i18n( "User:" ), this ); + mUser = new KLineEdit( this ); + + mainLayout->addWidget( label, 1, 0 ); + mainLayout->addWidget( mUser, 1, 1 ); + + label = new TQLabel( i18n( "Password:" ), this ); + mPassword = new KLineEdit( this ); + mPassword->setEchoMode( TQLineEdit::Password ); + + mainLayout->addWidget( label, 2, 0 ); + mainLayout->addWidget( mPassword, 2, 1 ); + + TQFrame *hline = new TQFrame( this ); + hline->setFrameStyle( TQFrame::HLine | TQFrame::Sunken ); + + mainLayout->addMultiCellWidget( hline, 3, 3, 0, 1 ); + + TQPushButton *updateButton = new TQPushButton( i18n( "Retrieve Address Book List From Server" ), this ); + mainLayout->addMultiCellWidget( updateButton, 4, 4, 0, 1 ); + + mAddressBookView = new TDEListView( this ); + mAddressBookView->addColumn( i18n( "Address Book" ) ); + mAddressBookView->addColumn( i18n( "Personal" ) ); + mAddressBookView->addColumn( i18n( "Frequent Contacts" ) ); + mAddressBookView->setFullWidth( true ); + + mainLayout->addMultiCellWidget( mAddressBookView, 5, 5, 0, 1 ); + + label = new TQLabel( i18n( "Address book for new contacts:" ), this ); + mAddressBookBox = new KComboBox( this ); + + mainLayout->addWidget( label, 6, 0 ); + mainLayout->addWidget( mAddressBookBox, 6, 1 ); + + connect( updateButton, TQT_SIGNAL( clicked() ), TQT_SLOT( updateAddressBookList() ) ); +} + +void ResourceGroupwiseConfig::loadSettings( KRES::Resource *res ) +{ + mResource = dynamic_cast( res ); + + if ( !mResource ) { + kdDebug(5700) << "ResourceGroupwiseConfig::loadSettings(): cast failed" << endl; + return; + } + + mURL->setURL( mResource->prefs()->url() ); + mUser->setText( mResource->prefs()->user() ); + mPassword->setText( mResource->prefs()->password() ); + mReadAddressBookIds = mResource->prefs()->readAddressBooks(); + updateAddressBookView(); +} + +void ResourceGroupwiseConfig::saveSettings( KRES::Resource *res ) +{ + ResourceGroupwise *resource = dynamic_cast( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceGroupwiseConfig::saveSettings(): cast failed" << endl; + return; + } + + saveServerSettings( resource ); + + saveAddressBookSettings(); +} + +void ResourceGroupwiseConfig::saveServerSettings( ResourceGroupwise *resource ) +{ + resource->prefs()->setUrl( mURL->url() ); + resource->prefs()->setUser( mUser->text() ); + resource->prefs()->setPassword( mPassword->text() ); +} + +void ResourceGroupwiseConfig::updateAddressBookList() +{ + saveServerSettings( mResource ); + + mResource->retrieveAddressBooks(); + + updateAddressBookView(); +} + +void ResourceGroupwiseConfig::saveAddressBookSettings() +{ + TQStringList selectedRead; + TQString selectedWrite; + + TQListViewItemIterator it2( mAddressBookView ); + while ( it2.current() ) { + AddressBookItem *item = static_cast( it2.current() ); + if ( item->isOn() ) + selectedRead.append( item->id() ); + + ++it2; + } + // check if the SAB was selected when the settings were loaded and is not selected now, + // if so, clear the resource to clear the SAB data that is no longer required. + // also, set the sequence numbers to 0 so that we know the SAB should be re-fetched in its entirety the next time we do load it + TQString sab = mResource->prefs()->systemAddressBook(); + if ( ( mReadAddressBookIds.find( sab ) != mReadAddressBookIds.end() ) && ( selectedRead.find( sab ) == selectedRead.end() ) ) + { + mResource->clearCache(); + mResource->prefs()->setLastSequenceNumber( 0 ); + mResource->prefs()->setFirstSequenceNumber( 0 ); + } + selectedWrite = mWriteAddressBookIds[ mAddressBookBox->currentItem() ]; + + mResource->prefs()->setReadAddressBooks( selectedRead ); + mResource->prefs()->setWriteAddressBook( selectedWrite ); +} + +void ResourceGroupwiseConfig::updateAddressBookView() +{ + if ( mAddressBookBox->count() != 0 ) // we loaded it already + saveAddressBookSettings(); + + mAddressBookView->clear(); + mAddressBookBox->clear(); + mWriteAddressBookIds.clear(); + + TQStringList selectedRead = mResource->prefs()->readAddressBooks(); + + GroupWise::AddressBook::List addressBooks = mResource->addressBooks(); + GroupWise::AddressBook::List::ConstIterator abIt; + for ( abIt = addressBooks.begin(); abIt != addressBooks.end(); ++abIt ) { + AddressBookItem *item = new AddressBookItem( mAddressBookView, *abIt ); + if ( selectedRead.find( (*abIt).id ) != selectedRead.end() ) + item->setOn( true ); + + mAddressBookBox->insertItem( (*abIt).name ); + mWriteAddressBookIds.append( (*abIt).id ); + } + + int index = mWriteAddressBookIds.findIndex( mResource->prefs()->writeAddressBook() ); + mAddressBookBox->setCurrentItem( index ); +} + +#include "kabc_resourcegroupwiseconfig.moc" diff --git a/tderesources/groupwise/tdeabc_resourcegroupwiseconfig.h b/tderesources/groupwise/tdeabc_resourcegroupwiseconfig.h new file mode 100644 index 000000000..eb54803c0 --- /dev/null +++ b/tderesources/groupwise/tdeabc_resourcegroupwiseconfig.h @@ -0,0 +1,74 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_RESOURCEGROUPWISECONFIG_H +#define KABC_RESOURCEGROUPWISECONFIG_H + +#include "soap/groupwiseserver.h" + +#include +#include + +#include + +class KComboBox; +class KLineEdit; +class TDEListView; +class KURLRequester; + +namespace KABC { + +class ResourceGroupwise; + +class KDE_EXPORT ResourceGroupwiseConfig : public KRES::ConfigWidget +{ + Q_OBJECT + + + public: + ResourceGroupwiseConfig( TQWidget* parent = 0, const char* name = 0 ); + + public slots: + void loadSettings( KRES::Resource* ); + void saveSettings( KRES::Resource* ); + + protected slots: + void updateAddressBookList(); + + private: + void updateAddressBookView(); + void saveAddressBookSettings(); + void loadAddressBookSettings(); + void saveServerSettings( ResourceGroupwise *resource ); + + KURLRequester *mURL; + KLineEdit *mUser; + KLineEdit *mPassword; + + TDEListView *mAddressBookView; + KComboBox *mAddressBookBox; + + TQStringList mWriteAddressBookIds; + TQStringList mReadAddressBookIds; + ResourceGroupwise *mResource; +}; + +} + +#endif diff --git a/tderesources/groupwise/tderesources_kabc_groupwise.kcfg b/tderesources/groupwise/tderesources_kabc_groupwise.kcfg deleted file mode 100644 index 6bc3e4c3c..000000000 --- a/tderesources/groupwise/tderesources_kabc_groupwise.kcfg +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - URL of SOAP interface of GroupWise server - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - kmail,kaddressbook,kontact - - - diff --git a/tderesources/groupwise/tderesources_tdeabc_groupwise.kcfg b/tderesources/groupwise/tderesources_tdeabc_groupwise.kcfg new file mode 100644 index 000000000..188e50d9f --- /dev/null +++ b/tderesources/groupwise/tderesources_tdeabc_groupwise.kcfg @@ -0,0 +1,55 @@ + + + + + + + URL of SOAP interface of GroupWise server + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + kmail,kaddressbook,kontact + + + diff --git a/tderesources/lib/kabc_resourcegroupwarebase.cpp b/tderesources/lib/kabc_resourcegroupwarebase.cpp deleted file mode 100644 index 3ebd175eb..000000000 --- a/tderesources/lib/kabc_resourcegroupwarebase.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - Copyright (c) 2004 Till Adam - Copyright (C) 2005 Reinhold Kainhofer - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "kabc_resourcegroupwarebase.h" -#include "tderesources_groupwareprefs.h" - -#include "folderlister.h" -#include "addressbookadaptor.h" -#include "groupwaredownloadjob.h" -#include "groupwareuploadjob.h" - -#include -#include -#include - -using namespace KABC; - -ResourceGroupwareBase::ResourceGroupwareBase( const TDEConfig *config ) - : ResourceCached( config ), - mPrefs(0), mFolderLister(0), mAdaptor(0), mDownloadJob(0), mUploadJob(0) -{ - if ( config ) readConfig( config ); -} - -ResourceGroupwareBase::~ResourceGroupwareBase() -{ - delete mPrefs; - mPrefs = 0; -} - -KPIM::GroupwareDownloadJob *ResourceGroupwareBase::createDownloadJob( - AddressBookAdaptor *adaptor ) -{ - return new KPIM::GroupwareDownloadJob( adaptor ); -} - -KPIM::GroupwareUploadJob *ResourceGroupwareBase::createUploadJob( - AddressBookAdaptor *adaptor ) -{ - return new KPIM::GroupwareUploadJob( adaptor ); -} - -void ResourceGroupwareBase::setPrefs( KPIM::GroupwarePrefsBase *newprefs ) -{ - if ( !newprefs ) return; - if ( mPrefs ) delete mPrefs; - mPrefs = newprefs; - mPrefs->addGroupPrefix( identifier() ); - - mPrefs->readConfig(); - if ( mFolderLister ) mFolderLister->readConfig( mPrefs ); -} - -void ResourceGroupwareBase::setFolderLister( KPIM::FolderLister *folderLister ) -{ - if ( !folderLister ) return; - if ( mFolderLister ) delete mFolderLister; - mFolderLister = folderLister; - if ( mPrefs ) mFolderLister->readConfig( mPrefs ); - if ( mAdaptor ) { - mAdaptor->setFolderLister( mFolderLister ); - mFolderLister->setAdaptor( mAdaptor ); - } -} - -void ResourceGroupwareBase::setAdaptor( AddressBookAdaptor *adaptor ) -{ - if ( !adaptor ) return; - if ( mAdaptor ) delete mAdaptor; - mAdaptor = adaptor; - mAdaptor->setFolderLister( mFolderLister ); - if ( mFolderLister ) mFolderLister->setAdaptor( mAdaptor ); - mAdaptor->setDownloadProgressMessage( i18n("Downloading addressbook") ); - mAdaptor->setUploadProgressMessage( i18n("Uploading addressbook") ); - if ( prefs() ) { - mAdaptor->setBaseURL( prefs()->url() ); - mAdaptor->setUser( prefs()->user() ); - mAdaptor->setPassword( prefs()->password() ); - } - mAdaptor->setIdMapper( &idMapper() ); - mAdaptor->setResource( this ); -} - -void ResourceGroupwareBase::init() -{ - mDownloadJob = 0; -} - -KPIM::GroupwarePrefsBase *ResourceGroupwareBase::createPrefs() -{ - return new KPIM::GroupwarePrefsBase(); -} - - - -void ResourceGroupwareBase::readConfig( const TDEConfig */*config*/ ) -{ - kdDebug(5700) << "KABC::ResourceGroupwareBase::readConfig()" << endl; -// ResourceCached::readConfig( config ); - if ( mPrefs ) { - mPrefs->readConfig(); - if ( mFolderLister ) - mFolderLister->readConfig( mPrefs ); - } -} - -void ResourceGroupwareBase::writeConfig( TDEConfig *config ) -{ - Resource::writeConfig( config ); - - if ( mPrefs ) { - if ( mFolderLister ) - mFolderLister->writeConfig( mPrefs ); - mPrefs->writeConfig(); - } -} - -Ticket *ResourceGroupwareBase::requestSaveTicket() -{ - if ( !addressBook() ) { - kdDebug(5700) << "no addressbook" << endl; - return 0; - } - - return createTicket( this ); -} - -void ResourceGroupwareBase::releaseSaveTicket( Ticket *ticket ) -{ - delete ticket; -} - -bool ResourceGroupwareBase::doOpen() -{ - return true; -} - -void ResourceGroupwareBase::doClose() -{ - kdDebug(5800) << "ResourceGroupwareBase::doClose()" << endl; - - if ( mDownloadJob ) mDownloadJob->kill(); -} - -bool ResourceGroupwareBase::load() -{ - return asyncLoad(); -} - -bool ResourceGroupwareBase::asyncLoad() -{ - if ( mDownloadJob ) { - kdWarning() << "Download still in progress" << endl; - return false; - } - - mAddrMap.clear(); - loadCache(); - - mDownloadJob = createDownloadJob( mAdaptor ); - connect( mDownloadJob, TQT_SIGNAL( result( KPIM::GroupwareJob * ) ), - TQT_SLOT( slotDownloadJobResult( KPIM::GroupwareJob * ) ) ); - - return true; -} - -void ResourceGroupwareBase::slotDownloadJobResult( KPIM::GroupwareJob *job ) -{ - kdDebug(5800) << "ResourceGroupwareBase::slotJobResult(): " << endl; - - if ( job->error() ) { - kdError() << "job failed: " << job->errorString() << endl; - } else { - emit loadingFinished( this ); - if ( addressBook() ) - addressBook()->emitAddressBookChanged(); - } - - mDownloadJob = 0; -} - -bool ResourceGroupwareBase::save( Ticket *ticket ) -{ - return asyncSave( ticket ); -} - -bool ResourceGroupwareBase::asyncSave( Ticket* ) -{ - if ( mUploadJob ) { - // FIXME: If the user cancels, need to reset the mUploadJob variable to 0. - kdWarning() << "Upload still in progress." << endl; - return false; - } - - mUploadJob = createUploadJob( mAdaptor ); - connect( mUploadJob, TQT_SIGNAL( result( KPIM::GroupwareJob * ) ), - TQT_SLOT( slotUploadJobResult( KPIM::GroupwareJob * ) ) ); - - KABC::Addressee::List addr; - KABC::Addressee::List::Iterator it; - KPIM::GroupwareUploadItem::List addedItems, changedItems, deletedItems; - - addr = addedAddressees(); - for( it = addr.begin(); it != addr.end(); ++it ) { - addedItems.append( adaptor()->newUploadItem( *it, - KPIM::GroupwareUploadItem::Added ) ); - } - // TODO: Check if the item has changed on the server... - // In particular, check if the version we based our change on is still current - // on the server - addr = changedAddressees(); - for( it = addr.begin(); it != addr.end(); ++it ) { - changedItems.append( adaptor()->newUploadItem( *it, - KPIM::GroupwareUploadItem::Changed ) ); - } - addr = deletedAddressees(); - for( it = addr.begin(); it != addr.end(); ++it ) { - deletedItems.append( adaptor()->newUploadItem( *it, - KPIM::GroupwareUploadItem::Deleted ) ); - } - - mUploadJob->setAddedItems( addedItems ); - mUploadJob->setChangedItems( changedItems ); - mUploadJob->setDeletedItems( deletedItems ); - - return true; -} - -void ResourceGroupwareBase::slotUploadJobResult( KPIM::GroupwareJob *job ) -{ - kdDebug(5800) << "ResourceGroupwareBase::slotJobResult(): " << endl; - - if ( job->error() ) { - kdError() << "job failed: " << job->errorString() << endl; - } else { - // FIXME - } - - mUploadJob = 0; -} - - -#include "kabc_resourcegroupwarebase.moc" diff --git a/tderesources/lib/kabc_resourcegroupwarebase.h b/tderesources/lib/kabc_resourcegroupwarebase.h deleted file mode 100644 index 28ce5199e..000000000 --- a/tderesources/lib/kabc_resourcegroupwarebase.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - Copyright (c) 2004 Till Adam - Copyright (C) 2005 Reinhold Kainhofer - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#ifndef KABC_RESOURCEGROUPWARE_H -#define KABC_RESOURCEGROUPWARE_H - -#include -#include -#include - -class TDEConfig; - -namespace KPIM { -class GroupwareJob; -class GroupwareDownloadJob; -class GroupwareUploadJob; -class FolderLister; -class GroupwarePrefsBase; -} - -namespace KABC { - -class AddressBookAdaptor; - -class KDE_EXPORT ResourceGroupwareBase : public ResourceCached -{ - Q_OBJECT - - - public: - ResourceGroupwareBase( const TDEConfig * ); - ~ResourceGroupwareBase(); - - void readConfig( const TDEConfig * ); - void writeConfig( TDEConfig * ); - - KPIM::GroupwarePrefsBase *prefs() const { return mPrefs; } - void setPrefs( KPIM::GroupwarePrefsBase *prefs ); - - KPIM::FolderLister *folderLister() const { return mFolderLister; } - void setFolderLister( KPIM::FolderLister *folderLister ); - - AddressBookAdaptor *adaptor() const { return mAdaptor; } - void setAdaptor( AddressBookAdaptor *adaptor ); - - bool doOpen(); - void doClose(); - - Ticket *requestSaveTicket(); - void releaseSaveTicket( Ticket* ); - - bool load(); - bool asyncLoad(); - bool save( Ticket * ); - bool asyncSave( Ticket * ); - - protected: - void init(); - - KPIM::GroupwarePrefsBase *createPrefs(); - virtual KPIM::GroupwareDownloadJob *createDownloadJob( - AddressBookAdaptor *adaptor ); - virtual KPIM::GroupwareUploadJob *createUploadJob( - AddressBookAdaptor *adaptor ); - - private slots: - void slotDownloadJobResult( KPIM::GroupwareJob * ); - void slotUploadJobResult( KPIM::GroupwareJob * ); - - private: - KPIM::GroupwarePrefsBase *mPrefs; - KPIM::FolderLister *mFolderLister; - AddressBookAdaptor *mAdaptor; - - KPIM::GroupwareDownloadJob *mDownloadJob; - KPIM::GroupwareUploadJob *mUploadJob; -}; - -} - -#endif diff --git a/tderesources/lib/kabc_resourcegroupwarebaseconfig.cpp b/tderesources/lib/kabc_resourcegroupwarebaseconfig.cpp deleted file mode 100644 index 918dfc52b..000000000 --- a/tderesources/lib/kabc_resourcegroupwarebaseconfig.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - Copyright (c) 2004 Till Adam - Copyright (c) 2005 Reinhold Kainhofer - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "kabc_resourcegroupwarebaseconfig.h" - -#include "kabc_resourcegroupwarebase.h" -#include "tderesources_groupwareprefs.h" -#include "folderconfig.h" - -#include -#include -#include -#include -#include - -#include -#include - -using namespace KABC; - -ResourceGroupwareBaseConfig::ResourceGroupwareBaseConfig( TQWidget* parent, const char* name ) - : KRES::ConfigWidget( parent, name ) -{ - TQGridLayout *mainLayout = new TQGridLayout( this, 7, 2, 0, KDialog::spacingHint() ); - - TQLabel *label = new TQLabel( i18n( "URL:" ), this ); - mURL = new KURLRequester( this ); - - mainLayout->addWidget( label, 0, 0 ); - mainLayout->addWidget( mURL, 0, 1 ); - - label = new TQLabel( i18n( "User:" ), this ); - mUser = new KLineEdit( this ); - - mainLayout->addWidget( label, 1, 0 ); - mainLayout->addWidget( mUser, 1, 1 ); - - label = new TQLabel( i18n( "Password:" ), this ); - mPassword = new KLineEdit( this ); - mPassword->setEchoMode( TQLineEdit::Password ); - - mainLayout->addWidget( label, 2, 0 ); - mainLayout->addWidget( mPassword, 2, 1 ); - - TQFrame *hline = new TQFrame( this ); - hline->setFrameStyle( TQFrame::HLine | TQFrame::Sunken ); - - mainLayout->addMultiCellWidget( hline, 3, 3, 0, 1 ); - - mFolderConfig = new KPIM::FolderConfig( this ); - connect( mFolderConfig, TQT_SIGNAL( updateFoldersClicked() ), - TQT_SLOT( updateFolders() ) ); - mainLayout->addMultiCellWidget( mFolderConfig, 4, 4, 0, 1 ); -} - -void ResourceGroupwareBaseConfig::loadSettings( KRES::Resource *res ) -{ - mResource = dynamic_cast( res ); - - if ( !mResource ) { - kdDebug(5700) << "ResourceGroupwareBaseConfig::loadSettings(): cast failed" << endl; - return; - } - - mURL->setURL( mResource->prefs()->url() ); - mUser->setText( mResource->prefs()->user() ); - mPassword->setText( mResource->prefs()->password() ); - - mFolderConfig->setFolderLister( mResource->folderLister() ); - mFolderConfig->updateFolderList(); -} - -void ResourceGroupwareBaseConfig::saveSettings( KRES::Resource *res ) -{ - ResourceGroupwareBase *resource = dynamic_cast( res ); - - if ( !resource ) { - kdDebug(5700) << "ResourceGroupwareBaseConfig::saveSettings(): cast failed" << endl; - return; - } - - resource->prefs()->setUrl( mURL->url() ); - resource->prefs()->setUser( mUser->text() ); - resource->prefs()->setPassword( mPassword->text() ); - - mFolderConfig->saveSettings(); -} - -void ResourceGroupwareBaseConfig::updateFolders() -{ - KURL url = mURL->url(); - url.setUser( mUser->text() ); - url.setPass( mPassword->text() ); - - mFolderConfig->retrieveFolderList( url ); -} - -#include "kabc_resourcegroupwarebaseconfig.moc" diff --git a/tderesources/lib/kabc_resourcegroupwarebaseconfig.h b/tderesources/lib/kabc_resourcegroupwarebaseconfig.h deleted file mode 100644 index f505d9ceb..000000000 --- a/tderesources/lib/kabc_resourcegroupwarebaseconfig.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - Copyright (c) 2004 Till Adam - Copyright (c) 2005 Reinhold Kainhofer - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#ifndef KABC_RESOURCEGROUPWAREBASECONFIG_H -#define KABC_RESOURCEGROUPWAREBASECONFIG_H - -#include -#include - -class KLineEdit; -class KURLRequester; - -namespace KPIM { -class FolderConfig; -} - -namespace KABC { - -class ResourceGroupwareBase; - -class KDE_EXPORT ResourceGroupwareBaseConfig : public KRES::ConfigWidget -{ - Q_OBJECT - - - public: - ResourceGroupwareBaseConfig( TQWidget* parent = 0, const char* name = 0 ); - - public slots: - void loadSettings( KRES::Resource* ); - void saveSettings( KRES::Resource* ); - - protected slots: - void updateFolders(); - - private: - KURLRequester *mURL; - KLineEdit *mUser; - KLineEdit *mPassword; - KPIM::FolderConfig *mFolderConfig; - - ResourceGroupwareBase *mResource; -}; - -} - -#endif diff --git a/tderesources/lib/tdeabc_resourcegroupwarebase.cpp b/tderesources/lib/tdeabc_resourcegroupwarebase.cpp new file mode 100644 index 000000000..3ebd175eb --- /dev/null +++ b/tderesources/lib/tdeabc_resourcegroupwarebase.cpp @@ -0,0 +1,262 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + Copyright (c) 2004 Till Adam + Copyright (C) 2005 Reinhold Kainhofer + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "kabc_resourcegroupwarebase.h" +#include "tderesources_groupwareprefs.h" + +#include "folderlister.h" +#include "addressbookadaptor.h" +#include "groupwaredownloadjob.h" +#include "groupwareuploadjob.h" + +#include +#include +#include + +using namespace KABC; + +ResourceGroupwareBase::ResourceGroupwareBase( const TDEConfig *config ) + : ResourceCached( config ), + mPrefs(0), mFolderLister(0), mAdaptor(0), mDownloadJob(0), mUploadJob(0) +{ + if ( config ) readConfig( config ); +} + +ResourceGroupwareBase::~ResourceGroupwareBase() +{ + delete mPrefs; + mPrefs = 0; +} + +KPIM::GroupwareDownloadJob *ResourceGroupwareBase::createDownloadJob( + AddressBookAdaptor *adaptor ) +{ + return new KPIM::GroupwareDownloadJob( adaptor ); +} + +KPIM::GroupwareUploadJob *ResourceGroupwareBase::createUploadJob( + AddressBookAdaptor *adaptor ) +{ + return new KPIM::GroupwareUploadJob( adaptor ); +} + +void ResourceGroupwareBase::setPrefs( KPIM::GroupwarePrefsBase *newprefs ) +{ + if ( !newprefs ) return; + if ( mPrefs ) delete mPrefs; + mPrefs = newprefs; + mPrefs->addGroupPrefix( identifier() ); + + mPrefs->readConfig(); + if ( mFolderLister ) mFolderLister->readConfig( mPrefs ); +} + +void ResourceGroupwareBase::setFolderLister( KPIM::FolderLister *folderLister ) +{ + if ( !folderLister ) return; + if ( mFolderLister ) delete mFolderLister; + mFolderLister = folderLister; + if ( mPrefs ) mFolderLister->readConfig( mPrefs ); + if ( mAdaptor ) { + mAdaptor->setFolderLister( mFolderLister ); + mFolderLister->setAdaptor( mAdaptor ); + } +} + +void ResourceGroupwareBase::setAdaptor( AddressBookAdaptor *adaptor ) +{ + if ( !adaptor ) return; + if ( mAdaptor ) delete mAdaptor; + mAdaptor = adaptor; + mAdaptor->setFolderLister( mFolderLister ); + if ( mFolderLister ) mFolderLister->setAdaptor( mAdaptor ); + mAdaptor->setDownloadProgressMessage( i18n("Downloading addressbook") ); + mAdaptor->setUploadProgressMessage( i18n("Uploading addressbook") ); + if ( prefs() ) { + mAdaptor->setBaseURL( prefs()->url() ); + mAdaptor->setUser( prefs()->user() ); + mAdaptor->setPassword( prefs()->password() ); + } + mAdaptor->setIdMapper( &idMapper() ); + mAdaptor->setResource( this ); +} + +void ResourceGroupwareBase::init() +{ + mDownloadJob = 0; +} + +KPIM::GroupwarePrefsBase *ResourceGroupwareBase::createPrefs() +{ + return new KPIM::GroupwarePrefsBase(); +} + + + +void ResourceGroupwareBase::readConfig( const TDEConfig */*config*/ ) +{ + kdDebug(5700) << "KABC::ResourceGroupwareBase::readConfig()" << endl; +// ResourceCached::readConfig( config ); + if ( mPrefs ) { + mPrefs->readConfig(); + if ( mFolderLister ) + mFolderLister->readConfig( mPrefs ); + } +} + +void ResourceGroupwareBase::writeConfig( TDEConfig *config ) +{ + Resource::writeConfig( config ); + + if ( mPrefs ) { + if ( mFolderLister ) + mFolderLister->writeConfig( mPrefs ); + mPrefs->writeConfig(); + } +} + +Ticket *ResourceGroupwareBase::requestSaveTicket() +{ + if ( !addressBook() ) { + kdDebug(5700) << "no addressbook" << endl; + return 0; + } + + return createTicket( this ); +} + +void ResourceGroupwareBase::releaseSaveTicket( Ticket *ticket ) +{ + delete ticket; +} + +bool ResourceGroupwareBase::doOpen() +{ + return true; +} + +void ResourceGroupwareBase::doClose() +{ + kdDebug(5800) << "ResourceGroupwareBase::doClose()" << endl; + + if ( mDownloadJob ) mDownloadJob->kill(); +} + +bool ResourceGroupwareBase::load() +{ + return asyncLoad(); +} + +bool ResourceGroupwareBase::asyncLoad() +{ + if ( mDownloadJob ) { + kdWarning() << "Download still in progress" << endl; + return false; + } + + mAddrMap.clear(); + loadCache(); + + mDownloadJob = createDownloadJob( mAdaptor ); + connect( mDownloadJob, TQT_SIGNAL( result( KPIM::GroupwareJob * ) ), + TQT_SLOT( slotDownloadJobResult( KPIM::GroupwareJob * ) ) ); + + return true; +} + +void ResourceGroupwareBase::slotDownloadJobResult( KPIM::GroupwareJob *job ) +{ + kdDebug(5800) << "ResourceGroupwareBase::slotJobResult(): " << endl; + + if ( job->error() ) { + kdError() << "job failed: " << job->errorString() << endl; + } else { + emit loadingFinished( this ); + if ( addressBook() ) + addressBook()->emitAddressBookChanged(); + } + + mDownloadJob = 0; +} + +bool ResourceGroupwareBase::save( Ticket *ticket ) +{ + return asyncSave( ticket ); +} + +bool ResourceGroupwareBase::asyncSave( Ticket* ) +{ + if ( mUploadJob ) { + // FIXME: If the user cancels, need to reset the mUploadJob variable to 0. + kdWarning() << "Upload still in progress." << endl; + return false; + } + + mUploadJob = createUploadJob( mAdaptor ); + connect( mUploadJob, TQT_SIGNAL( result( KPIM::GroupwareJob * ) ), + TQT_SLOT( slotUploadJobResult( KPIM::GroupwareJob * ) ) ); + + KABC::Addressee::List addr; + KABC::Addressee::List::Iterator it; + KPIM::GroupwareUploadItem::List addedItems, changedItems, deletedItems; + + addr = addedAddressees(); + for( it = addr.begin(); it != addr.end(); ++it ) { + addedItems.append( adaptor()->newUploadItem( *it, + KPIM::GroupwareUploadItem::Added ) ); + } + // TODO: Check if the item has changed on the server... + // In particular, check if the version we based our change on is still current + // on the server + addr = changedAddressees(); + for( it = addr.begin(); it != addr.end(); ++it ) { + changedItems.append( adaptor()->newUploadItem( *it, + KPIM::GroupwareUploadItem::Changed ) ); + } + addr = deletedAddressees(); + for( it = addr.begin(); it != addr.end(); ++it ) { + deletedItems.append( adaptor()->newUploadItem( *it, + KPIM::GroupwareUploadItem::Deleted ) ); + } + + mUploadJob->setAddedItems( addedItems ); + mUploadJob->setChangedItems( changedItems ); + mUploadJob->setDeletedItems( deletedItems ); + + return true; +} + +void ResourceGroupwareBase::slotUploadJobResult( KPIM::GroupwareJob *job ) +{ + kdDebug(5800) << "ResourceGroupwareBase::slotJobResult(): " << endl; + + if ( job->error() ) { + kdError() << "job failed: " << job->errorString() << endl; + } else { + // FIXME + } + + mUploadJob = 0; +} + + +#include "kabc_resourcegroupwarebase.moc" diff --git a/tderesources/lib/tdeabc_resourcegroupwarebase.h b/tderesources/lib/tdeabc_resourcegroupwarebase.h new file mode 100644 index 000000000..28ce5199e --- /dev/null +++ b/tderesources/lib/tdeabc_resourcegroupwarebase.h @@ -0,0 +1,99 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + Copyright (c) 2004 Till Adam + Copyright (C) 2005 Reinhold Kainhofer + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_RESOURCEGROUPWARE_H +#define KABC_RESOURCEGROUPWARE_H + +#include +#include +#include + +class TDEConfig; + +namespace KPIM { +class GroupwareJob; +class GroupwareDownloadJob; +class GroupwareUploadJob; +class FolderLister; +class GroupwarePrefsBase; +} + +namespace KABC { + +class AddressBookAdaptor; + +class KDE_EXPORT ResourceGroupwareBase : public ResourceCached +{ + Q_OBJECT + + + public: + ResourceGroupwareBase( const TDEConfig * ); + ~ResourceGroupwareBase(); + + void readConfig( const TDEConfig * ); + void writeConfig( TDEConfig * ); + + KPIM::GroupwarePrefsBase *prefs() const { return mPrefs; } + void setPrefs( KPIM::GroupwarePrefsBase *prefs ); + + KPIM::FolderLister *folderLister() const { return mFolderLister; } + void setFolderLister( KPIM::FolderLister *folderLister ); + + AddressBookAdaptor *adaptor() const { return mAdaptor; } + void setAdaptor( AddressBookAdaptor *adaptor ); + + bool doOpen(); + void doClose(); + + Ticket *requestSaveTicket(); + void releaseSaveTicket( Ticket* ); + + bool load(); + bool asyncLoad(); + bool save( Ticket * ); + bool asyncSave( Ticket * ); + + protected: + void init(); + + KPIM::GroupwarePrefsBase *createPrefs(); + virtual KPIM::GroupwareDownloadJob *createDownloadJob( + AddressBookAdaptor *adaptor ); + virtual KPIM::GroupwareUploadJob *createUploadJob( + AddressBookAdaptor *adaptor ); + + private slots: + void slotDownloadJobResult( KPIM::GroupwareJob * ); + void slotUploadJobResult( KPIM::GroupwareJob * ); + + private: + KPIM::GroupwarePrefsBase *mPrefs; + KPIM::FolderLister *mFolderLister; + AddressBookAdaptor *mAdaptor; + + KPIM::GroupwareDownloadJob *mDownloadJob; + KPIM::GroupwareUploadJob *mUploadJob; +}; + +} + +#endif diff --git a/tderesources/lib/tdeabc_resourcegroupwarebaseconfig.cpp b/tderesources/lib/tdeabc_resourcegroupwarebaseconfig.cpp new file mode 100644 index 000000000..918dfc52b --- /dev/null +++ b/tderesources/lib/tdeabc_resourcegroupwarebaseconfig.cpp @@ -0,0 +1,117 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + Copyright (c) 2004 Till Adam + Copyright (c) 2005 Reinhold Kainhofer + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "kabc_resourcegroupwarebaseconfig.h" + +#include "kabc_resourcegroupwarebase.h" +#include "tderesources_groupwareprefs.h" +#include "folderconfig.h" + +#include +#include +#include +#include +#include + +#include +#include + +using namespace KABC; + +ResourceGroupwareBaseConfig::ResourceGroupwareBaseConfig( TQWidget* parent, const char* name ) + : KRES::ConfigWidget( parent, name ) +{ + TQGridLayout *mainLayout = new TQGridLayout( this, 7, 2, 0, KDialog::spacingHint() ); + + TQLabel *label = new TQLabel( i18n( "URL:" ), this ); + mURL = new KURLRequester( this ); + + mainLayout->addWidget( label, 0, 0 ); + mainLayout->addWidget( mURL, 0, 1 ); + + label = new TQLabel( i18n( "User:" ), this ); + mUser = new KLineEdit( this ); + + mainLayout->addWidget( label, 1, 0 ); + mainLayout->addWidget( mUser, 1, 1 ); + + label = new TQLabel( i18n( "Password:" ), this ); + mPassword = new KLineEdit( this ); + mPassword->setEchoMode( TQLineEdit::Password ); + + mainLayout->addWidget( label, 2, 0 ); + mainLayout->addWidget( mPassword, 2, 1 ); + + TQFrame *hline = new TQFrame( this ); + hline->setFrameStyle( TQFrame::HLine | TQFrame::Sunken ); + + mainLayout->addMultiCellWidget( hline, 3, 3, 0, 1 ); + + mFolderConfig = new KPIM::FolderConfig( this ); + connect( mFolderConfig, TQT_SIGNAL( updateFoldersClicked() ), + TQT_SLOT( updateFolders() ) ); + mainLayout->addMultiCellWidget( mFolderConfig, 4, 4, 0, 1 ); +} + +void ResourceGroupwareBaseConfig::loadSettings( KRES::Resource *res ) +{ + mResource = dynamic_cast( res ); + + if ( !mResource ) { + kdDebug(5700) << "ResourceGroupwareBaseConfig::loadSettings(): cast failed" << endl; + return; + } + + mURL->setURL( mResource->prefs()->url() ); + mUser->setText( mResource->prefs()->user() ); + mPassword->setText( mResource->prefs()->password() ); + + mFolderConfig->setFolderLister( mResource->folderLister() ); + mFolderConfig->updateFolderList(); +} + +void ResourceGroupwareBaseConfig::saveSettings( KRES::Resource *res ) +{ + ResourceGroupwareBase *resource = dynamic_cast( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceGroupwareBaseConfig::saveSettings(): cast failed" << endl; + return; + } + + resource->prefs()->setUrl( mURL->url() ); + resource->prefs()->setUser( mUser->text() ); + resource->prefs()->setPassword( mPassword->text() ); + + mFolderConfig->saveSettings(); +} + +void ResourceGroupwareBaseConfig::updateFolders() +{ + KURL url = mURL->url(); + url.setUser( mUser->text() ); + url.setPass( mPassword->text() ); + + mFolderConfig->retrieveFolderList( url ); +} + +#include "kabc_resourcegroupwarebaseconfig.moc" diff --git a/tderesources/lib/tdeabc_resourcegroupwarebaseconfig.h b/tderesources/lib/tdeabc_resourcegroupwarebaseconfig.h new file mode 100644 index 000000000..f505d9ceb --- /dev/null +++ b/tderesources/lib/tdeabc_resourcegroupwarebaseconfig.h @@ -0,0 +1,65 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + Copyright (c) 2004 Till Adam + Copyright (c) 2005 Reinhold Kainhofer + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_RESOURCEGROUPWAREBASECONFIG_H +#define KABC_RESOURCEGROUPWAREBASECONFIG_H + +#include +#include + +class KLineEdit; +class KURLRequester; + +namespace KPIM { +class FolderConfig; +} + +namespace KABC { + +class ResourceGroupwareBase; + +class KDE_EXPORT ResourceGroupwareBaseConfig : public KRES::ConfigWidget +{ + Q_OBJECT + + + public: + ResourceGroupwareBaseConfig( TQWidget* parent = 0, const char* name = 0 ); + + public slots: + void loadSettings( KRES::Resource* ); + void saveSettings( KRES::Resource* ); + + protected slots: + void updateFolders(); + + private: + KURLRequester *mURL; + KLineEdit *mUser; + KLineEdit *mPassword; + KPIM::FolderConfig *mFolderConfig; + + ResourceGroupwareBase *mResource; +}; + +} + +#endif diff --git a/tderesources/newexchange/kabc_newexchange.desktop b/tderesources/newexchange/kabc_newexchange.desktop deleted file mode 100644 index c48d5f3cf..000000000 --- a/tderesources/newexchange/kabc_newexchange.desktop +++ /dev/null @@ -1,51 +0,0 @@ -[Desktop Entry] -Name=Addressbook on an Exchange Server (experimental) -Name[af]=Adresboek op 'n Exchange bediener (eksperimenteel) -Name[bg]=Адресник на сървър Exchange (експериментално) -Name[ca]=Llibreta d'adreces a un servidor Exchange (experimental) -Name[cs]=Kniha adres na serveru Exchange (experimentální) -Name[da]=Adressebog på en Exchange-server (eksperimentel) -Name[de]=Adressbuch auf einem Exchange-Server (experimentell) -Name[el]=Βιβλίο διευθύνσεων σε εξυπηρετητή Exchange (πειραματικό) -Name[es]=Libreta de direcciones en un servidor Exchange (experimental) -Name[et]=Aadressiraamat Exchange-serveris (eksperimentaalne) -Name[eu]=Helbide-liburua Exchange zerbitzari batean (esperimentala) -Name[fa]=کتاب نشانی روی یک کارساز مبادله )تجربی( -Name[fi]=Osoitekirja Exchange-palvelimella (kokeellinen) -Name[fr]=Carnet d'adresse sur un serveur Exchange (expérimental) -Name[fy]=Adresboek op in Exchange-tsjinner (eksperimenteel) -Name[ga]=Leabhar Seoltaí ar Fhreastalaí Exchange (trialach) -Name[gl]=Caderno de enderezos no Servidor Exchange2000 (experimental) -Name[hu]=Exchange-kiszolgáló címjegyzéke (kísérleti) -Name[is]=Vistfangaskrá Exchange þjóni (á tilraunarstigi) -Name[it]=Rubrica indirizzi su un server Exchange (sperimentale) -Name[ja]=Exchange サーバのアドレス帳 (実験版) -Name[kk]=Exchange серверіндегі адрестік кітапша (сынақтағы) -Name[km]=សៀវភៅ​អាសយដ្ឋាន​លើ​ម៉ាស៊ីន​បម្រើ Exchange (សម្រាប់​អ្នក​មាន​បទពិសោធន៍) -Name[lt]=Adresų knygelė Exchange serveryje (eksperimentine tvarka) -Name[mk]=Адресар на Exchange-сервер (експериментално) -Name[ms]=Buku Alamat pada pelayan Exchange (ujikaji) -Name[nb]=Adressebok på en Exchange-tjener (forsøksvis) -Name[nds]=Adressbook op en Exchange-Server (warrt utprobeert) -Name[ne]=एक्सचेन्ज सर्भरमा ठेगाना पुस्तिका (प्रयोगात्मक) -Name[nl]=Adresboek op een Exchange-server (experimenteel) -Name[nn]=Adressebok på ein Exchange-tenar (eksperimentelt) -Name[pl]=Książka adresowa na serwerze Exchange (eksperymentalne) -Name[pt]=Livro de endereços em servidor Exchange (experimental) -Name[pt_BR]=Livro de Endereços em um Servidor Exchange (experimenal) -Name[ru]=Адресная книга на сервере Exchange (экспериментально) -Name[sk]=Adresár na Exchange serveri (experimentálne) -Name[sl]=Adresar na strežniku Exchange (poskusno) -Name[sr]=Адресар на Exchange серверу (експериментално) -Name[sr@Latn]=Adresar na Exchange serveru (eksperimentalno) -Name[sv]=Adressbok på en Exchange-server (experimentell) -Name[ta]=IMAP சேவையக வழியாக கேஅஞ்சலில் நாள்காட்டி(சோதனைக்குரியது) -Name[tr]=Bir Exchange Sunucusu üzerinde Adres Defteri (deneyimsel) -Name[uk]=Адресна книга на сервері Exchange (експериментальне) -Name[zh_CN]=Exchange 服务器上的地址簿(试验性) -Name[zh_TW]=Exchanger 伺服器的通訊錄(實驗中) -X-TDE-Library=kabc_newexchange -Type=Service -ServiceTypes=KResources/Plugin -X-TDE-ResourceFamily=contact -X-TDE-ResourceType=newexchange diff --git a/tderesources/newexchange/kabc_newexchange_final.desktop b/tderesources/newexchange/kabc_newexchange_final.desktop deleted file mode 100644 index 19cdda43e..000000000 --- a/tderesources/newexchange/kabc_newexchange_final.desktop +++ /dev/null @@ -1,48 +0,0 @@ -[Desktop Entry] -Name=Addressbook on an Exchange Server -Name[af]=Adresboek op 'n Exchange bediener -Name[bg]=Адресник на сървър Exchange -Name[br]=Karned chomlec'hioù war ur servijer Exchange -Name[ca]=Llibreta d'adreces a un servidor Exchange -Name[cs]=Kniha adres na serveru Exchange -Name[da]=Adressebog på en Exchange-server -Name[de]=Adressbuch auf einem Exchange-Server -Name[el]=Βιβλίο διευθύνσεων σε εξυπηρετητή Exchange -Name[es]=Libreta de direcciones en un servidor Exchange -Name[et]=Aadressiraamat Exchange-serveris -Name[eu]=Helbide-liburua Exchange zerbitzari (esperimentala) -Name[fa]=کتاب نشانی روی یک کارساز مبادله -Name[fi]=Osoitekirja Exchange-palvelimella -Name[fr]=Carnet d'adresse sur un serveur Exchange -Name[fy]=Adresboek op in Exchange-tsjinner -Name[ga]=Leabhar Seoltaí ar Fhreastalaí Exchange -Name[gl]=Caderno de enderezos nun Servidor Exchange -Name[he]=פנקס כתובות בשרת Exchange -Name[hu]=Exchange-kiszolgáló címjegyzéke -Name[is]=Vistfangaskrá á Exchange þjóni -Name[it]=Rubrica indirizzi su un server Exchange -Name[ja]=Exchange サーバのアドレス帳 -Name[kk]=Exchange серверіндегі адрестік кітапша -Name[km]=សៀវភៅ​អាសយដ្ឋាន​លើ​ម៉ាស៊ីន​បម្រើ Exchange -Name[lt]=Adresų knygelė Exchange serveryje -Name[mk]=Адресар на Exchange-сервер -Name[ms]=Buku alamat pada pelayan Exchange -Name[nb]=Adressebok på en Exchange-tjener -Name[nds]=Adressbook op en Exchange-Server -Name[ne]=एक्सचेन्ज सर्भरमा ठेगाना पुस्तिका -Name[nl]=Adresboek op een Exchange-server -Name[nn]=Adressebok på ein Exchange-tenar -Name[pl]=Książka adresowa na serwerze Exchange -Name[pt]=Livro de endereços em servidor Exchange -Name[pt_BR]=Livro de Endereços em um Servidor Exchange -Name[ru]=Адресная книга на сервере Exchange -Name[sk]=Adresár na Exchange serveri -Name[sl]=Adresar na strežniko Exchange -Name[sr]=Адресар на Exchange серверу -Name[sr@Latn]=Adresar na Exchange serveru -Name[sv]=Adressbok på en Exchange-server -Name[ta]=ஒருமாற்று சேவகனில் முகவரிப்புத்தகம் -Name[tr]=Bir Exchange Sunucusu üzerinde Adres Defteri -Name[uk]=Адресна книга на сервері Exchange -Name[zh_CN]=Exchange 服务器上的地址簿 -Name[zh_TW]=Exchanger 伺服器上的通訊錄 diff --git a/tderesources/newexchange/kabc_resourceexchange.cpp b/tderesources/newexchange/kabc_resourceexchange.cpp deleted file mode 100644 index bd60cd2fc..000000000 --- a/tderesources/newexchange/kabc_resourceexchange.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (C) 2004 Reinhold Kainhofer - - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "exchangeaddressbookadaptor.h" - -#include "kabc_resourceexchange.h" -#include "groupwaredownloadjob.h" -#include "groupwareuploadjob.h" -#include "tderesources_groupwareprefs.h" - -#include - -using namespace KABC; - -ResourceExchange::ResourceExchange( const TDEConfig *config ) - : ResourceGroupwareBase( config ) -{ - init(); - if ( config ) { - readConfig( config ); - } else { - setResourceName( i18n( "Exchange Server" ) ); - } -} - -void ResourceExchange::init() -{ - setType( "ResourceExchange" ); - setPrefs( createPrefs() ); - setFolderLister( new KPIM::FolderLister( KPIM::FolderLister::AddressBook ) ); - setAdaptor( new ExchangeAddressBookAdaptor() ); - - ResourceGroupwareBase::init(); -} - -#include "kabc_resourceexchange.moc" diff --git a/tderesources/newexchange/kabc_resourceexchange.h b/tderesources/newexchange/kabc_resourceexchange.h deleted file mode 100644 index 941f91792..000000000 --- a/tderesources/newexchange/kabc_resourceexchange.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (C) 2004 Reinhold Kainhofer - - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#ifndef KABC_RESOURCEEXCHANGE_H -#define KABC_RESOURCEEXCHANGE_H - -#include - -namespace KABC { - -class KDE_EXPORT ResourceExchange : public ResourceGroupwareBase -{ - Q_OBJECT - - - public: - ResourceExchange( const TDEConfig * ); -/* ResourceExchange( const KURL &url, - const TQString &user, const TQString &password );*/ - protected: - void init(); -}; - -} - -#endif diff --git a/tderesources/newexchange/kabc_resourceexchange_plugin.cpp b/tderesources/newexchange/kabc_resourceexchange_plugin.cpp deleted file mode 100644 index adc0b6859..000000000 --- a/tderesources/newexchange/kabc_resourceexchange_plugin.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (C) 2004 Reinhold Kainhofer - - 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; either version 2 of the License, or - (at your option) any later version. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "kabc_resourceexchange.h" -#include "kabc_resourcegroupwarebaseconfig.h" - -using namespace KABC; - -typedef KRES::PluginFactory ExchangeFactory; -K_EXPORT_COMPONENT_FACTORY( kabc_newexchange, ExchangeFactory ) diff --git a/tderesources/newexchange/tdeabc_newexchange.desktop b/tderesources/newexchange/tdeabc_newexchange.desktop new file mode 100644 index 000000000..c48d5f3cf --- /dev/null +++ b/tderesources/newexchange/tdeabc_newexchange.desktop @@ -0,0 +1,51 @@ +[Desktop Entry] +Name=Addressbook on an Exchange Server (experimental) +Name[af]=Adresboek op 'n Exchange bediener (eksperimenteel) +Name[bg]=Адресник на сървър Exchange (експериментално) +Name[ca]=Llibreta d'adreces a un servidor Exchange (experimental) +Name[cs]=Kniha adres na serveru Exchange (experimentální) +Name[da]=Adressebog på en Exchange-server (eksperimentel) +Name[de]=Adressbuch auf einem Exchange-Server (experimentell) +Name[el]=Βιβλίο διευθύνσεων σε εξυπηρετητή Exchange (πειραματικό) +Name[es]=Libreta de direcciones en un servidor Exchange (experimental) +Name[et]=Aadressiraamat Exchange-serveris (eksperimentaalne) +Name[eu]=Helbide-liburua Exchange zerbitzari batean (esperimentala) +Name[fa]=کتاب نشانی روی یک کارساز مبادله )تجربی( +Name[fi]=Osoitekirja Exchange-palvelimella (kokeellinen) +Name[fr]=Carnet d'adresse sur un serveur Exchange (expérimental) +Name[fy]=Adresboek op in Exchange-tsjinner (eksperimenteel) +Name[ga]=Leabhar Seoltaí ar Fhreastalaí Exchange (trialach) +Name[gl]=Caderno de enderezos no Servidor Exchange2000 (experimental) +Name[hu]=Exchange-kiszolgáló címjegyzéke (kísérleti) +Name[is]=Vistfangaskrá Exchange þjóni (á tilraunarstigi) +Name[it]=Rubrica indirizzi su un server Exchange (sperimentale) +Name[ja]=Exchange サーバのアドレス帳 (実験版) +Name[kk]=Exchange серверіндегі адрестік кітапша (сынақтағы) +Name[km]=សៀវភៅ​អាសយដ្ឋាន​លើ​ម៉ាស៊ីន​បម្រើ Exchange (សម្រាប់​អ្នក​មាន​បទពិសោធន៍) +Name[lt]=Adresų knygelė Exchange serveryje (eksperimentine tvarka) +Name[mk]=Адресар на Exchange-сервер (експериментално) +Name[ms]=Buku Alamat pada pelayan Exchange (ujikaji) +Name[nb]=Adressebok på en Exchange-tjener (forsøksvis) +Name[nds]=Adressbook op en Exchange-Server (warrt utprobeert) +Name[ne]=एक्सचेन्ज सर्भरमा ठेगाना पुस्तिका (प्रयोगात्मक) +Name[nl]=Adresboek op een Exchange-server (experimenteel) +Name[nn]=Adressebok på ein Exchange-tenar (eksperimentelt) +Name[pl]=Książka adresowa na serwerze Exchange (eksperymentalne) +Name[pt]=Livro de endereços em servidor Exchange (experimental) +Name[pt_BR]=Livro de Endereços em um Servidor Exchange (experimenal) +Name[ru]=Адресная книга на сервере Exchange (экспериментально) +Name[sk]=Adresár na Exchange serveri (experimentálne) +Name[sl]=Adresar na strežniku Exchange (poskusno) +Name[sr]=Адресар на Exchange серверу (експериментално) +Name[sr@Latn]=Adresar na Exchange serveru (eksperimentalno) +Name[sv]=Adressbok på en Exchange-server (experimentell) +Name[ta]=IMAP சேவையக வழியாக கேஅஞ்சலில் நாள்காட்டி(சோதனைக்குரியது) +Name[tr]=Bir Exchange Sunucusu üzerinde Adres Defteri (deneyimsel) +Name[uk]=Адресна книга на сервері Exchange (експериментальне) +Name[zh_CN]=Exchange 服务器上的地址簿(试验性) +Name[zh_TW]=Exchanger 伺服器的通訊錄(實驗中) +X-TDE-Library=kabc_newexchange +Type=Service +ServiceTypes=KResources/Plugin +X-TDE-ResourceFamily=contact +X-TDE-ResourceType=newexchange diff --git a/tderesources/newexchange/tdeabc_newexchange_final.desktop b/tderesources/newexchange/tdeabc_newexchange_final.desktop new file mode 100644 index 000000000..19cdda43e --- /dev/null +++ b/tderesources/newexchange/tdeabc_newexchange_final.desktop @@ -0,0 +1,48 @@ +[Desktop Entry] +Name=Addressbook on an Exchange Server +Name[af]=Adresboek op 'n Exchange bediener +Name[bg]=Адресник на сървър Exchange +Name[br]=Karned chomlec'hioù war ur servijer Exchange +Name[ca]=Llibreta d'adreces a un servidor Exchange +Name[cs]=Kniha adres na serveru Exchange +Name[da]=Adressebog på en Exchange-server +Name[de]=Adressbuch auf einem Exchange-Server +Name[el]=Βιβλίο διευθύνσεων σε εξυπηρετητή Exchange +Name[es]=Libreta de direcciones en un servidor Exchange +Name[et]=Aadressiraamat Exchange-serveris +Name[eu]=Helbide-liburua Exchange zerbitzari (esperimentala) +Name[fa]=کتاب نشانی روی یک کارساز مبادله +Name[fi]=Osoitekirja Exchange-palvelimella +Name[fr]=Carnet d'adresse sur un serveur Exchange +Name[fy]=Adresboek op in Exchange-tsjinner +Name[ga]=Leabhar Seoltaí ar Fhreastalaí Exchange +Name[gl]=Caderno de enderezos nun Servidor Exchange +Name[he]=פנקס כתובות בשרת Exchange +Name[hu]=Exchange-kiszolgáló címjegyzéke +Name[is]=Vistfangaskrá á Exchange þjóni +Name[it]=Rubrica indirizzi su un server Exchange +Name[ja]=Exchange サーバのアドレス帳 +Name[kk]=Exchange серверіндегі адрестік кітапша +Name[km]=សៀវភៅ​អាសយដ្ឋាន​លើ​ម៉ាស៊ីន​បម្រើ Exchange +Name[lt]=Adresų knygelė Exchange serveryje +Name[mk]=Адресар на Exchange-сервер +Name[ms]=Buku alamat pada pelayan Exchange +Name[nb]=Adressebok på en Exchange-tjener +Name[nds]=Adressbook op en Exchange-Server +Name[ne]=एक्सचेन्ज सर्भरमा ठेगाना पुस्तिका +Name[nl]=Adresboek op een Exchange-server +Name[nn]=Adressebok på ein Exchange-tenar +Name[pl]=Książka adresowa na serwerze Exchange +Name[pt]=Livro de endereços em servidor Exchange +Name[pt_BR]=Livro de Endereços em um Servidor Exchange +Name[ru]=Адресная книга на сервере Exchange +Name[sk]=Adresár na Exchange serveri +Name[sl]=Adresar na strežniko Exchange +Name[sr]=Адресар на Exchange серверу +Name[sr@Latn]=Adresar na Exchange serveru +Name[sv]=Adressbok på en Exchange-server +Name[ta]=ஒருமாற்று சேவகனில் முகவரிப்புத்தகம் +Name[tr]=Bir Exchange Sunucusu üzerinde Adres Defteri +Name[uk]=Адресна книга на сервері Exchange +Name[zh_CN]=Exchange 服务器上的地址簿 +Name[zh_TW]=Exchanger 伺服器上的通訊錄 diff --git a/tderesources/newexchange/tdeabc_resourceexchange.cpp b/tderesources/newexchange/tdeabc_resourceexchange.cpp new file mode 100644 index 000000000..bd60cd2fc --- /dev/null +++ b/tderesources/newexchange/tdeabc_resourceexchange.cpp @@ -0,0 +1,54 @@ +/* + This file is part of tdepim. + + Copyright (C) 2004 Reinhold Kainhofer + + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "exchangeaddressbookadaptor.h" + +#include "kabc_resourceexchange.h" +#include "groupwaredownloadjob.h" +#include "groupwareuploadjob.h" +#include "tderesources_groupwareprefs.h" + +#include + +using namespace KABC; + +ResourceExchange::ResourceExchange( const TDEConfig *config ) + : ResourceGroupwareBase( config ) +{ + init(); + if ( config ) { + readConfig( config ); + } else { + setResourceName( i18n( "Exchange Server" ) ); + } +} + +void ResourceExchange::init() +{ + setType( "ResourceExchange" ); + setPrefs( createPrefs() ); + setFolderLister( new KPIM::FolderLister( KPIM::FolderLister::AddressBook ) ); + setAdaptor( new ExchangeAddressBookAdaptor() ); + + ResourceGroupwareBase::init(); +} + +#include "kabc_resourceexchange.moc" diff --git a/tderesources/newexchange/tdeabc_resourceexchange.h b/tderesources/newexchange/tdeabc_resourceexchange.h new file mode 100644 index 000000000..941f91792 --- /dev/null +++ b/tderesources/newexchange/tdeabc_resourceexchange.h @@ -0,0 +1,43 @@ +/* + This file is part of tdepim. + + Copyright (C) 2004 Reinhold Kainhofer + + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef KABC_RESOURCEEXCHANGE_H +#define KABC_RESOURCEEXCHANGE_H + +#include + +namespace KABC { + +class KDE_EXPORT ResourceExchange : public ResourceGroupwareBase +{ + Q_OBJECT + + + public: + ResourceExchange( const TDEConfig * ); +/* ResourceExchange( const KURL &url, + const TQString &user, const TQString &password );*/ + protected: + void init(); +}; + +} + +#endif diff --git a/tderesources/newexchange/tdeabc_resourceexchange_plugin.cpp b/tderesources/newexchange/tdeabc_resourceexchange_plugin.cpp new file mode 100644 index 000000000..adc0b6859 --- /dev/null +++ b/tderesources/newexchange/tdeabc_resourceexchange_plugin.cpp @@ -0,0 +1,27 @@ +/* + This file is part of tdepim. + + Copyright (C) 2004 Reinhold Kainhofer + + 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; either version 2 of the License, or + (at your option) any later version. + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "kabc_resourceexchange.h" +#include "kabc_resourcegroupwarebaseconfig.h" + +using namespace KABC; + +typedef KRES::PluginFactory ExchangeFactory; +K_EXPORT_COMPONENT_FACTORY( kabc_newexchange, ExchangeFactory ) diff --git a/tderesources/slox/kabc_ox.desktop b/tderesources/slox/kabc_ox.desktop deleted file mode 100644 index 39570ad29..000000000 --- a/tderesources/slox/kabc_ox.desktop +++ /dev/null @@ -1,46 +0,0 @@ -[Desktop Entry] -Name=OpenXchange Server -Name[af]=OpenXchange bediener -Name[bg]=Сървър OpenXchange -Name[br]=Servijer OpenXchange -Name[ca]=Servidor OpenXchange -Name[da]=Openxchange-server -Name[el]=Εξυπηρετητής OpenXchange -Name[es]=Servidor OpenXchange -Name[et]=OpenXchange server -Name[eu]=OpenXchange zerbitzaria -Name[fa]=کارساز OpenXchange -Name[fi]=OpenXchange-palvelin -Name[fr]=Serveur OpenXchange -Name[fy]=OpenXchange-tsjinner -Name[ga]=Freastalaí Openexchange -Name[gl]=Servidor OpenXchange -Name[hu]=OpenXchange-kiszolgáló -Name[is]=OpenXchange þjónn -Name[ja]=OpenXchange サーバ -Name[kk]=OpenXchange сервері -Name[km]=ម៉ាស៊ីន​បម្រើ OpenXchange -Name[lt]=OpenXchange serveris -Name[mk]=OpenXchange-сервер -Name[nb]=OpenExchange-tjener -Name[nds]=OpenXchange-Server -Name[ne]=ओपन एक्सचेन्ज सर्भर -Name[nl]=OpenXchange-server -Name[nn]=OpenXchange-tenar -Name[pl]=Server OpenXchange -Name[pt]=Servidor OpenXchange -Name[pt_BR]=Servidor OpenXchange -Name[ru]=Сервер OpenXchange -Name[sl]=Strežnik OpenXchange -Name[sr]=Openexchange сервер -Name[sr@Latn]=Openexchange server -Name[sv]=Openxchange-server -Name[tr]=OpenXchange Sunucusu -Name[uk]=Сервер OpenXchange -Name[zh_CN]=OpenXchange 服务器 -Name[zh_TW]=OpenXchange 伺服器 -X-TDE-Library=kabc_slox -Type=Service -ServiceTypes=KResources/Plugin -X-TDE-ResourceFamily=contact -X-TDE-ResourceType=ox diff --git a/tderesources/slox/kabc_slox.desktop b/tderesources/slox/kabc_slox.desktop deleted file mode 100644 index 6c7b0352c..000000000 --- a/tderesources/slox/kabc_slox.desktop +++ /dev/null @@ -1,51 +0,0 @@ -[Desktop Entry] -Name=SUSE LINUX Openexchange Server -Name[af]=SuSE Linux OpenExchange bediener -Name[bg]=Сървър SUSE LINUX Openexchange -Name[br]=Servijer Openexchange SUSE LINUX -Name[ca]=Servidor SUSE LINUX Openexchange -Name[cs]=SUSE LINUX Openexchange server -Name[da]=SUSE Linux Openexchange-server -Name[de]=SUSE LINUX Openexchange-Server -Name[el]=Εξυπηρετητή SUSE LINUX Openexchange -Name[es]=Servidor Openexchange de SUSE LINUX -Name[et]=SUSE LINUX Openexchange server -Name[eu]=SUSE LINUX Openexchange zerbitzaria -Name[fa]=کارساز SUSE LINUX Openexchange -Name[fi]=Suse Linux Openexchange -palvelin -Name[fr]=Serveur SUSE Linux Openexchange -Name[fy]=SUSE LINUX Openexchange-tsjinner -Name[ga]=Freastalaí Openexchange SUSE LINUX -Name[gl]=Servidor SUSE LINUX Openexchange -Name[hu]=SUSE LINUX Openexchange-kiszolgáló -Name[is]=SUSE LINUX Openexchange þjónn -Name[it]=Server SUSE LINUX Openexchange -Name[ja]=SUSE LINUX Openexchange サーバ -Name[kk]=SUSE LINUX Openexchange сервері -Name[km]=ម៉ាស៊ីន​បម្រើ Openexchange របស់​ស៊ូស៊ីលីនីក -Name[lt]=SUSE LINUX Openexchange serveris -Name[mk]=SUSE LINUX Openexchange-сервер -Name[ms]=Pelayan SUSE LINUX Openexchange -Name[nb]=SUSE LINUX Openexchange-tjener -Name[nds]=SUSE-Openexchangeserver -Name[ne]=SUSE LINUX ओपन एक्सचेन्ज सर्भर -Name[nl]=SUSE LINUX Openexchange-server -Name[nn]=SUSE LINUX Openexchange-tenar -Name[pl]=Server SUSE LINUX Openexchange -Name[pt]=Servidor SUSE LINUX Openexchange -Name[pt_BR]=Servidor OpenExchange do SUSE Linux (SLOX) -Name[ru]=Сервер SUSE LINUX Openexchange -Name[sl]=Strežnik SUSE LINUX Openexchange -Name[sr]=Openexchange сервер SUSE-овог Linux-а -Name[sr@Latn]=Openexchange server SUSE-ovog Linux-a -Name[sv]=SUSE Linux Openexchange-server -Name[ta]=SUSE LINUX திறந்த பரிமாற்ற சேவகன் -Name[tr]=SUSE LINUX Openexchange Sunucusu -Name[uk]=Сервер SUSE LINUX Openexchange -Name[zh_CN]=SUSE LINUX Openexchange 服务器 -Name[zh_TW]=SUSE LINUX Openexchange 伺服器 -X-TDE-Library=kabc_slox -Type=Service -ServiceTypes=KResources/Plugin -X-TDE-ResourceFamily=contact -X-TDE-ResourceType=slox diff --git a/tderesources/slox/kabcresourceslox.cpp b/tderesources/slox/kabcresourceslox.cpp index 426d86add..17b282969 100644 --- a/tderesources/slox/kabcresourceslox.cpp +++ b/tderesources/slox/kabcresourceslox.cpp @@ -243,7 +243,7 @@ void ResourceSlox::slotResult( TDEIO::Job *job ) TQValueList::ConstIterator it; for( it = items.begin(); it != items.end(); ++it ) { SloxItem item = *it; - TQString uid = "tderesources_slox_kabc_" + item.sloxId; + TQString uid = "tderesources_slox_tdeabc_" + item.sloxId; if ( item.status == SloxItem::Delete ) { TQMap::Iterator it; it = mAddrMap.find( uid ); @@ -317,7 +317,7 @@ void ResourceSlox::slotUploadResult( TDEIO::Job *job ) // use the id provided by the server Addressee a = *search_res; mAddrMap.remove( search_res ); - a.setUid( "tderesources_slox_kabc_" + item.sloxId ); + a.setUid( "tderesources_slox_tdeabc_" + item.sloxId ); a.setResource( this ); a.setChanged( false ); mAddrMap.replace( a.uid(), a ); @@ -494,7 +494,7 @@ void ResourceSlox::uploadContacts() } else if ( !changedAddr.isEmpty() ) { mUploadAddressee = changedAddr.first(); WebdavHandler::addSloxElement( this, doc, prop, fieldName( ObjectId ), - mUploadAddressee.uid().remove( 0, sizeof("tderesources_slox_kabc_") - 1) ); + mUploadAddressee.uid().remove( 0, sizeof("tderesources_slox_tdeabc_") - 1) ); } else if ( !deletedAddr.isEmpty() ) { mUploadAddressee = deletedAddr.first(); isDelete = true; @@ -507,7 +507,7 @@ void ResourceSlox::uploadContacts() if ( !isDelete ) { createAddresseeFields( doc, prop, mUploadAddressee ); } else { - TQString tmp_uid = mUploadAddressee.uid().remove( 0, sizeof("tderesources_slox_kabc_") - 1); // remove prefix from uid + TQString tmp_uid = mUploadAddressee.uid().remove( 0, sizeof("tderesources_slox_tdeabc_") - 1); // remove prefix from uid WebdavHandler::addSloxElement( this, doc, prop, fieldName( ObjectId ), tmp_uid ); WebdavHandler::addSloxElement( this, doc, prop, "method", "DELETE" ); } diff --git a/tderesources/slox/kabcresourceslox_plugin.cpp b/tderesources/slox/kabcresourceslox_plugin.cpp index 0ee425179..49e1f368b 100644 --- a/tderesources/slox/kabcresourceslox_plugin.cpp +++ b/tderesources/slox/kabcresourceslox_plugin.cpp @@ -30,7 +30,7 @@ typedef KRES::PluginFactory< ResourceSlox, ResourceSloxConfig > SloxFactory; extern "C" { - void *init_kabc_slox() + void *init_tdeabc_slox() { TDEGlobal::locale()->insertCatalogue( "libkcal" ); TDEGlobal::locale()->insertCatalogue( "kabc_slox" ); diff --git a/tderesources/slox/kabcsloxprefs.kcfgc b/tderesources/slox/kabcsloxprefs.kcfgc index 51bd1ac16..70c006f52 100644 --- a/tderesources/slox/kabcsloxprefs.kcfgc +++ b/tderesources/slox/kabcsloxprefs.kcfgc @@ -1,5 +1,5 @@ # Code generation options for tdeconfig_compiler -File=tderesources_kabc_slox.kcfg +File=tderesources_tdeabc_slox.kcfg ClassName=SloxPrefs NameSpace=KABC Singleton=false diff --git a/tderesources/slox/tdeabc_ox.desktop b/tderesources/slox/tdeabc_ox.desktop new file mode 100644 index 000000000..39570ad29 --- /dev/null +++ b/tderesources/slox/tdeabc_ox.desktop @@ -0,0 +1,46 @@ +[Desktop Entry] +Name=OpenXchange Server +Name[af]=OpenXchange bediener +Name[bg]=Сървър OpenXchange +Name[br]=Servijer OpenXchange +Name[ca]=Servidor OpenXchange +Name[da]=Openxchange-server +Name[el]=Εξυπηρετητής OpenXchange +Name[es]=Servidor OpenXchange +Name[et]=OpenXchange server +Name[eu]=OpenXchange zerbitzaria +Name[fa]=کارساز OpenXchange +Name[fi]=OpenXchange-palvelin +Name[fr]=Serveur OpenXchange +Name[fy]=OpenXchange-tsjinner +Name[ga]=Freastalaí Openexchange +Name[gl]=Servidor OpenXchange +Name[hu]=OpenXchange-kiszolgáló +Name[is]=OpenXchange þjónn +Name[ja]=OpenXchange サーバ +Name[kk]=OpenXchange сервері +Name[km]=ម៉ាស៊ីន​បម្រើ OpenXchange +Name[lt]=OpenXchange serveris +Name[mk]=OpenXchange-сервер +Name[nb]=OpenExchange-tjener +Name[nds]=OpenXchange-Server +Name[ne]=ओपन एक्सचेन्ज सर्भर +Name[nl]=OpenXchange-server +Name[nn]=OpenXchange-tenar +Name[pl]=Server OpenXchange +Name[pt]=Servidor OpenXchange +Name[pt_BR]=Servidor OpenXchange +Name[ru]=Сервер OpenXchange +Name[sl]=Strežnik OpenXchange +Name[sr]=Openexchange сервер +Name[sr@Latn]=Openexchange server +Name[sv]=Openxchange-server +Name[tr]=OpenXchange Sunucusu +Name[uk]=Сервер OpenXchange +Name[zh_CN]=OpenXchange 服务器 +Name[zh_TW]=OpenXchange 伺服器 +X-TDE-Library=kabc_slox +Type=Service +ServiceTypes=KResources/Plugin +X-TDE-ResourceFamily=contact +X-TDE-ResourceType=ox diff --git a/tderesources/slox/tdeabc_slox.desktop b/tderesources/slox/tdeabc_slox.desktop new file mode 100644 index 000000000..6c7b0352c --- /dev/null +++ b/tderesources/slox/tdeabc_slox.desktop @@ -0,0 +1,51 @@ +[Desktop Entry] +Name=SUSE LINUX Openexchange Server +Name[af]=SuSE Linux OpenExchange bediener +Name[bg]=Сървър SUSE LINUX Openexchange +Name[br]=Servijer Openexchange SUSE LINUX +Name[ca]=Servidor SUSE LINUX Openexchange +Name[cs]=SUSE LINUX Openexchange server +Name[da]=SUSE Linux Openexchange-server +Name[de]=SUSE LINUX Openexchange-Server +Name[el]=Εξυπηρετητή SUSE LINUX Openexchange +Name[es]=Servidor Openexchange de SUSE LINUX +Name[et]=SUSE LINUX Openexchange server +Name[eu]=SUSE LINUX Openexchange zerbitzaria +Name[fa]=کارساز SUSE LINUX Openexchange +Name[fi]=Suse Linux Openexchange -palvelin +Name[fr]=Serveur SUSE Linux Openexchange +Name[fy]=SUSE LINUX Openexchange-tsjinner +Name[ga]=Freastalaí Openexchange SUSE LINUX +Name[gl]=Servidor SUSE LINUX Openexchange +Name[hu]=SUSE LINUX Openexchange-kiszolgáló +Name[is]=SUSE LINUX Openexchange þjónn +Name[it]=Server SUSE LINUX Openexchange +Name[ja]=SUSE LINUX Openexchange サーバ +Name[kk]=SUSE LINUX Openexchange сервері +Name[km]=ម៉ាស៊ីន​បម្រើ Openexchange របស់​ស៊ូស៊ីលីនីក +Name[lt]=SUSE LINUX Openexchange serveris +Name[mk]=SUSE LINUX Openexchange-сервер +Name[ms]=Pelayan SUSE LINUX Openexchange +Name[nb]=SUSE LINUX Openexchange-tjener +Name[nds]=SUSE-Openexchangeserver +Name[ne]=SUSE LINUX ओपन एक्सचेन्ज सर्भर +Name[nl]=SUSE LINUX Openexchange-server +Name[nn]=SUSE LINUX Openexchange-tenar +Name[pl]=Server SUSE LINUX Openexchange +Name[pt]=Servidor SUSE LINUX Openexchange +Name[pt_BR]=Servidor OpenExchange do SUSE Linux (SLOX) +Name[ru]=Сервер SUSE LINUX Openexchange +Name[sl]=Strežnik SUSE LINUX Openexchange +Name[sr]=Openexchange сервер SUSE-овог Linux-а +Name[sr@Latn]=Openexchange server SUSE-ovog Linux-a +Name[sv]=SUSE Linux Openexchange-server +Name[ta]=SUSE LINUX திறந்த பரிமாற்ற சேவகன் +Name[tr]=SUSE LINUX Openexchange Sunucusu +Name[uk]=Сервер SUSE LINUX Openexchange +Name[zh_CN]=SUSE LINUX Openexchange 服务器 +Name[zh_TW]=SUSE LINUX Openexchange 伺服器 +X-TDE-Library=kabc_slox +Type=Service +ServiceTypes=KResources/Plugin +X-TDE-ResourceFamily=contact +X-TDE-ResourceType=slox diff --git a/tderesources/slox/tderesources_kabc_slox.kcfg b/tderesources/slox/tderesources_kabc_slox.kcfg deleted file mode 100644 index 6e3057e64..000000000 --- a/tderesources/slox/tderesources_kabc_slox.kcfg +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - true - - - - - - - - - - - diff --git a/tderesources/slox/tderesources_tdeabc_slox.kcfg b/tderesources/slox/tderesources_tdeabc_slox.kcfg new file mode 100644 index 000000000..a193ee02b --- /dev/null +++ b/tderesources/slox/tderesources_tdeabc_slox.kcfg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + true + + + + + + + + + + + -- cgit v1.2.1