diff options
Diffstat (limited to 'kontact/plugins/kpilot')
-rw-r--r-- | kontact/plugins/kpilot/Makefile.am | 24 | ||||
-rw-r--r-- | kontact/plugins/kpilot/kpilot_plugin.cpp | 69 | ||||
-rw-r--r-- | kontact/plugins/kpilot/kpilot_plugin.h | 49 | ||||
-rw-r--r-- | kontact/plugins/kpilot/kpilotplugin.desktop | 44 | ||||
-rw-r--r-- | kontact/plugins/kpilot/summarywidget.cpp | 242 | ||||
-rw-r--r-- | kontact/plugins/kpilot/summarywidget.h | 99 |
6 files changed, 527 insertions, 0 deletions
diff --git a/kontact/plugins/kpilot/Makefile.am b/kontact/plugins/kpilot/Makefile.am new file mode 100644 index 000000000..2383a4fbd --- /dev/null +++ b/kontact/plugins/kpilot/Makefile.am @@ -0,0 +1,24 @@ +INCLUDES = -I$(top_srcdir)/kontact/interfaces \ + -I$(top_srcdir)/libkdepim \ + -I$(top_srcdir) \ + -I$(top_srcdir)/kpilot/lib \ + -I$(top_srcdir)/kpilot/kpilot \ + $(PISOCK_INCLUDE) $(all_includes) + +kde_module_LTLIBRARIES = libkontact_kpilotplugin.la +libkontact_kpilotplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkontact_kpilotplugin_la_LIBADD = $(top_builddir)/kontact/interfaces/libkpinterfaces.la \ + $(LIB_KPARTS) \ + $(top_builddir)/libkdepim/libkdepim.la \ + $(top_builddir)/kpilot/lib/libkpilot.la + +libkontact_kpilotplugin_la_SOURCES = kpilot_plugin.cpp summarywidget.cpp \ + summarywidget.skel pilotDaemonDCOP.stub + +pilotDaemonDCOP_DIR = $(top_srcdir)/kpilot/kpilot +pilotDaemonDCOP_DCOPIDLNG = true + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir)/kontact +service_DATA = kpilotplugin.desktop diff --git a/kontact/plugins/kpilot/kpilot_plugin.cpp b/kontact/plugins/kpilot/kpilot_plugin.cpp new file mode 100644 index 000000000..ed6104bd4 --- /dev/null +++ b/kontact/plugins/kpilot/kpilot_plugin.cpp @@ -0,0 +1,69 @@ +/* + This file is part of Kontact. + Copyright (C) 2003 Tobias Koenig <tokoe@kde.org> + Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> + + 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 "options.h" + +#include <kaboutdata.h> +#include <kgenericfactory.h> +#include <kparts/componentfactory.h> + +#include "core.h" +#include "summarywidget.h" + +#include "kpilot_plugin.h" + +typedef KGenericFactory< KPilotPlugin, Kontact::Core > KPilotPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_kpilotplugin, + KPilotPluginFactory( "kontact_kpilotplugin" ) ) + +KPilotPlugin::KPilotPlugin( Kontact::Core *core, const char *name, const QStringList& ) + : Kontact::Plugin( core, core, "kpilot" ), mAboutData( 0 ) +{ + setInstance( KPilotPluginFactory::instance() ); + // TODO: Make sure kpilotDaemon is running! + + +} + +Kontact::Summary *KPilotPlugin::createSummaryWidget( QWidget *parentWidget ) +{ + return new SummaryWidget( parentWidget ); +} + +const KAboutData *KPilotPlugin::aboutData() +{ + if ( !mAboutData ) { + mAboutData = new KAboutData("kpilotplugin", I18N_NOOP("KPilot Information"), + KPILOT_VERSION, + I18N_NOOP("KPilot - HotSync software for KDE\n\n"), + KAboutData::License_GPL, "(c) 2004 Reinhold Kainhofer"); + mAboutData->addAuthor("Reinhold Kainhofer", + I18N_NOOP("Plugin Developer"), "reinhold@kainhofer.com", "http://reinhold.kainhofer.com/Linux/"); + mAboutData->addAuthor("Dan Pilone", + I18N_NOOP("Project Leader"), + 0, "http://www.kpilot.org/"); + mAboutData->addAuthor("Adriaan de Groot", + I18N_NOOP("Maintainer"), + "groot@kde.org", "http://people.fruitsalad.org/adridg/"); + } + + return mAboutData; +} diff --git a/kontact/plugins/kpilot/kpilot_plugin.h b/kontact/plugins/kpilot/kpilot_plugin.h new file mode 100644 index 000000000..9b76bd644 --- /dev/null +++ b/kontact/plugins/kpilot/kpilot_plugin.h @@ -0,0 +1,49 @@ +/* + This file is part of Kontact. + Copyright (C) 2003 Tobias Koenig <tokoe@kde.org> + Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> + + 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 KPilot_PLUGIN_H +#define KPilot_PLUGIN_H + +#include "plugin.h" +#include "pilotDaemonDCOP_stub.h" + +class SummaryWidget; + +class KPilotPlugin : public Kontact::Plugin +{ + public: + KPilotPlugin( Kontact::Core *core, const char *name, const QStringList& ); + KPilotPlugin(); + + virtual Kontact::Summary *createSummaryWidget( QWidget *parentWidget ); + + virtual bool showInSideBar() const { return false; } +// virtual QStringList configModules() const; + + const KAboutData *aboutData(); + + protected: + virtual KParts::ReadOnlyPart *createPart() { return 0; } + private: + KAboutData *mAboutData; +}; + +#endif diff --git a/kontact/plugins/kpilot/kpilotplugin.desktop b/kontact/plugins/kpilot/kpilotplugin.desktop new file mode 100644 index 000000000..7ad217fd9 --- /dev/null +++ b/kontact/plugins/kpilot/kpilotplugin.desktop @@ -0,0 +1,44 @@ +[Desktop Entry] +Type=Service +Icon=kpilot +ServiceTypes=Kontact/Plugin,KPluginInfo + +X-KDE-Library=libkontact_kpilotplugin +X-KDE-KontactIdentifier=kpilot +X-KDE-KontactPluginVersion=6 +X-KDE-KontactPluginHasSummary=true +X-KDE-KontactPluginHasPart=false + +X-KDE-PluginInfo-Website=http://www.slac.com/~pilone/kpilot_home/ +X-KDE-PluginInfo-Name=kontact_kpilotplugin +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true + +Comment=Palm Tools Component (KPilot Plugin) +Comment[bg]=Приставка за KPilot +Comment[ca]=Component d'eines de la Palm (endollable del KPilot) +Comment[da]=Komponent til palm-værktøjer (KPilot-plugin) +Comment[de]=Palm-Komponente (KPilot-Modul) +Comment[el]=Συστατικό εργαλείων Palm (Πρόσθετο του KPilot) +Comment[es]=Componente de herramientas de Palm (complemento KPilot) +Comment[et]=Palmi tööriistade plugin (KPilot) +Comment[fr]=Composant d'outils pour Palms (Module KPilot) +Comment[is]=Palm verkfæraeining (KPilot íforrit) +Comment[it]=Componente strumenti Palm (plugin KPilot) +Comment[ja]=Palm ツールコンポーネント (KPilot プラグイン) +Comment[km]=សមាសភាគឧបករណ៍ Palm (កម្មវិធីជំនួយ KPilot) +Comment[nds]=Palmreekner-Warktüüchkomponent (KPilot-Moduul) +Comment[nl]=Component met hulpmiddelen voor PalmOS(tm)-apparaten (KPilot-plugin) +Comment[pl]=Składnik narzędzi Palma (wtyczka KPilot) +Comment[ru]=Синхронизация с Palm (модуль KPilot) +Comment[sr]=Компонента алата за Palm (прикључак KPilot-а) +Comment[sr@Latn]=Komponenta alata za Palm (priključak KPilot-a) +Comment[sv]=Palm Pilot-verktygskomponent (Kpilot-insticksprogram) +Comment[tr]=Palm Araçları Bileşeni (KPilot Eklentisi) +Comment[zh_CN]=Palm 工具组件(KPilot 插件) +Comment[zh_TW]=Palm 工具組件(KPilot 外掛程式) +Name=Palm +Name[nds]=Palmreekner +Name[nl]=PalmOS(tm)-apparaat +Name[sv]=Palm Pilot diff --git a/kontact/plugins/kpilot/summarywidget.cpp b/kontact/plugins/kpilot/summarywidget.cpp new file mode 100644 index 000000000..4230e6479 --- /dev/null +++ b/kontact/plugins/kpilot/summarywidget.cpp @@ -0,0 +1,242 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> + Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> + + 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 <qimage.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qtooltip.h> +#include <qfile.h> +#include <qlabel.h> +#include <qtextedit.h> +#include <qvbox.h> + +#include <dcopclient.h> +#include <dcopref.h> +#include <kapplication.h> +#include <kdebug.h> +#include <kglobal.h> +#include <kglobalsettings.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kurllabel.h> +#include <kdialogbase.h> +#include <kmessagebox.h> + +#include "pilotDaemonDCOP_stub.h" + +#include <ktextedit.h> + +#include "summarywidget.h" + +SummaryWidget::SummaryWidget( QWidget *parent, const char *name ) + : Kontact::Summary( parent, name ), + DCOPObject( "KPilotSummaryWidget" ), + mDCOPSuccess( false ), + mStartedDaemon( false ), + mShouldStopDaemon( true ) +{ + mLayout = new QGridLayout( this, 2, 3, 3, 3 ); + + int row=0; + QPixmap icon = KGlobal::iconLoader()->loadIcon( "kpilot", KIcon::Desktop, KIcon::SizeMedium ); + QWidget *header = createHeader( this, icon, i18n( "KPilot Configuration" ) ); + mLayout->addMultiCellWidget( header, row,row, 0,3 ); + + // Last sync information + row++; + mSyncTimeTextLabel = new QLabel( i18n( "<i>Last sync:</i>" ), this); + mLayout->addWidget( mSyncTimeTextLabel, row, 0 ); + mSyncTimeLabel = new QLabel( i18n( "No information available" ), this ); + mLayout->addWidget( mSyncTimeLabel, row, 1 ); + mShowSyncLogLabel = new KURLLabel( "", i18n( "[View Sync Log]" ), this ); + mLayout->addWidget( mShowSyncLogLabel, row, 3 ); + connect( mShowSyncLogLabel, SIGNAL( leftClickedURL( const QString& ) ), + this, SLOT( showSyncLog( const QString& ) ) ); + + // User + row++; + mPilotUserTextLabel = new QLabel( i18n( "<i>User:</i>" ), this); + mLayout->addWidget( mPilotUserTextLabel, row, 0); + mPilotUserLabel = new QLabel( i18n( "Unknown" ), this ); + mLayout->addMultiCellWidget( mPilotUserLabel, row, row, 1, 3 ); + + // Device information + row++; + mPilotDeviceTextLabel = new QLabel( i18n( "<i>Device:</i>" ), this); + mLayout->addWidget( mPilotDeviceTextLabel, row, 0 ); + mPilotDeviceLabel = new QLabel( i18n( "Unknown" ), this ); + mLayout->addMultiCellWidget( mPilotDeviceLabel, row, row, 1, 3 ); + + // Status + row++; + mDaemonStatusTextLabel = new QLabel( i18n( "<i>Status:</i>" ), this); + mLayout->addWidget( mDaemonStatusTextLabel, row, 0 ); + mDaemonStatusLabel = new QLabel( i18n( "No communication with the daemon possible" ), this ); + mLayout->addMultiCellWidget( mDaemonStatusLabel, row, row, 1, 3 ); + + // Conduits: + row++; + mConduitsTextLabel = new QLabel( i18n( "<i>Conduits:</i>" ), this ); + mConduitsTextLabel->setAlignment( AlignAuto | AlignTop | ExpandTabs ); + mLayout->addWidget( mConduitsTextLabel, row, 0 ); + mConduitsLabel = new QLabel( i18n( "No information available" ), this ); + mConduitsLabel->setAlignment( mConduitsLabel->alignment() | Qt::WordBreak ); + mLayout->addMultiCellWidget( mConduitsLabel, row, row, 1, 3 ); + + // widgets shown if kpilotDaemon is not running + row++; + mNoConnectionLabel = new QLabel( i18n( "KPilot is currently not running." ), this ); + mLayout->addMultiCellWidget( mNoConnectionLabel, row, row, 1, 2 ); + mNoConnectionStartLabel = new KURLLabel( "", i18n( "[Start KPilot]" ), this ); + mLayout->addWidget( mNoConnectionStartLabel, row, 3 ); + connect( mNoConnectionStartLabel, SIGNAL( leftClickedURL( const QString& ) ), + this, SLOT( startKPilot() ) ); + + if ( !kapp->dcopClient()->isApplicationRegistered( "kpilotDaemon" ) ) { + startKPilot(); + } + + connectDCOPSignal( 0, 0, "kpilotDaemonStatusDetails(QDateTime,QString,QStringList,QString,QString,QString,bool)", + "receiveDaemonStatusDetails(QDateTime,QString,QStringList,QString,QString,QString,bool)", false ); + connect( kapp->dcopClient(), SIGNAL( applicationRemoved( const QCString & ) ), SLOT( slotAppRemoved( const QCString& ) ) ); +} + +SummaryWidget::~SummaryWidget() +{ + if ( mStartedDaemon && mShouldStopDaemon ) { + PilotDaemonDCOP_stub dcopToDaemon( "kpilotDaemon", "KPilotDaemonIface" ); + dcopToDaemon.quitNow(); // ASYNC, always succeeds. + } +} + +QStringList SummaryWidget::configModules() const +{ + QStringList modules; + modules << "kpilot_config.desktop"; + return modules; +} + +void SummaryWidget::receiveDaemonStatusDetails(QDateTime lastSyncTime, QString status, QStringList conduits, QString logFileName, QString userName, QString pilotDevice, bool killOnExit ) +{ + mDCOPSuccess = true; + mLastSyncTime = lastSyncTime; + mDaemonStatus = status; + mConduits = conduits; + mSyncLog = logFileName; + mUserName = userName; + mPilotDevice = pilotDevice; + mShouldStopDaemon = killOnExit; + updateView(); +} + +void SummaryWidget::updateView() +{ + if ( mDCOPSuccess ) { + if ( mLastSyncTime.isValid() ) { + mSyncTimeLabel->setText( mLastSyncTime.toString(Qt::LocalDate) ); + } else { + mSyncTimeLabel->setText( i18n( "No information available" ) ); + } + if ( !mSyncLog.isEmpty() ) { + mShowSyncLogLabel->setEnabled( true ); + mShowSyncLogLabel->setURL( mSyncLog ); + } else { + mShowSyncLogLabel->setEnabled( false ); + } + mPilotUserLabel->setText( mUserName.isEmpty() ? i18n( "unknown" ) : mUserName ); + mPilotDeviceLabel->setText( mPilotDevice.isEmpty() ? i18n( "unknown" ) : mPilotDevice ); + mDaemonStatusLabel->setText( mDaemonStatus ); + mConduitsLabel->setText( mConduits.join( ", " ) ); + } else { + mSyncTimeLabel->setText( i18n( "No information available (Daemon not running?)" ) ); + mShowSyncLogLabel->setEnabled( false ); + mPilotUserLabel->setText( i18n( "unknown" ) ); + mPilotDeviceLabel->setText( i18n( "unknown" ) ); + mDaemonStatusLabel->setText( i18n( "No communication with the daemon possible" ) ); + mConduitsLabel->setText( i18n( "No information available" ) ); + } + + mSyncTimeTextLabel->setShown( mDCOPSuccess ); + mSyncTimeLabel->setShown( mDCOPSuccess ); + mShowSyncLogLabel->setShown( mDCOPSuccess ); + mPilotUserTextLabel->setShown( mDCOPSuccess ); + mPilotUserLabel->setShown( mDCOPSuccess ); + mPilotDeviceTextLabel->setShown( mDCOPSuccess ); + mPilotDeviceLabel->setShown( mDCOPSuccess ); + mDaemonStatusTextLabel->setShown( mDCOPSuccess ); + mDaemonStatusLabel->setShown( mDCOPSuccess ); + mConduitsTextLabel->setShown( mDCOPSuccess ); + mConduitsLabel->setShown( mDCOPSuccess ); + mNoConnectionLabel->setShown( !mDCOPSuccess ); + mNoConnectionStartLabel->setShown( !mDCOPSuccess ); +} + +void SummaryWidget::showSyncLog( const QString &filename ) +{ + KDialogBase dlg( this, 0, true, QString::null, KDialogBase::Ok, KDialogBase::Ok ); + dlg.setCaption( i18n( "KPilot HotSync Log" ) ); + + QTextEdit *edit = new QTextEdit( dlg.makeVBoxMainWidget() ); + edit->setReadOnly( true ); + + QFile f(filename); + if ( !f.open( IO_ReadOnly ) ) { + KMessageBox::error( this, i18n( "Unable to open Hotsync log %1." ).arg( filename ) ); + return; + } + + QTextStream s( &f ); + while ( !s.eof() ) + edit->append( s.readLine() ); + + edit->moveCursor( QTextEdit::MoveHome, false ); + + f.close(); + + dlg.setInitialSize( QSize( 400, 350 ) ); + dlg.exec(); +} + +void SummaryWidget::startKPilot() +{ + QString error; + QCString appID; + if ( !KApplication::kdeinitExec( "kpilotDaemon", QString( "--fail-silently" ) ) ) { + kdDebug(5602) << "No service available..." << endl; + mStartedDaemon = true; + } +} + +void SummaryWidget::slotAppRemoved( const QCString & appId ) +{ + if ( appId == "kpilotDaemon" ) + { + mDCOPSuccess = false; + updateView(); + } +} + + +#include "summarywidget.moc" + diff --git a/kontact/plugins/kpilot/summarywidget.h b/kontact/plugins/kpilot/summarywidget.h new file mode 100644 index 000000000..94fda7e55 --- /dev/null +++ b/kontact/plugins/kpilot/summarywidget.h @@ -0,0 +1,99 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> + Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> + + 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 SUMMARYWIDGET_H +#define SUMMARYWIDGET_H + +#include "summary.h" + +#include <dcopobject.h> +#include <pilotDaemonDCOP.h> + +#include <qmap.h> +#include <qpixmap.h> +#include <qptrlist.h> +#include <qstringlist.h> +#include <qtimer.h> +#include <qwidget.h> +#include <qdatetime.h> + +class QGridLayout; +class QLabel; +class KURLLabel; + +class SummaryWidget : public Kontact::Summary, public DCOPObject +{ + Q_OBJECT + K_DCOP + + public: + SummaryWidget( QWidget *parent, const char *name = 0 ); + virtual ~SummaryWidget(); + + int summaryHeight() const { return 1; } + + QStringList configModules() const; + + k_dcop: + // all the information is pushed to Kontact by the daemon, to remove the chance of Kontact calling a daemon + // that is blocked for some reason, and blocking itself. + void receiveDaemonStatusDetails( QDateTime, QString, QStringList, QString, QString, QString, bool ); + private slots: + void updateView(); + void showSyncLog( const QString &filename ); + void startKPilot(); + void slotAppRemoved( const QCString & ); + private: + QTimer mTimer; + + QLabel*mSyncTimeTextLabel; + QLabel*mSyncTimeLabel; + KURLLabel*mShowSyncLogLabel; + QLabel*mPilotUserTextLabel; + QLabel*mPilotUserLabel; + QLabel*mPilotDeviceTextLabel; + QLabel*mPilotDeviceLabel; + QLabel*mDaemonStatusTextLabel; + QLabel*mDaemonStatusLabel; + QLabel*mConduitsTextLabel; + QLabel*mConduitsLabel; + QLabel*mNoConnectionLabel; + KURLLabel*mNoConnectionStartLabel; + + QGridLayout *mLayout; + + QDateTime mLastSyncTime; + QString mDaemonStatus; + QStringList mConduits; + QString mSyncLog; + QString mUserName; + QString mPilotDevice; + bool mDCOPSuccess; + + bool mStartedDaemon; // Record whether the daemon was started by kontact + bool mShouldStopDaemon; +}; + +#endif + |