summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-09 18:02:44 (UTC)
committer zautrix <zautrix>2004-08-09 18:02:44 (UTC)
commit4f05a9fcbb9e54184aef93883886aaf865104463 (patch) (side-by-side diff)
treef5e94f7694b74dca3b11e1e74a94058a4526dafe
parente1909ade2188e53feee65089d5f2882563876c58 (diff)
downloadkdepimpi-4f05a9fcbb9e54184aef93883886aaf865104463.zip
kdepimpi-4f05a9fcbb9e54184aef93883886aaf865104463.tar.gz
kdepimpi-4f05a9fcbb9e54184aef93883886aaf865104463.tar.bz2
more syncing
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
@@ -1064,19 +1064,38 @@ void MainWindow::features()
displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
}
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") );
}
void MainWindow::whatsNew()
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 11c68c5..e6d4879 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -865,69 +865,27 @@ 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 );
else
csum = PhoneFormat::getCsumTodo( (Todo*) inc );
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 7b7dd04..33b2091 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -20,16 +20,17 @@
*/
#ifndef PHONEFORMAT_H
#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 {
/**
This class implements the calendar format used by Phone.
@@ -45,16 +46,17 @@ class PhoneFormat : public QObject {
bool load( Calendar * ,Calendar * );
bool save( Calendar * );
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 );
QString mProfileName, mDevice, mConnection, mModel;
void afterSave( Incidence* );
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index 72a781a..1167e58 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -160,16 +160,35 @@ bool VCalFormat::fromString( Calendar *calendar, const QString &text )
return false;
}
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);
addPropValue( vcal, VCProdIdProp, CalFormat::productId() );
QString tmpStr = mCalendar->getTimeZoneStr();
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h
index d4cecbc..8490125 100644
--- a/libkcal/vcalformat.h
+++ b/libkcal/vcalformat.h
@@ -57,16 +57,18 @@ class VCalFormat : public CalFormat {
/**
Parse string and populate calendar with that information.
*/
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);
/** translate a Event into a VTodo-type VObject and return pointer */
VObject *eventToVTodo(const Todo *anEvent);