kitchensync Library API Documentation

synchelper.cpp

00001 /* 00002 This file is part of KitchenSync. 00003 00004 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 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., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, USA. 00020 */ 00021 00022 #include <qapplication.h> 00023 #include <qthread.h> 00024 00025 #include "synchelper.h" 00026 00027 using namespace KSync; 00028 00029 namespace { 00030 struct DoneEvent : public QCustomEvent { 00031 DoneEvent() : QCustomEvent( 6666 ) { 00032 } 00033 ~DoneEvent() { 00034 } 00035 }; 00036 class SyncThread : public QThread { 00037 public: 00038 SyncThread(Syncer*, QObject* obj ); 00039 ~SyncThread(); 00040 void run(); 00041 private: 00042 Syncer* m_sync; 00043 QObject* m_obj; 00044 }; 00045 SyncThread::SyncThread( Syncer* syn, QObject* obj) { 00046 m_sync = syn; 00047 m_obj = obj; 00048 } 00049 SyncThread::~SyncThread() { 00050 } 00051 void SyncThread::run() { 00052 m_sync->sync(); 00053 /* we're done tell it the other thread.... */ 00054 QApplication::postEvent( m_obj, new DoneEvent ); 00055 } 00056 00057 } 00058 struct SyncHelper::Data { 00059 Syncer *syncer; 00060 }; 00061 00062 SyncHelper::SyncHelper( SyncUi* ui, SyncAlgorithm* al) { 00063 data = new Data; 00064 data->syncer = new Syncer( ui, al ); 00065 } 00066 SyncHelper::~SyncHelper() { 00067 delete data->syncer; 00068 delete data; 00069 } 00070 void SyncHelper::sync() { 00071 SyncThread thread(data->syncer, this ); 00072 thread.start(); 00073 } 00074 void SyncHelper::addSyncee( Syncee* syn ) { 00075 data->syncer->addSyncee( syn); 00076 } 00077 void SyncHelper::customEvent( QCustomEvent* ) { 00078 emit done(); 00079 } 00080 00081 #include "synchelper.moc"
KDE Logo
This file is part of the documentation for kitchensync Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 1 15:19:00 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003