KCalCore 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
00028 #include "freebusyurlstore.h"
00029
00030 #include <KConfig>
00031 #include <KConfigGroup>
00032 #include <KStandardDirs>
00033
00034 #include <QtCore/QCoreApplication>
00035
00036 using namespace KCalCore;
00037
00038
00039 class FreeBusyUrlStore::Private
00040 {
00041 public:
00042 Private()
00043 : mConfig(0)
00044 {}
00045 ~Private()
00046 {
00047 qRemovePostRoutine(cleanupFreeBusyUrlStore);
00048 }
00049 KConfig *mConfig;
00050
00051 static FreeBusyUrlStore *sSelf;
00052 static void cleanupFreeBusyUrlStore()
00053 {
00054 delete sSelf;
00055 sSelf = 0;
00056 }
00057 };
00058 FreeBusyUrlStore *FreeBusyUrlStore::Private::sSelf = 0;
00059
00060
00061 FreeBusyUrlStore *FreeBusyUrlStore::self()
00062 {
00063 static Private p;
00064 if ( !p.sSelf ) {
00065 p.sSelf = new FreeBusyUrlStore();
00066 qAddPostRoutine( Private::cleanupFreeBusyUrlStore );
00067 }
00068 return p.sSelf;
00069 }
00070
00071 FreeBusyUrlStore::FreeBusyUrlStore() : d( new Private() )
00072 {
00073 QString configFile =
00074 KStandardDirs::locateLocal( "data", "korganizer/freebusyurls" );
00075 d->mConfig = new KConfig( configFile );
00076 }
00077
00078 FreeBusyUrlStore::~FreeBusyUrlStore()
00079 {
00080 delete d->mConfig;
00081 delete d;
00082 }
00083
00084 void FreeBusyUrlStore::writeUrl( const QString &email, const QString &url )
00085 {
00086 KConfigGroup group = d->mConfig->group( email );
00087 group.writeEntry( "url", url );
00088 }
00089
00090 QString FreeBusyUrlStore::readUrl( const QString &email )
00091 {
00092 KConfigGroup group = d->mConfig->group( email );
00093 return group.readEntry( "url" );
00094 }
00095
00096 void FreeBusyUrlStore::sync()
00097 {
00098 d->mConfig->sync();
00099 }