From bd9e6617827818fd043452c08c606f07b78014a0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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/kdesdk@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kbugbuster/kresources/Makefile.am | 16 ++ kbugbuster/kresources/bugzilla.desktop | 48 ++++ kbugbuster/kresources/kcalresource.cpp | 316 +++++++++++++++++++++ kbugbuster/kresources/kcalresource.h | 123 ++++++++ kbugbuster/kresources/kcalresource_plugin.cpp | 37 +++ kbugbuster/kresources/kcalresourceconfig.cpp | 92 ++++++ kbugbuster/kresources/kcalresourceconfig.h | 53 ++++ .../kresources/kresources_kcal_bugzilla.kcfg | 20 ++ kbugbuster/kresources/resourceprefs.kcfgc | 9 + 9 files changed, 714 insertions(+) create mode 100644 kbugbuster/kresources/Makefile.am create mode 100644 kbugbuster/kresources/bugzilla.desktop create mode 100644 kbugbuster/kresources/kcalresource.cpp create mode 100644 kbugbuster/kresources/kcalresource.h create mode 100644 kbugbuster/kresources/kcalresource_plugin.cpp create mode 100644 kbugbuster/kresources/kcalresourceconfig.cpp create mode 100644 kbugbuster/kresources/kcalresourceconfig.h create mode 100644 kbugbuster/kresources/kresources_kcal_bugzilla.kcfg create mode 100644 kbugbuster/kresources/resourceprefs.kcfgc (limited to 'kbugbuster/kresources') diff --git a/kbugbuster/kresources/Makefile.am b/kbugbuster/kresources/Makefile.am new file mode 100644 index 00000000..ddfde0fa --- /dev/null +++ b/kbugbuster/kresources/Makefile.am @@ -0,0 +1,16 @@ +INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/kbugbuster/backend $(all_includes) + +kde_module_LTLIBRARIES = kcal_bugzilla.la + +kcal_bugzilla_la_SOURCES = kcalresource.cpp kcalresourceconfig.cpp \ + kcalresource_plugin.cpp resourceprefs.kcfgc +kcal_bugzilla_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +kcal_bugzilla_la_LIBADD = ../backend/libkbbbackend.la -lkcal + +servicedir = $(kde_servicesdir)/kresources/kcal +service_DATA = bugzilla.desktop + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kres_bugzilla.pot diff --git a/kbugbuster/kresources/bugzilla.desktop b/kbugbuster/kresources/bugzilla.desktop new file mode 100644 index 00000000..75cbb5a5 --- /dev/null +++ b/kbugbuster/kresources/bugzilla.desktop @@ -0,0 +1,48 @@ +[Desktop Entry] +Name=Bugzilla To-do List +Name[bg]=Задачи (Bugzilla) +Name[ca]=Llista de pendents de Bugzilla +Name[cs]=Seznam úkolů (Bugzilla) +Name[da]=Bugzilla gøremålsliste +Name[de]=Bugzilla Todo-Liste +Name[el]=Προς υλοποίηση λίστα του Bugzilla +Name[es]=Listado de tareas pendientes de BugZilla +Name[et]=Bugzilla ülesannete nimekiri +Name[eu]=Bugzilla-ren egiteke zerrenda +Name[fa]=فهرست کار انجامی Bugzilla +Name[fi]=Bugzilla-tehtäväluettelo +Name[fr]=Liste de tâches de Bugzilla +Name[ga]=Tascliosta Bugzilla +Name[gl]=Lista de itens por facer de Bugzilla +Name[he]=רשימת מטלות של Bugzilla +Name[hu]=Bugzilla feladatlista +Name[is]=Bugzilla verklisti +Name[it]=Lista delle cosa da fare di Bugzilla +Name[ja]=BugzillaToDo リスト +Name[ka]=Bugzilla-ს დავალებათა სია +Name[kk]=Bugzilla To-do тізімі +Name[lt]=Bugzilla darbų sąrašas +Name[nb]=Bugzilla-huskeliste +Name[nds]=Bugzilla-Opgavenlist +Name[ne]=बगजिला गर्नुपर्ने कार्य सूची +Name[nl]=Bugzilla Todo-lijst +Name[nn]=Bugzilla-hugseliste +Name[pa]=ਬੱਗਜੀਲਾ ਕਰਨ ਸੂਚੀ +Name[pl]=Lista rzeczy do zrobienia w Bugzilli +Name[pt]=Lista de Itens Por-Fazer do Bugzilla +Name[pt_BR]=Lista de Itens Por-Fazer do Bugzilla +Name[ru]=Список TODO Bugzilla +Name[sk]=Zoznam úloh v Bugzille +Name[sl]=Seznam »za-narediti« v Bugzilli +Name[sr]=Листа послова Bugzilla-е +Name[sr@Latn]=Lista poslova Bugzilla-e +Name[sv]=Bugzilla uppgiftslista +Name[tr]=Bugzilla To-do Listesi +Name[uk]=Список завдань Bugzilla +Name[zh_CN]=Bugzilla 待办列表 +Name[zh_TW]=Bugzilla 待辦清單 +X-KDE-Library=kcal_bugzilla +Type=Service +ServiceTypes=KResources/Plugin +X-KDE-ResourceFamily=calendar +X-KDE-ResourceType=bugzilla diff --git a/kbugbuster/kresources/kcalresource.cpp b/kbugbuster/kresources/kcalresource.cpp new file mode 100644 index 00000000..fbd91bc1 --- /dev/null +++ b/kbugbuster/kresources/kcalresource.cpp @@ -0,0 +1,316 @@ +/* + This file is part of KBugBuster. + + Copyright (c) 2003 Cornelius Schumacher + + 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "bugsystem.h" +#include "bugserver.h" + +#include "kcalresourceconfig.h" +#include "resourceprefs.h" + +#include "kcalresource.h" + +KCalResource::KCalResource( const KConfig* config ) + : ResourceCached( config ), mLock( 0 ) +{ + mPrefs = new KBB::ResourcePrefs; + + KConfigSkeletonItem::List items = mPrefs->items(); + KConfigSkeletonItem::List::Iterator it; + for( it = items.begin(); it != items.end(); ++it ) { + (*it)->setGroup( identifier() ); + } + + if ( config ) { + readConfig( config ); + } + + init(); +} + +KCalResource::~KCalResource() +{ + close(); + + if ( mDownloadJob ) mDownloadJob->kill(); + if ( mUploadJob ) mUploadJob->kill(); + + delete mLock; +} + +void KCalResource::init() +{ + mDownloadJob = 0; + mUploadJob = 0; + + setType( "remote" ); + + mOpen = false; + + mLock = new KABC::LockNull( true ); + + KConfig config( "kbugbusterrc" ); + + BugSystem::self()->readConfig( &config ); +} + +KBB::ResourcePrefs *KCalResource::prefs() +{ + return mPrefs; +} + +void KCalResource::readConfig( const KConfig * ) +{ + mPrefs->readConfig(); +} + +void KCalResource::writeConfig( KConfig *config ) +{ + kdDebug() << "KCalResource::writeConfig()" << endl; + + ResourceCalendar::writeConfig( config ); + + mPrefs->writeConfig(); +} + +QString KCalResource::cacheFile() +{ + QString file = locateLocal( "cache", "kcal/kresources/" + identifier() ); + kdDebug() << "KCalResource::cacheFile(): " << file << endl; + return file; +} + +bool KCalResource::doOpen() +{ + kdDebug(5800) << "KCalResource::doOpen()" << endl; + + mOpen = true; + + return true; +} + +bool KCalResource::doLoad() +{ + kdDebug() << "KCalResource::doLoad()" << endl; + + if ( !mOpen ) return true; + + if ( mDownloadJob ) { + kdWarning() << "KCalResource::doLoad(): download still in progress." + << endl; + return false; + } + if ( mUploadJob ) { + kdWarning() << "KCalResource::doLoad(): upload still in progress." + << endl; + return false; + } + + mCalendar.close(); + + mCalendar.load( cacheFile() ); + + BugSystem *kbb = BugSystem::self(); + + kdDebug() << "KNOWN SERVERS:" << endl; + QValueList servers = kbb->serverList(); + QValueList::ConstIterator it; + for( it = servers.begin(); it != servers.end(); ++it ) { + kdDebug() << " " << (*it)->identifier() << endl; + } + + kbb->setCurrentServer( mPrefs->server() ); + if ( !kbb->server() ) { + kdError() << "Server not found." << endl; + return false; + } else { + kdDebug() << "CURRENT SERVER: " << kbb->server()->identifier() << endl; + } + + kbb->retrievePackageList(); + + Package package = kbb->package( mPrefs->product() ); + + connect( kbb, SIGNAL( bugListAvailable( const Package &, const QString &, + const Bug::List & ) ), + SLOT( slotBugListAvailable( const Package &, const QString &, + const Bug::List & ) ) ); + + kbb->retrieveBugList( package, mPrefs->component() ); + + return true; +} + +void KCalResource::slotBugListAvailable( const Package &, const QString &, + const Bug::List &bugs ) +{ + kdDebug() << "KCalResource::slotBugListAvailable()" << endl; + + if ( bugs.isEmpty() ) return; + + QString masterUid = "kbb_" + BugSystem::self()->server()->identifier(); + KCal::Todo *masterTodo = mCalendar.todo( masterUid ); + if ( !masterTodo ) { + masterTodo = new KCal::Todo; + masterTodo->setUid( masterUid ); + masterTodo->setSummary( resourceName() ); + mCalendar.addTodo( masterTodo ); + } + + Bug::List::ConstIterator it; + for( it = bugs.begin(); it != bugs.end(); ++it ) { + Bug bug = *it; + kdDebug() << " Bug " << bug.number() << ": " << bug.title() << endl; + QString uid = "KBugBuster_" + bug.number(); + KCal::Todo *newTodo = 0; + KCal::Todo *todo = mCalendar.todo( uid ); + if ( !todo ) { + newTodo = new KCal::Todo; + newTodo->setUid( uid ); + QString uri = "http://bugs.kde.org/show_bug.cgi?id=%1"; + newTodo->addAttachment( new KCal::Attachment( uri.arg( bug.number() ) ) ); + todo = newTodo; + } + + todo->setSummary( bug.number() + ": " + bug.title() ); + todo->setRelatedTo( masterTodo ); + + if ( newTodo ) mCalendar.addTodo( newTodo ); + } + + emit resourceChanged( this ); +} + +void KCalResource::slotLoadJobResult( KIO::Job *job ) +{ + if ( job->error() ) { + job->showErrorDialog( 0 ); + } else { + kdDebug() << "KCalResource::slotLoadJobResult() success" << endl; + + mCalendar.close(); + mCalendar.load( cacheFile() ); + + emit resourceChanged( this ); + } + + mDownloadJob = 0; + + emit resourceLoaded( this ); +} + +bool KCalResource::doSave() +{ + kdDebug() << "KCalResource::doSave()" << endl; + + if ( !mOpen ) return true; + + if ( readOnly() ) { + emit resourceSaved( this ); + return true; + } + + if ( mDownloadJob ) { + kdWarning() << "KCalResource::save(): download still in progress." + << endl; + return false; + } + if ( mUploadJob ) { + kdWarning() << "KCalResource::save(): upload still in progress." + << endl; + return false; + } + + mCalendar.save( cacheFile() ); + + mUploadJob = KIO::file_copy( KURL( cacheFile() ), mUploadUrl, -1, true ); + connect( mUploadJob, SIGNAL( result( KIO::Job * ) ), + SLOT( slotSaveJobResult( KIO::Job * ) ) ); + + return true; +} + +bool KCalResource::isSaving() +{ + return mUploadJob; +} + +void KCalResource::slotSaveJobResult( KIO::Job *job ) +{ + if ( job->error() ) { + job->showErrorDialog( 0 ); + } else { + kdDebug() << "KCalResource::slotSaveJobResult() success" << endl; + } + + mUploadJob = 0; + + emit resourceSaved( this ); +} + +void KCalResource::doClose() +{ + if ( !mOpen ) return; + + mCalendar.close(); + mOpen = false; +} + +KABC::Lock *KCalResource::lock() +{ + return mLock; +} + +void KCalResource::dump() const +{ + ResourceCalendar::dump(); + kdDebug(5800) << " DownloadUrl: " << mDownloadUrl.url() << endl; + kdDebug(5800) << " UploadUrl: " << mUploadUrl.url() << endl; + kdDebug(5800) << " ReloadPolicy: " << mReloadPolicy << endl; +} + +#include "kcalresource.moc" diff --git a/kbugbuster/kresources/kcalresource.h b/kbugbuster/kresources/kcalresource.h new file mode 100644 index 00000000..9970f5e4 --- /dev/null +++ b/kbugbuster/kresources/kcalresource.h @@ -0,0 +1,123 @@ +/* + This file is part of KBugBuster. + + Copyright (c) 2003 Cornelius Schumacher + + 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +#ifndef KCALRESOURCE_H +#define KCALRESOURCE_H + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include + +namespace KIO { +class FileCopyJob; +class Job; +} + +namespace KBB { +class ResourcePrefs; +} + +/** + This class provides a calendar stored as a remote file. +*/ +class KCalResource : public KCal::ResourceCached +{ + Q_OBJECT + + friend class KCalResourceConfig; + + public: + /** + Reload policy. + + @see setReloadPolicy(), reloadPolicy() + */ + enum { ReloadNever, ReloadOnStartup, ReloadOnceADay, ReloadAlways }; + + /** + Create resource from configuration information stored in KConfig object. + */ + KCalResource( const KConfig * ); + ~KCalResource(); + + void readConfig( const KConfig *config ); + void writeConfig( KConfig *config ); + + KBB::ResourcePrefs *prefs(); + + /** + Return name of file used as cache for remote file. + */ + QString cacheFile(); + + KABC::Lock *lock(); + + bool isSaving(); + + void dump() const; + + protected slots: + void slotBugListAvailable( const Package &, const QString &, + const Bug::List &bugs ); + + void slotLoadJobResult( KIO::Job * ); + void slotSaveJobResult( KIO::Job * ); + + protected: + bool doOpen(); + void doClose(); + bool doLoad(); + bool doSave(); + + private: + void init(); + + KBB::ResourcePrefs *mPrefs; + + KURL mDownloadUrl; + KURL mUploadUrl; + + int mReloadPolicy; + + KCal::ICalFormat mFormat; + + bool mOpen; + + KIO::FileCopyJob *mDownloadJob; + KIO::FileCopyJob *mUploadJob; + + KABC::Lock *mLock; + + class Private; + Private *d; +}; + +#endif diff --git a/kbugbuster/kresources/kcalresource_plugin.cpp b/kbugbuster/kresources/kcalresource_plugin.cpp new file mode 100644 index 00000000..23b5f8ac --- /dev/null +++ b/kbugbuster/kresources/kcalresource_plugin.cpp @@ -0,0 +1,37 @@ +/* + This file is part of KBugBuster. + + Copyright (c) 2003 Cornelius Schumacher + + 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "kcalresourceconfig.h" +#include "kcalresource.h" + +#include +#include + +using namespace KCal; + +extern "C" +{ + KDE_EXPORT void *init_kcal_bugzilla() + { + KGlobal::locale()->insertCatalogue( "kres_bugzilla" ); + return new KRES::PluginFactory(); + } +} diff --git a/kbugbuster/kresources/kcalresourceconfig.cpp b/kbugbuster/kresources/kcalresourceconfig.cpp new file mode 100644 index 00000000..bb404445 --- /dev/null +++ b/kbugbuster/kresources/kcalresourceconfig.cpp @@ -0,0 +1,92 @@ +/* + This file is part of KBugBuster. + + Copyright (c) 2003 Cornelius Schumacher + + 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include "kcalresource.h" +#include "resourceprefs.h" +#include "kcalresourceconfig.h" + +KCalResourceConfig::KCalResourceConfig( QWidget* parent, const char* name ) + : KRES::ConfigWidget( parent, name ) +{ + resize( 245, 115 ); + + QGridLayout *mainLayout = new QGridLayout( this, 2, 2 ); + mainLayout->setSpacing( KDialog::spacingHint() ); + + QLabel *label = new QLabel( i18n("Server:"), this ); + mainLayout->addWidget( label, 0, 0 ); + + mServerEdit = new KLineEdit( this ); + mainLayout->addWidget( mServerEdit, 0, 1 ); + + + label = new QLabel( i18n("Product:"), this ); + mainLayout->addWidget( label, 1, 0 ); + + mProductEdit = new KLineEdit( this ); + mainLayout->addWidget( mProductEdit, 1, 1 ); + + + label = new QLabel( i18n("Component:"), this ); + mainLayout->addWidget( label, 2, 0 ); + + mComponentEdit = new KLineEdit( this ); + mainLayout->addWidget( mComponentEdit, 2, 1 ); +} + +void KCalResourceConfig::loadSettings( KRES::Resource *resource ) +{ + KCalResource *res = static_cast( resource ); + if ( res ) { + KBB::ResourcePrefs *p = res->prefs(); + mServerEdit->setText( p->server() ); + mProductEdit->setText( p->product() ); + mComponentEdit->setText( p->component() ); + } else { + kdError(5700) << "KCalResourceConfig::loadSettings(): no KCalResource, cast failed" << endl; + } +} + +void KCalResourceConfig::saveSettings( KRES::Resource *resource ) +{ + KCalResource *res = static_cast( resource ); + if ( res ) { + KBB::ResourcePrefs *p = res->prefs(); + p->setServer( mServerEdit->text() ); + p->setProduct( mProductEdit->text() ); + p->setComponent( mComponentEdit->text() ); + } else { + kdError(5700) << "KCalResourceConfig::saveSettings(): no KCalResource, cast failed" << endl; + } +} + +#include "kcalresourceconfig.moc" diff --git a/kbugbuster/kresources/kcalresourceconfig.h b/kbugbuster/kresources/kcalresourceconfig.h new file mode 100644 index 00000000..43ab60a1 --- /dev/null +++ b/kbugbuster/kresources/kcalresourceconfig.h @@ -0,0 +1,53 @@ +/* + This file is part of KBugBuster. + + Copyright (c) 2003 Cornelius Schumacher + + 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +#ifndef KCALRESOURCECONFIG_H +#define KCALRESOURCECONFIG_H + +#include +#include + +class KLineEdit; + +/** + Configuration widget for remote resource. + + @see KCalResource +*/ +class KCalResourceConfig : public KRES::ConfigWidget +{ + Q_OBJECT + public: + KCalResourceConfig( QWidget *parent = 0, const char *name = 0 ); + + public slots: + virtual void loadSettings( KRES::Resource *resource ); + virtual void saveSettings( KRES::Resource *resource ); + + private: + KLineEdit *mServerEdit; + KLineEdit *mComponentEdit; + KLineEdit *mProductEdit; + + class Private; + Private *d; +}; + +#endif diff --git a/kbugbuster/kresources/kresources_kcal_bugzilla.kcfg b/kbugbuster/kresources/kresources_kcal_bugzilla.kcfg new file mode 100644 index 00000000..ce23c969 --- /dev/null +++ b/kbugbuster/kresources/kresources_kcal_bugzilla.kcfg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + diff --git a/kbugbuster/kresources/resourceprefs.kcfgc b/kbugbuster/kresources/resourceprefs.kcfgc new file mode 100644 index 00000000..0f41bdb1 --- /dev/null +++ b/kbugbuster/kresources/resourceprefs.kcfgc @@ -0,0 +1,9 @@ +# Code generation options for kconfig_compiler +File=kresources_kcal_bugzilla.kcfg +ClassName=ResourcePrefs +NameSpace=KBB +Singleton=false +Mutators=true +GlobalEnums=true +#ItemAccessors=true +#SetUserTexts=true -- cgit v1.2.1