summaryrefslogtreecommitdiff
authorzecke <zecke>2003-05-07 17:49:07 (UTC)
committer zecke <zecke>2003-05-07 17:49:07 (UTC)
commitc13ada0f5e418b25b177e132ff2e1dfe7821577f (patch) (side-by-side diff)
tree40e8d6cc67a1de638ef3c278fd827ba0cbea5b76
parentac895871f93dce9734189daf9cb95dbbda605096 (diff)
downloadopie-c13ada0f5e418b25b177e132ff2e1dfe7821577f.zip
opie-c13ada0f5e418b25b177e132ff2e1dfe7821577f.tar.gz
opie-c13ada0f5e418b25b177e132ff2e1dfe7821577f.tar.bz2
implement loading of Recurrence
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/opimnotifymanager.cpp3
-rw-r--r--libopie/pim/opimnotifymanager.h3
-rw-r--r--libopie/pim/orecur.cpp2
-rw-r--r--libopie/pim/otodoaccessxml.cpp72
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp72
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.cpp3
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.h3
-rw-r--r--libopie2/opiepim/core/orecur.cpp2
8 files changed, 152 insertions, 8 deletions
diff --git a/libopie/pim/opimnotifymanager.cpp b/libopie/pim/opimnotifymanager.cpp
index be4a1c2..49af757 100644
--- a/libopie/pim/opimnotifymanager.cpp
+++ b/libopie/pim/opimnotifymanager.cpp
@@ -1,69 +1,72 @@
#include "opimnotifymanager.h"
OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al)
: m_rem( rem ), m_al( al )
{}
OPimNotifyManager::~OPimNotifyManager() {
}
/* use static_cast and type instead of dynamic... */
void OPimNotifyManager::add( const OPimNotify& noti) {
if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
m_rem.append( rem );
}else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
m_al.append( al );
}
}
void OPimNotifyManager::remove( const OPimNotify& noti) {
if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
m_rem.remove( rem );
}else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
m_al.remove( al );
}
}
void OPimNotifyManager::replace( const OPimNotify& noti) {
if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
m_rem.remove( rem );
m_rem.append( rem );
}else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
m_al.remove( al );
m_al.append( al );
}
}
OPimNotifyManager::Reminders OPimNotifyManager::reminders()const {
return m_rem;
}
OPimNotifyManager::Alarms OPimNotifyManager::alarms()const {
return m_al;
}
void OPimNotifyManager::setAlarms( const Alarms& al) {
m_al = al;
}
void OPimNotifyManager::setReminders( const Reminders& rem) {
m_rem = rem;
}
/* FIXME!!! */
/**
* The idea is to check if the provider for our service
* is online
* if it is we will use QCOP
* if not the Factory to get the backend...
* Qtopia1.6 services would be kewl to have here....
*/
void OPimNotifyManager::registerNotify( const OPimNotify& ) {
}
/* FIXME!!! */
/**
* same as above...
* Also implement Url model
* have a MainWindow....
*/
void OPimNotifyManager::deregister( const OPimNotify& ) {
}
+bool OPimNotifyManager::isEmpty()const {
+ return ( m_rem.isEmpty() && m_al.isEmpty() );
+}
diff --git a/libopie/pim/opimnotifymanager.h b/libopie/pim/opimnotifymanager.h
index 0eebc9b..0ac30a1 100644
--- a/libopie/pim/opimnotifymanager.h
+++ b/libopie/pim/opimnotifymanager.h
@@ -1,51 +1,54 @@
#ifndef OPIE_PIM_NOTIFY_MANAGER_H
#define OPIE_PIM_NOTIFY_MANAGER_H
#include <qvaluelist.h>
#include <opie/opimnotify.h>
/**
* The notify manager keeps track of the Notifiers....
*/
class OPimNotifyManager {
public:
typedef QValueList<OPimReminder> Reminders;
typedef QValueList<OPimAlarm> Alarms;
OPimNotifyManager( const Reminders& rems = Reminders(), const Alarms& alarms = Alarms() );
~OPimNotifyManager();
/* we will cast it for you ;) */
void add( const OPimNotify& );
void remove( const OPimNotify& );
/* replaces all with this one! */
void replace( const OPimNotify& );
Reminders reminders()const;
Alarms alarms()const;
void setAlarms( const Alarms& );
void setReminders( const Reminders& );
/* register is a Ansi C keyword... */
/**
* This function will register the Notify to the Alarm Server
* or datebook depending on the type of the notify
*/
void registerNotify( const OPimNotify& );
/**
* this will do the opposite..
*/
void deregister( const OPimNotify& );
+
+ bool isEmpty()const;
+
private:
Reminders m_rem;
Alarms m_al;
class Private;
Private *d;
};
#endif
diff --git a/libopie/pim/orecur.cpp b/libopie/pim/orecur.cpp
index e3b45b4..eae1fdc 100644
--- a/libopie/pim/orecur.cpp
+++ b/libopie/pim/orecur.cpp
@@ -411,100 +411,100 @@ void ORecur::setPosition( int pos ) {
void ORecur::setDays( char c ) {
checkOrModify();
data->days = c;
}
void ORecur::setEndDate( const QDate& dt) {
checkOrModify();
data->end = dt;
}
void ORecur::setCreatedDateTime( const QDateTime& t) {
checkOrModify();
data->create = t;
}
void ORecur::setHasEndDate( bool b) {
checkOrModify();
data->hasEnd = b;
}
void ORecur::setRepitition( int rep ) {
checkOrModify();
data->rep = rep;
}
void ORecur::setService( const QString& app ) {
checkOrModify();
data->app = app;
}
void ORecur::setStart( const QDate& dt ) {
checkOrModify();
data->start = dt;
}
void ORecur::checkOrModify() {
if ( data->count != 1 ) {
data->deref();
Data* d2 = new Data;
d2->days = data->days;
d2->type = data->type;
d2->freq = data->freq;
d2->pos = data->pos;
d2->hasEnd = data->hasEnd;
d2->end = data->end;
d2->create = data->create;
d2->rep = data->rep;
d2->app = data->app;
d2->list = data->list;
d2->start = data->start;
data = d2;
}
}
QString ORecur::toString()const {
QString buf;
buf += " rtype=\"";
switch ( data->type ) {
case ORecur::Daily:
buf += "Daily";
break;
case ORecur::Weekly:
buf += "Weekly";
break;
case ORecur::MonthlyDay:
buf += "MonthlyDay";
break;
case ORecur::MonthlyDate:
buf += "MonthlyDate";
break;
case ORecur::Yearly:
buf += "Yearly";
break;
default:
buf += "NoRepeat";
break;
}
buf += "\"";
if (data->days > 0 )
buf += " rweekdays=\"" + QString::number( static_cast<int>( data->days ) ) + "\"";
if ( data->pos != 0 )
buf += " rposition=\"" + QString::number(data->pos ) + "\"";
buf += " rfreq=\"" + QString::number( data->freq ) + "\"";
buf += " rhasenddate=\"" + QString::number( static_cast<int>( data->hasEnd ) ) + "\"";
if ( data->hasEnd )
buf += " enddt=\""
+ QString::number( OTimeZone::utc().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) )
+ "\"";
buf += " created=\"" + QString::number( OTimeZone::utc().fromUTCDateTime( data->create ) ) + "\"";
if ( data->list.isEmpty() ) return buf;
// save exceptions list here!!
ExceptionList::ConstIterator it;
ExceptionList list = data->list;
buf += " exceptions=\"";
QDate date;
for ( it = list.begin(); it != list.end(); ++it ) {
date = (*it);
if ( it != list.begin() ) buf += " ";
buf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() );
}
- buf += "\"";
+ buf += "\" ";
return buf;
}
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp
index c0d8dfc..71b6a7e 100644
--- a/libopie/pim/otodoaccessxml.cpp
+++ b/libopie/pim/otodoaccessxml.cpp
@@ -1,281 +1,315 @@
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <qfile.h>
#include <qvector.h>
#include <qpe/global.h>
#include <qpe/stringutil.h>
#include <qpe/timeconversion.h>
+#include "otimezone.h"
#include "orecur.h"
#include "otodoaccessxml.h"
namespace {
+ time_t rp_end;
+ ORecur* rec;
+ ORecur *recur() {
+ if (!rec ) rec = new ORecur;
+ return rec;
+ }
+ int snd;
+ enum MoreAttributes {
+ FRType = OTodo::CompletedDate + 2,
+ FRWeekdays,
+ FRPosition,
+ FRFreq,
+ FRHasEndDate,
+ FREndDate,
+ FRStart,
+ FREnd
+ };
// FROM TT again
char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
{
char needleChar;
char haystackChar;
if (!needle || !haystack || !hLen || !nLen)
return 0;
const char* hsearch = haystack;
if ((needleChar = *needle++) != 0) {
nLen--; //(to make up for needle++)
do {
do {
if ((haystackChar = *hsearch++) == 0)
return (0);
if (hsearch >= haystack + hLen)
return (0);
} while (haystackChar != needleChar);
} while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0);
hsearch--;
}
return ((char *)hsearch);
}
}
OTodoAccessXML::OTodoAccessXML( const QString& appName,
const QString& fileName )
: OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false )
{
if (!fileName.isEmpty() )
m_file = fileName;
else
m_file = Global::applicationFileName( "todolist", "todolist.xml" );
}
OTodoAccessXML::~OTodoAccessXML() {
}
bool OTodoAccessXML::load() {
+ rec = 0;
m_opened = true;
m_changed = false;
/* initialize dict */
/*
* UPDATE dict if you change anything!!!
*/
QAsciiDict<int> dict(21);
dict.setAutoDelete( TRUE );
dict.insert("Categories" , new int(OTodo::Category) );
dict.insert("Uid" , new int(OTodo::Uid) );
dict.insert("HasDate" , new int(OTodo::HasDate) );
dict.insert("Completed" , new int(OTodo::Completed) );
dict.insert("Description" , new int(OTodo::Description) );
dict.insert("Summary" , new int(OTodo::Summary) );
dict.insert("Priority" , new int(OTodo::Priority) );
dict.insert("DateDay" , new int(OTodo::DateDay) );
dict.insert("DateMonth" , new int(OTodo::DateMonth) );
dict.insert("DateYear" , new int(OTodo::DateYear) );
dict.insert("Progress" , new int(OTodo::Progress) );
- dict.insert("Completed", new int(OTodo::Completed) );
+ dict.insert("CompletedDate", new int(OTodo::CompletedDate) );
dict.insert("CrossReference", new int(OTodo::CrossReference) );
dict.insert("State", new int(OTodo::State) );
- dict.insert("Recurrence", new int(OTodo::Recurrence) );
dict.insert("Alarms", new int(OTodo::Alarms) );
dict.insert("Reminders", new int(OTodo::Reminders) );
dict.insert("Notifiers", new int(OTodo::Notifiers) );
dict.insert("Maintainer", new int(OTodo::Maintainer) );
+ dict.insert("rtype", new int(FRType) );
+ dict.insert("rweekdays", new int(FRWeekdays) );
+ dict.insert("rposition", new int(FRPosition) );
+ dict.insert("rfreq", new int(FRFreq) );
+ dict.insert("start", new int(FRStart) );
+ dict.insert("rhasenddate", new int(FRHasEndDate) );
+ dict.insert("enddt", new int(FREndDate) );
// here the custom XML parser from TT it's GPL
// but we want to push OpiePIM... to TT.....
// mmap part from zecke :)
int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY );
struct stat attribut;
if ( fd < 0 ) return false;
if ( fstat(fd, &attribut ) == -1 ) {
::close( fd );
return false;
}
void* map_addr = ::mmap(NULL, attribut.st_size, PROT_READ, MAP_SHARED, fd, 0 );
if ( map_addr == ( (caddr_t)-1) ) {
::close(fd );
return false;
}
/* advise the kernel who we want to read it */
::madvise( map_addr, attribut.st_size, MADV_SEQUENTIAL );
/* we do not the file any more */
::close( fd );
char* dt = (char*)map_addr;
int len = attribut.st_size;
int i = 0;
char *point;
const char* collectionString = "<Task ";
int strLen = strlen(collectionString);
while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) {
i = point -dt;
i+= strLen;
qWarning("Found a start at %d %d", i, (point-dt) );
OTodo ev;
m_year = m_month = m_day = 0;
while ( TRUE ) {
while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') )
++i;
if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') )
break;
// we have another attribute, read it.
int j = i;
while ( j < len && dt[j] != '=' )
++j;
QCString attr( dt+i, j-i+1);
i = ++j; // skip =
// find the start of quotes
while ( i < len && dt[i] != '"' )
++i;
j = ++i;
bool haveUtf = FALSE;
bool haveEnt = FALSE;
while ( j < len && dt[j] != '"' ) {
if ( ((unsigned char)dt[j]) > 0x7f )
haveUtf = TRUE;
if ( dt[j] == '&' )
haveEnt = TRUE;
++j;
}
if ( i == j ) {
// empty value
i = j + 1;
continue;
}
QCString value( dt+i, j-i+1 );
i = j + 1;
QString str = (haveUtf ? QString::fromUtf8( value )
: QString::fromLatin1( value ) );
if ( haveEnt )
str = Qtopia::plainString( str );
/*
* add key + value
*/
todo( &dict, ev, attr, str );
}
/*
* now add it
*/
qWarning("End at %d", i );
if (m_events.contains( ev.uid() ) || ev.uid() == 0) {
ev.setUid( 1 );
m_changed = true;
}
if ( ev.hasDueDate() ) {
ev.setDueDate( QDate(m_year, m_month, m_day) );
}
+ if ( rec && rec->doesRecur() ) {
+ OTimeZone utc = OTimeZone::utc();
+ ORecur recu( *rec ); // call copy c'tor
+ recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() );
+ recu.setStart( ev.dueDate() );
+ ev.setRecurrence( recu );
+ }
m_events.insert(ev.uid(), ev );
m_year = m_month = m_day = -1;
+ delete rec;
+ rec = 0;
}
munmap(map_addr, attribut.st_size );
qWarning("counts %d records loaded!", m_events.count() );
return true;
}
bool OTodoAccessXML::reload() {
m_events.clear();
return load();
}
bool OTodoAccessXML::save() {
// qWarning("saving");
if (!m_opened || !m_changed ) {
// qWarning("not saving");
return true;
}
QString strNewFile = m_file + ".new";
QFile f( strNewFile );
if (!f.open( IO_WriteOnly|IO_Raw ) )
return false;
int written;
QString out;
out = "<!DOCTYPE Tasks>\n<Tasks>\n";
// for all todos
QMap<int, OTodo>::Iterator it;
for (it = m_events.begin(); it != m_events.end(); ++it ) {
out+= "<Task " + toString( (*it) ) + " />\n";
QCString cstr = out.utf8();
written = f.writeBlock( cstr.data(), cstr.length() );
/* less written then we wanted */
if ( written != (int)cstr.length() ) {
f.close();
QFile::remove( strNewFile );
return false;
}
out = QString::null;
}
out += "</Tasks>";
QCString cstr = out.utf8();
written = f.writeBlock( cstr.data(), cstr.length() );
if ( written != (int)cstr.length() ) {
f.close();
QFile::remove( strNewFile );
return false;
}
/* flush before renaming */
f.close();
if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) {
// qWarning("error renaming");
QFile::remove( strNewFile );
}
m_changed = false;
return true;
}
QArray<int> OTodoAccessXML::allRecords()const {
QArray<int> ids( m_events.count() );
QMap<int, OTodo>::ConstIterator it;
int i = 0;
for ( it = m_events.begin(); it != m_events.end(); ++it ) {
ids[i] = it.key();
i++;
}
return ids;
}
QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int, const QDateTime& ) {
QArray<int> ids(0);
return ids;
}
OTodo OTodoAccessXML::find( int uid )const {
OTodo todo;
todo.setUid( 0 ); // isEmpty()
QMap<int, OTodo>::ConstIterator it = m_events.find( uid );
if ( it != m_events.end() )
todo = it.data();
return todo;
}
void OTodoAccessXML::clear() {
if (m_opened )
m_changed = true;
m_events.clear();
}
bool OTodoAccessXML::add( const OTodo& todo ) {
// qWarning("add");
m_changed = true;
m_events.insert( todo.uid(), todo );
@@ -304,232 +338,264 @@ QArray<int> OTodoAccessXML::effectiveToDos( const QDate& start,
for ( it = m_events.begin(); it != m_events.end(); ++it ) {
if ( !it.data().hasDueDate() ) {
if ( includeNoDates ) {
ids[i] = it.key();
i++;
}
}else if ( it.data().dueDate() >= start &&
it.data().dueDate() <= end ) {
ids[i] = it.key();
i++;
}
}
ids.resize( i );
return ids;
}
QArray<int> OTodoAccessXML::overDue() {
QArray<int> ids( m_events.count() );
int i = 0;
QMap<int, OTodo>::Iterator it;
for ( it = m_events.begin(); it != m_events.end(); ++it ) {
if ( it.data().isOverdue() ) {
ids[i] = it.key();
i++;
}
}
ids.resize( i );
return ids;
}
/* private */
void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev,
const QCString& attr, const QString& val) {
// qWarning("parse to do from XMLElement" );
int *find=0;
find = (*dict)[ attr.data() ];
if (!find ) {
// qWarning("Unknown option" + it.key() );
ev.setCustomField( attr, val );
return;
}
switch( *find ) {
case OTodo::Uid:
ev.setUid( val.toInt() );
break;
case OTodo::Category:
ev.setCategories( ev.idsFromString( val ) );
break;
case OTodo::HasDate:
ev.setHasDueDate( val.toInt() );
break;
case OTodo::Completed:
ev.setCompleted( val.toInt() );
break;
case OTodo::Description:
ev.setDescription( val );
break;
case OTodo::Summary:
ev.setSummary( val );
break;
case OTodo::Priority:
ev.setPriority( val.toInt() );
break;
case OTodo::DateDay:
m_day = val.toInt();
break;
case OTodo::DateMonth:
m_month = val.toInt();
break;
case OTodo::DateYear:
m_year = val.toInt();
break;
case OTodo::Progress:
ev.setProgress( val.toInt() );
break;
case OTodo::CrossReference:
{
/*
* A cross refernce looks like
* appname,id;appname,id
* we need to split it up
*/
QStringList refs = QStringList::split(';', val );
QStringList::Iterator strIt;
for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) {
int pos = (*strIt).find(',');
if ( pos > -1 )
; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() );
}
break;
}
+ /* Recurrence stuff below + post processing later */
+ case FRType:
+ if ( val == "Daily" )
+ recur()->setType( ORecur::Daily );
+ else if ( val == "Weekly" )
+ recur()->setType( ORecur::Weekly);
+ else if ( val == "MonthlyDay" )
+ recur()->setType( ORecur::MonthlyDay );
+ else if ( val == "MonthlyDate" )
+ recur()->setType( ORecur::MonthlyDate );
+ else if ( val == "Yearly" )
+ recur()->setType( ORecur::Yearly );
+ else
+ recur()->setType( ORecur::NoRepeat );
+ break;
+ case FRWeekdays:
+ recur()->setDays( val.toInt() );
+ break;
+ case FRPosition:
+ recur()->setPosition( val.toInt() );
+ break;
+ case FRFreq:
+ recur()->setFrequency( val.toInt() );
+ break;
+ case FRHasEndDate:
+ recur()->setHasEndDate( val.toInt() );
+ break;
+ case FREndDate: {
+ rp_end = (time_t) val.toLong();
+ break;
+ }
default:
break;
}
}
QString OTodoAccessXML::toString( const OTodo& ev )const {
QString str;
str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" ";
str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" ";
str += "Priority=\"" + QString::number( ev.priority() ) + "\" ";
str += "Progress=\"" + QString::number(ev.progress() ) + "\" ";
str += "Categories=\"" + toString( ev.categories() ) + "\" ";
str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" ";
str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" ";
if ( ev.hasDueDate() ) {
str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" ";
str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" ";
str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" ";
}
// qWarning( "Uid %d", ev.uid() );
str += "Uid=\"" + QString::number( ev.uid() ) + "\" ";
// append the extra options
/* FIXME Qtopia::Record this is currently not
* possible you can set custom fields
* but don' iterate over the list
* I may do #define private protected
* for this case - cough --zecke
*/
/*
QMap<QString, QString> extras = ev.extras();
QMap<QString, QString>::Iterator extIt;
for (extIt = extras.begin(); extIt != extras.end(); ++extIt )
str += extIt.key() + "=\"" + extIt.data() + "\" ";
*/
// cross refernce
- if ( ev.hasRecurrence() )
+ if ( ev.hasRecurrence() ) {
str += ev.recurrence().toString();
+ }
return str;
}
QString OTodoAccessXML::toString( const QArray<int>& ints ) const {
return Qtopia::Record::idsToString( ints );
}
/* internal class for sorting
*
* Inspired by todoxmlio.cpp from TT
*/
struct OTodoXMLContainer {
OTodo todo;
};
namespace {
inline QString string( const OTodo& todo) {
return todo.summary().isEmpty() ?
todo.description().left(20 ) :
todo.summary();
}
inline int completed( const OTodo& todo1, const OTodo& todo2) {
int ret = 0;
if ( todo1.isCompleted() ) ret++;
if ( todo2.isCompleted() ) ret--;
return ret;
}
inline int priority( const OTodo& t1, const OTodo& t2) {
return ( t1.priority() - t2.priority() );
}
inline int description( const OTodo& t1, const OTodo& t2) {
return QString::compare( string(t1), string(t2) );
}
inline int deadline( const OTodo& t1, const OTodo& t2) {
int ret = 0;
if ( t1.hasDueDate() &&
t2.hasDueDate() )
ret = t2.dueDate().daysTo( t1.dueDate() );
else if ( t1.hasDueDate() )
ret = -1;
else if ( t2.hasDueDate() )
ret = 1;
else
ret = 0;
return ret;
}
};
/*
* Returns:
* 0 if item1 == item2
*
* non-zero if item1 != item2
*
* This function returns int rather than bool so that reimplementations
* can return one of three values and use it to sort by:
*
* 0 if item1 == item2
*
* > 0 (positive integer) if item1 > item2
*
* < 0 (negative integer) if item1 < item2
*
*/
class OTodoXMLVector : public QVector<OTodoXMLContainer> {
public:
OTodoXMLVector(int size, bool asc, int sort)
: QVector<OTodoXMLContainer>( size )
{
setAutoDelete( true );
m_asc = asc;
m_sort = sort;
}
/* return the summary/description */
QString string( const OTodo& todo) {
return todo.summary().isEmpty() ?
todo.description().left(20 ) :
todo.summary();
}
/**
* we take the sortorder( switch on it )
*
*/
int compareItems( Item d1, Item d2 ) {
bool seComp, sePrio, seDesc, seDeadline;
seComp = sePrio = seDeadline = seDesc = false;
int ret =0;
OTodoXMLContainer* con1 = (OTodoXMLContainer*)d1;
OTodoXMLContainer* con2 = (OTodoXMLContainer*)d2;
/* same item */
if ( con1->todo.uid() == con2->todo.uid() )
return 0;
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index c0d8dfc..71b6a7e 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -1,281 +1,315 @@
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <qfile.h>
#include <qvector.h>
#include <qpe/global.h>
#include <qpe/stringutil.h>
#include <qpe/timeconversion.h>
+#include "otimezone.h"
#include "orecur.h"
#include "otodoaccessxml.h"
namespace {
+ time_t rp_end;
+ ORecur* rec;
+ ORecur *recur() {
+ if (!rec ) rec = new ORecur;
+ return rec;
+ }
+ int snd;
+ enum MoreAttributes {
+ FRType = OTodo::CompletedDate + 2,
+ FRWeekdays,
+ FRPosition,
+ FRFreq,
+ FRHasEndDate,
+ FREndDate,
+ FRStart,
+ FREnd
+ };
// FROM TT again
char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
{
char needleChar;
char haystackChar;
if (!needle || !haystack || !hLen || !nLen)
return 0;
const char* hsearch = haystack;
if ((needleChar = *needle++) != 0) {
nLen--; //(to make up for needle++)
do {
do {
if ((haystackChar = *hsearch++) == 0)
return (0);
if (hsearch >= haystack + hLen)
return (0);
} while (haystackChar != needleChar);
} while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0);
hsearch--;
}
return ((char *)hsearch);
}
}
OTodoAccessXML::OTodoAccessXML( const QString& appName,
const QString& fileName )
: OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false )
{
if (!fileName.isEmpty() )
m_file = fileName;
else
m_file = Global::applicationFileName( "todolist", "todolist.xml" );
}
OTodoAccessXML::~OTodoAccessXML() {
}
bool OTodoAccessXML::load() {
+ rec = 0;
m_opened = true;
m_changed = false;
/* initialize dict */
/*
* UPDATE dict if you change anything!!!
*/
QAsciiDict<int> dict(21);
dict.setAutoDelete( TRUE );
dict.insert("Categories" , new int(OTodo::Category) );
dict.insert("Uid" , new int(OTodo::Uid) );
dict.insert("HasDate" , new int(OTodo::HasDate) );
dict.insert("Completed" , new int(OTodo::Completed) );
dict.insert("Description" , new int(OTodo::Description) );
dict.insert("Summary" , new int(OTodo::Summary) );
dict.insert("Priority" , new int(OTodo::Priority) );
dict.insert("DateDay" , new int(OTodo::DateDay) );
dict.insert("DateMonth" , new int(OTodo::DateMonth) );
dict.insert("DateYear" , new int(OTodo::DateYear) );
dict.insert("Progress" , new int(OTodo::Progress) );
- dict.insert("Completed", new int(OTodo::Completed) );
+ dict.insert("CompletedDate", new int(OTodo::CompletedDate) );
dict.insert("CrossReference", new int(OTodo::CrossReference) );
dict.insert("State", new int(OTodo::State) );
- dict.insert("Recurrence", new int(OTodo::Recurrence) );
dict.insert("Alarms", new int(OTodo::Alarms) );
dict.insert("Reminders", new int(OTodo::Reminders) );
dict.insert("Notifiers", new int(OTodo::Notifiers) );
dict.insert("Maintainer", new int(OTodo::Maintainer) );
+ dict.insert("rtype", new int(FRType) );
+ dict.insert("rweekdays", new int(FRWeekdays) );
+ dict.insert("rposition", new int(FRPosition) );
+ dict.insert("rfreq", new int(FRFreq) );
+ dict.insert("start", new int(FRStart) );
+ dict.insert("rhasenddate", new int(FRHasEndDate) );
+ dict.insert("enddt", new int(FREndDate) );
// here the custom XML parser from TT it's GPL
// but we want to push OpiePIM... to TT.....
// mmap part from zecke :)
int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY );
struct stat attribut;
if ( fd < 0 ) return false;
if ( fstat(fd, &attribut ) == -1 ) {
::close( fd );
return false;
}
void* map_addr = ::mmap(NULL, attribut.st_size, PROT_READ, MAP_SHARED, fd, 0 );
if ( map_addr == ( (caddr_t)-1) ) {
::close(fd );
return false;
}
/* advise the kernel who we want to read it */
::madvise( map_addr, attribut.st_size, MADV_SEQUENTIAL );
/* we do not the file any more */
::close( fd );
char* dt = (char*)map_addr;
int len = attribut.st_size;
int i = 0;
char *point;
const char* collectionString = "<Task ";
int strLen = strlen(collectionString);
while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) {
i = point -dt;
i+= strLen;
qWarning("Found a start at %d %d", i, (point-dt) );
OTodo ev;
m_year = m_month = m_day = 0;
while ( TRUE ) {
while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') )
++i;
if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') )
break;
// we have another attribute, read it.
int j = i;
while ( j < len && dt[j] != '=' )
++j;
QCString attr( dt+i, j-i+1);
i = ++j; // skip =
// find the start of quotes
while ( i < len && dt[i] != '"' )
++i;
j = ++i;
bool haveUtf = FALSE;
bool haveEnt = FALSE;
while ( j < len && dt[j] != '"' ) {
if ( ((unsigned char)dt[j]) > 0x7f )
haveUtf = TRUE;
if ( dt[j] == '&' )
haveEnt = TRUE;
++j;
}
if ( i == j ) {
// empty value
i = j + 1;
continue;
}
QCString value( dt+i, j-i+1 );
i = j + 1;
QString str = (haveUtf ? QString::fromUtf8( value )
: QString::fromLatin1( value ) );
if ( haveEnt )
str = Qtopia::plainString( str );
/*
* add key + value
*/
todo( &dict, ev, attr, str );
}
/*
* now add it
*/
qWarning("End at %d", i );
if (m_events.contains( ev.uid() ) || ev.uid() == 0) {
ev.setUid( 1 );
m_changed = true;
}
if ( ev.hasDueDate() ) {
ev.setDueDate( QDate(m_year, m_month, m_day) );
}
+ if ( rec && rec->doesRecur() ) {
+ OTimeZone utc = OTimeZone::utc();
+ ORecur recu( *rec ); // call copy c'tor
+ recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() );
+ recu.setStart( ev.dueDate() );
+ ev.setRecurrence( recu );
+ }
m_events.insert(ev.uid(), ev );
m_year = m_month = m_day = -1;
+ delete rec;
+ rec = 0;
}
munmap(map_addr, attribut.st_size );
qWarning("counts %d records loaded!", m_events.count() );
return true;
}
bool OTodoAccessXML::reload() {
m_events.clear();
return load();
}
bool OTodoAccessXML::save() {
// qWarning("saving");
if (!m_opened || !m_changed ) {
// qWarning("not saving");
return true;
}
QString strNewFile = m_file + ".new";
QFile f( strNewFile );
if (!f.open( IO_WriteOnly|IO_Raw ) )
return false;
int written;
QString out;
out = "<!DOCTYPE Tasks>\n<Tasks>\n";
// for all todos
QMap<int, OTodo>::Iterator it;
for (it = m_events.begin(); it != m_events.end(); ++it ) {
out+= "<Task " + toString( (*it) ) + " />\n";
QCString cstr = out.utf8();
written = f.writeBlock( cstr.data(), cstr.length() );
/* less written then we wanted */
if ( written != (int)cstr.length() ) {
f.close();
QFile::remove( strNewFile );
return false;
}
out = QString::null;
}
out += "</Tasks>";
QCString cstr = out.utf8();
written = f.writeBlock( cstr.data(), cstr.length() );
if ( written != (int)cstr.length() ) {
f.close();
QFile::remove( strNewFile );
return false;
}
/* flush before renaming */
f.close();
if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) {
// qWarning("error renaming");
QFile::remove( strNewFile );
}
m_changed = false;
return true;
}
QArray<int> OTodoAccessXML::allRecords()const {
QArray<int> ids( m_events.count() );
QMap<int, OTodo>::ConstIterator it;
int i = 0;
for ( it = m_events.begin(); it != m_events.end(); ++it ) {
ids[i] = it.key();
i++;
}
return ids;
}
QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int, const QDateTime& ) {
QArray<int> ids(0);
return ids;
}
OTodo OTodoAccessXML::find( int uid )const {
OTodo todo;
todo.setUid( 0 ); // isEmpty()
QMap<int, OTodo>::ConstIterator it = m_events.find( uid );
if ( it != m_events.end() )
todo = it.data();
return todo;
}
void OTodoAccessXML::clear() {
if (m_opened )
m_changed = true;
m_events.clear();
}
bool OTodoAccessXML::add( const OTodo& todo ) {
// qWarning("add");
m_changed = true;
m_events.insert( todo.uid(), todo );
@@ -304,232 +338,264 @@ QArray<int> OTodoAccessXML::effectiveToDos( const QDate& start,
for ( it = m_events.begin(); it != m_events.end(); ++it ) {
if ( !it.data().hasDueDate() ) {
if ( includeNoDates ) {
ids[i] = it.key();
i++;
}
}else if ( it.data().dueDate() >= start &&
it.data().dueDate() <= end ) {
ids[i] = it.key();
i++;
}
}
ids.resize( i );
return ids;
}
QArray<int> OTodoAccessXML::overDue() {
QArray<int> ids( m_events.count() );
int i = 0;
QMap<int, OTodo>::Iterator it;
for ( it = m_events.begin(); it != m_events.end(); ++it ) {
if ( it.data().isOverdue() ) {
ids[i] = it.key();
i++;
}
}
ids.resize( i );
return ids;
}
/* private */
void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev,
const QCString& attr, const QString& val) {
// qWarning("parse to do from XMLElement" );
int *find=0;
find = (*dict)[ attr.data() ];
if (!find ) {
// qWarning("Unknown option" + it.key() );
ev.setCustomField( attr, val );
return;
}
switch( *find ) {
case OTodo::Uid:
ev.setUid( val.toInt() );
break;
case OTodo::Category:
ev.setCategories( ev.idsFromString( val ) );
break;
case OTodo::HasDate:
ev.setHasDueDate( val.toInt() );
break;
case OTodo::Completed:
ev.setCompleted( val.toInt() );
break;
case OTodo::Description:
ev.setDescription( val );
break;
case OTodo::Summary:
ev.setSummary( val );
break;
case OTodo::Priority:
ev.setPriority( val.toInt() );
break;
case OTodo::DateDay:
m_day = val.toInt();
break;
case OTodo::DateMonth:
m_month = val.toInt();
break;
case OTodo::DateYear:
m_year = val.toInt();
break;
case OTodo::Progress:
ev.setProgress( val.toInt() );
break;
case OTodo::CrossReference:
{
/*
* A cross refernce looks like
* appname,id;appname,id
* we need to split it up
*/
QStringList refs = QStringList::split(';', val );
QStringList::Iterator strIt;
for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) {
int pos = (*strIt).find(',');
if ( pos > -1 )
; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() );
}
break;
}
+ /* Recurrence stuff below + post processing later */
+ case FRType:
+ if ( val == "Daily" )
+ recur()->setType( ORecur::Daily );
+ else if ( val == "Weekly" )
+ recur()->setType( ORecur::Weekly);
+ else if ( val == "MonthlyDay" )
+ recur()->setType( ORecur::MonthlyDay );
+ else if ( val == "MonthlyDate" )
+ recur()->setType( ORecur::MonthlyDate );
+ else if ( val == "Yearly" )
+ recur()->setType( ORecur::Yearly );
+ else
+ recur()->setType( ORecur::NoRepeat );
+ break;
+ case FRWeekdays:
+ recur()->setDays( val.toInt() );
+ break;
+ case FRPosition:
+ recur()->setPosition( val.toInt() );
+ break;
+ case FRFreq:
+ recur()->setFrequency( val.toInt() );
+ break;
+ case FRHasEndDate:
+ recur()->setHasEndDate( val.toInt() );
+ break;
+ case FREndDate: {
+ rp_end = (time_t) val.toLong();
+ break;
+ }
default:
break;
}
}
QString OTodoAccessXML::toString( const OTodo& ev )const {
QString str;
str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" ";
str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" ";
str += "Priority=\"" + QString::number( ev.priority() ) + "\" ";
str += "Progress=\"" + QString::number(ev.progress() ) + "\" ";
str += "Categories=\"" + toString( ev.categories() ) + "\" ";
str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" ";
str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" ";
if ( ev.hasDueDate() ) {
str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" ";
str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" ";
str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" ";
}
// qWarning( "Uid %d", ev.uid() );
str += "Uid=\"" + QString::number( ev.uid() ) + "\" ";
// append the extra options
/* FIXME Qtopia::Record this is currently not
* possible you can set custom fields
* but don' iterate over the list
* I may do #define private protected
* for this case - cough --zecke
*/
/*
QMap<QString, QString> extras = ev.extras();
QMap<QString, QString>::Iterator extIt;
for (extIt = extras.begin(); extIt != extras.end(); ++extIt )
str += extIt.key() + "=\"" + extIt.data() + "\" ";
*/
// cross refernce
- if ( ev.hasRecurrence() )
+ if ( ev.hasRecurrence() ) {
str += ev.recurrence().toString();
+ }
return str;
}
QString OTodoAccessXML::toString( const QArray<int>& ints ) const {
return Qtopia::Record::idsToString( ints );
}
/* internal class for sorting
*
* Inspired by todoxmlio.cpp from TT
*/
struct OTodoXMLContainer {
OTodo todo;
};
namespace {
inline QString string( const OTodo& todo) {
return todo.summary().isEmpty() ?
todo.description().left(20 ) :
todo.summary();
}
inline int completed( const OTodo& todo1, const OTodo& todo2) {
int ret = 0;
if ( todo1.isCompleted() ) ret++;
if ( todo2.isCompleted() ) ret--;
return ret;
}
inline int priority( const OTodo& t1, const OTodo& t2) {
return ( t1.priority() - t2.priority() );
}
inline int description( const OTodo& t1, const OTodo& t2) {
return QString::compare( string(t1), string(t2) );
}
inline int deadline( const OTodo& t1, const OTodo& t2) {
int ret = 0;
if ( t1.hasDueDate() &&
t2.hasDueDate() )
ret = t2.dueDate().daysTo( t1.dueDate() );
else if ( t1.hasDueDate() )
ret = -1;
else if ( t2.hasDueDate() )
ret = 1;
else
ret = 0;
return ret;
}
};
/*
* Returns:
* 0 if item1 == item2
*
* non-zero if item1 != item2
*
* This function returns int rather than bool so that reimplementations
* can return one of three values and use it to sort by:
*
* 0 if item1 == item2
*
* > 0 (positive integer) if item1 > item2
*
* < 0 (negative integer) if item1 < item2
*
*/
class OTodoXMLVector : public QVector<OTodoXMLContainer> {
public:
OTodoXMLVector(int size, bool asc, int sort)
: QVector<OTodoXMLContainer>( size )
{
setAutoDelete( true );
m_asc = asc;
m_sort = sort;
}
/* return the summary/description */
QString string( const OTodo& todo) {
return todo.summary().isEmpty() ?
todo.description().left(20 ) :
todo.summary();
}
/**
* we take the sortorder( switch on it )
*
*/
int compareItems( Item d1, Item d2 ) {
bool seComp, sePrio, seDesc, seDeadline;
seComp = sePrio = seDeadline = seDesc = false;
int ret =0;
OTodoXMLContainer* con1 = (OTodoXMLContainer*)d1;
OTodoXMLContainer* con2 = (OTodoXMLContainer*)d2;
/* same item */
if ( con1->todo.uid() == con2->todo.uid() )
return 0;
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp
index be4a1c2..49af757 100644
--- a/libopie2/opiepim/core/opimnotifymanager.cpp
+++ b/libopie2/opiepim/core/opimnotifymanager.cpp
@@ -1,69 +1,72 @@
#include "opimnotifymanager.h"
OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al)
: m_rem( rem ), m_al( al )
{}
OPimNotifyManager::~OPimNotifyManager() {
}
/* use static_cast and type instead of dynamic... */
void OPimNotifyManager::add( const OPimNotify& noti) {
if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
m_rem.append( rem );
}else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
m_al.append( al );
}
}
void OPimNotifyManager::remove( const OPimNotify& noti) {
if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
m_rem.remove( rem );
}else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
m_al.remove( al );
}
}
void OPimNotifyManager::replace( const OPimNotify& noti) {
if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
m_rem.remove( rem );
m_rem.append( rem );
}else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
m_al.remove( al );
m_al.append( al );
}
}
OPimNotifyManager::Reminders OPimNotifyManager::reminders()const {
return m_rem;
}
OPimNotifyManager::Alarms OPimNotifyManager::alarms()const {
return m_al;
}
void OPimNotifyManager::setAlarms( const Alarms& al) {
m_al = al;
}
void OPimNotifyManager::setReminders( const Reminders& rem) {
m_rem = rem;
}
/* FIXME!!! */
/**
* The idea is to check if the provider for our service
* is online
* if it is we will use QCOP
* if not the Factory to get the backend...
* Qtopia1.6 services would be kewl to have here....
*/
void OPimNotifyManager::registerNotify( const OPimNotify& ) {
}
/* FIXME!!! */
/**
* same as above...
* Also implement Url model
* have a MainWindow....
*/
void OPimNotifyManager::deregister( const OPimNotify& ) {
}
+bool OPimNotifyManager::isEmpty()const {
+ return ( m_rem.isEmpty() && m_al.isEmpty() );
+}
diff --git a/libopie2/opiepim/core/opimnotifymanager.h b/libopie2/opiepim/core/opimnotifymanager.h
index 0eebc9b..0ac30a1 100644
--- a/libopie2/opiepim/core/opimnotifymanager.h
+++ b/libopie2/opiepim/core/opimnotifymanager.h
@@ -1,51 +1,54 @@
#ifndef OPIE_PIM_NOTIFY_MANAGER_H
#define OPIE_PIM_NOTIFY_MANAGER_H
#include <qvaluelist.h>
#include <opie/opimnotify.h>
/**
* The notify manager keeps track of the Notifiers....
*/
class OPimNotifyManager {
public:
typedef QValueList<OPimReminder> Reminders;
typedef QValueList<OPimAlarm> Alarms;
OPimNotifyManager( const Reminders& rems = Reminders(), const Alarms& alarms = Alarms() );
~OPimNotifyManager();
/* we will cast it for you ;) */
void add( const OPimNotify& );
void remove( const OPimNotify& );
/* replaces all with this one! */
void replace( const OPimNotify& );
Reminders reminders()const;
Alarms alarms()const;
void setAlarms( const Alarms& );
void setReminders( const Reminders& );
/* register is a Ansi C keyword... */
/**
* This function will register the Notify to the Alarm Server
* or datebook depending on the type of the notify
*/
void registerNotify( const OPimNotify& );
/**
* this will do the opposite..
*/
void deregister( const OPimNotify& );
+
+ bool isEmpty()const;
+
private:
Reminders m_rem;
Alarms m_al;
class Private;
Private *d;
};
#endif
diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/orecur.cpp
index e3b45b4..eae1fdc 100644
--- a/libopie2/opiepim/core/orecur.cpp
+++ b/libopie2/opiepim/core/orecur.cpp
@@ -411,100 +411,100 @@ void ORecur::setPosition( int pos ) {
void ORecur::setDays( char c ) {
checkOrModify();
data->days = c;
}
void ORecur::setEndDate( const QDate& dt) {
checkOrModify();
data->end = dt;
}
void ORecur::setCreatedDateTime( const QDateTime& t) {
checkOrModify();
data->create = t;
}
void ORecur::setHasEndDate( bool b) {
checkOrModify();
data->hasEnd = b;
}
void ORecur::setRepitition( int rep ) {
checkOrModify();
data->rep = rep;
}
void ORecur::setService( const QString& app ) {
checkOrModify();
data->app = app;
}
void ORecur::setStart( const QDate& dt ) {
checkOrModify();
data->start = dt;
}
void ORecur::checkOrModify() {
if ( data->count != 1 ) {
data->deref();
Data* d2 = new Data;
d2->days = data->days;
d2->type = data->type;
d2->freq = data->freq;
d2->pos = data->pos;
d2->hasEnd = data->hasEnd;
d2->end = data->end;
d2->create = data->create;
d2->rep = data->rep;
d2->app = data->app;
d2->list = data->list;
d2->start = data->start;
data = d2;
}
}
QString ORecur::toString()const {
QString buf;
buf += " rtype=\"";
switch ( data->type ) {
case ORecur::Daily:
buf += "Daily";
break;
case ORecur::Weekly:
buf += "Weekly";
break;
case ORecur::MonthlyDay:
buf += "MonthlyDay";
break;
case ORecur::MonthlyDate:
buf += "MonthlyDate";
break;
case ORecur::Yearly:
buf += "Yearly";
break;
default:
buf += "NoRepeat";
break;
}
buf += "\"";
if (data->days > 0 )
buf += " rweekdays=\"" + QString::number( static_cast<int>( data->days ) ) + "\"";
if ( data->pos != 0 )
buf += " rposition=\"" + QString::number(data->pos ) + "\"";
buf += " rfreq=\"" + QString::number( data->freq ) + "\"";
buf += " rhasenddate=\"" + QString::number( static_cast<int>( data->hasEnd ) ) + "\"";
if ( data->hasEnd )
buf += " enddt=\""
+ QString::number( OTimeZone::utc().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) )
+ "\"";
buf += " created=\"" + QString::number( OTimeZone::utc().fromUTCDateTime( data->create ) ) + "\"";
if ( data->list.isEmpty() ) return buf;
// save exceptions list here!!
ExceptionList::ConstIterator it;
ExceptionList list = data->list;
buf += " exceptions=\"";
QDate date;
for ( it = list.begin(); it != list.end(); ++it ) {
date = (*it);
if ( it != list.begin() ) buf += " ";
buf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() );
}
- buf += "\"";
+ buf += "\" ";
return buf;
}