summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp42
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/mainwindow.cpp8
-rw-r--r--libkcal/libkcalE.pro2
-rw-r--r--libkcal/phoneformat.cpp1359
-rw-r--r--libkcal/phoneformat.h65
6 files changed, 1467 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 689618d..a7f7010 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,277 +1,278 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66 66
67#include <libkcal/vcaldrag.h> 67#include <libkcal/vcaldrag.h>
68#include <libkcal/icaldrag.h> 68#include <libkcal/icaldrag.h>
69#include <libkcal/icalformat.h> 69#include <libkcal/icalformat.h>
70#include <libkcal/vcalformat.h> 70#include <libkcal/vcalformat.h>
71#include <libkcal/scheduler.h> 71#include <libkcal/scheduler.h>
72#include <libkcal/calendarlocal.h> 72#include <libkcal/calendarlocal.h>
73#include <libkcal/journal.h> 73#include <libkcal/journal.h>
74#include <libkcal/calfilter.h> 74#include <libkcal/calfilter.h>
75#include <libkcal/attendee.h> 75#include <libkcal/attendee.h>
76#include <libkcal/dndfactory.h> 76#include <libkcal/dndfactory.h>
77#include <libkcal/freebusy.h> 77#include <libkcal/freebusy.h>
78#include <libkcal/filestorage.h> 78#include <libkcal/filestorage.h>
79#include <libkcal/calendarresources.h> 79#include <libkcal/calendarresources.h>
80#include <libkcal/qtopiaformat.h> 80#include <libkcal/qtopiaformat.h>
81#include "../kalarmd/alarmdialog.h" 81#include "../kalarmd/alarmdialog.h"
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <libkcal/sharpformat.h> 84#include <libkcal/sharpformat.h>
85#endif 85#endif
86#include <libkcal/phoneformat.h>
86#ifndef KORG_NOMAIL 87#ifndef KORG_NOMAIL
87#include "komailclient.h" 88#include "komailclient.h"
88#endif 89#endif
89#ifndef KORG_NOPRINTER 90#ifndef KORG_NOPRINTER
90#include "calprinter.h" 91#include "calprinter.h"
91#endif 92#endif
92#ifndef KORG_NOPLUGINS 93#ifndef KORG_NOPLUGINS
93#include "kocore.h" 94#include "kocore.h"
94#endif 95#endif
95#include "koeventeditor.h" 96#include "koeventeditor.h"
96#include "kotodoeditor.h" 97#include "kotodoeditor.h"
97#include "koprefs.h" 98#include "koprefs.h"
98#include "koeventviewerdialog.h" 99#include "koeventviewerdialog.h"
99#include "publishdialog.h" 100#include "publishdialog.h"
100#include "kofilterview.h" 101#include "kofilterview.h"
101#include "koglobals.h" 102#include "koglobals.h"
102#include "koviewmanager.h" 103#include "koviewmanager.h"
103#include "koagendaview.h" 104#include "koagendaview.h"
104#include "kodialogmanager.h" 105#include "kodialogmanager.h"
105#include "outgoingdialog.h" 106#include "outgoingdialog.h"
106#include "incomingdialog.h" 107#include "incomingdialog.h"
107#include "statusdialog.h" 108#include "statusdialog.h"
108#include "kdatenavigator.h" 109#include "kdatenavigator.h"
109#include "kotodoview.h" 110#include "kotodoview.h"
110#include "datenavigator.h" 111#include "datenavigator.h"
111#include "resourceview.h" 112#include "resourceview.h"
112#include "navigatorbar.h" 113#include "navigatorbar.h"
113#include "searchdialog.h" 114#include "searchdialog.h"
114#include "mainwindow.h" 115#include "mainwindow.h"
115 116
116#include "calendarview.h" 117#include "calendarview.h"
117#ifndef DESKTOP_VERSION 118#ifndef DESKTOP_VERSION
118#include <qtopia/alarmserver.h> 119#include <qtopia/alarmserver.h>
119#endif 120#endif
120#ifndef _WIN32_ 121#ifndef _WIN32_
121#include <stdlib.h> 122#include <stdlib.h>
122#include <stdio.h> 123#include <stdio.h>
123#include <unistd.h> 124#include <unistd.h>
124#else 125#else
125#include <qprocess.h> 126#include <qprocess.h>
126#endif 127#endif
127using namespace KOrg; 128using namespace KOrg;
128using namespace KCal; 129using namespace KCal;
129extern int globalFlagBlockAgenda; 130extern int globalFlagBlockAgenda;
130extern int globalFlagBlockStartup; 131extern int globalFlagBlockStartup;
131 132
132 133
133 134
134class KOBeamPrefs : public QDialog 135class KOBeamPrefs : public QDialog
135{ 136{
136 public: 137 public:
137 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 138 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
138 QDialog( parent, name, true ) 139 QDialog( parent, name, true )
139 { 140 {
140 setCaption( i18n("Beam Options") ); 141 setCaption( i18n("Beam Options") );
141 QVBoxLayout* lay = new QVBoxLayout( this ); 142 QVBoxLayout* lay = new QVBoxLayout( this );
142 lay->setSpacing( 3 ); 143 lay->setSpacing( 3 );
143 lay->setMargin( 3 ); 144 lay->setMargin( 3 );
144 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 145 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
145 lay->addWidget( format ); 146 lay->addWidget( format );
146 format->setExclusive ( true ) ; 147 format->setExclusive ( true ) ;
147 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 148 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
148 lay->addWidget( time ); time->setExclusive ( true ) ; 149 lay->addWidget( time ); time->setExclusive ( true ) ;
149 vcal = new QRadioButton(" vCalendar ", format ); 150 vcal = new QRadioButton(" vCalendar ", format );
150 ical = new QRadioButton(" iCalendar ", format ); 151 ical = new QRadioButton(" iCalendar ", format );
151 vcal->setChecked( true ); 152 vcal->setChecked( true );
152 tz = new QRadioButton(i18n(" With timezone "), time ); 153 tz = new QRadioButton(i18n(" With timezone "), time );
153 local = new QRadioButton(i18n(" Local time "), time ); 154 local = new QRadioButton(i18n(" Local time "), time );
154 tz->setChecked( true ); 155 tz->setChecked( true );
155 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 156 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
156 lay->addWidget( ok ); 157 lay->addWidget( ok );
157 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 158 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
158 lay->addWidget( cancel ); 159 lay->addWidget( cancel );
159 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 160 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
160 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 161 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
161 resize( 200, 200 ); 162 resize( 200, 200 );
162 } 163 }
163 164
164 bool beamVcal() { return vcal->isChecked(); } 165 bool beamVcal() { return vcal->isChecked(); }
165 bool beamLocal() { return local->isChecked(); } 166 bool beamLocal() { return local->isChecked(); }
166private: 167private:
167 QRadioButton* vcal, *ical, *local, *tz; 168 QRadioButton* vcal, *ical, *local, *tz;
168}; 169};
169class KOCatPrefs : public QDialog 170class KOCatPrefs : public QDialog
170{ 171{
171 public: 172 public:
172 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 173 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
173 QDialog( parent, name, true ) 174 QDialog( parent, name, true )
174 { 175 {
175 setCaption( i18n("Manage new Categories") ); 176 setCaption( i18n("Manage new Categories") );
176 QVBoxLayout* lay = new QVBoxLayout( this ); 177 QVBoxLayout* lay = new QVBoxLayout( this );
177 lay->setSpacing( 3 ); 178 lay->setSpacing( 3 );
178 lay->setMargin( 3 ); 179 lay->setMargin( 3 );
179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
180 lay->addWidget( lab ); 181 lay->addWidget( lab );
181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
182 lay->addWidget( format ); 183 lay->addWidget( format );
183 format->setExclusive ( true ) ; 184 format->setExclusive ( true ) ;
184 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 185 addCatBut = new QRadioButton(i18n("Add to category list"), format );
185 new QRadioButton(i18n("Remove from Events/Todos"), format ); 186 new QRadioButton(i18n("Remove from Events/Todos"), format );
186 addCatBut->setChecked( true ); 187 addCatBut->setChecked( true );
187 QPushButton * ok = new QPushButton( i18n("OK"), this ); 188 QPushButton * ok = new QPushButton( i18n("OK"), this );
188 lay->addWidget( ok ); 189 lay->addWidget( ok );
189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
190 lay->addWidget( cancel ); 191 lay->addWidget( cancel );
191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
193 resize( 200, 200 ); 194 resize( 200, 200 );
194 } 195 }
195 196
196 bool addCat() { return addCatBut->isChecked(); } 197 bool addCat() { return addCatBut->isChecked(); }
197private: 198private:
198 QRadioButton* addCatBut; 199 QRadioButton* addCatBut;
199}; 200};
200 201
201 202
202 203
203CalendarView::CalendarView( CalendarResources *calendar, 204CalendarView::CalendarView( CalendarResources *calendar,
204 QWidget *parent, const char *name ) 205 QWidget *parent, const char *name )
205 : CalendarViewBase( parent, name ), 206 : CalendarViewBase( parent, name ),
206 mCalendar( calendar ), 207 mCalendar( calendar ),
207 mResourceManager( calendar->resourceManager() ) 208 mResourceManager( calendar->resourceManager() )
208{ 209{
209 210
210 mEventEditor = 0; 211 mEventEditor = 0;
211 mTodoEditor = 0; 212 mTodoEditor = 0;
212 213
213 init(); 214 init();
214} 215}
215 216
216CalendarView::CalendarView( Calendar *calendar, 217CalendarView::CalendarView( Calendar *calendar,
217 QWidget *parent, const char *name ) 218 QWidget *parent, const char *name )
218 : CalendarViewBase( parent, name ), 219 : CalendarViewBase( parent, name ),
219 mCalendar( calendar ), 220 mCalendar( calendar ),
220 mResourceManager( 0 ) 221 mResourceManager( 0 )
221{ 222{
222 223
223 mEventEditor = 0; 224 mEventEditor = 0;
224 mTodoEditor = 0; 225 mTodoEditor = 0;
225 init();} 226 init();}
226 227
227void CalendarView::init() 228void CalendarView::init()
228{ 229{
229 beamDialog = new KOBeamPrefs(); 230 beamDialog = new KOBeamPrefs();
230 mDatePickerMode = 0; 231 mDatePickerMode = 0;
231 mCurrentSyncDevice = ""; 232 mCurrentSyncDevice = "";
232 writeLocale(); 233 writeLocale();
233 mViewManager = new KOViewManager( this ); 234 mViewManager = new KOViewManager( this );
234 mDialogManager = new KODialogManager( this ); 235 mDialogManager = new KODialogManager( this );
235 mEventViewerDialog = 0; 236 mEventViewerDialog = 0;
236 mModified = false; 237 mModified = false;
237 mReadOnly = false; 238 mReadOnly = false;
238 mSelectedIncidence = 0; 239 mSelectedIncidence = 0;
239 mCalPrinter = 0; 240 mCalPrinter = 0;
240 mFilters.setAutoDelete(true); 241 mFilters.setAutoDelete(true);
241 242
242 mCalendar->registerObserver( this ); 243 mCalendar->registerObserver( this );
243 // TODO: Make sure that view is updated, when calendar is changed. 244 // TODO: Make sure that view is updated, when calendar is changed.
244 245
245 mStorage = new FileStorage( mCalendar ); 246 mStorage = new FileStorage( mCalendar );
246 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 247 mNavigator = new DateNavigator( this, "datevav", mViewManager );
247 248
248 QBoxLayout *topLayout = (QBoxLayout*)layout(); 249 QBoxLayout *topLayout = (QBoxLayout*)layout();
249#ifndef KORG_NOSPLITTER 250#ifndef KORG_NOSPLITTER
250 // create the main layout frames. 251 // create the main layout frames.
251 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 252 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
252 topLayout->addWidget(mPanner); 253 topLayout->addWidget(mPanner);
253 254
254 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 255 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
255 "CalendarView::LeftFrame"); 256 "CalendarView::LeftFrame");
256 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 257 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
257 258
258 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 259 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
259 "CalendarView::DateNavigator", QDate::currentDate() ); 260 "CalendarView::DateNavigator", QDate::currentDate() );
260 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 261 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
261 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 262 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
262 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 263 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
263 264
264#ifdef KORG_NORESOURCEVIEW 265#ifdef KORG_NORESOURCEVIEW
265 mResourceView = 0; 266 mResourceView = 0;
266#else 267#else
267 if ( mResourceManager ) { 268 if ( mResourceManager ) {
268 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 269 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
269 mResourceView->updateView(); 270 mResourceView->updateView();
270 connect( mResourceView, SIGNAL( resourcesChanged() ), 271 connect( mResourceView, SIGNAL( resourcesChanged() ),
271 SLOT( updateView() ) ); 272 SLOT( updateView() ) );
272 } else { 273 } else {
273 mResourceView = 0; 274 mResourceView = 0;
274 } 275 }
275#endif 276#endif
276 QWidget *rightBox = new QWidget( mPanner ); 277 QWidget *rightBox = new QWidget( mPanner );
277 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 278 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
@@ -986,448 +987,471 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
986 int w = 300; 987 int w = 300;
987 if ( QApplication::desktop()->width() < 320 ) 988 if ( QApplication::desktop()->width() < 320 )
988 w = 220; 989 w = 220;
989 int h = bar.sizeHint().height() ; 990 int h = bar.sizeHint().height() ;
990 int dw = QApplication::desktop()->width(); 991 int dw = QApplication::desktop()->width();
991 int dh = QApplication::desktop()->height(); 992 int dh = QApplication::desktop()->height();
992 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 993 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
993 bar.show(); 994 bar.show();
994 int modulo = (er.count()/10)+1; 995 int modulo = (er.count()/10)+1;
995 int incCounter = 0; 996 int incCounter = 0;
996 while ( inR ) { 997 while ( inR ) {
997 if ( ! bar.isVisible() ) 998 if ( ! bar.isVisible() )
998 return false; 999 return false;
999 if ( incCounter % modulo == 0 ) 1000 if ( incCounter % modulo == 0 )
1000 bar.setProgress( incCounter ); 1001 bar.setProgress( incCounter );
1001 ++incCounter; 1002 ++incCounter;
1002 uid = inR->uid(); 1003 uid = inR->uid();
1003 bool skipIncidence = false; 1004 bool skipIncidence = false;
1004 if ( uid.left(15) == QString("last-syncEvent-") ) 1005 if ( uid.left(15) == QString("last-syncEvent-") )
1005 skipIncidence = true; 1006 skipIncidence = true;
1006 1007
1007 qApp->processEvents(); 1008 qApp->processEvents();
1008 if ( !skipIncidence ) { 1009 if ( !skipIncidence ) {
1009 inL = local->incidence( uid ); 1010 inL = local->incidence( uid );
1010 if ( inL ) { // maybe conflict - same uid in both calendars 1011 if ( inL ) { // maybe conflict - same uid in both calendars
1011 int maxrev = inL->revision(); 1012 int maxrev = inL->revision();
1012 if ( maxrev < inR->revision() ) 1013 if ( maxrev < inR->revision() )
1013 maxrev = inR->revision(); 1014 maxrev = inR->revision();
1014 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1015 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1015 //qDebug("take %d %s ", take, inL->summary().latin1()); 1016 //qDebug("take %d %s ", take, inL->summary().latin1());
1016 if ( take == 3 ) 1017 if ( take == 3 )
1017 return false; 1018 return false;
1018 if ( take == 1 ) {// take local 1019 if ( take == 1 ) {// take local
1019 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1020 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1020 remote->deleteIncidence( inR ); 1021 remote->deleteIncidence( inR );
1021 if ( inL->revision() < maxrev ) 1022 if ( inL->revision() < maxrev )
1022 inL->setRevision( maxrev ); 1023 inL->setRevision( maxrev );
1023 remote->addIncidence( inL->clone() ); 1024 remote->addIncidence( inL->clone() );
1024 ++changedRemote; 1025 ++changedRemote;
1025 } else { 1026 } else {
1026 if ( inR->revision() < maxrev ) 1027 if ( inR->revision() < maxrev )
1027 inR->setRevision( maxrev ); 1028 inR->setRevision( maxrev );
1028 local->deleteIncidence( inL ); 1029 local->deleteIncidence( inL );
1029 local->addIncidence( inR->clone() ); 1030 local->addIncidence( inR->clone() );
1030 ++changedLocal; 1031 ++changedLocal;
1031 } 1032 }
1032 } 1033 }
1033 } else { // no conflict 1034 } else { // no conflict
1034 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1035 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1035 QString des = eventLSync->description(); 1036 QString des = eventLSync->description();
1036 QString pref = "e"; 1037 QString pref = "e";
1037 if ( inR->type() == "Todo" ) 1038 if ( inR->type() == "Todo" )
1038 pref = "t"; 1039 pref = "t";
1039 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1040 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1040 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1041 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1041 //remote->deleteIncidence( inR ); 1042 //remote->deleteIncidence( inR );
1042 ++deletedEventR; 1043 ++deletedEventR;
1043 } else { 1044 } else {
1044 inR->setLastModified( modifiedCalendar ); 1045 inR->setLastModified( modifiedCalendar );
1045 local->addIncidence( inR->clone() ); 1046 local->addIncidence( inR->clone() );
1046 ++addedEvent; 1047 ++addedEvent;
1047 } 1048 }
1048 } else { 1049 } else {
1049 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1050 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1050 inR->setLastModified( modifiedCalendar ); 1051 inR->setLastModified( modifiedCalendar );
1051 local->addIncidence( inR->clone() ); 1052 local->addIncidence( inR->clone() );
1052 ++addedEvent; 1053 ++addedEvent;
1053 } else { 1054 } else {
1054 checkExternSyncEvent(eventRSyncSharp, inR); 1055 checkExternSyncEvent(eventRSyncSharp, inR);
1055 remote->deleteIncidence( inR ); 1056 remote->deleteIncidence( inR );
1056 ++deletedEventR; 1057 ++deletedEventR;
1057 } 1058 }
1058 } 1059 }
1059 } 1060 }
1060 } 1061 }
1061 inR = er.next(); 1062 inR = er.next();
1062 } 1063 }
1063 QPtrList<Incidence> el = local->rawIncidences(); 1064 QPtrList<Incidence> el = local->rawIncidences();
1064 inL = el.first(); 1065 inL = el.first();
1065 modulo = (el.count()/10)+1; 1066 modulo = (el.count()/10)+1;
1066 bar.setCaption (i18n("Add / remove events") ); 1067 bar.setCaption (i18n("Add / remove events") );
1067 bar.setTotalSteps ( el.count() ) ; 1068 bar.setTotalSteps ( el.count() ) ;
1068 bar.show(); 1069 bar.show();
1069 incCounter = 0; 1070 incCounter = 0;
1070 1071
1071 while ( inL ) { 1072 while ( inL ) {
1072 1073
1073 qApp->processEvents(); 1074 qApp->processEvents();
1074 if ( ! bar.isVisible() ) 1075 if ( ! bar.isVisible() )
1075 return false; 1076 return false;
1076 if ( incCounter % modulo == 0 ) 1077 if ( incCounter % modulo == 0 )
1077 bar.setProgress( incCounter ); 1078 bar.setProgress( incCounter );
1078 ++incCounter; 1079 ++incCounter;
1079 uid = inL->uid(); 1080 uid = inL->uid();
1080 bool skipIncidence = false; 1081 bool skipIncidence = false;
1081 if ( uid.left(15) == QString("last-syncEvent-") ) 1082 if ( uid.left(15) == QString("last-syncEvent-") )
1082 skipIncidence = true; 1083 skipIncidence = true;
1083 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1084 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1084 skipIncidence = true; 1085 skipIncidence = true;
1085 if ( !skipIncidence ) { 1086 if ( !skipIncidence ) {
1086 inR = remote->incidence( uid ); 1087 inR = remote->incidence( uid );
1087 if ( ! inR ) { 1088 if ( ! inR ) {
1088 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1089 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1089 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1090 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1090 local->deleteIncidence( inL ); 1091 local->deleteIncidence( inL );
1091 ++deletedEventL; 1092 ++deletedEventL;
1092 } else { 1093 } else {
1093 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1094 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1094 inL->removeID(mCurrentSyncDevice ); 1095 inL->removeID(mCurrentSyncDevice );
1095 ++addedEventR; 1096 ++addedEventR;
1096 inL->setLastModified( modifiedCalendar ); 1097 inL->setLastModified( modifiedCalendar );
1097 remote->addIncidence( inL->clone() ); 1098 remote->addIncidence( inL->clone() );
1098 } 1099 }
1099 } 1100 }
1100 } else { 1101 } else {
1101 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1102 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1102 checkExternSyncEvent(eventLSyncSharp, inL); 1103 checkExternSyncEvent(eventLSyncSharp, inL);
1103 local->deleteIncidence( inL ); 1104 local->deleteIncidence( inL );
1104 ++deletedEventL; 1105 ++deletedEventL;
1105 } else { 1106 } else {
1106 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1107 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1107 ++addedEventR; 1108 ++addedEventR;
1108 inL->setLastModified( modifiedCalendar ); 1109 inL->setLastModified( modifiedCalendar );
1109 remote->addIncidence( inL->clone() ); 1110 remote->addIncidence( inL->clone() );
1110 } 1111 }
1111 } 1112 }
1112 } 1113 }
1113 } 1114 }
1114 } 1115 }
1115 inL = el.next(); 1116 inL = el.next();
1116 } 1117 }
1117 1118
1118 bar.hide(); 1119 bar.hide();
1119 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1120 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1120 eventLSync->setReadOnly( false ); 1121 eventLSync->setReadOnly( false );
1121 eventLSync->setDtStart( mLastCalendarSync ); 1122 eventLSync->setDtStart( mLastCalendarSync );
1122 eventRSync->setDtStart( mLastCalendarSync ); 1123 eventRSync->setDtStart( mLastCalendarSync );
1123 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1124 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1124 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1125 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1125 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1126 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1126 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1127 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1127 eventLSync->setReadOnly( true ); 1128 eventLSync->setReadOnly( true );
1128 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1129 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1129 remote->addEvent( eventRSync ); 1130 remote->addEvent( eventRSync );
1130 QString mes; 1131 QString mes;
1131 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1132 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1132 if ( KOPrefs::instance()->mShowSyncSummary ) { 1133 if ( KOPrefs::instance()->mShowSyncSummary ) {
1133 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1134 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1134 } 1135 }
1135 qDebug( mes ); 1136 qDebug( mes );
1136 mCalendar->checkAlarmForIncidence( 0, true ); 1137 mCalendar->checkAlarmForIncidence( 0, true );
1137 return syncOK; 1138 return syncOK;
1138} 1139}
1139 1140
1140void CalendarView::setSyncDevice( QString s ) 1141void CalendarView::setSyncDevice( QString s )
1141{ 1142{
1142 mCurrentSyncDevice= s; 1143 mCurrentSyncDevice= s;
1143} 1144}
1144void CalendarView::setSyncName( QString s ) 1145void CalendarView::setSyncName( QString s )
1145{ 1146{
1146 mCurrentSyncName= s; 1147 mCurrentSyncName= s;
1147} 1148}
1148bool CalendarView::syncCalendar(QString filename, int mode) 1149bool CalendarView::syncCalendar(QString filename, int mode)
1149{ 1150{
1150 mGlobalSyncMode = SYNC_MODE_NORMAL; 1151 mGlobalSyncMode = SYNC_MODE_NORMAL;
1151 CalendarLocal* calendar = new CalendarLocal(); 1152 CalendarLocal* calendar = new CalendarLocal();
1152 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1153 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1153 FileStorage* storage = new FileStorage( calendar ); 1154 FileStorage* storage = new FileStorage( calendar );
1154 bool syncOK = false; 1155 bool syncOK = false;
1155 storage->setFileName( filename ); 1156 storage->setFileName( filename );
1156 // qDebug("loading ... "); 1157 // qDebug("loading ... ");
1157 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1158 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1158 getEventViewerDialog()->setSyncMode( true ); 1159 getEventViewerDialog()->setSyncMode( true );
1159 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1160 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1160 getEventViewerDialog()->setSyncMode( false ); 1161 getEventViewerDialog()->setSyncMode( false );
1161 if ( syncOK ) { 1162 if ( syncOK ) {
1162 if ( KOPrefs::instance()->mWriteBackFile ) 1163 if ( KOPrefs::instance()->mWriteBackFile )
1163 { 1164 {
1164 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1165 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1165 storage->save(); 1166 storage->save();
1166 } 1167 }
1167 } 1168 }
1168 setModified( true ); 1169 setModified( true );
1169 } 1170 }
1170 delete storage; 1171 delete storage;
1171 delete calendar; 1172 delete calendar;
1172 if ( syncOK ) 1173 if ( syncOK )
1173 updateView(); 1174 updateView();
1174 return syncOK; 1175 return syncOK;
1175} 1176}
1176void CalendarView::syncPhone() 1177void CalendarView::syncPhone()
1177{ 1178{
1178 qDebug("CalendarView::syncPhone() "); 1179 syncExternal( 1 );
1179} 1180}
1180void CalendarView::syncSharp() 1181void CalendarView::syncExternal( int mode )
1181{ 1182{
1182#ifndef DESKTOP_VERSION 1183 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1183 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1184 //mCurrentSyncDevice = "sharp-DTM"; 1184 //mCurrentSyncDevice = "sharp-DTM";
1185 if ( KOPrefs::instance()->mAskForPreferences ) 1185 if ( KOPrefs::instance()->mAskForPreferences )
1186 edit_sync_options(); 1186 edit_sync_options();
1187 qApp->processEvents(); 1187 qApp->processEvents();
1188 CalendarLocal* calendar = new CalendarLocal(); 1188 CalendarLocal* calendar = new CalendarLocal();
1189 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1189 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1190 bool syncOK = false; 1190 bool syncOK = false;
1191 SharpFormat sharpFormat; 1191 boo loadSuccess = false;
1192 if ( sharpFormat.load( calendar, mCalendar ) ) { 1192 PhoneFormat* phoneFormat = 0;
1193#ifndef DESKTOP_VERSION
1194 SharpFormat* sharpFormat = 0;
1195 if ( mode == 0 ) { // sharp
1196 sharpFormat = new SharpFormat () ;
1197 loadSuccess = sharpFormat->load( calendar, mCalendar );
1198
1199 } else
1200#endif
1201 if ( mode == 1 ) { // phone
1202 phoneFormat = new PhoneFormat ();
1203 loadSuccess = phoneFormat->load( calendar, mCalendar );
1204
1205 } else
1206 return;
1207 if ( loadSuccess ) {
1193 getEventViewerDialog()->setSyncMode( true ); 1208 getEventViewerDialog()->setSyncMode( true );
1194 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1209 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1195 getEventViewerDialog()->setSyncMode( false ); 1210 getEventViewerDialog()->setSyncMode( false );
1196 qApp->processEvents(); 1211 qApp->processEvents();
1197 if ( syncOK ) { 1212 if ( syncOK ) {
1198 if ( KOPrefs::instance()->mWriteBackFile ) 1213 if ( KOPrefs::instance()->mWriteBackFile )
1199 { 1214 {
1200 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1215 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1201 Incidence* inc = iL.first(); 1216 Incidence* inc = iL.first();
1202 /* obsolete 1217 /* obsolete
1203 while ( inc ) { 1218 while ( inc ) {
1204 inc->setZaurusStat( inc->revision () ); 1219 inc->setZaurusStat( inc->revision () );
1205 inc = iL.next(); 1220 inc = iL.next();
1206 } 1221 }
1207 */ 1222 */
1208 // pending: clean last sync event description 1223#ifndef DESKTOP_VERSION
1209 sharpFormat.save(calendar); 1224 if ( sharpFormat )
1225 sharpFormat->save(calendar);
1226#endif
1227 if ( phoneFormat )
1228 phoneFormat->save(calendar);
1210 iL = calendar->rawIncidences(); 1229 iL = calendar->rawIncidences();
1211 inc = iL.first(); 1230 inc = iL.first();
1212 Incidence* loc; 1231 Incidence* loc;
1213 while ( inc ) { 1232 while ( inc ) {
1214 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1233 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1215 loc = mCalendar->incidence(inc->uid() ); 1234 loc = mCalendar->incidence(inc->uid() );
1216 if ( loc ) { 1235 if ( loc ) {
1217 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1236 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1218 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1237 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1219 } 1238 }
1220 } 1239 }
1221 inc = iL.next(); 1240 inc = iL.next();
1222 } 1241 }
1223 Incidence* lse = getLastSyncEvent(); 1242 Incidence* lse = getLastSyncEvent();
1224 if ( lse ) { 1243 if ( lse ) {
1225 lse->setReadOnly( false ); 1244 lse->setReadOnly( false );
1226 lse->setDescription( "" ); 1245 lse->setDescription( "" );
1227 lse->setReadOnly( true ); 1246 lse->setReadOnly( true );
1228 } 1247 }
1229 } 1248 }
1230 } 1249 }
1231 setModified( true ); 1250 setModified( true );
1232 } else { 1251 } else {
1233 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1252 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1234 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1253 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1235 question, i18n("Ok")) ; 1254 question, i18n("Ok")) ;
1236 1255
1237 } 1256 }
1238 delete calendar; 1257 delete calendar;
1239 updateView(); 1258 updateView();
1240 return ;//syncOK; 1259 return ;//syncOK;
1241#endif 1260
1261}
1262void CalendarView::syncSharp()
1263{
1264 syncExternal( 0 );
1265
1242} 1266}
1243 1267
1244 1268
1245#include <kabc/stdaddressbook.h> 1269#include <kabc/stdaddressbook.h>
1246bool CalendarView::importBday() 1270bool CalendarView::importBday()
1247{ 1271{
1248 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1272 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1249 KABC::AddressBook::Iterator it; 1273 KABC::AddressBook::Iterator it;
1250 int count = 0; 1274 int count = 0;
1251 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1275 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1252 ++count; 1276 ++count;
1253 } 1277 }
1254 QProgressBar bar(count,0 ); 1278 QProgressBar bar(count,0 );
1255 int w = 300; 1279 int w = 300;
1256 if ( QApplication::desktop()->width() < 320 ) 1280 if ( QApplication::desktop()->width() < 320 )
1257 w = 220; 1281 w = 220;
1258 int h = bar.sizeHint().height() ; 1282 int h = bar.sizeHint().height() ;
1259 int dw = QApplication::desktop()->width(); 1283 int dw = QApplication::desktop()->width();
1260 int dh = QApplication::desktop()->height(); 1284 int dh = QApplication::desktop()->height();
1261 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1285 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1262 bar.show(); 1286 bar.show();
1263 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1287 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1264 qApp->processEvents(); 1288 qApp->processEvents();
1265 count = 0; 1289 count = 0;
1266 int addCount = 0; 1290 int addCount = 0;
1267 KCal::Attendee* a = 0; 1291 KCal::Attendee* a = 0;
1268 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1292 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1269 if ( ! bar.isVisible() ) 1293 if ( ! bar.isVisible() )
1270 return false; 1294 return false;
1271 bar.setProgress( count++ ); 1295 bar.setProgress( count++ );
1272 qApp->processEvents(); 1296 qApp->processEvents();
1273 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1297 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1274 if ( (*it).birthday().date().isValid() ){ 1298 if ( (*it).birthday().date().isValid() ){
1275 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1299 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1276 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1300 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1277 ++addCount; 1301 ++addCount;
1278 } 1302 }
1279 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1303 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1280 if ( anni.isValid() ){ 1304 if ( anni.isValid() ){
1281 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1305 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1282 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1306 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1283 ++addCount; 1307 ++addCount;
1284 } 1308 }
1285 } 1309 }
1286 updateView(); 1310 updateView();
1287 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1311 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1288 return true; 1312 return true;
1289} 1313}
1290 1314
1291bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1315bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1292{ 1316{
1293 //qDebug("addAnni "); 1317 //qDebug("addAnni ");
1294 Event * ev = new Event(); 1318 Event * ev = new Event();
1295 if ( a ) { 1319 if ( a ) {
1296 ev->addAttendee( a ); 1320 ev->addAttendee( a );
1297 } 1321 }
1298 QString kind; 1322 QString kind;
1299 if ( birthday ) 1323 if ( birthday )
1300 kind = i18n( "Birthday" ); 1324 kind = i18n( "Birthday" );
1301 else 1325 else
1302 kind = i18n( "Anniversary" ); 1326 kind = i18n( "Anniversary" );
1303 ev->setSummary( name + " - " + kind ); 1327 ev->setSummary( name + " - " + kind );
1304 ev->setOrganizer( "nobody@nowhere" ); 1328 ev->setOrganizer( "nobody@nowhere" );
1305 ev->setCategories( kind ); 1329 ev->setCategories( kind );
1306 ev->setDtStart( QDateTime(date) ); 1330 ev->setDtStart( QDateTime(date) );
1307 ev->setDtEnd( QDateTime(date) ); 1331 ev->setDtEnd( QDateTime(date) );
1308 ev->setFloats( true ); 1332 ev->setFloats( true );
1309 Recurrence * rec = ev->recurrence(); 1333 Recurrence * rec = ev->recurrence();
1310 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1334 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1311 rec->addYearlyNum( date.month() ); 1335 rec->addYearlyNum( date.month() );
1312 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1336 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1313 delete ev; 1337 delete ev;
1314 return false; 1338 return false;
1315 } 1339 }
1316 return true; 1340 return true;
1317 1341
1318} 1342}
1319bool CalendarView::importQtopia( const QString &categories, 1343bool CalendarView::importQtopia( const QString &categories,
1320 const QString &datebook, 1344 const QString &datebook,
1321 const QString &todolist ) 1345 const QString &todolist )
1322{ 1346{
1323 1347
1324 QtopiaFormat qtopiaFormat; 1348 QtopiaFormat qtopiaFormat;
1325 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1349 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1326 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1350 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1327 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1351 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1328 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1352 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1329 1353
1330 updateView(); 1354 updateView();
1331 return true; 1355 return true;
1332 1356
1333#if 0 1357#if 0
1334 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1358 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1335 mCurrentSyncDevice = "qtopia-XML"; 1359 mCurrentSyncDevice = "qtopia-XML";
1336 if ( KOPrefs::instance()->mAskForPreferences ) 1360 if ( KOPrefs::instance()->mAskForPreferences )
1337 edit_sync_options(); 1361 edit_sync_options();
1338 qApp->processEvents(); 1362 qApp->processEvents();
1339 CalendarLocal* calendar = new CalendarLocal(); 1363 CalendarLocal* calendar = new CalendarLocal();
1340 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1364 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1341 bool syncOK = false; 1365 bool syncOK = false;
1342 QtopiaFormat qtopiaFormat; 1366 QtopiaFormat qtopiaFormat;
1343 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1367 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1344 bool loadOk = true; 1368 bool loadOk = true;
1345 if ( !categories.isEmpty() ) 1369 if ( !categories.isEmpty() )
1346 loadOk = qtopiaFormat.load( calendar, categories ); 1370 loadOk = qtopiaFormat.load( calendar, categories );
1347 if ( loadOk && !datebook.isEmpty() ) 1371 if ( loadOk && !datebook.isEmpty() )
1348 loadOk = qtopiaFormat.load( calendar, datebook ); 1372 loadOk = qtopiaFormat.load( calendar, datebook );
1349 if ( loadOk && !todolist.isEmpty() ) 1373 if ( loadOk && !todolist.isEmpty() )
1350 loadOk = qtopiaFormat.load( calendar, todolist ); 1374 loadOk = qtopiaFormat.load( calendar, todolist );
1351 1375
1352 if ( loadOk ) { 1376 if ( loadOk ) {
1353 getEventViewerDialog()->setSyncMode( true ); 1377 getEventViewerDialog()->setSyncMode( true );
1354 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1378 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1355 getEventViewerDialog()->setSyncMode( false ); 1379 getEventViewerDialog()->setSyncMode( false );
1356 qApp->processEvents(); 1380 qApp->processEvents();
1357 if ( syncOK ) { 1381 if ( syncOK ) {
1358 if ( KOPrefs::instance()->mWriteBackFile ) 1382 if ( KOPrefs::instance()->mWriteBackFile )
1359 { 1383 {
1360 // write back XML file 1384 // write back XML file
1361 1385
1362 } 1386 }
1363 setModified( true ); 1387 setModified( true );
1364 } 1388 }
1365 } else { 1389 } else {
1366 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1390 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1367 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1391 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1368 question, i18n("Ok")) ; 1392 question, i18n("Ok")) ;
1369 } 1393 }
1370 delete calendar; 1394 delete calendar;
1371 updateView(); 1395 updateView();
1372 return syncOK; 1396 return syncOK;
1373 1397
1374 1398
1375#endif 1399#endif
1376 1400
1377} 1401}
1378 1402
1379void CalendarView::setSyncEventsReadOnly() 1403void CalendarView::setSyncEventsReadOnly()
1380{ 1404{
1381 Event * ev; 1405 Event * ev;
1382 QPtrList<Event> eL = mCalendar->rawEvents(); 1406 QPtrList<Event> eL = mCalendar->rawEvents();
1383 ev = eL.first(); 1407 ev = eL.first();
1384 while ( ev ) { 1408 while ( ev ) {
1385 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1409 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1386 ev->setReadOnly( true ); 1410 ev->setReadOnly( true );
1387 ev = eL.next(); 1411 ev = eL.next();
1388 } 1412 }
1389} 1413}
1390bool CalendarView::openCalendar(QString filename, bool merge) 1414bool CalendarView::openCalendar(QString filename, bool merge)
1391{ 1415{
1392 1416
1393 if (filename.isEmpty()) { 1417 if (filename.isEmpty()) {
1394 return false; 1418 return false;
1395 } 1419 }
1396 1420
1397 if (!QFile::exists(filename)) { 1421 if (!QFile::exists(filename)) {
1398 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1422 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1399 return false; 1423 return false;
1400 } 1424 }
1401 1425
1402 globalFlagBlockAgenda = 1; 1426 globalFlagBlockAgenda = 1;
1403 if (!merge) mCalendar->close(); 1427 if (!merge) mCalendar->close();
1404 1428
1405 mStorage->setFileName( filename ); 1429 mStorage->setFileName( filename );
1406 1430
1407 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1431 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1408 if ( merge ) ;//setModified( true ); 1432 if ( merge ) ;//setModified( true );
1409 else { 1433 else {
1410 //setModified( true ); 1434 //setModified( true );
1411 mViewManager->setDocumentId( filename ); 1435 mViewManager->setDocumentId( filename );
1412 mDialogManager->setDocumentId( filename ); 1436 mDialogManager->setDocumentId( filename );
1413 mTodoList->setDocumentId( filename ); 1437 mTodoList->setDocumentId( filename );
1414 } 1438 }
1415 globalFlagBlockAgenda = 2; 1439 globalFlagBlockAgenda = 2;
1416 // if ( getLastSyncEvent() ) 1440 // if ( getLastSyncEvent() )
1417 // getLastSyncEvent()->setReadOnly( true ); 1441 // getLastSyncEvent()->setReadOnly( true );
1418 mCalendar->reInitAlarmSettings(); 1442 mCalendar->reInitAlarmSettings();
1419 setSyncEventsReadOnly(); 1443 setSyncEventsReadOnly();
1420 updateUnmanagedViews(); 1444 updateUnmanagedViews();
1421 updateView(); 1445 updateView();
1422 if ( filename != MainWindow::defaultFileName() ) 1446 if ( filename != MainWindow::defaultFileName() )
1423 saveCalendar( MainWindow::defaultFileName() ); 1447 saveCalendar( MainWindow::defaultFileName() );
1424 loadedFileVersion = QDateTime::currentDateTime(); 1448 loadedFileVersion = QDateTime::currentDateTime();
1425 return true; 1449 return true;
1426 } else { 1450 } else {
1427 // while failing to load, the calendar object could 1451 // while failing to load, the calendar object could
1428 // have become partially populated. Clear it out. 1452 // have become partially populated. Clear it out.
1429 if ( !merge ) mCalendar->close(); 1453 if ( !merge ) mCalendar->close();
1430 1454
1431 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1455 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1432 1456
1433 globalFlagBlockAgenda = 2; 1457 globalFlagBlockAgenda = 2;
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index b2838db..a3315ad 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -237,353 +237,354 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
237 bool deleteEvent(const QString &uid); 237 bool deleteEvent(const QString &uid);
238 /** Create a read-only viewer dialog for the supplied event. */ 238 /** Create a read-only viewer dialog for the supplied event. */
239 void showEvent(Event *); 239 void showEvent(Event *);
240 240
241 void editJournal(Journal *); 241 void editJournal(Journal *);
242 void showJournal(Journal *); 242 void showJournal(Journal *);
243 void deleteJournal(Journal *); 243 void deleteJournal(Journal *);
244 /** Create an editor dialog for a todo */ 244 /** Create an editor dialog for a todo */
245 void editTodo(Todo *); 245 void editTodo(Todo *);
246 /** Create a read-only viewer dialog for the supplied todo */ 246 /** Create a read-only viewer dialog for the supplied todo */
247 void showTodo(Todo *); 247 void showTodo(Todo *);
248 /** create new todo */ 248 /** create new todo */
249 void newTodo(); 249 void newTodo();
250 /** create new todo with a parent todo */ 250 /** create new todo with a parent todo */
251 void newSubTodo(); 251 void newSubTodo();
252 /** create new todo with a parent todo */ 252 /** create new todo with a parent todo */
253 void newSubTodo(Todo *); 253 void newSubTodo(Todo *);
254 /** Delete todo */ 254 /** Delete todo */
255 void deleteTodo(Todo *); 255 void deleteTodo(Todo *);
256 256
257 257
258 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 258 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
259 * emitted as result. */ 259 * emitted as result. */
260 void checkClipboard(); 260 void checkClipboard();
261 261
262 /** using the KConfig associated with the kapp variable, read in the 262 /** using the KConfig associated with the kapp variable, read in the
263 * settings from the config file. 263 * settings from the config file.
264 */ 264 */
265 void readSettings(); 265 void readSettings();
266 266
267 /** write current state to config file. */ 267 /** write current state to config file. */
268 void writeSettings(); 268 void writeSettings();
269 269
270 /** read settings for calendar filters */ 270 /** read settings for calendar filters */
271 void readFilterSettings(KConfig *config); 271 void readFilterSettings(KConfig *config);
272 272
273 /** write settings for calendar filters */ 273 /** write settings for calendar filters */
274 void writeFilterSettings(KConfig *config); 274 void writeFilterSettings(KConfig *config);
275 275
276 /** passes on the message that an event has changed to the currently 276 /** passes on the message that an event has changed to the currently
277 * activated view so that it can make appropriate display changes. */ 277 * activated view so that it can make appropriate display changes. */
278 void changeEventDisplay(Event *, int); 278 void changeEventDisplay(Event *, int);
279 void changeIncidenceDisplay(Incidence *, int); 279 void changeIncidenceDisplay(Incidence *, int);
280 void changeTodoDisplay(Todo *, int); 280 void changeTodoDisplay(Todo *, int);
281 281
282 void eventAdded(Event *); 282 void eventAdded(Event *);
283 void eventChanged(Event *); 283 void eventChanged(Event *);
284 void eventToBeDeleted(Event *); 284 void eventToBeDeleted(Event *);
285 void eventDeleted(); 285 void eventDeleted();
286 286
287 void todoAdded(Todo *); 287 void todoAdded(Todo *);
288 void todoChanged(Todo *); 288 void todoChanged(Todo *);
289 void todoToBeDeleted(Todo *); 289 void todoToBeDeleted(Todo *);
290 void todoDeleted(); 290 void todoDeleted();
291 291
292 void updateView(const QDate &start, const QDate &end); 292 void updateView(const QDate &start, const QDate &end);
293 void updateView(); 293 void updateView();
294 294
295 /** Full update of visible todo views */ 295 /** Full update of visible todo views */
296 void updateTodoViews(); 296 void updateTodoViews();
297 297
298 void updateUnmanagedViews(); 298 void updateUnmanagedViews();
299 299
300 /** cut the current appointment to the clipboard */ 300 /** cut the current appointment to the clipboard */
301 void edit_cut(); 301 void edit_cut();
302 302
303 /** copy the current appointment(s) to the clipboard */ 303 /** copy the current appointment(s) to the clipboard */
304 void edit_copy(); 304 void edit_copy();
305 305
306 /** paste the current vobject(s) in the clipboard buffer into calendar */ 306 /** paste the current vobject(s) in the clipboard buffer into calendar */
307 void edit_paste(); 307 void edit_paste();
308 308
309 /** edit viewing and configuration options. */ 309 /** edit viewing and configuration options. */
310 void edit_options(); 310 void edit_options();
311 void edit_sync_options(); 311 void edit_sync_options();
312 /** 312 /**
313 Functions for printing, previewing a print, and setting up printing 313 Functions for printing, previewing a print, and setting up printing
314 parameters. 314 parameters.
315 */ 315 */
316 void print(); 316 void print();
317 void printSetup(); 317 void printSetup();
318 void printPreview(); 318 void printPreview();
319 319
320 /** Export as iCalendar file */ 320 /** Export as iCalendar file */
321 void exportICalendar(); 321 void exportICalendar();
322 322
323 /** Export as vCalendar file */ 323 /** Export as vCalendar file */
324 bool exportVCalendar( QString fn); 324 bool exportVCalendar( QString fn);
325 325
326 /** pop up a dialog to show an existing appointment. */ 326 /** pop up a dialog to show an existing appointment. */
327 void appointment_show(); 327 void appointment_show();
328 /** 328 /**
329 * pop up an Appointment Dialog to edit an existing appointment.Get 329 * pop up an Appointment Dialog to edit an existing appointment.Get
330 * information on the appointment from the list of unique IDs that is 330 * information on the appointment from the list of unique IDs that is
331 * currently in the View, called currIds. 331 * currently in the View, called currIds.
332 */ 332 */
333 void appointment_edit(); 333 void appointment_edit();
334 /** 334 /**
335 * pop up dialog confirming deletion of currently selected event in the 335 * pop up dialog confirming deletion of currently selected event in the
336 * View. 336 * View.
337 */ 337 */
338 void appointment_delete(); 338 void appointment_delete();
339 339
340 /** mails the currently selected event to a particular user as a vCalendar 340 /** mails the currently selected event to a particular user as a vCalendar
341 attachment. */ 341 attachment. */
342 void action_mail(); 342 void action_mail();
343 343
344 /* frees a subtodo from it's relation */ 344 /* frees a subtodo from it's relation */
345 void todo_unsub( Todo * ); 345 void todo_unsub( Todo * );
346 346
347 /** Take ownership of selected event. */ 347 /** Take ownership of selected event. */
348 void takeOverEvent(); 348 void takeOverEvent();
349 349
350 /** Take ownership of all events in calendar. */ 350 /** Take ownership of all events in calendar. */
351 void takeOverCalendar(); 351 void takeOverCalendar();
352 352
353 /** query whether or not the calendar is "dirty". */ 353 /** query whether or not the calendar is "dirty". */
354 bool isModified(); 354 bool isModified();
355 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 355 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
356 void setModified(bool modified=true); 356 void setModified(bool modified=true);
357 357
358 /** query if the calendar is read-only. */ 358 /** query if the calendar is read-only. */
359 bool isReadOnly(); 359 bool isReadOnly();
360 /** set state of calendar to read-only */ 360 /** set state of calendar to read-only */
361 void setReadOnly(bool readOnly=true); 361 void setReadOnly(bool readOnly=true);
362 362
363 void eventUpdated(Incidence *); 363 void eventUpdated(Incidence *);
364 364
365 /* iTIP scheduling actions */ 365 /* iTIP scheduling actions */
366 void schedule_publish(Incidence *incidence = 0); 366 void schedule_publish(Incidence *incidence = 0);
367 void schedule_request(Incidence *incidence = 0); 367 void schedule_request(Incidence *incidence = 0);
368 void schedule_refresh(Incidence *incidence = 0); 368 void schedule_refresh(Incidence *incidence = 0);
369 void schedule_cancel(Incidence *incidence = 0); 369 void schedule_cancel(Incidence *incidence = 0);
370 void schedule_add(Incidence *incidence = 0); 370 void schedule_add(Incidence *incidence = 0);
371 void schedule_reply(Incidence *incidence = 0); 371 void schedule_reply(Incidence *incidence = 0);
372 void schedule_counter(Incidence *incidence = 0); 372 void schedule_counter(Incidence *incidence = 0);
373 void schedule_declinecounter(Incidence *incidence = 0); 373 void schedule_declinecounter(Incidence *incidence = 0);
374 void schedule_publish_freebusy(int daysToPublish = 30); 374 void schedule_publish_freebusy(int daysToPublish = 30);
375 375
376 void openAddressbook(); 376 void openAddressbook();
377 377
378 void editFilters(); 378 void editFilters();
379 void toggleFilerEnabled(); 379 void toggleFilerEnabled();
380 QPtrList<CalFilter> filters(); 380 QPtrList<CalFilter> filters();
381 void toggleFilter(); 381 void toggleFilter();
382 void showFilter(bool visible); 382 void showFilter(bool visible);
383 void updateFilter(); 383 void updateFilter();
384 void filterEdited(); 384 void filterEdited();
385 void selectFilter( int ); 385 void selectFilter( int );
386 KOFilterView *filterView(); 386 KOFilterView *filterView();
387 387
388 void showIntro(); 388 void showIntro();
389 389
390 /** Move the curdatepient view date to today */ 390 /** Move the curdatepient view date to today */
391 void goToday(); 391 void goToday();
392 392
393 /** Move to the next date(s) in the current view */ 393 /** Move to the next date(s) in the current view */
394 void goNext(); 394 void goNext();
395 395
396 /** Move to the previous date(s) in the current view */ 396 /** Move to the previous date(s) in the current view */
397 void goPrevious(); 397 void goPrevious();
398 /** Move to the next date(s) in the current view */ 398 /** Move to the next date(s) in the current view */
399 void goNextMonth(); 399 void goNextMonth();
400 400
401 /** Move to the previous date(s) in the current view */ 401 /** Move to the previous date(s) in the current view */
402 void goPreviousMonth(); 402 void goPreviousMonth();
403 403
404 void toggleExpand(); 404 void toggleExpand();
405 void toggleDateNavigatorWidget(); 405 void toggleDateNavigatorWidget();
406 void toggleAllDaySize(); 406 void toggleAllDaySize();
407 void dialogClosing(Incidence *); 407 void dialogClosing(Incidence *);
408 408
409 /** Look for new messages in the inbox */ 409 /** Look for new messages in the inbox */
410 void lookForIncomingMessages(); 410 void lookForIncomingMessages();
411 /** Look for new messages in the outbox */ 411 /** Look for new messages in the outbox */
412 void lookForOutgoingMessages(); 412 void lookForOutgoingMessages();
413 413
414 void processMainViewSelection( Incidence * ); 414 void processMainViewSelection( Incidence * );
415 void processTodoListSelection( Incidence * ); 415 void processTodoListSelection( Incidence * );
416 416
417 void processIncidenceSelection( Incidence * ); 417 void processIncidenceSelection( Incidence * );
418 418
419 void purgeCompleted(); 419 void purgeCompleted();
420 bool removeCompletedSubTodos( Todo* ); 420 bool removeCompletedSubTodos( Todo* );
421 void slotCalendarChanged(); 421 void slotCalendarChanged();
422 bool importBday(); 422 bool importBday();
423 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 423 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
424 bool importQtopia( const QString &categoriesFile, 424 bool importQtopia( const QString &categoriesFile,
425 const QString &datebookFile, 425 const QString &datebookFile,
426 const QString &tasklistFile ); 426 const QString &tasklistFile );
427 void syncSharp( ); 427 void syncSharp( );
428 void syncPhone( ); 428 void syncPhone( );
429 void syncExternal( int mode );
429 void slotSelectPickerDate( QDate ) ; 430 void slotSelectPickerDate( QDate ) ;
430 void showDatePicker( ) ; 431 void showDatePicker( ) ;
431 void moveIncidence(Incidence *) ; 432 void moveIncidence(Incidence *) ;
432 void beamIncidence(Incidence *) ; 433 void beamIncidence(Incidence *) ;
433 void beamCalendar() ; 434 void beamCalendar() ;
434 void beamFilteredCalendar() ; 435 void beamFilteredCalendar() ;
435 void beamIncidenceList(QPtrList<Incidence>) ; 436 void beamIncidenceList(QPtrList<Incidence>) ;
436 void manageCategories(); 437 void manageCategories();
437 int addCategories(); 438 int addCategories();
438 void removeCategories(); 439 void removeCategories();
439 void setSyncDevice( QString ); 440 void setSyncDevice( QString );
440 void setSyncName( QString ); 441 void setSyncName( QString );
441 protected slots: 442 protected slots:
442 void timerAlarm(); 443 void timerAlarm();
443 void suspendAlarm(); 444 void suspendAlarm();
444 void beamDone( Ir *ir ); 445 void beamDone( Ir *ir );
445 /** Select a view or adapt the current view to display the specified dates. */ 446 /** Select a view or adapt the current view to display the specified dates. */
446 void showDates( const KCal::DateList & ); 447 void showDates( const KCal::DateList & );
447 void selectWeekNum ( int ); 448 void selectWeekNum ( int );
448 449
449 public: 450 public:
450 // show a standard warning 451 // show a standard warning
451 // returns KMsgBox::yesNoCancel() 452 // returns KMsgBox::yesNoCancel()
452 int msgCalModified(); 453 int msgCalModified();
453 void confSync(); 454 void confSync();
454 void setLoadedFileVersion(QDateTime); 455 void setLoadedFileVersion(QDateTime);
455 bool checkFileVersion(QString fn); 456 bool checkFileVersion(QString fn);
456 bool checkFileChanged(QString fn); 457 bool checkFileChanged(QString fn);
457 Event* getLastSyncEvent(); 458 Event* getLastSyncEvent();
458 /** Adapt navigation units correpsonding to step size of navigation of the 459 /** Adapt navigation units correpsonding to step size of navigation of the
459 * current view. 460 * current view.
460 */ 461 */
461 void adaptNavigationUnits(); 462 void adaptNavigationUnits();
462 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 463 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
463 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 464 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
464 //Attendee* getYourAttendee(Event *event); 465 //Attendee* getYourAttendee(Event *event);
465 protected: 466 protected:
466 void schedule(Scheduler::Method, Incidence *incidence = 0); 467 void schedule(Scheduler::Method, Incidence *incidence = 0);
467 468
468 // returns KMsgBox::OKCandel() 469 // returns KMsgBox::OKCandel()
469 int msgItemDelete(); 470 int msgItemDelete();
470 void showEventEditor(); 471 void showEventEditor();
471 void showTodoEditor(); 472 void showTodoEditor();
472 void writeLocale(); 473 void writeLocale();
473 Todo *selectedTodo(); 474 Todo *selectedTodo();
474 475
475 private: 476 private:
476 AlarmDialog * mAlarmDialog; 477 AlarmDialog * mAlarmDialog;
477 QString mAlarmNotification; 478 QString mAlarmNotification;
478 QString mSuspendAlarmNotification; 479 QString mSuspendAlarmNotification;
479 QTimer* mSuspendTimer; 480 QTimer* mSuspendTimer;
480 QTimer* mAlarmTimer; 481 QTimer* mAlarmTimer;
481 QTimer* mRecheckAlarmTimer; 482 QTimer* mRecheckAlarmTimer;
482 void computeAlarm( QString ); 483 void computeAlarm( QString );
483 void startAlarm( QString, QString ); 484 void startAlarm( QString, QString );
484 void setSyncEventsReadOnly(); 485 void setSyncEventsReadOnly();
485 486
486 QDateTime loadedFileVersion; 487 QDateTime loadedFileVersion;
487 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 488 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
488 void checkExternalId( Incidence * inc ); 489 void checkExternalId( Incidence * inc );
489 int mGlobalSyncMode; 490 int mGlobalSyncMode;
490 QString mCurrentSyncDevice; 491 QString mCurrentSyncDevice;
491 QString mCurrentSyncName; 492 QString mCurrentSyncName;
492 KOBeamPrefs* beamDialog; 493 KOBeamPrefs* beamDialog;
493 void init(); 494 void init();
494 int mDatePickerMode; 495 int mDatePickerMode;
495 bool mFlagEditDescription; 496 bool mFlagEditDescription;
496 QDateTime mLastCalendarSync; 497 QDateTime mLastCalendarSync;
497 void createPrinter(); 498 void createPrinter();
498 499
499 void calendarModified( bool, Calendar * ); 500 void calendarModified( bool, Calendar * );
500 501
501 CalPrinter *mCalPrinter; 502 CalPrinter *mCalPrinter;
502 503
503 QSplitter *mPanner; 504 QSplitter *mPanner;
504 QSplitter *mLeftSplitter; 505 QSplitter *mLeftSplitter;
505 QWidget *mLeftFrame; 506 QWidget *mLeftFrame;
506 QWidgetStack *mRightFrame; 507 QWidgetStack *mRightFrame;
507 508
508 KDatePicker* mDatePicker; 509 KDatePicker* mDatePicker;
509 QVBox* mDateFrame; 510 QVBox* mDateFrame;
510 NavigatorBar *mNavigatorBar; 511 NavigatorBar *mNavigatorBar;
511 512
512 KDateNavigator *mDateNavigator; // widget showing small month view. 513 KDateNavigator *mDateNavigator; // widget showing small month view.
513 514
514 KOFilterView *mFilterView; 515 KOFilterView *mFilterView;
515 516
516 ResourceView *mResourceView; 517 ResourceView *mResourceView;
517 518
518 // calendar object for this viewing instance 519 // calendar object for this viewing instance
519 Calendar *mCalendar; 520 Calendar *mCalendar;
520 521
521 CalendarResourceManager *mResourceManager; 522 CalendarResourceManager *mResourceManager;
522 523
523 FileStorage *mStorage; 524 FileStorage *mStorage;
524 525
525 DateNavigator *mNavigator; 526 DateNavigator *mNavigator;
526 527
527 KOViewManager *mViewManager; 528 KOViewManager *mViewManager;
528 KODialogManager *mDialogManager; 529 KODialogManager *mDialogManager;
529 530
530 // Calendar filters 531 // Calendar filters
531 QPtrList<CalFilter> mFilters; 532 QPtrList<CalFilter> mFilters;
532 533
533 // various housekeeping variables. 534 // various housekeeping variables.
534 bool mModified; // flag indicating if calendar is modified 535 bool mModified; // flag indicating if calendar is modified
535 bool mReadOnly; // flag indicating if calendar is read-only 536 bool mReadOnly; // flag indicating if calendar is read-only
536 QDate mSaveSingleDate; 537 QDate mSaveSingleDate;
537 538
538 Incidence *mSelectedIncidence; 539 Incidence *mSelectedIncidence;
539 Incidence *mMoveIncidence; 540 Incidence *mMoveIncidence;
540 QPtrList<Event> mExternLastSyncEvent; 541 QPtrList<Event> mExternLastSyncEvent;
541 KOTodoView *mTodoList; 542 KOTodoView *mTodoList;
542 KOEventEditor * mEventEditor; 543 KOEventEditor * mEventEditor;
543 KOTodoEditor * mTodoEditor; 544 KOTodoEditor * mTodoEditor;
544 KOEventViewerDialog * mEventViewerDialog; 545 KOEventViewerDialog * mEventViewerDialog;
545 void keyPressEvent ( QKeyEvent *e) ; 546 void keyPressEvent ( QKeyEvent *e) ;
546 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 547 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
547}; 548};
548 549
549 550
550class CalendarViewVisitor : public Incidence::Visitor 551class CalendarViewVisitor : public Incidence::Visitor
551{ 552{
552 public: 553 public:
553 CalendarViewVisitor() : mView( 0 ) {} 554 CalendarViewVisitor() : mView( 0 ) {}
554 555
555 bool act( Incidence *incidence, CalendarView *view ) 556 bool act( Incidence *incidence, CalendarView *view )
556 { 557 {
557 mView = view; 558 mView = view;
558 return incidence->accept( *this ); 559 return incidence->accept( *this );
559 } 560 }
560 561
561 protected: 562 protected:
562 CalendarView *mView; 563 CalendarView *mView;
563}; 564};
564 565
565class ShowIncidenceVisitor : public CalendarViewVisitor 566class ShowIncidenceVisitor : public CalendarViewVisitor
566{ 567{
567 protected: 568 protected:
568 bool visit( Event *event ) { mView->showEvent( event ); return true; } 569 bool visit( Event *event ) { mView->showEvent( event ); return true; }
569 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 570 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
570 bool visit( Journal * j ) { mView->showJournal( j );return true; } 571 bool visit( Journal * j ) { mView->showJournal( j );return true; }
571}; 572};
572 573
573class EditIncidenceVisitor : public CalendarViewVisitor 574class EditIncidenceVisitor : public CalendarViewVisitor
574{ 575{
575 protected: 576 protected:
576 bool visit( Event *event ) { mView->editEvent( event ); return true; } 577 bool visit( Event *event ) { mView->editEvent( event ); return true; }
577 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 578 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
578 bool visit( Journal *j ) { mView->editJournal( j); return true; } 579 bool visit( Journal *j ) { mView->editJournal( j); return true; }
579}; 580};
580 581
581class DeleteIncidenceVisitor : public CalendarViewVisitor 582class DeleteIncidenceVisitor : public CalendarViewVisitor
582{ 583{
583 protected: 584 protected:
584 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 585 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
585 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 586 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
586 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 587 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
587}; 588};
588 589
589#endif 590#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 062c95f..cce182a 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -811,385 +811,391 @@ void MainWindow::initActions()
811 if (p-> mShowIconWhatsThis) 811 if (p-> mShowIconWhatsThis)
812 configureToolBarMenu->setItemChecked( 300, true ); 812 configureToolBarMenu->setItemChecked( 300, true );
813 813
814 QLabel* dummy = new QLabel( iconToolBar ); 814 QLabel* dummy = new QLabel( iconToolBar );
815 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 815 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
816 if (!p-> mShowIconStretch) 816 if (!p-> mShowIconStretch)
817 iconToolBar->setStretchableWidget ( dummy ) ; 817 iconToolBar->setStretchableWidget ( dummy ) ;
818 else 818 else
819 configureToolBarMenu->setItemChecked( 5, true ); 819 configureToolBarMenu->setItemChecked( 5, true );
820 if (p-> mShowIconWhatsThis) 820 if (p-> mShowIconWhatsThis)
821 QWhatsThis::whatsThisButton ( iconToolBar ); 821 QWhatsThis::whatsThisButton ( iconToolBar );
822 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 822 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
823 configureAgenda( p->mHourSize ); 823 configureAgenda( p->mHourSize );
824 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 824 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
825} 825}
826void MainWindow::fillSyncMenu() 826void MainWindow::fillSyncMenu()
827{ 827{
828 syncMenu->clear(); 828 syncMenu->clear();
829 syncMenu->insertItem( i18n("Configure..."), 0 ); 829 syncMenu->insertItem( i18n("Configure..."), 0 );
830 syncMenu->insertSeparator(); 830 syncMenu->insertSeparator();
831 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 831 syncMenu->insertItem( i18n("Multiple sync"), 1 );
832 syncMenu->insertSeparator(); 832 syncMenu->insertSeparator();
833 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 833 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
834 config.setGroup("General"); 834 config.setGroup("General");
835 QStringList prof = config.readListEntry("SyncProfileNames"); 835 QStringList prof = config.readListEntry("SyncProfileNames");
836 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 836 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
837 if ( prof.count() < 3 ) { 837 if ( prof.count() < 3 ) {
838 prof.clear(); 838 prof.clear();
839 prof << i18n("Sharp_DTM"); 839 prof << i18n("Sharp_DTM");
840 prof << i18n("Local_file"); 840 prof << i18n("Local_file");
841 prof << i18n("Last_file"); 841 prof << i18n("Last_file");
842 KSyncProfile* temp = new KSyncProfile (); 842 KSyncProfile* temp = new KSyncProfile ();
843 temp->setName( prof[0] ); 843 temp->setName( prof[0] );
844 temp->writeConfig(&config); 844 temp->writeConfig(&config);
845 temp->setName( prof[1] ); 845 temp->setName( prof[1] );
846 temp->writeConfig(&config); 846 temp->writeConfig(&config);
847 temp->setName( prof[2] ); 847 temp->setName( prof[2] );
848 temp->writeConfig(&config); 848 temp->writeConfig(&config);
849 config.setGroup("General"); 849 config.setGroup("General");
850 config.writeEntry("SyncProfileNames",prof); 850 config.writeEntry("SyncProfileNames",prof);
851 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 851 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
852 config.sync(); 852 config.sync();
853 delete temp; 853 delete temp;
854 } 854 }
855 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 855 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
856 KOPrefs::instance()->mSyncProfileNames = prof; 856 KOPrefs::instance()->mSyncProfileNames = prof;
857 int i; 857 int i;
858 for ( i = 0; i < prof.count(); ++i ) { 858 for ( i = 0; i < prof.count(); ++i ) {
859 859
860 syncMenu->insertItem( prof[i], 1000+i ); 860 syncMenu->insertItem( prof[i], 1000+i );
861 if ( i == 2 ) 861 if ( i == 2 )
862 syncMenu->insertSeparator(); 862 syncMenu->insertSeparator();
863 } 863 }
864 QDir app_dir; 864 QDir app_dir;
865 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 865 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
866 syncMenu->setItemEnabled( false , 1000 ); 866 syncMenu->setItemEnabled( false , 1000 );
867 } 867 }
868 mView->setupExternSyncProfiles(); 868 mView->setupExternSyncProfiles();
869} 869}
870 870
871int MainWindow::ringSync() 871int MainWindow::ringSync()
872{ 872{
873 int syncedProfiles = 0; 873 int syncedProfiles = 0;
874 int i; 874 int i;
875 QTime timer; 875 QTime timer;
876 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 876 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
877 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 877 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
878 KSyncProfile* temp = new KSyncProfile (); 878 KSyncProfile* temp = new KSyncProfile ();
879 KOPrefs::instance()->mAskForPreferences = false; 879 KOPrefs::instance()->mAskForPreferences = false;
880 for ( i = 0; i < syncProfileNames.count(); ++i ) { 880 for ( i = 0; i < syncProfileNames.count(); ++i ) {
881 mCurrentSyncProfile = i; 881 mCurrentSyncProfile = i;
882 temp->setName(syncProfileNames[mCurrentSyncProfile]); 882 temp->setName(syncProfileNames[mCurrentSyncProfile]);
883 temp->readConfig(&config); 883 temp->readConfig(&config);
884 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 884 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
885 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 885 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
886 ++syncedProfiles; 886 ++syncedProfiles;
887 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 887 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
888 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 888 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
889 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 889 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
890 KOPrefs::instance()->mShowSyncSummary = false; 890 KOPrefs::instance()->mShowSyncSummary = false;
891 mView->setSyncDevice(syncProfileNames[i] ); 891 mView->setSyncDevice(syncProfileNames[i] );
892 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 892 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
893 if ( i == 0 ) { 893 if ( i == 0 ) {
894 syncSharp(); 894 syncSharp();
895 } else { 895 } else {
896 if ( temp->getIsLocalFileSync() ) { 896 if ( temp->getIsLocalFileSync() ) {
897 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 897 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
898 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 898 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
899 } else { 899 } else {
900 if ( temp->getIsPhoneSync() ) { 900 if ( temp->getIsPhoneSync() ) {
901 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 901 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
902 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 902 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
903 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 903 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
904 syncPhone(); 904 syncPhone();
905 } else 905 } else
906 syncRemote( temp, false ); 906 syncRemote( temp, false );
907 907
908 } 908 }
909 } 909 }
910 timer.start(); 910 timer.start();
911 setCaption(i18n("Multiple sync in progress ... please wait!") ); 911 setCaption(i18n("Multiple sync in progress ... please wait!") );
912 while ( timer.elapsed () < 2000 ) { 912 while ( timer.elapsed () < 2000 ) {
913 qApp->processEvents(); 913 qApp->processEvents();
914#ifndef _WIN32_ 914#ifndef _WIN32_
915 sleep (1); 915 sleep (1);
916#endif 916#endif
917 } 917 }
918 918
919 } 919 }
920 920
921 } 921 }
922 delete temp; 922 delete temp;
923 return syncedProfiles; 923 return syncedProfiles;
924} 924}
925 925
926void MainWindow::multiSync( bool askforPrefs ) 926void MainWindow::multiSync( bool askforPrefs )
927{ 927{
928 if (mBlockSaveFlag) 928 if (mBlockSaveFlag)
929 return; 929 return;
930 mBlockSaveFlag = true; 930 mBlockSaveFlag = true;
931 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 931 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
932 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 932 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
933 question, 933 question,
934 i18n("Yes"), i18n("No"), 934 i18n("Yes"), i18n("No"),
935 0, 0 ) != 0 ) { 935 0, 0 ) != 0 ) {
936 mBlockSaveFlag = false; 936 mBlockSaveFlag = false;
937 setCaption(i18n("Aborted! Nothing synced!")); 937 setCaption(i18n("Aborted! Nothing synced!"));
938 return; 938 return;
939 } 939 }
940 mView->setSyncDevice(i18n("Multiple profiles") ); 940 mView->setSyncDevice(i18n("Multiple profiles") );
941 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 941 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
942 if ( askforPrefs ) { 942 if ( askforPrefs ) {
943 mView->edit_sync_options(); 943 mView->edit_sync_options();
944 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 944 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
945 } 945 }
946 setCaption(i18n("Multiple sync started.") ); 946 setCaption(i18n("Multiple sync started.") );
947 qApp->processEvents(); 947 qApp->processEvents();
948 int num = ringSync() ; 948 int num = ringSync() ;
949 if ( num > 1 ) 949 if ( num > 1 )
950 ringSync(); 950 ringSync();
951 mBlockSaveFlag = false; 951 mBlockSaveFlag = false;
952 if ( num ) 952 if ( num )
953 save(); 953 save();
954 if ( num ) 954 if ( num )
955 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 955 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
956 else 956 else
957 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 957 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
958 return; 958 return;
959} 959}
960void MainWindow::slotSyncMenu( int action ) 960void MainWindow::slotSyncMenu( int action )
961{ 961{
962 //qDebug("syncaction %d ", action); 962 //qDebug("syncaction %d ", action);
963 if ( action == 0 ) { 963 if ( action == 0 ) {
964 964
965 confSync(); 965 confSync();
966 966
967 return; 967 return;
968 } 968 }
969 if ( action == 1 ) { 969 if ( action == 1 ) {
970 multiSync( true ); 970 multiSync( true );
971 return; 971 return;
972 } 972 }
973 973
974 if (mBlockSaveFlag) 974 if (mBlockSaveFlag)
975 return; 975 return;
976 mBlockSaveFlag = true; 976 mBlockSaveFlag = true;
977 mCurrentSyncProfile = action - 1000 ; 977 mCurrentSyncProfile = action - 1000 ;
978 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 978 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
979 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 979 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
980 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 980 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
981 KSyncProfile* temp = new KSyncProfile (); 981 KSyncProfile* temp = new KSyncProfile ();
982 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 982 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
983 temp->readConfig(&config); 983 temp->readConfig(&config);
984 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 984 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
985 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 985 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
986 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 986 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
987 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 987 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
988 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 988 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
989 if ( action == 1000 ) { 989 if ( action == 1000 ) {
990 syncSharp(); 990 syncSharp();
991 991
992 } else if ( action == 1001 ) { 992 } else if ( action == 1001 ) {
993 syncLocalFile(); 993 syncLocalFile();
994 994
995 } else if ( action == 1002 ) { 995 } else if ( action == 1002 ) {
996 quickSyncLocalFile(); 996 quickSyncLocalFile();
997 997
998 } else if ( action >= 1003 ) { 998 } else if ( action >= 1003 ) {
999 if ( temp->getIsLocalFileSync() ) { 999 if ( temp->getIsLocalFileSync() ) {
1000 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1000 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1001 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1001 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1002 } else { 1002 } else {
1003 syncRemote( temp ); 1003 if ( temp->getIsPhoneSync() ) {
1004 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1005 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1006 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1007 syncPhone();
1008 } else
1009 syncRemote( temp );
1004 1010
1005 } 1011 }
1006 } 1012 }
1007 delete temp; 1013 delete temp;
1008 mBlockSaveFlag = false; 1014 mBlockSaveFlag = false;
1009} 1015}
1010void MainWindow::setDefaultPreferences() 1016void MainWindow::setDefaultPreferences()
1011{ 1017{
1012 KOPrefs *p = KOPrefs::instance(); 1018 KOPrefs *p = KOPrefs::instance();
1013 1019
1014 p->mCompactDialogs = true; 1020 p->mCompactDialogs = true;
1015 p->mConfirm = true; 1021 p->mConfirm = true;
1016 // p->mEnableQuickTodo = false; 1022 // p->mEnableQuickTodo = false;
1017} 1023}
1018 1024
1019QString MainWindow::resourcePath() 1025QString MainWindow::resourcePath()
1020{ 1026{
1021 return KGlobal::iconLoader()->iconPath(); 1027 return KGlobal::iconLoader()->iconPath();
1022} 1028}
1023 1029
1024void MainWindow::displayText( QString text ,QString cap ) 1030void MainWindow::displayText( QString text ,QString cap )
1025{ 1031{
1026 QDialog dia( this, "name", true ); ; 1032 QDialog dia( this, "name", true ); ;
1027 dia.setCaption( cap ); 1033 dia.setCaption( cap );
1028 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1034 QVBoxLayout* lay = new QVBoxLayout( &dia );
1029 lay->setSpacing( 3 ); 1035 lay->setSpacing( 3 );
1030 lay->setMargin( 3 ); 1036 lay->setMargin( 3 );
1031 QTextBrowser tb ( &dia ); 1037 QTextBrowser tb ( &dia );
1032 lay->addWidget( &tb ); 1038 lay->addWidget( &tb );
1033 tb.setText( text ); 1039 tb.setText( text );
1034#ifdef DESKTOP_VERSION 1040#ifdef DESKTOP_VERSION
1035 dia.resize( 640, 480); 1041 dia.resize( 640, 480);
1036#else 1042#else
1037 dia.showMaximized(); 1043 dia.showMaximized();
1038#endif 1044#endif
1039 dia.exec(); 1045 dia.exec();
1040} 1046}
1041void MainWindow::displayFile( QString fn, QString cap ) 1047void MainWindow::displayFile( QString fn, QString cap )
1042{ 1048{
1043 QString fileName = resourcePath() + fn; 1049 QString fileName = resourcePath() + fn;
1044 QString text; 1050 QString text;
1045 QFile file( fileName ); 1051 QFile file( fileName );
1046 if (!file.open( IO_ReadOnly ) ) { 1052 if (!file.open( IO_ReadOnly ) ) {
1047 return ; 1053 return ;
1048 1054
1049 } 1055 }
1050 QTextStream ts( &file ); 1056 QTextStream ts( &file );
1051 text = ts.read(); 1057 text = ts.read();
1052 file.close(); 1058 file.close();
1053 displayText( text, cap); 1059 displayText( text, cap);
1054} 1060}
1055void MainWindow::features() 1061void MainWindow::features()
1056{ 1062{
1057 1063
1058 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1064 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1059} 1065}
1060 1066
1061void MainWindow::usertrans() 1067void MainWindow::usertrans()
1062{ 1068{
1063 1069
1064 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1070 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1065} 1071}
1066void MainWindow::synchowto() 1072void MainWindow::synchowto()
1067{ 1073{
1068 1074
1069 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1075 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1070} 1076}
1071void MainWindow::faq() 1077void MainWindow::faq()
1072{ 1078{
1073 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1079 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1074 1080
1075} 1081}
1076void MainWindow::whatsNew() 1082void MainWindow::whatsNew()
1077{ 1083{
1078 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1084 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1079 1085
1080} 1086}
1081void MainWindow::licence() 1087void MainWindow::licence()
1082{ 1088{
1083 KApplication::showLicence(); 1089 KApplication::showLicence();
1084 1090
1085} 1091}
1086void MainWindow::about() 1092void MainWindow::about()
1087{ 1093{
1088 QString version; 1094 QString version;
1089#include <../version> 1095#include <../version>
1090 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1096 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1091 i18n("KOrganizer/Platform-independent\n") + 1097 i18n("KOrganizer/Platform-independent\n") +
1092 "(KO/Pi) " + version + " - " + 1098 "(KO/Pi) " + version + " - " +
1093 1099
1094#ifdef DESKTOP_VERSION 1100#ifdef DESKTOP_VERSION
1095 i18n("Desktop Edition\n") + 1101 i18n("Desktop Edition\n") +
1096#else 1102#else
1097 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1103 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1098#endif 1104#endif
1099 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1105 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1100} 1106}
1101void MainWindow::keyBindings() 1107void MainWindow::keyBindings()
1102{ 1108{
1103 QString cap = i18n("Key bindings KOrganizer/Pi"); 1109 QString cap = i18n("Key bindings KOrganizer/Pi");
1104 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1110 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1105 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1111 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1106 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1112 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1107 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1113 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1108 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1114 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1109 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1115 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1110 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1116 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1111 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1117 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1112 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1118 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1113 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1119 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1114 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1120 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1115 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1121 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1116 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1122 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1117 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1123 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1118 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1124 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1119 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1125 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1120 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1126 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1121 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1127 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1122 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1128 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1123 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1129 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1124 i18n("<p><h3>In agenda view:</h3></p>\n") + 1130 i18n("<p><h3>In agenda view:</h3></p>\n") +
1125 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1131 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1126 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1132 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1127 i18n("<p><h3>In todo view:</h3></p>\n") + 1133 i18n("<p><h3>In todo view:</h3></p>\n") +
1128 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1134 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1129 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1135 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1130 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1136 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1131 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1137 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1132 i18n("<p><h3>In list view:</h3></p>\n") + 1138 i18n("<p><h3>In list view:</h3></p>\n") +
1133 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1139 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1134 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1140 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1135 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1141 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1136 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1142 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1137 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1143 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1138 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1144 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1139 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1145 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1140 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1146 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1141 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1147 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1142 i18n("<p><b>E</b>: Edit item</p>\n") + 1148 i18n("<p><b>E</b>: Edit item</p>\n") +
1143 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1149 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1144 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1150 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1145 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1151 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1146 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1152 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1147 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1153 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1148 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1154 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1149 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1155 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1150 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1156 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1151 i18n("<p><b>White</b>: Item readonly</p>\n"); 1157 i18n("<p><b>White</b>: Item readonly</p>\n");
1152 displayText( text, cap); 1158 displayText( text, cap);
1153 1159
1154} 1160}
1155void MainWindow::aboutAutoSaving() 1161void MainWindow::aboutAutoSaving()
1156{ 1162{
1157 QMessageBox* msg; 1163 QMessageBox* msg;
1158 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1164 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1159 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, 1165 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon,
1160 QMessageBox::Ok, 1166 QMessageBox::Ok,
1161 QMessageBox::NoButton, 1167 QMessageBox::NoButton,
1162 QMessageBox::NoButton); 1168 QMessageBox::NoButton);
1163 msg->exec(); 1169 msg->exec();
1164 delete msg; 1170 delete msg;
1165 1171
1166 1172
1167} 1173}
1168void MainWindow::aboutKnownBugs() 1174void MainWindow::aboutKnownBugs()
1169{ 1175{
1170 QMessageBox* msg; 1176 QMessageBox* msg;
1171 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1177 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1172 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1178 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1173 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1179 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1174 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1180 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1175 i18n("\nor report them in the bugtracker on\n") + 1181 i18n("\nor report them in the bugtracker on\n") +
1176 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1182 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1177 QMessageBox::NoIcon, 1183 QMessageBox::NoIcon,
1178 QMessageBox::Ok, 1184 QMessageBox::Ok,
1179 QMessageBox::NoButton, 1185 QMessageBox::NoButton,
1180 QMessageBox::NoButton); 1186 QMessageBox::NoButton);
1181 msg->exec(); 1187 msg->exec();
1182 delete msg; 1188 delete msg;
1183 1189
1184} 1190}
1185 1191
1186QString MainWindow::defaultFileName() 1192QString MainWindow::defaultFileName()
1187{ 1193{
1188 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1194 return locateLocal( "data", "korganizer/mycalendar.ics" );
1189} 1195}
1190 1196
1191void MainWindow::processIncidenceSelection( Incidence *incidence ) 1197void MainWindow::processIncidenceSelection( Incidence *incidence )
1192{ 1198{
1193 if ( !incidence ) { 1199 if ( !incidence ) {
1194 enableIncidenceActions( false ); 1200 enableIncidenceActions( false );
1195 1201
diff --git a/libkcal/libkcalE.pro b/libkcal/libkcalE.pro
index 283a22d..f5be980 100644
--- a/libkcal/libkcalE.pro
+++ b/libkcal/libkcalE.pro
@@ -1,87 +1,89 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3 TARGET = microkcal 3 TARGET = microkcal
4 4
5INCLUDEPATH += ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include 5INCLUDEPATH += ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include
6INCLUDEPATH += ../libical/src/libical 6INCLUDEPATH += ../libical/src/libical
7INCLUDEPATH += ../libical/src/libicalss 7INCLUDEPATH += ../libical/src/libicalss
8OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)
9MOC_DIR = moc/$(PLATFORM) 9MOC_DIR = moc/$(PLATFORM)
10DESTDIR = $(QPEDIR)/lib 10DESTDIR = $(QPEDIR)/lib
11LIBS += ../libical/lib/$(PLATFORM)/libical.a 11LIBS += ../libical/lib/$(PLATFORM)/libical.a
12LIBS += ../libical/lib/$(PLATFORM)/libicalss.a 12LIBS += ../libical/lib/$(PLATFORM)/libicalss.a
13 13
14INTERFACES = \ 14INTERFACES = \
15 15
16HEADERS = \ 16HEADERS = \
17 alarm.h \ 17 alarm.h \
18 attachment.h \ 18 attachment.h \
19 attendee.h \ 19 attendee.h \
20 calendar.h \ 20 calendar.h \
21 calendarlocal.h \ 21 calendarlocal.h \
22 calfilter.h \ 22 calfilter.h \
23 calformat.h \ 23 calformat.h \
24 calstorage.h \ 24 calstorage.h \
25 compat.h \ 25 compat.h \
26 customproperties.h \ 26 customproperties.h \
27 dummyscheduler.h \ 27 dummyscheduler.h \
28 duration.h \ 28 duration.h \
29 event.h \ 29 event.h \
30 exceptions.h \ 30 exceptions.h \
31 filestorage.h \ 31 filestorage.h \
32 freebusy.h \ 32 freebusy.h \
33 icaldrag.h \ 33 icaldrag.h \
34 icalformat.h \ 34 icalformat.h \
35 icalformatimpl.h \ 35 icalformatimpl.h \
36 imipscheduler.h \ 36 imipscheduler.h \
37 incidence.h \ 37 incidence.h \
38 incidencebase.h \ 38 incidencebase.h \
39 journal.h \ 39 journal.h \
40 period.h \ 40 period.h \
41 person.h \ 41 person.h \
42 qtopiaformat.h \ 42 qtopiaformat.h \
43 sharpformat.h \ 43 sharpformat.h \
44 phoneformat.h \
44 recurrence.h \ 45 recurrence.h \
45 scheduler.h \ 46 scheduler.h \
46 todo.h \ 47 todo.h \
47 vcaldrag.h \ 48 vcaldrag.h \
48 vcalformat.h \ 49 vcalformat.h \
49 versit/port.h \ 50 versit/port.h \
50 versit/vcc.h \ 51 versit/vcc.h \
51 versit/vobject.h \ 52 versit/vobject.h \
52 53
53SOURCES = \ 54SOURCES = \
54 alarm.cpp \ 55 alarm.cpp \
55 attachment.cpp \ 56 attachment.cpp \
56 attendee.cpp \ 57 attendee.cpp \
57 calendar.cpp \ 58 calendar.cpp \
58 calendarlocal.cpp \ 59 calendarlocal.cpp \
59 calfilter.cpp \ 60 calfilter.cpp \
60 calformat.cpp \ 61 calformat.cpp \
61 compat.cpp \ 62 compat.cpp \
62 customproperties.cpp \ 63 customproperties.cpp \
63 dummyscheduler.cpp \ 64 dummyscheduler.cpp \
64 duration.cpp \ 65 duration.cpp \
65 event.cpp \ 66 event.cpp \
66 exceptions.cpp \ 67 exceptions.cpp \
67 filestorage.cpp \ 68 filestorage.cpp \
68 freebusy.cpp \ 69 freebusy.cpp \
69 icaldrag.cpp \ 70 icaldrag.cpp \
70 icalformat.cpp \ 71 icalformat.cpp \
71 icalformatimpl.cpp \ 72 icalformatimpl.cpp \
72 imipscheduler.cpp \ 73 imipscheduler.cpp \
73 incidence.cpp \ 74 incidence.cpp \
74 incidencebase.cpp \ 75 incidencebase.cpp \
75 journal.cpp \ 76 journal.cpp \
76 period.cpp \ 77 period.cpp \
77 person.cpp \ 78 person.cpp \
78 qtopiaformat.cpp \ 79 qtopiaformat.cpp \
79 sharpformat.cpp \ 80 sharpformat.cpp \
81 phoneformat.cpp \
80 recurrence.cpp \ 82 recurrence.cpp \
81 scheduler.cpp \ 83 scheduler.cpp \
82 todo.cpp \ 84 todo.cpp \
83 vcaldrag.cpp \ 85 vcaldrag.cpp \
84 vcalformat.cpp \ 86 vcalformat.cpp \
85 versit/vcc.c \ 87 versit/vcc.c \
86 versit/vobject.c \ 88 versit/vobject.c \
87 89
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
new file mode 100644
index 0000000..f78730d
--- a/dev/null
+++ b/libkcal/phoneformat.cpp
@@ -0,0 +1,1359 @@
1/*
2 This file is part of libkcal.
3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20*/
21
22#include <qdatetime.h>
23#include <qstring.h>
24#include <qapplication.h>
25#include <qptrlist.h>
26#include <qregexp.h>
27#include <qmessagebox.h>
28#include <qclipboard.h>
29#include <qfile.h>
30#include <qtextstream.h>
31#include <qtextcodec.h>
32#include <qxml.h>
33#include <qlabel.h>
34
35#include <kdebug.h>
36#include <klocale.h>
37#include <kglobal.h>
38
39#include "calendar.h"
40#include "alarm.h"
41#include "recurrence.h"
42#include "calendarlocal.h"
43
44#include "phoneformat.h"
45
46using namespace KCal;
47
48//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
49// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
50
51//ARSD silentalarm = 0
52// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly
53// 12 RFRQ
54// 13 RPOS pos = 4. monday in month
55// 14 RDYS days: 1 mon/ 2 tue .. 64 sun
56// 15 REND 0 = no end/ 1 = end
57// 16 REDT rec end dt
58//ALSD
59//ALED
60//MDAY
61
62class SharpParser : public QObject
63{
64 public:
65 SharpParser( Calendar *calendar ) : mCalendar( calendar ) {
66 oldCategories = 0;
67 }
68
69 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName )
70 {
71 int i = 1;
72 bool skip = true;
73 int max = attList.count() -2;
74 while ( i < max ) {
75 if ( !attList[i].isEmpty() ) {
76 skip = false;
77 break;
78 }
79 ++i ;
80 }
81 if ( skip )
82 return false;
83 ulong cSum = SharpFormat::getCsum(attList );
84
85 if ( qName == "Event" ) {
86 Event *event;
87 event = existingCalendar->event( attList[0].toInt() );
88 if ( event )
89 event = (Event*)event->clone();
90 else
91 event = new Event;
92 event->setZaurusId( attList[0].toInt() );
93 event->setZaurusUid( cSum );
94 event->setZaurusStat( -2 );
95
96 event->setSummary( attList[2] );
97 event->setLocation( attList[3] );
98 event->setDescription( attList[4] );
99 if ( attList[7] == "1" ) {
100 event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) ));
101 event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 )));
102 event->setFloats( true );
103 } else {
104 event->setFloats( false );
105 event->setDtStart( fromString( attList[5] ) );
106 event->setDtEnd( fromString( attList[6] ));
107 }
108
109 QString rtype = attList[11];
110 if ( rtype != "255" ) {
111 // qDebug("recurs ");
112 QDate startDate = event->dtStart().date();
113
114 QString freqStr = attList[12];
115 int freq = freqStr.toInt();
116
117 QString hasEndDateStr = attList[15] ;
118 bool hasEndDate = hasEndDateStr == "1";
119
120 QString endDateStr = attList[16];
121 QDate endDate = fromString( endDateStr ).date();
122
123 QString weekDaysStr = attList[14];
124 uint weekDaysNum = weekDaysStr.toInt();
125
126 QBitArray weekDays( 7 );
127 int i;
128 int bb = 1;
129 for( i = 1; i <= 7; ++i ) {
130 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
131 bb = 2 << (i-1);
132 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
133 }
134 // qDebug("next ");
135 QString posStr = attList[13];
136 int pos = posStr.toInt();
137 Recurrence *r = event->recurrence();
138
139 if ( rtype == "0" ) {
140 if ( hasEndDate ) r->setDaily( freq, endDate );
141 else r->setDaily( freq, -1 );
142 } else if ( rtype == "1" ) {
143 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
144 else r->setWeekly( freq, weekDays, -1 );
145 } else if ( rtype == "3" ) {
146 if ( hasEndDate )
147 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
148 else
149 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
150 r->addMonthlyDay( startDate.day() );
151 } else if ( rtype == "2" ) {
152 if ( hasEndDate )
153 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
154 else
155 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
156 QBitArray days( 7 );
157 days.fill( false );
158 days.setBit( startDate.dayOfWeek() - 1 );
159 r->addMonthlyPos( pos, days );
160 } else if ( rtype == "4" ) {
161 if ( hasEndDate )
162 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
163 else
164 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
165 r->addYearlyNum( startDate.month() );
166 }
167 }
168
169 QString categoryList = attList[1] ;
170 event->setCategories( lookupCategories( categoryList ) );
171
172 // strange 0 semms to mean: alarm enabled
173 if ( attList[8] == "0" ) {
174 Alarm *alarm;
175 if ( event->alarms().count() > 0 )
176 alarm = event->alarms().first();
177 else {
178 alarm = new Alarm( event );
179 event->addAlarm( alarm );
180 }
181 alarm->setType( Alarm::Audio );
182 alarm->setEnabled( true );
183 int alarmOffset = attList[9].toInt();
184 alarm->setStartOffset( alarmOffset * -60 );
185 }
186
187 mCalendar->addEvent( event);
188 } else if ( qName == "Todo" ) {
189 Todo *todo;
190
191 todo = existingCalendar->todo( attList[0].toInt() );
192 if (todo )
193 todo = (Todo*)todo->clone();
194 else
195 todo = new Todo;
196
197//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1
198// 0 1 2 3 4 5 6 7 8
199//1,,,,,1,4,Loch zumachen,""
200//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" "
201//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes
202
203 todo->setZaurusId( attList[0].toInt() );
204 todo->setZaurusUid( cSum );
205 todo->setZaurusStat( -2 );
206
207 todo->setSummary( attList[7] );
208 todo->setDescription( attList[8]);
209
210 int priority = attList[6].toInt();
211 if ( priority == 0 ) priority = 3;
212 todo->setPriority( priority );
213
214 QString categoryList = attList[1];
215 todo->setCategories( lookupCategories( categoryList ) );
216
217
218
219 QString hasDateStr = attList[3]; // due
220 if ( !hasDateStr.isEmpty() ) {
221 if ( hasDateStr.right(6) == "000000" ) {
222 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) );
223 todo->setFloats( true );
224 }
225 else {
226 todo->setDtDue( fromString( hasDateStr ) );
227 todo->setFloats( false );
228 }
229
230 todo->setHasDueDate( true );
231 }
232 hasDateStr = attList[2];//start
233 if ( !hasDateStr.isEmpty() ) {
234
235 todo->setDtStart( fromString( hasDateStr ) );
236 todo->setHasStartDate( true);
237 } else
238 todo->setHasStartDate( false );
239 hasDateStr = attList[4];//completed
240 if ( !hasDateStr.isEmpty() ) {
241 todo->setCompleted(fromString( hasDateStr ) );
242 }
243 QString completedStr = attList[5];
244 if ( completedStr == "0" )
245 todo->setCompleted( true );
246 else
247 todo->setCompleted( false );
248 mCalendar->addTodo( todo );
249
250 } else if ( qName == "Category" ) {
251 /*
252 QString id = attributes.value( "id" );
253 QString name = attributes.value( "name" );
254 setCategory( id, name );
255 */
256 }
257 //qDebug("end ");
258 return true;
259 }
260
261
262 void setCategoriesList ( QStringList * c )
263 {
264 oldCategories = c;
265 }
266
267 QDateTime fromString ( QString s, bool useTz = true ) {
268 QDateTime dt;
269 int y,m,t,h,min,sec;
270 y = s.mid(0,4).toInt();
271 m = s.mid(4,2).toInt();
272 t = s.mid(6,2).toInt();
273 h = s.mid(9,2).toInt();
274 min = s.mid(11,2).toInt();
275 sec = s.mid(13,2).toInt();
276 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec));
277 int offset = KGlobal::locale()->localTimeOffset( dt );
278 if ( useTz )
279 dt = dt.addSecs ( offset*60);
280 return dt;
281
282 }
283 protected:
284 QDateTime toDateTime( const QString &value )
285 {
286 QDateTime dt;
287 dt.setTime_t( value.toUInt() );
288
289 return dt;
290 }
291
292 QStringList lookupCategories( const QString &categoryList )
293 {
294 QStringList categoryIds = QStringList::split( ";", categoryList );
295 QStringList categories;
296 QStringList::ConstIterator it;
297 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) {
298 QString cate = category( *it );
299 if ( oldCategories ) {
300 if ( ! oldCategories->contains( cate ) )
301 oldCategories->append( cate );
302 }
303 categories.append(cate );
304 }
305 return categories;
306 }
307
308 private:
309 Calendar *mCalendar;
310 QStringList * oldCategories;
311 static QString category( const QString &id )
312 {
313 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id );
314 if ( it == mCategoriesMap.end() ) return id;
315 else return *it;
316 }
317
318 static void setCategory( const QString &id, const QString &name )
319 {
320 mCategoriesMap.insert( id, name );
321 }
322
323 static QMap<QString,QString> mCategoriesMap;
324};
325
326QMap<QString,QString> SharpParser::mCategoriesMap;
327
328SharpFormat::SharpFormat()
329{
330 mCategories = 0;
331}
332
333SharpFormat::~SharpFormat()
334{
335}
336ulong SharpFormat::getCsum( const QStringList & attList)
337{
338 int max = attList.count() -1;
339 ulong cSum = 0;
340 int j,k,i;
341 int add;
342 for ( i = 1; i < max ; ++i ) {
343 QString s = attList[i];
344 if ( ! s.isEmpty() ){
345 j = s.length();
346 for ( k = 0; k < j; ++k ) {
347 int mul = k +1;
348 add = s[k].unicode ();
349 if ( k < 16 )
350 mul = mul * mul;
351 add = add * mul *i*i*i;
352 cSum += add;
353 }
354 }
355 }
356 return cSum;
357
358}
359//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
360#include <stdlib.h>
361#define DEBUGMODE false
362bool SharpFormat::load( Calendar *calendar, Calendar *existngCal )
363{
364
365 GSM_StateMachines;
366 qDebug(" load ");
367 s.opened = false;
368 s.msg = NULL;
369 s.ConfigNum = 0;
370 static char*cp;
371 static INI_Section *cfg = NULL;
372 cfg=GSM_FindGammuRC();
373 int i;
374 for (i = 0; i <= MAX_CONFIG_NUM; i++) {
375 if (cfg!=NULL) {
376 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false);
377 if (cp) di.coding = cp;
378
379 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false);
380 if (s.Config[i].Localize) {
381 s.msg=INI_ReadFile(s.Config[i].Localize, true);
382 } else {
383#if !defined(WIN32) && defined(LOCALE_PATH)
384 locale = setlocale(LC_MESSAGES, NULL);
385 if (locale != NULL) {
386 snprintf(locale_file, 200, "%s/gammu_%c%c.txt",
387 LOCALE_PATH,
388 tolower(locale[0]),
389 tolower(locale[1]));
390 s.msg = INI_ReadFile(locale_file, true);
391 }
392#endif
393 }
394 }
395
396 /* Wanted user specific configuration? */
397
398 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
399
400 s.ConfigNum++;
401
402 /* We want to use only one file descriptor for global and state machine debug output */
403 s.Config[i].UseGlobalDebugFile = true;
404
405
406
407 /* We wanted to read just user specified configuration. */
408 {break;}
409 }
410
411
412
413
414 int error=GSM_InitConnection(&s,3);
415
416
417 qDebug(" init %d %d", error, ERR_NONE);
418 if ( error != ERR_NONE )
419 return false;
420 fromString2Cal( calendar, existngCal, &s, "Event" );
421
422
423 error=GSM_TerminateConnection(&s);
424
425
426#if 0
427
428 bool debug = DEBUGMODE;
429 //debug = true;
430 QString text;
431 QString codec = "utf8";
432 QLabel status ( i18n("Reading events ..."), 0 );
433
434 int w = status.sizeHint().width()+20 ;
435 if ( w < 200 ) w = 200;
436 int h = status.sizeHint().height()+20 ;
437 int dw = QApplication::desktop()->width();
438 int dh = QApplication::desktop()->height();
439 status.setCaption(i18n("Reading DTM Data") );
440 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
441 status.show();
442 status.raise();
443 qApp->processEvents();
444 QString fileName;
445 if ( ! debug ) {
446 fileName = "/tmp/kopitempout";
447 QString command ="db2file datebook -r -c "+ codec + " > " + fileName;
448 system ( command.latin1() );
449 } else {
450 fileName = "/tmp/events.txt";
451
452 }
453 QFile file( fileName );
454 if (!file.open( IO_ReadOnly ) ) {
455 return false;
456
457 }
458 QTextStream ts( &file );
459 ts.setCodec( QTextCodec::codecForName("utf8") );
460 text = ts.read();
461 file.close();
462 status.setText( i18n("Processing events ...") );
463 status.raise();
464 qApp->processEvents();
465 fromString2Cal( calendar, existngCal, text, "Event" );
466 status.setText( i18n("Reading todos ...") );
467 qApp->processEvents();
468 if ( ! debug ) {
469 fileName = "/tmp/kopitempout";
470 QString command = "db2file todo -r -c " + codec+ " > " + fileName;
471 system ( command.latin1() );
472 } else {
473 fileName = "/tmp/todo.txt";
474 }
475 file.setName( fileName );
476 if (!file.open( IO_ReadOnly ) ) {
477 return false;
478
479 }
480 ts.setDevice( &file );
481 text = ts.read();
482 file.close();
483
484 status.setText( i18n("Processing todos ...") );
485 status.raise();
486 qApp->processEvents();
487 fromString2Cal( calendar, existngCal, text, "Todo" );
488#endif
489 return true;
490}
491int SharpFormat::getNumFromRecord( QString answer, Incidence* inc )
492{
493 int retval = -1;
494 QStringList templist;
495 QString tempString;
496 int start = 0;
497 int len = answer.length();
498 int end = answer.find ("\n",start)+1;
499 bool ok = true;
500 start = end;
501 int ccc = 0;
502 while ( start > 0 ) {
503 templist.clear();
504 ok = true;
505 int loopCount = 0;
506 while ( ok ) {
507 ++loopCount;
508 if ( loopCount > 25 ) {
509 qDebug("KO: Error in while loop");
510 ok = false;
511 start = 0;
512 break;
513 }
514 if ( ok )
515 tempString = getPart( answer, ok, start );
516 if ( start >= len || start == 0 ) {
517 start = 0;
518 ok = false;
519 }
520 if ( tempString.right(1) =="\n" )
521 tempString = tempString.left( tempString.length()-1);
522
523 templist.append( tempString );
524 }
525 ++ccc;
526 if ( ccc == 2 && loopCount < 25 ) {
527 start = 0;
528 bool ok;
529 int newnum = templist[0].toInt( &ok );
530 if ( ok && newnum > 0) {
531 retval = newnum;
532 inc->setZaurusId( newnum );
533 inc->setZaurusUid( getCsum( templist ) );
534 inc->setZaurusStat( -4 );
535 }
536 }
537 }
538 //qDebug("getNumFromRecord returning : %d ", retval);
539 return retval;
540}
541bool SharpFormat::save( Calendar *calendar)
542{
543
544 QLabel status ( i18n("Processing/adding events ..."), 0 );
545 int w = status.sizeHint().width()+20 ;
546 if ( w < 200 ) w = 200;
547 int h = status.sizeHint().height()+20 ;
548 int dw = QApplication::desktop()->width();
549 int dh = QApplication::desktop()->height();
550 status.setCaption(i18n("Writing DTM Data") );
551 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
552 status.show();
553 status.raise();
554 qApp->processEvents();
555 bool debug = DEBUGMODE;
556 QString codec = "utf8";
557 QString answer;
558 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n";
559 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n";
560 QString command;
561 QPtrList<Event> er = calendar->rawEvents();
562 Event* ev = er.first();
563 QString fileName = "/tmp/kopitempout";
564 int i = 0;
565 QString changeString = ePrefix;
566 QString deleteString = ePrefix;
567 bool deleteEnt = false;
568 bool changeEnt = false;
569 QString message = i18n("Processing event # ");
570 int procCount = 0;
571 while ( ev ) {
572 //qDebug("i %d ", ++i);
573 if ( ev->zaurusStat() != -2 ) {
574 status.setText ( message + QString::number ( ++procCount ) );
575 qApp->processEvents();
576 QString eString = getEventString( ev );
577 if ( ev->zaurusStat() == -3 ) { // delete
578 // deleting empty strings does not work.
579 // we write first and x and then delete the record with the x
580 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
581 changeString += eString + "\n";
582 deleteString += eString + "\n";
583 deleteEnt = true;
584 changeEnt = true;
585 }
586 else if ( ev->zaurusId() == -1 ) { // add new
587 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
588 system ( command.utf8() );
589 QFile file( fileName );
590 if (!file.open( IO_ReadOnly ) ) {
591 return false;
592
593 }
594 QTextStream ts( &file );
595 ts.setCodec( QTextCodec::codecForName("utf8") );
596 answer = ts.read();
597 file.close();
598 //qDebug("answer \n%s ", answer.latin1());
599 getNumFromRecord( answer, ev ) ;
600
601 }
602 else { // change existing
603 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() );
604 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
605 changeString += eString + "\n";
606 changeEnt = true;
607
608 }
609 }
610 ev = er.next();
611 }
612 status.setText ( i18n("Changing events ...") );
613 qApp->processEvents();
614 //qDebug("changing... ");
615 if ( changeEnt ) {
616 QFile file( fileName );
617 if (!file.open( IO_WriteOnly ) ) {
618 return false;
619
620 }
621 QTextStream ts( &file );
622 ts.setCodec( QTextCodec::codecForName("utf8") );
623 ts << changeString ;
624 file.close();
625 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName;
626 system ( command.latin1() );
627 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
628
629 }
630 status.setText ( i18n("Deleting events ...") );
631 qApp->processEvents();
632 //qDebug("deleting... ");
633 if ( deleteEnt ) {
634 QFile file( fileName );
635 if (!file.open( IO_WriteOnly ) ) {
636 return false;
637
638 }
639 QTextStream ts( &file );
640 ts.setCodec( QTextCodec::codecForName("utf8") );
641 ts << deleteString;
642 file.close();
643 command = "db2file datebook -d -c " + codec+ " < "+ fileName;
644 system ( command.latin1() );
645 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
646 }
647
648
649 changeString = tPrefix;
650 deleteString = tPrefix;
651 status.setText ( i18n("Processing todos ...") );
652 qApp->processEvents();
653 QPtrList<Todo> tl = calendar->rawTodos();
654 Todo* to = tl.first();
655 i = 0;
656 message = i18n("Processing todo # ");
657 procCount = 0;
658 while ( to ) {
659 if ( to->zaurusStat() != -2 ) {
660 status.setText ( message + QString::number ( ++procCount ) );
661 qApp->processEvents();
662 QString eString = getTodoString( to );
663 if ( to->zaurusStat() == -3 ) { // delete
664 // deleting empty strings does not work.
665 // we write first and x and then delete the record with the x
666 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
667 changeString += eString + "\n";
668 deleteString += eString + "\n";
669 deleteEnt = true;
670 changeEnt = true;
671 }
672 else if ( to->zaurusId() == -1 ) { // add new
673 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName;
674 system ( command.utf8() );
675 QFile file( fileName );
676 if (!file.open( IO_ReadOnly ) ) {
677 return false;
678
679 }
680 QTextStream ts( &file );
681 ts.setCodec( QTextCodec::codecForName("utf8") );
682 answer = ts.read();
683 file.close();
684 //qDebug("answer \n%s ", answer.latin1());
685 getNumFromRecord( answer, to ) ;
686
687 }
688 else { // change existing
689 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() );
690 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
691 changeString += eString + "\n";
692 changeEnt = true;
693
694 }
695 }
696
697 to = tl.next();
698 }
699 status.setText ( i18n("Changing todos ...") );
700 qApp->processEvents();
701 //qDebug("changing... ");
702 if ( changeEnt ) {
703 QFile file( fileName );
704 if (!file.open( IO_WriteOnly ) ) {
705 return false;
706
707 }
708 QTextStream ts( &file );
709 ts.setCodec( QTextCodec::codecForName("utf8") );
710 ts << changeString ;
711 file.close();
712 command = "db2file todo -w -g -c " + codec+ " < "+ fileName;
713 system ( command.latin1() );
714 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
715
716 }
717 status.setText ( i18n("Deleting todos ...") );
718 qApp->processEvents();
719 //qDebug("deleting... ");
720 if ( deleteEnt ) {
721 QFile file( fileName );
722 if (!file.open( IO_WriteOnly ) ) {
723 return false;
724
725 }
726 QTextStream ts( &file );
727 ts.setCodec( QTextCodec::codecForName("utf8") );
728 ts << deleteString;
729 file.close();
730 command = "db2file todo -d -c " + codec+ " < "+ fileName;
731 system ( command.latin1() );
732 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
733 }
734
735 return true;
736}
737QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ )
738{
739 QString datestr;
740 QString timestr;
741 int offset = KGlobal::locale()->localTimeOffset( dti );
742 QDateTime dt;
743 if (useTZ)
744 dt = dti.addSecs ( -(offset*60));
745 else
746 dt = dti;
747 if(dt.date().isValid()){
748 const QDate& date = dt.date();
749 datestr.sprintf("%04d%02d%02d",
750 date.year(), date.month(), date.day());
751 }
752 if(dt.time().isValid()){
753 const QTime& time = dt.time();
754 timestr.sprintf("T%02d%02d%02d",
755 time.hour(), time.minute(), time.second());
756 }
757 return datestr + timestr;
758}
759QString SharpFormat::getEventString( Event* event )
760{
761 QStringList list;
762 list.append( QString::number(event->zaurusId() ) );
763 list.append( event->categories().join(",") );
764 if ( !event->summary().isEmpty() )
765 list.append( event->summary() );
766 else
767 list.append("" );
768 if ( !event->location().isEmpty() )
769 list.append( event->location() );
770 else
771 list.append("" );
772 if ( !event->description().isEmpty() )
773 list.append( event->description() );
774 else
775 list.append( "" );
776 if ( event->doesFloat () ) {
777 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false ));
778 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6
779 list.append( "1" );
780
781 }
782 else {
783 list.append( dtToString( event->dtStart()) );
784 list.append( dtToString( event->dtEnd()) ); //6
785 list.append( "0" );
786 }
787 bool noAlarm = true;
788 if ( event->alarms().count() > 0 ) {
789 Alarm * al = event->alarms().first();
790 if ( al->enabled() ) {
791 noAlarm = false;
792 list.append( "0" ); // yes, 0 == alarm
793 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) );
794 if ( al->type() == Alarm::Audio )
795 list.append( "1" ); // type audio
796 else
797 list.append( "0" ); // type silent
798 }
799 }
800 if ( noAlarm ) {
801 list.append( "1" ); // yes, 1 == no alarm
802 list.append( "0" ); // no alarm offset
803 list.append( "1" ); // type
804 }
805 // next is: 11
806 // next is: 11-16 are recurrence
807 Recurrence* rec = event->recurrence();
808
809 bool writeEndDate = false;
810 switch ( rec->doesRecur() )
811 {
812 case Recurrence::rDaily: // 0
813 list.append( "0" );
814 list.append( QString::number( rec->frequency() ));//12
815 list.append( "0" );
816 list.append( "0" );
817 writeEndDate = true;
818 break;
819 case Recurrence::rWeekly:// 1
820 list.append( "1" );
821 list.append( QString::number( rec->frequency()) );//12
822 list.append( "0" );
823 {
824 int days = 0;
825 QBitArray weekDays = rec->days();
826 int i;
827 for( i = 1; i <= 7; ++i ) {
828 if ( weekDays[i-1] ) {
829 days += 1 << (i-1);
830 }
831 }
832 list.append( QString::number( days ) );
833 }
834 //pending weekdays
835 writeEndDate = true;
836
837 break;
838 case Recurrence::rMonthlyPos:// 2
839 list.append( "2" );
840 list.append( QString::number( rec->frequency()) );//12
841
842 writeEndDate = true;
843 {
844 int count = 1;
845 QPtrList<Recurrence::rMonthPos> rmp;
846 rmp = rec->monthPositions();
847 if ( rmp.first()->negative )
848 count = 5 - rmp.first()->rPos - 1;
849 else
850 count = rmp.first()->rPos - 1;
851 list.append( QString::number( count ) );
852
853 }
854
855 list.append( "0" );
856 break;
857 case Recurrence::rMonthlyDay:// 3
858 list.append( "3" );
859 list.append( QString::number( rec->frequency()) );//12
860 list.append( "0" );
861 list.append( "0" );
862 writeEndDate = true;
863 break;
864 case Recurrence::rYearlyMonth://4
865 list.append( "4" );
866 list.append( QString::number( rec->frequency()) );//12
867 list.append( "0" );
868 list.append( "0" );
869 writeEndDate = true;
870 break;
871
872 default:
873 list.append( "255" );
874 list.append( QString() );
875 list.append( "0" );
876 list.append( QString() );
877 list.append( "0" );
878 list.append( "20991231T000000" );
879 break;
880 }
881 if ( writeEndDate ) {
882
883 if ( rec->endDate().isValid() ) { // 15 + 16
884 list.append( "1" );
885 list.append( dtToString( rec->endDate()) );
886 } else {
887 list.append( "0" );
888 list.append( "20991231T000000" );
889 }
890
891 }
892 if ( event->doesFloat () ) {
893 list.append( dtToString( event->dtStart(), false ).left( 8 ));
894 list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6
895
896 }
897 else {
898 list.append( QString() );
899 list.append( QString() );
900
901 }
902 if (event->dtStart().date() == event->dtEnd().date() )
903 list.append( "0" );
904 else
905 list.append( "1" );
906
907
908 for(QStringList::Iterator it=list.begin();
909 it!=list.end(); ++it){
910 QString& s = (*it);
911 s.replace(QRegExp("\""), "\"\"");
912 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
913 s.prepend('\"');
914 s.append('\"');
915 } else if(s.isEmpty() && !s.isNull()){
916 s = "\"\"";
917 }
918 }
919 return list.join(",");
920
921
922}
923QString SharpFormat::getTodoString( Todo* todo )
924{
925 QStringList list;
926 list.append( QString::number( todo->zaurusId() ) );
927 list.append( todo->categories().join(",") );
928
929 if ( todo->hasStartDate() ) {
930 list.append( dtToString( todo->dtStart()) );
931 } else
932 list.append( QString() );
933
934 if ( todo->hasDueDate() ) {
935 QTime tim;
936 if ( todo->doesFloat()) {
937 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ;
938 } else {
939 list.append( dtToString(todo->dtDue() ) );
940 }
941 } else
942 list.append( QString() );
943
944 if ( todo->isCompleted() ) {
945 list.append( dtToString( todo->completed()) );
946 list.append( "0" ); // yes 0 == completed
947 } else {
948 list.append( dtToString( todo->completed()) );
949 list.append( "1" );
950 }
951 list.append( QString::number( todo->priority() ));
952 if( ! todo->summary().isEmpty() )
953 list.append( todo->summary() );
954 else
955 list.append( "" );
956 if (! todo->description().isEmpty() )
957 list.append( todo->description() );
958 else
959 list.append( "" );
960 for(QStringList::Iterator it=list.begin();
961 it!=list.end(); ++it){
962 QString& s = (*it);
963 s.replace(QRegExp("\""), "\"\"");
964 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
965 s.prepend('\"');
966 s.append('\"');
967 } else if(s.isEmpty() && !s.isNull()){
968 s = "\"\"";
969 }
970 }
971 return list.join(",");
972}
973QString SharpFormat::getPart( const QString & text, bool &ok, int &start )
974{
975 //qDebug("start %d ", start);
976
977 QString retval ="";
978 if ( text.at(start) == '"' ) {
979 if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) {
980 start = start +2;
981 if ( text.mid( start,1) == "," ) {
982 start += 1;
983 }
984 retval = "";
985 if ( text.mid( start,1) == "\n" ) {
986 start += 1;
987 ok = false;
988 }
989 return retval;
990 }
991 int hk = start+1;
992 hk = text.find ('"',hk);
993 while ( text.at(hk+1) == '"' )
994 hk = text.find ('"',hk+2);
995 retval = text.mid( start+1, hk-start-1);
996 start = hk+1;
997 retval.replace( QRegExp("\"\""), "\"");
998 if ( text.mid( start,1) == "," ) {
999 start += 1;
1000 }
1001 if ( text.mid( start,1) == "\n" ) {
1002 start += 1;
1003 ok = false;
1004 }
1005 //qDebug("retval***%s*** ",retval.latin1() );
1006 return retval;
1007
1008 } else {
1009 int nl = text.find ("\n",start);
1010 int kom = text.find (',',start);
1011 if ( kom < nl ) {
1012 // qDebug("kom < nl %d ", kom);
1013 retval = text.mid(start, kom-start);
1014 start = kom+1;
1015 return retval;
1016 } else {
1017 if ( nl == kom ) {
1018 // qDebug(" nl == kom ");
1019 start = 0;
1020 ok = false;
1021 return "0";
1022 }
1023 // qDebug(" nl < kom ", nl);
1024 retval = text.mid( start, nl-start);
1025 ok = false;
1026 start = nl+1;
1027 return retval;
1028 }
1029 }
1030}
1031bool SharpFormat::fromString( Calendar *calendar, const QString & text)
1032{
1033 return false;
1034}
1035 bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, GSM_StateMachine*s, const QString & type)
1036{
1037 GSM_Phone_Functions*Phone;
1038
1039 GSM_CalendarEntrynote;
1040 GSM_CalendarEntry*Note;
1041 bool refresh= true;
1042
1043 Phone=s->Phone.Functions;
1044 bool gshutdown = false;
1045 SharpParser handler( calendar );
1046 //handler.setCategoriesList( mCategories );
1047 QStringList templist;
1048 QString tempString;
1049 int start = 0;
1050 int error;
1051 int ccc = 0;
1052 while (!gshutdown && ccc++ < 10 ) {
1053 QString CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY;
1054 templist.clear();
1055 qDebug("count %d ", ccc);
1056 error=Phone->GetNextCalendar(s,&note,refresh);
1057 if (error == ERR_EMPTY) break;
1058
1059 Note = &note;
1060//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
1061// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
1062
1063//ARSD silentalarm = 0
1064// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly
1065// 12 RFRQ
1066// 13 RPOS pos = 4. monday in month
1067// 14 RDYS days: 1 mon/ 2 tue .. 64 sun
1068// 15 REND 0 = no end/ 1 = end
1069// 16 REDT rec end dt
1070//ALSD
1071//ALED
1072//MDAY
1073
1074 CARDID = QString::number( Note->Location ); // 0
1075
1076
1077 int i_age = 0,i;
1078 GSM_DateTime Alarm,DateTime;
1079 GSM_DateTime* dtp;
1080 GSM_MemoryEntry entry;
1081 unsigned char *name;
1082
1083 bool repeating = false;
1084 int repeat_dayofweek = -1;
1085 int repeat_day = -1;
1086 int repeat_weekofmonth = -1;
1087 int repeat_month = -1;
1088 int repeat_frequency = -1;
1089 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
1090 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
1091
1092 Alarm.Year = 0;
1093
1094 repeating = false;
1095 repeat_dayofweek = -1;
1096 repeat_day = -1;
1097 repeat_weekofmonth = -1;
1098 repeat_month = -1;
1099 repeat_frequency = -1;
1100 repeat_startdate.Day= 0;
1101 repeat_stopdate.Day = 0;
1102
1103
1104 switch (Note->Type) {
1105 case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break;
1106 case GSM_CAL_CALL : CATEGORY = QString("Call"); break;
1107 case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break;
1108 case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break;
1109 case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break;
1110 case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break;
1111 case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break;
1112 case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break;
1113 case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break;
1114 case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break;
1115 case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break;
1116 case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break;
1117 case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break;
1118 case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break;
1119 case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break;
1120 case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break;
1121 case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break;
1122 case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break;
1123 case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break;
1124 case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break;
1125 case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break;
1126 case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break;
1127 case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break;
1128 case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break;
1129 case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break;
1130 case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break;
1131 case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break;
1132 case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break;
1133 default : CATEGORY = QString("");
1134 }
1135//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
1136// 0x 1x 2x 3x 4x 5x 6x 7x 8x 9x 10? 11 12 13 14 15 16 17x 18x 19?
1137
1138 MEM1 = "";
1139
1140#if 0
1141
1142 if ( attList[7] == "1" ) {
1143 event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) ));
1144 event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 )));
1145 event->setFloats( true );
1146 } else {
1147 event->setFloats( false );
1148 event->setDtStart( fromString( attList[5] ) );
1149 event->setDtEnd( fromString( attList[6] ));
1150 }
1151
1152
1153
1154typedef struct {
1155 /**
1156 * The difference between local time and GMT in hours
1157 */
1158 int Timezone;
1159
1160 unsigned int Second;
1161 unsigned int Minute;
1162 unsigned int Hour;
1163
1164 unsigned int Day;
1165 /**
1166 * January = 1, February = 2, etc.
1167 */
1168 unsigned int Month;
1169 /**
1170 * Complete year number. Not 03, but 2003
1171 */
1172 unsigned int Year;
1173} GSM_DateTime;
1174
1175 if(dt.date().isValid()){
1176 const QDate& date = dt.date();
1177 datestr.sprintf("%04d%02d%02d",
1178 date.year(), date.month(), date.day());
1179 }
1180 if(dt.time().isValid()){
1181 const QTime& time = dt.time();
1182 timestr.sprintf("T%02d%02d%02d",
1183 time.hour(), time.minute(), time.second());
1184 }
1185 return datestr + timestr;
1186
1187
1188
1189
1190#endif
1191
1192
1193 ADAY = "0";
1194 ARON = "1"; // 1 == disabled
1195 ARMN = "0"; //alarm offset in minutes
1196
1197 for (i=0;i<Note->EntriesNum;i++) {
1198
1199 qDebug(" for ");
1200 switch (Note->Entries[i].EntryType) {
1201 case CAL_START_DATETIME:
1202 dtp = &Note->Entries[i].Date ;
1203
1204 qDebug("hour: %d ", dtp->Hour);
1205 if ( dtp->Hour == -1 ) {
1206 ADAY = "1";
1207 ALSD.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day );
1208 TIM1.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day );
1209 } else {
1210 TIM1.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1211
1212 }
1213 ////printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false));
1214 //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1215 break;
1216 case CAL_END_DATETIME:
1217 dtp = &Note->Entries[i].Date ;
1218 qDebug("hour2: %d ", dtp->Hour);
1219 if ( dtp->Hour == -1 ) {
1220 ADAY = "1";
1221 ALED.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day );
1222 TIM2.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day );
1223 } else {
1224 TIM2.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1225
1226 }
1227 //printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false));
1228 //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1229 break;
1230 case CAL_ALARM_DATETIME:
1231 ARON = "0";
1232 dtp = &Note->Entries[i].Date ;
1233 ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1234 //printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
1235 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1236 break;
1237 case CAL_SILENT_ALARM_DATETIME:
1238 ARON = "0";
1239 dtp = &Note->Entries[i].Date ;
1240 ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1241 //printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
1242 //memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1243 break;
1244 case CAL_RECURRANCE:
1245 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" );
1246 break;
1247 case CAL_TEXT:
1248 DSRP = QString ( (const char*) Note->Entries[i].Text );
1249 break;
1250 case CAL_LOCATION:
1251 PLCE = QString ((const char*) Note->Entries[i].Text );
1252 break;
1253 case CAL_PHONE:
1254 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
1255 break;
1256 case CAL_PRIVATE:
1257 //printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No");
1258 break;
1259 case CAL_CONTACTID:
1260#if 0
1261 entry.Location = Note->Entries[i].Number;
1262 entry.MemoryType = MEM_ME;
1263 error=Phone->GetMemory(&s, &entry);
1264 if (error == ERR_NONE) {
1265 name = GSM_PhonebookGetEntryName(&entry);
1266 if (name != NULL) {
1267 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
1268 } else {
1269 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
1270 }
1271 } else {
1272 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
1273 }
1274#endif
1275 break;
1276 case CAL_REPEAT_DAYOFWEEK:
1277 repeat_dayofweek = Note->Entries[i].Number;
1278 repeating = true;
1279 break;
1280 case CAL_REPEAT_DAY:
1281 repeat_day = Note->Entries[i].Number;
1282 repeating = true;
1283 break;
1284 case CAL_REPEAT_WEEKOFMONTH:
1285 repeat_weekofmonth = Note->Entries[i].Number;
1286 repeating = true;
1287 break;
1288 case CAL_REPEAT_MONTH:
1289 repeat_month = Note->Entries[i].Number;
1290 repeating = true;
1291 break;
1292 case CAL_REPEAT_FREQUENCY:
1293 repeat_frequency = Note->Entries[i].Number;
1294 repeating = true;
1295 break;
1296 case CAL_REPEAT_STARTDATE:
1297 repeat_startdate = Note->Entries[i].Date;
1298 repeating = true;
1299 break;
1300 case CAL_REPEAT_STOPDATE:
1301 repeat_stopdate = Note->Entries[i].Date;
1302 repeating = true;
1303 break;
1304 }
1305 }
1306
1307
1308
1309 if ( ARON == "0" ) {
1310 QDateTime start,alarm;
1311 start = handler.fromString( TIM1 );
1312 alarm = handler.fromString( ARMN );
1313 int min = alarm.secsTo ( start )/60;
1314 ARMN = QString::number ( min );
1315 }
1316
1317 templist.clear();
1318 templist << CARDID << CATEGORY << DSRP << PLCE << MEM1 << TIM1 << TIM2 << ADAY << ARON << ARMN << ARSD << RTYP << RFRQ << RPOS << RDYS << REND << REDT << ALSD << ALED << MDAY;
1319 handler.startElement( existingCalendar, templist, type );
1320 }
1321
1322
1323
1324#if 0
1325 // qDebug("test %s ", text.latin1());
1326 QStringList templist;
1327 QString tempString;
1328 int start = 0;
1329 int len = text.length();
1330 int end = text.find ("\n",start)+1;
1331 bool ok = true;
1332 start = end;
1333 SharpParser handler( calendar );
1334 handler.setCategoriesList( mCategories );
1335 while ( start > 0 ) {
1336 templist.clear();
1337 ok = true;
1338 while ( ok ) {
1339 tempString = getPart( text, ok, start );
1340 if ( start >= len || start == 0 ) {
1341 start = 0;
1342 ok = false;
1343 }
1344 if ( tempString.right(1) =="\n" )
1345 tempString = tempString.left( tempString.length()-1);
1346 //if ( ok )
1347 templist.append( tempString );
1348 //qDebug("%d ---%s---", templist.count(),tempString.latin1() );
1349 }
1350 handler.startElement( existingCalendar, templist, type );
1351 }
1352#endif
1353 return false;
1354}
1355
1356QString SharpFormat::toString( Calendar * )
1357{
1358 return QString::null;
1359}
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
new file mode 100644
index 0000000..f4cb52c
--- a/dev/null
+++ b/libkcal/phoneformat.h
@@ -0,0 +1,65 @@
1/*
2 This file is part of libkcal.
3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20*/
21#ifndef SHARPFORMAT_H
22#define SHARPAFORMAT_H
23
24#include <qstring.h>
25
26#include "scheduler.h"
27
28#include "calformat.h"
29extern "C" {
30#include "gammu.h"
31}
32
33namespace KCal {
34
35/**
36 This class implements the calendar format used by Sharp.
37*/
38
39class SharpFormat : public QObject {
40 public:
41 /** Create new iCalendar format. */
42 SharpFormat();
43 virtual ~SharpFormat();
44
45 bool load( Calendar * ,Calendar *);
46 bool save( Calendar * );
47 void setCategoriesList ( QStringList * cat ){ mCategories = cat; }
48 bool fromString2Cal( Calendar *, Calendar *, GSM_StateMachine*s , const QString & );
49 bool fromString( Calendar *, const QString & );
50 QString toString( Calendar * );
51 static ulong getCsum( const QStringList & );
52
53 private:
54 QString getEventString( Event* );
55 QString getTodoString( Todo* );
56 QString dtToString( const QDateTime& dt, bool useTZ = true );
57
58 QStringList *mCategories;
59 int getNumFromRecord( QString answer,Incidence* inc ) ;
60 QString getPart( const QString & text, bool &ok, int &start );
61};
62
63}
64
65#endif