summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-13 03:53:45 (UTC)
committer zautrix <zautrix>2005-01-13 03:53:45 (UTC)
commit7d00f1441b5e1270dcd447bfb7920dbd3a21503d (patch) (unidiff)
tree8eb3b053e8104914021eff6f39772024784fff64
parent7a4a866cded40032766acb4fe8d02b6347b1d12e (diff)
downloadkdepimpi-7d00f1441b5e1270dcd447bfb7920dbd3a21503d.zip
kdepimpi-7d00f1441b5e1270dcd447bfb7920dbd3a21503d.tar.gz
kdepimpi-7d00f1441b5e1270dcd447bfb7920dbd3a21503d.tar.bz2
sync dialog fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp6
-rw-r--r--libkcal/syncdefines.h6
-rw-r--r--libkdepim/ksyncmanager.cpp10
-rw-r--r--libkdepim/ksyncmanager.h1
-rw-r--r--libkdepim/ksyncprefsdialog.cpp333
-rw-r--r--libkdepim/ksyncprefsdialog.h6
-rw-r--r--libkdepim/ksyncprofile.cpp4
-rw-r--r--libkdepim/ksyncprofile.h3
8 files changed, 218 insertions, 151 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 7ddbe23..363dc32 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,2742 +1,2742 @@
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#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "statusdialog.h" 110#include "statusdialog.h"
111#include "kdatenavigator.h" 111#include "kdatenavigator.h"
112#include "kotodoview.h" 112#include "kotodoview.h"
113#include "datenavigator.h" 113#include "datenavigator.h"
114#include "resourceview.h" 114#include "resourceview.h"
115#include "navigatorbar.h" 115#include "navigatorbar.h"
116#include "searchdialog.h" 116#include "searchdialog.h"
117#include "mainwindow.h" 117#include "mainwindow.h"
118 118
119#include "calendarview.h" 119#include "calendarview.h"
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121#include <qtopia/alarmserver.h> 121#include <qtopia/alarmserver.h>
122#endif 122#endif
123#ifndef _WIN32_ 123#ifndef _WIN32_
124#include <stdlib.h> 124#include <stdlib.h>
125#include <stdio.h> 125#include <stdio.h>
126#include <unistd.h> 126#include <unistd.h>
127#else 127#else
128#include <qprocess.h> 128#include <qprocess.h>
129#endif 129#endif
130 130
131#ifdef DESKTOP_VERSION 131#ifdef DESKTOP_VERSION
132#include <kabc/stdaddressbook.h> 132#include <kabc/stdaddressbook.h>
133#endif 133#endif
134using namespace KOrg; 134using namespace KOrg;
135using namespace KCal; 135using namespace KCal;
136extern int globalFlagBlockAgenda; 136extern int globalFlagBlockAgenda;
137extern int globalFlagBlockStartup; 137extern int globalFlagBlockStartup;
138 138
139 139
140 140
141class KOBeamPrefs : public QDialog 141class KOBeamPrefs : public QDialog
142{ 142{
143 public: 143 public:
144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
145 QDialog( parent, name, true ) 145 QDialog( parent, name, true )
146 { 146 {
147 setCaption( i18n("Beam Options") ); 147 setCaption( i18n("Beam Options") );
148 QVBoxLayout* lay = new QVBoxLayout( this ); 148 QVBoxLayout* lay = new QVBoxLayout( this );
149 lay->setSpacing( 3 ); 149 lay->setSpacing( 3 );
150 lay->setMargin( 3 ); 150 lay->setMargin( 3 );
151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
152 lay->addWidget( format ); 152 lay->addWidget( format );
153 format->setExclusive ( true ) ; 153 format->setExclusive ( true ) ;
154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
155 lay->addWidget( time ); time->setExclusive ( true ) ; 155 lay->addWidget( time ); time->setExclusive ( true ) ;
156 vcal = new QRadioButton(" vCalendar ", format ); 156 vcal = new QRadioButton(" vCalendar ", format );
157 ical = new QRadioButton(" iCalendar ", format ); 157 ical = new QRadioButton(" iCalendar ", format );
158 vcal->setChecked( true ); 158 vcal->setChecked( true );
159 tz = new QRadioButton(i18n(" With timezone "), time ); 159 tz = new QRadioButton(i18n(" With timezone "), time );
160 local = new QRadioButton(i18n(" Local time "), time ); 160 local = new QRadioButton(i18n(" Local time "), time );
161 tz->setChecked( true ); 161 tz->setChecked( true );
162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
163 lay->addWidget( ok ); 163 lay->addWidget( ok );
164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
165 lay->addWidget( cancel ); 165 lay->addWidget( cancel );
166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
168 resize( 200, 200 ); 168 resize( 200, 200 );
169 } 169 }
170 170
171 bool beamVcal() { return vcal->isChecked(); } 171 bool beamVcal() { return vcal->isChecked(); }
172 bool beamLocal() { return local->isChecked(); } 172 bool beamLocal() { return local->isChecked(); }
173private: 173private:
174 QRadioButton* vcal, *ical, *local, *tz; 174 QRadioButton* vcal, *ical, *local, *tz;
175}; 175};
176class KOCatPrefs : public QDialog 176class KOCatPrefs : public QDialog
177{ 177{
178 public: 178 public:
179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
180 QDialog( parent, name, true ) 180 QDialog( parent, name, true )
181 { 181 {
182 setCaption( i18n("Manage new Categories") ); 182 setCaption( i18n("Manage new Categories") );
183 QVBoxLayout* lay = new QVBoxLayout( this ); 183 QVBoxLayout* lay = new QVBoxLayout( this );
184 lay->setSpacing( 3 ); 184 lay->setSpacing( 3 );
185 lay->setMargin( 3 ); 185 lay->setMargin( 3 );
186 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 ); 186 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 );
187 lay->addWidget( lab ); 187 lay->addWidget( lab );
188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
189 lay->addWidget( format ); 189 lay->addWidget( format );
190 format->setExclusive ( true ) ; 190 format->setExclusive ( true ) ;
191 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 191 addCatBut = new QRadioButton(i18n("Add to category list"), format );
192 new QRadioButton(i18n("Remove from Events/Todos"), format ); 192 new QRadioButton(i18n("Remove from Events/Todos"), format );
193 addCatBut->setChecked( true ); 193 addCatBut->setChecked( true );
194 QPushButton * ok = new QPushButton( i18n("OK"), this ); 194 QPushButton * ok = new QPushButton( i18n("OK"), this );
195 lay->addWidget( ok ); 195 lay->addWidget( ok );
196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
197 lay->addWidget( cancel ); 197 lay->addWidget( cancel );
198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
200 resize( 200, 200 ); 200 resize( 200, 200 );
201 } 201 }
202 202
203 bool addCat() { return addCatBut->isChecked(); } 203 bool addCat() { return addCatBut->isChecked(); }
204private: 204private:
205 QRadioButton* addCatBut; 205 QRadioButton* addCatBut;
206}; 206};
207 207
208 208
209 209
210CalendarView::CalendarView( CalendarResources *calendar, 210CalendarView::CalendarView( CalendarResources *calendar,
211 QWidget *parent, const char *name ) 211 QWidget *parent, const char *name )
212 : CalendarViewBase( parent, name ), 212 : CalendarViewBase( parent, name ),
213 mCalendar( calendar ), 213 mCalendar( calendar ),
214 mResourceManager( calendar->resourceManager() ) 214 mResourceManager( calendar->resourceManager() )
215{ 215{
216 216
217 mEventEditor = 0; 217 mEventEditor = 0;
218 mTodoEditor = 0; 218 mTodoEditor = 0;
219 219
220 init(); 220 init();
221} 221}
222 222
223CalendarView::CalendarView( Calendar *calendar, 223CalendarView::CalendarView( Calendar *calendar,
224 QWidget *parent, const char *name ) 224 QWidget *parent, const char *name )
225 : CalendarViewBase( parent, name ), 225 : CalendarViewBase( parent, name ),
226 mCalendar( calendar ), 226 mCalendar( calendar ),
227 mResourceManager( 0 ) 227 mResourceManager( 0 )
228{ 228{
229 229
230 mEventEditor = 0; 230 mEventEditor = 0;
231 mTodoEditor = 0; 231 mTodoEditor = 0;
232 init();} 232 init();}
233 233
234void CalendarView::init() 234void CalendarView::init()
235{ 235{
236 beamDialog = new KOBeamPrefs(); 236 beamDialog = new KOBeamPrefs();
237 mDatePickerMode = 0; 237 mDatePickerMode = 0;
238 mCurrentSyncDevice = ""; 238 mCurrentSyncDevice = "";
239 writeLocale(); 239 writeLocale();
240 mViewManager = new KOViewManager( this ); 240 mViewManager = new KOViewManager( this );
241 mDialogManager = new KODialogManager( this ); 241 mDialogManager = new KODialogManager( this );
242 mEventViewerDialog = 0; 242 mEventViewerDialog = 0;
243 mModified = false; 243 mModified = false;
244 mReadOnly = false; 244 mReadOnly = false;
245 mSelectedIncidence = 0; 245 mSelectedIncidence = 0;
246 mCalPrinter = 0; 246 mCalPrinter = 0;
247 mFilters.setAutoDelete(true); 247 mFilters.setAutoDelete(true);
248 248
249 mCalendar->registerObserver( this ); 249 mCalendar->registerObserver( this );
250 // TODO: Make sure that view is updated, when calendar is changed. 250 // TODO: Make sure that view is updated, when calendar is changed.
251 251
252 mStorage = new FileStorage( mCalendar ); 252 mStorage = new FileStorage( mCalendar );
253 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 253 mNavigator = new DateNavigator( this, "datevav", mViewManager );
254 254
255 QBoxLayout *topLayout = (QBoxLayout*)layout(); 255 QBoxLayout *topLayout = (QBoxLayout*)layout();
256#ifndef KORG_NOSPLITTER 256#ifndef KORG_NOSPLITTER
257 // create the main layout frames. 257 // create the main layout frames.
258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
259 topLayout->addWidget(mPanner); 259 topLayout->addWidget(mPanner);
260 260
261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
262 "CalendarView::LeftFrame"); 262 "CalendarView::LeftFrame");
263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
264 264
265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
266 "CalendarView::DateNavigator", QDate::currentDate() ); 266 "CalendarView::DateNavigator", QDate::currentDate() );
267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
269 mTodoList->setNavigator( mNavigator ); 269 mTodoList->setNavigator( mNavigator );
270 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 270 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
271 271
272#ifdef KORG_NORESOURCEVIEW 272#ifdef KORG_NORESOURCEVIEW
273 mResourceView = 0; 273 mResourceView = 0;
274#else 274#else
275 if ( mResourceManager ) { 275 if ( mResourceManager ) {
276 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 276 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
277 mResourceView->updateView(); 277 mResourceView->updateView();
278 connect( mResourceView, SIGNAL( resourcesChanged() ), 278 connect( mResourceView, SIGNAL( resourcesChanged() ),
279 SLOT( updateView() ) ); 279 SLOT( updateView() ) );
280 } else { 280 } else {
281 mResourceView = 0; 281 mResourceView = 0;
282 } 282 }
283#endif 283#endif
284 QWidget *rightBox = new QWidget( mPanner ); 284 QWidget *rightBox = new QWidget( mPanner );
285 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 285 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
286 286
287 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 287 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
288 rightLayout->addWidget( mNavigatorBar ); 288 rightLayout->addWidget( mNavigatorBar );
289 289
290 mRightFrame = new QWidgetStack( rightBox ); 290 mRightFrame = new QWidgetStack( rightBox );
291 rightLayout->addWidget( mRightFrame, 1 ); 291 rightLayout->addWidget( mRightFrame, 1 );
292 292
293 mLeftFrame = mLeftSplitter; 293 mLeftFrame = mLeftSplitter;
294#else 294#else
295 QWidget *mainBox = new QWidget( this ); 295 QWidget *mainBox = new QWidget( this );
296 QWidget *leftFrame = new QWidget( mainBox ); 296 QWidget *leftFrame = new QWidget( mainBox );
297 297
298 QBoxLayout * mainBoxLayout; 298 QBoxLayout * mainBoxLayout;
299 QBoxLayout * leftFrameLayout; 299 QBoxLayout * leftFrameLayout;
300 if ( KOPrefs::instance()->mVerticalScreen ) { 300 if ( KOPrefs::instance()->mVerticalScreen ) {
301 mainBoxLayout = new QVBoxLayout(mainBox); 301 mainBoxLayout = new QVBoxLayout(mainBox);
302 leftFrameLayout = new QHBoxLayout(leftFrame ); 302 leftFrameLayout = new QHBoxLayout(leftFrame );
303 } else { 303 } else {
304 mainBoxLayout = new QHBoxLayout(mainBox); 304 mainBoxLayout = new QHBoxLayout(mainBox);
305 leftFrameLayout = new QVBoxLayout(leftFrame ); 305 leftFrameLayout = new QVBoxLayout(leftFrame );
306 } 306 }
307 topLayout->addWidget( mainBox ); 307 topLayout->addWidget( mainBox );
308 mainBoxLayout->addWidget (leftFrame); 308 mainBoxLayout->addWidget (leftFrame);
309 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 309 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
310 "CalendarView::DateNavigator", QDate::currentDate()); 310 "CalendarView::DateNavigator", QDate::currentDate());
311 // mDateNavigator->blockSignals( true ); 311 // mDateNavigator->blockSignals( true );
312 leftFrameLayout->addWidget( mDateNavigator ); 312 leftFrameLayout->addWidget( mDateNavigator );
313 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 313 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
314 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 314 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
315 mTodoList->setNavigator( mNavigator ); 315 mTodoList->setNavigator( mNavigator );
316 316
317 if ( QApplication::desktop()->width() < 480 ) { 317 if ( QApplication::desktop()->width() < 480 ) {
318 leftFrameLayout->addWidget(mFilterView); 318 leftFrameLayout->addWidget(mFilterView);
319 leftFrameLayout->addWidget(mTodoList, 2 ); 319 leftFrameLayout->addWidget(mTodoList, 2 );
320 320
321 } else { 321 } else {
322 leftFrameLayout->addWidget(mTodoList,2 ); 322 leftFrameLayout->addWidget(mTodoList,2 );
323 leftFrameLayout->addWidget(mFilterView ); 323 leftFrameLayout->addWidget(mFilterView );
324 } 324 }
325 mFilterView->hide(); 325 mFilterView->hide();
326 QWidget *rightBox = new QWidget( mainBox ); 326 QWidget *rightBox = new QWidget( mainBox );
327 mainBoxLayout->addWidget ( rightBox, 10 ); 327 mainBoxLayout->addWidget ( rightBox, 10 );
328 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 328 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
329 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 329 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
330 mRightFrame = new QWidgetStack( rightBox ); 330 mRightFrame = new QWidgetStack( rightBox );
331 rightLayout->addWidget( mNavigatorBar ); 331 rightLayout->addWidget( mNavigatorBar );
332 rightLayout->addWidget( mRightFrame, 10 ); 332 rightLayout->addWidget( mRightFrame, 10 );
333 333
334 mLeftFrame = leftFrame; 334 mLeftFrame = leftFrame;
335 if ( KOPrefs::instance()->mVerticalScreen ) { 335 if ( KOPrefs::instance()->mVerticalScreen ) {
336 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 336 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
337 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 337 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
338 } else { 338 } else {
339 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 339 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
340 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 340 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
341 } 341 }
342 342
343 //qDebug("Calendarview Size %d %d ", width(), height()); 343 //qDebug("Calendarview Size %d %d ", width(), height());
344#endif 344#endif
345 345
346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
347 SLOT( showDates( const KCal::DateList & ) ) ); 347 SLOT( showDates( const KCal::DateList & ) ) );
348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
349 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 349 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
350 350
351 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 351 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
352 mNavigator, SLOT( selectPreviousYear() ) ); 352 mNavigator, SLOT( selectPreviousYear() ) );
353 connect( mNavigatorBar, SIGNAL( goNextYear() ), 353 connect( mNavigatorBar, SIGNAL( goNextYear() ),
354 mNavigator, SLOT( selectNextYear() ) ); 354 mNavigator, SLOT( selectNextYear() ) );
355 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 355 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
356 mNavigator, SLOT( selectPreviousMonth() ) ); 356 mNavigator, SLOT( selectPreviousMonth() ) );
357 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 357 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
358 mNavigator, SLOT( selectNextMonth() ) ); 358 mNavigator, SLOT( selectNextMonth() ) );
359 359
360 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 360 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
361 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 361 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
362 362
363 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 363 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
364 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 364 mNavigator, SLOT( selectWeek( const QDate & ) ) );
365 365
366 connect( mDateNavigator, SIGNAL( goPrevYear() ), 366 connect( mDateNavigator, SIGNAL( goPrevYear() ),
367 mNavigator, SLOT( selectPreviousYear() ) ); 367 mNavigator, SLOT( selectPreviousYear() ) );
368 connect( mDateNavigator, SIGNAL( goNextYear() ), 368 connect( mDateNavigator, SIGNAL( goNextYear() ),
369 mNavigator, SLOT( selectNextYear() ) ); 369 mNavigator, SLOT( selectNextYear() ) );
370 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 370 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
371 mNavigator, SLOT( selectPreviousMonth() ) ); 371 mNavigator, SLOT( selectPreviousMonth() ) );
372 connect( mDateNavigator, SIGNAL( goNextMonth() ), 372 connect( mDateNavigator, SIGNAL( goNextMonth() ),
373 mNavigator, SLOT( selectNextMonth() ) ); 373 mNavigator, SLOT( selectNextMonth() ) );
374 374
375 connect( mDateNavigator, SIGNAL( goPrevious() ), 375 connect( mDateNavigator, SIGNAL( goPrevious() ),
376 mNavigator, SLOT( selectPrevious() ) ); 376 mNavigator, SLOT( selectPrevious() ) );
377 connect( mDateNavigator, SIGNAL( goNext() ), 377 connect( mDateNavigator, SIGNAL( goNext() ),
378 mNavigator, SLOT( selectNext() ) ); 378 mNavigator, SLOT( selectNext() ) );
379 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 379 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
380 mNavigator, SLOT( slotMonthSelect( int ) ) ); 380 mNavigator, SLOT( slotMonthSelect( int ) ) );
381 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 381 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
382 mNavigator, SLOT( slotMonthSelect( int ) ) ); 382 mNavigator, SLOT( slotMonthSelect( int ) ) );
383 383
384 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 384 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
385 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 385 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
386 386
387 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 387 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
388 SLOT( eventAdded( Event *) ) ); 388 SLOT( eventAdded( Event *) ) );
389 389
390 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 390 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
391 391
392 connect( this, SIGNAL( configChanged() ), 392 connect( this, SIGNAL( configChanged() ),
393 mDateNavigator, SLOT( updateConfig() ) ); 393 mDateNavigator, SLOT( updateConfig() ) );
394 394
395 connect( mTodoList, SIGNAL( newTodoSignal() ), 395 connect( mTodoList, SIGNAL( newTodoSignal() ),
396 SLOT( newTodo() ) ); 396 SLOT( newTodo() ) );
397 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 397 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
398 SLOT( newSubTodo( Todo * ) ) ); 398 SLOT( newSubTodo( Todo * ) ) );
399 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 399 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
400 SLOT( editTodo( Todo * ) ) ); 400 SLOT( editTodo( Todo * ) ) );
401 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 401 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
402 SLOT( showTodo( Todo *) ) ); 402 SLOT( showTodo( Todo *) ) );
403 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 403 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
404 SLOT( deleteTodo( Todo *) ) ); 404 SLOT( deleteTodo( Todo *) ) );
405 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 405 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
406 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 406 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
407 SLOT( purgeCompleted() ) ); 407 SLOT( purgeCompleted() ) );
408 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 408 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
409 SIGNAL( todoModified( Todo *, int ) ) ); 409 SIGNAL( todoModified( Todo *, int ) ) );
410 410
411 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 411 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
412 this, SLOT ( cloneIncidence( Incidence * ) ) ); 412 this, SLOT ( cloneIncidence( Incidence * ) ) );
413 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 413 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
414 this, SLOT (cancelIncidence( Incidence * ) ) ); 414 this, SLOT (cancelIncidence( Incidence * ) ) );
415 415
416 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 416 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
417 this, SLOT ( moveIncidence( Incidence * ) ) ); 417 this, SLOT ( moveIncidence( Incidence * ) ) );
418 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 418 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
419 this, SLOT ( beamIncidence( Incidence * ) ) ); 419 this, SLOT ( beamIncidence( Incidence * ) ) );
420 420
421 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 421 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
422 this, SLOT ( todo_unsub( Todo * ) ) ); 422 this, SLOT ( todo_unsub( Todo * ) ) );
423 423
424 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 424 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
425 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 425 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
426 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 426 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
427 SLOT( updateTodo( Todo *, int ) ) ); 427 SLOT( updateTodo( Todo *, int ) ) );
428 connect( this, SIGNAL( todoModified( Todo *, int )), this, 428 connect( this, SIGNAL( todoModified( Todo *, int )), this,
429 SLOT( changeTodoDisplay( Todo *, int ) ) ); 429 SLOT( changeTodoDisplay( Todo *, int ) ) );
430 430
431 431
432 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 432 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
433 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 433 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
434 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 434 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
435 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 435 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
436 436
437 437
438 438
439 439
440 440
441 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 441 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
442 SLOT(checkClipboard())); 442 SLOT(checkClipboard()));
443 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 443 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
444 SLOT( processTodoListSelection( Incidence * ) ) ); 444 SLOT( processTodoListSelection( Incidence * ) ) );
445 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 445 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
446 446
447 // kdDebug() << "CalendarView::CalendarView() done" << endl; 447 // kdDebug() << "CalendarView::CalendarView() done" << endl;
448 448
449 mDateFrame = new QVBox(0,0,WType_Popup); 449 mDateFrame = new QVBox(0,0,WType_Popup);
450 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 450 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
451 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 451 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
452 mDateFrame->setLineWidth(3); 452 mDateFrame->setLineWidth(3);
453 mDateFrame->hide(); 453 mDateFrame->hide();
454 mDateFrame->setCaption( i18n( "Pick a date to display")); 454 mDateFrame->setCaption( i18n( "Pick a date to display"));
455 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 455 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
456 456
457 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 457 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
458 458
459 mEventEditor = mDialogManager->getEventEditor(); 459 mEventEditor = mDialogManager->getEventEditor();
460 mTodoEditor = mDialogManager->getTodoEditor(); 460 mTodoEditor = mDialogManager->getTodoEditor();
461 461
462 mFlagEditDescription = false; 462 mFlagEditDescription = false;
463 463
464 mSuspendTimer = new QTimer( this ); 464 mSuspendTimer = new QTimer( this );
465 mAlarmTimer = new QTimer( this ); 465 mAlarmTimer = new QTimer( this );
466 mRecheckAlarmTimer = new QTimer( this ); 466 mRecheckAlarmTimer = new QTimer( this );
467 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 467 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
468 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 468 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
469 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 469 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
470 mAlarmDialog = new AlarmDialog( this ); 470 mAlarmDialog = new AlarmDialog( this );
471 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 471 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
472 mAlarmDialog->setServerNotification( false ); 472 mAlarmDialog->setServerNotification( false );
473 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 473 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
474 474
475 475
476#ifndef DESKTOP_VERSION 476#ifndef DESKTOP_VERSION
477//US listen for arriving address resultsets 477//US listen for arriving address resultsets
478 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 478 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
479 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 479 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
480#endif 480#endif
481 481
482} 482}
483 483
484 484
485CalendarView::~CalendarView() 485CalendarView::~CalendarView()
486{ 486{
487 // kdDebug() << "~CalendarView()" << endl; 487 // kdDebug() << "~CalendarView()" << endl;
488 //qDebug("CalendarView::~CalendarView() "); 488 //qDebug("CalendarView::~CalendarView() ");
489 delete mDialogManager; 489 delete mDialogManager;
490 delete mViewManager; 490 delete mViewManager;
491 delete mStorage; 491 delete mStorage;
492 delete mDateFrame ; 492 delete mDateFrame ;
493 delete beamDialog; 493 delete beamDialog;
494 //kdDebug() << "~CalendarView() done" << endl; 494 //kdDebug() << "~CalendarView() done" << endl;
495} 495}
496 496
497void CalendarView::showDay( QDate d ) 497void CalendarView::showDay( QDate d )
498{ 498{
499 dateNavigator()->selectDate( d ); 499 dateNavigator()->selectDate( d );
500 mViewManager->showWeekView(); 500 mViewManager->showWeekView();
501 dateNavigator()->selectDate( d ); 501 dateNavigator()->selectDate( d );
502} 502}
503void CalendarView::timerAlarm() 503void CalendarView::timerAlarm()
504{ 504{
505 //qDebug("CalendarView::timerAlarm() "); 505 //qDebug("CalendarView::timerAlarm() ");
506 computeAlarm(mAlarmNotification ); 506 computeAlarm(mAlarmNotification );
507} 507}
508 508
509void CalendarView::suspendAlarm() 509void CalendarView::suspendAlarm()
510{ 510{
511 //qDebug(" CalendarView::suspendAlarm() "); 511 //qDebug(" CalendarView::suspendAlarm() ");
512 computeAlarm(mSuspendAlarmNotification ); 512 computeAlarm(mSuspendAlarmNotification );
513 513
514} 514}
515 515
516void CalendarView::startAlarm( QString mess , QString filename) 516void CalendarView::startAlarm( QString mess , QString filename)
517{ 517{
518 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 518 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
519 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 519 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
520 520
521} 521}
522 522
523void CalendarView::checkNextTimerAlarm() 523void CalendarView::checkNextTimerAlarm()
524{ 524{
525 mCalendar->checkAlarmForIncidence( 0, true ); 525 mCalendar->checkAlarmForIncidence( 0, true );
526} 526}
527 527
528void CalendarView::computeAlarm( QString msg ) 528void CalendarView::computeAlarm( QString msg )
529{ 529{
530 530
531 QString mess = msg; 531 QString mess = msg;
532 QString mAlarmMessage = mess.mid( 9 ); 532 QString mAlarmMessage = mess.mid( 9 );
533 QString filename = MainWindow::resourcePath(); 533 QString filename = MainWindow::resourcePath();
534 filename += "koalarm.wav"; 534 filename += "koalarm.wav";
535 QString tempfilename; 535 QString tempfilename;
536 if ( mess.left( 13 ) == "suspend_alarm") { 536 if ( mess.left( 13 ) == "suspend_alarm") {
537 bool error = false; 537 bool error = false;
538 int len = mess.mid( 13 ).find("+++"); 538 int len = mess.mid( 13 ).find("+++");
539 if ( len < 2 ) 539 if ( len < 2 )
540 error = true; 540 error = true;
541 else { 541 else {
542 tempfilename = mess.mid( 13, len ); 542 tempfilename = mess.mid( 13, len );
543 if ( !QFile::exists( tempfilename ) ) 543 if ( !QFile::exists( tempfilename ) )
544 error = true; 544 error = true;
545 } 545 }
546 if ( ! error ) { 546 if ( ! error ) {
547 filename = tempfilename; 547 filename = tempfilename;
548 } 548 }
549 mAlarmMessage = mess.mid( 13+len+3 ); 549 mAlarmMessage = mess.mid( 13+len+3 );
550 //qDebug("suspend file %s ",tempfilename.latin1() ); 550 //qDebug("suspend file %s ",tempfilename.latin1() );
551 startAlarm( mAlarmMessage, filename); 551 startAlarm( mAlarmMessage, filename);
552 return; 552 return;
553 } 553 }
554 if ( mess.left( 11 ) == "timer_alarm") { 554 if ( mess.left( 11 ) == "timer_alarm") {
555 //mTimerTime = 0; 555 //mTimerTime = 0;
556 startAlarm( mess.mid( 11 ), filename ); 556 startAlarm( mess.mid( 11 ), filename );
557 return; 557 return;
558 } 558 }
559 if ( mess.left( 10 ) == "proc_alarm") { 559 if ( mess.left( 10 ) == "proc_alarm") {
560 bool error = false; 560 bool error = false;
561 int len = mess.mid( 10 ).find("+++"); 561 int len = mess.mid( 10 ).find("+++");
562 if ( len < 2 ) 562 if ( len < 2 )
563 error = true; 563 error = true;
564 else { 564 else {
565 tempfilename = mess.mid( 10, len ); 565 tempfilename = mess.mid( 10, len );
566 if ( !QFile::exists( tempfilename ) ) 566 if ( !QFile::exists( tempfilename ) )
567 error = true; 567 error = true;
568 } 568 }
569 if ( error ) { 569 if ( error ) {
570 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 570 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
571 mAlarmMessage += mess.mid( 10+len+3+9 ); 571 mAlarmMessage += mess.mid( 10+len+3+9 );
572 } else { 572 } else {
573 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 573 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
574 //qDebug("-----system command %s ",tempfilename.latin1() ); 574 //qDebug("-----system command %s ",tempfilename.latin1() );
575#ifndef _WIN32_ 575#ifndef _WIN32_
576 if ( vfork () == 0 ) { 576 if ( vfork () == 0 ) {
577 execl ( tempfilename.latin1(), 0 ); 577 execl ( tempfilename.latin1(), 0 );
578 return; 578 return;
579 } 579 }
580#else 580#else
581 QProcess* p = new QProcess(); 581 QProcess* p = new QProcess();
582 p->addArgument( tempfilename.latin1() ); 582 p->addArgument( tempfilename.latin1() );
583 p->start(); 583 p->start();
584 return; 584 return;
585#endif 585#endif
586 586
587 return; 587 return;
588 } 588 }
589 589
590 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 590 //qDebug("+++++++system command %s ",tempfilename.latin1() );
591 } 591 }
592 if ( mess.left( 11 ) == "audio_alarm") { 592 if ( mess.left( 11 ) == "audio_alarm") {
593 bool error = false; 593 bool error = false;
594 int len = mess.mid( 11 ).find("+++"); 594 int len = mess.mid( 11 ).find("+++");
595 if ( len < 2 ) 595 if ( len < 2 )
596 error = true; 596 error = true;
597 else { 597 else {
598 tempfilename = mess.mid( 11, len ); 598 tempfilename = mess.mid( 11, len );
599 if ( !QFile::exists( tempfilename ) ) 599 if ( !QFile::exists( tempfilename ) )
600 error = true; 600 error = true;
601 } 601 }
602 if ( ! error ) { 602 if ( ! error ) {
603 filename = tempfilename; 603 filename = tempfilename;
604 } 604 }
605 mAlarmMessage = mess.mid( 11+len+3+9 ); 605 mAlarmMessage = mess.mid( 11+len+3+9 );
606 //qDebug("audio file command %s ",tempfilename.latin1() ); 606 //qDebug("audio file command %s ",tempfilename.latin1() );
607 } 607 }
608 if ( mess.left( 9 ) == "cal_alarm") { 608 if ( mess.left( 9 ) == "cal_alarm") {
609 mAlarmMessage = mess.mid( 9 ) ; 609 mAlarmMessage = mess.mid( 9 ) ;
610 } 610 }
611 611
612 startAlarm( mAlarmMessage, filename ); 612 startAlarm( mAlarmMessage, filename );
613 613
614 614
615} 615}
616 616
617void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 617void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
618{ 618{
619 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 619 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
620 620
621 mSuspendAlarmNotification = noti; 621 mSuspendAlarmNotification = noti;
622 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 622 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
623 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 623 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
624 mSuspendTimer->start( ms , true ); 624 mSuspendTimer->start( ms , true );
625 625
626} 626}
627 627
628void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 628void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
629{ 629{
630 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 630 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
631 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 631 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
632#ifndef DESKTOP_VERSION 632#ifndef DESKTOP_VERSION
633 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 633 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
634#endif 634#endif
635 return; 635 return;
636 } 636 }
637 int maxSec; 637 int maxSec;
638 //maxSec = 5; //testing only 638 //maxSec = 5; //testing only
639 maxSec = 86400+3600; // one day+1hour 639 maxSec = 86400+3600; // one day+1hour
640 mAlarmNotification = noti; 640 mAlarmNotification = noti;
641 int sec = QDateTime::currentDateTime().secsTo( qdt ); 641 int sec = QDateTime::currentDateTime().secsTo( qdt );
642 if ( sec > maxSec ) { 642 if ( sec > maxSec ) {
643 mRecheckAlarmTimer->start( maxSec * 1000 ); 643 mRecheckAlarmTimer->start( maxSec * 1000 );
644 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 644 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
645 return; 645 return;
646 } else { 646 } else {
647 mRecheckAlarmTimer->stop(); 647 mRecheckAlarmTimer->stop();
648 } 648 }
649 //qDebug("Alarm timer started with secs: %d ", sec); 649 //qDebug("Alarm timer started with secs: %d ", sec);
650 mAlarmTimer->start( sec *1000 , true ); 650 mAlarmTimer->start( sec *1000 , true );
651 651
652} 652}
653// called by mRecheckAlarmTimer to get next alarm 653// called by mRecheckAlarmTimer to get next alarm
654// we need this, because a QTimer has only a max range of 25 days 654// we need this, because a QTimer has only a max range of 25 days
655void CalendarView::recheckTimerAlarm() 655void CalendarView::recheckTimerAlarm()
656{ 656{
657 mAlarmTimer->stop(); 657 mAlarmTimer->stop();
658 mRecheckAlarmTimer->stop(); 658 mRecheckAlarmTimer->stop();
659 mCalendar->checkAlarmForIncidence( 0, true ); 659 mCalendar->checkAlarmForIncidence( 0, true );
660} 660}
661void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 661void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
662{ 662{
663 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 663 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
664 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 664 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
665#ifndef DESKTOP_VERSION 665#ifndef DESKTOP_VERSION
666 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 666 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
667#endif 667#endif
668 return; 668 return;
669 } 669 }
670 mAlarmTimer->stop(); 670 mAlarmTimer->stop();
671} 671}
672void CalendarView::selectWeekNum ( int num ) 672void CalendarView::selectWeekNum ( int num )
673{ 673{
674 dateNavigator()->selectWeek( num ); 674 dateNavigator()->selectWeek( num );
675 mViewManager->showWeekView(); 675 mViewManager->showWeekView();
676} 676}
677KOViewManager *CalendarView::viewManager() 677KOViewManager *CalendarView::viewManager()
678{ 678{
679 return mViewManager; 679 return mViewManager;
680} 680}
681 681
682KODialogManager *CalendarView::dialogManager() 682KODialogManager *CalendarView::dialogManager()
683{ 683{
684 return mDialogManager; 684 return mDialogManager;
685} 685}
686 686
687QDate CalendarView::startDate() 687QDate CalendarView::startDate()
688{ 688{
689 DateList dates = mNavigator->selectedDates(); 689 DateList dates = mNavigator->selectedDates();
690 690
691 return dates.first(); 691 return dates.first();
692} 692}
693 693
694QDate CalendarView::endDate() 694QDate CalendarView::endDate()
695{ 695{
696 DateList dates = mNavigator->selectedDates(); 696 DateList dates = mNavigator->selectedDates();
697 697
698 return dates.last(); 698 return dates.last();
699} 699}
700 700
701 701
702void CalendarView::createPrinter() 702void CalendarView::createPrinter()
703{ 703{
704#ifndef KORG_NOPRINTER 704#ifndef KORG_NOPRINTER
705 if (!mCalPrinter) { 705 if (!mCalPrinter) {
706 mCalPrinter = new CalPrinter(this, mCalendar); 706 mCalPrinter = new CalPrinter(this, mCalendar);
707 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 707 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
708 } 708 }
709#endif 709#endif
710} 710}
711 711
712 712
713//KOPrefs::instance()->mWriteBackFile 713//KOPrefs::instance()->mWriteBackFile
714//KOPrefs::instance()->mWriteBackExistingOnly 714//KOPrefs::instance()->mWriteBackExistingOnly
715 715
716// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 716// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
717// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 717// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
718// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 718// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
719// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 719// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
720// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 720// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
721// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 721// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
722 722
723int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 723int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
724{ 724{
725 725
726 // 0 equal 726 // 0 equal
727 // 1 take local 727 // 1 take local
728 // 2 take remote 728 // 2 take remote
729 // 3 cancel 729 // 3 cancel
730 QDateTime lastSync = mLastCalendarSync; 730 QDateTime lastSync = mLastCalendarSync;
731 QDateTime localMod = local->lastModified(); 731 QDateTime localMod = local->lastModified();
732 QDateTime remoteMod = remote->lastModified(); 732 QDateTime remoteMod = remote->lastModified();
733 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 733 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
734 bool remCh, locCh; 734 bool remCh, locCh;
735 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 735 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
736 //if ( remCh ) 736 //if ( remCh )
737 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 737 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
738 locCh = ( localMod > mLastCalendarSync ); 738 locCh = ( localMod > mLastCalendarSync );
739 if ( !remCh && ! locCh ) { 739 if ( !remCh && ! locCh ) {
740 //qDebug("both not changed "); 740 //qDebug("both not changed ");
741 lastSync = localMod.addDays(1); 741 lastSync = localMod.addDays(1);
742 if ( mode <= SYNC_PREF_ASK ) 742 if ( mode <= SYNC_PREF_ASK )
743 return 0; 743 return 0;
744 } else { 744 } else {
745 if ( locCh ) { 745 if ( locCh ) {
746 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 746 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
747 lastSync = localMod.addDays( -1 ); 747 lastSync = localMod.addDays( -1 );
748 if ( !remCh ) 748 if ( !remCh )
749 remoteMod = ( lastSync.addDays( -1 ) ); 749 remoteMod = ( lastSync.addDays( -1 ) );
750 } else { 750 } else {
751 //qDebug(" not loc changed "); 751 //qDebug(" not loc changed ");
752 lastSync = localMod.addDays( 1 ); 752 lastSync = localMod.addDays( 1 );
753 if ( remCh ) 753 if ( remCh )
754 remoteMod =( lastSync.addDays( 1 ) ); 754 remoteMod =( lastSync.addDays( 1 ) );
755 755
756 } 756 }
757 } 757 }
758 full = true; 758 full = true;
759 if ( mode < SYNC_PREF_ASK ) 759 if ( mode < SYNC_PREF_ASK )
760 mode = SYNC_PREF_ASK; 760 mode = SYNC_PREF_ASK;
761 } else { 761 } else {
762 if ( localMod == remoteMod ) 762 if ( localMod == remoteMod )
763 // if ( local->revision() == remote->revision() ) 763 // if ( local->revision() == remote->revision() )
764 return 0; 764 return 0;
765 765
766 } 766 }
767 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 767 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
768 768
769 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 769 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
770 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 770 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
771 //full = true; //debug only 771 //full = true; //debug only
772 if ( full ) { 772 if ( full ) {
773 bool equ = false; 773 bool equ = false;
774 if ( local->type() == "Event" ) { 774 if ( local->type() == "Event" ) {
775 equ = (*((Event*) local) == *((Event*) remote)); 775 equ = (*((Event*) local) == *((Event*) remote));
776 } 776 }
777 else if ( local->type() =="Todo" ) 777 else if ( local->type() =="Todo" )
778 equ = (*((Todo*) local) == (*(Todo*) remote)); 778 equ = (*((Todo*) local) == (*(Todo*) remote));
779 else if ( local->type() =="Journal" ) 779 else if ( local->type() =="Journal" )
780 equ = (*((Journal*) local) == *((Journal*) remote)); 780 equ = (*((Journal*) local) == *((Journal*) remote));
781 if ( equ ) { 781 if ( equ ) {
782 //qDebug("equal "); 782 //qDebug("equal ");
783 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 783 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
784 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 784 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
785 } 785 }
786 if ( mode < SYNC_PREF_FORCE_LOCAL ) 786 if ( mode < SYNC_PREF_FORCE_LOCAL )
787 return 0; 787 return 0;
788 788
789 }//else //debug only 789 }//else //debug only
790 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 790 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
791 } 791 }
792 int result; 792 int result;
793 bool localIsNew; 793 bool localIsNew;
794 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 794 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
795 795
796 if ( full && mode < SYNC_PREF_NEWEST ) 796 if ( full && mode < SYNC_PREF_NEWEST )
797 mode = SYNC_PREF_ASK; 797 mode = SYNC_PREF_ASK;
798 798
799 switch( mode ) { 799 switch( mode ) {
800 case SYNC_PREF_LOCAL: 800 case SYNC_PREF_LOCAL:
801 if ( lastSync > remoteMod ) 801 if ( lastSync > remoteMod )
802 return 1; 802 return 1;
803 if ( lastSync > localMod ) 803 if ( lastSync > localMod )
804 return 2; 804 return 2;
805 return 1; 805 return 1;
806 break; 806 break;
807 case SYNC_PREF_REMOTE: 807 case SYNC_PREF_REMOTE:
808 if ( lastSync > remoteMod ) 808 if ( lastSync > remoteMod )
809 return 1; 809 return 1;
810 if ( lastSync > localMod ) 810 if ( lastSync > localMod )
811 return 2; 811 return 2;
812 return 2; 812 return 2;
813 break; 813 break;
814 case SYNC_PREF_NEWEST: 814 case SYNC_PREF_NEWEST:
815 if ( localMod > remoteMod ) 815 if ( localMod > remoteMod )
816 return 1; 816 return 1;
817 else 817 else
818 return 2; 818 return 2;
819 break; 819 break;
820 case SYNC_PREF_ASK: 820 case SYNC_PREF_ASK:
821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
822 if ( lastSync > remoteMod ) 822 if ( lastSync > remoteMod )
823 return 1; 823 return 1;
824 if ( lastSync > localMod ) 824 if ( lastSync > localMod )
825 return 2; 825 return 2;
826 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 826 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
827 localIsNew = localMod >= remoteMod; 827 localIsNew = localMod >= remoteMod;
828 if ( localIsNew ) 828 if ( localIsNew )
829 getEventViewerDialog()->setColorMode( 1 ); 829 getEventViewerDialog()->setColorMode( 1 );
830 else 830 else
831 getEventViewerDialog()->setColorMode( 2 ); 831 getEventViewerDialog()->setColorMode( 2 );
832 getEventViewerDialog()->setIncidence(local); 832 getEventViewerDialog()->setIncidence(local);
833 if ( localIsNew ) 833 if ( localIsNew )
834 getEventViewerDialog()->setColorMode( 2 ); 834 getEventViewerDialog()->setColorMode( 2 );
835 else 835 else
836 getEventViewerDialog()->setColorMode( 1 ); 836 getEventViewerDialog()->setColorMode( 1 );
837 getEventViewerDialog()->addIncidence(remote); 837 getEventViewerDialog()->addIncidence(remote);
838 getEventViewerDialog()->setColorMode( 0 ); 838 getEventViewerDialog()->setColorMode( 0 );
839 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 839 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
840 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 840 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
841 getEventViewerDialog()->showMe(); 841 getEventViewerDialog()->showMe();
842 result = getEventViewerDialog()->executeS( localIsNew ); 842 result = getEventViewerDialog()->executeS( localIsNew );
843 return result; 843 return result;
844 844
845 break; 845 break;
846 case SYNC_PREF_FORCE_LOCAL: 846 case SYNC_PREF_FORCE_LOCAL:
847 return 1; 847 return 1;
848 break; 848 break;
849 case SYNC_PREF_FORCE_REMOTE: 849 case SYNC_PREF_FORCE_REMOTE:
850 return 2; 850 return 2;
851 break; 851 break;
852 852
853 default: 853 default:
854 // SYNC_PREF_TAKE_BOTH not implemented 854 // SYNC_PREF_TAKE_BOTH not implemented
855 break; 855 break;
856 } 856 }
857 return 0; 857 return 0;
858} 858}
859Event* CalendarView::getLastSyncEvent() 859Event* CalendarView::getLastSyncEvent()
860{ 860{
861 Event* lse; 861 Event* lse;
862 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 862 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
863 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 863 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
864 if (!lse) { 864 if (!lse) {
865 lse = new Event(); 865 lse = new Event();
866 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 866 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
867 QString sum = ""; 867 QString sum = "";
868 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 868 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
869 sum = "E: "; 869 sum = "E: ";
870 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 870 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
871 lse->setDtStart( mLastCalendarSync ); 871 lse->setDtStart( mLastCalendarSync );
872 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 872 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
873 lse->setCategories( i18n("SyncEvent") ); 873 lse->setCategories( i18n("SyncEvent") );
874 lse->setReadOnly( true ); 874 lse->setReadOnly( true );
875 mCalendar->addEvent( lse ); 875 mCalendar->addEvent( lse );
876 } 876 }
877 877
878 return lse; 878 return lse;
879 879
880} 880}
881 881
882// we check, if the to delete event has a id for a profile 882// we check, if the to delete event has a id for a profile
883// if yes, we set this id in the profile to delete 883// if yes, we set this id in the profile to delete
884void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 884void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
885{ 885{
886 if ( lastSync.count() == 0 ) { 886 if ( lastSync.count() == 0 ) {
887 //qDebug(" lastSync.count() == 0"); 887 //qDebug(" lastSync.count() == 0");
888 return; 888 return;
889 } 889 }
890 if ( toDelete->type() == "Journal" ) 890 if ( toDelete->type() == "Journal" )
891 return; 891 return;
892 892
893 Event* eve = lastSync.first(); 893 Event* eve = lastSync.first();
894 894
895 while ( eve ) { 895 while ( eve ) {
896 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 896 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
897 if ( !id.isEmpty() ) { 897 if ( !id.isEmpty() ) {
898 QString des = eve->description(); 898 QString des = eve->description();
899 QString pref = "e"; 899 QString pref = "e";
900 if ( toDelete->type() == "Todo" ) 900 if ( toDelete->type() == "Todo" )
901 pref = "t"; 901 pref = "t";
902 des += pref+ id + ","; 902 des += pref+ id + ",";
903 eve->setReadOnly( false ); 903 eve->setReadOnly( false );
904 eve->setDescription( des ); 904 eve->setDescription( des );
905 //qDebug("setdes %s ", des.latin1()); 905 //qDebug("setdes %s ", des.latin1());
906 eve->setReadOnly( true ); 906 eve->setReadOnly( true );
907 } 907 }
908 eve = lastSync.next(); 908 eve = lastSync.next();
909 } 909 }
910 910
911} 911}
912void CalendarView::checkExternalId( Incidence * inc ) 912void CalendarView::checkExternalId( Incidence * inc )
913{ 913{
914 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 914 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
915 checkExternSyncEvent( lastSync, inc ); 915 checkExternSyncEvent( lastSync, inc );
916 916
917} 917}
918bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 918bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
919{ 919{
920 bool syncOK = true; 920 bool syncOK = true;
921 int addedEvent = 0; 921 int addedEvent = 0;
922 int addedEventR = 0; 922 int addedEventR = 0;
923 int deletedEventR = 0; 923 int deletedEventR = 0;
924 int deletedEventL = 0; 924 int deletedEventL = 0;
925 int changedLocal = 0; 925 int changedLocal = 0;
926 int changedRemote = 0; 926 int changedRemote = 0;
927 //QPtrList<Event> el = local->rawEvents(); 927 //QPtrList<Event> el = local->rawEvents();
928 Event* eventR; 928 Event* eventR;
929 QString uid; 929 QString uid;
930 int take; 930 int take;
931 Event* eventL; 931 Event* eventL;
932 Event* eventRSync; 932 Event* eventRSync;
933 Event* eventLSync; 933 Event* eventLSync;
934 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 934 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
935 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 935 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
936 bool fullDateRange = false; 936 bool fullDateRange = false;
937 local->resetTempSyncStat(); 937 local->resetTempSyncStat();
938 mLastCalendarSync = QDateTime::currentDateTime(); 938 mLastCalendarSync = QDateTime::currentDateTime();
939 if ( mSyncManager->syncWithDesktop() ) { 939 if ( mSyncManager->syncWithDesktop() ) {
940 remote->resetPilotStat(1); 940 remote->resetPilotStat(1);
941 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 941 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
942 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 942 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
943 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 943 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
944 } else { 944 } else {
945 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 945 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
946 } 946 }
947 } 947 }
948 QDateTime modifiedCalendar = mLastCalendarSync; 948 QDateTime modifiedCalendar = mLastCalendarSync;
949 eventLSync = getLastSyncEvent(); 949 eventLSync = getLastSyncEvent();
950 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 950 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
951 if ( eventR ) { 951 if ( eventR ) {
952 eventRSync = (Event*) eventR->clone(); 952 eventRSync = (Event*) eventR->clone();
953 remote->deleteEvent(eventR ); 953 remote->deleteEvent(eventR );
954 954
955 } else { 955 } else {
956 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 956 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
957 eventRSync = (Event*)eventLSync->clone(); 957 eventRSync = (Event*)eventLSync->clone();
958 } else { 958 } else {
959 fullDateRange = true; 959 fullDateRange = true;
960 eventRSync = new Event(); 960 eventRSync = new Event();
961 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 961 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
962 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 962 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
963 eventRSync->setDtStart( mLastCalendarSync ); 963 eventRSync->setDtStart( mLastCalendarSync );
964 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 964 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
965 eventRSync->setCategories( i18n("SyncEvent") ); 965 eventRSync->setCategories( i18n("SyncEvent") );
966 } 966 }
967 } 967 }
968 if ( eventLSync->dtStart() == mLastCalendarSync ) 968 if ( eventLSync->dtStart() == mLastCalendarSync )
969 fullDateRange = true; 969 fullDateRange = true;
970 970
971 if ( ! fullDateRange ) { 971 if ( ! fullDateRange ) {
972 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 972 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
973 973
974 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 974 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
975 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 975 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
976 fullDateRange = true; 976 fullDateRange = true;
977 } 977 }
978 } 978 }
979 if ( mSyncManager->syncWithDesktop() ) { 979 if ( mSyncManager->syncWithDesktop() ) {
980 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 980 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
981 } 981 }
982 if ( fullDateRange ) 982 if ( fullDateRange )
983 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 983 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
984 else 984 else
985 mLastCalendarSync = eventLSync->dtStart(); 985 mLastCalendarSync = eventLSync->dtStart();
986 // for resyncing if own file has changed 986 // for resyncing if own file has changed
987 if ( mCurrentSyncDevice == "deleteaftersync" ) { 987 if ( mCurrentSyncDevice == "deleteaftersync" ) {
988 mLastCalendarSync = loadedFileVersion; 988 mLastCalendarSync = loadedFileVersion;
989 //qDebug("setting mLastCalendarSync "); 989 //qDebug("setting mLastCalendarSync ");
990 } 990 }
991 //qDebug("*************************** "); 991 //qDebug("*************************** ");
992 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 992 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
993 QPtrList<Incidence> er = remote->rawIncidences(); 993 QPtrList<Incidence> er = remote->rawIncidences();
994 Incidence* inR = er.first(); 994 Incidence* inR = er.first();
995 Incidence* inL; 995 Incidence* inL;
996 QProgressBar bar( er.count(),0 ); 996 QProgressBar bar( er.count(),0 );
997 bar.setCaption (i18n("Syncing - close to abort!") ); 997 bar.setCaption (i18n("Syncing - close to abort!") );
998 998
999 int w = 300; 999 int w = 300;
1000 if ( QApplication::desktop()->width() < 320 ) 1000 if ( QApplication::desktop()->width() < 320 )
1001 w = 220; 1001 w = 220;
1002 int h = bar.sizeHint().height() ; 1002 int h = bar.sizeHint().height() ;
1003 int dw = QApplication::desktop()->width(); 1003 int dw = QApplication::desktop()->width();
1004 int dh = QApplication::desktop()->height(); 1004 int dh = QApplication::desktop()->height();
1005 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1005 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1006 bar.show(); 1006 bar.show();
1007 int modulo = (er.count()/10)+1; 1007 int modulo = (er.count()/10)+1;
1008 int incCounter = 0; 1008 int incCounter = 0;
1009 while ( inR ) { 1009 while ( inR ) {
1010 if ( ! bar.isVisible() ) 1010 if ( ! bar.isVisible() )
1011 return false; 1011 return false;
1012 if ( incCounter % modulo == 0 ) 1012 if ( incCounter % modulo == 0 )
1013 bar.setProgress( incCounter ); 1013 bar.setProgress( incCounter );
1014 ++incCounter; 1014 ++incCounter;
1015 uid = inR->uid(); 1015 uid = inR->uid();
1016 bool skipIncidence = false; 1016 bool skipIncidence = false;
1017 if ( uid.left(15) == QString("last-syncEvent-") ) 1017 if ( uid.left(15) == QString("last-syncEvent-") )
1018 skipIncidence = true; 1018 skipIncidence = true;
1019 QString idS; 1019 QString idS;
1020 qApp->processEvents(); 1020 qApp->processEvents();
1021 if ( !skipIncidence ) { 1021 if ( !skipIncidence ) {
1022 inL = local->incidence( uid ); 1022 inL = local->incidence( uid );
1023 if ( inL ) { // maybe conflict - same uid in both calendars 1023 if ( inL ) { // maybe conflict - same uid in both calendars
1024 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1024 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1025 //qDebug("take %d %s ", take, inL->summary().latin1()); 1025 //qDebug("take %d %s ", take, inL->summary().latin1());
1026 if ( take == 3 ) 1026 if ( take == 3 )
1027 return false; 1027 return false;
1028 if ( take == 1 ) {// take local ********************** 1028 if ( take == 1 ) {// take local **********************
1029 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1029 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1030 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1030 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1031 else 1031 else
1032 idS = inR->IDStr(); 1032 idS = inR->IDStr();
1033 remote->deleteIncidence( inR ); 1033 remote->deleteIncidence( inR );
1034 inR = inL->clone(); 1034 inR = inL->clone();
1035 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1035 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1036 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1036 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1037 inR->setIDStr( idS ); 1037 inR->setIDStr( idS );
1038 remote->addIncidence( inR ); 1038 remote->addIncidence( inR );
1039 if ( mSyncManager->syncWithDesktop() ) 1039 if ( mSyncManager->syncWithDesktop() )
1040 inR->setPilotId( 2 ); 1040 inR->setPilotId( 2 );
1041 ++changedRemote; 1041 ++changedRemote;
1042 } else {// take remote ********************** 1042 } else {// take remote **********************
1043 idS = inL->IDStr(); 1043 idS = inL->IDStr();
1044 int pid = inL->pilotId(); 1044 int pid = inL->pilotId();
1045 local->deleteIncidence( inL ); 1045 local->deleteIncidence( inL );
1046 inL = inR->clone(); 1046 inL = inR->clone();
1047 if ( mSyncManager->syncWithDesktop() ) 1047 if ( mSyncManager->syncWithDesktop() )
1048 inL->setPilotId( pid ); 1048 inL->setPilotId( pid );
1049 inL->setIDStr( idS ); 1049 inL->setIDStr( idS );
1050 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1050 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1051 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1051 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1052 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1052 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1053 } 1053 }
1054 local->addIncidence( inL ); 1054 local->addIncidence( inL );
1055 ++changedLocal; 1055 ++changedLocal;
1056 } 1056 }
1057 } 1057 }
1058 } else { // no conflict ********** add or delete remote 1058 } else { // no conflict ********** add or delete remote
1059 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1059 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1060 QString des = eventLSync->description(); 1060 QString des = eventLSync->description();
1061 QString pref = "e"; 1061 QString pref = "e";
1062 if ( inR->type() == "Todo" ) 1062 if ( inR->type() == "Todo" )
1063 pref = "t"; 1063 pref = "t";
1064 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1064 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1065 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1065 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1066 //remote->deleteIncidence( inR ); 1066 //remote->deleteIncidence( inR );
1067 ++deletedEventR; 1067 ++deletedEventR;
1068 } else { 1068 } else {
1069 inR->setLastModified( modifiedCalendar ); 1069 inR->setLastModified( modifiedCalendar );
1070 inL = inR->clone(); 1070 inL = inR->clone();
1071 inL->setIDStr( ":" ); 1071 inL->setIDStr( ":" );
1072 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1072 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1073 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1073 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1074 local->addIncidence( inL ); 1074 local->addIncidence( inL );
1075 ++addedEvent; 1075 ++addedEvent;
1076 } 1076 }
1077 } else { 1077 } else {
1078 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1078 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1079 inR->setLastModified( modifiedCalendar ); 1079 inR->setLastModified( modifiedCalendar );
1080 inL = inR->clone(); 1080 inL = inR->clone();
1081 inL->setIDStr( ":" ); 1081 inL->setIDStr( ":" );
1082 local->addIncidence( inL ); 1082 local->addIncidence( inL );
1083 ++addedEvent; 1083 ++addedEvent;
1084 } else { 1084 } else {
1085 checkExternSyncEvent(eventRSyncSharp, inR); 1085 checkExternSyncEvent(eventRSyncSharp, inR);
1086 remote->deleteIncidence( inR ); 1086 remote->deleteIncidence( inR );
1087 ++deletedEventR; 1087 ++deletedEventR;
1088 } 1088 }
1089 } 1089 }
1090 } 1090 }
1091 } 1091 }
1092 inR = er.next(); 1092 inR = er.next();
1093 } 1093 }
1094 QPtrList<Incidence> el = local->rawIncidences(); 1094 QPtrList<Incidence> el = local->rawIncidences();
1095 inL = el.first(); 1095 inL = el.first();
1096 modulo = (el.count()/10)+1; 1096 modulo = (el.count()/10)+1;
1097 bar.setCaption (i18n("Add / remove events") ); 1097 bar.setCaption (i18n("Add / remove events") );
1098 bar.setTotalSteps ( el.count() ) ; 1098 bar.setTotalSteps ( el.count() ) ;
1099 bar.show(); 1099 bar.show();
1100 incCounter = 0; 1100 incCounter = 0;
1101 1101
1102 while ( inL ) { 1102 while ( inL ) {
1103 1103
1104 qApp->processEvents(); 1104 qApp->processEvents();
1105 if ( ! bar.isVisible() ) 1105 if ( ! bar.isVisible() )
1106 return false; 1106 return false;
1107 if ( incCounter % modulo == 0 ) 1107 if ( incCounter % modulo == 0 )
1108 bar.setProgress( incCounter ); 1108 bar.setProgress( incCounter );
1109 ++incCounter; 1109 ++incCounter;
1110 uid = inL->uid(); 1110 uid = inL->uid();
1111 bool skipIncidence = false; 1111 bool skipIncidence = false;
1112 if ( uid.left(15) == QString("last-syncEvent-") ) 1112 if ( uid.left(15) == QString("last-syncEvent-") )
1113 skipIncidence = true; 1113 skipIncidence = true;
1114 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1114 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1115 skipIncidence = true; 1115 skipIncidence = true;
1116 if ( !skipIncidence ) { 1116 if ( !skipIncidence ) {
1117 inR = remote->incidence( uid ); 1117 inR = remote->incidence( uid );
1118 if ( ! inR ) { // no conflict ********** add or delete local 1118 if ( ! inR ) { // no conflict ********** add or delete local
1119 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1119 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1120 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1120 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1121 checkExternSyncEvent(eventLSyncSharp, inL); 1121 checkExternSyncEvent(eventLSyncSharp, inL);
1122 local->deleteIncidence( inL ); 1122 local->deleteIncidence( inL );
1123 ++deletedEventL; 1123 ++deletedEventL;
1124 } else { 1124 } else {
1125 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1125 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1126 inL->removeID(mCurrentSyncDevice ); 1126 inL->removeID(mCurrentSyncDevice );
1127 ++addedEventR; 1127 ++addedEventR;
1128 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1128 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1129 inL->setLastModified( modifiedCalendar ); 1129 inL->setLastModified( modifiedCalendar );
1130 inR = inL->clone(); 1130 inR = inL->clone();
1131 inR->setIDStr( ":" ); 1131 inR->setIDStr( ":" );
1132 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1132 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1133 remote->addIncidence( inR ); 1133 remote->addIncidence( inR );
1134 } 1134 }
1135 } 1135 }
1136 } else { 1136 } else {
1137 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1137 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1138 checkExternSyncEvent(eventLSyncSharp, inL); 1138 checkExternSyncEvent(eventLSyncSharp, inL);
1139 local->deleteIncidence( inL ); 1139 local->deleteIncidence( inL );
1140 ++deletedEventL; 1140 ++deletedEventL;
1141 } else { 1141 } else {
1142 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1142 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1143 ++addedEventR; 1143 ++addedEventR;
1144 inL->setLastModified( modifiedCalendar ); 1144 inL->setLastModified( modifiedCalendar );
1145 inR = inL->clone(); 1145 inR = inL->clone();
1146 inR->setIDStr( ":" ); 1146 inR->setIDStr( ":" );
1147 remote->addIncidence( inR ); 1147 remote->addIncidence( inR );
1148 } 1148 }
1149 } 1149 }
1150 } 1150 }
1151 } 1151 }
1152 } 1152 }
1153 inL = el.next(); 1153 inL = el.next();
1154 } 1154 }
1155 int delFut = 0; 1155 int delFut = 0;
1156 int remRem = 0; 1156 int remRem = 0;
1157 if ( mSyncManager->mWriteBackInFuture ) { 1157 if ( mSyncManager->mWriteBackInFuture ) {
1158 er = remote->rawIncidences(); 1158 er = remote->rawIncidences();
1159 remRem = er.count(); 1159 remRem = er.count();
1160 inR = er.first(); 1160 inR = er.first();
1161 QDateTime dt; 1161 QDateTime dt;
1162 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1162 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1163 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); 1163 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1164 while ( inR ) { 1164 while ( inR ) {
1165 if ( inR->type() == "Todo" ) { 1165 if ( inR->type() == "Todo" ) {
1166 Todo * t = (Todo*)inR; 1166 Todo * t = (Todo*)inR;
1167 if ( t->hasDueDate() ) 1167 if ( t->hasDueDate() )
1168 dt = t->dtDue(); 1168 dt = t->dtDue();
1169 else 1169 else
1170 dt = cur.addSecs( 62 ); 1170 dt = cur.addSecs( 62 );
1171 } 1171 }
1172 else if (inR->type() == "Event" ) { 1172 else if (inR->type() == "Event" ) {
1173 bool ok; 1173 bool ok;
1174 dt = inR->getNextOccurence( cur, &ok ); 1174 dt = inR->getNextOccurence( cur, &ok );
1175 if ( !ok ) 1175 if ( !ok )
1176 dt = cur.addSecs( -62 ); 1176 dt = cur.addSecs( -62 );
1177 } 1177 }
1178 else 1178 else
1179 dt = inR->dtStart(); 1179 dt = inR->dtStart();
1180 if ( dt < cur || dt > end ) { 1180 if ( dt < cur || dt > end ) {
1181 remote->deleteIncidence( inR ); 1181 remote->deleteIncidence( inR );
1182 ++delFut; 1182 ++delFut;
1183 } 1183 }
1184 inR = er.next(); 1184 inR = er.next();
1185 } 1185 }
1186 } 1186 }
1187 bar.hide(); 1187 bar.hide();
1188 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1188 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1189 eventLSync->setReadOnly( false ); 1189 eventLSync->setReadOnly( false );
1190 eventLSync->setDtStart( mLastCalendarSync ); 1190 eventLSync->setDtStart( mLastCalendarSync );
1191 eventRSync->setDtStart( mLastCalendarSync ); 1191 eventRSync->setDtStart( mLastCalendarSync );
1192 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1192 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1193 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1193 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1194 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1194 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1195 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1195 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1196 eventLSync->setReadOnly( true ); 1196 eventLSync->setReadOnly( true );
1197 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); 1197 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() );
1198 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1198 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1199 remote->addEvent( eventRSync ); 1199 remote->addEvent( eventRSync );
1200 else 1200 else
1201 delete eventRSync; 1201 delete eventRSync;
1202 QString mes; 1202 QString mes;
1203 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 ); 1203 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 );
1204 QString delmess; 1204 QString delmess;
1205 if ( delFut ) { 1205 if ( delFut ) {
1206 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); 1206 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1207 mes += delmess; 1207 mes += delmess;
1208 } 1208 }
1209 mes = i18n("Local calendar changed!\n") +mes; 1209 mes = i18n("Local calendar changed!\n") +mes;
1210 mCalendar->checkAlarmForIncidence( 0, true ); 1210 mCalendar->checkAlarmForIncidence( 0, true );
1211 qDebug( mes ); 1211 qDebug( mes );
1212 if ( mSyncManager->mShowSyncSummary ) { 1212 if ( mSyncManager->mShowSyncSummary ) {
1213 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1213 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1214 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1214 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1215 qDebug("cancelled "); 1215 qDebug("cancelled ");
1216 return false; 1216 return false;
1217 } 1217 }
1218 } 1218 }
1219 return syncOK; 1219 return syncOK;
1220} 1220}
1221 1221
1222void CalendarView::setSyncDevice( QString s ) 1222void CalendarView::setSyncDevice( QString s )
1223{ 1223{
1224 mCurrentSyncDevice= s; 1224 mCurrentSyncDevice= s;
1225} 1225}
1226void CalendarView::setSyncName( QString s ) 1226void CalendarView::setSyncName( QString s )
1227{ 1227{
1228 mCurrentSyncName= s; 1228 mCurrentSyncName= s;
1229} 1229}
1230bool CalendarView::syncCalendar(QString filename, int mode) 1230bool CalendarView::syncCalendar(QString filename, int mode)
1231{ 1231{
1232 //qDebug("syncCalendar %s ", filename.latin1()); 1232 //qDebug("syncCalendar %s ", filename.latin1());
1233 mGlobalSyncMode = SYNC_MODE_NORMAL; 1233 mGlobalSyncMode = SYNC_MODE_NORMAL;
1234 CalendarLocal* calendar = new CalendarLocal(); 1234 CalendarLocal* calendar = new CalendarLocal();
1235 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1235 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1236 FileStorage* storage = new FileStorage( calendar ); 1236 FileStorage* storage = new FileStorage( calendar );
1237 bool syncOK = false; 1237 bool syncOK = false;
1238 storage->setFileName( filename ); 1238 storage->setFileName( filename );
1239 // qDebug("loading ... "); 1239 // qDebug("loading ... ");
1240 if ( storage->load() ) { 1240 if ( storage->load() ) {
1241 getEventViewerDialog()->setSyncMode( true ); 1241 getEventViewerDialog()->setSyncMode( true );
1242 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1242 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1243 getEventViewerDialog()->setSyncMode( false ); 1243 getEventViewerDialog()->setSyncMode( false );
1244 if ( syncOK ) { 1244 if ( syncOK ) {
1245 if ( mSyncManager->mWriteBackFile ) 1245 if ( mSyncManager->mWriteBackFile )
1246 { 1246 {
1247 storage->setSaveFormat( new ICalFormat() ); 1247 storage->setSaveFormat( new ICalFormat() );
1248 storage->save(); 1248 storage->save();
1249 } 1249 }
1250 } 1250 }
1251 setModified( true ); 1251 setModified( true );
1252 } 1252 }
1253 delete storage; 1253 delete storage;
1254 delete calendar; 1254 delete calendar;
1255 if ( syncOK ) 1255 if ( syncOK )
1256 updateView(); 1256 updateView();
1257 return syncOK; 1257 return syncOK;
1258} 1258}
1259 1259
1260void CalendarView::syncExternal( int mode ) 1260void CalendarView::syncExternal( int mode )
1261{ 1261{
1262 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1262 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1263 1263
1264 qApp->processEvents(); 1264 qApp->processEvents();
1265 CalendarLocal* calendar = new CalendarLocal(); 1265 CalendarLocal* calendar = new CalendarLocal();
1266 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1266 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1267 bool syncOK = false; 1267 bool syncOK = false;
1268 bool loadSuccess = false; 1268 bool loadSuccess = false;
1269 PhoneFormat* phoneFormat = 0; 1269 PhoneFormat* phoneFormat = 0;
1270 emit tempDisableBR(true); 1270 emit tempDisableBR(true);
1271#ifndef DESKTOP_VERSION 1271#ifndef DESKTOP_VERSION
1272 SharpFormat* sharpFormat = 0; 1272 SharpFormat* sharpFormat = 0;
1273 if ( mode == 0 ) { // sharp 1273 if ( mode == 0 ) { // sharp
1274 sharpFormat = new SharpFormat () ; 1274 sharpFormat = new SharpFormat () ;
1275 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1275 loadSuccess = sharpFormat->load( calendar, mCalendar );
1276 1276
1277 } else 1277 } else
1278#endif 1278#endif
1279 if ( mode == 1 ) { // phone 1279 if ( mode == 1 ) { // phone
1280 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1280 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1281 mSyncManager->mPhoneDevice, 1281 mSyncManager->mPhoneDevice,
1282 mSyncManager->mPhoneConnection, 1282 mSyncManager->mPhoneConnection,
1283 mSyncManager->mPhoneModel); 1283 mSyncManager->mPhoneModel);
1284 loadSuccess = phoneFormat->load( calendar,mCalendar); 1284 loadSuccess = phoneFormat->load( calendar,mCalendar);
1285 1285
1286 } else { 1286 } else {
1287 emit tempDisableBR(false); 1287 emit tempDisableBR(false);
1288 return; 1288 return;
1289 } 1289 }
1290 if ( loadSuccess ) { 1290 if ( loadSuccess ) {
1291 getEventViewerDialog()->setSyncMode( true ); 1291 getEventViewerDialog()->setSyncMode( true );
1292 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1292 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1293 getEventViewerDialog()->setSyncMode( false ); 1293 getEventViewerDialog()->setSyncMode( false );
1294 qApp->processEvents(); 1294 qApp->processEvents();
1295 if ( syncOK ) { 1295 if ( syncOK ) {
1296 if ( mSyncManager->mWriteBackFile ) 1296 if ( mSyncManager->mWriteBackFile )
1297 { 1297 {
1298 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1298 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1299 Incidence* inc = iL.first(); 1299 Incidence* inc = iL.first();
1300 if ( phoneFormat ) { 1300 if ( phoneFormat ) {
1301 while ( inc ) { 1301 while ( inc ) {
1302 inc->removeID(mCurrentSyncDevice); 1302 inc->removeID(mCurrentSyncDevice);
1303 inc = iL.next(); 1303 inc = iL.next();
1304 } 1304 }
1305 } 1305 }
1306#ifndef DESKTOP_VERSION 1306#ifndef DESKTOP_VERSION
1307 if ( sharpFormat ) 1307 if ( sharpFormat )
1308 sharpFormat->save(calendar); 1308 sharpFormat->save(calendar);
1309#endif 1309#endif
1310 if ( phoneFormat ) 1310 if ( phoneFormat )
1311 phoneFormat->save(calendar); 1311 phoneFormat->save(calendar);
1312 iL = calendar->rawIncidences(); 1312 iL = calendar->rawIncidences();
1313 inc = iL.first(); 1313 inc = iL.first();
1314 Incidence* loc; 1314 Incidence* loc;
1315 while ( inc ) { 1315 while ( inc ) {
1316 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1316 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1317 loc = mCalendar->incidence(inc->uid() ); 1317 loc = mCalendar->incidence(inc->uid() );
1318 if ( loc ) { 1318 if ( loc ) {
1319 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1319 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1320 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1320 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1321 } 1321 }
1322 } 1322 }
1323 inc = iL.next(); 1323 inc = iL.next();
1324 } 1324 }
1325 Incidence* lse = getLastSyncEvent(); 1325 Incidence* lse = getLastSyncEvent();
1326 if ( lse ) { 1326 if ( lse ) {
1327 lse->setReadOnly( false ); 1327 lse->setReadOnly( false );
1328 lse->setDescription( "" ); 1328 lse->setDescription( "" );
1329 lse->setReadOnly( true ); 1329 lse->setReadOnly( true );
1330 } 1330 }
1331 } 1331 }
1332 } else { 1332 } else {
1333 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1333 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1334 } 1334 }
1335 setModified( true ); 1335 setModified( true );
1336 } else { 1336 } else {
1337 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1337 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1338 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1338 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1339 question, i18n("Ok")) ; 1339 question, i18n("Ok")) ;
1340 1340
1341 } 1341 }
1342 delete calendar; 1342 delete calendar;
1343 updateView(); 1343 updateView();
1344 emit tempDisableBR(false); 1344 emit tempDisableBR(false);
1345 return ;//syncOK; 1345 return ;//syncOK;
1346 1346
1347} 1347}
1348 1348
1349bool CalendarView::importBday() 1349bool CalendarView::importBday()
1350{ 1350{
1351#ifndef KORG_NOKABC 1351#ifndef KORG_NOKABC
1352 1352
1353#ifdef DESKTOP_VERSION 1353#ifdef DESKTOP_VERSION
1354 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1354 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1355 KABC::AddressBook::Iterator it; 1355 KABC::AddressBook::Iterator it;
1356 int count = 0; 1356 int count = 0;
1357 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1357 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1358 ++count; 1358 ++count;
1359 } 1359 }
1360 QProgressBar bar(count,0 ); 1360 QProgressBar bar(count,0 );
1361 int w = 300; 1361 int w = 300;
1362 if ( QApplication::desktop()->width() < 320 ) 1362 if ( QApplication::desktop()->width() < 320 )
1363 w = 220; 1363 w = 220;
1364 int h = bar.sizeHint().height() ; 1364 int h = bar.sizeHint().height() ;
1365 int dw = QApplication::desktop()->width(); 1365 int dw = QApplication::desktop()->width();
1366 int dh = QApplication::desktop()->height(); 1366 int dh = QApplication::desktop()->height();
1367 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1367 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1368 bar.show(); 1368 bar.show();
1369 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1369 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1370 qApp->processEvents(); 1370 qApp->processEvents();
1371 count = 0; 1371 count = 0;
1372 int addCount = 0; 1372 int addCount = 0;
1373 KCal::Attendee* a = 0; 1373 KCal::Attendee* a = 0;
1374 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1374 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1375 if ( ! bar.isVisible() ) 1375 if ( ! bar.isVisible() )
1376 return false; 1376 return false;
1377 bar.setProgress( count++ ); 1377 bar.setProgress( count++ );
1378 qApp->processEvents(); 1378 qApp->processEvents();
1379 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1379 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1380 if ( (*it).birthday().date().isValid() ){ 1380 if ( (*it).birthday().date().isValid() ){
1381 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1381 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1382 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1382 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1383 ++addCount; 1383 ++addCount;
1384 } 1384 }
1385 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1385 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1386 if ( anni.isValid() ){ 1386 if ( anni.isValid() ){
1387 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1387 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1388 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1388 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1389 ++addCount; 1389 ++addCount;
1390 } 1390 }
1391 } 1391 }
1392 updateView(); 1392 updateView();
1393 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1393 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1394#else //DESKTOP_VERSION 1394#else //DESKTOP_VERSION
1395 1395
1396 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1396 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1397 // the result should now arrive through method insertBirthdays 1397 // the result should now arrive through method insertBirthdays
1398 1398
1399#endif //DESKTOP_VERSION 1399#endif //DESKTOP_VERSION
1400 1400
1401#endif //KORG_NOKABC 1401#endif //KORG_NOKABC
1402 1402
1403 1403
1404 return true; 1404 return true;
1405} 1405}
1406 1406
1407// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1407// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1408void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1408void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1409 const QStringList& anniversaryList, const QStringList& realNameList, 1409 const QStringList& anniversaryList, const QStringList& realNameList,
1410 const QStringList& emailList, const QStringList& assembledNameList, 1410 const QStringList& emailList, const QStringList& assembledNameList,
1411 const QStringList& uidList) 1411 const QStringList& uidList)
1412{ 1412{
1413 qDebug("CalendarView::insertBirthdays"); 1413 qDebug("CalendarView::insertBirthdays");
1414 if (uid == this->name()) 1414 if (uid == this->name())
1415 { 1415 {
1416 int count = birthdayList.count(); 1416 int count = birthdayList.count();
1417 int addCount = 0; 1417 int addCount = 0;
1418 KCal::Attendee* a = 0; 1418 KCal::Attendee* a = 0;
1419 1419
1420 qDebug("CalView 1 %i", count); 1420 qDebug("CalView 1 %i", count);
1421 1421
1422 QProgressBar bar(count,0 ); 1422 QProgressBar bar(count,0 );
1423 int w = 300; 1423 int w = 300;
1424 if ( QApplication::desktop()->width() < 320 ) 1424 if ( QApplication::desktop()->width() < 320 )
1425 w = 220; 1425 w = 220;
1426 int h = bar.sizeHint().height() ; 1426 int h = bar.sizeHint().height() ;
1427 int dw = QApplication::desktop()->width(); 1427 int dw = QApplication::desktop()->width();
1428 int dh = QApplication::desktop()->height(); 1428 int dh = QApplication::desktop()->height();
1429 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1429 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1430 bar.show(); 1430 bar.show();
1431 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1431 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1432 qApp->processEvents(); 1432 qApp->processEvents();
1433 1433
1434 QDate birthday; 1434 QDate birthday;
1435 QDate anniversary; 1435 QDate anniversary;
1436 QString realName; 1436 QString realName;
1437 QString email; 1437 QString email;
1438 QString assembledName; 1438 QString assembledName;
1439 QString uid; 1439 QString uid;
1440 bool ok = true; 1440 bool ok = true;
1441 for ( int i = 0; i < count; i++) 1441 for ( int i = 0; i < count; i++)
1442 { 1442 {
1443 if ( ! bar.isVisible() ) 1443 if ( ! bar.isVisible() )
1444 return; 1444 return;
1445 bar.setProgress( i ); 1445 bar.setProgress( i );
1446 qApp->processEvents(); 1446 qApp->processEvents();
1447 1447
1448 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1448 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1449 if (!ok) { 1449 if (!ok) {
1450 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1450 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1451 } 1451 }
1452 1452
1453 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1453 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1454 if (!ok) { 1454 if (!ok) {
1455 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1455 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1456 } 1456 }
1457 realName = realNameList[i]; 1457 realName = realNameList[i];
1458 email = emailList[i]; 1458 email = emailList[i];
1459 assembledName = assembledNameList[i]; 1459 assembledName = assembledNameList[i];
1460 uid = uidList[i]; 1460 uid = uidList[i];
1461 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1461 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1462 1462
1463 if ( birthday.isValid() ){ 1463 if ( birthday.isValid() ){
1464 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1464 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1465 KCal::Attendee::ReqParticipant,uid) ; 1465 KCal::Attendee::ReqParticipant,uid) ;
1466 if ( addAnniversary( birthday, assembledName, a, true ) ) 1466 if ( addAnniversary( birthday, assembledName, a, true ) )
1467 ++addCount; 1467 ++addCount;
1468 } 1468 }
1469 1469
1470 if ( anniversary.isValid() ){ 1470 if ( anniversary.isValid() ){
1471 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1471 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1472 KCal::Attendee::ReqParticipant,uid) ; 1472 KCal::Attendee::ReqParticipant,uid) ;
1473 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1473 if ( addAnniversary( anniversary, assembledName, a, false ) )
1474 ++addCount; 1474 ++addCount;
1475 } 1475 }
1476 } 1476 }
1477 1477
1478 updateView(); 1478 updateView();
1479 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1479 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1480 1480
1481 } 1481 }
1482 1482
1483} 1483}
1484 1484
1485 1485
1486 1486
1487bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1487bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1488{ 1488{
1489 //qDebug("addAnni "); 1489 //qDebug("addAnni ");
1490 Event * ev = new Event(); 1490 Event * ev = new Event();
1491 if ( a ) { 1491 if ( a ) {
1492 ev->addAttendee( a ); 1492 ev->addAttendee( a );
1493 } 1493 }
1494 QString kind; 1494 QString kind;
1495 if ( birthday ) 1495 if ( birthday )
1496 kind = i18n( "Birthday" ); 1496 kind = i18n( "Birthday" );
1497 else 1497 else
1498 kind = i18n( "Anniversary" ); 1498 kind = i18n( "Anniversary" );
1499 ev->setSummary( name + " - " + kind ); 1499 ev->setSummary( name + " - " + kind );
1500 ev->setOrganizer(a->email()); 1500 ev->setOrganizer(a->email());
1501 ev->setCategories( kind ); 1501 ev->setCategories( kind );
1502 ev->setDtStart( QDateTime(date) ); 1502 ev->setDtStart( QDateTime(date) );
1503 ev->setDtEnd( QDateTime(date) ); 1503 ev->setDtEnd( QDateTime(date) );
1504 ev->setFloats( true ); 1504 ev->setFloats( true );
1505 Recurrence * rec = ev->recurrence(); 1505 Recurrence * rec = ev->recurrence();
1506 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1506 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1507 rec->addYearlyNum( date.month() ); 1507 rec->addYearlyNum( date.month() );
1508 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1508 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1509 delete ev; 1509 delete ev;
1510 return false; 1510 return false;
1511 } 1511 }
1512 return true; 1512 return true;
1513 1513
1514} 1514}
1515bool CalendarView::importQtopia( const QString &categories, 1515bool CalendarView::importQtopia( const QString &categories,
1516 const QString &datebook, 1516 const QString &datebook,
1517 const QString &todolist ) 1517 const QString &todolist )
1518{ 1518{
1519 1519
1520 QtopiaFormat qtopiaFormat; 1520 QtopiaFormat qtopiaFormat;
1521 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1521 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1522 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1522 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1523 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1523 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1524 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1524 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1525 1525
1526 updateView(); 1526 updateView();
1527 return true; 1527 return true;
1528 1528
1529#if 0 1529#if 0
1530 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1530 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1531 mCurrentSyncDevice = "qtopia-XML"; 1531 mCurrentSyncDevice = "qtopia-XML";
1532 if ( mSyncManager->mAskForPreferences ) 1532 if ( mSyncManager->mAskForPreferences )
1533 edit_sync_options(); 1533 edit_sync_options();
1534 qApp->processEvents(); 1534 qApp->processEvents();
1535 CalendarLocal* calendar = new CalendarLocal(); 1535 CalendarLocal* calendar = new CalendarLocal();
1536 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1536 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1537 bool syncOK = false; 1537 bool syncOK = false;
1538 QtopiaFormat qtopiaFormat; 1538 QtopiaFormat qtopiaFormat;
1539 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1539 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1540 bool loadOk = true; 1540 bool loadOk = true;
1541 if ( !categories.isEmpty() ) 1541 if ( !categories.isEmpty() )
1542 loadOk = qtopiaFormat.load( calendar, categories ); 1542 loadOk = qtopiaFormat.load( calendar, categories );
1543 if ( loadOk && !datebook.isEmpty() ) 1543 if ( loadOk && !datebook.isEmpty() )
1544 loadOk = qtopiaFormat.load( calendar, datebook ); 1544 loadOk = qtopiaFormat.load( calendar, datebook );
1545 if ( loadOk && !todolist.isEmpty() ) 1545 if ( loadOk && !todolist.isEmpty() )
1546 loadOk = qtopiaFormat.load( calendar, todolist ); 1546 loadOk = qtopiaFormat.load( calendar, todolist );
1547 1547
1548 if ( loadOk ) { 1548 if ( loadOk ) {
1549 getEventViewerDialog()->setSyncMode( true ); 1549 getEventViewerDialog()->setSyncMode( true );
1550 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1550 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1551 getEventViewerDialog()->setSyncMode( false ); 1551 getEventViewerDialog()->setSyncMode( false );
1552 qApp->processEvents(); 1552 qApp->processEvents();
1553 if ( syncOK ) { 1553 if ( syncOK ) {
1554 if ( mSyncManager->mWriteBackFile ) 1554 if ( mSyncManager->mWriteBackFile )
1555 { 1555 {
1556 // write back XML file 1556 // write back XML file
1557 1557
1558 } 1558 }
1559 setModified( true ); 1559 setModified( true );
1560 } 1560 }
1561 } else { 1561 } else {
1562 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1562 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1563 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1563 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1564 question, i18n("Ok")) ; 1564 question, i18n("Ok")) ;
1565 } 1565 }
1566 delete calendar; 1566 delete calendar;
1567 updateView(); 1567 updateView();
1568 return syncOK; 1568 return syncOK;
1569 1569
1570 1570
1571#endif 1571#endif
1572 1572
1573} 1573}
1574 1574
1575void CalendarView::setSyncEventsReadOnly() 1575void CalendarView::setSyncEventsReadOnly()
1576{ 1576{
1577 Event * ev; 1577 Event * ev;
1578 QPtrList<Event> eL = mCalendar->rawEvents(); 1578 QPtrList<Event> eL = mCalendar->rawEvents();
1579 ev = eL.first(); 1579 ev = eL.first();
1580 while ( ev ) { 1580 while ( ev ) {
1581 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1581 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1582 ev->setReadOnly( true ); 1582 ev->setReadOnly( true );
1583 ev = eL.next(); 1583 ev = eL.next();
1584 } 1584 }
1585} 1585}
1586bool CalendarView::openCalendar(QString filename, bool merge) 1586bool CalendarView::openCalendar(QString filename, bool merge)
1587{ 1587{
1588 1588
1589 if (filename.isEmpty()) { 1589 if (filename.isEmpty()) {
1590 return false; 1590 return false;
1591 } 1591 }
1592 1592
1593 if (!QFile::exists(filename)) { 1593 if (!QFile::exists(filename)) {
1594 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1594 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1595 return false; 1595 return false;
1596 } 1596 }
1597 1597
1598 globalFlagBlockAgenda = 1; 1598 globalFlagBlockAgenda = 1;
1599 if (!merge) mCalendar->close(); 1599 if (!merge) mCalendar->close();
1600 1600
1601 mStorage->setFileName( filename ); 1601 mStorage->setFileName( filename );
1602 1602
1603 if ( mStorage->load() ) { 1603 if ( mStorage->load() ) {
1604 if ( merge ) ;//setModified( true ); 1604 if ( merge ) ;//setModified( true );
1605 else { 1605 else {
1606 //setModified( true ); 1606 //setModified( true );
1607 mViewManager->setDocumentId( filename ); 1607 mViewManager->setDocumentId( filename );
1608 mDialogManager->setDocumentId( filename ); 1608 mDialogManager->setDocumentId( filename );
1609 mTodoList->setDocumentId( filename ); 1609 mTodoList->setDocumentId( filename );
1610 } 1610 }
1611 globalFlagBlockAgenda = 2; 1611 globalFlagBlockAgenda = 2;
1612 // if ( getLastSyncEvent() ) 1612 // if ( getLastSyncEvent() )
1613 // getLastSyncEvent()->setReadOnly( true ); 1613 // getLastSyncEvent()->setReadOnly( true );
1614 mCalendar->reInitAlarmSettings(); 1614 mCalendar->reInitAlarmSettings();
1615 setSyncEventsReadOnly(); 1615 setSyncEventsReadOnly();
1616 updateUnmanagedViews(); 1616 updateUnmanagedViews();
1617 updateView(); 1617 updateView();
1618 if ( filename != MainWindow::defaultFileName() ) { 1618 if ( filename != MainWindow::defaultFileName() ) {
1619 saveCalendar( MainWindow::defaultFileName() ); 1619 saveCalendar( MainWindow::defaultFileName() );
1620 } else { 1620 } else {
1621 QFileInfo finf ( MainWindow::defaultFileName()); 1621 QFileInfo finf ( MainWindow::defaultFileName());
1622 if ( finf.exists() ) { 1622 if ( finf.exists() ) {
1623 setLoadedFileVersion( finf.lastModified () ); 1623 setLoadedFileVersion( finf.lastModified () );
1624 } 1624 }
1625 } 1625 }
1626 return true; 1626 return true;
1627 } else { 1627 } else {
1628 // while failing to load, the calendar object could 1628 // while failing to load, the calendar object could
1629 // have become partially populated. Clear it out. 1629 // have become partially populated. Clear it out.
1630 if ( !merge ) { 1630 if ( !merge ) {
1631 mCalendar->close(); 1631 mCalendar->close();
1632 mViewManager->setDocumentId( filename ); 1632 mViewManager->setDocumentId( filename );
1633 mDialogManager->setDocumentId( filename ); 1633 mDialogManager->setDocumentId( filename );
1634 mTodoList->setDocumentId( filename ); 1634 mTodoList->setDocumentId( filename );
1635 } 1635 }
1636 1636
1637 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1637 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1638 1638
1639 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1639 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1640 globalFlagBlockAgenda = 2; 1640 globalFlagBlockAgenda = 2;
1641 mCalendar->reInitAlarmSettings(); 1641 mCalendar->reInitAlarmSettings();
1642 setSyncEventsReadOnly(); 1642 setSyncEventsReadOnly();
1643 updateUnmanagedViews(); 1643 updateUnmanagedViews();
1644 updateView(); 1644 updateView();
1645 } 1645 }
1646 return false; 1646 return false;
1647} 1647}
1648void CalendarView::showOpenError() 1648void CalendarView::showOpenError()
1649{ 1649{
1650 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1650 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1651} 1651}
1652void CalendarView::setLoadedFileVersion(QDateTime dt) 1652void CalendarView::setLoadedFileVersion(QDateTime dt)
1653{ 1653{
1654 loadedFileVersion = dt; 1654 loadedFileVersion = dt;
1655} 1655}
1656bool CalendarView::checkFileChanged(QString fn) 1656bool CalendarView::checkFileChanged(QString fn)
1657{ 1657{
1658 QFileInfo finf ( fn ); 1658 QFileInfo finf ( fn );
1659 if ( !finf.exists() ) 1659 if ( !finf.exists() )
1660 return true; 1660 return true;
1661 QDateTime dt = finf.lastModified (); 1661 QDateTime dt = finf.lastModified ();
1662 if ( dt <= loadedFileVersion ) 1662 if ( dt <= loadedFileVersion )
1663 return false; 1663 return false;
1664 return true; 1664 return true;
1665 1665
1666} 1666}
1667void CalendarView::watchSavedFile() 1667void CalendarView::watchSavedFile()
1668{ 1668{
1669 QFileInfo finf ( MainWindow::defaultFileName()); 1669 QFileInfo finf ( MainWindow::defaultFileName());
1670 if ( !finf.exists() ) 1670 if ( !finf.exists() )
1671 return; 1671 return;
1672 QDateTime dt = finf.lastModified (); 1672 QDateTime dt = finf.lastModified ();
1673 if ( dt < loadedFileVersion ) { 1673 if ( dt < loadedFileVersion ) {
1674 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1674 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1675 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1675 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1676 return; 1676 return;
1677 } 1677 }
1678 loadedFileVersion = dt; 1678 loadedFileVersion = dt;
1679} 1679}
1680 1680
1681bool CalendarView::checkFileVersion(QString fn) 1681bool CalendarView::checkFileVersion(QString fn)
1682{ 1682{
1683 QFileInfo finf ( fn ); 1683 QFileInfo finf ( fn );
1684 if ( !finf.exists() ) 1684 if ( !finf.exists() )
1685 return true; 1685 return true;
1686 QDateTime dt = finf.lastModified (); 1686 QDateTime dt = finf.lastModified ();
1687 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1687 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1688 //qDebug("file on disk version %s",dt.toString().latin1()); 1688 //qDebug("file on disk version %s",dt.toString().latin1());
1689 if ( dt <= loadedFileVersion ) 1689 if ( dt <= loadedFileVersion )
1690 return true; 1690 return true;
1691 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1691 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1692 i18n("KO/Pi Warning"),i18n("Overwrite"), 1692 i18n("KO/Pi Warning"),i18n("Overwrite"),
1693 i18n("Sync+save")); 1693 i18n("Sync+save"));
1694 1694
1695 if ( km == KMessageBox::Cancel ) 1695 if ( km == KMessageBox::Cancel )
1696 return false; 1696 return false;
1697 if ( km == KMessageBox::Yes ) 1697 if ( km == KMessageBox::Yes )
1698 return true; 1698 return true;
1699 1699
1700 setSyncDevice("deleteaftersync" ); 1700 setSyncDevice("deleteaftersync" );
1701 mSyncManager->mAskForPreferences = true; 1701 mSyncManager->mAskForPreferences = true;
1702 mSyncManager->mSyncAlgoPrefs = 3; 1702 mSyncManager->mSyncAlgoPrefs = 3;
1703 mSyncManager->mWriteBackFile = false; 1703 mSyncManager->mWriteBackFile = false;
1704 mSyncManager->mWriteBackExistingOnly = false; 1704 mSyncManager->mWriteBackExistingOnly = false;
1705 mSyncManager->mShowSyncSummary = false; 1705 mSyncManager->mShowSyncSummary = false;
1706 syncCalendar( fn, 3 ); 1706 syncCalendar( fn, 3 );
1707 Event * e = getLastSyncEvent(); 1707 Event * e = getLastSyncEvent();
1708 mCalendar->deleteEvent ( e ); 1708 mCalendar->deleteEvent ( e );
1709 updateView(); 1709 updateView();
1710 return true; 1710 return true;
1711} 1711}
1712 1712
1713bool CalendarView::saveCalendar( QString filename ) 1713bool CalendarView::saveCalendar( QString filename )
1714{ 1714{
1715 1715
1716 // Store back all unsaved data into calendar object 1716 // Store back all unsaved data into calendar object
1717 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1717 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1718 if ( mViewManager->currentView() ) 1718 if ( mViewManager->currentView() )
1719 mViewManager->currentView()->flushView(); 1719 mViewManager->currentView()->flushView();
1720 1720
1721 1721
1722 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1722 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1723 mStorage->setSaveFormat( new ICalFormat() ); 1723 mStorage->setSaveFormat( new ICalFormat() );
1724 mStorage->setFileName( filename ); 1724 mStorage->setFileName( filename );
1725 bool success; 1725 bool success;
1726 success = mStorage->save(); 1726 success = mStorage->save();
1727 if ( !success ) { 1727 if ( !success ) {
1728 return false; 1728 return false;
1729 } 1729 }
1730 if ( filename == MainWindow::defaultFileName() ) { 1730 if ( filename == MainWindow::defaultFileName() ) {
1731 setLoadedFileVersion( lfv ); 1731 setLoadedFileVersion( lfv );
1732 watchSavedFile(); 1732 watchSavedFile();
1733 } 1733 }
1734 return true; 1734 return true;
1735} 1735}
1736 1736
1737void CalendarView::closeCalendar() 1737void CalendarView::closeCalendar()
1738{ 1738{
1739 1739
1740 // child windows no longer valid 1740 // child windows no longer valid
1741 emit closingDown(); 1741 emit closingDown();
1742 1742
1743 mCalendar->close(); 1743 mCalendar->close();
1744 setModified(false); 1744 setModified(false);
1745 updateView(); 1745 updateView();
1746} 1746}
1747 1747
1748void CalendarView::archiveCalendar() 1748void CalendarView::archiveCalendar()
1749{ 1749{
1750 mDialogManager->showArchiveDialog(); 1750 mDialogManager->showArchiveDialog();
1751} 1751}
1752 1752
1753 1753
1754void CalendarView::readSettings() 1754void CalendarView::readSettings()
1755{ 1755{
1756 1756
1757 1757
1758 // mViewManager->showAgendaView(); 1758 // mViewManager->showAgendaView();
1759 QString str; 1759 QString str;
1760 //qDebug("CalendarView::readSettings() "); 1760 //qDebug("CalendarView::readSettings() ");
1761 // read settings from the KConfig, supplying reasonable 1761 // read settings from the KConfig, supplying reasonable
1762 // defaults where none are to be found 1762 // defaults where none are to be found
1763 KConfig *config = KOGlobals::config(); 1763 KConfig *config = KOGlobals::config();
1764#ifndef KORG_NOSPLITTER 1764#ifndef KORG_NOSPLITTER
1765 config->setGroup("KOrganizer Geometry"); 1765 config->setGroup("KOrganizer Geometry");
1766 1766
1767 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1767 QValueList<int> sizes = config->readIntListEntry("Separator1");
1768 if (sizes.count() != 2) { 1768 if (sizes.count() != 2) {
1769 sizes << mDateNavigator->minimumSizeHint().width(); 1769 sizes << mDateNavigator->minimumSizeHint().width();
1770 sizes << 300; 1770 sizes << 300;
1771 } 1771 }
1772 mPanner->setSizes(sizes); 1772 mPanner->setSizes(sizes);
1773 1773
1774 sizes = config->readIntListEntry("Separator2"); 1774 sizes = config->readIntListEntry("Separator2");
1775 if ( ( mResourceView && sizes.count() == 4 ) || 1775 if ( ( mResourceView && sizes.count() == 4 ) ||
1776 ( !mResourceView && sizes.count() == 3 ) ) { 1776 ( !mResourceView && sizes.count() == 3 ) ) {
1777 mLeftSplitter->setSizes(sizes); 1777 mLeftSplitter->setSizes(sizes);
1778 } 1778 }
1779#endif 1779#endif
1780 globalFlagBlockAgenda = 1; 1780 globalFlagBlockAgenda = 1;
1781 mViewManager->showAgendaView(); 1781 mViewManager->showAgendaView();
1782 //mViewManager->readSettings( config ); 1782 //mViewManager->readSettings( config );
1783 mTodoList->restoreLayout(config,QString("Todo Layout")); 1783 mTodoList->restoreLayout(config,QString("Todo Layout"));
1784 readFilterSettings(config); 1784 readFilterSettings(config);
1785 config->setGroup( "Views" ); 1785 config->setGroup( "Views" );
1786 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1786 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1787 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1787 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1788 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1788 else if ( dateCount == 7 ) mNavigator->selectWeek();
1789 else mNavigator->selectDates( dateCount ); 1789 else mNavigator->selectDates( dateCount );
1790 // mViewManager->readSettings( config ); 1790 // mViewManager->readSettings( config );
1791 updateConfig(); 1791 updateConfig();
1792 globalFlagBlockAgenda = 2; 1792 globalFlagBlockAgenda = 2;
1793 mViewManager->readSettings( config ); 1793 mViewManager->readSettings( config );
1794#ifdef DESKTOP_VERSION 1794#ifdef DESKTOP_VERSION
1795 config->setGroup("WidgetLayout"); 1795 config->setGroup("WidgetLayout");
1796 QStringList list; 1796 QStringList list;
1797 list = config->readListEntry("MainLayout"); 1797 list = config->readListEntry("MainLayout");
1798 int x,y,w,h; 1798 int x,y,w,h;
1799 if ( ! list.isEmpty() ) { 1799 if ( ! list.isEmpty() ) {
1800 x = list[0].toInt(); 1800 x = list[0].toInt();
1801 y = list[1].toInt(); 1801 y = list[1].toInt();
1802 w = list[2].toInt(); 1802 w = list[2].toInt();
1803 h = list[3].toInt(); 1803 h = list[3].toInt();
1804 topLevelWidget()->setGeometry(x,y,w,h); 1804 topLevelWidget()->setGeometry(x,y,w,h);
1805 1805
1806 } else { 1806 } else {
1807 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1807 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1808 } 1808 }
1809 list = config->readListEntry("EditEventLayout"); 1809 list = config->readListEntry("EditEventLayout");
1810 if ( ! list.isEmpty() ) { 1810 if ( ! list.isEmpty() ) {
1811 x = list[0].toInt(); 1811 x = list[0].toInt();
1812 y = list[1].toInt(); 1812 y = list[1].toInt();
1813 w = list[2].toInt(); 1813 w = list[2].toInt();
1814 h = list[3].toInt(); 1814 h = list[3].toInt();
1815 mEventEditor->setGeometry(x,y,w,h); 1815 mEventEditor->setGeometry(x,y,w,h);
1816 1816
1817 } 1817 }
1818 list = config->readListEntry("EditTodoLayout"); 1818 list = config->readListEntry("EditTodoLayout");
1819 if ( ! list.isEmpty() ) { 1819 if ( ! list.isEmpty() ) {
1820 x = list[0].toInt(); 1820 x = list[0].toInt();
1821 y = list[1].toInt(); 1821 y = list[1].toInt();
1822 w = list[2].toInt(); 1822 w = list[2].toInt();
1823 h = list[3].toInt(); 1823 h = list[3].toInt();
1824 mTodoEditor->setGeometry(x,y,w,h); 1824 mTodoEditor->setGeometry(x,y,w,h);
1825 1825
1826 } 1826 }
1827 list = config->readListEntry("ViewerLayout"); 1827 list = config->readListEntry("ViewerLayout");
1828 if ( ! list.isEmpty() ) { 1828 if ( ! list.isEmpty() ) {
1829 x = list[0].toInt(); 1829 x = list[0].toInt();
1830 y = list[1].toInt(); 1830 y = list[1].toInt();
1831 w = list[2].toInt(); 1831 w = list[2].toInt();
1832 h = list[3].toInt(); 1832 h = list[3].toInt();
1833 getEventViewerDialog()->setGeometry(x,y,w,h); 1833 getEventViewerDialog()->setGeometry(x,y,w,h);
1834 } 1834 }
1835#endif 1835#endif
1836 1836
1837} 1837}
1838 1838
1839 1839
1840void CalendarView::writeSettings() 1840void CalendarView::writeSettings()
1841{ 1841{
1842 // kdDebug() << "CalendarView::writeSettings" << endl; 1842 // kdDebug() << "CalendarView::writeSettings" << endl;
1843 1843
1844 KConfig *config = KOGlobals::config(); 1844 KConfig *config = KOGlobals::config();
1845 1845
1846#ifndef KORG_NOSPLITTER 1846#ifndef KORG_NOSPLITTER
1847 config->setGroup("KOrganizer Geometry"); 1847 config->setGroup("KOrganizer Geometry");
1848 1848
1849 QValueList<int> list = mPanner->sizes(); 1849 QValueList<int> list = mPanner->sizes();
1850 config->writeEntry("Separator1",list); 1850 config->writeEntry("Separator1",list);
1851 1851
1852 list = mLeftSplitter->sizes(); 1852 list = mLeftSplitter->sizes();
1853 config->writeEntry("Separator2",list); 1853 config->writeEntry("Separator2",list);
1854#endif 1854#endif
1855 1855
1856 mViewManager->writeSettings( config ); 1856 mViewManager->writeSettings( config );
1857 mTodoList->saveLayout(config,QString("Todo Layout")); 1857 mTodoList->saveLayout(config,QString("Todo Layout"));
1858 mDialogManager->writeSettings( config ); 1858 mDialogManager->writeSettings( config );
1859 //KOPrefs::instance()->usrWriteConfig(); 1859 //KOPrefs::instance()->usrWriteConfig();
1860 KOPrefs::instance()->writeConfig(); 1860 KOPrefs::instance()->writeConfig();
1861 1861
1862 writeFilterSettings(config); 1862 writeFilterSettings(config);
1863 1863
1864 config->setGroup( "Views" ); 1864 config->setGroup( "Views" );
1865 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1865 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1866 1866
1867#ifdef DESKTOP_VERSION 1867#ifdef DESKTOP_VERSION
1868 config->setGroup("WidgetLayout"); 1868 config->setGroup("WidgetLayout");
1869 QStringList list ;//= config->readListEntry("MainLayout"); 1869 QStringList list ;//= config->readListEntry("MainLayout");
1870 int x,y,w,h; 1870 int x,y,w,h;
1871 QWidget* wid; 1871 QWidget* wid;
1872 wid = topLevelWidget(); 1872 wid = topLevelWidget();
1873 x = wid->geometry().x(); 1873 x = wid->geometry().x();
1874 y = wid->geometry().y(); 1874 y = wid->geometry().y();
1875 w = wid->width(); 1875 w = wid->width();
1876 h = wid->height(); 1876 h = wid->height();
1877 list.clear(); 1877 list.clear();
1878 list << QString::number( x ); 1878 list << QString::number( x );
1879 list << QString::number( y ); 1879 list << QString::number( y );
1880 list << QString::number( w ); 1880 list << QString::number( w );
1881 list << QString::number( h ); 1881 list << QString::number( h );
1882 config->writeEntry("MainLayout",list ); 1882 config->writeEntry("MainLayout",list );
1883 1883
1884 wid = mEventEditor; 1884 wid = mEventEditor;
1885 x = wid->geometry().x(); 1885 x = wid->geometry().x();
1886 y = wid->geometry().y(); 1886 y = wid->geometry().y();
1887 w = wid->width(); 1887 w = wid->width();
1888 h = wid->height(); 1888 h = wid->height();
1889 list.clear(); 1889 list.clear();
1890 list << QString::number( x ); 1890 list << QString::number( x );
1891 list << QString::number( y ); 1891 list << QString::number( y );
1892 list << QString::number( w ); 1892 list << QString::number( w );
1893 list << QString::number( h ); 1893 list << QString::number( h );
1894 config->writeEntry("EditEventLayout",list ); 1894 config->writeEntry("EditEventLayout",list );
1895 1895
1896 wid = mTodoEditor; 1896 wid = mTodoEditor;
1897 x = wid->geometry().x(); 1897 x = wid->geometry().x();
1898 y = wid->geometry().y(); 1898 y = wid->geometry().y();
1899 w = wid->width(); 1899 w = wid->width();
1900 h = wid->height(); 1900 h = wid->height();
1901 list.clear(); 1901 list.clear();
1902 list << QString::number( x ); 1902 list << QString::number( x );
1903 list << QString::number( y ); 1903 list << QString::number( y );
1904 list << QString::number( w ); 1904 list << QString::number( w );
1905 list << QString::number( h ); 1905 list << QString::number( h );
1906 config->writeEntry("EditTodoLayout",list ); 1906 config->writeEntry("EditTodoLayout",list );
1907 wid = getEventViewerDialog(); 1907 wid = getEventViewerDialog();
1908 x = wid->geometry().x(); 1908 x = wid->geometry().x();
1909 y = wid->geometry().y(); 1909 y = wid->geometry().y();
1910 w = wid->width(); 1910 w = wid->width();
1911 h = wid->height(); 1911 h = wid->height();
1912 list.clear(); 1912 list.clear();
1913 list << QString::number( x ); 1913 list << QString::number( x );
1914 list << QString::number( y ); 1914 list << QString::number( y );
1915 list << QString::number( w ); 1915 list << QString::number( w );
1916 list << QString::number( h ); 1916 list << QString::number( h );
1917 config->writeEntry("ViewerLayout",list ); 1917 config->writeEntry("ViewerLayout",list );
1918 wid = mDialogManager->getSearchDialog(); 1918 wid = mDialogManager->getSearchDialog();
1919 if ( wid ) { 1919 if ( wid ) {
1920 x = wid->geometry().x(); 1920 x = wid->geometry().x();
1921 y = wid->geometry().y(); 1921 y = wid->geometry().y();
1922 w = wid->width(); 1922 w = wid->width();
1923 h = wid->height(); 1923 h = wid->height();
1924 list.clear(); 1924 list.clear();
1925 list << QString::number( x ); 1925 list << QString::number( x );
1926 list << QString::number( y ); 1926 list << QString::number( y );
1927 list << QString::number( w ); 1927 list << QString::number( w );
1928 list << QString::number( h ); 1928 list << QString::number( h );
1929 config->writeEntry("SearchLayout",list ); 1929 config->writeEntry("SearchLayout",list );
1930 } 1930 }
1931#endif 1931#endif
1932 1932
1933 1933
1934 config->sync(); 1934 config->sync();
1935} 1935}
1936 1936
1937void CalendarView::readFilterSettings(KConfig *config) 1937void CalendarView::readFilterSettings(KConfig *config)
1938{ 1938{
1939 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1939 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1940 1940
1941 mFilters.clear(); 1941 mFilters.clear();
1942 1942
1943 config->setGroup("General"); 1943 config->setGroup("General");
1944 QStringList filterList = config->readListEntry("CalendarFilters"); 1944 QStringList filterList = config->readListEntry("CalendarFilters");
1945 1945
1946 QStringList::ConstIterator it = filterList.begin(); 1946 QStringList::ConstIterator it = filterList.begin();
1947 QStringList::ConstIterator end = filterList.end(); 1947 QStringList::ConstIterator end = filterList.end();
1948 while(it != end) { 1948 while(it != end) {
1949 // kdDebug() << " filter: " << (*it) << endl; 1949 // kdDebug() << " filter: " << (*it) << endl;
1950 1950
1951 CalFilter *filter; 1951 CalFilter *filter;
1952 filter = new CalFilter(*it); 1952 filter = new CalFilter(*it);
1953 config->setGroup("Filter_" + (*it)); 1953 config->setGroup("Filter_" + (*it));
1954 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1954 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1955 filter->setCriteria(config->readNumEntry("Criteria",0)); 1955 filter->setCriteria(config->readNumEntry("Criteria",0));
1956 filter->setCategoryList(config->readListEntry("CategoryList")); 1956 filter->setCategoryList(config->readListEntry("CategoryList"));
1957 mFilters.append(filter); 1957 mFilters.append(filter);
1958 1958
1959 ++it; 1959 ++it;
1960 } 1960 }
1961 1961
1962 if (mFilters.count() == 0) { 1962 if (mFilters.count() == 0) {
1963 CalFilter *filter = new CalFilter(i18n("Default")); 1963 CalFilter *filter = new CalFilter(i18n("Default"));
1964 mFilters.append(filter); 1964 mFilters.append(filter);
1965 } 1965 }
1966 mFilterView->updateFilters(); 1966 mFilterView->updateFilters();
1967 config->setGroup("FilterView"); 1967 config->setGroup("FilterView");
1968 1968
1969 mFilterView->blockSignals(true); 1969 mFilterView->blockSignals(true);
1970 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1970 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1971 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1971 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1972 mFilterView->blockSignals(false); 1972 mFilterView->blockSignals(false);
1973 // We do it manually to avoid it being done twice by the above calls 1973 // We do it manually to avoid it being done twice by the above calls
1974 updateFilter(); 1974 updateFilter();
1975} 1975}
1976 1976
1977void CalendarView::writeFilterSettings(KConfig *config) 1977void CalendarView::writeFilterSettings(KConfig *config)
1978{ 1978{
1979 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1979 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1980 1980
1981 QStringList filterList; 1981 QStringList filterList;
1982 1982
1983 CalFilter *filter = mFilters.first(); 1983 CalFilter *filter = mFilters.first();
1984 while(filter) { 1984 while(filter) {
1985 // kdDebug() << " fn: " << filter->name() << endl; 1985 // kdDebug() << " fn: " << filter->name() << endl;
1986 filterList << filter->name(); 1986 filterList << filter->name();
1987 config->setGroup("Filter_" + filter->name()); 1987 config->setGroup("Filter_" + filter->name());
1988 config->writeEntry("Criteria",filter->criteria()); 1988 config->writeEntry("Criteria",filter->criteria());
1989 config->writeEntry("CategoryList",filter->categoryList()); 1989 config->writeEntry("CategoryList",filter->categoryList());
1990 filter = mFilters.next(); 1990 filter = mFilters.next();
1991 } 1991 }
1992 config->setGroup("General"); 1992 config->setGroup("General");
1993 config->writeEntry("CalendarFilters",filterList); 1993 config->writeEntry("CalendarFilters",filterList);
1994 1994
1995 config->setGroup("FilterView"); 1995 config->setGroup("FilterView");
1996 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1996 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1997 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1997 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1998} 1998}
1999 1999
2000 2000
2001void CalendarView::goToday() 2001void CalendarView::goToday()
2002{ 2002{
2003 if ( mViewManager->currentView()->isMonthView() ) 2003 if ( mViewManager->currentView()->isMonthView() )
2004 mNavigator->selectTodayMonth(); 2004 mNavigator->selectTodayMonth();
2005 else 2005 else
2006 mNavigator->selectToday(); 2006 mNavigator->selectToday();
2007} 2007}
2008 2008
2009void CalendarView::goNext() 2009void CalendarView::goNext()
2010{ 2010{
2011 mNavigator->selectNext(); 2011 mNavigator->selectNext();
2012} 2012}
2013 2013
2014void CalendarView::goPrevious() 2014void CalendarView::goPrevious()
2015{ 2015{
2016 mNavigator->selectPrevious(); 2016 mNavigator->selectPrevious();
2017} 2017}
2018void CalendarView::goNextMonth() 2018void CalendarView::goNextMonth()
2019{ 2019{
2020 mNavigator->selectNextMonth(); 2020 mNavigator->selectNextMonth();
2021} 2021}
2022 2022
2023void CalendarView::goPreviousMonth() 2023void CalendarView::goPreviousMonth()
2024{ 2024{
2025 mNavigator->selectPreviousMonth(); 2025 mNavigator->selectPreviousMonth();
2026} 2026}
2027void CalendarView::writeLocale() 2027void CalendarView::writeLocale()
2028{ 2028{
2029 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2029 //KPimGlobalPrefs::instance()->setGlobalConfig();
2030#if 0 2030#if 0
2031 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2031 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2032 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2032 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2033 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2033 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2034 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2034 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2035 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2035 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2036 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2036 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2037 dummy = KOPrefs::instance()->mUserDateFormatShort; 2037 dummy = KOPrefs::instance()->mUserDateFormatShort;
2038 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2038 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2039 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2039 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2040 KOPrefs::instance()->mDaylightsavingStart, 2040 KOPrefs::instance()->mDaylightsavingStart,
2041 KOPrefs::instance()->mDaylightsavingEnd ); 2041 KOPrefs::instance()->mDaylightsavingEnd );
2042 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2042 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2043#endif 2043#endif
2044} 2044}
2045void CalendarView::updateConfig() 2045void CalendarView::updateConfig()
2046{ 2046{
2047 writeLocale(); 2047 writeLocale();
2048 if ( KOPrefs::instance()->mUseAppColors ) 2048 if ( KOPrefs::instance()->mUseAppColors )
2049 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2049 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2050 emit configChanged(); 2050 emit configChanged();
2051 mTodoList->updateConfig(); 2051 mTodoList->updateConfig();
2052 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2052 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2053 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2053 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2054 // To make the "fill window" configurations work 2054 // To make the "fill window" configurations work
2055 //mViewManager->raiseCurrentView(); 2055 //mViewManager->raiseCurrentView();
2056} 2056}
2057 2057
2058 2058
2059void CalendarView::eventChanged(Event *event) 2059void CalendarView::eventChanged(Event *event)
2060{ 2060{
2061 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2061 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2062 //updateUnmanagedViews(); 2062 //updateUnmanagedViews();
2063} 2063}
2064 2064
2065void CalendarView::eventAdded(Event *event) 2065void CalendarView::eventAdded(Event *event)
2066{ 2066{
2067 changeEventDisplay(event,KOGlobals::EVENTADDED); 2067 changeEventDisplay(event,KOGlobals::EVENTADDED);
2068} 2068}
2069 2069
2070void CalendarView::eventToBeDeleted(Event *) 2070void CalendarView::eventToBeDeleted(Event *)
2071{ 2071{
2072 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2072 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2073} 2073}
2074 2074
2075void CalendarView::eventDeleted() 2075void CalendarView::eventDeleted()
2076{ 2076{
2077 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2077 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2078} 2078}
2079void CalendarView::changeTodoDisplay(Todo *which, int action) 2079void CalendarView::changeTodoDisplay(Todo *which, int action)
2080{ 2080{
2081 changeIncidenceDisplay((Incidence *)which, action); 2081 changeIncidenceDisplay((Incidence *)which, action);
2082 mDateNavigator->updateView(); //LR 2082 mDateNavigator->updateView(); //LR
2083 //mDialogManager->updateSearchDialog(); 2083 //mDialogManager->updateSearchDialog();
2084 2084
2085 if (which) { 2085 if (which) {
2086 mViewManager->updateWNview(); 2086 mViewManager->updateWNview();
2087 //mTodoList->updateView(); 2087 //mTodoList->updateView();
2088 } 2088 }
2089 2089
2090} 2090}
2091 2091
2092void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2092void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2093{ 2093{
2094 updateUnmanagedViews(); 2094 updateUnmanagedViews();
2095 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2095 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2096 if ( action == KOGlobals::EVENTDELETED ) { //delete 2096 if ( action == KOGlobals::EVENTDELETED ) { //delete
2097 mCalendar->checkAlarmForIncidence( 0, true ); 2097 mCalendar->checkAlarmForIncidence( 0, true );
2098 if ( mEventViewerDialog ) 2098 if ( mEventViewerDialog )
2099 mEventViewerDialog->hide(); 2099 mEventViewerDialog->hide();
2100 } 2100 }
2101 else 2101 else
2102 mCalendar->checkAlarmForIncidence( which , false ); 2102 mCalendar->checkAlarmForIncidence( which , false );
2103} 2103}
2104 2104
2105// most of the changeEventDisplays() right now just call the view's 2105// most of the changeEventDisplays() right now just call the view's
2106// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2106// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2107void CalendarView::changeEventDisplay(Event *which, int action) 2107void CalendarView::changeEventDisplay(Event *which, int action)
2108{ 2108{
2109 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2109 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2110 changeIncidenceDisplay((Incidence *)which, action); 2110 changeIncidenceDisplay((Incidence *)which, action);
2111 mDateNavigator->updateView(); 2111 mDateNavigator->updateView();
2112 //mDialogManager->updateSearchDialog(); 2112 //mDialogManager->updateSearchDialog();
2113 2113
2114 if (which) { 2114 if (which) {
2115 // If there is an event view visible update the display 2115 // If there is an event view visible update the display
2116 mViewManager->currentView()->changeEventDisplay(which,action); 2116 mViewManager->currentView()->changeEventDisplay(which,action);
2117 // TODO: check, if update needed 2117 // TODO: check, if update needed
2118 // if (which->getTodoStatus()) { 2118 // if (which->getTodoStatus()) {
2119 mTodoList->updateView(); 2119 mTodoList->updateView();
2120 // } 2120 // }
2121 } else { 2121 } else {
2122 mViewManager->currentView()->updateView(); 2122 mViewManager->currentView()->updateView();
2123 } 2123 }
2124} 2124}
2125 2125
2126 2126
2127void CalendarView::updateTodoViews() 2127void CalendarView::updateTodoViews()
2128{ 2128{
2129 2129
2130 mTodoList->updateView(); 2130 mTodoList->updateView();
2131 mViewManager->currentView()->updateView(); 2131 mViewManager->currentView()->updateView();
2132 2132
2133} 2133}
2134 2134
2135 2135
2136void CalendarView::updateView(const QDate &start, const QDate &end) 2136void CalendarView::updateView(const QDate &start, const QDate &end)
2137{ 2137{
2138 mTodoList->updateView(); 2138 mTodoList->updateView();
2139 mViewManager->updateView(start, end); 2139 mViewManager->updateView(start, end);
2140 //mDateNavigator->updateView(); 2140 //mDateNavigator->updateView();
2141} 2141}
2142 2142
2143void CalendarView::updateView() 2143void CalendarView::updateView()
2144{ 2144{
2145 DateList tmpList = mNavigator->selectedDates(); 2145 DateList tmpList = mNavigator->selectedDates();
2146 2146
2147 // We assume that the navigator only selects consecutive days. 2147 // We assume that the navigator only selects consecutive days.
2148 updateView( tmpList.first(), tmpList.last() ); 2148 updateView( tmpList.first(), tmpList.last() );
2149 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2149 if ( KOPrefs::instance()->mHideNonStartedTodos )
2150 mTodoList->updateView(); 2150 mTodoList->updateView();
2151} 2151}
2152 2152
2153void CalendarView::updateUnmanagedViews() 2153void CalendarView::updateUnmanagedViews()
2154{ 2154{
2155 mDateNavigator->updateDayMatrix(); 2155 mDateNavigator->updateDayMatrix();
2156} 2156}
2157 2157
2158int CalendarView::msgItemDelete() 2158int CalendarView::msgItemDelete()
2159{ 2159{
2160 return KMessageBox::warningContinueCancel(this, 2160 return KMessageBox::warningContinueCancel(this,
2161 i18n("This item will be\npermanently deleted."), 2161 i18n("This item will be\npermanently deleted."),
2162 i18n("KO/Pi Confirmation"),i18n("Delete")); 2162 i18n("KO/Pi Confirmation"),i18n("Delete"));
2163} 2163}
2164 2164
2165 2165
2166void CalendarView::edit_cut() 2166void CalendarView::edit_cut()
2167{ 2167{
2168 Event *anEvent=0; 2168 Event *anEvent=0;
2169 2169
2170 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2170 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2171 2171
2172 if (mViewManager->currentView()->isEventView()) { 2172 if (mViewManager->currentView()->isEventView()) {
2173 if ( incidence && incidence->type() == "Event" ) { 2173 if ( incidence && incidence->type() == "Event" ) {
2174 anEvent = static_cast<Event *>(incidence); 2174 anEvent = static_cast<Event *>(incidence);
2175 } 2175 }
2176 } 2176 }
2177 2177
2178 if (!anEvent) { 2178 if (!anEvent) {
2179 KNotifyClient::beep(); 2179 KNotifyClient::beep();
2180 return; 2180 return;
2181 } 2181 }
2182 DndFactory factory( mCalendar ); 2182 DndFactory factory( mCalendar );
2183 factory.cutEvent(anEvent); 2183 factory.cutEvent(anEvent);
2184 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2184 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2185} 2185}
2186 2186
2187void CalendarView::edit_copy() 2187void CalendarView::edit_copy()
2188{ 2188{
2189 Event *anEvent=0; 2189 Event *anEvent=0;
2190 2190
2191 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2191 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2192 2192
2193 if (mViewManager->currentView()->isEventView()) { 2193 if (mViewManager->currentView()->isEventView()) {
2194 if ( incidence && incidence->type() == "Event" ) { 2194 if ( incidence && incidence->type() == "Event" ) {
2195 anEvent = static_cast<Event *>(incidence); 2195 anEvent = static_cast<Event *>(incidence);
2196 } 2196 }
2197 } 2197 }
2198 2198
2199 if (!anEvent) { 2199 if (!anEvent) {
2200 KNotifyClient::beep(); 2200 KNotifyClient::beep();
2201 return; 2201 return;
2202 } 2202 }
2203 DndFactory factory( mCalendar ); 2203 DndFactory factory( mCalendar );
2204 factory.copyEvent(anEvent); 2204 factory.copyEvent(anEvent);
2205} 2205}
2206 2206
2207void CalendarView::edit_paste() 2207void CalendarView::edit_paste()
2208{ 2208{
2209 QDate date = mNavigator->selectedDates().first(); 2209 QDate date = mNavigator->selectedDates().first();
2210 2210
2211 DndFactory factory( mCalendar ); 2211 DndFactory factory( mCalendar );
2212 Event *pastedEvent = factory.pasteEvent( date ); 2212 Event *pastedEvent = factory.pasteEvent( date );
2213 2213
2214 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2214 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2215} 2215}
2216 2216
2217void CalendarView::edit_options() 2217void CalendarView::edit_options()
2218{ 2218{
2219 mDialogManager->showOptionsDialog(); 2219 mDialogManager->showOptionsDialog();
2220 //writeSettings(); 2220 //writeSettings();
2221} 2221}
2222 2222
2223 2223
2224void CalendarView::slotSelectPickerDate( QDate d) 2224void CalendarView::slotSelectPickerDate( QDate d)
2225{ 2225{
2226 mDateFrame->hide(); 2226 mDateFrame->hide();
2227 if ( mDatePickerMode == 1 ) { 2227 if ( mDatePickerMode == 1 ) {
2228 mNavigator->slotDaySelect( d ); 2228 mNavigator->slotDaySelect( d );
2229 } else if ( mDatePickerMode == 2 ) { 2229 } else if ( mDatePickerMode == 2 ) {
2230 if ( mMoveIncidence->type() == "Todo" ) { 2230 if ( mMoveIncidence->type() == "Todo" ) {
2231 Todo * to = (Todo *) mMoveIncidence; 2231 Todo * to = (Todo *) mMoveIncidence;
2232 QTime tim; 2232 QTime tim;
2233 if ( to->hasDueDate() ) 2233 if ( to->hasDueDate() )
2234 tim = to->dtDue().time(); 2234 tim = to->dtDue().time();
2235 else { 2235 else {
2236 tim = QTime ( 0,0,0 ); 2236 tim = QTime ( 0,0,0 );
2237 to->setFloats( true ); 2237 to->setFloats( true );
2238 to->setHasDueDate( true ); 2238 to->setHasDueDate( true );
2239 } 2239 }
2240 QDateTime dt ( d,tim ); 2240 QDateTime dt ( d,tim );
2241 to->setDtDue( dt ); 2241 to->setDtDue( dt );
2242 todoChanged( to ); 2242 todoChanged( to );
2243 } else { 2243 } else {
2244 if ( mMoveIncidence->doesRecur() ) { 2244 if ( mMoveIncidence->doesRecur() ) {
2245#if 0 2245#if 0
2246 // PENDING implement this 2246 // PENDING implement this
2247 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2247 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2248 mCalendar()->addIncidence( newInc ); 2248 mCalendar()->addIncidence( newInc );
2249 if ( mMoveIncidence->type() == "Todo" ) 2249 if ( mMoveIncidence->type() == "Todo" )
2250 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2250 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2251 else 2251 else
2252 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2252 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2253 mMoveIncidence = newInc; 2253 mMoveIncidence = newInc;
2254 2254
2255#endif 2255#endif
2256 } 2256 }
2257 QTime tim = mMoveIncidence->dtStart().time(); 2257 QTime tim = mMoveIncidence->dtStart().time();
2258 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2258 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2259 QDateTime dt ( d,tim ); 2259 QDateTime dt ( d,tim );
2260 mMoveIncidence->setDtStart( dt ); 2260 mMoveIncidence->setDtStart( dt );
2261 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2261 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2262 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2262 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2263 } 2263 }
2264 2264
2265 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2265 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2266 } 2266 }
2267} 2267}
2268 2268
2269void CalendarView::removeCategories() 2269void CalendarView::removeCategories()
2270{ 2270{
2271 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2271 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2272 QStringList catList = KOPrefs::instance()->mCustomCategories; 2272 QStringList catList = KOPrefs::instance()->mCustomCategories;
2273 QStringList catIncList; 2273 QStringList catIncList;
2274 QStringList newCatList; 2274 QStringList newCatList;
2275 Incidence* inc = incList.first(); 2275 Incidence* inc = incList.first();
2276 int i; 2276 int i;
2277 int count = 0; 2277 int count = 0;
2278 while ( inc ) { 2278 while ( inc ) {
2279 newCatList.clear(); 2279 newCatList.clear();
2280 catIncList = inc->categories() ; 2280 catIncList = inc->categories() ;
2281 for( i = 0; i< catIncList.count(); ++i ) { 2281 for( i = 0; i< catIncList.count(); ++i ) {
2282 if ( catList.contains (catIncList[i])) 2282 if ( catList.contains (catIncList[i]))
2283 newCatList.append( catIncList[i] ); 2283 newCatList.append( catIncList[i] );
2284 } 2284 }
2285 newCatList.sort(); 2285 newCatList.sort();
2286 inc->setCategories( newCatList.join(",") ); 2286 inc->setCategories( newCatList.join(",") );
2287 inc = incList.next(); 2287 inc = incList.next();
2288 } 2288 }
2289} 2289}
2290 2290
2291int CalendarView::addCategories() 2291int CalendarView::addCategories()
2292{ 2292{
2293 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2293 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2294 QStringList catList = KOPrefs::instance()->mCustomCategories; 2294 QStringList catList = KOPrefs::instance()->mCustomCategories;
2295 QStringList catIncList; 2295 QStringList catIncList;
2296 Incidence* inc = incList.first(); 2296 Incidence* inc = incList.first();
2297 int i; 2297 int i;
2298 int count = 0; 2298 int count = 0;
2299 while ( inc ) { 2299 while ( inc ) {
2300 catIncList = inc->categories() ; 2300 catIncList = inc->categories() ;
2301 for( i = 0; i< catIncList.count(); ++i ) { 2301 for( i = 0; i< catIncList.count(); ++i ) {
2302 if ( !catList.contains (catIncList[i])) { 2302 if ( !catList.contains (catIncList[i])) {
2303 catList.append( catIncList[i] ); 2303 catList.append( catIncList[i] );
2304 //qDebug("add cat %s ", catIncList[i].latin1()); 2304 //qDebug("add cat %s ", catIncList[i].latin1());
2305 ++count; 2305 ++count;
2306 } 2306 }
2307 } 2307 }
2308 inc = incList.next(); 2308 inc = incList.next();
2309 } 2309 }
2310 catList.sort(); 2310 catList.sort();
2311 KOPrefs::instance()->mCustomCategories = catList; 2311 KOPrefs::instance()->mCustomCategories = catList;
2312 return count; 2312 return count;
2313} 2313}
2314 2314
2315void CalendarView::manageCategories() 2315void CalendarView::manageCategories()
2316{ 2316{
2317 KOCatPrefs* cp = new KOCatPrefs(); 2317 KOCatPrefs* cp = new KOCatPrefs();
2318 cp->show(); 2318 cp->show();
2319 int w =cp->sizeHint().width() ; 2319 int w =cp->sizeHint().width() ;
2320 int h = cp->sizeHint().height() ; 2320 int h = cp->sizeHint().height() ;
2321 int dw = QApplication::desktop()->width(); 2321 int dw = QApplication::desktop()->width();
2322 int dh = QApplication::desktop()->height(); 2322 int dh = QApplication::desktop()->height();
2323 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2323 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2324 if ( !cp->exec() ) { 2324 if ( !cp->exec() ) {
2325 delete cp; 2325 delete cp;
2326 return; 2326 return;
2327 } 2327 }
2328 int count = 0; 2328 int count = 0;
2329 if ( cp->addCat() ) { 2329 if ( cp->addCat() ) {
2330 count = addCategories(); 2330 count = addCategories();
2331 if ( count ) { 2331 if ( count ) {
2332 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2332 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2333 writeSettings(); 2333 writeSettings();
2334 } else 2334 } else
2335 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2335 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2336 } else { 2336 } else {
2337 removeCategories(); 2337 removeCategories();
2338 updateView(); 2338 updateView();
2339 } 2339 }
2340 delete cp; 2340 delete cp;
2341} 2341}
2342 2342
2343void CalendarView::beamIncidence(Incidence * Inc) 2343void CalendarView::beamIncidence(Incidence * Inc)
2344{ 2344{
2345 QPtrList<Incidence> delSel ; 2345 QPtrList<Incidence> delSel ;
2346 delSel.append(Inc); 2346 delSel.append(Inc);
2347 beamIncidenceList( delSel ); 2347 beamIncidenceList( delSel );
2348} 2348}
2349void CalendarView::beamCalendar() 2349void CalendarView::beamCalendar()
2350{ 2350{
2351 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2351 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2352 //qDebug("beamCalendar() "); 2352 //qDebug("beamCalendar() ");
2353 beamIncidenceList( delSel ); 2353 beamIncidenceList( delSel );
2354} 2354}
2355void CalendarView::beamFilteredCalendar() 2355void CalendarView::beamFilteredCalendar()
2356{ 2356{
2357 QPtrList<Incidence> delSel = mCalendar->incidences(); 2357 QPtrList<Incidence> delSel = mCalendar->incidences();
2358 //qDebug("beamFilteredCalendar() "); 2358 //qDebug("beamFilteredCalendar() ");
2359 beamIncidenceList( delSel ); 2359 beamIncidenceList( delSel );
2360} 2360}
2361void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2361void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2362{ 2362{
2363 if ( beamDialog->exec () == QDialog::Rejected ) 2363 if ( beamDialog->exec () == QDialog::Rejected )
2364 return; 2364 return;
2365#ifdef DESKTOP_VERSION 2365#ifdef DESKTOP_VERSION
2366 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2366 QString fn = locateLocal( "tmp", "kopibeamfile" );
2367#else 2367#else
2368 QString fn = "/tmp/kopibeamfile"; 2368 QString fn = "/tmp/kopibeamfile";
2369#endif 2369#endif
2370 QString mes; 2370 QString mes;
2371 bool createbup = true; 2371 bool createbup = true;
2372 if ( createbup ) { 2372 if ( createbup ) {
2373 QString description = "\n"; 2373 QString description = "\n";
2374 CalendarLocal* cal = new CalendarLocal(); 2374 CalendarLocal* cal = new CalendarLocal();
2375 if ( beamDialog->beamLocal() ) 2375 if ( beamDialog->beamLocal() )
2376 cal->setLocalTime(); 2376 cal->setLocalTime();
2377 else 2377 else
2378 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2378 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2379 Incidence *incidence = delSel.first(); 2379 Incidence *incidence = delSel.first();
2380 bool addText = false; 2380 bool addText = false;
2381 if ( delSel.count() < 10 ) 2381 if ( delSel.count() < 10 )
2382 addText = true; 2382 addText = true;
2383 else { 2383 else {
2384 description.sprintf(i18n(" %d items?"),delSel.count() ); 2384 description.sprintf(i18n(" %d items?"),delSel.count() );
2385 } 2385 }
2386 while ( incidence ) { 2386 while ( incidence ) {
2387 Incidence *in = incidence->clone(); 2387 Incidence *in = incidence->clone();
2388 if ( ! in->summary().isEmpty() ) { 2388 if ( ! in->summary().isEmpty() ) {
2389 in->setDescription(""); 2389 in->setDescription("");
2390 } else { 2390 } else {
2391 in->setSummary( in->description().left(20)); 2391 in->setSummary( in->description().left(20));
2392 in->setDescription(""); 2392 in->setDescription("");
2393 } 2393 }
2394 if ( addText ) 2394 if ( addText )
2395 description += in->summary() + "\n"; 2395 description += in->summary() + "\n";
2396 cal->addIncidence( in ); 2396 cal->addIncidence( in );
2397 incidence = delSel.next(); 2397 incidence = delSel.next();
2398 } 2398 }
2399 if ( beamDialog->beamVcal() ) { 2399 if ( beamDialog->beamVcal() ) {
2400 fn += ".vcs"; 2400 fn += ".vcs";
2401 FileStorage storage( cal, fn, new VCalFormat ); 2401 FileStorage storage( cal, fn, new VCalFormat );
2402 storage.save(); 2402 storage.save();
2403 } else { 2403 } else {
2404 fn += ".ics"; 2404 fn += ".ics";
2405 FileStorage storage( cal, fn, new ICalFormat( ) ); 2405 FileStorage storage( cal, fn, new ICalFormat( ) );
2406 storage.save(); 2406 storage.save();
2407 } 2407 }
2408 delete cal; 2408 delete cal;
2409 mes = i18n("KO/Pi: Ready for beaming"); 2409 mes = i18n("KO/Pi: Ready for beaming");
2410 topLevelWidget()->setCaption(mes); 2410 topLevelWidget()->setCaption(mes);
2411 KApplication::convert2latin1( fn ); 2411 KApplication::convert2latin1( fn );
2412#ifndef DESKTOP_VERSION 2412#ifndef DESKTOP_VERSION
2413 Ir *ir = new Ir( this ); 2413 Ir *ir = new Ir( this );
2414 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2414 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2415 ir->send( fn, description, "text/x-vCalendar" ); 2415 ir->send( fn, description, "text/x-vCalendar" );
2416#endif 2416#endif
2417 } 2417 }
2418} 2418}
2419void CalendarView::beamDone( Ir *ir ) 2419void CalendarView::beamDone( Ir *ir )
2420{ 2420{
2421#ifndef DESKTOP_VERSION 2421#ifndef DESKTOP_VERSION
2422 delete ir; 2422 delete ir;
2423#endif 2423#endif
2424 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2424 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2425 topLevelWidget()->raise(); 2425 topLevelWidget()->raise();
2426} 2426}
2427 2427
2428void CalendarView::moveIncidence(Incidence * inc ) 2428void CalendarView::moveIncidence(Incidence * inc )
2429{ 2429{
2430 if ( !inc ) return; 2430 if ( !inc ) return;
2431 // qDebug("showDatePickerForIncidence( ) "); 2431 // qDebug("showDatePickerForIncidence( ) ");
2432 if ( mDateFrame->isVisible() ) 2432 if ( mDateFrame->isVisible() )
2433 mDateFrame->hide(); 2433 mDateFrame->hide();
2434 else { 2434 else {
2435 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2435 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2436 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2436 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2437 int dw = QApplication::desktop()->width(); 2437 int dw = QApplication::desktop()->width();
2438 int dh = QApplication::desktop()->height(); 2438 int dh = QApplication::desktop()->height();
2439 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2439 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2440 mDateFrame->show(); 2440 mDateFrame->show();
2441 } 2441 }
2442 mDatePickerMode = 2; 2442 mDatePickerMode = 2;
2443 mMoveIncidence = inc ; 2443 mMoveIncidence = inc ;
2444 QDate da; 2444 QDate da;
2445 if ( mMoveIncidence->type() == "Todo" ) { 2445 if ( mMoveIncidence->type() == "Todo" ) {
2446 Todo * to = (Todo *) mMoveIncidence; 2446 Todo * to = (Todo *) mMoveIncidence;
2447 if ( to->hasDueDate() ) 2447 if ( to->hasDueDate() )
2448 da = to->dtDue().date(); 2448 da = to->dtDue().date();
2449 else 2449 else
2450 da = QDate::currentDate(); 2450 da = QDate::currentDate();
2451 } else { 2451 } else {
2452 da = mMoveIncidence->dtStart().date(); 2452 da = mMoveIncidence->dtStart().date();
2453 } 2453 }
2454 //PENDING set date for recurring incidence to date of recurrence 2454 //PENDING set date for recurring incidence to date of recurrence
2455 //mMoveIncidenceOldDate; 2455 //mMoveIncidenceOldDate;
2456 mDatePicker->setDate( da ); 2456 mDatePicker->setDate( da );
2457} 2457}
2458void CalendarView::showDatePicker( ) 2458void CalendarView::showDatePicker( )
2459{ 2459{
2460 //qDebug("CalendarView::showDatePicker( ) "); 2460 //qDebug("CalendarView::showDatePicker( ) ");
2461 if ( mDateFrame->isVisible() ) 2461 if ( mDateFrame->isVisible() )
2462 mDateFrame->hide(); 2462 mDateFrame->hide();
2463 else { 2463 else {
2464 int w =mDatePicker->sizeHint().width() ; 2464 int w =mDatePicker->sizeHint().width() ;
2465 int h = mDatePicker->sizeHint().height() ; 2465 int h = mDatePicker->sizeHint().height() ;
2466 int dw = QApplication::desktop()->width(); 2466 int dw = QApplication::desktop()->width();
2467 int dh = QApplication::desktop()->height(); 2467 int dh = QApplication::desktop()->height();
2468 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2468 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2469 mDateFrame->show(); 2469 mDateFrame->show();
2470 } 2470 }
2471 mDatePickerMode = 1; 2471 mDatePickerMode = 1;
2472 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2472 mDatePicker->setDate( mNavigator->selectedDates().first() );
2473} 2473}
2474 2474
2475void CalendarView::showEventEditor() 2475void CalendarView::showEventEditor()
2476{ 2476{
2477#ifdef DESKTOP_VERSION 2477#ifdef DESKTOP_VERSION
2478 mEventEditor->show(); 2478 mEventEditor->show();
2479#else 2479#else
2480 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2480 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2481 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2481 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2482 qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2482 qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2483 delete mEventEditor; 2483 delete mEventEditor;
2484 mEventEditor = mDialogManager->getEventEditor(); 2484 mEventEditor = mDialogManager->getEventEditor();
2485 } 2485 }
2486 mEventEditor->showMaximized(); 2486 mEventEditor->showMaximized();
2487#endif 2487#endif
2488} 2488}
2489void CalendarView::showTodoEditor() 2489void CalendarView::showTodoEditor()
2490{ 2490{
2491#ifdef DESKTOP_VERSION 2491#ifdef DESKTOP_VERSION
2492 mTodoEditor->show(); 2492 mTodoEditor->show();
2493#else 2493#else
2494 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2494 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2495 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2495 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2496 qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2496 qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2497 delete mTodoEditor; 2497 delete mTodoEditor;
2498 mTodoEditor = mDialogManager->getTodoEditor(); 2498 mTodoEditor = mDialogManager->getTodoEditor();
2499 } 2499 }
2500 mTodoEditor->showMaximized(); 2500 mTodoEditor->showMaximized();
2501#endif 2501#endif
2502} 2502}
2503 2503
2504void CalendarView::cloneIncidence() 2504void CalendarView::cloneIncidence()
2505{ 2505{
2506 Incidence *incidence = currentSelection(); 2506 Incidence *incidence = currentSelection();
2507 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2507 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2508 if ( incidence ) { 2508 if ( incidence ) {
2509 cloneIncidence(incidence); 2509 cloneIncidence(incidence);
2510 } 2510 }
2511} 2511}
2512void CalendarView::moveIncidence() 2512void CalendarView::moveIncidence()
2513{ 2513{
2514 Incidence *incidence = currentSelection(); 2514 Incidence *incidence = currentSelection();
2515 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2515 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2516 if ( incidence ) { 2516 if ( incidence ) {
2517 moveIncidence(incidence); 2517 moveIncidence(incidence);
2518 } 2518 }
2519} 2519}
2520void CalendarView::beamIncidence() 2520void CalendarView::beamIncidence()
2521{ 2521{
2522 Incidence *incidence = currentSelection(); 2522 Incidence *incidence = currentSelection();
2523 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2523 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2524 if ( incidence ) { 2524 if ( incidence ) {
2525 beamIncidence(incidence); 2525 beamIncidence(incidence);
2526 } 2526 }
2527} 2527}
2528void CalendarView::toggleCancelIncidence() 2528void CalendarView::toggleCancelIncidence()
2529{ 2529{
2530 Incidence *incidence = currentSelection(); 2530 Incidence *incidence = currentSelection();
2531 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2531 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2532 if ( incidence ) { 2532 if ( incidence ) {
2533 cancelIncidence(incidence); 2533 cancelIncidence(incidence);
2534 } 2534 }
2535} 2535}
2536 2536
2537 2537
2538void CalendarView::cancelIncidence(Incidence * inc ) 2538void CalendarView::cancelIncidence(Incidence * inc )
2539{ 2539{
2540 inc->setCancelled( ! inc->cancelled() ); 2540 inc->setCancelled( ! inc->cancelled() );
2541 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2541 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2542 updateView(); 2542 updateView();
2543} 2543}
2544void CalendarView::cloneIncidence(Incidence * orgInc ) 2544void CalendarView::cloneIncidence(Incidence * orgInc )
2545{ 2545{
2546 Incidence * newInc = orgInc->clone(); 2546 Incidence * newInc = orgInc->clone();
2547 newInc->recreate(); 2547 newInc->recreate();
2548 2548
2549 if ( newInc->type() == "Todo" ) { 2549 if ( newInc->type() == "Todo" ) {
2550 Todo* t = (Todo*) newInc; 2550 Todo* t = (Todo*) newInc;
2551 showTodoEditor(); 2551 showTodoEditor();
2552 mTodoEditor->editTodo( t ); 2552 mTodoEditor->editTodo( t );
2553 if ( mTodoEditor->exec() ) { 2553 if ( mTodoEditor->exec() ) {
2554 mCalendar->addTodo( t ); 2554 mCalendar->addTodo( t );
2555 updateView(); 2555 updateView();
2556 } else { 2556 } else {
2557 delete t; 2557 delete t;
2558 } 2558 }
2559 } 2559 }
2560 else { 2560 else {
2561 Event* e = (Event*) newInc; 2561 Event* e = (Event*) newInc;
2562 showEventEditor(); 2562 showEventEditor();
2563 mEventEditor->editEvent( e ); 2563 mEventEditor->editEvent( e );
2564 if ( mEventEditor->exec() ) { 2564 if ( mEventEditor->exec() ) {
2565 mCalendar->addEvent( e ); 2565 mCalendar->addEvent( e );
2566 updateView(); 2566 updateView();
2567 } else { 2567 } else {
2568 delete e; 2568 delete e;
2569 } 2569 }
2570 } 2570 }
2571} 2571}
2572 2572
2573void CalendarView::newEvent() 2573void CalendarView::newEvent()
2574{ 2574{
2575 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2575 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2576 KOAgendaView *aView = mViewManager->agendaView(); 2576 KOAgendaView *aView = mViewManager->agendaView();
2577 if (aView) { 2577 if (aView) {
2578 if (aView->selectionStart().isValid()) { 2578 if (aView->selectionStart().isValid()) {
2579 if (aView->selectedIsAllDay()) { 2579 if (aView->selectedIsAllDay()) {
2580 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2580 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2581 } else { 2581 } else {
2582 newEvent(aView->selectionStart(),aView->selectionEnd()); 2582 newEvent(aView->selectionStart(),aView->selectionEnd());
2583 } 2583 }
2584 return; 2584 return;
2585 } 2585 }
2586 } 2586 }
2587 2587
2588 QDate date = mNavigator->selectedDates().first(); 2588 QDate date = mNavigator->selectedDates().first();
2589 QDateTime current = QDateTime::currentDateTime(); 2589 QDateTime current = QDateTime::currentDateTime();
2590 if ( date <= current.date() ) { 2590 if ( date <= current.date() ) {
2591 int hour = current.time().hour() +1; 2591 int hour = current.time().hour() +1;
2592 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2592 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2593 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2593 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2594 } else 2594 } else
2595 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2595 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2596 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2596 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2597 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2597 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2598} 2598}
2599 2599
2600void CalendarView::newEvent(QDateTime fh) 2600void CalendarView::newEvent(QDateTime fh)
2601{ 2601{
2602 newEvent(fh, 2602 newEvent(fh,
2603 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2603 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2604} 2604}
2605 2605
2606void CalendarView::newEvent(QDate dt) 2606void CalendarView::newEvent(QDate dt)
2607{ 2607{
2608 newEvent(QDateTime(dt, QTime(0,0,0)), 2608 newEvent(QDateTime(dt, QTime(0,0,0)),
2609 QDateTime(dt, QTime(0,0,0)), true); 2609 QDateTime(dt, QTime(0,0,0)), true);
2610} 2610}
2611 2611
2612void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2612void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2613{ 2613{
2614 2614
2615 showEventEditor(); 2615 showEventEditor();
2616 mEventEditor->newEvent(fromHint,toHint,allDay); 2616 mEventEditor->newEvent(fromHint,toHint,allDay);
2617 if ( mFilterView->filtersEnabled() ) { 2617 if ( mFilterView->filtersEnabled() ) {
2618 CalFilter *filter = mFilterView->selectedFilter(); 2618 CalFilter *filter = mFilterView->selectedFilter();
2619 if (filter && filter->showCategories()) { 2619 if (filter && filter->showCategories()) {
2620 mEventEditor->setCategories(filter->categoryList().join(",") ); 2620 mEventEditor->setCategories(filter->categoryList().join(",") );
2621 } 2621 }
2622 if ( filter ) 2622 if ( filter )
2623 mEventEditor->setSecrecy( filter->getSecrecy() ); 2623 mEventEditor->setSecrecy( filter->getSecrecy() );
2624 } 2624 }
2625} 2625}
2626void CalendarView::todoAdded(Todo * t) 2626void CalendarView::todoAdded(Todo * t)
2627{ 2627{
2628 2628
2629 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2629 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2630 updateTodoViews(); 2630 updateTodoViews();
2631} 2631}
2632void CalendarView::todoChanged(Todo * t) 2632void CalendarView::todoChanged(Todo * t)
2633{ 2633{
2634 emit todoModified( t, 4 ); 2634 emit todoModified( t, 4 );
2635 // updateTodoViews(); 2635 // updateTodoViews();
2636} 2636}
2637void CalendarView::todoToBeDeleted(Todo *) 2637void CalendarView::todoToBeDeleted(Todo *)
2638{ 2638{
2639 //qDebug("todoToBeDeleted(Todo *) "); 2639 //qDebug("todoToBeDeleted(Todo *) ");
2640 updateTodoViews(); 2640 updateTodoViews();
2641} 2641}
2642void CalendarView::todoDeleted() 2642void CalendarView::todoDeleted()
2643{ 2643{
2644 //qDebug(" todoDeleted()"); 2644 //qDebug(" todoDeleted()");
2645 updateTodoViews(); 2645 updateTodoViews();
2646} 2646}
2647 2647
2648 2648
2649 2649
2650void CalendarView::newTodo() 2650void CalendarView::newTodo()
2651{ 2651{
2652 2652
2653 showTodoEditor(); 2653 showTodoEditor();
2654 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2654 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2655 if ( mFilterView->filtersEnabled() ) { 2655 if ( mFilterView->filtersEnabled() ) {
2656 CalFilter *filter = mFilterView->selectedFilter(); 2656 CalFilter *filter = mFilterView->selectedFilter();
2657 if (filter && filter->showCategories()) { 2657 if (filter && filter->showCategories()) {
2658 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2658 mTodoEditor->setCategories(filter->categoryList().join(",") );
2659 } 2659 }
2660 if ( filter ) 2660 if ( filter )
2661 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2661 mTodoEditor->setSecrecy( filter->getSecrecy() );
2662 } 2662 }
2663} 2663}
2664 2664
2665void CalendarView::newSubTodo() 2665void CalendarView::newSubTodo()
2666{ 2666{
2667 Todo *todo = selectedTodo(); 2667 Todo *todo = selectedTodo();
2668 if ( todo ) newSubTodo( todo ); 2668 if ( todo ) newSubTodo( todo );
2669} 2669}
2670 2670
2671void CalendarView::newSubTodo(Todo *parentEvent) 2671void CalendarView::newSubTodo(Todo *parentEvent)
2672{ 2672{
2673 2673
2674 showTodoEditor(); 2674 showTodoEditor();
2675 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2675 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2676} 2676}
2677 2677
2678void CalendarView::newFloatingEvent() 2678void CalendarView::newFloatingEvent()
2679{ 2679{
2680 DateList tmpList = mNavigator->selectedDates(); 2680 DateList tmpList = mNavigator->selectedDates();
2681 QDate date = tmpList.first(); 2681 QDate date = tmpList.first();
2682 2682
2683 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2683 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2684 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2684 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2685} 2685}
2686 2686
2687 2687
2688void CalendarView::editEvent( Event *event ) 2688void CalendarView::editEvent( Event *event )
2689{ 2689{
2690 2690
2691 if ( !event ) return; 2691 if ( !event ) return;
2692 if ( event->isReadOnly() ) { 2692 if ( event->isReadOnly() ) {
2693 showEvent( event ); 2693 showEvent( event );
2694 return; 2694 return;
2695 } 2695 }
2696 showEventEditor(); 2696 showEventEditor();
2697 mEventEditor->editEvent( event , mFlagEditDescription); 2697 mEventEditor->editEvent( event , mFlagEditDescription);
2698} 2698}
2699void CalendarView::editJournal( Journal *jour ) 2699void CalendarView::editJournal( Journal *jour )
2700{ 2700{
2701 if ( !jour ) return; 2701 if ( !jour ) return;
2702 mDialogManager->hideSearchDialog(); 2702 mDialogManager->hideSearchDialog();
2703 mViewManager->showJournalView(); 2703 mViewManager->showJournalView();
2704 mNavigator->slotDaySelect( jour->dtStart().date() ); 2704 mNavigator->slotDaySelect( jour->dtStart().date() );
2705} 2705}
2706void CalendarView::editTodo( Todo *todo ) 2706void CalendarView::editTodo( Todo *todo )
2707{ 2707{
2708 if ( !todo ) return; 2708 if ( !todo ) return;
2709 2709
2710 if ( todo->isReadOnly() ) { 2710 if ( todo->isReadOnly() ) {
2711 showTodo( todo ); 2711 showTodo( todo );
2712 return; 2712 return;
2713 } 2713 }
2714 showTodoEditor(); 2714 showTodoEditor();
2715 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2715 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2716 2716
2717} 2717}
2718 2718
2719KOEventViewerDialog* CalendarView::getEventViewerDialog() 2719KOEventViewerDialog* CalendarView::getEventViewerDialog()
2720{ 2720{
2721 if ( !mEventViewerDialog ) { 2721 if ( !mEventViewerDialog ) {
2722 mEventViewerDialog = new KOEventViewerDialog(this); 2722 mEventViewerDialog = new KOEventViewerDialog(this);
2723 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2723 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2724 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2724 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2725 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2725 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2726 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2726 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2727 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2727 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2728 viewManager(), SLOT( showAgendaView( bool ) ) ); 2728 viewManager(), SLOT( showAgendaView( bool ) ) );
2729 mEventViewerDialog->resize( 640, 480 ); 2729 mEventViewerDialog->resize( 640, 480 );
2730 2730
2731 } 2731 }
2732 return mEventViewerDialog; 2732 return mEventViewerDialog;
2733} 2733}
2734void CalendarView::showEvent(Event *event) 2734void CalendarView::showEvent(Event *event)
2735{ 2735{
2736 getEventViewerDialog()->setEvent(event); 2736 getEventViewerDialog()->setEvent(event);
2737 getEventViewerDialog()->showMe(); 2737 getEventViewerDialog()->showMe();
2738} 2738}
2739 2739
2740void CalendarView::showTodo(Todo *event) 2740void CalendarView::showTodo(Todo *event)
2741{ 2741{
2742 getEventViewerDialog()->setTodo(event); 2742 getEventViewerDialog()->setTodo(event);
diff --git a/libkcal/syncdefines.h b/libkcal/syncdefines.h
index 704a670..f3204a2 100644
--- a/libkcal/syncdefines.h
+++ b/libkcal/syncdefines.h
@@ -1,24 +1,30 @@
1 1
2#ifndef _KSYNC_DEFINES_H_ 2#ifndef _KSYNC_DEFINES_H_
3#define _KSYNC_DEFINES_H_ 3#define _KSYNC_DEFINES_H_
4 4
5 enum TargetApp {
6 KOPI = 0,
7 KAPI = 1,
8 PWMPI = 2 };
9
10
5#define SYNC_PREF_LOCAL 0 11#define SYNC_PREF_LOCAL 0
6#define SYNC_PREF_REMOTE 1 12#define SYNC_PREF_REMOTE 1
7#define SYNC_PREF_NEWEST 2 13#define SYNC_PREF_NEWEST 2
8#define SYNC_PREF_ASK 3 14#define SYNC_PREF_ASK 3
9#define SYNC_PREF_FORCE_LOCAL 4 15#define SYNC_PREF_FORCE_LOCAL 4
10#define SYNC_PREF_FORCE_REMOTE 5 16#define SYNC_PREF_FORCE_REMOTE 5
11#define SYNC_PREF_TAKE_BOTH 6 17#define SYNC_PREF_TAKE_BOTH 6
12 18
13#define SYNC_MODE_NORMAL 0 19#define SYNC_MODE_NORMAL 0
14#define SYNC_MODE_EXTERNAL 1 20#define SYNC_MODE_EXTERNAL 1
15 21
16#define SYNC_TEMPSTATE_INITIAL 0 22#define SYNC_TEMPSTATE_INITIAL 0
17#define SYNC_TEMPSTATE_ADDED_EXTERNAL -1 23#define SYNC_TEMPSTATE_ADDED_EXTERNAL -1
18#define SYNC_TEMPSTATE_NEW_EXTERNAL -2 24#define SYNC_TEMPSTATE_NEW_EXTERNAL -2
19#define SYNC_TEMPSTATE_DELETE -3 25#define SYNC_TEMPSTATE_DELETE -3
20#define SYNC_TEMPSTATE_NEW_ID -4 26#define SYNC_TEMPSTATE_NEW_ID -4
21#define SYNC_TEMPSTATE_NEW_CSUM -5 27#define SYNC_TEMPSTATE_NEW_CSUM -5
22 28
23 29
24#endif 30#endif
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 6f68d84..33b4a65 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1472 +1,1476 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include "ksyncmanager.h" 23#include "ksyncmanager.h"
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <unistd.h> 28#include <unistd.h>
29#endif 29#endif
30 30
31 31
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qbuttongroup.h> 42#include <qbuttongroup.h>
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qlabel.h> 50#include <qlabel.h>
51#include <qcheckbox.h> 51#include <qcheckbox.h>
52 52
53#include <klocale.h> 53#include <klocale.h>
54#include <kglobal.h> 54#include <kglobal.h>
55#include <kconfig.h> 55#include <kconfig.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57 57
58QDateTime KSyncManager::mRequestedSyncEvent; 58QDateTime KSyncManager::mRequestedSyncEvent;
59 59
60 60
61KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 61KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
62 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) 62 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu)
63{ 63{
64 mServerSocket = 0; 64 mServerSocket = 0;
65 bar = new QProgressBar ( 1, 0 ); 65 bar = new QProgressBar ( 1, 0 );
66 bar->setCaption (""); 66 bar->setCaption ("");
67 67 mWriteBackInPast = 2;
68 int w = 300; 68 int w = 300;
69 if ( QApplication::desktop()->width() < 320 ) 69 if ( QApplication::desktop()->width() < 320 )
70 w = 220; 70 w = 220;
71 int h = bar->sizeHint().height() ; 71 int h = bar->sizeHint().height() ;
72 int dw = QApplication::desktop()->width(); 72 int dw = QApplication::desktop()->width();
73 int dh = QApplication::desktop()->height(); 73 int dh = QApplication::desktop()->height();
74 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 74 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
75 if ( mPrefs->mPassiveSyncAutoStart ) 75 if ( mPrefs->mPassiveSyncAutoStart )
76 enableQuick( false ); 76 enableQuick( false );
77 77
78} 78}
79 79
80KSyncManager::~KSyncManager() 80KSyncManager::~KSyncManager()
81{ 81{
82 delete bar; 82 delete bar;
83} 83}
84 84
85 85
86void KSyncManager::fillSyncMenu() 86void KSyncManager::fillSyncMenu()
87{ 87{
88 if ( mSyncMenu->count() ) 88 if ( mSyncMenu->count() )
89 mSyncMenu->clear(); 89 mSyncMenu->clear();
90 90
91 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 91 mSyncMenu->insertItem( i18n("Configure..."), 0 );
92 mSyncMenu->insertSeparator(); 92 mSyncMenu->insertSeparator();
93 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); 93 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu );
94 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); 94 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
95 clearMenu->insertItem( i18n("For all profiles"), 1 ); 95 clearMenu->insertItem( i18n("For all profiles"), 1 );
96 clearMenu->insertSeparator(); 96 clearMenu->insertSeparator();
97 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); 97 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
98 mSyncMenu->insertSeparator(); 98 mSyncMenu->insertSeparator();
99 if ( mServerSocket == 0 ) { 99 if ( mServerSocket == 0 ) {
100 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 100 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
101 } else { 101 } else {
102 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 102 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
103 } 103 }
104 mSyncMenu->insertSeparator(); 104 mSyncMenu->insertSeparator();
105 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 105 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
106 mSyncMenu->insertSeparator(); 106 mSyncMenu->insertSeparator();
107 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 107 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
108 config.setGroup("General"); 108 config.setGroup("General");
109 QStringList prof = config.readListEntry("SyncProfileNames"); 109 QStringList prof = config.readListEntry("SyncProfileNames");
110 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 110 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
111 if ( prof.count() < 2 ) { 111 if ( prof.count() < 2 ) {
112 prof.clear(); 112 prof.clear();
113 QString externalName; 113 QString externalName;
114#ifdef DESKTOP_VERSION 114#ifdef DESKTOP_VERSION
115#ifdef _WIN32_ 115#ifdef _WIN32_
116 externalName = "OutLook(not_implemented)"; 116 externalName = "OutLook(not_implemented)";
117#else 117#else
118 externalName = "KDE_Desktop"; 118 externalName = "KDE_Desktop";
119#endif 119#endif
120#else 120#else
121 externalName = "Sharp_DTM"; 121 externalName = "Sharp_DTM";
122#endif 122#endif
123 prof << externalName; 123 prof << externalName;
124 prof << i18n("Local_file"); 124 prof << i18n("Local_file");
125 prof << i18n("Last_file"); 125 prof << i18n("Last_file");
126 KSyncProfile* temp = new KSyncProfile (); 126 KSyncProfile* temp = new KSyncProfile ();
127 temp->setName( prof[0] ); 127 temp->setName( prof[0] );
128 temp->writeConfig(&config); 128 temp->writeConfig(&config);
129 temp->setName( prof[1] ); 129 temp->setName( prof[1] );
130 temp->writeConfig(&config); 130 temp->writeConfig(&config);
131 temp->setName( prof[2] ); 131 temp->setName( prof[2] );
132 temp->writeConfig(&config); 132 temp->writeConfig(&config);
133 config.setGroup("General"); 133 config.setGroup("General");
134 config.writeEntry("SyncProfileNames",prof); 134 config.writeEntry("SyncProfileNames",prof);
135 config.writeEntry("ExternSyncProfiles",externalName); 135 config.writeEntry("ExternSyncProfiles",externalName);
136 config.sync(); 136 config.sync();
137 delete temp; 137 delete temp;
138 } 138 }
139 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 139 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
140 mSyncProfileNames = prof; 140 mSyncProfileNames = prof;
141 unsigned int i; 141 unsigned int i;
142 for ( i = 0; i < prof.count(); ++i ) { 142 for ( i = 0; i < prof.count(); ++i ) {
143 mSyncMenu->insertItem( prof[i], 1000+i ); 143 mSyncMenu->insertItem( prof[i], 1000+i );
144 clearMenu->insertItem( prof[i], 1000+i ); 144 clearMenu->insertItem( prof[i], 1000+i );
145 if ( i == 2 ) 145 if ( i == 2 )
146 mSyncMenu->insertSeparator(); 146 mSyncMenu->insertSeparator();
147 } 147 }
148 QDir app_dir; 148 QDir app_dir;
149 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 149 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
150 if ( mTargetApp == PWMPI) { 150 if ( mTargetApp == PWMPI) {
151 mSyncMenu->removeItem( 1000 ); 151 mSyncMenu->removeItem( 1000 );
152 clearMenu->removeItem( 1000 ); 152 clearMenu->removeItem( 1000 );
153 } 153 }
154#ifndef DESKTOP_VERSION 154#ifndef DESKTOP_VERSION
155 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 155 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
156 mSyncMenu->removeItem( 1000 ); 156 mSyncMenu->removeItem( 1000 );
157 clearMenu->removeItem( 1000 ); 157 clearMenu->removeItem( 1000 );
158 } 158 }
159#endif 159#endif
160 mSyncMenu->removeItem( 1002 ); 160 mSyncMenu->removeItem( 1002 );
161 clearMenu->removeItem( 1002 ); 161 clearMenu->removeItem( 1002 );
162} 162}
163void KSyncManager::slotClearMenu( int action ) 163void KSyncManager::slotClearMenu( int action )
164{ 164{
165 QString syncDevice; 165 QString syncDevice;
166 if ( action > 999 ) { 166 if ( action > 999 ) {
167 syncDevice = mSyncProfileNames[action - 1000] ; 167 syncDevice = mSyncProfileNames[action - 1000] ;
168 } 168 }
169 169
170 170
171 171
172 int result = 0; 172 int result = 0;
173 QString sd; 173 QString sd;
174 if ( syncDevice.isEmpty() ) 174 if ( syncDevice.isEmpty() )
175 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 175 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
176 else 176 else
177 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 177 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
178 178
179 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 179 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
180 0, 1 ); 180 0, 1 );
181 if ( result ) 181 if ( result )
182 return; 182 return;
183 mImplementation->removeSyncInfo( syncDevice ); 183 mImplementation->removeSyncInfo( syncDevice );
184} 184}
185void KSyncManager::slotSyncMenu( int action ) 185void KSyncManager::slotSyncMenu( int action )
186{ 186{
187 qDebug("syncaction %d ", action); 187 qDebug("syncaction %d ", action);
188 if ( action == 5000 ) 188 if ( action == 5000 )
189 return; 189 return;
190 mSyncWithDesktop = false; 190 mSyncWithDesktop = false;
191 if ( action == 0 ) { 191 if ( action == 0 ) {
192 192
193 // seems to be a Qt2 event handling bug 193 // seems to be a Qt2 event handling bug
194 // syncmenu.clear causes a segfault at first time 194 // syncmenu.clear causes a segfault at first time
195 // when we call it after the main event loop, it is ok 195 // when we call it after the main event loop, it is ok
196 // same behaviour when calling OM/Pi via QCOP for the first time 196 // same behaviour when calling OM/Pi via QCOP for the first time
197 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 197 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
198 //confSync(); 198 //confSync();
199 199
200 return; 200 return;
201 } 201 }
202 if ( action == 1 ) { 202 if ( action == 1 ) {
203 multiSync( true ); 203 multiSync( true );
204 return; 204 return;
205 } 205 }
206 if ( action == 2 ) { 206 if ( action == 2 ) {
207 enableQuick(); 207 enableQuick();
208 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 208 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
209 return; 209 return;
210 } 210 }
211 if ( action == 3 ) { 211 if ( action == 3 ) {
212 delete mServerSocket; 212 delete mServerSocket;
213 mServerSocket = 0; 213 mServerSocket = 0;
214 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 214 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
215 return; 215 return;
216 } 216 }
217 217
218 if (blockSave()) 218 if (blockSave())
219 return; 219 return;
220 220
221 setBlockSave(true); 221 setBlockSave(true);
222 bool silent = false; 222 bool silent = false;
223 if ( action == 999 ) { 223 if ( action == 999 ) {
224 //special mode for silent syncing 224 //special mode for silent syncing
225 action = 1000; 225 action = 1000;
226 silent = true; 226 silent = true;
227 } 227 }
228 228
229 mCurrentSyncProfile = action - 1000 ; 229 mCurrentSyncProfile = action - 1000 ;
230 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 230 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
231 mCurrentSyncName = mLocalMachineName ; 231 mCurrentSyncName = mLocalMachineName ;
232 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 232 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
233 KSyncProfile* temp = new KSyncProfile (); 233 KSyncProfile* temp = new KSyncProfile ();
234 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 234 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
235 temp->readConfig(&config); 235 temp->readConfig(&config);
236 if (silent) { 236 if (silent) {
237 mAskForPreferences = false; 237 mAskForPreferences = false;
238 mShowSyncSummary = false; 238 mShowSyncSummary = false;
239 mWriteBackFile = true; 239 mWriteBackFile = true;
240 mSyncAlgoPrefs = 2;// take newest 240 mSyncAlgoPrefs = 2;// take newest
241 } 241 }
242 else { 242 else {
243 mAskForPreferences = temp->getAskForPreferences(); 243 mAskForPreferences = temp->getAskForPreferences();
244 mShowSyncSummary = temp->getShowSummaryAfterSync(); 244 mShowSyncSummary = temp->getShowSummaryAfterSync();
245 mWriteBackFile = temp->getWriteBackFile(); 245 mWriteBackFile = temp->getWriteBackFile();
246 mSyncAlgoPrefs = temp->getSyncPrefs(); 246 mSyncAlgoPrefs = temp->getSyncPrefs();
247 } 247 }
248 mWriteBackExistingOnly = temp->getWriteBackExisting(); 248 mWriteBackExistingOnly = temp->getWriteBackExisting();
249 mIsKapiFile = temp->getIsKapiFile(); 249 mIsKapiFile = temp->getIsKapiFile();
250 mWriteBackInFuture = 0; 250 mWriteBackInFuture = 0;
251 if ( temp->getWriteBackFuture() ) 251 if ( temp->getWriteBackFuture() ) {
252 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 252 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
253 mWriteBackInPast = temp->getWriteBackPastWeeks( );
254 }
253 255
254 if ( action == 1000 ) { 256 if ( action == 1000 ) {
255 mIsKapiFile = false; 257 mIsKapiFile = false;
256#ifdef DESKTOP_VERSION 258#ifdef DESKTOP_VERSION
257 syncKDE(); 259 syncKDE();
258#else 260#else
259 syncSharp(); 261 syncSharp();
260#endif 262#endif
261 263
262 } else if ( action == 1001 ) { 264 } else if ( action == 1001 ) {
263 syncLocalFile(); 265 syncLocalFile();
264 266
265 } else if ( action == 1002 ) { 267 } else if ( action == 1002 ) {
266 mWriteBackFile = false; 268 mWriteBackFile = false;
267 mAskForPreferences = false; 269 mAskForPreferences = false;
268 mShowSyncSummary = false; 270 mShowSyncSummary = false;
269 mSyncAlgoPrefs = 3; 271 mSyncAlgoPrefs = 3;
270 quickSyncLocalFile(); 272 quickSyncLocalFile();
271 273
272 } else if ( action >= 1003 ) { 274 } else if ( action >= 1003 ) {
273 if ( temp->getIsLocalFileSync() ) { 275 if ( temp->getIsLocalFileSync() ) {
274 switch(mTargetApp) 276 switch(mTargetApp)
275 { 277 {
276 case (KAPI): 278 case (KAPI):
277 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 279 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
278 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 280 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
279 break; 281 break;
280 case (KOPI): 282 case (KOPI):
281 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 283 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
282 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 284 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
283 break; 285 break;
284 case (PWMPI): 286 case (PWMPI):
285 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 287 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
286 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 288 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
287 break; 289 break;
288 default: 290 default:
289 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 291 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
290 break; 292 break;
291 293
292 } 294 }
293 } else { 295 } else {
294 if ( temp->getIsPhoneSync() ) { 296 if ( temp->getIsPhoneSync() ) {
295 mPhoneDevice = temp->getPhoneDevice( ) ; 297 mPhoneDevice = temp->getPhoneDevice( ) ;
296 mPhoneConnection = temp->getPhoneConnection( ); 298 mPhoneConnection = temp->getPhoneConnection( );
297 mPhoneModel = temp->getPhoneModel( ); 299 mPhoneModel = temp->getPhoneModel( );
298 syncPhone(); 300 syncPhone();
299 } else if ( temp->getIsPiSync() ) { 301 } else if ( temp->getIsPiSync() ) {
300 if ( mTargetApp == KAPI ) { 302 if ( mTargetApp == KAPI ) {
301 mPassWordPiSync = temp->getRemotePwAB(); 303 mPassWordPiSync = temp->getRemotePwAB();
302 mActiveSyncPort = temp->getRemotePortAB(); 304 mActiveSyncPort = temp->getRemotePortAB();
303 mActiveSyncIP = temp->getRemoteIPAB(); 305 mActiveSyncIP = temp->getRemoteIPAB();
304 } else if ( mTargetApp == KOPI ) { 306 } else if ( mTargetApp == KOPI ) {
305 mPassWordPiSync = temp->getRemotePw(); 307 mPassWordPiSync = temp->getRemotePw();
306 mActiveSyncPort = temp->getRemotePort(); 308 mActiveSyncPort = temp->getRemotePort();
307 mActiveSyncIP = temp->getRemoteIP(); 309 mActiveSyncIP = temp->getRemoteIP();
308 } else { 310 } else {
309 mPassWordPiSync = temp->getRemotePwPWM(); 311 mPassWordPiSync = temp->getRemotePwPWM();
310 mActiveSyncPort = temp->getRemotePortPWM(); 312 mActiveSyncPort = temp->getRemotePortPWM();
311 mActiveSyncIP = temp->getRemoteIPPWM(); 313 mActiveSyncIP = temp->getRemoteIPPWM();
312 } 314 }
313 syncPi(); 315 syncPi();
314 while ( !mPisyncFinished ) { 316 while ( !mPisyncFinished ) {
315 //qDebug("waiting "); 317 //qDebug("waiting ");
316 qApp->processEvents(); 318 qApp->processEvents();
317 } 319 }
318 } else 320 } else
319 syncRemote( temp ); 321 syncRemote( temp );
320 322
321 } 323 }
322 } 324 }
323 delete temp; 325 delete temp;
324 setBlockSave(false); 326 setBlockSave(false);
325} 327}
326 328
327void KSyncManager::enableQuick( bool ask ) 329void KSyncManager::enableQuick( bool ask )
328{ 330{
329 bool autoStart; 331 bool autoStart;
330 bool changed = false; 332 bool changed = false;
331 if ( ask ) { 333 if ( ask ) {
332 QDialog dia ( 0, "input-dialog", true ); 334 QDialog dia ( 0, "input-dialog", true );
333 QLineEdit lab ( &dia ); 335 QLineEdit lab ( &dia );
334 QVBoxLayout lay( &dia ); 336 QVBoxLayout lay( &dia );
335 lab.setText( mPrefs->mPassiveSyncPort ); 337 lab.setText( mPrefs->mPassiveSyncPort );
336 lay.setMargin(7); 338 lay.setMargin(7);
337 lay.setSpacing(7); 339 lay.setSpacing(7);
338 int po = 9197+mTargetApp; 340 int po = 9197+mTargetApp;
339 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 341 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
340 lay.addWidget( &label); 342 lay.addWidget( &label);
341 lay.addWidget( &lab); 343 lay.addWidget( &lab);
342 344
343 QLineEdit lepw ( &dia ); 345 QLineEdit lepw ( &dia );
344 lepw.setText( mPrefs->mPassiveSyncPw ); 346 lepw.setText( mPrefs->mPassiveSyncPw );
345 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 347 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
346 lay.addWidget( &label2); 348 lay.addWidget( &label2);
347 lay.addWidget( &lepw); 349 lay.addWidget( &lepw);
348 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 350 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
349 lay.addWidget( &autostart); 351 lay.addWidget( &autostart);
350 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 352 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
351#ifdef DESKTOP_VERSION 353#ifdef DESKTOP_VERSION
352#ifdef _WIN32_ 354#ifdef _WIN32_
353 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 355 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
354 syncdesktop.hide();// not implemented! 356 syncdesktop.hide();// not implemented!
355#else 357#else
356 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 358 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
357#endif 359#endif
358 lay.addWidget( &syncdesktop); 360 lay.addWidget( &syncdesktop);
359#else 361#else
360 mPrefs->mPassiveSyncWithDesktop = false; 362 mPrefs->mPassiveSyncWithDesktop = false;
361 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 363 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
362 syncdesktop.hide(); 364 syncdesktop.hide();
363#endif 365#endif
364 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 366 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
365 367
366 dia.setFixedSize( 230,120 ); 368 dia.setFixedSize( 230,120 );
367 dia.setCaption( i18n("Enter port for Pi-Sync") ); 369 dia.setCaption( i18n("Enter port for Pi-Sync") );
368 QPushButton pb ( "OK", &dia); 370 QPushButton pb ( "OK", &dia);
369 lay.addWidget( &pb ); 371 lay.addWidget( &pb );
370 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 372 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
371 dia.show(); 373 dia.show();
372 if ( ! dia.exec() ) 374 if ( ! dia.exec() )
373 return; 375 return;
374 dia.hide(); 376 dia.hide();
375 qApp->processEvents(); 377 qApp->processEvents();
376 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 378 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
377 changed = true; 379 changed = true;
378 mPrefs->mPassiveSyncPw = lepw.text(); 380 mPrefs->mPassiveSyncPw = lepw.text();
379 } 381 }
380 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 382 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
381 mPrefs->mPassiveSyncPort = lab.text(); 383 mPrefs->mPassiveSyncPort = lab.text();
382 changed = true; 384 changed = true;
383 } 385 }
384 autoStart = autostart.isChecked(); 386 autoStart = autostart.isChecked();
385 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 387 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
386 changed = true; 388 changed = true;
387 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 389 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
388 } 390 }
389 } 391 }
390 else 392 else
391 autoStart = mPrefs->mPassiveSyncAutoStart; 393 autoStart = mPrefs->mPassiveSyncAutoStart;
392 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 394 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
393 changed = true; 395 changed = true;
394 bool ok; 396 bool ok;
395 mPrefs->mPassiveSyncAutoStart = false; 397 mPrefs->mPassiveSyncAutoStart = false;
396 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 398 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
397 if ( ! ok ) { 399 if ( ! ok ) {
398 KMessageBox::information( 0, i18n("No valid port")); 400 KMessageBox::information( 0, i18n("No valid port"));
399 return; 401 return;
400 } 402 }
401 //qDebug("port %d ", port); 403 //qDebug("port %d ", port);
402 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 404 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
403 mServerSocket->setFileName( defaultFileName() );//bbb 405 mServerSocket->setFileName( defaultFileName() );//bbb
404 //qDebug("connected "); 406 //qDebug("connected ");
405 if ( !mServerSocket->ok() ) { 407 if ( !mServerSocket->ok() ) {
406 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 408 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
407 delete mServerSocket; 409 delete mServerSocket;
408 mServerSocket = 0; 410 mServerSocket = 0;
409 return; 411 return;
410 } 412 }
411 mPrefs->mPassiveSyncAutoStart = autoStart; 413 mPrefs->mPassiveSyncAutoStart = autoStart;
412 if ( changed ) { 414 if ( changed ) {
413 mPrefs->writeConfig(); 415 mPrefs->writeConfig();
414 } 416 }
415 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 417 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
416 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 418 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
417} 419}
418 420
419void KSyncManager::syncLocalFile() 421void KSyncManager::syncLocalFile()
420{ 422{
421 423
422 QString fn =mPrefs->mLastSyncedLocalFile; 424 QString fn =mPrefs->mLastSyncedLocalFile;
423 QString ext; 425 QString ext;
424 426
425 switch(mTargetApp) 427 switch(mTargetApp)
426 { 428 {
427 case (KAPI): 429 case (KAPI):
428 ext = "(*.vcf)"; 430 ext = "(*.vcf)";
429 break; 431 break;
430 case (KOPI): 432 case (KOPI):
431 ext = "(*.ics/*.vcs)"; 433 ext = "(*.ics/*.vcs)";
432 break; 434 break;
433 case (PWMPI): 435 case (PWMPI):
434 ext = "(*.pwm)"; 436 ext = "(*.pwm)";
435 break; 437 break;
436 default: 438 default:
437 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 439 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
438 break; 440 break;
439 441
440 } 442 }
441 443
442 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 444 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
443 if ( fn == "" ) 445 if ( fn == "" )
444 return; 446 return;
445 if ( syncWithFile( fn, false ) ) { 447 if ( syncWithFile( fn, false ) ) {
446 qDebug("syncLocalFile() successful "); 448 qDebug("syncLocalFile() successful ");
447 } 449 }
448 450
449} 451}
450 452
451bool KSyncManager::syncWithFile( QString fn , bool quick ) 453bool KSyncManager::syncWithFile( QString fn , bool quick )
452{ 454{
453 bool ret = false; 455 bool ret = false;
454 QFileInfo info; 456 QFileInfo info;
455 info.setFile( fn ); 457 info.setFile( fn );
456 QString mess; 458 QString mess;
457 bool loadbup = true; 459 bool loadbup = true;
458 if ( !info. exists() ) { 460 if ( !info. exists() ) {
459 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 461 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
460 int result = QMessageBox::warning( mParent, i18n("Warning!"), 462 int result = QMessageBox::warning( mParent, i18n("Warning!"),
461 mess ); 463 mess );
462 return ret; 464 return ret;
463 } 465 }
464 int result = 0; 466 int result = 0;
465 if ( !quick ) { 467 if ( !quick ) {
466 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 468 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
467 result = QMessageBox::warning( mParent, i18n("Warning!"), 469 result = QMessageBox::warning( mParent, i18n("Warning!"),
468 mess, 470 mess,
469 i18n("Sync"), i18n("Cancel"), 0, 471 i18n("Sync"), i18n("Cancel"), 0,
470 0, 1 ); 472 0, 1 );
471 if ( result ) 473 if ( result )
472 return false; 474 return false;
473 } 475 }
474 if ( mAskForPreferences ) 476 if ( mAskForPreferences )
475 if ( !edit_sync_options()) { 477 if ( !edit_sync_options()) {
476 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 478 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
477 return false; 479 return false;
478 } 480 }
479 if ( result == 0 ) { 481 if ( result == 0 ) {
480 //qDebug("Now sycing ... "); 482 //qDebug("Now sycing ... ");
481 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 483 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
482 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 484 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
483 else 485 else
484 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 486 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
485 if ( ! quick ) 487 if ( ! quick )
486 mPrefs->mLastSyncedLocalFile = fn; 488 mPrefs->mLastSyncedLocalFile = fn;
487 } 489 }
488 return ret; 490 return ret;
489} 491}
490 492
491void KSyncManager::quickSyncLocalFile() 493void KSyncManager::quickSyncLocalFile()
492{ 494{
493 495
494 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 496 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
495 qDebug("quick syncLocalFile() successful "); 497 qDebug("quick syncLocalFile() successful ");
496 498
497 } 499 }
498} 500}
499 501
500void KSyncManager::multiSync( bool askforPrefs ) 502void KSyncManager::multiSync( bool askforPrefs )
501{ 503{
502 if (blockSave()) 504 if (blockSave())
503 return; 505 return;
504 setBlockSave(true); 506 setBlockSave(true);
505 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 507 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
506 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 508 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
507 question, 509 question,
508 i18n("Yes"), i18n("No"), 510 i18n("Yes"), i18n("No"),
509 0, 0 ) != 0 ) { 511 0, 0 ) != 0 ) {
510 setBlockSave(false); 512 setBlockSave(false);
511 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 513 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
512 return; 514 return;
513 } 515 }
514 mCurrentSyncDevice = i18n("Multiple profiles") ; 516 mCurrentSyncDevice = i18n("Multiple profiles") ;
515 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 517 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
516 if ( askforPrefs ) { 518 if ( askforPrefs ) {
517 if ( !edit_sync_options()) { 519 if ( !edit_sync_options()) {
518 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 520 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
519 return; 521 return;
520 } 522 }
521 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 523 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
522 } 524 }
523 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 525 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
524 qApp->processEvents(); 526 qApp->processEvents();
525 int num = ringSync() ; 527 int num = ringSync() ;
526 if ( num > 1 ) 528 if ( num > 1 )
527 ringSync(); 529 ringSync();
528 setBlockSave(false); 530 setBlockSave(false);
529 if ( num ) 531 if ( num )
530 emit save(); 532 emit save();
531 if ( num ) 533 if ( num )
532 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 534 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
533 else 535 else
534 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 536 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
535 return; 537 return;
536} 538}
537 539
538int KSyncManager::ringSync() 540int KSyncManager::ringSync()
539{ 541{
540 542
541 int syncedProfiles = 0; 543 int syncedProfiles = 0;
542 unsigned int i; 544 unsigned int i;
543 QTime timer; 545 QTime timer;
544 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 546 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
545 QStringList syncProfileNames = mSyncProfileNames; 547 QStringList syncProfileNames = mSyncProfileNames;
546 KSyncProfile* temp = new KSyncProfile (); 548 KSyncProfile* temp = new KSyncProfile ();
547 mAskForPreferences = false; 549 mAskForPreferences = false;
548 for ( i = 0; i < syncProfileNames.count(); ++i ) { 550 for ( i = 0; i < syncProfileNames.count(); ++i ) {
549 mCurrentSyncProfile = i; 551 mCurrentSyncProfile = i;
550 temp->setName(syncProfileNames[mCurrentSyncProfile]); 552 temp->setName(syncProfileNames[mCurrentSyncProfile]);
551 temp->readConfig(&config); 553 temp->readConfig(&config);
552 554
553 bool includeInRingSync; 555 bool includeInRingSync;
554 switch(mTargetApp) 556 switch(mTargetApp)
555 { 557 {
556 case (KAPI): 558 case (KAPI):
557 includeInRingSync = temp->getIncludeInRingSyncAB(); 559 includeInRingSync = temp->getIncludeInRingSyncAB();
558 break; 560 break;
559 case (KOPI): 561 case (KOPI):
560 includeInRingSync = temp->getIncludeInRingSync(); 562 includeInRingSync = temp->getIncludeInRingSync();
561 break; 563 break;
562 case (PWMPI): 564 case (PWMPI):
563 includeInRingSync = temp->getIncludeInRingSyncPWM(); 565 includeInRingSync = temp->getIncludeInRingSyncPWM();
564 break; 566 break;
565 default: 567 default:
566 qDebug("KSyncManager::ringSync: invalid apptype selected"); 568 qDebug("KSyncManager::ringSync: invalid apptype selected");
567 break; 569 break;
568 570
569 } 571 }
570 572
571 573
572 if ( includeInRingSync && ( i < 1 || i > 2 )) { 574 if ( includeInRingSync && ( i < 1 || i > 2 )) {
573 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 575 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
574 ++syncedProfiles; 576 ++syncedProfiles;
575 mSyncWithDesktop = false; 577 mSyncWithDesktop = false;
576 // mAskForPreferences = temp->getAskForPreferences(); 578 // mAskForPreferences = temp->getAskForPreferences();
577 mWriteBackFile = temp->getWriteBackFile(); 579 mWriteBackFile = temp->getWriteBackFile();
578 mWriteBackExistingOnly = temp->getWriteBackExisting(); 580 mWriteBackExistingOnly = temp->getWriteBackExisting();
579 mIsKapiFile = temp->getIsKapiFile(); 581 mIsKapiFile = temp->getIsKapiFile();
580 mWriteBackInFuture = 0; 582 mWriteBackInFuture = 0;
581 if ( temp->getWriteBackFuture() ) 583 if ( temp->getWriteBackFuture() ) {
582 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 584 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
585 mWriteBackInPast = temp->getWriteBackPastWeeks( );
586 }
583 mShowSyncSummary = false; 587 mShowSyncSummary = false;
584 mCurrentSyncDevice = syncProfileNames[i] ; 588 mCurrentSyncDevice = syncProfileNames[i] ;
585 mCurrentSyncName = mLocalMachineName; 589 mCurrentSyncName = mLocalMachineName;
586 if ( i == 0 ) { 590 if ( i == 0 ) {
587 mIsKapiFile = false; 591 mIsKapiFile = false;
588#ifdef DESKTOP_VERSION 592#ifdef DESKTOP_VERSION
589 syncKDE(); 593 syncKDE();
590#else 594#else
591 syncSharp(); 595 syncSharp();
592#endif 596#endif
593 } else { 597 } else {
594 if ( temp->getIsLocalFileSync() ) { 598 if ( temp->getIsLocalFileSync() ) {
595 switch(mTargetApp) 599 switch(mTargetApp)
596 { 600 {
597 case (KAPI): 601 case (KAPI):
598 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 602 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
599 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 603 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
600 break; 604 break;
601 case (KOPI): 605 case (KOPI):
602 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 606 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
603 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 607 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
604 break; 608 break;
605 case (PWMPI): 609 case (PWMPI):
606 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 610 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
607 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 611 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
608 break; 612 break;
609 default: 613 default:
610 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 614 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
611 break; 615 break;
612 } 616 }
613 } else { 617 } else {
614 if ( temp->getIsPhoneSync() ) { 618 if ( temp->getIsPhoneSync() ) {
615 mPhoneDevice = temp->getPhoneDevice( ) ; 619 mPhoneDevice = temp->getPhoneDevice( ) ;
616 mPhoneConnection = temp->getPhoneConnection( ); 620 mPhoneConnection = temp->getPhoneConnection( );
617 mPhoneModel = temp->getPhoneModel( ); 621 mPhoneModel = temp->getPhoneModel( );
618 syncPhone(); 622 syncPhone();
619 } else if ( temp->getIsPiSync() ) { 623 } else if ( temp->getIsPiSync() ) {
620 if ( mTargetApp == KAPI ) { 624 if ( mTargetApp == KAPI ) {
621 mPassWordPiSync = temp->getRemotePwAB(); 625 mPassWordPiSync = temp->getRemotePwAB();
622 mActiveSyncPort = temp->getRemotePortAB(); 626 mActiveSyncPort = temp->getRemotePortAB();
623 mActiveSyncIP = temp->getRemoteIPAB(); 627 mActiveSyncIP = temp->getRemoteIPAB();
624 } else if ( mTargetApp == KOPI ) { 628 } else if ( mTargetApp == KOPI ) {
625 mPassWordPiSync = temp->getRemotePw(); 629 mPassWordPiSync = temp->getRemotePw();
626 mActiveSyncPort = temp->getRemotePort(); 630 mActiveSyncPort = temp->getRemotePort();
627 mActiveSyncIP = temp->getRemoteIP(); 631 mActiveSyncIP = temp->getRemoteIP();
628 } else { 632 } else {
629 mPassWordPiSync = temp->getRemotePwPWM(); 633 mPassWordPiSync = temp->getRemotePwPWM();
630 mActiveSyncPort = temp->getRemotePortPWM(); 634 mActiveSyncPort = temp->getRemotePortPWM();
631 mActiveSyncIP = temp->getRemoteIPPWM(); 635 mActiveSyncIP = temp->getRemoteIPPWM();
632 } 636 }
633 syncPi(); 637 syncPi();
634 while ( !mPisyncFinished ) { 638 while ( !mPisyncFinished ) {
635 //qDebug("waiting "); 639 //qDebug("waiting ");
636 qApp->processEvents(); 640 qApp->processEvents();
637 } 641 }
638 timer.start(); 642 timer.start();
639 while ( timer.elapsed () < 2000 ) { 643 while ( timer.elapsed () < 2000 ) {
640 qApp->processEvents(); 644 qApp->processEvents();
641 } 645 }
642 } else 646 } else
643 syncRemote( temp, false ); 647 syncRemote( temp, false );
644 648
645 } 649 }
646 } 650 }
647 timer.start(); 651 timer.start();
648 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 652 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
649 while ( timer.elapsed () < 2000 ) { 653 while ( timer.elapsed () < 2000 ) {
650 qApp->processEvents(); 654 qApp->processEvents();
651#ifndef _WIN32_ 655#ifndef _WIN32_
652 sleep (1); 656 sleep (1);
653#endif 657#endif
654 } 658 }
655 659
656 } 660 }
657 661
658 } 662 }
659 delete temp; 663 delete temp;
660 return syncedProfiles; 664 return syncedProfiles;
661} 665}
662 666
663void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 667void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
664{ 668{
665 QString question; 669 QString question;
666 if ( ask ) { 670 if ( ask ) {
667 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 671 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
668 if ( QMessageBox::information( mParent, i18n("Sync"), 672 if ( QMessageBox::information( mParent, i18n("Sync"),
669 question, 673 question,
670 i18n("Yes"), i18n("No"), 674 i18n("Yes"), i18n("No"),
671 0, 0 ) != 0 ) 675 0, 0 ) != 0 )
672 return; 676 return;
673 } 677 }
674 678
675 QString preCommand; 679 QString preCommand;
676 QString localTempFile; 680 QString localTempFile;
677 QString postCommand; 681 QString postCommand;
678 682
679 switch(mTargetApp) 683 switch(mTargetApp)
680 { 684 {
681 case (KAPI): 685 case (KAPI):
682 preCommand = prof->getPreSyncCommandAB(); 686 preCommand = prof->getPreSyncCommandAB();
683 postCommand = prof->getPostSyncCommandAB(); 687 postCommand = prof->getPostSyncCommandAB();
684 localTempFile = prof->getLocalTempFileAB(); 688 localTempFile = prof->getLocalTempFileAB();
685 break; 689 break;
686 case (KOPI): 690 case (KOPI):
687 preCommand = prof->getPreSyncCommand(); 691 preCommand = prof->getPreSyncCommand();
688 postCommand = prof->getPostSyncCommand(); 692 postCommand = prof->getPostSyncCommand();
689 localTempFile = prof->getLocalTempFile(); 693 localTempFile = prof->getLocalTempFile();
690 break; 694 break;
691 case (PWMPI): 695 case (PWMPI):
692 preCommand = prof->getPreSyncCommandPWM(); 696 preCommand = prof->getPreSyncCommandPWM();
693 postCommand = prof->getPostSyncCommandPWM(); 697 postCommand = prof->getPostSyncCommandPWM();
694 localTempFile = prof->getLocalTempFilePWM(); 698 localTempFile = prof->getLocalTempFilePWM();
695 break; 699 break;
696 default: 700 default:
697 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 701 qDebug("KSyncManager::syncRemote: invalid apptype selected");
698 break; 702 break;
699 } 703 }
700 704
701 705
702 int fi; 706 int fi;
703 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 707 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
704 QString pwd = getPassword(); 708 QString pwd = getPassword();
705 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 709 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
706 710
707 } 711 }
708 int maxlen = 30; 712 int maxlen = 30;
709 if ( QApplication::desktop()->width() > 320 ) 713 if ( QApplication::desktop()->width() > 320 )
710 maxlen += 25; 714 maxlen += 25;
711 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 715 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
712 int fileSize = 0; 716 int fileSize = 0;
713 int result = system ( preCommand ); 717 int result = system ( preCommand );
714 // 0 : okay 718 // 0 : okay
715 // 256: no such file or dir 719 // 256: no such file or dir
716 // 720 //
717 qDebug("Sync: Remote copy result(0 = okay): %d ",result ); 721 qDebug("Sync: Remote copy result(0 = okay): %d ",result );
718 if ( result != 0 ) { 722 if ( result != 0 ) {
719 unsigned int len = maxlen; 723 unsigned int len = maxlen;
720 while ( len < preCommand.length() ) { 724 while ( len < preCommand.length() ) {
721 preCommand.insert( len , "\n" ); 725 preCommand.insert( len , "\n" );
722 len += maxlen +2; 726 len += maxlen +2;
723 } 727 }
724 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 728 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
725 QMessageBox::information( mParent, i18n("Sync - ERROR"), 729 QMessageBox::information( mParent, i18n("Sync - ERROR"),
726 question, 730 question,
727 i18n("Okay!")) ; 731 i18n("Okay!")) ;
728 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 732 mParent->topLevelWidget()->setCaption ("KDE-Pim");
729 return; 733 return;
730 } 734 }
731 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 735 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
732 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 736 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
733 737
734 if ( syncWithFile( localTempFile, true ) ) { 738 if ( syncWithFile( localTempFile, true ) ) {
735 739
736 if ( mWriteBackFile ) { 740 if ( mWriteBackFile ) {
737 int fi; 741 int fi;
738 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 742 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
739 QString pwd = getPassword(); 743 QString pwd = getPassword();
740 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 744 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
741 745
742 } 746 }
743 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 747 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
744 result = system ( postCommand ); 748 result = system ( postCommand );
745 qDebug("Sync:Writing back file result: %d ", result); 749 qDebug("Sync:Writing back file result: %d ", result);
746 if ( result != 0 ) { 750 if ( result != 0 ) {
747 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 751 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
748 return; 752 return;
749 } else { 753 } else {
750 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 754 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
751 } 755 }
752 } 756 }
753 } 757 }
754 return; 758 return;
755} 759}
756bool KSyncManager::edit_pisync_options() 760bool KSyncManager::edit_pisync_options()
757{ 761{
758 QDialog dia( mParent, "dia", true ); 762 QDialog dia( mParent, "dia", true );
759 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 763 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
760 QVBoxLayout lay ( &dia ); 764 QVBoxLayout lay ( &dia );
761 lay.setSpacing( 5 ); 765 lay.setSpacing( 5 );
762 lay.setMargin( 3 ); 766 lay.setMargin( 3 );
763 QLabel lab1 ( i18n("Password for remote access:"), &dia); 767 QLabel lab1 ( i18n("Password for remote access:"), &dia);
764 lay.addWidget( &lab1 ); 768 lay.addWidget( &lab1 );
765 QLineEdit le1 (&dia ); 769 QLineEdit le1 (&dia );
766 lay.addWidget( &le1 ); 770 lay.addWidget( &le1 );
767 QLabel lab2 ( i18n("Remote IP address:"), &dia); 771 QLabel lab2 ( i18n("Remote IP address:"), &dia);
768 lay.addWidget( &lab2 ); 772 lay.addWidget( &lab2 );
769 QLineEdit le2 (&dia ); 773 QLineEdit le2 (&dia );
770 lay.addWidget( &le2 ); 774 lay.addWidget( &le2 );
771 QLabel lab3 ( i18n("Remote port number:"), &dia); 775 QLabel lab3 ( i18n("Remote port number:"), &dia);
772 lay.addWidget( &lab3 ); 776 lay.addWidget( &lab3 );
773 QLineEdit le3 (&dia ); 777 QLineEdit le3 (&dia );
774 lay.addWidget( &le3 ); 778 lay.addWidget( &le3 );
775 QPushButton pb ( "OK", &dia); 779 QPushButton pb ( "OK", &dia);
776 lay.addWidget( &pb ); 780 lay.addWidget( &pb );
777 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 781 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
778 le1.setText( mPassWordPiSync ); 782 le1.setText( mPassWordPiSync );
779 le2.setText( mActiveSyncIP ); 783 le2.setText( mActiveSyncIP );
780 le3.setText( mActiveSyncPort ); 784 le3.setText( mActiveSyncPort );
781 if ( dia.exec() ) { 785 if ( dia.exec() ) {
782 mPassWordPiSync = le1.text(); 786 mPassWordPiSync = le1.text();
783 mActiveSyncPort = le3.text(); 787 mActiveSyncPort = le3.text();
784 mActiveSyncIP = le2.text(); 788 mActiveSyncIP = le2.text();
785 return true; 789 return true;
786 } 790 }
787 return false; 791 return false;
788} 792}
789bool KSyncManager::edit_sync_options() 793bool KSyncManager::edit_sync_options()
790{ 794{
791 795
792 QDialog dia( mParent, "dia", true ); 796 QDialog dia( mParent, "dia", true );
793 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 797 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
794 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 798 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
795 QVBoxLayout lay ( &dia ); 799 QVBoxLayout lay ( &dia );
796 lay.setSpacing( 2 ); 800 lay.setSpacing( 2 );
797 lay.setMargin( 3 ); 801 lay.setMargin( 3 );
798 lay.addWidget(&gr); 802 lay.addWidget(&gr);
799 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 803 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
800 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 804 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
801 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 805 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
802 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 806 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
803 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 807 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
804 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 808 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
805 //QRadioButton both( i18n("Take both on conflict"), &gr ); 809 //QRadioButton both( i18n("Take both on conflict"), &gr );
806 QPushButton pb ( "OK", &dia); 810 QPushButton pb ( "OK", &dia);
807 lay.addWidget( &pb ); 811 lay.addWidget( &pb );
808 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 812 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
809 switch ( mSyncAlgoPrefs ) { 813 switch ( mSyncAlgoPrefs ) {
810 case 0: 814 case 0:
811 loc.setChecked( true); 815 loc.setChecked( true);
812 break; 816 break;
813 case 1: 817 case 1:
814 rem.setChecked( true ); 818 rem.setChecked( true );
815 break; 819 break;
816 case 2: 820 case 2:
817 newest.setChecked( true); 821 newest.setChecked( true);
818 break; 822 break;
819 case 3: 823 case 3:
820 ask.setChecked( true); 824 ask.setChecked( true);
821 break; 825 break;
822 case 4: 826 case 4:
823 f_loc.setChecked( true); 827 f_loc.setChecked( true);
824 break; 828 break;
825 case 5: 829 case 5:
826 f_rem.setChecked( true); 830 f_rem.setChecked( true);
827 break; 831 break;
828 case 6: 832 case 6:
829 // both.setChecked( true); 833 // both.setChecked( true);
830 break; 834 break;
831 default: 835 default:
832 break; 836 break;
833 } 837 }
834 if ( dia.exec() ) { 838 if ( dia.exec() ) {
835 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 839 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
836 return true; 840 return true;
837 } 841 }
838 return false; 842 return false;
839} 843}
840 844
841QString KSyncManager::getPassword( ) 845QString KSyncManager::getPassword( )
842{ 846{
843 QString retfile = ""; 847 QString retfile = "";
844 QDialog dia ( mParent, "input-dialog", true ); 848 QDialog dia ( mParent, "input-dialog", true );
845 QLineEdit lab ( &dia ); 849 QLineEdit lab ( &dia );
846 lab.setEchoMode( QLineEdit::Password ); 850 lab.setEchoMode( QLineEdit::Password );
847 QVBoxLayout lay( &dia ); 851 QVBoxLayout lay( &dia );
848 lay.setMargin(7); 852 lay.setMargin(7);
849 lay.setSpacing(7); 853 lay.setSpacing(7);
850 lay.addWidget( &lab); 854 lay.addWidget( &lab);
851 dia.setFixedSize( 230,50 ); 855 dia.setFixedSize( 230,50 );
852 dia.setCaption( i18n("Enter password") ); 856 dia.setCaption( i18n("Enter password") );
853 QPushButton pb ( "OK", &dia); 857 QPushButton pb ( "OK", &dia);
854 lay.addWidget( &pb ); 858 lay.addWidget( &pb );
855 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 859 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
856 dia.show(); 860 dia.show();
857 int res = dia.exec(); 861 int res = dia.exec();
858 if ( res ) 862 if ( res )
859 retfile = lab.text(); 863 retfile = lab.text();
860 dia.hide(); 864 dia.hide();
861 qApp->processEvents(); 865 qApp->processEvents();
862 return retfile; 866 return retfile;
863 867
864} 868}
865 869
866 870
867void KSyncManager::confSync() 871void KSyncManager::confSync()
868{ 872{
869 static KSyncPrefsDialog* sp = 0; 873 static KSyncPrefsDialog* sp = 0;
870 if ( ! sp ) { 874 if ( ! sp ) {
871 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 875 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
872 } 876 }
873 sp->usrReadConfig(); 877 sp->usrReadConfig();
874#ifndef DESKTOP_VERSION 878#ifndef DESKTOP_VERSION
875 sp->showMaximized(); 879 sp->showMaximized();
876#else 880#else
877 sp->show(); 881 sp->show();
878#endif 882#endif
879 sp->exec(); 883 sp->exec();
880 QStringList oldSyncProfileNames = mSyncProfileNames; 884 QStringList oldSyncProfileNames = mSyncProfileNames;
881 mSyncProfileNames = sp->getSyncProfileNames(); 885 mSyncProfileNames = sp->getSyncProfileNames();
882 mLocalMachineName = sp->getLocalMachineName (); 886 mLocalMachineName = sp->getLocalMachineName ();
883 int ii; 887 int ii;
884 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 888 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
885 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 889 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
886 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 890 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
887 } 891 }
888 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 892 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
889} 893}
890void KSyncManager::syncKDE() 894void KSyncManager::syncKDE()
891{ 895{
892 mSyncWithDesktop = true; 896 mSyncWithDesktop = true;
893 emit save(); 897 emit save();
894 switch(mTargetApp) 898 switch(mTargetApp)
895 { 899 {
896 case (KAPI): 900 case (KAPI):
897 { 901 {
898#ifdef DESKTOP_VERSION 902#ifdef DESKTOP_VERSION
899 QString command = qApp->applicationDirPath () + "/kdeabdump"; 903 QString command = qApp->applicationDirPath () + "/kdeabdump";
900#else 904#else
901 QString command = "kdeabdump"; 905 QString command = "kdeabdump";
902#endif 906#endif
903 if ( ! QFile::exists ( command ) ) 907 if ( ! QFile::exists ( command ) )
904 command = "kdeabdump"; 908 command = "kdeabdump";
905 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 909 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
906 system ( command.latin1()); 910 system ( command.latin1());
907 if ( syncWithFile( fileName,true ) ) { 911 if ( syncWithFile( fileName,true ) ) {
908 if ( mWriteBackFile ) { 912 if ( mWriteBackFile ) {
909 command += " --read"; 913 command += " --read";
910 system ( command.latin1()); 914 system ( command.latin1());
911 } 915 }
912 } 916 }
913 917
914 } 918 }
915 break; 919 break;
916 case (KOPI): 920 case (KOPI):
917 { 921 {
918#ifdef DESKTOP_VERSION 922#ifdef DESKTOP_VERSION
919 QString command = qApp->applicationDirPath () + "/kdecaldump"; 923 QString command = qApp->applicationDirPath () + "/kdecaldump";
920#else 924#else
921 QString command = "kdecaldump"; 925 QString command = "kdecaldump";
922#endif 926#endif
923 if ( ! QFile::exists ( command ) ) 927 if ( ! QFile::exists ( command ) )
924 command = "kdecaldump"; 928 command = "kdecaldump";
925 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 929 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
926 system ( command.latin1()); 930 system ( command.latin1());
927 if ( syncWithFile( fileName,true ) ) { 931 if ( syncWithFile( fileName,true ) ) {
928 if ( mWriteBackFile ) { 932 if ( mWriteBackFile ) {
929 command += " --read"; 933 command += " --read";
930 system ( command.latin1()); 934 system ( command.latin1());
931 } 935 }
932 } 936 }
933 937
934 } 938 }
935 break; 939 break;
936 case (PWMPI): 940 case (PWMPI):
937 941
938 break; 942 break;
939 default: 943 default:
940 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 944 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
941 break; 945 break;
942 946
943 } 947 }
944} 948}
945 949
946void KSyncManager::syncSharp() 950void KSyncManager::syncSharp()
947{ 951{
948 952
949 if ( ! syncExternalApplication("sharp") ) 953 if ( ! syncExternalApplication("sharp") )
950 qDebug("ERROR sync sharp "); 954 qDebug("ERROR sync sharp ");
951} 955}
952 956
953bool KSyncManager::syncExternalApplication(QString resource) 957bool KSyncManager::syncExternalApplication(QString resource)
954{ 958{
955 959
956 emit save(); 960 emit save();
957 961
958 if ( mAskForPreferences ) 962 if ( mAskForPreferences )
959 if ( !edit_sync_options()) { 963 if ( !edit_sync_options()) {
960 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 964 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
961 return false; 965 return false;
962 } 966 }
963 967
964 qDebug("Sync extern %s", resource.latin1()); 968 qDebug("Sync extern %s", resource.latin1());
965 969
966 bool syncOK = mImplementation->syncExternal(this, resource); 970 bool syncOK = mImplementation->syncExternal(this, resource);
967 971
968 return syncOK; 972 return syncOK;
969 973
970} 974}
971 975
972void KSyncManager::syncPhone() 976void KSyncManager::syncPhone()
973{ 977{
974 978
975 syncExternalApplication("phone"); 979 syncExternalApplication("phone");
976 980
977} 981}
978 982
979void KSyncManager::showProgressBar(int percentage, QString caption, int total) 983void KSyncManager::showProgressBar(int percentage, QString caption, int total)
980{ 984{
981 if (!bar->isVisible()) 985 if (!bar->isVisible())
982 { 986 {
983 bar->setCaption (caption); 987 bar->setCaption (caption);
984 bar->setTotalSteps ( total ) ; 988 bar->setTotalSteps ( total ) ;
985 989
986 bar->show(); 990 bar->show();
987 } 991 }
988 992
989 bar->setProgress( percentage ); 993 bar->setProgress( percentage );
990} 994}
991 995
992void KSyncManager::hideProgressBar() 996void KSyncManager::hideProgressBar()
993{ 997{
994 bar->hide(); 998 bar->hide();
995} 999}
996 1000
997bool KSyncManager::isProgressBarCanceled() 1001bool KSyncManager::isProgressBarCanceled()
998{ 1002{
999 return !bar->isVisible(); 1003 return !bar->isVisible();
1000} 1004}
1001 1005
1002QString KSyncManager::syncFileName() 1006QString KSyncManager::syncFileName()
1003{ 1007{
1004 1008
1005 QString fn = "tempfile"; 1009 QString fn = "tempfile";
1006 switch(mTargetApp) 1010 switch(mTargetApp)
1007 { 1011 {
1008 case (KAPI): 1012 case (KAPI):
1009 fn = "tempsyncab.vcf"; 1013 fn = "tempsyncab.vcf";
1010 break; 1014 break;
1011 case (KOPI): 1015 case (KOPI):
1012 fn = "tempsynccal.ics"; 1016 fn = "tempsynccal.ics";
1013 break; 1017 break;
1014 case (PWMPI): 1018 case (PWMPI):
1015 fn = "tempsyncpw.pwm"; 1019 fn = "tempsyncpw.pwm";
1016 break; 1020 break;
1017 default: 1021 default:
1018 break; 1022 break;
1019 } 1023 }
1020#ifdef _WIN32_ 1024#ifdef _WIN32_
1021 return locateLocal( "tmp", fn ); 1025 return locateLocal( "tmp", fn );
1022#else 1026#else
1023 return (QString( "/tmp/" )+ fn ); 1027 return (QString( "/tmp/" )+ fn );
1024#endif 1028#endif
1025} 1029}
1026 1030
1027void KSyncManager::syncPi() 1031void KSyncManager::syncPi()
1028{ 1032{
1029 mIsKapiFile = true; 1033 mIsKapiFile = true;
1030 mPisyncFinished = false; 1034 mPisyncFinished = false;
1031 qApp->processEvents(); 1035 qApp->processEvents();
1032 if ( mAskForPreferences ) 1036 if ( mAskForPreferences )
1033 if ( !edit_pisync_options()) { 1037 if ( !edit_pisync_options()) {
1034 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1038 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1035 return; 1039 return;
1036 } 1040 }
1037 bool ok; 1041 bool ok;
1038 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1042 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1039 if ( ! ok ) { 1043 if ( ! ok ) {
1040 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1044 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1041 return; 1045 return;
1042 } 1046 }
1043 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 1047 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
1044 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1048 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1045 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 1049 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
1046 commandSocket->readFile( syncFileName() ); 1050 commandSocket->readFile( syncFileName() );
1047} 1051}
1048 1052
1049void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1053void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1050{ 1054{
1051 //enum { success, errorW, errorR, quiet }; 1055 //enum { success, errorW, errorR, quiet };
1052 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 1056 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
1053 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1057 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1054 delete s; 1058 delete s;
1055 if ( state == KCommandSocket::errorR ) { 1059 if ( state == KCommandSocket::errorR ) {
1056 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 1060 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
1057 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1061 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1058 commandSocket->sendStop(); 1062 commandSocket->sendStop();
1059 } 1063 }
1060 mPisyncFinished = true; 1064 mPisyncFinished = true;
1061 return; 1065 return;
1062 1066
1063 } else if ( state == KCommandSocket::errorW ) { 1067 } else if ( state == KCommandSocket::errorW ) {
1064 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1068 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1065 mPisyncFinished = true; 1069 mPisyncFinished = true;
1066 1070
1067 } else if ( state == KCommandSocket::successR ) { 1071 } else if ( state == KCommandSocket::successR ) {
1068 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1072 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1069 1073
1070 } else if ( state == KCommandSocket::successW ) { 1074 } else if ( state == KCommandSocket::successW ) {
1071 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1075 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1072 mPisyncFinished = true; 1076 mPisyncFinished = true;
1073 } 1077 }
1074 1078
1075 delete s; 1079 delete s;
1076} 1080}
1077 1081
1078void KSyncManager::readFileFromSocket() 1082void KSyncManager::readFileFromSocket()
1079{ 1083{
1080 QString fileName = syncFileName(); 1084 QString fileName = syncFileName();
1081 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1085 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1082 if ( ! syncWithFile( fileName , true ) ) { 1086 if ( ! syncWithFile( fileName , true ) ) {
1083 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1087 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1084 mPisyncFinished = true; 1088 mPisyncFinished = true;
1085 return; 1089 return;
1086 } 1090 }
1087 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 1091 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
1088 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1092 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1089 if ( mWriteBackFile ) 1093 if ( mWriteBackFile )
1090 commandSocket->writeFile( fileName ); 1094 commandSocket->writeFile( fileName );
1091 else { 1095 else {
1092 commandSocket->sendStop(); 1096 commandSocket->sendStop();
1093 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1097 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1094 mPisyncFinished = true; 1098 mPisyncFinished = true;
1095 } 1099 }
1096} 1100}
1097 1101
1098KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1102KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1099{ 1103{
1100 mPassWord = pw; 1104 mPassWord = pw;
1101 mSocket = 0; 1105 mSocket = 0;
1102 mSyncActionDialog = 0; 1106 mSyncActionDialog = 0;
1103 blockRC = false; 1107 blockRC = false;
1104}; 1108};
1105 1109
1106void KServerSocket::newConnection ( int socket ) 1110void KServerSocket::newConnection ( int socket )
1107{ 1111{
1108 // qDebug("KServerSocket:New connection %d ", socket); 1112 // qDebug("KServerSocket:New connection %d ", socket);
1109 if ( mSocket ) { 1113 if ( mSocket ) {
1110 qDebug("KServerSocket::newConnection Socket deleted! "); 1114 qDebug("KServerSocket::newConnection Socket deleted! ");
1111 delete mSocket; 1115 delete mSocket;
1112 mSocket = 0; 1116 mSocket = 0;
1113 } 1117 }
1114 mSocket = new QSocket( this ); 1118 mSocket = new QSocket( this );
1115 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1119 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1116 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1120 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1117 mSocket->setSocket( socket ); 1121 mSocket->setSocket( socket );
1118} 1122}
1119 1123
1120void KServerSocket::discardClient() 1124void KServerSocket::discardClient()
1121{ 1125{
1122 //qDebug(" KServerSocket::discardClient()"); 1126 //qDebug(" KServerSocket::discardClient()");
1123 if ( mSocket ) { 1127 if ( mSocket ) {
1124 delete mSocket; 1128 delete mSocket;
1125 mSocket = 0; 1129 mSocket = 0;
1126 } 1130 }
1127 //emit endConnect(); 1131 //emit endConnect();
1128} 1132}
1129void KServerSocket::readClient() 1133void KServerSocket::readClient()
1130{ 1134{
1131 if ( blockRC ) 1135 if ( blockRC )
1132 return; 1136 return;
1133 if ( mSocket == 0 ) { 1137 if ( mSocket == 0 ) {
1134 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 1138 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
1135 return; 1139 return;
1136 } 1140 }
1137 //qDebug("KServerSocket::readClient()"); 1141 //qDebug("KServerSocket::readClient()");
1138 if ( mSocket->canReadLine() ) { 1142 if ( mSocket->canReadLine() ) {
1139 QString line = mSocket->readLine(); 1143 QString line = mSocket->readLine();
1140 //qDebug("KServerSocket readline: %s ", line.latin1()); 1144 //qDebug("KServerSocket readline: %s ", line.latin1());
1141 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1145 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1142 if ( tokens[0] == "GET" ) { 1146 if ( tokens[0] == "GET" ) {
1143 if ( tokens[1] == mPassWord ) { 1147 if ( tokens[1] == mPassWord ) {
1144 //emit sendFile( mSocket ); 1148 //emit sendFile( mSocket );
1145 bool ok = false; 1149 bool ok = false;
1146 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1150 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1147 if ( ok ) { 1151 if ( ok ) {
1148 KSyncManager::mRequestedSyncEvent = dt; 1152 KSyncManager::mRequestedSyncEvent = dt;
1149 } 1153 }
1150 else 1154 else
1151 KSyncManager::mRequestedSyncEvent = QDateTime(); 1155 KSyncManager::mRequestedSyncEvent = QDateTime();
1152 send_file(); 1156 send_file();
1153 } 1157 }
1154 else { 1158 else {
1155 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); 1159 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
1156 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1160 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1157 } 1161 }
1158 } 1162 }
1159 if ( tokens[0] == "PUT" ) { 1163 if ( tokens[0] == "PUT" ) {
1160 if ( tokens[1] == mPassWord ) { 1164 if ( tokens[1] == mPassWord ) {
1161 //emit getFile( mSocket ); 1165 //emit getFile( mSocket );
1162 blockRC = true; 1166 blockRC = true;
1163 get_file(); 1167 get_file();
1164 } 1168 }
1165 else { 1169 else {
1166 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); 1170 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
1167 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1171 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1168 } 1172 }
1169 } 1173 }
1170 if ( tokens[0] == "STOP" ) { 1174 if ( tokens[0] == "STOP" ) {
1171 //emit endConnect(); 1175 //emit endConnect();
1172 end_connect(); 1176 end_connect();
1173 } 1177 }
1174 } 1178 }
1175} 1179}
1176void KServerSocket::end_connect() 1180void KServerSocket::end_connect()
1177{ 1181{
1178 delete mSyncActionDialog; 1182 delete mSyncActionDialog;
1179 mSyncActionDialog = 0; 1183 mSyncActionDialog = 0;
1180} 1184}
1181void KServerSocket::send_file() 1185void KServerSocket::send_file()
1182{ 1186{
1183 //qDebug("MainWindow::sendFile(QSocket* s) "); 1187 //qDebug("MainWindow::sendFile(QSocket* s) ");
1184 if ( mSyncActionDialog ) 1188 if ( mSyncActionDialog )
1185 delete mSyncActionDialog; 1189 delete mSyncActionDialog;
1186 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1190 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1187 mSyncActionDialog->setCaption(i18n("Received sync request")); 1191 mSyncActionDialog->setCaption(i18n("Received sync request"));
1188 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1192 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1189 label->setAlignment ( Qt::AlignHCenter ); 1193 label->setAlignment ( Qt::AlignHCenter );
1190 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1194 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1191 lay->addWidget( label); 1195 lay->addWidget( label);
1192 lay->setMargin(7); 1196 lay->setMargin(7);
1193 lay->setSpacing(7); 1197 lay->setSpacing(7);
1194 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1198 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1195 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1199 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1196 if ( secs < 0 ) 1200 if ( secs < 0 )
1197 secs = secs * (-1); 1201 secs = secs * (-1);
1198 if ( secs > 30 ) 1202 if ( secs > 30 )
1199 //if ( true ) 1203 //if ( true )
1200 { 1204 {
1201 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); 1205 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs );
1202 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1206 QLabel* label = new QLabel( warning, mSyncActionDialog );
1203 label->setAlignment ( Qt::AlignHCenter ); 1207 label->setAlignment ( Qt::AlignHCenter );
1204 lay->addWidget( label); 1208 lay->addWidget( label);
1205 if ( secs > 180 ) 1209 if ( secs > 180 )
1206 { 1210 {
1207 if ( secs > 300 ) { 1211 if ( secs > 300 ) {
1208 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { 1212 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) {
1209 qDebug("cancelled "); 1213 qDebug("cancelled ");
1210 return ; 1214 return ;
1211 } 1215 }
1212 } 1216 }
1213 QFont f = label->font(); 1217 QFont f = label->font();
1214 f.setPointSize ( f.pointSize() *2 ); 1218 f.setPointSize ( f.pointSize() *2 );
1215 f. setBold (true ); 1219 f. setBold (true );
1216 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1220 QLabel* label = new QLabel( warning, mSyncActionDialog );
1217 label->setFont( f ); 1221 label->setFont( f );
1218 warning = i18n("ADJUST\nYOUR\nCLOCKS!"); 1222 warning = i18n("ADJUST\nYOUR\nCLOCKS!");
1219 label->setText( warning ); 1223 label->setText( warning );
1220 label->setAlignment ( Qt::AlignHCenter ); 1224 label->setAlignment ( Qt::AlignHCenter );
1221 lay->addWidget( label); 1225 lay->addWidget( label);
1222 mSyncActionDialog->setFixedSize( 230, 300); 1226 mSyncActionDialog->setFixedSize( 230, 300);
1223 } else { 1227 } else {
1224 mSyncActionDialog->setFixedSize( 230, 200); 1228 mSyncActionDialog->setFixedSize( 230, 200);
1225 } 1229 }
1226 } else { 1230 } else {
1227 mSyncActionDialog->setFixedSize( 230, 120); 1231 mSyncActionDialog->setFixedSize( 230, 120);
1228 } 1232 }
1229 } else 1233 } else
1230 mSyncActionDialog->setFixedSize( 230, 120); 1234 mSyncActionDialog->setFixedSize( 230, 120);
1231 mSyncActionDialog->show(); 1235 mSyncActionDialog->show();
1232 mSyncActionDialog->raise(); 1236 mSyncActionDialog->raise();
1233 emit request_file(); 1237 emit request_file();
1234 qApp->processEvents(); 1238 qApp->processEvents();
1235 QString fileName = mFileName; 1239 QString fileName = mFileName;
1236 QFile file( fileName ); 1240 QFile file( fileName );
1237 if (!file.open( IO_ReadOnly ) ) { 1241 if (!file.open( IO_ReadOnly ) ) {
1238 delete mSyncActionDialog; 1242 delete mSyncActionDialog;
1239 mSyncActionDialog = 0; 1243 mSyncActionDialog = 0;
1240 qDebug("KSS::error open sync file: %s ", fileName.latin1()); 1244 qDebug("KSS::error open sync file: %s ", fileName.latin1());
1241 mSocket->close(); 1245 mSocket->close();
1242 if ( mSocket->state() == QSocket::Idle ) 1246 if ( mSocket->state() == QSocket::Idle )
1243 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1247 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1244 return ; 1248 return ;
1245 1249
1246 } 1250 }
1247 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1251 mSyncActionDialog->setCaption( i18n("Sending file...") );
1248 QTextStream ts( &file ); 1252 QTextStream ts( &file );
1249 ts.setEncoding( QTextStream::Latin1 ); 1253 ts.setEncoding( QTextStream::Latin1 );
1250 1254
1251 QTextStream os( mSocket ); 1255 QTextStream os( mSocket );
1252 os.setEncoding( QTextStream::Latin1 ); 1256 os.setEncoding( QTextStream::Latin1 );
1253 while ( ! ts.atEnd() ) { 1257 while ( ! ts.atEnd() ) {
1254 os << ts.readLine() << "\r\n"; 1258 os << ts.readLine() << "\r\n";
1255 } 1259 }
1256 //os << ts.read(); 1260 //os << ts.read();
1257 file.close(); 1261 file.close();
1258 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1262 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1259 mSocket->close(); 1263 mSocket->close();
1260 if ( mSocket->state() == QSocket::Idle ) 1264 if ( mSocket->state() == QSocket::Idle )
1261 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1265 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1262} 1266}
1263void KServerSocket::get_file() 1267void KServerSocket::get_file()
1264{ 1268{
1265 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1269 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1266 1270
1267 piTime.start(); 1271 piTime.start();
1268 piFileString = ""; 1272 piFileString = "";
1269 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1273 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1270} 1274}
1271 1275
1272 1276
1273void KServerSocket::readBackFileFromSocket() 1277void KServerSocket::readBackFileFromSocket()
1274{ 1278{
1275 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1279 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1276 while ( mSocket->canReadLine () ) { 1280 while ( mSocket->canReadLine () ) {
1277 piTime.restart(); 1281 piTime.restart();
1278 QString line = mSocket->readLine (); 1282 QString line = mSocket->readLine ();
1279 piFileString += line; 1283 piFileString += line;
1280 //qDebug("readline: %s ", line.latin1()); 1284 //qDebug("readline: %s ", line.latin1());
1281 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1285 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1282 1286
1283 } 1287 }
1284 if ( piTime.elapsed () < 3000 ) { 1288 if ( piTime.elapsed () < 3000 ) {
1285 // wait for more 1289 // wait for more
1286 //qDebug("waitformore "); 1290 //qDebug("waitformore ");
1287 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1291 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1288 return; 1292 return;
1289 } 1293 }
1290 QString fileName = mFileName; 1294 QString fileName = mFileName;
1291 QFile file ( fileName ); 1295 QFile file ( fileName );
1292 if (!file.open( IO_WriteOnly ) ) { 1296 if (!file.open( IO_WriteOnly ) ) {
1293 delete mSyncActionDialog; 1297 delete mSyncActionDialog;
1294 mSyncActionDialog = 0; 1298 mSyncActionDialog = 0;
1295 qDebug("KSS:Error open read back file "); 1299 qDebug("KSS:Error open read back file ");
1296 piFileString = ""; 1300 piFileString = "";
1297 emit file_received( false ); 1301 emit file_received( false );
1298 blockRC = false; 1302 blockRC = false;
1299 return ; 1303 return ;
1300 1304
1301 } 1305 }
1302 1306
1303 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1307 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1304 QTextStream ts ( &file ); 1308 QTextStream ts ( &file );
1305 ts.setEncoding( QTextStream::Latin1 ); 1309 ts.setEncoding( QTextStream::Latin1 );
1306 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1310 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1307 ts << piFileString; 1311 ts << piFileString;
1308 mSocket->close(); 1312 mSocket->close();
1309 if ( mSocket->state() == QSocket::Idle ) 1313 if ( mSocket->state() == QSocket::Idle )
1310 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1314 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1311 file.close(); 1315 file.close();
1312 piFileString = ""; 1316 piFileString = "";
1313 emit file_received( true ); 1317 emit file_received( true );
1314 delete mSyncActionDialog; 1318 delete mSyncActionDialog;
1315 mSyncActionDialog = 0; 1319 mSyncActionDialog = 0;
1316 blockRC = false; 1320 blockRC = false;
1317 1321
1318} 1322}
1319 1323
1320KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 1324KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
1321{ 1325{
1322 mPassWord = password; 1326 mPassWord = password;
1323 mSocket = 0; 1327 mSocket = 0;
1324 mPort = port; 1328 mPort = port;
1325 mHost = host; 1329 mHost = host;
1326 1330
1327 mRetVal = quiet; 1331 mRetVal = quiet;
1328 mTimerSocket = new QTimer ( this ); 1332 mTimerSocket = new QTimer ( this );
1329 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 1333 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1330} 1334}
1331void KCommandSocket::readFile( QString fn ) 1335void KCommandSocket::readFile( QString fn )
1332{ 1336{
1333 if ( !mSocket ) { 1337 if ( !mSocket ) {
1334 mSocket = new QSocket( this ); 1338 mSocket = new QSocket( this );
1335 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1339 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1336 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1340 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1337 } 1341 }
1338 mFileString = ""; 1342 mFileString = "";
1339 mFileName = fn; 1343 mFileName = fn;
1340 mFirst = true; 1344 mFirst = true;
1341 mSocket->connectToHost( mHost, mPort ); 1345 mSocket->connectToHost( mHost, mPort );
1342 QTextStream os( mSocket ); 1346 QTextStream os( mSocket );
1343 os.setEncoding( QTextStream::Latin1 ); 1347 os.setEncoding( QTextStream::Latin1 );
1344 1348
1345 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1349 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1346 os << "GET " << mPassWord << curDt <<"\r\n"; 1350 os << "GET " << mPassWord << curDt <<"\r\n";
1347 mTimerSocket->start( 300000 ); 1351 mTimerSocket->start( 300000 );
1348} 1352}
1349 1353
1350void KCommandSocket::writeFile( QString fileName ) 1354void KCommandSocket::writeFile( QString fileName )
1351{ 1355{
1352 if ( !mSocket ) { 1356 if ( !mSocket ) {
1353 mSocket = new QSocket( this ); 1357 mSocket = new QSocket( this );
1354 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1358 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1355 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1359 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1356 } 1360 }
1357 mFileName = fileName ; 1361 mFileName = fileName ;
1358 mSocket->connectToHost( mHost, mPort ); 1362 mSocket->connectToHost( mHost, mPort );
1359} 1363}
1360void KCommandSocket::writeFileToSocket() 1364void KCommandSocket::writeFileToSocket()
1361{ 1365{
1362 QFile file2( mFileName ); 1366 QFile file2( mFileName );
1363 if (!file2.open( IO_ReadOnly ) ) { 1367 if (!file2.open( IO_ReadOnly ) ) {
1364 mRetVal= errorW; 1368 mRetVal= errorW;
1365 mSocket->close(); 1369 mSocket->close();
1366 if ( mSocket->state() == QSocket::Idle ) 1370 if ( mSocket->state() == QSocket::Idle )
1367 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1371 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1368 return ; 1372 return ;
1369 } 1373 }
1370 QTextStream ts2( &file2 ); 1374 QTextStream ts2( &file2 );
1371 ts2.setEncoding( QTextStream::Latin1 ); 1375 ts2.setEncoding( QTextStream::Latin1 );
1372 QTextStream os2( mSocket ); 1376 QTextStream os2( mSocket );
1373 os2.setEncoding( QTextStream::Latin1 ); 1377 os2.setEncoding( QTextStream::Latin1 );
1374 os2 << "PUT " << mPassWord << "\r\n";; 1378 os2 << "PUT " << mPassWord << "\r\n";;
1375 while ( ! ts2.atEnd() ) { 1379 while ( ! ts2.atEnd() ) {
1376 os2 << ts2.readLine() << "\r\n"; 1380 os2 << ts2.readLine() << "\r\n";
1377 } 1381 }
1378 mRetVal= successW; 1382 mRetVal= successW;
1379 file2.close(); 1383 file2.close();
1380 mSocket->close(); 1384 mSocket->close();
1381 if ( mSocket->state() == QSocket::Idle ) 1385 if ( mSocket->state() == QSocket::Idle )
1382 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1386 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1383} 1387}
1384void KCommandSocket::sendStop() 1388void KCommandSocket::sendStop()
1385{ 1389{
1386 if ( !mSocket ) { 1390 if ( !mSocket ) {
1387 mSocket = new QSocket( this ); 1391 mSocket = new QSocket( this );
1388 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1392 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1389 } 1393 }
1390 mSocket->connectToHost( mHost, mPort ); 1394 mSocket->connectToHost( mHost, mPort );
1391 QTextStream os2( mSocket ); 1395 QTextStream os2( mSocket );
1392 os2.setEncoding( QTextStream::Latin1 ); 1396 os2.setEncoding( QTextStream::Latin1 );
1393 os2 << "STOP\r\n"; 1397 os2 << "STOP\r\n";
1394 mSocket->close(); 1398 mSocket->close();
1395 if ( mSocket->state() == QSocket::Idle ) 1399 if ( mSocket->state() == QSocket::Idle )
1396 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1400 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1397} 1401}
1398 1402
1399void KCommandSocket::startReadFileFromSocket() 1403void KCommandSocket::startReadFileFromSocket()
1400{ 1404{
1401 if ( ! mFirst ) 1405 if ( ! mFirst )
1402 return; 1406 return;
1403 mFirst = false; 1407 mFirst = false;
1404 mTimerSocket->stop(); 1408 mTimerSocket->stop();
1405 mFileString = ""; 1409 mFileString = "";
1406 mTime.start(); 1410 mTime.start();
1407 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1411 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1408 1412
1409} 1413}
1410void KCommandSocket::readFileFromSocket() 1414void KCommandSocket::readFileFromSocket()
1411{ 1415{
1412 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1416 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1413 while ( mSocket->canReadLine () ) { 1417 while ( mSocket->canReadLine () ) {
1414 mTime.restart(); 1418 mTime.restart();
1415 QString line = mSocket->readLine (); 1419 QString line = mSocket->readLine ();
1416 mFileString += line; 1420 mFileString += line;
1417 //qDebug("readline: %s ", line.latin1()); 1421 //qDebug("readline: %s ", line.latin1());
1418 } 1422 }
1419 if ( mTime.elapsed () < 3000 ) { 1423 if ( mTime.elapsed () < 3000 ) {
1420 // wait for more 1424 // wait for more
1421 //qDebug("waitformore "); 1425 //qDebug("waitformore ");
1422 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1426 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1423 return; 1427 return;
1424 } 1428 }
1425 QString fileName = mFileName; 1429 QString fileName = mFileName;
1426 QFile file ( fileName ); 1430 QFile file ( fileName );
1427 if (!file.open( IO_WriteOnly ) ) { 1431 if (!file.open( IO_WriteOnly ) ) {
1428 mFileString = ""; 1432 mFileString = "";
1429 mRetVal = errorR; 1433 mRetVal = errorR;
1430 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1434 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1431 deleteSocket(); 1435 deleteSocket();
1432 return ; 1436 return ;
1433 1437
1434 } 1438 }
1435 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1439 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1436 QTextStream ts ( &file ); 1440 QTextStream ts ( &file );
1437 ts.setEncoding( QTextStream::Latin1 ); 1441 ts.setEncoding( QTextStream::Latin1 );
1438 ts << mFileString; 1442 ts << mFileString;
1439 file.close(); 1443 file.close();
1440 mFileString = ""; 1444 mFileString = "";
1441 mRetVal = successR; 1445 mRetVal = successR;
1442 mSocket->close(); 1446 mSocket->close();
1443 // if state is not idle, deleteSocket(); is called via 1447 // if state is not idle, deleteSocket(); is called via
1444 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1448 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1445 if ( mSocket->state() == QSocket::Idle ) 1449 if ( mSocket->state() == QSocket::Idle )
1446 deleteSocket(); 1450 deleteSocket();
1447} 1451}
1448 1452
1449void KCommandSocket::deleteSocket() 1453void KCommandSocket::deleteSocket()
1450{ 1454{
1451 //qDebug("KCommandSocket::deleteSocket() "); 1455 //qDebug("KCommandSocket::deleteSocket() ");
1452 if ( mTimerSocket->isActive () ) { 1456 if ( mTimerSocket->isActive () ) {
1453 mTimerSocket->stop(); 1457 mTimerSocket->stop();
1454 mRetVal = errorTO; 1458 mRetVal = errorTO;
1455 qDebug("Connection to remote host timed out"); 1459 qDebug("Connection to remote host timed out");
1456 if ( mSocket ) { 1460 if ( mSocket ) {
1457 mSocket->close(); 1461 mSocket->close();
1458 //if ( mSocket->state() == QSocket::Idle ) 1462 //if ( mSocket->state() == QSocket::Idle )
1459 // deleteSocket(); 1463 // deleteSocket();
1460 delete mSocket; 1464 delete mSocket;
1461 mSocket = 0; 1465 mSocket = 0;
1462 } 1466 }
1463 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 1467 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? "));
1464 emit commandFinished( this, mRetVal ); 1468 emit commandFinished( this, mRetVal );
1465 return; 1469 return;
1466 } 1470 }
1467 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1471 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1468 if ( mSocket) 1472 if ( mSocket)
1469 delete mSocket; 1473 delete mSocket;
1470 mSocket = 0; 1474 mSocket = 0;
1471 emit commandFinished( this, mRetVal ); 1475 emit commandFinished( this, mRetVal );
1472} 1476}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 6da0ee4..2d0a4ab 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,216 +1,217 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20 $Id$ 20 $Id$
21*/ 21*/
22#ifndef _KSYNCMANAGER_H 22#ifndef _KSYNCMANAGER_H
23#define _KSYNCMANAGER_H 23#define _KSYNCMANAGER_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qsocket.h> 27#include <qsocket.h>
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qserversocket.h> 29#include <qserversocket.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qregexp.h> 31#include <qregexp.h>
32 32
33class QPopupMenu; 33class QPopupMenu;
34class KSyncProfile; 34class KSyncProfile;
35class KPimPrefs; 35class KPimPrefs;
36class QWidget; 36class QWidget;
37class KSyncManager; 37class KSyncManager;
38class KSyncInterface; 38class KSyncInterface;
39class QProgressBar; 39class QProgressBar;
40 40
41 41
42class KServerSocket : public QServerSocket 42class KServerSocket : public QServerSocket
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46 public: 46 public:
47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
48 48
49 void newConnection ( int socket ) ; 49 void newConnection ( int socket ) ;
50 void setFileName( QString fn ) {mFileName = fn;}; 50 void setFileName( QString fn ) {mFileName = fn;};
51 signals: 51 signals:
52 void file_received( bool ); 52 void file_received( bool );
53 void request_file(); 53 void request_file();
54 void saveFile(); 54 void saveFile();
55 void endConnect(); 55 void endConnect();
56 private slots: 56 private slots:
57 void discardClient(); 57 void discardClient();
58 void readClient(); 58 void readClient();
59 void readBackFileFromSocket(); 59 void readBackFileFromSocket();
60 private : 60 private :
61 bool blockRC; 61 bool blockRC;
62 void send_file(); 62 void send_file();
63 void get_file(); 63 void get_file();
64 void end_connect(); 64 void end_connect();
65 QDialog* mSyncActionDialog; 65 QDialog* mSyncActionDialog;
66 QSocket* mSocket; 66 QSocket* mSocket;
67 QString mPassWord; 67 QString mPassWord;
68 QString mFileName; 68 QString mFileName;
69 QTime piTime; 69 QTime piTime;
70 QString piFileString; 70 QString piFileString;
71}; 71};
72 72
73class KCommandSocket : public QObject 73class KCommandSocket : public QObject
74{ 74{
75 Q_OBJECT 75 Q_OBJECT
76 public: 76 public:
77 enum state { successR, errorR, successW, errorW, errorTO, quiet }; 77 enum state { successR, errorR, successW, errorW, errorTO, quiet };
78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
79 void readFile( QString ); 79 void readFile( QString );
80 void writeFile( QString ); 80 void writeFile( QString );
81 void sendStop(); 81 void sendStop();
82 82
83 signals: 83 signals:
84 void commandFinished( KCommandSocket*, int ); 84 void commandFinished( KCommandSocket*, int );
85 private slots: 85 private slots:
86 void startReadFileFromSocket(); 86 void startReadFileFromSocket();
87 void readFileFromSocket(); 87 void readFileFromSocket();
88 void deleteSocket(); 88 void deleteSocket();
89 void writeFileToSocket(); 89 void writeFileToSocket();
90 private : 90 private :
91 QSocket* mSocket; 91 QSocket* mSocket;
92 QString mPassWord; 92 QString mPassWord;
93 Q_UINT16 mPort; 93 Q_UINT16 mPort;
94 QString mHost; 94 QString mHost;
95 QString mFileName; 95 QString mFileName;
96 QTimer* mTimerSocket; 96 QTimer* mTimerSocket;
97 int mRetVal; 97 int mRetVal;
98 QTime mTime; 98 QTime mTime;
99 QString mFileString; 99 QString mFileString;
100 bool mFirst; 100 bool mFirst;
101}; 101};
102 102
103 103
104class KSyncManager : public QObject 104class KSyncManager : public QObject
105{ 105{
106 Q_OBJECT 106 Q_OBJECT
107 107
108 public: 108 public:
109 enum TargetApp { 109 enum TargetApp {
110 KOPI = 0, 110 KOPI = 0,
111 KAPI = 1, 111 KAPI = 1,
112 PWMPI = 2 }; 112 PWMPI = 2 };
113 113
114 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 114 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
115 ~KSyncManager() ; 115 ~KSyncManager() ;
116 116
117 void multiSync( bool askforPrefs ); 117 void multiSync( bool askforPrefs );
118 bool blockSave() { return mBlockSaveFlag; } 118 bool blockSave() { return mBlockSaveFlag; }
119 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 119 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
120 void setDefaultFileName( QString s) { mDefFileName = s ;} 120 void setDefaultFileName( QString s) { mDefFileName = s ;}
121 QString defaultFileName() { return mDefFileName ;} 121 QString defaultFileName() { return mDefFileName ;}
122 QString syncFileName(); 122 QString syncFileName();
123 void enableQuick( bool ask = true); 123 void enableQuick( bool ask = true);
124 124
125 bool syncWithDesktop () { return mSyncWithDesktop;} 125 bool syncWithDesktop () { return mSyncWithDesktop;}
126 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 126 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
127 QString getCurrentSyncName() { return mCurrentSyncName; } 127 QString getCurrentSyncName() { return mCurrentSyncName; }
128 128
129 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 129 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
130 void hideProgressBar(); 130 void hideProgressBar();
131 bool isProgressBarCanceled(); 131 bool isProgressBarCanceled();
132 132
133 // sync stuff 133 // sync stuff
134 QString mLocalMachineName; 134 QString mLocalMachineName;
135 QStringList mExternSyncProfiles; 135 QStringList mExternSyncProfiles;
136 QStringList mSyncProfileNames; 136 QStringList mSyncProfileNames;
137 bool mAskForPreferences; 137 bool mAskForPreferences;
138 bool mShowSyncSummary; 138 bool mShowSyncSummary;
139 bool mIsKapiFile; 139 bool mIsKapiFile;
140 bool mWriteBackExistingOnly; 140 bool mWriteBackExistingOnly;
141 int mSyncAlgoPrefs; 141 int mSyncAlgoPrefs;
142 bool mWriteBackFile; 142 bool mWriteBackFile;
143 int mWriteBackInFuture; 143 int mWriteBackInFuture;
144 int mWriteBackInPast;
144 QString mPhoneDevice; 145 QString mPhoneDevice;
145 QString mPhoneConnection; 146 QString mPhoneConnection;
146 QString mPhoneModel; 147 QString mPhoneModel;
147 QString mPassWordPiSync; 148 QString mPassWordPiSync;
148 QString mActiveSyncPort; 149 QString mActiveSyncPort;
149 QString mActiveSyncIP ; 150 QString mActiveSyncIP ;
150 static QDateTime mRequestedSyncEvent; 151 static QDateTime mRequestedSyncEvent;
151 152
152 signals: 153 signals:
153 void save(); 154 void save();
154 void request_file(); 155 void request_file();
155 void getFile( bool ); 156 void getFile( bool );
156 157
157 public slots: 158 public slots:
158 void slotSyncMenu( int ); 159 void slotSyncMenu( int );
159 void slotClearMenu( int action ); 160 void slotClearMenu( int action );
160 void deleteCommandSocket(KCommandSocket*s, int state); 161 void deleteCommandSocket(KCommandSocket*s, int state);
161 void readFileFromSocket(); 162 void readFileFromSocket();
162 void fillSyncMenu(); 163 void fillSyncMenu();
163 164
164 private: 165 private:
165 void syncPi(); 166 void syncPi();
166 KServerSocket * mServerSocket; 167 KServerSocket * mServerSocket;
167 KPimPrefs* mPrefs; 168 KPimPrefs* mPrefs;
168 QString mDefFileName; 169 QString mDefFileName;
169 QString mCurrentSyncDevice; 170 QString mCurrentSyncDevice;
170 QString mCurrentSyncName; 171 QString mCurrentSyncName;
171 void quickSyncLocalFile(); 172 void quickSyncLocalFile();
172 bool syncWithFile( QString fn , bool quick ); 173 bool syncWithFile( QString fn , bool quick );
173 void syncLocalFile(); 174 void syncLocalFile();
174 void syncPhone(); 175 void syncPhone();
175 void syncSharp(); 176 void syncSharp();
176 void syncKDE(); 177 void syncKDE();
177 bool syncExternalApplication(QString); 178 bool syncExternalApplication(QString);
178 int mCurrentSyncProfile ; 179 int mCurrentSyncProfile ;
179 void syncRemote( KSyncProfile* prof, bool ask = true); 180 void syncRemote( KSyncProfile* prof, bool ask = true);
180 bool edit_sync_options(); 181 bool edit_sync_options();
181 bool edit_pisync_options(); 182 bool edit_pisync_options();
182 int ringSync(); 183 int ringSync();
183 QString getPassword( ); 184 QString getPassword( );
184 bool mPisyncFinished; 185 bool mPisyncFinished;
185 bool mBlockSaveFlag; 186 bool mBlockSaveFlag;
186 QWidget* mParent; 187 QWidget* mParent;
187 KSyncInterface* mImplementation; 188 KSyncInterface* mImplementation;
188 TargetApp mTargetApp; 189 TargetApp mTargetApp;
189 QPopupMenu* mSyncMenu; 190 QPopupMenu* mSyncMenu;
190 QProgressBar* bar; 191 QProgressBar* bar;
191 bool mSyncWithDesktop; 192 bool mSyncWithDesktop;
192 193
193private slots: 194private slots:
194 void confSync(); 195 void confSync();
195 196
196 197
197}; 198};
198 199
199 200
200class KSyncInterface 201class KSyncInterface
201{ 202{
202 public : 203 public :
203 virtual void removeSyncInfo( QString syncProfile) = 0; 204 virtual void removeSyncInfo( QString syncProfile) = 0;
204 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 205 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
205 virtual bool syncExternal(KSyncManager* manager, QString resource) 206 virtual bool syncExternal(KSyncManager* manager, QString resource)
206 { 207 {
207 // empty implementation, because some syncable applications do not 208 // empty implementation, because some syncable applications do not
208 // have an external(sharpdtm) syncmode, like pwmanager. 209 // have an external(sharpdtm) syncmode, like pwmanager.
209 return false; 210 return false;
210 } 211 }
211 212
212 213
213}; 214};
214 215
215 216
216#endif 217#endif
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 03265d2..8a3f4cf 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -1,744 +1,791 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qvbox.h> 35#include <qvbox.h>
36#include <qhbox.h> 36#include <qhbox.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qstrlist.h> 42#include <qstrlist.h>
43#include <qapplication.h> 43#include <qapplication.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qscrollview.h> 45#include <qscrollview.h>
46#include <qvgroupbox.h>
47#include <qhgroupbox.h>
46 48
47#include <kcolorbutton.h> 49#include <kcolorbutton.h>
48#include <kdebug.h> 50#include <kdebug.h>
49#include <klocale.h> 51#include <klocale.h>
50#include <kglobal.h> 52#include <kglobal.h>
51#include <kfontdialog.h> 53#include <kfontdialog.h>
52#include <kmessagebox.h> 54#include <kmessagebox.h>
53#include <kcolordialog.h> 55#include <kcolordialog.h>
54#include <kiconloader.h> 56#include <kiconloader.h>
55#include <kemailsettings.h> 57#include <kemailsettings.h>
56#include <kstandarddirs.h> 58#include <kstandarddirs.h>
57#include <kfiledialog.h> 59#include <kfiledialog.h>
58#include <kmessagebox.h> 60#include <kmessagebox.h>
59 61
60//#include <kurlrequester.h> 62//#include <kurlrequester.h>
61#include <klineedit.h> 63#include <klineedit.h>
62#include "ksyncprofile.h" 64#include "ksyncprofile.h"
63 65
64 66
65//#include "koprefs.h" 67//#include "koprefs.h"
66 68
67#include "ksyncprefsdialog.h" 69#include "ksyncprefsdialog.h"
68//#include "koglobals.h" 70//#include "koglobals.h"
69 71
70 72
71KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : 73KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) :
72 KDialog(parent,name,true) 74 KDialog(parent,name,true)
73{ 75{
74 76
75 setCaption( i18n("Synchronization Preferences")); 77 setCaption( i18n("Synchronization Preferences"));
76 78
77 mSyncProfiles.setAutoDelete( true ); 79 mSyncProfiles.setAutoDelete( true );
78 setupSyncAlgTab(); 80 setupSyncAlgTab();
79} 81}
80 82
81 83
82KSyncPrefsDialog::~KSyncPrefsDialog() 84KSyncPrefsDialog::~KSyncPrefsDialog()
83{ 85{
84} 86}
85 87
86void KSyncPrefsDialog::setupSyncAlgTab() 88void KSyncPrefsDialog::setupSyncAlgTab()
87{ 89{
88 QLabel * lab; 90 QLabel * lab;
89 //QFrame *page = addPage(i18n("Sync Prefs"),0,0); 91 //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
90 QVBox * mainbox = new QVBox( this ); 92 QVBox * mainbox = new QVBox( this );
91 QScrollView* sv = new QScrollView( mainbox ); 93 QScrollView* sv = new QScrollView( mainbox );
92 QHBoxLayout * lay = new QHBoxLayout( this ); 94 QHBoxLayout * lay = new QHBoxLayout( this );
93 lay->addWidget( mainbox ); 95 lay->addWidget( mainbox );
94 QHBox * b_box = new QHBox( mainbox ); 96 QHBox * b_box = new QHBox( mainbox );
95 97
96 QPushButton* button = new QPushButton( i18n("Ok"), b_box ); 98 QPushButton* button = new QPushButton( i18n("Ok"), b_box );
97 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); 99 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
98 button = new QPushButton( i18n("Cancel"), b_box ); 100 button = new QPushButton( i18n("Cancel"), b_box );
99 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); 101 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
100 //QBoxLayout * sl = new QVBoxLayout(this ); 102 //QBoxLayout * sl = new QVBoxLayout(this );
101 //sl->addWidget ( sv ); 103 //sl->addWidget ( sv );
102 sv->setResizePolicy ( QScrollView::AutoOneFit ); 104 sv->setResizePolicy ( QScrollView::AutoOneFit );
103 QFrame *topFrame = new QFrame ( sv ); 105 QFrame *topFrame = new QFrame ( sv );
104 sv->addChild( topFrame ); 106 sv->addChild( topFrame );
105 mSetupSyncAlgTab = topFrame; 107 mSetupSyncAlgTab = topFrame;
106 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 108 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
107 topLayout->setSpacing(spacingHint()); 109 topLayout->setSpacing(spacingHint());
108 topLayout->setMargin(marginHint()); 110 topLayout->setMargin(marginHint());
109 111
110 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); 112 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
111 int iii = 0; 113 int iii = 0;
112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1); 114 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
113 //++iii; 115 //++iii;
114 116
115 mMyMachineName = new QLineEdit(topFrame); 117 mMyMachineName = new QLineEdit(topFrame);
116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); 118 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
117 topLayout->addWidget(lab ,iii,0); 119 topLayout->addWidget(lab ,iii,0);
118 topLayout->addWidget(mMyMachineName,iii,1); 120 topLayout->addWidget(mMyMachineName,iii,1);
119 ++iii; 121 ++iii;
120 122
121 QHBox* buttonbox = new QHBox( topFrame); 123 QHBox* buttonbox = new QHBox( topFrame);
122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); 124 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
123 ++iii; 125 ++iii;
124 button = new QPushButton( i18n("New profile"), buttonbox ); 126 button = new QPushButton( i18n("New profile"), buttonbox );
125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); 127 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
126 128
127 button = new QPushButton( i18n("Clone profile"), buttonbox ); 129 button = new QPushButton( i18n("Clone profile"), buttonbox );
128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); 130 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
129 131
130 button = new QPushButton( i18n("Delete profile"), buttonbox ); 132 button = new QPushButton( i18n("Delete profile"), buttonbox );
131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); 133 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
132 134
133 mProfileBox = new QComboBox(topFrame); 135 mProfileBox = new QComboBox(topFrame);
134 mProfileBox->setEditable ( true ); 136 mProfileBox->setEditable ( true );
135 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); 137 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion);
136 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); 138 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
137 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); 139 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
138 140
139 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); 141 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
140 topLayout->addWidget(lab ,iii,0); 142 topLayout->addWidget(lab ,iii,0);
141 topLayout->addWidget(mProfileBox, iii,1); 143 topLayout->addWidget(mProfileBox, iii,1);
142 ++iii; 144 ++iii;
143 145
144 QHBox *iims = new QHBox( topFrame ); 146
147
148 QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame);
145 new QLabel( i18n("Include in multiple "), iims ); 149 new QLabel( i18n("Include in multiple "), iims );
146 mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); 150 mIncludeInRing = new QCheckBox( i18n("calendar "), iims );
147 mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); 151 mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims );
148 mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); 152 mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims );
149 new QLabel( i18n(" sync"), iims ); 153 new QLabel( i18n(" sync"), iims );
150 topLayout->addMultiCellWidget(iims, iii,iii,0,1); 154 topLayout->addMultiCellWidget(iims, iii,iii,0,1);
151 ++iii; 155 ++iii;
152 156 QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame);
153 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); 157 topLayout->addMultiCellWidget(gb0, iii,iii,0,1);
154 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
155 ++iii;
156 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
157 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
158 ++iii;
159 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
160 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
161 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
162 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
163 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
164 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
165 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
166
167 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
168 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
169 ++iii;
170
171 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame );
172 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
173 ++iii; 158 ++iii;
159 QButtonGroup* gr;
160 {
161 QVGroupBox* topFrame = gb0;
162 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame );
163 //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
164 //++iii;
165 gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
166 //topLayout->addMultiCellWidget(gr, iii,iii,0,1);
167 //++iii;
168 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
169 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
170 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
171 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
172 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
173 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
174 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
175
176 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
177 //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
178 //++iii;
179
180 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame );
181 // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
182 // ++iii;
174 183
175 mWriteBackExisting= new QCheckBox( i18n("-- Write back (on remote) existing entries only"), topFrame ); 184 QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame);
176 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); 185 //topLayout->addMultiCellWidget(gb2, iii,iii,0,1);
177 ++iii; 186 //++iii;
178 187 {
179 mWriteBackFuture= new QCheckBox( i18n("-- Write back (calendar) entries in future only"), topFrame ); 188 QVGroupBox*topFrame = gb2;
180 topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); 189 mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame );
181 ++iii; 190 //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
182 topLayout->addMultiCellWidget(new QLabel( i18n("---- Max. weeks in future: ") , topFrame ), iii,iii,0,0); 191 //++iii;
183 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, topFrame); 192 mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame );
184 topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); 193 //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1);
185 ++iii; 194 //++iii;
186 195 QHGroupBox* gb3 = new QHGroupBox( i18n("Time period"), topFrame);
196 connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) );
197 new QLabel( i18n("From ") , gb3 );
198 mWriteBackPastWeeks= new QSpinBox(1,104, 1, gb3);
199 new QLabel( i18n(" weeks in the past to ") , gb3 );
200 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, gb3);
201 new QLabel( i18n(" weeks in the future ") , gb3 );
202 //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1);
203 //++iii;
204 gb3->setEnabled( false );
205 }
206 connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) );
207
208 }
187 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); 209 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame);
188 gr = proGr; 210 gr = proGr;
189 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 211 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
190 ++iii; 212 ++iii;
191 mIsLocal = new QRadioButton ( i18n("Local file"), gr ); 213 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
192 mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr ); 214 mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr );
193 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 215 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
194 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); 216 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
195 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 217 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
196 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); 218 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr );
197 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 219 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
198 220
199 221 QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame);
200 phoneWidget = new QVBox( topFrame); 222 topLayout->addMultiCellWidget(gb1, iii,iii,0,1);
201 topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1);
202 ++iii;
203 mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget );
204 QHBox* temphb = new QHBox( phoneWidget );
205 new QLabel( i18n("I/O device: "), temphb );
206 mPhoneDevice = new QLineEdit( temphb);
207 button = new QPushButton( i18n("Help..."), temphb );
208 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) );
209
210
211 temphb = new QHBox( phoneWidget );
212 new QLabel( i18n("Connection: "), temphb );
213 mPhoneConnection = new QLineEdit( temphb);
214 button = new QPushButton( i18n("Help..."), temphb );
215 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) );
216
217
218 temphb = new QHBox( phoneWidget );
219 new QLabel( i18n("Model(opt.): "), temphb );
220 mPhoneModel = new QLineEdit( temphb);
221 button = new QPushButton( i18n("Help..."), temphb );
222 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) );
223
224 // *** local
225 localFileWidget = new QVBox( topFrame);
226 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
227 ++iii; 223 ++iii;
228 temphb = new QHBox( localFileWidget );
229
230 lab = new QLabel( i18n("Local file Cal:"), temphb );
231 lab = new QLabel( i18n("Local file ABook:"), temphb );
232 lab = new QLabel( i18n("Local file PWMgr:"), temphb );
233 temphb = new QHBox( localFileWidget );
234 button = new QPushButton( i18n("Choose..."), temphb );
235 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
236 button = new QPushButton( i18n("Choose..."), temphb );
237 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) );
238 button = new QPushButton( i18n("Choose..."), temphb );
239 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) );
240 temphb = new QHBox( localFileWidget );
241
242 mRemoteFile = new QLineEdit( temphb);
243 mRemoteFileAB = new QLineEdit( temphb);
244 mRemoteFilePWM = new QLineEdit( temphb);
245 mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget );
246
247
248 // *** remote
249 remoteFileWidget = new QVBox( topFrame);
250 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
251 ++iii;
252 temphb = new QHBox( remoteFileWidget );
253 new QLabel( i18n("Calendar:"), temphb);
254 new QLabel( i18n("AddressBook:"), temphb);
255 new QLabel( i18n("PWManager:"), temphb);
256
257 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
258 temphb = new QHBox( remoteFileWidget );
259 mRemotePrecommand = new QLineEdit(temphb);
260 mRemotePrecommandAB = new QLineEdit(temphb);
261 mRemotePrecommandPWM = new QLineEdit(temphb);
262
263 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
264 temphb = new QHBox( remoteFileWidget );
265 mLocalTempFile = new QLineEdit(temphb);
266 mLocalTempFileAB = new QLineEdit(temphb);
267 mLocalTempFilePWM = new QLineEdit(temphb);
268
269 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
270 temphb = new QHBox( remoteFileWidget );
271 mRemotePostcommand = new QLineEdit(temphb );
272 mRemotePostcommandAB = new QLineEdit(temphb );
273 mRemotePostcommandPWM = new QLineEdit(temphb );
274 mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget );
275 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
276 temphb = new QHBox( remoteFileWidget );
277 button = new QPushButton( i18n("ssh/scp"), temphb );
278 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
279 button = new QPushButton( i18n("ftp"), temphb );
280 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
281 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
282
283 // *** pi-sync
284 piWidget = new QVBox( topFrame);
285 topLayout->addMultiCellWidget(piWidget, iii,iii,0,1);
286 ++iii;
287 temphb = new QHBox( piWidget );
288 new QLabel( i18n("Calendar:"), temphb);
289 new QLabel( i18n("AddressBook:"), temphb);
290 new QLabel( i18n("PWManager:"), temphb);
291
292 lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget);
293 temphb = new QHBox( piWidget );
294 mRemotePw = new QLineEdit(temphb);
295 mRemotePwAB = new QLineEdit(temphb);
296 mRemotePwPWM = new QLineEdit(temphb);
297
298 lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget);
299 temphb = new QHBox( piWidget );
300 mRemoteIP = new QLineEdit(temphb);
301 mRemoteIPAB = new QLineEdit(temphb);
302 mRemoteIPPWM = new QLineEdit(temphb);
303
304 lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget);
305 temphb = new QHBox( piWidget );
306 mRemotePort = new QLineEdit(temphb);
307 mRemotePortAB = new QLineEdit(temphb);
308 mRemotePortPWM = new QLineEdit(temphb);
309 224
225 // ******************************************
226 // Profile kind specific settings
227 {
228 // *** phone *******************************
229 QVGroupBox* topFrame = gb1;
230 phoneWidget = new QVBox( topFrame);
231 //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1);
232 //++iii;
233 mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget );
234 QHBox* temphb = new QHBox( phoneWidget );
235 new QLabel( i18n("I/O device: "), temphb );
236 mPhoneDevice = new QLineEdit( temphb);
237 button = new QPushButton( i18n("Help..."), temphb );
238 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) );
239
240
241 temphb = new QHBox( phoneWidget );
242 new QLabel( i18n("Connection: "), temphb );
243 mPhoneConnection = new QLineEdit( temphb);
244 button = new QPushButton( i18n("Help..."), temphb );
245 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) );
246
247
248 temphb = new QHBox( phoneWidget );
249 new QLabel( i18n("Model(opt.): "), temphb );
250 mPhoneModel = new QLineEdit( temphb);
251 button = new QPushButton( i18n("Help..."), temphb );
252 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) );
253
254 // *** local*******************************
255 localFileWidget = new QVBox( topFrame);
256 //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
257 //++iii;
258 temphb = new QHBox( localFileWidget );
259
260 lab = new QLabel( i18n("Local file Cal:"), temphb );
261 lab = new QLabel( i18n("Local file ABook:"), temphb );
262 lab = new QLabel( i18n("Local file PWMgr:"), temphb );
263 temphb = new QHBox( localFileWidget );
264 button = new QPushButton( i18n("Choose..."), temphb );
265 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
266 button = new QPushButton( i18n("Choose..."), temphb );
267 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) );
268 button = new QPushButton( i18n("Choose..."), temphb );
269 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) );
270 temphb = new QHBox( localFileWidget );
271
272 mRemoteFile = new QLineEdit( temphb);
273 mRemoteFileAB = new QLineEdit( temphb);
274 mRemoteFilePWM = new QLineEdit( temphb);
275 mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget );
276
277
278 // *** remote*******************************
279 remoteFileWidget = new QVBox( topFrame);
280 //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
281 //++iii;
282 temphb = new QHBox( remoteFileWidget );
283 new QLabel( i18n("Calendar:"), temphb);
284 new QLabel( i18n("AddressBook:"), temphb);
285 new QLabel( i18n("PWManager:"), temphb);
286
287 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
288 temphb = new QHBox( remoteFileWidget );
289 mRemotePrecommand = new QLineEdit(temphb);
290 mRemotePrecommandAB = new QLineEdit(temphb);
291 mRemotePrecommandPWM = new QLineEdit(temphb);
292
293 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
294 temphb = new QHBox( remoteFileWidget );
295 mLocalTempFile = new QLineEdit(temphb);
296 mLocalTempFileAB = new QLineEdit(temphb);
297 mLocalTempFilePWM = new QLineEdit(temphb);
298
299 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
300 temphb = new QHBox( remoteFileWidget );
301 mRemotePostcommand = new QLineEdit(temphb );
302 mRemotePostcommandAB = new QLineEdit(temphb );
303 mRemotePostcommandPWM = new QLineEdit(temphb );
304 mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget );
305 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
306 temphb = new QHBox( remoteFileWidget );
307 button = new QPushButton( i18n("ssh/scp"), temphb );
308 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
309 button = new QPushButton( i18n("ftp"), temphb );
310 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
311 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
312
313 // *** pi-sync*******************************
314 piWidget = new QVBox( topFrame);
315 //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1);
316 //++iii;
317 temphb = new QHBox( piWidget );
318 new QLabel( i18n("Calendar:"), temphb);
319 new QLabel( i18n("AddressBook:"), temphb);
320 new QLabel( i18n("PWManager:"), temphb);
321
322 lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget);
323 temphb = new QHBox( piWidget );
324 mRemotePw = new QLineEdit(temphb);
325 mRemotePwAB = new QLineEdit(temphb);
326 mRemotePwPWM = new QLineEdit(temphb);
327
328 lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget);
329 temphb = new QHBox( piWidget );
330 mRemoteIP = new QLineEdit(temphb);
331 mRemoteIPAB = new QLineEdit(temphb);
332 mRemoteIPPWM = new QLineEdit(temphb);
333
334 lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget);
335 temphb = new QHBox( piWidget );
336 mRemotePort = new QLineEdit(temphb);
337 mRemotePortAB = new QLineEdit(temphb);
338 mRemotePortPWM = new QLineEdit(temphb);
339 }
340 // ******************************************
341 // Profile kind specific settings END
342
310} 343}
311 344
312 345
313 346
347void KSyncPrefsDialog::readFilter()
348{
349 mFilterKapi.clear();
350 mFilterKopi.clear();
351 mFilterKopi.append(i18n("No Filter") );
352 mFilterKapi.append(i18n("No Filter") );
353 KConfig cfgko(locateLocal("config","korganizerrc"));
354 KConfig cfgka(locateLocal("config","kaddressbookrc"));
355 cfgko.setGroup("General");
356 mFilterKopi = cfgko.readListEntry("CalendarFilters");
357 mFilterKopi.prepend(i18n("No Filter") );
358}
314 359
315 360
316void KSyncPrefsDialog::slotOK() 361void KSyncPrefsDialog::slotOK()
317{ 362{
318 if ( mMyMachineName->text() == "undefined" ) { 363 if ( mMyMachineName->text() == "undefined" ) {
319 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); 364 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
320 return; 365 return;
321 } 366 }
322 int i; 367 int i;
323 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 368 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
324 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 369 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
325 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); 370 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
326 return; 371 return;
327 } 372 }
328 } 373 }
329 usrWriteConfig(); 374 usrWriteConfig();
330 QDialog::accept(); 375 QDialog::accept();
331} 376}
332void KSyncPrefsDialog::accept() 377void KSyncPrefsDialog::accept()
333{ 378{
334 slotOK(); 379 slotOK();
335} 380}
336void KSyncPrefsDialog::chooseFile() 381void KSyncPrefsDialog::chooseFile()
337{ 382{
338 QString fn = QDir::homeDirPath(); 383 QString fn = QDir::homeDirPath();
339 384
340 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 385 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
341 if ( fn == "" ) 386 if ( fn == "" )
342 return; 387 return;
343 mRemoteFile->setText( fn ); 388 mRemoteFile->setText( fn );
344} 389}
345 390
346void KSyncPrefsDialog::chooseFileAB() 391void KSyncPrefsDialog::chooseFileAB()
347{ 392{
348 QString fn = QDir::homeDirPath(); 393 QString fn = QDir::homeDirPath();
349 394
350 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); 395 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this );
351 if ( fn == "" ) 396 if ( fn == "" )
352 return; 397 return;
353 mRemoteFileAB->setText( fn ); 398 mRemoteFileAB->setText( fn );
354} 399}
355 400
356void KSyncPrefsDialog::chooseFilePWM() 401void KSyncPrefsDialog::chooseFilePWM()
357{ 402{
358 QString fn = QDir::homeDirPath(); 403 QString fn = QDir::homeDirPath();
359 404
360 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); 405 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this );
361 if ( fn == "" ) 406 if ( fn == "" )
362 return; 407 return;
363 mRemoteFilePWM->setText( fn ); 408 mRemoteFilePWM->setText( fn );
364} 409}
365 410
366void KSyncPrefsDialog::textChanged( const QString & s ) 411void KSyncPrefsDialog::textChanged( const QString & s )
367{ 412{
368 if ( mProfileBox->count() == 0 ) 413 if ( mProfileBox->count() == 0 )
369 return; 414 return;
370 if ( currentSelection < 3 ) { 415 if ( currentSelection < 3 ) {
371 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 416 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
372 mProfileBox->blockSignals( true ); 417 mProfileBox->blockSignals( true );
373 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 418 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
374 mProfileBox->blockSignals( false ); 419 mProfileBox->blockSignals( false );
375 return; 420 return;
376 } 421 }
377 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 422 //qDebug("cur i %d ",mProfileBox-> currentItem () );
378 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 423 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
379 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 424 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
380 prof->setName( s ); 425 prof->setName( s );
381 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 426 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
382} 427}
383void KSyncPrefsDialog::profileChanged( int item ) 428void KSyncPrefsDialog::profileChanged( int item )
384{ 429{
385 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); 430 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() );
386 KSyncProfile* prof; 431 KSyncProfile* prof;
387 saveProfile(); 432 saveProfile();
388 currentSelection = item; 433 currentSelection = item;
389 prof = mSyncProfiles.at(item) ; 434 prof = mSyncProfiles.at(item) ;
390 435
391 mRemotePw->setText(prof->getRemotePw()); 436 mRemotePw->setText(prof->getRemotePw());
392 mRemoteIP->setText(prof->getRemoteIP()); 437 mRemoteIP->setText(prof->getRemoteIP());
393 mRemotePort->setText(prof->getRemotePort()); 438 mRemotePort->setText(prof->getRemotePort());
394 439
395 mRemotePwAB->setText(prof->getRemotePwAB()); 440 mRemotePwAB->setText(prof->getRemotePwAB());
396 mRemoteIPAB->setText(prof->getRemoteIPAB()); 441 mRemoteIPAB->setText(prof->getRemoteIPAB());
397 mRemotePortAB->setText(prof->getRemotePortAB()); 442 mRemotePortAB->setText(prof->getRemotePortAB());
398 443
399 mRemotePwPWM->setText(prof->getRemotePwPWM()); 444 mRemotePwPWM->setText(prof->getRemotePwPWM());
400 mRemoteIPPWM->setText(prof->getRemoteIPPWM()); 445 mRemoteIPPWM->setText(prof->getRemoteIPPWM());
401 mRemotePortPWM->setText(prof->getRemotePortPWM()); 446 mRemotePortPWM->setText(prof->getRemotePortPWM());
402 447
403 mRemotePrecommand->setText(prof->getPreSyncCommand()); 448 mRemotePrecommand->setText(prof->getPreSyncCommand());
404 mRemotePostcommand->setText(prof->getPostSyncCommand()); 449 mRemotePostcommand->setText(prof->getPostSyncCommand());
405 mLocalTempFile->setText(prof->getLocalTempFile()); 450 mLocalTempFile->setText(prof->getLocalTempFile());
406 mRemoteFile->setText(prof->getRemoteFileName()) ; 451 mRemoteFile->setText(prof->getRemoteFileName()) ;
407 452
408 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); 453 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB());
409 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); 454 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB());
410 mLocalTempFileAB->setText(prof->getLocalTempFileAB()); 455 mLocalTempFileAB->setText(prof->getLocalTempFileAB());
411 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; 456 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ;
412 457
413 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); 458 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM());
414 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); 459 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM());
415 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); 460 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM());
416 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; 461 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ;
417 462
418 if ( mWriteContactToSIM ) 463 if ( mWriteContactToSIM )
419 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); 464 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM());
420 mPhoneDevice->setText(prof->getPhoneDevice()); 465 mPhoneDevice->setText(prof->getPhoneDevice());
421 mPhoneConnection->setText(prof->getPhoneConnection()); 466 mPhoneConnection->setText(prof->getPhoneConnection());
422 mPhoneModel->setText(prof->getPhoneModel()); 467 mPhoneModel->setText(prof->getPhoneModel());
423 468
424 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 469 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
425 mAskForPreferences->setChecked( prof->getAskForPreferences()); 470 mAskForPreferences->setChecked( prof->getAskForPreferences());
426 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 471 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
427 mWriteBackFile->setChecked( prof->getWriteBackFile()); 472 mWriteBackFile->setChecked( prof->getWriteBackFile());
428 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 473 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
429 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); 474 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() );
430 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); 475 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() );
431 mWriteBackFuture->setChecked( prof->getWriteBackFuture()); 476 mWriteBackFuture->setChecked( prof->getWriteBackFuture());
432 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); 477 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() );
478 mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() );
433 479
434 switch ( prof->getSyncPrefs() ) { 480 switch ( prof->getSyncPrefs() ) {
435 case 0: 481 case 0:
436 loc->setChecked( true); 482 loc->setChecked( true);
437 break; 483 break;
438 case 1: 484 case 1:
439 rem->setChecked( true ); 485 rem->setChecked( true );
440 break; 486 break;
441 case 2: 487 case 2:
442 newest->setChecked( true); 488 newest->setChecked( true);
443 break; 489 break;
444 case 3: 490 case 3:
445 ask->setChecked( true); 491 ask->setChecked( true);
446 break; 492 break;
447 case 4: 493 case 4:
448 f_loc->setChecked( true); 494 f_loc->setChecked( true);
449 break; 495 break;
450 case 5: 496 case 5:
451 f_rem->setChecked( true); 497 f_rem->setChecked( true);
452 break; 498 break;
453 case 6: 499 case 6:
454 //both->setChecked( true); 500 //both->setChecked( true);
455 break; 501 break;
456 default: 502 default:
457 break; 503 break;
458 } 504 }
459 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 505 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
460 mIsPhone->setChecked(prof->getIsPhoneSync()) ; 506 mIsPhone->setChecked(prof->getIsPhoneSync()) ;
461 mIsPi->setChecked(prof->getIsPiSync()) ; 507 mIsPi->setChecked(prof->getIsPiSync()) ;
462 mIsKapiFileL->setChecked(prof->getIsKapiFile()) ; 508 mIsKapiFileL->setChecked(prof->getIsKapiFile()) ;
463 mIsKapiFileR->setChecked(prof->getIsKapiFile()) ; 509 mIsKapiFileR->setChecked(prof->getIsKapiFile()) ;
464 510
465 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() ); 511 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() );
466 proGr->setEnabled( item > 2 ); 512 proGr->setEnabled( item > 2 );
467 if ( item < 3 ) { 513 if ( item < 3 ) {
468 localFileWidget->hide(); 514 localFileWidget->hide();
469 remoteFileWidget->hide(); 515 remoteFileWidget->hide();
470 phoneWidget->hide(); 516 phoneWidget->hide();
471 piWidget->hide(); 517 piWidget->hide();
472 518
473 } else 519 } else
474 kindChanged( prof->getIsLocalFileSync() ); 520 kindChanged( prof->getIsLocalFileSync() );
475} 521}
476 522
477void KSyncPrefsDialog::fillSSH() 523void KSyncPrefsDialog::fillSSH()
478{ 524{
479 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 525 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
480 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 526 mLocalTempFile->setText("/tmp/mycalendar.ics" );
481 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 527 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
482 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 528 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
483 mLocalTempFileAB->setText("/tmp/std.vcf" ); 529 mLocalTempFileAB->setText("/tmp/std.vcf" );
484 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); 530 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" );
485 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 531 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
486 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 532 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
487 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); 533 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" );
488} 534}
489void KSyncPrefsDialog::fillFTP() 535void KSyncPrefsDialog::fillFTP()
490{ 536{
491 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 537 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
492 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 538 mLocalTempFile->setText("/tmp/mycalendar.ics" );
493 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 539 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
494 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); 540 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" );
495 mLocalTempFileAB->setText("/tmp/std.vcf" ); 541 mLocalTempFileAB->setText("/tmp/std.vcf" );
496 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 542 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
497 543
498 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); 544 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" );
499 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 545 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
500 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 546 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
501 547
502} 548}
503void KSyncPrefsDialog::kindChanged( bool b ) 549void KSyncPrefsDialog::kindChanged( bool b )
504{ 550{
505 551
506 if ( mIsLocal->isChecked () ) { 552 if ( mIsLocal->isChecked () ) {
507 mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() ); 553 mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() );
508 } else { 554 } else {
509 mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() ); 555 mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() );
510 } 556 }
511 557
512 if ( mIsLocal->isChecked () ) 558 if ( mIsLocal->isChecked () )
513 localFileWidget->show(); 559 localFileWidget->show();
514 else 560 else
515 localFileWidget->hide(); 561 localFileWidget->hide();
516 562
517 if ( mIsNotLocal->isChecked () ) 563 if ( mIsNotLocal->isChecked () )
518 remoteFileWidget->show(); 564 remoteFileWidget->show();
519 else 565 else
520 remoteFileWidget->hide(); 566 remoteFileWidget->hide();
521 567
522 if ( mIsPhone->isChecked () ) { 568 if ( mIsPhone->isChecked () ) {
523 phoneWidget->show(); 569 phoneWidget->show();
524 } 570 }
525 else { 571 else {
526 phoneWidget->hide(); 572 phoneWidget->hide();
527 } 573 }
528 if ( mIsPi->isChecked () ) { 574 if ( mIsPi->isChecked () ) {
529 piWidget->show(); 575 piWidget->show();
530 } 576 }
531 else { 577 else {
532 piWidget->hide(); 578 piWidget->hide();
533 } 579 }
534 580
535} 581}
536void KSyncPrefsDialog::deleteProfile() 582void KSyncPrefsDialog::deleteProfile()
537{ 583{
538 //qDebug("KSyncPrefsDialog::deleteProfile() "); 584 //qDebug("KSyncPrefsDialog::deleteProfile() ");
539 if ( currentSelection >= 0 ) { 585 if ( currentSelection >= 0 ) {
540 if ( currentSelection < 3 ) { 586 if ( currentSelection < 3 ) {
541 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); 587 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
542 return; 588 return;
543 } 589 }
544 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 590 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
545 mSyncProfiles.remove( temp ); 591 mSyncProfiles.remove( temp );
546 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 592 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
547 insertProfiles(); 593 insertProfiles();
548 } 594 }
549} 595}
550 596
551void KSyncPrefsDialog::saveProfile() 597void KSyncPrefsDialog::saveProfile()
552{ 598{
553 KSyncProfile* prof; 599 KSyncProfile* prof;
554 if ( currentSelection >= 0 ) { 600 if ( currentSelection >= 0 ) {
555 prof = mSyncProfiles.at(currentSelection) ; 601 prof = mSyncProfiles.at(currentSelection) ;
556 602
557 prof->setRemotePw( mRemotePw->text()); 603 prof->setRemotePw( mRemotePw->text());
558 prof->setRemoteIP( mRemoteIP->text()); 604 prof->setRemoteIP( mRemoteIP->text());
559 prof->setRemotePort( mRemotePort->text()); 605 prof->setRemotePort( mRemotePort->text());
560 606
561 prof->setRemotePwAB( mRemotePwAB->text()); 607 prof->setRemotePwAB( mRemotePwAB->text());
562 prof->setRemoteIPAB( mRemoteIPAB->text()); 608 prof->setRemoteIPAB( mRemoteIPAB->text());
563 prof->setRemotePortAB( mRemotePortAB->text()); 609 prof->setRemotePortAB( mRemotePortAB->text());
564 610
565 prof->setRemotePwPWM( mRemotePwPWM->text()); 611 prof->setRemotePwPWM( mRemotePwPWM->text());
566 prof->setRemoteIPPWM( mRemoteIPPWM->text()); 612 prof->setRemoteIPPWM( mRemoteIPPWM->text());
567 prof->setRemotePortPWM( mRemotePortPWM->text()); 613 prof->setRemotePortPWM( mRemotePortPWM->text());
568 614
569 prof->setPreSyncCommand( mRemotePrecommand->text()); 615 prof->setPreSyncCommand( mRemotePrecommand->text());
570 prof->setPostSyncCommand( mRemotePostcommand->text() ); 616 prof->setPostSyncCommand( mRemotePostcommand->text() );
571 prof->setLocalTempFile( mLocalTempFile->text()); 617 prof->setLocalTempFile( mLocalTempFile->text());
572 prof->setRemoteFileName( mRemoteFile->text() ); 618 prof->setRemoteFileName( mRemoteFile->text() );
573 prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); 619 prof->setPreSyncCommandAB( mRemotePrecommandAB->text());
574 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); 620 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() );
575 prof->setLocalTempFileAB( mLocalTempFileAB->text()); 621 prof->setLocalTempFileAB( mLocalTempFileAB->text());
576 prof->setRemoteFileNameAB( mRemoteFileAB->text() ); 622 prof->setRemoteFileNameAB( mRemoteFileAB->text() );
577 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); 623 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text());
578 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); 624 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() );
579 prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); 625 prof->setLocalTempFilePWM( mLocalTempFilePWM->text());
580 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); 626 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() );
581 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 627 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
582 prof->setAskForPreferences( mAskForPreferences->isChecked()); 628 prof->setAskForPreferences( mAskForPreferences->isChecked());
583 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 629 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
584 prof->setWriteBackFile( mWriteBackFile->isChecked()); 630 prof->setWriteBackFile( mWriteBackFile->isChecked());
585 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 631 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
586 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); 632 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() );
587 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); 633 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() );
588 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 634 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
589 prof->setSyncPrefs( syncprefs); 635 prof->setSyncPrefs( syncprefs);
590 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 636 prof->setIsLocalFileSync( mIsLocal->isChecked() );
591 prof->setIsPhoneSync( mIsPhone->isChecked() ); 637 prof->setIsPhoneSync( mIsPhone->isChecked() );
592 prof->setIsPiSync( mIsPi->isChecked() ); 638 prof->setIsPiSync( mIsPi->isChecked() );
593 prof->setIsKapiFile( mIsKapiFileL->isChecked() ); 639 prof->setIsKapiFile( mIsKapiFileL->isChecked() );
594 prof->setWriteBackFuture(mWriteBackFuture->isChecked()); 640 prof->setWriteBackFuture(mWriteBackFuture->isChecked());
595 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); 641 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value());
642 prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value());
596 if ( mWriteContactToSIM ) 643 if ( mWriteContactToSIM )
597 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); 644 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked());
598 prof->setPhoneDevice( mPhoneDevice->text() ); 645 prof->setPhoneDevice( mPhoneDevice->text() );
599 prof->setPhoneConnection( mPhoneConnection->text() ); 646 prof->setPhoneConnection( mPhoneConnection->text() );
600 prof->setPhoneModel( mPhoneModel->text() ); 647 prof->setPhoneModel( mPhoneModel->text() );
601 648
602 } 649 }
603 650
604} 651}
605 652
606void KSyncPrefsDialog::insertProfiles() 653void KSyncPrefsDialog::insertProfiles()
607{ 654{
608 int curItem = mProfileBox->currentItem(); 655 int curItem = mProfileBox->currentItem();
609 mProfileBox->blockSignals( true ); 656 mProfileBox->blockSignals( true );
610 mProfileBox->clear(); 657 mProfileBox->clear();
611 mProfileBox->insertStringList (mSyncProfileNames ); 658 mProfileBox->insertStringList (mSyncProfileNames );
612 int item = mSyncProfileNames.count() -1; 659 int item = mSyncProfileNames.count() -1;
613 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 660 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
614 mProfileBox->setCurrentItem( curItem ); 661 mProfileBox->setCurrentItem( curItem );
615 else if ( item >= 0 ) { 662 else if ( item >= 0 ) {
616 mProfileBox->setCurrentItem( item ); 663 mProfileBox->setCurrentItem( item );
617 } 664 }
618 currentSelection = -1; 665 currentSelection = -1;
619 if ( mSyncProfileNames.count() > 0 ) { 666 if ( mSyncProfileNames.count() > 0 ) {
620 //qDebug(" profileChanged( mProfileBox->currentItem() "); 667 //qDebug(" profileChanged( mProfileBox->currentItem() ");
621 profileChanged( mProfileBox->currentItem() ); 668 profileChanged( mProfileBox->currentItem() );
622 currentSelection = mProfileBox->currentItem(); 669 currentSelection = mProfileBox->currentItem();
623 } 670 }
624 mProfileBox->blockSignals( false ); 671 mProfileBox->blockSignals( false );
625} 672}
626 673
627void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 674void KSyncPrefsDialog::addProfile ( KSyncProfile* temp )
628{ 675{
629 saveProfile(); 676 saveProfile();
630 mSyncProfiles.append( temp ); 677 mSyncProfiles.append( temp );
631 mSyncProfileNames << temp->getName(); 678 mSyncProfileNames << temp->getName();
632 insertProfiles(); 679 insertProfiles();
633 int last = mProfileBox->count() -1; 680 int last = mProfileBox->count() -1;
634 mProfileBox->blockSignals( true ); 681 mProfileBox->blockSignals( true );
635 mProfileBox->setCurrentItem( last ); 682 mProfileBox->setCurrentItem( last );
636 mProfileBox->blockSignals( false ); 683 mProfileBox->blockSignals( false );
637 profileChanged(last); 684 profileChanged(last);
638} 685}
639void KSyncPrefsDialog::newProfile() 686void KSyncPrefsDialog::newProfile()
640{ 687{
641 addProfile ( new KSyncProfile () ); 688 addProfile ( new KSyncProfile () );
642} 689}
643 690
644void KSyncPrefsDialog::cloneProfile() 691void KSyncPrefsDialog::cloneProfile()
645{ 692{
646 if ( currentSelection >= 0 ) 693 if ( currentSelection >= 0 )
647 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 694 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
648 else 695 else
649 newProfile(); 696 newProfile();
650} 697}
651 698
652void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) 699void KSyncPrefsDialog::setLocalMachineName ( const QString& name )
653{ 700{
654 mMyMachineName->setText( name ); 701 mMyMachineName->setText( name );
655 702
656} 703}
657QString KSyncPrefsDialog::getLocalMachineName ( ) 704QString KSyncPrefsDialog::getLocalMachineName ( )
658{ 705{
659 return mMyMachineName->text(); 706 return mMyMachineName->text();
660} 707}
661 708
662QStringList KSyncPrefsDialog::getSyncProfileNames() 709QStringList KSyncPrefsDialog::getSyncProfileNames()
663{ 710{
664 return mSyncProfileNames; 711 return mSyncProfileNames;
665} 712}
666void KSyncPrefsDialog::usrReadConfig() 713void KSyncPrefsDialog::usrReadConfig()
667{ 714{
668 //KConfig *config = KOGlobals::config(); 715 //KConfig *config = KOGlobals::config();
669 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 716 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
670 config.setGroup("General"); 717 config.setGroup("General");
671 mSyncProfileNames =config.readListEntry("SyncProfileNames"); 718 mSyncProfileNames =config.readListEntry("SyncProfileNames");
672 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); 719 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined"));
673 int i; 720 int i;
674 KSyncProfile* temp ; 721 KSyncProfile* temp ;
675 mSyncProfiles.clear(); 722 mSyncProfiles.clear();
676 for ( i = 0; i < mSyncProfileNames.count();++i ) { 723 for ( i = 0; i < mSyncProfileNames.count();++i ) {
677 temp = new KSyncProfile (); 724 temp = new KSyncProfile ();
678 temp->setName( mSyncProfileNames[i] ); 725 temp->setName( mSyncProfileNames[i] );
679 temp->readConfig( &config ); 726 temp->readConfig( &config );
680 mSyncProfiles.append( temp ); 727 mSyncProfiles.append( temp );
681 } 728 }
682 insertProfiles(); 729 insertProfiles();
683 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 730 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
684} 731}
685 732
686 733
687void KSyncPrefsDialog::usrWriteConfig() 734void KSyncPrefsDialog::usrWriteConfig()
688{ 735{
689 saveProfile(); 736 saveProfile();
690 if ( currentSelection >= 0 ) 737 if ( currentSelection >= 0 )
691 profileChanged(currentSelection); 738 profileChanged(currentSelection);
692 //KConfig *config = KOGlobals::config(); 739 //KConfig *config = KOGlobals::config();
693 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 740 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
694 KSyncProfile* prof = mSyncProfiles.first(); 741 KSyncProfile* prof = mSyncProfiles.first();
695 QStringList externalSyncProfileNames; 742 QStringList externalSyncProfileNames;
696 externalSyncProfileNames.append("Sharp_DTM");; 743 externalSyncProfileNames.append("Sharp_DTM");;
697 while ( prof ) { 744 while ( prof ) {
698 prof->writeConfig(&config); 745 prof->writeConfig(&config);
699 if ( prof->getIsPhoneSync( ) ) 746 if ( prof->getIsPhoneSync( ) )
700 externalSyncProfileNames.append(prof->getName( ) ); 747 externalSyncProfileNames.append(prof->getName( ) );
701 prof = mSyncProfiles.next(); 748 prof = mSyncProfiles.next();
702 } 749 }
703 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 750 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
704 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 751 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
705 config.setGroup("General"); 752 config.setGroup("General");
706 config.writeEntry("SyncProfileNames",mSyncProfileNames); 753 config.writeEntry("SyncProfileNames",mSyncProfileNames);
707 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); 754 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames);
708 config.writeEntry("LocalMachineName",mMyMachineName->text()); 755 config.writeEntry("LocalMachineName",mMyMachineName->text());
709 config.sync(); 756 config.sync();
710} 757}
711 758
712void KSyncPrefsDialog::helpDevice() 759void KSyncPrefsDialog::helpDevice()
713{ 760{
714 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); 761 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n");
715#ifdef _WIN32_ 762#ifdef _WIN32_
716 hint += "Leave empty for Irda.\n" 763 hint += "Leave empty for Irda.\n"
717 "com1:\n(first serial port)\n" 764 "com1:\n(first serial port)\n"
718 "usb not supported\n" 765 "usb not supported\n"
719 "???\n(bluetooth device address)\n"; 766 "???\n(bluetooth device address)\n";
720 767
721#else 768#else
722 hint += "/dev/ircomm\n(Irda)\n" 769 hint += "/dev/ircomm\n(Irda)\n"
723 "/dev/ttyS0\n(first serial port)\n" 770 "/dev/ttyS0\n(first serial port)\n"
724 "/dev/ttyUSB0\n(first device usb port)\n" 771 "/dev/ttyUSB0\n(first device usb port)\n"
725 "???\n(bluetooth device address)\n"; 772 "???\n(bluetooth device address)\n";
726#endif 773#endif
727 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 774 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
728} 775}
729void KSyncPrefsDialog::helpModel() 776void KSyncPrefsDialog::helpModel()
730{ 777{
731 QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n"); 778 QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n");
732 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; 779 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection";
733 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 780 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
734 781
735} 782}
736void KSyncPrefsDialog::helpConnection() 783void KSyncPrefsDialog::helpConnection()
737{ 784{
738 QString hint = i18n("Insert kind of connection,e.g.:\n"); 785 QString hint = i18n("Insert kind of connection,e.g.:\n");
739 hint += "irda | Nokia FBUS over infrared\n" 786 hint += "irda | Nokia FBUS over infrared\n"
740 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" 787 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n"
741 "irdaobex | set also model as obex\n" 788 "irdaobex | set also model as obex\n"
742 "fbus | Nokia FBUS2 serial\n"; 789 "fbus | Nokia FBUS2 serial\n";
743 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 790 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
744} 791}
diff --git a/libkdepim/ksyncprefsdialog.h b/libkdepim/ksyncprefsdialog.h
index c601a58..997f524 100644
--- a/libkdepim/ksyncprefsdialog.h
+++ b/libkdepim/ksyncprefsdialog.h
@@ -1,153 +1,155 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef _KSYNCPREFSDIALOG_H 23#ifndef _KSYNCPREFSDIALOG_H
24#define _KSYNCPREFSDIALOG_H 24#define _KSYNCPREFSDIALOG_H
25 25
26 26
27#include <kdialogbase.h> 27#include <kdialogbase.h>
28#include <qptrlist.h> 28#include <qptrlist.h>
29 29
30//#include <libkdepim/kprefsdialog.h> 30//#include <libkdepim/kprefsdialog.h>
31 31
32class KColorButton; 32class KColorButton;
33class QSpinBox;; 33class QSpinBox;;
34class QRadioButton; 34class QRadioButton;
35class QCheckBox; 35class QCheckBox;
36class QSlider; 36class QSlider;
37class KURLRequester; 37class KURLRequester;
38class QComboBox; 38class QComboBox;
39class QButtonGroup; 39class QButtonGroup;
40class QLineEdit; 40class QLineEdit;
41class QVBox; 41class QVBox;
42class QStringList; 42class QStringList;
43class KSyncProfile; 43class KSyncProfile;
44 44
45/** Dialog to change the korganizer configuration. 45/** Dialog to change the korganizer configuration.
46 */ 46 */
47class KSyncPrefsDialog : public KDialog 47class KSyncPrefsDialog : public KDialog
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 /** Initialize dialog and pages */ 51 /** Initialize dialog and pages */
52 KSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false); 52 KSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false);
53 ~KSyncPrefsDialog(); 53 ~KSyncPrefsDialog();
54 void usrReadConfig(); 54 void usrReadConfig();
55 void setLocalMachineName ( const QString& name ); 55 void setLocalMachineName ( const QString& name );
56 QString getLocalMachineName ( ); 56 QString getLocalMachineName ( );
57 57
58 QStringList getSyncProfileNames(); 58 QStringList getSyncProfileNames();
59 59
60 public slots: 60 public slots:
61 protected slots: 61 protected slots:
62 void accept(); 62 void accept();
63 void deleteProfile(); 63 void deleteProfile();
64 void newProfile(); 64 void newProfile();
65 void cloneProfile(); 65 void cloneProfile();
66 void kindChanged(bool); 66 void kindChanged(bool);
67 void fillSSH(); 67 void fillSSH();
68 void fillFTP(); 68 void fillFTP();
69 void textChanged( const QString & ); 69 void textChanged( const QString & );
70 void profileChanged( int ); 70 void profileChanged( int );
71 void chooseFile(); 71 void chooseFile();
72 void chooseFileAB(); 72 void chooseFileAB();
73 void chooseFilePWM(); 73 void chooseFilePWM();
74 void slotOK(); 74 void slotOK();
75 void helpDevice(); 75 void helpDevice();
76 void helpModel(); 76 void helpModel();
77 void helpConnection(); 77 void helpConnection();
78 78
79 protected: 79 protected:
80 void usrWriteConfig(); 80 void usrWriteConfig();
81
82 void setupSyncAlgTab(); 81 void setupSyncAlgTab();
83 82 void readFilter();
84 private: 83 private:
85 int currentSelection; 84 int currentSelection;
86 QPtrList<KSyncProfile> mSyncProfiles; 85 QPtrList<KSyncProfile> mSyncProfiles;
87 QStringList mSyncProfileNames; 86 QStringList mSyncProfileNames;
87 QStringList mFilterKapi;
88 QStringList mFilterKopi;
88 QLineEdit * mMyMachineName; 89 QLineEdit * mMyMachineName;
89 QComboBox * mProfileBox; 90 QComboBox * mProfileBox;
90 QRadioButton* mIsLocal; 91 QRadioButton* mIsLocal;
91 QRadioButton* mIsNotLocal; 92 QRadioButton* mIsNotLocal;
92 QRadioButton* mIsPhone; 93 QRadioButton* mIsPhone;
93 QRadioButton* mIsPi; 94 QRadioButton* mIsPi;
94 QCheckBox* mIncludeInRing; 95 QCheckBox* mIncludeInRing;
95 QCheckBox* mIncludeInRingAB; 96 QCheckBox* mIncludeInRingAB;
96 QCheckBox* mIncludeInRingPWM; 97 QCheckBox* mIncludeInRingPWM;
97 void addProfile ( KSyncProfile* ); 98 void addProfile ( KSyncProfile* );
98 void insertProfiles(); 99 void insertProfiles();
99 void saveProfile(); 100 void saveProfile();
100 QButtonGroup* proGr; 101 QButtonGroup* proGr;
101 102
102 QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both; 103 QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both;
103 104
104 105
105 QLineEdit * mRemotePostcommand; 106 QLineEdit * mRemotePostcommand;
106 QLineEdit * mRemotePrecommand; 107 QLineEdit * mRemotePrecommand;
107 QLineEdit * mRemoteFile; 108 QLineEdit * mRemoteFile;
108 QLineEdit * mLocalTempFile; 109 QLineEdit * mLocalTempFile;
109 110
110 QLineEdit * mRemotePostcommandAB; 111 QLineEdit * mRemotePostcommandAB;
111 QLineEdit * mRemotePrecommandAB; 112 QLineEdit * mRemotePrecommandAB;
112 QLineEdit * mRemoteFileAB; 113 QLineEdit * mRemoteFileAB;
113 QLineEdit * mLocalTempFileAB; 114 QLineEdit * mLocalTempFileAB;
114 115
115 QLineEdit * mRemotePostcommandPWM; 116 QLineEdit * mRemotePostcommandPWM;
116 QLineEdit * mRemotePrecommandPWM; 117 QLineEdit * mRemotePrecommandPWM;
117 QLineEdit * mRemoteFilePWM; 118 QLineEdit * mRemoteFilePWM;
118 QLineEdit * mLocalTempFilePWM; 119 QLineEdit * mLocalTempFilePWM;
119 120
120 121
121 QLineEdit * mRemotePw; 122 QLineEdit * mRemotePw;
122 QLineEdit * mRemoteIP; 123 QLineEdit * mRemoteIP;
123 QLineEdit * mRemotePort; 124 QLineEdit * mRemotePort;
124 125
125 QLineEdit * mRemotePwAB; 126 QLineEdit * mRemotePwAB;
126 QLineEdit * mRemoteIPAB; 127 QLineEdit * mRemoteIPAB;
127 QLineEdit * mRemotePortAB; 128 QLineEdit * mRemotePortAB;
128 129
129 QLineEdit * mRemotePwPWM; 130 QLineEdit * mRemotePwPWM;
130 QLineEdit * mRemoteIPPWM; 131 QLineEdit * mRemoteIPPWM;
131 QLineEdit * mRemotePortPWM; 132 QLineEdit * mRemotePortPWM;
132 133
133 QLineEdit * mPhoneDevice; 134 QLineEdit * mPhoneDevice;
134 QLineEdit * mPhoneConnection; 135 QLineEdit * mPhoneConnection;
135 QLineEdit * mPhoneModel; 136 QLineEdit * mPhoneModel;
136 137
137 QWidget* mSetupSyncAlgTab; 138 QWidget* mSetupSyncAlgTab;
138 QVBox* localFileWidget; 139 QVBox* localFileWidget;
139 QVBox* remoteFileWidget; 140 QVBox* remoteFileWidget;
140 QVBox* phoneWidget; 141 QVBox* phoneWidget;
141 QVBox* piWidget; 142 QVBox* piWidget;
142 QCheckBox* mWriteBackFile; 143 QCheckBox* mWriteBackFile;
143 QCheckBox* mWriteBackFuture; 144 QCheckBox* mWriteBackFuture;
144 QSpinBox* mWriteBackFutureWeeks; 145 QSpinBox* mWriteBackFutureWeeks;
146 QSpinBox* mWriteBackPastWeeks;
145 QCheckBox* mWriteBackExisting; 147 QCheckBox* mWriteBackExisting;
146 QCheckBox* mAskForPreferences; 148 QCheckBox* mAskForPreferences;
147 QCheckBox* mShowSummaryAfterSync; 149 QCheckBox* mShowSummaryAfterSync;
148 QCheckBox* mWriteContactToSIM; 150 QCheckBox* mWriteContactToSIM;
149 QCheckBox* mIsKapiFileL; 151 QCheckBox* mIsKapiFileL;
150 QCheckBox* mIsKapiFileR; 152 QCheckBox* mIsKapiFileR;
151}; 153};
152 154
153#endif 155#endif
diff --git a/libkdepim/ksyncprofile.cpp b/libkdepim/ksyncprofile.cpp
index 029b70b..9f404cb 100644
--- a/libkdepim/ksyncprofile.cpp
+++ b/libkdepim/ksyncprofile.cpp
@@ -1,252 +1,256 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include <qcolor.h> 23#include <qcolor.h>
24 24
25#include <kconfig.h> 25#include <kconfig.h>
26#include <kstandarddirs.h> 26#include <kstandarddirs.h>
27#include <kglobal.h> 27#include <kglobal.h>
28#include <kdebug.h> 28#include <kdebug.h>
29 29
30#include "ksyncprofile.h" 30#include "ksyncprofile.h"
31 31
32 32
33KSyncProfile::KSyncProfile(): QObject () 33KSyncProfile::KSyncProfile(): QObject ()
34{ 34{
35 setDefault(); 35 setDefault();
36} 36}
37KSyncProfile::~KSyncProfile() 37KSyncProfile::~KSyncProfile()
38{ 38{
39 39
40} 40}
41 41
42 42
43KSyncProfile* KSyncProfile::clone() 43KSyncProfile* KSyncProfile::clone()
44{ 44{
45 KSyncProfile* myClone = new KSyncProfile(); 45 KSyncProfile* myClone = new KSyncProfile();
46 myClone->setRemotePw(mRemotePw); 46 myClone->setRemotePw(mRemotePw);
47 myClone->setRemoteIP(mRemoteIP); 47 myClone->setRemoteIP(mRemoteIP);
48 myClone->setRemotePort(mRemotePort); 48 myClone->setRemotePort(mRemotePort);
49 myClone->setRemotePwAB(mRemotePwAB); 49 myClone->setRemotePwAB(mRemotePwAB);
50 myClone->setRemoteIPAB(mRemoteIPAB); 50 myClone->setRemoteIPAB(mRemoteIPAB);
51 myClone->setRemotePortAB(mRemotePortAB); 51 myClone->setRemotePortAB(mRemotePortAB);
52 myClone->setRemotePwPWM(mRemotePwPWM); 52 myClone->setRemotePwPWM(mRemotePwPWM);
53 myClone->setRemoteIPPWM(mRemoteIPPWM); 53 myClone->setRemoteIPPWM(mRemoteIPPWM);
54 myClone->setRemotePortPWM (mRemotePortPWM); 54 myClone->setRemotePortPWM (mRemotePortPWM);
55 myClone->setPreSyncCommand( mPreSyncCommand ); 55 myClone->setPreSyncCommand( mPreSyncCommand );
56 myClone->setPostSyncCommand( mPostSyncCommand ); 56 myClone->setPostSyncCommand( mPostSyncCommand );
57 myClone->setLocalTempFile( mLocalTempFile); 57 myClone->setLocalTempFile( mLocalTempFile);
58 myClone->setRemoteFileName( mRemoteFileName ); 58 myClone->setRemoteFileName( mRemoteFileName );
59 myClone->setPreSyncCommandAB( mPreSyncCommandAB ); 59 myClone->setPreSyncCommandAB( mPreSyncCommandAB );
60 myClone->setPostSyncCommandAB( mPostSyncCommandAB ); 60 myClone->setPostSyncCommandAB( mPostSyncCommandAB );
61 myClone->setLocalTempFileAB( mLocalTempFileAB); 61 myClone->setLocalTempFileAB( mLocalTempFileAB);
62 myClone->setRemoteFileNameAB( mRemoteFileNameAB ); 62 myClone->setRemoteFileNameAB( mRemoteFileNameAB );
63 myClone->setPreSyncCommandPWM( mPreSyncCommandPWM ); 63 myClone->setPreSyncCommandPWM( mPreSyncCommandPWM );
64 myClone->setPostSyncCommandPWM( mPostSyncCommandPWM ); 64 myClone->setPostSyncCommandPWM( mPostSyncCommandPWM );
65 myClone->setLocalTempFilePWM( mLocalTempFilePWM); 65 myClone->setLocalTempFilePWM( mLocalTempFilePWM);
66 myClone->setRemoteFileNamePWM( mRemoteFileNamePWM ); 66 myClone->setRemoteFileNamePWM( mRemoteFileNamePWM );
67 myClone->setShowSummaryAfterSync( mShowSummaryAfterSync ); 67 myClone->setShowSummaryAfterSync( mShowSummaryAfterSync );
68 myClone->setAskForPreferences( mAskForPreferences); 68 myClone->setAskForPreferences( mAskForPreferences);
69 myClone->setWriteBackExisting(mWriteBackExisting ); 69 myClone->setWriteBackExisting(mWriteBackExisting );
70 myClone->setWriteBackFile( mWriteBackFile); 70 myClone->setWriteBackFile( mWriteBackFile);
71 myClone->setWriteBackFuture( mWriteBackFuture ); 71 myClone->setWriteBackFuture( mWriteBackFuture );
72 myClone->setWriteBackFutureWeeks( mWriteBackFutureWeeks ); 72 myClone->setWriteBackFutureWeeks( mWriteBackFutureWeeks );
73 myClone->setWriteBackPastWeeks( mWriteBackPastWeeks );
73 myClone->setIncludeInRingSync( mIncludeInRingSync ); 74 myClone->setIncludeInRingSync( mIncludeInRingSync );
74 myClone->setIncludeInRingSyncAB( mIncludeInRingSyncAB ); 75 myClone->setIncludeInRingSyncAB( mIncludeInRingSyncAB );
75 myClone->setIncludeInRingSyncPWM( mIncludeInRingSyncPWM ); 76 myClone->setIncludeInRingSyncPWM( mIncludeInRingSyncPWM );
76 myClone->setSyncPrefs( mSyncPrefs); 77 myClone->setSyncPrefs( mSyncPrefs);
77 myClone->setIsLocalFileSync( mIsLocalFileSync ); 78 myClone->setIsLocalFileSync( mIsLocalFileSync );
78 myClone->setIsPhoneSync( mIsPhoneSync ); 79 myClone->setIsPhoneSync( mIsPhoneSync );
79 myClone->setIsKapiFile( mIsKapiFile ); 80 myClone->setIsKapiFile( mIsKapiFile );
80 myClone->setIsPiSync( mIsPiSync ); 81 myClone->setIsPiSync( mIsPiSync );
81 myClone->setWriteContactToSIM( mWriteContactToSIM ); 82 myClone->setWriteContactToSIM( mWriteContactToSIM );
82 myClone->setName( "noName" ); 83 myClone->setName( "noName" );
83 //myClone->setIdentifier( "noID" ); 84 //myClone->setIdentifier( "noID" );
84 return myClone; 85 return myClone;
85} 86}
86 87
87 88
88void KSyncProfile::setDefault() 89void KSyncProfile::setDefault()
89{ 90{
90 mPreSyncCommand = i18n("command for downloading remote file to local device"); 91 mPreSyncCommand = i18n("command for downloading remote file to local device");
91 mPostSyncCommand = i18n("command for uploading local temp file to remote device"); 92 mPostSyncCommand = i18n("command for uploading local temp file to remote device");
92 mLocalTempFile = "/tmp/mycalendar.ics"; 93 mLocalTempFile = "/tmp/mycalendar.ics";
93 mRemoteFileName = "/home/polo/kdepim/apps/korganizer/localfile.ics"; 94 mRemoteFileName = "/home/polo/kdepim/apps/korganizer/localfile.ics";
94 mPreSyncCommandAB = i18n("command for downloading remote file to local device"); 95 mPreSyncCommandAB = i18n("command for downloading remote file to local device");
95 mPostSyncCommandAB = i18n("command for uploading local temp file to remote device"); 96 mPostSyncCommandAB = i18n("command for uploading local temp file to remote device");
96 mLocalTempFileAB = "/tmp/std.vcf"; 97 mLocalTempFileAB = "/tmp/std.vcf";
97 mRemoteFileNameAB = "/home/polo/kdepim/apps/kabc/localfile.vcf"; 98 mRemoteFileNameAB = "/home/polo/kdepim/apps/kabc/localfile.vcf";
98 mPreSyncCommandPWM = i18n("command for downloading remote file to local device"); 99 mPreSyncCommandPWM = i18n("command for downloading remote file to local device");
99 mPostSyncCommandPWM = i18n("command for uploading local temp file to remote device"); 100 mPostSyncCommandPWM = i18n("command for uploading local temp file to remote device");
100 mLocalTempFilePWM = "/tmp/passwords.pwm"; 101 mLocalTempFilePWM = "/tmp/passwords.pwm";
101 mRemoteFileNamePWM = "/home/polo/kdepim/apps/pwmanager/localfile.pwm"; 102 mRemoteFileNamePWM = "/home/polo/kdepim/apps/pwmanager/localfile.pwm";
102 103
103 mRemotePw = "abc"; 104 mRemotePw = "abc";
104 mRemoteIP = "192.168.0.99"; 105 mRemoteIP = "192.168.0.99";
105 mRemotePort = "9197"; 106 mRemotePort = "9197";
106 107
107 mRemotePwAB = "abc"; 108 mRemotePwAB = "abc";
108 mRemoteIPAB = "192.168.0.99"; 109 mRemoteIPAB = "192.168.0.99";
109 mRemotePortAB = "9198"; 110 mRemotePortAB = "9198";
110 111
111 mRemotePwPWM = "abc"; 112 mRemotePwPWM = "abc";
112 mRemoteIPPWM = "192.168.0.99"; 113 mRemoteIPPWM = "192.168.0.99";
113 mRemotePortPWM = "9199"; 114 mRemotePortPWM = "9199";
114 115
115 mShowSummaryAfterSync = true; 116 mShowSummaryAfterSync = true;
116 mAskForPreferences = true; 117 mAskForPreferences = true;
117 mWriteBackExisting = false; 118 mWriteBackExisting = false;
118 mWriteBackFuture = false; 119 mWriteBackFuture = false;
119 mWriteBackFutureWeeks = 12; 120 mWriteBackFutureWeeks = 12;
121 mWriteBackPastWeeks = 2;
120 mWriteBackFile = true; 122 mWriteBackFile = true;
121 mIncludeInRingSync = false; 123 mIncludeInRingSync = false;
122 mIncludeInRingSyncAB = false; 124 mIncludeInRingSyncAB = false;
123 mIncludeInRingSyncPWM = false; 125 mIncludeInRingSyncPWM = false;
124 mSyncPrefs = SYNC_PREF_ASK; 126 mSyncPrefs = SYNC_PREF_ASK;
125 mIsLocalFileSync = true; 127 mIsLocalFileSync = true;
126 mName = "noName"; 128 mName = "noName";
127 mIsPhoneSync = false; 129 mIsPhoneSync = false;
128 mIsPiSync = false; 130 mIsPiSync = false;
129 mIsKapiFile = false; 131 mIsKapiFile = false;
130 mWriteContactToSIM = false; 132 mWriteContactToSIM = false;
131 mPhoneDevice = "/dev/ircomm"; 133 mPhoneDevice = "/dev/ircomm";
132 mPhoneConnection = "irda"; 134 mPhoneConnection = "irda";
133 mPhoneModel = "6310i"; 135 mPhoneModel = "6310i";
134} 136}
135void KSyncProfile::readConfig(KConfig *config ) 137void KSyncProfile::readConfig(KConfig *config )
136{ 138{
137 if (config) 139 if (config)
138 { 140 {
139 141
140 config->setGroup( mName ); 142 config->setGroup( mName );
141 143
142 mName = config->readEntry( "Name", mName ); 144 mName = config->readEntry( "Name", mName );
143 145
144 mRemotePw = config->readEntry( "RemotePw",mRemotePw ); 146 mRemotePw = config->readEntry( "RemotePw",mRemotePw );
145 mRemoteIP = config->readEntry( "RemoteIP",mRemoteIP ); 147 mRemoteIP = config->readEntry( "RemoteIP",mRemoteIP );
146 mRemotePort = config->readEntry( "RemotePort", mRemotePort ); 148 mRemotePort = config->readEntry( "RemotePort", mRemotePort );
147 mRemotePwAB = config->readEntry( "RemotePwAB", mRemotePwAB ); 149 mRemotePwAB = config->readEntry( "RemotePwAB", mRemotePwAB );
148 mRemoteIPAB = config->readEntry( "RemoteIPAB", mRemoteIPAB ); 150 mRemoteIPAB = config->readEntry( "RemoteIPAB", mRemoteIPAB );
149 mRemotePortAB = config->readEntry( "RemotePortAB", mRemotePortAB ); 151 mRemotePortAB = config->readEntry( "RemotePortAB", mRemotePortAB );
150 mRemotePwPWM = config->readEntry( "RemotePwPWM", mRemotePwPWM ); 152 mRemotePwPWM = config->readEntry( "RemotePwPWM", mRemotePwPWM );
151 mRemoteIPPWM = config->readEntry( "RemoteIPPWM", mRemoteIPPWM ); 153 mRemoteIPPWM = config->readEntry( "RemoteIPPWM", mRemoteIPPWM );
152 mRemotePortPWM = config->readEntry( "RemotePortPWM", mRemotePortPWM ); 154 mRemotePortPWM = config->readEntry( "RemotePortPWM", mRemotePortPWM );
153 155
154 mPreSyncCommand = config->readEntry( "PreSyncCommand",mPreSyncCommand ); 156 mPreSyncCommand = config->readEntry( "PreSyncCommand",mPreSyncCommand );
155 mPostSyncCommand = config->readEntry( "PostSyncCommand", mPostSyncCommand ); 157 mPostSyncCommand = config->readEntry( "PostSyncCommand", mPostSyncCommand );
156 mLocalTempFile = config->readEntry( "LocalTempFile", mLocalTempFile ); 158 mLocalTempFile = config->readEntry( "LocalTempFile", mLocalTempFile );
157 mRemoteFileName = config->readEntry( "RemoteFileName", mRemoteFileName ); 159 mRemoteFileName = config->readEntry( "RemoteFileName", mRemoteFileName );
158 160
159 mPreSyncCommandAB = config->readEntry( "PreSyncCommandAB",mPreSyncCommandAB ); 161 mPreSyncCommandAB = config->readEntry( "PreSyncCommandAB",mPreSyncCommandAB );
160 mPostSyncCommandAB = config->readEntry( "PostSyncCommandAB", mPostSyncCommandAB ); 162 mPostSyncCommandAB = config->readEntry( "PostSyncCommandAB", mPostSyncCommandAB );
161 mLocalTempFileAB = config->readEntry( "LocalTempFileAB", mLocalTempFileAB ); 163 mLocalTempFileAB = config->readEntry( "LocalTempFileAB", mLocalTempFileAB );
162 mRemoteFileNameAB = config->readEntry( "RemoteFileNameAB", mRemoteFileNameAB ); 164 mRemoteFileNameAB = config->readEntry( "RemoteFileNameAB", mRemoteFileNameAB );
163 165
164 mPreSyncCommandPWM = config->readEntry( "PreSyncCommandPWM",mPreSyncCommandPWM ); 166 mPreSyncCommandPWM = config->readEntry( "PreSyncCommandPWM",mPreSyncCommandPWM );
165 mPostSyncCommandPWM = config->readEntry( "PostSyncCommandPWM", mPostSyncCommandPWM ); 167 mPostSyncCommandPWM = config->readEntry( "PostSyncCommandPWM", mPostSyncCommandPWM );
166 mLocalTempFilePWM = config->readEntry( "LocalTempFilePWM", mLocalTempFilePWM ); 168 mLocalTempFilePWM = config->readEntry( "LocalTempFilePWM", mLocalTempFilePWM );
167 mRemoteFileNamePWM = config->readEntry( "RemoteFileNamePWM", mRemoteFileNamePWM ); 169 mRemoteFileNamePWM = config->readEntry( "RemoteFileNamePWM", mRemoteFileNamePWM );
168 170
169 mPhoneDevice = config->readEntry( "PhoneDevice", mPhoneDevice ); 171 mPhoneDevice = config->readEntry( "PhoneDevice", mPhoneDevice );
170 mPhoneConnection = config->readEntry( "PhoneConnection", mPhoneConnection ); 172 mPhoneConnection = config->readEntry( "PhoneConnection", mPhoneConnection );
171 mPhoneModel = config->readEntry( "PhoneModel", mPhoneModel ); 173 mPhoneModel = config->readEntry( "PhoneModel", mPhoneModel );
172 174
173 mIncludeInRingSync = config->readBoolEntry( "IncludeInRingSync",mIncludeInRingSync ); 175 mIncludeInRingSync = config->readBoolEntry( "IncludeInRingSync",mIncludeInRingSync );
174 mIncludeInRingSyncAB = config->readBoolEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB ); 176 mIncludeInRingSyncAB = config->readBoolEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB );
175 mIncludeInRingSyncPWM = config->readBoolEntry( "IncludeInRingSyncPWM",mIncludeInRingSyncPWM ); 177 mIncludeInRingSyncPWM = config->readBoolEntry( "IncludeInRingSyncPWM",mIncludeInRingSyncPWM );
176 mShowSummaryAfterSync = config->readBoolEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync ); 178 mShowSummaryAfterSync = config->readBoolEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync );
177 mAskForPreferences = config->readBoolEntry( "AskForPreferences",mAskForPreferences ); 179 mAskForPreferences = config->readBoolEntry( "AskForPreferences",mAskForPreferences );
178 mWriteBackExisting = config->readBoolEntry( "WriteBackExisting",mWriteBackExisting ); 180 mWriteBackExisting = config->readBoolEntry( "WriteBackExisting",mWriteBackExisting );
179 mWriteBackFuture = config->readBoolEntry( "WriteBackFuture",mWriteBackFuture ); 181 mWriteBackFuture = config->readBoolEntry( "WriteBackFuture",mWriteBackFuture );
180 mWriteBackFile = config->readBoolEntry( "WriteBackFile",mWriteBackFile ); 182 mWriteBackFile = config->readBoolEntry( "WriteBackFile",mWriteBackFile );
181 mWriteContactToSIM = config->readBoolEntry( "WriteContactToSIM",mWriteContactToSIM ); 183 mWriteContactToSIM = config->readBoolEntry( "WriteContactToSIM",mWriteContactToSIM );
182 mSyncPrefs = config->readNumEntry( "SyncPrefs", mSyncPrefs ); 184 mSyncPrefs = config->readNumEntry( "SyncPrefs", mSyncPrefs );
183 mWriteBackFutureWeeks = config->readNumEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks ); 185 mWriteBackFutureWeeks = config->readNumEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks );
186 mWriteBackPastWeeks = config->readNumEntry( "WriteBackPastWeeks", mWriteBackPastWeeks );
184 mIsLocalFileSync= config->readBoolEntry( "IsLocalFileSync", mIsLocalFileSync ); 187 mIsLocalFileSync= config->readBoolEntry( "IsLocalFileSync", mIsLocalFileSync );
185 mIsPhoneSync= config->readBoolEntry( "IsPhoneSync", mIsPhoneSync ); 188 mIsPhoneSync= config->readBoolEntry( "IsPhoneSync", mIsPhoneSync );
186 mIsPiSync= config->readBoolEntry( "IsPiSync", mIsPiSync ); 189 mIsPiSync= config->readBoolEntry( "IsPiSync", mIsPiSync );
187 mIsKapiFile = config->readBoolEntry( "IsKapiFile", mIsKapiFile ); 190 mIsKapiFile = config->readBoolEntry( "IsKapiFile", mIsKapiFile );
188 } 191 }
189 else 192 else
190 { 193 {
191 setDefault(); 194 setDefault();
192 } 195 }
193} 196}
194 197
195void KSyncProfile::deleteConfig(KConfig *config ) 198void KSyncProfile::deleteConfig(KConfig *config )
196{ 199{
197 config->deleteGroup( mName ); 200 config->deleteGroup( mName );
198} 201}
199 202
200void KSyncProfile::writeConfig( KConfig * config ) 203void KSyncProfile::writeConfig( KConfig * config )
201{ 204{
202 config->setGroup(mName); 205 config->setGroup(mName);
203 206
204 config->writeEntry( "RemotePw", mRemotePw); 207 config->writeEntry( "RemotePw", mRemotePw);
205 config->writeEntry( "RemoteIP", mRemoteIP); 208 config->writeEntry( "RemoteIP", mRemoteIP);
206 config->writeEntry( "RemotePort", mRemotePort); 209 config->writeEntry( "RemotePort", mRemotePort);
207 210
208 config->writeEntry( "RemotePwAB", mRemotePwAB); 211 config->writeEntry( "RemotePwAB", mRemotePwAB);
209 config->writeEntry( "RemoteIPAB", mRemoteIPAB); 212 config->writeEntry( "RemoteIPAB", mRemoteIPAB);
210 config->writeEntry( "RemotePortAB", mRemotePortAB); 213 config->writeEntry( "RemotePortAB", mRemotePortAB);
211 214
212 config->writeEntry( "RemotePwPWM", mRemotePwPWM); 215 config->writeEntry( "RemotePwPWM", mRemotePwPWM);
213 config->writeEntry( "RemoteIPPWM", mRemoteIPPWM); 216 config->writeEntry( "RemoteIPPWM", mRemoteIPPWM);
214 config->writeEntry( "RemotePortPWM", mRemotePortPWM); 217 config->writeEntry( "RemotePortPWM", mRemotePortPWM);
215 218
216 config->writeEntry( "Name", mName ); 219 config->writeEntry( "Name", mName );
217 config->writeEntry( "PreSyncCommand",mPreSyncCommand ); 220 config->writeEntry( "PreSyncCommand",mPreSyncCommand );
218 config->writeEntry( "PostSyncCommand", mPostSyncCommand ); 221 config->writeEntry( "PostSyncCommand", mPostSyncCommand );
219 config->writeEntry( "LocalTempFile", mLocalTempFile ); 222 config->writeEntry( "LocalTempFile", mLocalTempFile );
220 config->writeEntry( "RemoteFileName", mRemoteFileName ); 223 config->writeEntry( "RemoteFileName", mRemoteFileName );
221 224
222 config->writeEntry( "PreSyncCommandAB",mPreSyncCommandAB ); 225 config->writeEntry( "PreSyncCommandAB",mPreSyncCommandAB );
223 config->writeEntry( "PostSyncCommandAB", mPostSyncCommandAB ); 226 config->writeEntry( "PostSyncCommandAB", mPostSyncCommandAB );
224 config->writeEntry( "LocalTempFileAB", mLocalTempFileAB ); 227 config->writeEntry( "LocalTempFileAB", mLocalTempFileAB );
225 config->writeEntry( "RemoteFileNameAB", mRemoteFileNameAB ); 228 config->writeEntry( "RemoteFileNameAB", mRemoteFileNameAB );
226 229
227 config->writeEntry( "PreSyncCommandPWM",mPreSyncCommandPWM ); 230 config->writeEntry( "PreSyncCommandPWM",mPreSyncCommandPWM );
228 config->writeEntry( "PostSyncCommandPWM", mPostSyncCommandPWM ); 231 config->writeEntry( "PostSyncCommandPWM", mPostSyncCommandPWM );
229 config->writeEntry( "LocalTempFilePWM", mLocalTempFilePWM ); 232 config->writeEntry( "LocalTempFilePWM", mLocalTempFilePWM );
230 config->writeEntry( "RemoteFileNamePWM", mRemoteFileNamePWM ); 233 config->writeEntry( "RemoteFileNamePWM", mRemoteFileNamePWM );
231 234
232 config->writeEntry( "PhoneDevice", mPhoneDevice ); 235 config->writeEntry( "PhoneDevice", mPhoneDevice );
233 config->writeEntry( "PhoneConnection", mPhoneConnection ); 236 config->writeEntry( "PhoneConnection", mPhoneConnection );
234 config->writeEntry( "PhoneModel", mPhoneModel ); 237 config->writeEntry( "PhoneModel", mPhoneModel );
235 238
236 config->writeEntry( "IncludeInRingSync",mIncludeInRingSync ); 239 config->writeEntry( "IncludeInRingSync",mIncludeInRingSync );
237 config->writeEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB ); 240 config->writeEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB );
238 config->writeEntry( "IncludeInRingSyncPWM",mIncludeInRingSyncPWM ); 241 config->writeEntry( "IncludeInRingSyncPWM",mIncludeInRingSyncPWM );
239 config->writeEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync ); 242 config->writeEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync );
240 config->writeEntry( "AskForPreferences",mAskForPreferences ); 243 config->writeEntry( "AskForPreferences",mAskForPreferences );
241 config->writeEntry( "WriteBackExisting",mWriteBackExisting ); 244 config->writeEntry( "WriteBackExisting",mWriteBackExisting );
242 config->writeEntry( "WriteBackFuture",mWriteBackFuture ); 245 config->writeEntry( "WriteBackFuture",mWriteBackFuture );
243 config->writeEntry( "WriteBackFile",mWriteBackFile ); 246 config->writeEntry( "WriteBackFile",mWriteBackFile );
244 config->writeEntry( "WriteContactToSIM",mWriteContactToSIM ); 247 config->writeEntry( "WriteContactToSIM",mWriteContactToSIM );
245 config->writeEntry( "SyncPrefs", mSyncPrefs ); 248 config->writeEntry( "SyncPrefs", mSyncPrefs );
246 config->writeEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks); 249 config->writeEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks);
250 config->writeEntry( "WriteBackPastWeeks", mWriteBackPastWeeks);
247 config->writeEntry( "IsLocalFileSync", mIsLocalFileSync ); 251 config->writeEntry( "IsLocalFileSync", mIsLocalFileSync );
248 config->writeEntry( "IsPhoneSync", mIsPhoneSync ); 252 config->writeEntry( "IsPhoneSync", mIsPhoneSync );
249 config->writeEntry( "IsPiSync", mIsPiSync ); 253 config->writeEntry( "IsPiSync", mIsPiSync );
250 config->writeEntry( "IsKapiFile", mIsKapiFile ); 254 config->writeEntry( "IsKapiFile", mIsKapiFile );
251} 255}
252 256
diff --git a/libkdepim/ksyncprofile.h b/libkdepim/ksyncprofile.h
index 0a59111..e970b50 100644
--- a/libkdepim/ksyncprofile.h
+++ b/libkdepim/ksyncprofile.h
@@ -1,188 +1,191 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef _KSYNCPROFILE_H 20#ifndef _KSYNCPROFILE_H
21#define _KSYNCPROFILE_H 21#define _KSYNCPROFILE_H
22 22
23#include <qptrlist.h> 23#include <qptrlist.h>
24#include <qcolor.h> 24#include <qcolor.h>
25#include <qfont.h> 25#include <qfont.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27#include <qobject.h> 27#include <qobject.h>
28#include <qstring.h> 28#include <qstring.h>
29 29
30#include <libkcal/syncdefines.h> 30#include <libkcal/syncdefines.h>
31 31
32 32
33 33
34class KConfig; 34class KConfig;
35 35
36 36
37class KSyncProfile : public QObject { 37class KSyncProfile : public QObject {
38 public: 38 public:
39 KSyncProfile(); 39 KSyncProfile();
40 ~KSyncProfile() ; 40 ~KSyncProfile() ;
41 41
42 KSyncProfile* clone(); 42 KSyncProfile* clone();
43 void setDefault(); 43 void setDefault();
44 void readConfig(KConfig *); 44 void readConfig(KConfig *);
45 void writeConfig(KConfig *); 45 void writeConfig(KConfig *);
46 void deleteConfig(KConfig *); 46 void deleteConfig(KConfig *);
47 47
48 void setRemotePw( const QString& n ) {mRemotePw = n;} 48 void setRemotePw( const QString& n ) {mRemotePw = n;}
49 QString getRemotePw( ) { return mRemotePw; } 49 QString getRemotePw( ) { return mRemotePw; }
50 void setRemotePwAB( const QString& n ) {mRemotePwAB = n;} 50 void setRemotePwAB( const QString& n ) {mRemotePwAB = n;}
51 QString getRemotePwAB( ) { return mRemotePwAB; } 51 QString getRemotePwAB( ) { return mRemotePwAB; }
52 void setRemotePwPWM( const QString& n ) {mRemotePwPWM = n;} 52 void setRemotePwPWM( const QString& n ) {mRemotePwPWM = n;}
53 QString getRemotePwPWM( ) { return mRemotePwPWM; } 53 QString getRemotePwPWM( ) { return mRemotePwPWM; }
54 54
55 void setRemoteIP( const QString& n ) {mRemoteIP = n;} 55 void setRemoteIP( const QString& n ) {mRemoteIP = n;}
56 QString getRemoteIP( ) { return mRemoteIP; } 56 QString getRemoteIP( ) { return mRemoteIP; }
57 void setRemoteIPAB( const QString& n ) {mRemoteIPAB = n;} 57 void setRemoteIPAB( const QString& n ) {mRemoteIPAB = n;}
58 QString getRemoteIPAB( ) { return mRemoteIPAB; } 58 QString getRemoteIPAB( ) { return mRemoteIPAB; }
59 void setRemoteIPPWM( const QString& n ) {mRemoteIPPWM = n;} 59 void setRemoteIPPWM( const QString& n ) {mRemoteIPPWM = n;}
60 QString getRemoteIPPWM( ) { return mRemoteIPPWM; } 60 QString getRemoteIPPWM( ) { return mRemoteIPPWM; }
61 61
62 void setRemotePort( const QString& n ) {mRemotePort = n;} 62 void setRemotePort( const QString& n ) {mRemotePort = n;}
63 QString getRemotePort( ) { return mRemotePort; } 63 QString getRemotePort( ) { return mRemotePort; }
64 void setRemotePortAB( const QString& n ) {mRemotePortAB = n;} 64 void setRemotePortAB( const QString& n ) {mRemotePortAB = n;}
65 QString getRemotePortAB( ) { return mRemotePortAB; } 65 QString getRemotePortAB( ) { return mRemotePortAB; }
66 void setRemotePortPWM( const QString& n ) {mRemotePortPWM = n;} 66 void setRemotePortPWM( const QString& n ) {mRemotePortPWM = n;}
67 QString getRemotePortPWM( ) { return mRemotePortPWM; } 67 QString getRemotePortPWM( ) { return mRemotePortPWM; }
68 68
69 void setPreSyncCommand( const QString& n ) {mPreSyncCommand = n;} 69 void setPreSyncCommand( const QString& n ) {mPreSyncCommand = n;}
70 QString getPreSyncCommand( ) { return mPreSyncCommand; } 70 QString getPreSyncCommand( ) { return mPreSyncCommand; }
71 void setPostSyncCommand( const QString& n ) {mPostSyncCommand = n;} 71 void setPostSyncCommand( const QString& n ) {mPostSyncCommand = n;}
72 QString getPostSyncCommand( ) { return mPostSyncCommand;} 72 QString getPostSyncCommand( ) { return mPostSyncCommand;}
73 void setLocalTempFile( const QString& n ) { mLocalTempFile= n;} 73 void setLocalTempFile( const QString& n ) { mLocalTempFile= n;}
74 QString getLocalTempFile( ) { return mLocalTempFile;} 74 QString getLocalTempFile( ) { return mLocalTempFile;}
75 void setRemoteFileName( const QString& n ) { mRemoteFileName = n;} 75 void setRemoteFileName( const QString& n ) { mRemoteFileName = n;}
76 QString getRemoteFileName( ) { return mRemoteFileName;} 76 QString getRemoteFileName( ) { return mRemoteFileName;}
77 77
78 void setPreSyncCommandAB( const QString& n ) {mPreSyncCommandAB = n;} 78 void setPreSyncCommandAB( const QString& n ) {mPreSyncCommandAB = n;}
79 QString getPreSyncCommandAB( ) { return mPreSyncCommandAB; } 79 QString getPreSyncCommandAB( ) { return mPreSyncCommandAB; }
80 void setPostSyncCommandAB( const QString& n ) {mPostSyncCommandAB = n;} 80 void setPostSyncCommandAB( const QString& n ) {mPostSyncCommandAB = n;}
81 QString getPostSyncCommandAB( ) { return mPostSyncCommandAB;} 81 QString getPostSyncCommandAB( ) { return mPostSyncCommandAB;}
82 void setLocalTempFileAB( const QString& n ) { mLocalTempFileAB= n;} 82 void setLocalTempFileAB( const QString& n ) { mLocalTempFileAB= n;}
83 QString getLocalTempFileAB( ) { return mLocalTempFileAB;} 83 QString getLocalTempFileAB( ) { return mLocalTempFileAB;}
84 void setRemoteFileNameAB( const QString& n ) { mRemoteFileNameAB = n;} 84 void setRemoteFileNameAB( const QString& n ) { mRemoteFileNameAB = n;}
85 QString getRemoteFileNameAB( ) { return mRemoteFileNameAB;} 85 QString getRemoteFileNameAB( ) { return mRemoteFileNameAB;}
86 86
87 void setPreSyncCommandPWM( const QString& n ) {mPreSyncCommandPWM = n;} 87 void setPreSyncCommandPWM( const QString& n ) {mPreSyncCommandPWM = n;}
88 QString getPreSyncCommandPWM( ) { return mPreSyncCommandPWM; } 88 QString getPreSyncCommandPWM( ) { return mPreSyncCommandPWM; }
89 void setPostSyncCommandPWM( const QString& n ) {mPostSyncCommandPWM = n;} 89 void setPostSyncCommandPWM( const QString& n ) {mPostSyncCommandPWM = n;}
90 QString getPostSyncCommandPWM( ) { return mPostSyncCommandPWM;} 90 QString getPostSyncCommandPWM( ) { return mPostSyncCommandPWM;}
91 void setLocalTempFilePWM( const QString& n ) { mLocalTempFilePWM= n;} 91 void setLocalTempFilePWM( const QString& n ) { mLocalTempFilePWM= n;}
92 QString getLocalTempFilePWM( ) { return mLocalTempFilePWM;} 92 QString getLocalTempFilePWM( ) { return mLocalTempFilePWM;}
93 void setRemoteFileNamePWM( const QString& n ) { mRemoteFileNamePWM = n;} 93 void setRemoteFileNamePWM( const QString& n ) { mRemoteFileNamePWM = n;}
94 QString getRemoteFileNamePWM( ) { return mRemoteFileNamePWM;} 94 QString getRemoteFileNamePWM( ) { return mRemoteFileNamePWM;}
95 95
96 void setPhoneDevice( const QString& n ) { mPhoneDevice = n;} 96 void setPhoneDevice( const QString& n ) { mPhoneDevice = n;}
97 QString getPhoneDevice( ) { return mPhoneDevice;} 97 QString getPhoneDevice( ) { return mPhoneDevice;}
98 void setPhoneConnection( const QString& n ) { mPhoneConnection = n;} 98 void setPhoneConnection( const QString& n ) { mPhoneConnection = n;}
99 QString getPhoneConnection( ) { return mPhoneConnection;} 99 QString getPhoneConnection( ) { return mPhoneConnection;}
100 void setPhoneModel( const QString& n ) { mPhoneModel = n;} 100 void setPhoneModel( const QString& n ) { mPhoneModel = n;}
101 QString getPhoneModel( ) { return mPhoneModel;} 101 QString getPhoneModel( ) { return mPhoneModel;}
102 /* 102 /*
103 void set( const QString& n ) { = n;} 103 void set( const QString& n ) { = n;}
104 QString get( ) { return ;} 104 QString get( ) { return ;}
105 */ 105 */
106 106
107 void setName( const QString& n ) {mName = n;} 107 void setName( const QString& n ) {mName = n;}
108 QString getName( ) { return mName;} 108 QString getName( ) { return mName;}
109 void setShowSummaryAfterSync( bool b ) { mShowSummaryAfterSync = b;} 109 void setShowSummaryAfterSync( bool b ) { mShowSummaryAfterSync = b;}
110 bool getShowSummaryAfterSync( ) { return mShowSummaryAfterSync ;} 110 bool getShowSummaryAfterSync( ) { return mShowSummaryAfterSync ;}
111 void setAskForPreferences( bool b ) { mAskForPreferences= b;} 111 void setAskForPreferences( bool b ) { mAskForPreferences= b;}
112 bool getAskForPreferences( ) { return mAskForPreferences;} 112 bool getAskForPreferences( ) { return mAskForPreferences;}
113 void setWriteBackExisting( bool b ) { mWriteBackExisting = b;} 113 void setWriteBackExisting( bool b ) { mWriteBackExisting = b;}
114 bool getWriteBackExisting( ) { return mWriteBackExisting;} 114 bool getWriteBackExisting( ) { return mWriteBackExisting;}
115 void setWriteBackFuture( bool b ) { mWriteBackFuture = b;} 115 void setWriteBackFuture( bool b ) { mWriteBackFuture = b;}
116 bool getWriteBackFuture( ) { return mWriteBackFuture;} 116 bool getWriteBackFuture( ) { return mWriteBackFuture;}
117 void setWriteBackFile( bool b ) { mWriteBackFile= b;} 117 void setWriteBackFile( bool b ) { mWriteBackFile= b;}
118 bool getWriteBackFile( ) { return mWriteBackFile;} 118 bool getWriteBackFile( ) { return mWriteBackFile;}
119 void setWriteContactToSIM( bool b ) { mWriteContactToSIM= b;} 119 void setWriteContactToSIM( bool b ) { mWriteContactToSIM= b;}
120 bool getWriteContactToSIM( ) { return mWriteContactToSIM;} 120 bool getWriteContactToSIM( ) { return mWriteContactToSIM;}
121 void setIncludeInRingSync( bool b ) {mIncludeInRingSync = b;} 121 void setIncludeInRingSync( bool b ) {mIncludeInRingSync = b;}
122 bool getIncludeInRingSync( ) { return mIncludeInRingSync;} 122 bool getIncludeInRingSync( ) { return mIncludeInRingSync;}
123 void setIncludeInRingSyncAB( bool b ) {mIncludeInRingSyncAB = b;} 123 void setIncludeInRingSyncAB( bool b ) {mIncludeInRingSyncAB = b;}
124 bool getIncludeInRingSyncAB( ) { return mIncludeInRingSyncAB;} 124 bool getIncludeInRingSyncAB( ) { return mIncludeInRingSyncAB;}
125 void setIncludeInRingSyncPWM( bool b ) {mIncludeInRingSyncPWM = b;} 125 void setIncludeInRingSyncPWM( bool b ) {mIncludeInRingSyncPWM = b;}
126 bool getIncludeInRingSyncPWM( ) { return mIncludeInRingSyncPWM;} 126 bool getIncludeInRingSyncPWM( ) { return mIncludeInRingSyncPWM;}
127 void setSyncPrefs( int n ) { mSyncPrefs= n;} 127 void setSyncPrefs( int n ) { mSyncPrefs= n;}
128 int getSyncPrefs( ) { return mSyncPrefs;} 128 int getSyncPrefs( ) { return mSyncPrefs;}
129 void setWriteBackFutureWeeks( int n ) { mWriteBackFutureWeeks= n;} 129 void setWriteBackFutureWeeks( int n ) { mWriteBackFutureWeeks= n;}
130 int getWriteBackFutureWeeks( ) { return mWriteBackFutureWeeks;} 130 int getWriteBackFutureWeeks( ) { return mWriteBackFutureWeeks;}
131 void setWriteBackPastWeeks( int n ) { mWriteBackPastWeeks= n;}
132 int getWriteBackPastWeeks( ) { return mWriteBackPastWeeks;}
131 void setIsLocalFileSync( bool b ) { mIsLocalFileSync= b;} 133 void setIsLocalFileSync( bool b ) { mIsLocalFileSync= b;}
132 bool getIsLocalFileSync( ) { return mIsLocalFileSync;} 134 bool getIsLocalFileSync( ) { return mIsLocalFileSync;}
133 void setIsPhoneSync( bool b ) { mIsPhoneSync= b;} 135 void setIsPhoneSync( bool b ) { mIsPhoneSync= b;}
134 bool getIsPhoneSync( ) { return mIsPhoneSync;} 136 bool getIsPhoneSync( ) { return mIsPhoneSync;}
135 void setIsPiSync( bool b ) { mIsPiSync= b;} 137 void setIsPiSync( bool b ) { mIsPiSync= b;}
136 bool getIsPiSync( ) { return mIsPiSync;} 138 bool getIsPiSync( ) { return mIsPiSync;}
137 void setIsKapiFile( bool b ) { mIsKapiFile= b;} 139 void setIsKapiFile( bool b ) { mIsKapiFile= b;}
138 bool getIsKapiFile( ) { return mIsKapiFile;} 140 bool getIsKapiFile( ) { return mIsKapiFile;}
139 private: 141 private:
140 QString mName; 142 QString mName;
141 QString mPreSyncCommand; 143 QString mPreSyncCommand;
142 QString mPostSyncCommand; 144 QString mPostSyncCommand;
143 QString mLocalTempFile; 145 QString mLocalTempFile;
144 QString mRemoteFileName; 146 QString mRemoteFileName;
145 QString mPreSyncCommandAB; 147 QString mPreSyncCommandAB;
146 QString mPostSyncCommandAB; 148 QString mPostSyncCommandAB;
147 QString mLocalTempFileAB; 149 QString mLocalTempFileAB;
148 QString mRemoteFileNameAB; 150 QString mRemoteFileNameAB;
149 QString mPreSyncCommandPWM; 151 QString mPreSyncCommandPWM;
150 QString mPostSyncCommandPWM; 152 QString mPostSyncCommandPWM;
151 QString mLocalTempFilePWM; 153 QString mLocalTempFilePWM;
152 QString mRemoteFileNamePWM; 154 QString mRemoteFileNamePWM;
153 155
154 QString mRemotePw; 156 QString mRemotePw;
155 QString mRemoteIP; 157 QString mRemoteIP;
156 QString mRemotePort; 158 QString mRemotePort;
157 159
158 QString mRemotePwAB; 160 QString mRemotePwAB;
159 QString mRemoteIPAB; 161 QString mRemoteIPAB;
160 QString mRemotePortAB; 162 QString mRemotePortAB;
161 163
162 QString mRemotePwPWM; 164 QString mRemotePwPWM;
163 QString mRemoteIPPWM; 165 QString mRemoteIPPWM;
164 QString mRemotePortPWM; 166 QString mRemotePortPWM;
165 167
166 QString mPhoneDevice; 168 QString mPhoneDevice;
167 QString mPhoneConnection; 169 QString mPhoneConnection;
168 QString mPhoneModel; 170 QString mPhoneModel;
169 171
170 bool mIncludeInRingSync; 172 bool mIncludeInRingSync;
171 bool mIncludeInRingSyncAB; 173 bool mIncludeInRingSyncAB;
172 bool mIncludeInRingSyncPWM; 174 bool mIncludeInRingSyncPWM;
173 int mSyncPrefs; 175 int mSyncPrefs;
174 bool mWriteBackFile; 176 bool mWriteBackFile;
175 bool mWriteBackExisting; 177 bool mWriteBackExisting;
176 bool mWriteBackFuture; 178 bool mWriteBackFuture;
177 int mWriteBackFutureWeeks; 179 int mWriteBackFutureWeeks;
180 int mWriteBackPastWeeks;
178 bool mAskForPreferences; 181 bool mAskForPreferences;
179 bool mShowSummaryAfterSync; 182 bool mShowSummaryAfterSync;
180 bool mIsLocalFileSync; 183 bool mIsLocalFileSync;
181 bool mIsPhoneSync; 184 bool mIsPhoneSync;
182 bool mWriteContactToSIM; 185 bool mWriteContactToSIM;
183 186
184 bool mIsPiSync; 187 bool mIsPiSync;
185 bool mIsKapiFile; 188 bool mIsKapiFile;
186}; 189};
187 190
188#endif 191#endif