-rw-r--r-- | korganizer/mainwindow.cpp | 21 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 60 | ||||
-rw-r--r-- | libkcal/phoneformat.h | 2 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 19 | ||||
-rw-r--r-- | libkcal/vcalformat.h | 2 |
5 files changed, 52 insertions, 52 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index cce182a..6c0aa9b 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -1068,11 +1068,30 @@ void MainWindow::usertrans() { displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); } +#if 0 +#include <libkcal/vcalformat.h> +#include <libkcal/event.h> +#include <libkcal/todo.h> +#include <libkcal/incidence.h> +#endif void MainWindow::synchowto() { - +#if 0 + QPtrList<Incidence> er = mCalendar->rawIncidences(); + Incidence* inR = er.first(); + VCalFormat vf; + QString strout; + while ( inR ) { + if ( inR->type() == "Todo" ) + strout = vf.todoToString( (Todo *) inR ); + if ( inR->type() == "Event" ) + strout = vf.eventToString( (Event *) inR ); + qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); + inR = er.next(); + } +#endif displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); } void MainWindow::faq() { diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 11c68c5..e6d4879 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp @@ -869,61 +869,19 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) return true; } void PhoneFormat::event2GSM( Event* ev, GSM_CalendarEntry*Note ) { - + QString eText = vfconverter.eventToString( ev ); + int pos = 0; + GSM_ToDoEntry dummy; + GSM_DecodeVCALENDAR_VTODO( (unsigned char*)eText.latin1(), &pos, Note , &dummy, Nokia_VCalendar, Nokia_VToDo ); } -void PhoneFormat::todo2GSM( Todo* todo, GSM_ToDoEntry *gsm ) +void PhoneFormat::todo2GSM( Todo* todo, GSM_ToDoEntry *gsmTodo ) { -#if 0 - QStringList list; - list.append( QString::number( todo->zaurusId() ) ); - list.append( todo->categories().join(",") ); - - if ( todo->hasStartDate() ) { - list.append( dtToString( todo->dtStart()) ); - } else - list.append( QString() ); - - if ( todo->hasDueDate() ) { - QTime tim; - if ( todo->doesFloat()) { - list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; - } else { - list.append( dtToString(todo->dtDue() ) ); - } - } else - list.append( QString() ); - - if ( todo->isCompleted() ) { - list.append( dtToString( todo->completed()) ); - list.append( "0" ); // yes 0 == completed - } else { - list.append( dtToString( todo->completed()) ); - list.append( "1" ); - } - list.append( QString::number( todo->priority() )); - if( ! todo->summary().isEmpty() ) - list.append( todo->summary() ); - else - list.append( "" ); - if (! todo->description().isEmpty() ) - list.append( todo->description() ); - else - list.append( "" ); - for(QStringList::Iterator it=list.begin(); - it!=list.end(); ++it){ - QString& s = (*it); - s.replace(QRegExp("\""), "\"\""); - if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ - s.prepend('\"'); - s.append('\"'); - } else if(s.isEmpty() && !s.isNull()){ - s = "\"\""; - } - } - return list.join(","); -#endif + QString tText = vfconverter.todoToString( todo ); + int pos = 0; + GSM_CalendarEntry dummy; + GSM_DecodeVCALENDAR_VTODO( (unsigned char*)tText.latin1(), &pos, &dummy, gsmTodo, Nokia_VCalendar, Nokia_VToDo ); } void PhoneFormat::afterSave( Incidence* inc) { uint csum; diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h index 7b7dd04..33b2091 100644 --- a/libkcal/phoneformat.h +++ b/libkcal/phoneformat.h @@ -24,8 +24,9 @@ #include <qstring.h> #include "scheduler.h" +#include "vcalformat.h" #include "calformat.h" extern "C" { #include "../gammu/emb/common/gammu.h" } @@ -49,8 +50,9 @@ class PhoneFormat : public QObject { static ulong getCsum( const QStringList & ); static ulong getCsumTodo( Todo* to ); static ulong getCsumEvent( Event* ev ); private: + VCalFormat vfconverter; void event2GSM( Event* ev, GSM_CalendarEntry*Note ); void todo2GSM( Todo* ev, GSM_ToDoEntry *ToDo ); int initDevice(GSM_StateMachine *s); QString getEventString( Event* ); diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 72a781a..1167e58 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp @@ -164,8 +164,27 @@ bool VCalFormat::fromString( Calendar *calendar, const QString &text ) return true; } +QString VCalFormat::eventToString( Event * event) +{ + if ( !event ) return QString::null; + VObject *vevent = eventToVEvent( event ); + char *buf = writeMemVObject( 0, 0, vevent ); + QString result( buf ); + cleanVObject( vevent ); + return result; +} +QString VCalFormat::todoToString( Todo * todo ) +{ + if ( !todo ) return QString::null; + VObject *vevent = eventToVTodo( todo ); + char *buf = writeMemVObject( 0, 0, vevent ); + QString result( buf ); + cleanVObject( vevent ); + return result; +} + QString VCalFormat::toString( Calendar *calendar ) { // TODO: Factor out VCalFormat::asString() diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h index d4cecbc..8490125 100644 --- a/libkcal/vcalformat.h +++ b/libkcal/vcalformat.h @@ -61,8 +61,10 @@ class VCalFormat : public CalFormat { /** Return calendar information as string. */ QString toString( Calendar * ); + QString eventToString( Event * ); + QString todoToString( Todo * ); protected: /** translates a VObject of the TODO type into a Event */ Todo *VTodoToEvent(VObject *vtodo); |