summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp21
-rw-r--r--libkcal/phoneformat.cpp60
-rw-r--r--libkcal/phoneformat.h2
-rw-r--r--libkcal/vcalformat.cpp19
-rw-r--r--libkcal/vcalformat.h2
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
@@ -1066,15 +1066,34 @@ void MainWindow::features()
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()
{
displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 11c68c5..e6d4879 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -867,65 +867,23 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
error=GSM_TerminateConnection(&s);
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;
if ( inc->type() == "Event")
csum = PhoneFormat::getCsumEvent( (Event*) inc );
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 7b7dd04..33b2091 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -22,12 +22,13 @@
#define PHONEFORMAT_H
#include <qstring.h>
#include "scheduler.h"
+#include "vcalformat.h"
#include "calformat.h"
extern "C" {
#include "../gammu/emb/common/gammu.h"
}
namespace KCal {
@@ -47,12 +48,13 @@ class PhoneFormat : public QObject {
bool fromString( Calendar *, const QString & );
QString toString( Calendar * );
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* );
QString getTodoString( Todo* );
QString dtToGSM( const QDateTime& dt, bool useTZ = true );
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index 72a781a..1167e58 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -162,12 +162,31 @@ bool VCalFormat::fromString( Calendar *calendar, const QString &text )
deleteVObject( vcal );
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()
VObject *vcal = newVObject(VCCalProp);
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h
index d4cecbc..8490125 100644
--- a/libkcal/vcalformat.h
+++ b/libkcal/vcalformat.h
@@ -59,12 +59,14 @@ class VCalFormat : public CalFormat {
*/
bool fromString( Calendar *, const QString & );
/**
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);
/** translates a VObject into a Event and returns a pointer to it. */
Event *VEventToEvent(VObject *vevent);