kitchensync

threadedkonnector.cpp

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2003 Mathias Froehlich <Mathias.Froehlich@web.de>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include <kdebug.h>
00023 #include <kgenericfactory.h>
00024 #include <kconfig.h>
00025 #include <konnectorinfo.h>
00026 
00027 #include "clientmanager.h"
00028 
00029 #include "threadedkonnector.h"
00030 #include "konnectorconfig.h"
00031 
00032 using namespace KSync;
00033 using namespace Threaded;
00034 
00035 extern "C"
00036 {
00037   void *init_libthreadedkonnector()
00038   {
00039     KGlobal::locale()->insertCatalogue( "konnector_threaded" );
00040     return new KRES::PluginFactory<ThreadedPlugin,ThreadedKonnectorConfig>();
00041   }
00042 }
00043 
00044 ThreadedPlugin::ThreadedPlugin( const KConfig *config )
00045   : Konnector( config ) {
00046   kdDebug() << __PRETTY_FUNCTION__ << " this = " << this << endl;
00047 
00048 //   connect( &mClientManager, SIGNAL(signalThreadTerminated()),
00049 //     SLOT(slotThreadTerminated()) );
00050   connect( &mClientManager, SIGNAL(signalProgress(const KSync::Progress&)),
00051        SLOT(slotProgress(const KSync::Progress&)) );
00052   connect( &mClientManager, SIGNAL(signalError(const KSync::Error&)),
00053        SLOT(slotError(const KSync::Error&)) );
00054   connect( &mClientManager, SIGNAL(signalFinished()),
00055        SLOT(slotFinished()) );
00056 }
00057 
00058 SynceeList ThreadedPlugin::syncees()
00059 {
00060   // TODO: Make this return something useful
00061   return SynceeList;
00062 }
00063 
00064 ThreadedPlugin::~ThreadedPlugin() {
00065   kdDebug() << __PRETTY_FUNCTION__ << " this = " << this << endl;
00066   mClientManager.terminate();
00067   mClientManager.wait();
00068 }
00069 
00070 bool ThreadedPlugin::readSyncees() {
00071   kdDebug() << __PRETTY_FUNCTION__ << " this = " << this << endl;
00072   return mClientManager.readSyncees();
00073 }
00074 
00075 bool ThreadedPlugin::writeSyncees() {
00076   kdDebug() << __PRETTY_FUNCTION__ << " this = " << this << endl;
00077   return mClientManager.writeSyncees();
00078 }
00079 
00080 bool ThreadedPlugin::connectDevice() {
00081   kdDebug() << __PRETTY_FUNCTION__ << " this = " << this << endl;
00082   return mClientManager.connectDevice();
00083 }
00084 
00085 bool ThreadedPlugin::disconnectDevice() {
00086   kdDebug() << __PRETTY_FUNCTION__ << " this = " << this << endl;
00087   return mClientManager.disconnectDevice();
00088 }
00089 
00090 KSync::KonnectorInfo ThreadedPlugin::info() const {
00091   kdDebug() << __PRETTY_FUNCTION__ << " this = " << this << endl;
00092   return KSync::KonnectorInfo();
00093 }
00094 
00095 void ThreadedPlugin::download( const QString& ) {
00096   kdDebug() << __PRETTY_FUNCTION__ << " this = " << this << endl;
00097 }
00098 
00099 void ThreadedPlugin::slotFinished() {
00100   kdDebug() << __PRETTY_FUNCTION__ << " this = " << this << endl;
00101   progress( KSync::StdProgress::done() );
00102 }
00103 
00104 void ThreadedPlugin::slotError( const KSync::Error& e ) {
00105   kdDebug() << __PRETTY_FUNCTION__ << " this = " << this << endl;
00106   error( e );
00107 }
00108 
00109 void ThreadedPlugin::slotProgress( const KSync::Progress& p ) {
00110   kdDebug() << __PRETTY_FUNCTION__ << " this = " << this << endl;
00111   progress( p );
00112 }
00113 
00114 #include "threadedkonnector.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys