kitchensync

dummykonnector.cpp

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.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., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include <kgenericfactory.h>
00023 #include <kdebug.h>
00024 #include <klocale.h>
00025 
00026 #include <synchistory.h>
00027 
00028 #include <konnectorinfo.h>
00029 
00030 #include <calendarsyncee.h>
00031 
00032 #include "dummykonnector.h"
00033 
00034 using namespace KSync;
00035 using namespace KCal;
00036 
00037 class DummyKonnectorFactory : public KRES::PluginFactoryBase
00038 {
00039   public:
00040     KRES::Resource *resource( const KConfig *config )
00041     {
00042       return new DummyKonnector( config );
00043     }
00044 
00045     KRES::ConfigWidget *configWidget( QWidget * )
00046     {
00047       return 0;
00048     }
00049 };
00050 
00051 extern "C"
00052 {
00053   void *init_libdummykonnector()
00054   {
00055     KGlobal::locale()->insertCatalogue( "konnector_dummy" );
00056     return new DummyKonnectorFactory();
00057   }
00058 }
00059 
00060 
00061 DummyKonnector::DummyKonnector( const KConfig *config )
00062     : Konnector( config )
00063 {
00064   Event *event = new Event;
00065   event->setSummary( "An Event" );
00066   mCalendar.addEvent( event );
00067 
00068   event = new Event;
00069   event->setSummary( "Another Event" );
00070   mCalendar.addEvent( event );
00071 
00072   mCalSyncee = new CalendarSyncee( &mCalendar );
00073 
00074   /* apply sync information */
00075   CalendarSyncHistory syncHistory( mCalSyncee, storagePath() + "/dummy-calendar.log" );
00076   syncHistory.load();
00077 
00078   mSyncees.append( mCalSyncee );
00079 }
00080 
00081 DummyKonnector::~DummyKonnector()
00082 {
00083 }
00084 
00085 SynceeList DummyKonnector::syncees()
00086 {
00087   return mSyncees;
00088 }
00089 
00090 bool DummyKonnector::readSyncees()
00091 {
00092   emit synceesRead( this );
00093 
00094   return true;
00095 }
00096 
00097 bool DummyKonnector::connectDevice()
00098 {
00099   return true;
00100 }
00101 
00102 bool DummyKonnector::disconnectDevice()
00103 {
00104   return true;
00105 }
00106 
00107 KSync::KonnectorInfo DummyKonnector::info() const
00108 {
00109   return KonnectorInfo( i18n("Dummy Konnector"),
00110                         QIconSet(),
00111                         "agenda", // icon name
00112                         false );
00113 }
00114 
00115 bool DummyKonnector::writeSyncees()
00116 {
00117 
00118   CalendarSyncHistory syncHistory( mCalSyncee, storagePath() + "/dummy-calendar.log" );
00119   syncHistory.save();
00120 
00121 
00122   emit synceesWritten( this );
00123   return true;
00124 }
00125 
00126 
00127 #include "dummykonnector.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys