diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch) | |
tree | 67208f7c145782a7e90b123b982ca78d88cc2c87 /kontact/plugins/test | |
download | tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kontact/plugins/test')
-rw-r--r-- | kontact/plugins/test/Makefile.am | 20 | ||||
-rw-r--r-- | kontact/plugins/test/kptestplugin.desktop | 113 | ||||
-rw-r--r-- | kontact/plugins/test/kptestplugin.rc | 10 | ||||
-rw-r--r-- | kontact/plugins/test/test_part.cpp | 117 | ||||
-rw-r--r-- | kontact/plugins/test/test_part.h | 61 | ||||
-rw-r--r-- | kontact/plugins/test/test_plugin.cpp | 61 | ||||
-rw-r--r-- | kontact/plugins/test/test_plugin.h | 51 | ||||
-rw-r--r-- | kontact/plugins/test/testpartui.rc | 10 |
8 files changed, 443 insertions, 0 deletions
diff --git a/kontact/plugins/test/Makefile.am b/kontact/plugins/test/Makefile.am new file mode 100644 index 000000000..3fbac9eb3 --- /dev/null +++ b/kontact/plugins/test/Makefile.am @@ -0,0 +1,20 @@ +INCLUDES = -I$(top_srcdir)/kontact/interfaces $(all_includes) + +kde_module_LTLIBRARIES = libkptestplugin.la +libkptestplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkptestplugin_la_LIBADD = $(top_builddir)/kontact/interfaces/libkpinterfaces.la $(LIB_KPARTS) + +libkptestplugin_la_SOURCES = test_plugin.cpp test_part.cpp kaddressbookiface.stub + +kaddressbookiface_DIR = $(top_srcdir)/kaddressbook + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir) +service_DATA = kptestplugin.desktop + +rc_DATA = kptestplugin.rc +rcdir = $(kde_datadir)/kptestplugin + +kpartrc_DATA = testpartui.rc +kpartrcdir = $(kde_datadir)/testpart diff --git a/kontact/plugins/test/kptestplugin.desktop b/kontact/plugins/test/kptestplugin.desktop new file mode 100644 index 000000000..17a3e52e9 --- /dev/null +++ b/kontact/plugins/test/kptestplugin.desktop @@ -0,0 +1,113 @@ +[Desktop Entry] +Type=Service +Icon=konsole +ServiceTypes=Kontact/Plugin,KPluginInfo + +X-KDE-Library=libkptestplugin +X-KDE-KontactPluginVersion=6 + +X-KDE-PluginInfo-Name=kptestplugin +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-EnabledByDefault=false + +Comment=Kontact Test Plugin +Comment[af]=Kontact toets inprop module +Comment[be]=Тэставае дапаўненне Кантакту +Comment[bg]=Приставка за проба +Comment[bs]=Kontact testni dodatak +Comment[ca]=Endollable de prova per a Kontact +Comment[cy]=Ategyn Prawf Kontact +Comment[da]=Kontact Test-plugin +Comment[de]=Test-Modul für Kontact +Comment[el]=Δοκιμαστικό πρόσθετο του Kontact +Comment[eo]=Kontact-Testkromaĵo +Comment[es]=Plugin de prueba para Kontact +Comment[et]=Kontacti testplugin +Comment[eu]=Kontact-en proba plugin-a +Comment[fa]=وصلۀ آزمون Kontact +Comment[fi]=Kontactin testiliitännäinen +Comment[fr]=Module de test pour Kontact +Comment[fy]=Kontact Test-plugin +Comment[gl]=Extensión de Proba para Kontact +Comment[he]=תוסף ניסיון עבור Kontact +Comment[hi]=कॉन्टेक्ट जांच प्लगइन +Comment[hu]=Kontact tesztmodul +Comment[is]=Kontact prufu íforrit +Comment[it]=Plugin test Kontact +Comment[ja]=Kontact テストプラグイン +Comment[ka]=Kontact სატესტო მოდული +Comment[kk]=Сынақ модулі +Comment[km]=កម្មវិធីជំនួយការសាកល្បងក្នុង Kontact +Comment[lt]=Kontact bandymo priedas +Comment[mk]=Приклучок за тест на Контакт +Comment[ms]=Plugin Ujian Kontact +Comment[nb]=Kontact test-programtillegg +Comment[nds]=Test-Moduul för Kontact +Comment[ne]=परीक्षण प्लगइनमा सम्पर्क गर्नुहोस् +Comment[nl]=Kontact Test-plugin +Comment[nn]=Kontact, test-programtillegg +Comment[pl]=Wtyczka Kontact do testowania +Comment[pt]='Plugin' de Teste do Kontact +Comment[pt_BR]=Plug-in para Teste do Kontact +Comment[ro]=Modul de test Kontact +Comment[ru]=Проверочный модуль Kontact +Comment[se]=Kontact, geahččalanlassemoduvla +Comment[sl]=Preizkusni vstavek za Kontact +Comment[sr]=Пробни прикључак Kontact-а +Comment[sr@Latn]=Probni priključak Kontact-a +Comment[sv]=Kontact-testinsticksprogram +Comment[ta]=பரிசோதனை சொருகுப்பொருளை தொடர்பு கொள் +Comment[tg]=Модули матнии Kontact +Comment[tr]=Kontact Test Eklentisi +Comment[uk]=Тестовий втулок Kontact +Comment[uz]=Kontact uchun sinash plagini +Comment[uz@cyrillic]=Kontact учун синаш плагини +Comment[zh_CN]=Kontact Test 插件 +Comment[zh_TW]=Kontact 測試外掛程式 +Name=TestPlugin +Name[af]=Toets inprop module +Name[be]=Тэставае дапаўненне +Name[bg]=Приставка за тестване +Name[ca]=Endollable de prova +Name[cy]=AtegynPrawf +Name[de]=TestModul +Name[el]=Πρόσθετο ελέγχου +Name[eo]=Testo-kromaĵo +Name[fa]=وصلۀ آزمون +Name[fr]=Module de test +Name[fy]=Test-plugin +Name[he]=תוסף ניסיון +Name[hi]=टेस्ट-प्लगइन +Name[hr]=Probni dodatak +Name[hu]=Tesztmodul +Name[is]=Prufu íforrit +Name[it]=Plugin Test +Name[ja]=テストプラグイン +Name[ka]=სატესტო მოდული +Name[kk]=Сынақ модулі +Name[km]=កម្មវិធីជំនួយការសាកល្បង +Name[mk]=Приклучок за тест +Name[ms]=Plugin Ujian +Name[nb]=Test-programtillegg +Name[nds]=Testmoduul +Name[ne]=परीक्षण प्लगइन +Name[nl]=Test-plugin +Name[nn]=Test-programtillegg +Name[nso]=Plugin ya Teko +Name[pl]=Wtyczka testowa +Name[pt_BR]=Plug-in de Teste +Name[ro]=Modul de test +Name[ru]=Проверочный модуль +Name[se]=Geahččalan-lassemoduvla +Name[sk]=TestModul +Name[sl]=Preizkusni vstavek +Name[sr]=Пробни прикључак +Name[sr@Latn]=Probni priključak +Name[sv]=Testinsticksprogram +Name[ta]=சோதனை சொருகுப்பொருள் +Name[tg]=Модули матнӣ +Name[tr]=Test Eklentisi +Name[uk]=Тестовий втулок +Name[ven]=Lingani Plugin +Name[zh_CN]=Test 插件 +Name[zh_TW]=測試外掛程式 diff --git a/kontact/plugins/test/kptestplugin.rc b/kontact/plugins/test/kptestplugin.rc new file mode 100644 index 000000000..0931d6c90 --- /dev/null +++ b/kontact/plugins/test/kptestplugin.rc @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<!DOCTYPE gui> +<gui name="kptestplugin" version="1"> +<MenuBar> + <Menu name="edit"><Text>&Edit</Text> + <Action name="edit_test"/> + </Menu> +</MenuBar> +</gui> + diff --git a/kontact/plugins/test/test_part.cpp b/kontact/plugins/test/test_part.cpp new file mode 100644 index 000000000..6477d1420 --- /dev/null +++ b/kontact/plugins/test/test_part.cpp @@ -0,0 +1,117 @@ +/* + This file is part of KDE Kontact. + + Copyright (c) 2001 Matthias Hoelzer-Kluepfel <mhk@kde.org> + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include "test_part.h" +#include "kaddressbookiface_stub.h" + +#include <qtextedit.h> +#include <qcombobox.h> + +#include "sidebarextension.h" + +#include <kmessagebox.h> +#include <klocale.h> +#include <kaction.h> +#include <kapplication.h> +#include <kdebug.h> +#include <dcopclient.h> +#include <kdcopservicestarter.h> +#include <ktrader.h> +#include <kservice.h> + + +TestPart::TestPart(QObject *parent, const char *name) // ## parentWidget + : KParts::ReadOnlyPart(parent, name) +{ + setInstance( new KInstance("testpart") ); // ## memleak + m_edit = new QTextEdit; + setWidget(m_edit); + setXMLFile("testpartui.rc"); + new KAction( "new contact (test)", 0, this, SLOT( newContact() ), actionCollection(), "test_deleteevent" ); + m_kab_stub = 0L; + + new KParts::SideBarExtension(new QComboBox(this), this, "sbe"); + + kapp->dcopClient()->setNotifications( true ); + connect( kapp->dcopClient(), SIGNAL( applicationRemoved( const QCString&)), + this, SLOT( unregisteredFromDCOP( const QCString& )) ); +} + +TestPart::~TestPart() +{ + kapp->dcopClient()->setNotifications( false ); + delete m_kab_stub; +} + +void TestPart::newContact() +{ + if ( !connectToAddressBook() ) + return; + + kdDebug(5602) << "Calling newContact" << endl; + m_kab_stub->newContact(); + + // If critical call: test that it worked ok + if ( !m_kab_stub->ok() ) { + kdDebug(5602) << "Communication problem - ERROR" << endl; + // TODO handle the error + } +} + +bool TestPart::connectToAddressBook() +{ + if ( !m_kab_stub ) + { + QString error; + QCString dcopService; + int result = KDCOPServiceStarter::self()->findServiceFor( "DCOP/AddressBook", QString::null, QString::null, &error, &dcopService ); + if ( result != 0 ) { + // You might want to show "error" (if not empty) here, using e.g. KMessageBox + return false; + } + // TODO document the required named for the dcop interfaces e.g. "CalendarIface". + QCString dcopObjectId = "KAddressBookIface"; + m_kab_stub = new KAddressBookIface_stub(kapp->dcopClient(), dcopService, dcopObjectId); + } + return m_kab_stub != 0L; +} + +void TestPart::unregisteredFromDCOP( const QCString& appId ) +{ + if ( m_kab_stub && m_kab_stub->app() == appId ) + { + // Delete the stub so that the next time we need the addressbook, + // we'll know that we need to start a new one. + delete m_kab_stub; + m_kab_stub = 0L; + } +} + +bool TestPart::openFile() +{ + m_edit->setText(m_file); + return true; +} + +#include "test_part.moc" diff --git a/kontact/plugins/test/test_part.h b/kontact/plugins/test/test_part.h new file mode 100644 index 000000000..8f2a927c1 --- /dev/null +++ b/kontact/plugins/test/test_part.h @@ -0,0 +1,61 @@ +/* + This file is part of KDE Kontact. + + Copyright (c) 2001 Matthias Hoelzer-Kluepfel <mhk@kde.org> + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#ifndef TEST_PART_H +#define TEST_PART_H + + + +#include <kparts/part.h> + +class QTextEdit; +class KAddressBookIface_stub; + +class TestPart : public KParts::ReadOnlyPart +{ + Q_OBJECT + +public: + + TestPart(QObject *parent=0, const char *name=0); + ~TestPart(); + +protected: + + virtual bool openFile(); + bool connectToAddressBook(); + +protected slots: + + void newContact(); + void unregisteredFromDCOP( const QCString& ); + +private: + + QTextEdit *m_edit; + KAddressBookIface_stub *m_kab_stub; + +}; + + +#endif diff --git a/kontact/plugins/test/test_plugin.cpp b/kontact/plugins/test/test_plugin.cpp new file mode 100644 index 000000000..62bd74bd2 --- /dev/null +++ b/kontact/plugins/test/test_plugin.cpp @@ -0,0 +1,61 @@ +/* + This file is part of KDE Kontact. + + Copyright (c) 2001 Matthias Hoelzer-Kluepfel <mhk@kde.org> + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#include <kmessagebox.h> +#include <kaction.h> +#include <kgenericfactory.h> +#include <kstatusbar.h> + +#include "core.h" + +#include "test_plugin.h" +#include "test_part.h" + +typedef KGenericFactory< TestPlugin, Kontact::Core > TestPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkptestplugin, TestPluginFactory( "kptestplugin" ) ) + +TestPlugin::TestPlugin(Kontact::Core *_core, const char *name, const QStringList &) + : Kontact::Plugin(_core, _core, name) +{ + setInstance(TestPluginFactory::instance()); + + insertNewAction(new KAction("Test", 0, this, SLOT(slotTestMenu()), actionCollection(), "edit_test")); + + setXMLFile("kptestplugin.rc"); +} + +TestPlugin::~TestPlugin() +{ +} + +void TestPlugin::slotTestMenu() +{ + core()->statusBar()->message("Test menu activated"); +} + +KParts::Part* TestPlugin::createPart() +{ + return new TestPart(this, "testpart"); +} + +#include "test_plugin.moc" diff --git a/kontact/plugins/test/test_plugin.h b/kontact/plugins/test/test_plugin.h new file mode 100644 index 000000000..35b60283d --- /dev/null +++ b/kontact/plugins/test/test_plugin.h @@ -0,0 +1,51 @@ +/* + This file is part of KDE Kontact. + + Copyright (c) 2001 Matthias Hoelzer-Kluepfel <mhk@kde.org> + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#ifndef TEST_PLUGIN_H +#define TEST_PLUGIN_H + + +#include "plugin.h" + + +class TestPart; + + +class TestPlugin : public Kontact::Plugin +{ + Q_OBJECT + +public: + + TestPlugin(Kontact::Core *core, const char *name, const QStringList &); + ~TestPlugin(); + +protected: + KParts::Part* createPart(); + +private slots: + + void slotTestMenu(); +}; + +#endif diff --git a/kontact/plugins/test/testpartui.rc b/kontact/plugins/test/testpartui.rc new file mode 100644 index 000000000..ad5c6764d --- /dev/null +++ b/kontact/plugins/test/testpartui.rc @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<!DOCTYPE gui> +<gui name="testpart" version="1"> +<MenuBar> + <Menu name="edit"><Text>&Edit</Text> + <Action name="test_deleteevent"/> + </Menu> +</MenuBar> +</gui> + |