KCal Library
freebusyurlstore.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00029 #include "freebusyurlstore.h"
00030 #include <kconfig.h>
00031 #include <kstandarddirs.h>
00032 #include <kconfiggroup.h>
00033 #include <QtCore/QCoreApplication>
00034
00035 using namespace KCal;
00036
00037
00038 class FreeBusyUrlStore::Private
00039 {
00040 public:
00041 Private()
00042 : mConfig(0)
00043 {}
00044 ~Private()
00045 {
00046 qRemovePostRoutine(cleanupFreeBusyUrlStore);
00047 }
00048 KConfig *mConfig;
00049
00050 static FreeBusyUrlStore *sSelf;
00051 static void cleanupFreeBusyUrlStore()
00052 {
00053 delete sSelf;
00054 sSelf = 0;
00055 }
00056 };
00057 FreeBusyUrlStore *FreeBusyUrlStore::Private::sSelf = 0;
00058
00059
00060 FreeBusyUrlStore *FreeBusyUrlStore::self()
00061 {
00062 static Private p;
00063 if ( !p.sSelf ) {
00064 p.sSelf = new FreeBusyUrlStore();
00065 qAddPostRoutine( Private::cleanupFreeBusyUrlStore );
00066 }
00067 return p.sSelf;
00068 }
00069
00070 FreeBusyUrlStore::FreeBusyUrlStore() : d( new Private() )
00071 {
00072 QString configFile =
00073 KStandardDirs::locateLocal( "data", "korganizer/freebusyurls" );
00074 d->mConfig = new KConfig( configFile );
00075 }
00076
00077 FreeBusyUrlStore::~FreeBusyUrlStore()
00078 {
00079 delete d->mConfig;
00080 delete d;
00081 }
00082
00083 void FreeBusyUrlStore::writeUrl( const QString &email, const QString &url )
00084 {
00085 KConfigGroup group = d->mConfig->group( email );
00086 group.writeEntry( "url", url );
00087 }
00088
00089 QString FreeBusyUrlStore::readUrl( const QString &email )
00090 {
00091 KConfigGroup group = d->mConfig->group( email );
00092 return group.readEntry( "url" );
00093 }
00094
00095 void FreeBusyUrlStore::sync()
00096 {
00097 d->mConfig->sync();
00098 }