summaryrefslogtreecommitdiffabout
path: root/libkcal
Side-by-side diff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calstorage.h2
-rw-r--r--libkcal/filestorage.cpp4
-rw-r--r--libkcal/filestorage.h2
-rw-r--r--libkcal/icalformat.cpp24
-rw-r--r--libkcal/icalformat.h3
5 files changed, 7 insertions, 28 deletions
diff --git a/libkcal/calstorage.h b/libkcal/calstorage.h
index 72972ea..82c8682 100644
--- a/libkcal/calstorage.h
+++ b/libkcal/calstorage.h
@@ -18,35 +18,35 @@
Boston, MA 02111-1307, USA.
*/
#ifndef KCAL_CALSTORAGE_H
#define KCAL_CALSTORAGE_H
namespace KCal {
class Calendar;
/**
This class provides the interface to the storage of a calendar.
*/
class CalStorage
{
public:
CalStorage( Calendar *calendar )
{
mCalendar = calendar;
}
virtual ~CalStorage() {}
Calendar *calendar() const { return mCalendar; }
virtual bool open() = 0;
- virtual bool load(bool = false ) = 0;
+ virtual bool load( ) = 0;
virtual bool save() = 0;
virtual bool close() = 0;
private:
Calendar *mCalendar;
};
}
#endif
diff --git a/libkcal/filestorage.cpp b/libkcal/filestorage.cpp
index 00c15d9..a139124 100644
--- a/libkcal/filestorage.cpp
+++ b/libkcal/filestorage.cpp
@@ -55,59 +55,59 @@ void FileStorage::setFileName( const QString &fileName )
QString FileStorage::fileName()const
{
return mFileName;
}
void FileStorage::setSaveFormat( CalFormat *format )
{
delete mSaveFormat;
mSaveFormat = format;
}
CalFormat *FileStorage::saveFormat()const
{
return mSaveFormat;
}
bool FileStorage::open()
{
return true;
}
-bool FileStorage::load( bool quick )
+bool FileStorage::load( )
{
kdDebug(5800) << "FileStorage::load(): '" << mFileName << "'" << endl;
// do we want to silently accept this, or make some noise? Dunno...
// it is a semantical thing vs. a practical thing.
if (mFileName.isEmpty()) return false;
// Always try to load with iCalendar. It will detect, if it is actually a
// vCalendar file.
- ICalFormat iCal (quick );
+ ICalFormat iCal;
bool success = iCal.load( calendar(), mFileName);
if ( !success ) {
if ( iCal.exception() ) {
// kdDebug(5800) << "---Error: " << mFormat->exception()->errorCode() << endl;
if ( iCal.exception()->errorCode() == ErrorFormat::CalVersion1 ) {
// Expected non vCalendar file, but detected vCalendar
kdDebug(5800) << "FileStorage::load() Fallback to VCalFormat" << endl;
VCalFormat vCal;
success = vCal.load( calendar(), mFileName );
calendar()->setLoadedProductId( vCal.productId() );
} else {
return false;
}
} else {
kdDebug(5800) << "Warning! There should be set an exception." << endl;
return false;
}
} else {
// kdDebug(5800) << "---Success" << endl;
calendar()->setLoadedProductId( iCal.loadedProductId() );
}
diff --git a/libkcal/filestorage.h b/libkcal/filestorage.h
index e9dc15e..17010ac 100644
--- a/libkcal/filestorage.h
+++ b/libkcal/filestorage.h
@@ -23,36 +23,36 @@
#include "calstorage.h"
namespace KCal {
/**
This class provides a calendar storage as a local file.
*/
class FileStorage : public CalStorage
{
public:
FileStorage( Calendar *, const QString &fileName = QString::null,
CalFormat *format = 0 );
virtual ~FileStorage();
void setFileName( const QString &mFileName );
QString fileName()const;
/**
FileStorage takes ownership of format object.
*/
void setSaveFormat( CalFormat * );
CalFormat *saveFormat()const;
bool open();
- bool load(bool quick = false );
+ bool load( );
bool save();
bool close();
private:
QString mFileName;
CalFormat *mSaveFormat;
};
}
#endif
diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp
index f2e7dfc..3a2aac6 100644
--- a/libkcal/icalformat.cpp
+++ b/libkcal/icalformat.cpp
@@ -29,122 +29,102 @@
#include <stdlib.h>
#include <kdebug.h>
#include <kglobal.h>
#include <klocale.h>
extern "C" {
#include <ical.h>
#include <icalss.h>
#include <icalparser.h>
#include <icalrestriction.h>
}
#include "calendar.h"
#include "calendarlocal.h"
#include "journal.h"
#include "icalformat.h"
#include "icalformatimpl.h"
#define _ICAL_VERSION "2.0"
using namespace KCal;
-ICalFormat::ICalFormat(bool quick )
+ICalFormat::ICalFormat( )
{
- mQuicksave = false; //quick;
mImpl = new ICalFormatImpl( this );
tzOffsetMin = 0;
//qDebug("new ICalFormat() ");
}
ICalFormat::~ICalFormat()
{
delete mImpl;
//qDebug("delete ICalFormat ");
}
bool ICalFormat::load( Calendar *calendar, const QString &fileName)
{
clearException();
QFile file( fileName );
if (!file.open( IO_ReadOnly ) ) {
setException(new ErrorFormat(ErrorFormat::LoadError));
return false;
}
QTextStream ts( &file );
QString text;
-#if 0
- if ( !mQuicksave ) {
- qDebug("KO: No quickload!");
- ts.setEncoding( QTextStream::Latin1 );
- text = ts.read();
- } else {
- ts.setCodec( QTextCodec::codecForName("utf8") );
- text = ts.read();
- }
-#endif
+
ts.setEncoding( QTextStream::Latin1 );
text = ts.read();
file.close();
return fromString( calendar, text );
}
//#include <qdatetime.h>
bool ICalFormat::save( Calendar *calendar, const QString &fileName )
{
//kdDebug(5800) << "ICalFormat::save(): " << fileName << endl;
//qDebug("ICalFormat::save ");
clearException();
QString text = toString( calendar );
//return false;
// qDebug("to string takes ms: %d ",is.elapsed() );
if ( text.isNull() ) return false;
// TODO: write backup file
//is.restart();
QFile file( fileName );
if (!file.open( IO_WriteOnly ) ) {
setException(new ErrorFormat(ErrorFormat::SaveError,
i18n("Could not open file '%1'").arg(fileName)));
return false;
}
QTextStream ts( &file );
-// #ifdef DESKTOP_VERSION
-// mQuicksave = false;
-// #endif
-// if ( mQuicksave ) {
-// ts << text.utf8();
-// } else {
-// ts.setEncoding( QTextStream::Latin1 );
-// ts << text;
-// //ts << text.latin1();
-// }
ts.setEncoding( QTextStream::Latin1 );
ts << text;
file.close();
//qDebug("saving file takes ms: %d ", is.elapsed() );
return true;
}
bool ICalFormat::fromString( Calendar *cal, const QString &text )
{
setTimeZone( cal->timeZoneId(), !cal->isLocalTime() );
// qDebug("ICalFormat::fromString tz: %s ", cal->timeZoneId().latin1());
// Get first VCALENDAR component.
// TODO: Handle more than one VCALENDAR or non-VCALENDAR top components
icalcomponent *calendar;
//calendar = icalcomponent_new_from_string( text.local8Bit().data());
// good calendar = icalcomponent_new_from_string( text.utf8().data());
calendar = icalcomponent_new_from_string( (char*)text.latin1());
if (!calendar) {
setException(new ErrorFormat(ErrorFormat::ParseErrorIcal));
return false;
}
bool success = true;
diff --git a/libkcal/icalformat.h b/libkcal/icalformat.h
index 236efbf..485ab6e 100644
--- a/libkcal/icalformat.h
+++ b/libkcal/icalformat.h
@@ -19,49 +19,49 @@
*/
#ifndef ICALFORMAT_H
#define ICALFORMAT_H
#include <qstring.h>
#include "scheduler.h"
#include "calformat.h"
namespace KCal {
class ICalFormatImpl;
/**
This class implements the iCalendar format. It provides methods for
loading/saving/converting iCalendar format data into the internal KOrganizer
representation as Calendar and Events.
@short iCalendar format implementation
*/
class ICalFormat : public CalFormat {
public:
/** Create new iCalendar format. */
- ICalFormat( bool quick = false );
+ ICalFormat( );
virtual ~ICalFormat();
/**
Loads a calendar on disk in iCalendar format into calendar.
Returns true if successful, else returns false. Provides more error
information by exception().
@param calendar Calendar object to be filled.
@param fileName The name of the calendar file on disk.
*/
bool load( Calendar *, const QString &fileName );
/**
Writes out the calendar to disk in iCalendar format. Returns true if
successful and false on error.
@param calendar The Calendar object to be written.
@param fileName The name of the calendar file on disk.
*/
bool save( Calendar *, const QString &fileName );
/**
Parse string and populate calendar with that information.
*/
bool fromString( Calendar *, const QString & );
/**
@@ -83,34 +83,33 @@ class ICalFormat : public CalFormat {
/**
Return recurrence as iCalendar formatted text.
*/
QString toString( Recurrence * );
/**
Parse string and fill recurrence object with
that information
*/
//bool fromString ( Recurrence *, const QString& );
/** Create a scheduling message for event \a e using method \m */
QString createScheduleMessage(IncidenceBase *e,Scheduler::Method m);
/** Parse scheduling message provided as string \s */
ScheduleMessage *parseScheduleMessage( Calendar *, const QString &s);
/** Set id of used time zone and whether this time zone is UTC or not. */
void setTimeZone( const QString &id, bool utc );
QString timeZoneId() const;
int timeOffset();
const char * tzString();
bool utc() const;
private:
ICalFormatImpl *mImpl;
- bool mQuicksave;
QString mTimeZoneId;
QCString mTzString;
int tzOffsetMin;
bool mUtc;
};
}
#endif