author | zautrix <zautrix> | 2004-08-09 18:02:44 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-09 18:02:44 (UTC) |
commit | 4f05a9fcbb9e54184aef93883886aaf865104463 (patch) (side-by-side diff) | |
tree | f5e94f7694b74dca3b11e1e74a94058a4526dafe | |
parent | e1909ade2188e53feee65089d5f2882563876c58 (diff) | |
download | kdepimpi-4f05a9fcbb9e54184aef93883886aaf865104463.zip kdepimpi-4f05a9fcbb9e54184aef93883886aaf865104463.tar.gz kdepimpi-4f05a9fcbb9e54184aef93883886aaf865104463.tar.bz2 |
more syncing
-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 @@ -1060,27 +1060,46 @@ void MainWindow::displayFile( QString fn, QString cap ) } 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() { displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); } diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 11c68c5..e6d4879 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp @@ -861,77 +861,35 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) start = false; qDebug("ReadTodo %d ", ++ccc); handler.readTodo( existingCal, &ToDo, &s); } 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 ); inc->setCsum( mProfileName, QString::number( csum )); inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); } diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h index 7b7dd04..33b2091 100644 --- a/libkcal/phoneformat.h +++ b/libkcal/phoneformat.h @@ -16,24 +16,25 @@ You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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. */ class Event; class Todo; class PhoneFormat : public QObject { @@ -41,24 +42,25 @@ class PhoneFormat : public QObject { /** Create new iCalendar format. */ PhoneFormat(QString profileName, QString device,QString connection, QString model); virtual ~PhoneFormat(); 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 @@ -156,24 +156,43 @@ bool VCalFormat::fromString( Calendar *calendar, const QString &text ) calendar->addEvent( event ); } else { kdDebug(5800) << "VCalFormat::fromString(): Unknown object type." << endl; deleteVObject( vcal ); 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(); addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); // TODO: Use all data. diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h index d4cecbc..8490125 100644 --- a/libkcal/vcalformat.h +++ b/libkcal/vcalformat.h @@ -53,24 +53,26 @@ class VCalFormat : public CalFormat { * @param fileName the name of the file */ bool save(Calendar *,const QString &fileName); /** 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); /** translate a Event into a VObject and returns a pointer to it. */ VObject* eventToVEvent(const Event *anEvent); /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ |