-rw-r--r-- | korganizer/mainwindow.cpp | 2 | ||||
-rw-r--r-- | libkdepim/kpimprefs.cpp | 2 | ||||
-rw-r--r-- | libkdepim/kpimprefs.h | 2 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 87 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 2 |
5 files changed, 64 insertions, 31 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index c3e9f75..02ca523 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -84,385 +84,385 @@ class KOex2phonePrefs : public QDialog | |||
84 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 84 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
85 | lab->setAlignment (AlignHCenter ); | 85 | lab->setAlignment (AlignHCenter ); |
86 | QHBox* temphb; | 86 | QHBox* temphb; |
87 | temphb = new QHBox( this ); | 87 | temphb = new QHBox( this ); |
88 | new QLabel( i18n("I/O device: "), temphb ); | 88 | new QLabel( i18n("I/O device: "), temphb ); |
89 | mPhoneDevice = new QLineEdit( temphb); | 89 | mPhoneDevice = new QLineEdit( temphb); |
90 | lay->addWidget( temphb ); | 90 | lay->addWidget( temphb ); |
91 | temphb = new QHBox( this ); | 91 | temphb = new QHBox( this ); |
92 | new QLabel( i18n("Connection: "), temphb ); | 92 | new QLabel( i18n("Connection: "), temphb ); |
93 | mPhoneConnection = new QLineEdit( temphb); | 93 | mPhoneConnection = new QLineEdit( temphb); |
94 | lay->addWidget( temphb ); | 94 | lay->addWidget( temphb ); |
95 | temphb = new QHBox( this ); | 95 | temphb = new QHBox( this ); |
96 | new QLabel( i18n("Model(opt.): "), temphb ); | 96 | new QLabel( i18n("Model(opt.): "), temphb ); |
97 | mPhoneModel = new QLineEdit( temphb); | 97 | mPhoneModel = new QLineEdit( temphb); |
98 | lay->addWidget( temphb ); | 98 | lay->addWidget( temphb ); |
99 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 99 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
100 | mWriteBackFuture->setChecked( true ); | 100 | mWriteBackFuture->setChecked( true ); |
101 | lay->addWidget( mWriteBackFuture ); | 101 | lay->addWidget( mWriteBackFuture ); |
102 | temphb = new QHBox( this ); | 102 | temphb = new QHBox( this ); |
103 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 103 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
104 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 104 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
105 | mWriteBackFutureWeeks->setValue( 8 ); | 105 | mWriteBackFutureWeeks->setValue( 8 ); |
106 | lay->addWidget( temphb ); | 106 | lay->addWidget( temphb ); |
107 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); | 107 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
108 | lab->setAlignment (AlignHCenter ); | 108 | lab->setAlignment (AlignHCenter ); |
109 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 109 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
110 | lay->addWidget( ok ); | 110 | lay->addWidget( ok ); |
111 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 111 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
112 | lay->addWidget( cancel ); | 112 | lay->addWidget( cancel ); |
113 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 113 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
114 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 114 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
115 | resize( 220, 240 ); | 115 | resize( 220, 240 ); |
116 | 116 | ||
117 | } | 117 | } |
118 | 118 | ||
119 | public: | 119 | public: |
120 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 120 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
121 | QCheckBox* mWriteBackFuture; | 121 | QCheckBox* mWriteBackFuture; |
122 | QSpinBox* mWriteBackFutureWeeks; | 122 | QSpinBox* mWriteBackFutureWeeks; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | int globalFlagBlockStartup; | 125 | int globalFlagBlockStartup; |
126 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 126 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
127 | QMainWindow( parent, name ) | 127 | QMainWindow( parent, name ) |
128 | { | 128 | { |
129 | 129 | ||
130 | #ifdef DESKTOP_VERSION | 130 | #ifdef DESKTOP_VERSION |
131 | setFont( QFont("Arial"), 14 ); | 131 | setFont( QFont("Arial"), 14 ); |
132 | #endif | 132 | #endif |
133 | mClosed = false; | 133 | mClosed = false; |
134 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 134 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
135 | QString confFile = locateLocal("config","korganizerrc"); | 135 | QString confFile = locateLocal("config","korganizerrc"); |
136 | QFileInfo finf ( confFile ); | 136 | QFileInfo finf ( confFile ); |
137 | bool showWarning = !finf.exists(); | 137 | bool showWarning = !finf.exists(); |
138 | setIcon(SmallIcon( "ko24" ) ); | 138 | setIcon(SmallIcon( "ko24" ) ); |
139 | mBlockAtStartup = true; | 139 | mBlockAtStartup = true; |
140 | mFlagKeyPressed = false; | 140 | mFlagKeyPressed = false; |
141 | setCaption("KOrganizer/Pi"); | 141 | setCaption("KOrganizer/Pi"); |
142 | KOPrefs *p = KOPrefs::instance(); | 142 | KOPrefs *p = KOPrefs::instance(); |
143 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 143 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
144 | if ( p->mHourSize > 18 ) | 144 | if ( p->mHourSize > 18 ) |
145 | p->mHourSize = 18; | 145 | p->mHourSize = 18; |
146 | QMainWindow::ToolBarDock tbd; | 146 | QMainWindow::ToolBarDock tbd; |
147 | if ( p->mToolBarHor ) { | 147 | if ( p->mToolBarHor ) { |
148 | if ( p->mToolBarUp ) | 148 | if ( p->mToolBarUp ) |
149 | tbd = Bottom; | 149 | tbd = Bottom; |
150 | else | 150 | else |
151 | tbd = Top; | 151 | tbd = Top; |
152 | } | 152 | } |
153 | else { | 153 | else { |
154 | if ( p->mToolBarUp ) | 154 | if ( p->mToolBarUp ) |
155 | tbd = Right; | 155 | tbd = Right; |
156 | else | 156 | else |
157 | tbd = Left; | 157 | tbd = Left; |
158 | } | 158 | } |
159 | if ( KOPrefs::instance()->mUseAppColors ) | 159 | if ( KOPrefs::instance()->mUseAppColors ) |
160 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 160 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
161 | globalFlagBlockStartup = 1; | 161 | globalFlagBlockStartup = 1; |
162 | iconToolBar = new QPEToolBar( this ); | 162 | iconToolBar = new QPEToolBar( this ); |
163 | addToolBar (iconToolBar , tbd ); | 163 | addToolBar (iconToolBar , tbd ); |
164 | mCalendarModifiedFlag = false; | 164 | mCalendarModifiedFlag = false; |
165 | 165 | ||
166 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 166 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
167 | splash->setAlignment ( AlignCenter ); | 167 | splash->setAlignment ( AlignCenter ); |
168 | setCentralWidget( splash ); | 168 | setCentralWidget( splash ); |
169 | #ifndef DESKTOP_VERSION | 169 | #ifndef DESKTOP_VERSION |
170 | showMaximized(); | 170 | showMaximized(); |
171 | #endif | 171 | #endif |
172 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 172 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
173 | setDefaultPreferences(); | 173 | setDefaultPreferences(); |
174 | mCalendar = new CalendarLocal(); | 174 | mCalendar = new CalendarLocal(); |
175 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 175 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
176 | mView->hide(); | 176 | mView->hide(); |
177 | //mView->resize(splash->size() ); | 177 | //mView->resize(splash->size() ); |
178 | initActions(); | 178 | initActions(); |
179 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 179 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
180 | mSyncManager->setBlockSave(false); | 180 | mSyncManager->setBlockSave(false); |
181 | mView->setSyncManager(mSyncManager); | 181 | mView->setSyncManager(mSyncManager); |
182 | #ifndef DESKTOP_VERSION | 182 | #ifndef DESKTOP_VERSION |
183 | iconToolBar->show(); | 183 | iconToolBar->show(); |
184 | qApp->processEvents(); | 184 | qApp->processEvents(); |
185 | #endif | 185 | #endif |
186 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 186 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
187 | int vh = height() ; | 187 | int vh = height() ; |
188 | int vw = width(); | 188 | int vw = width(); |
189 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 189 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
190 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 190 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
191 | vh -= iconToolBar->height(); | 191 | vh -= iconToolBar->height(); |
192 | } else { | 192 | } else { |
193 | vw -= iconToolBar->height(); | 193 | vw -= iconToolBar->height(); |
194 | } | 194 | } |
195 | //mView->setMaximumSize( splash->size() ); | 195 | //mView->setMaximumSize( splash->size() ); |
196 | //mView->resize( splash->size() ); | 196 | //mView->resize( splash->size() ); |
197 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 197 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
198 | mView->readSettings(); | 198 | mView->readSettings(); |
199 | bool newFile = false; | 199 | bool newFile = false; |
200 | if( !QFile::exists( defaultFileName() ) ) { | 200 | if( !QFile::exists( defaultFileName() ) ) { |
201 | QFileInfo finfo ( defaultFileName() ); | 201 | QFileInfo finfo ( defaultFileName() ); |
202 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 202 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
203 | qDebug("oldfile %s ", oldFile.latin1()); | 203 | qDebug("oldfile %s ", oldFile.latin1()); |
204 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; | 204 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; |
205 | finfo.setFile( oldFile ); | 205 | finfo.setFile( oldFile ); |
206 | if (finfo.exists() ) { | 206 | if (finfo.exists() ) { |
207 | KMessageBox::information( this, message); | 207 | KMessageBox::information( this, message); |
208 | mView->openCalendar( oldFile ); | 208 | mView->openCalendar( oldFile ); |
209 | qApp->processEvents(); | 209 | qApp->processEvents(); |
210 | } else { | 210 | } else { |
211 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 211 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
212 | finfo.setFile( oldFile ); | 212 | finfo.setFile( oldFile ); |
213 | if (finfo.exists() ) { | 213 | if (finfo.exists() ) { |
214 | KMessageBox::information( this, message); | 214 | KMessageBox::information( this, message); |
215 | mView->openCalendar( oldFile ); | 215 | mView->openCalendar( oldFile ); |
216 | qApp->processEvents(); | 216 | qApp->processEvents(); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | mView->saveCalendar( defaultFileName() ); | 219 | mView->saveCalendar( defaultFileName() ); |
220 | newFile = true; | 220 | newFile = true; |
221 | } | 221 | } |
222 | 222 | ||
223 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 223 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
224 | mView->openCalendar( defaultFileName() ); | 224 | mView->openCalendar( defaultFileName() ); |
225 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 225 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
226 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 226 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
227 | 227 | ||
228 | if ( KOPrefs::instance()->mLanguageChanged ) { | 228 | if ( KOPrefs::instance()->mLanguageChanged ) { |
229 | KOPrefs::instance()->setCategoryDefaults(); | 229 | KOPrefs::instance()->setCategoryDefaults(); |
230 | int count = mView->addCategories(); | 230 | int count = mView->addCategories(); |
231 | KOPrefs::instance()->mLanguageChanged = false; | 231 | KOPrefs::instance()->mLanguageChanged = false; |
232 | } | 232 | } |
233 | processIncidenceSelection( 0 ); | 233 | processIncidenceSelection( 0 ); |
234 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 234 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
235 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 235 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
236 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 236 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
237 | SLOT( slotModifiedChanged( bool ) ) ); | 237 | SLOT( slotModifiedChanged( bool ) ) ); |
238 | 238 | ||
239 | 239 | ||
240 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 240 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
241 | mView->setModified( false ); | 241 | mView->setModified( false ); |
242 | mBlockAtStartup = false; | 242 | mBlockAtStartup = false; |
243 | mView->setModified( false ); | 243 | mView->setModified( false ); |
244 | setCentralWidget( mView ); | 244 | setCentralWidget( mView ); |
245 | globalFlagBlockStartup = 0; | 245 | globalFlagBlockStartup = 0; |
246 | mView->show(); | 246 | mView->show(); |
247 | delete splash; | 247 | delete splash; |
248 | if ( newFile ) | 248 | if ( newFile ) |
249 | mView->updateConfig(); | 249 | mView->updateConfig(); |
250 | // qApp->processEvents(); | 250 | // qApp->processEvents(); |
251 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 251 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
252 | //fillSyncMenu(); | 252 | //fillSyncMenu(); |
253 | 253 | ||
254 | 254 | ||
255 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 255 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
256 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 256 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
257 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 257 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
258 | mSyncManager->setDefaultFileName( defaultFileName()); | 258 | mSyncManager->setDefaultFileName( defaultFileName()); |
259 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 259 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
260 | mSyncManager->fillSyncMenu(); | 260 | mSyncManager->fillSyncMenu(); |
261 | 261 | ||
262 | 262 | ||
263 | 263 | ||
264 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 264 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
265 | if ( showWarning ) { | 265 | if ( showWarning ) { |
266 | KMessageBox::information( this, | 266 | KMessageBox::information( this, |
267 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 267 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
268 | qApp->processEvents(); | 268 | qApp->processEvents(); |
269 | mView->dialogManager()->showSyncOptions(); | 269 | mView->dialogManager()->showSyncOptions(); |
270 | } | 270 | } |
271 | 271 | ||
272 | //US listen for result adressed from Ka/Pi | 272 | //US listen for result adressed from Ka/Pi |
273 | #ifndef DESKTOP_VERSION | 273 | #ifndef DESKTOP_VERSION |
274 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 274 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
275 | #endif | 275 | #endif |
276 | 276 | ||
277 | } | 277 | } |
278 | MainWindow::~MainWindow() | 278 | MainWindow::~MainWindow() |
279 | { | 279 | { |
280 | //qDebug("MainWindow::~MainWindow() "); | 280 | //qDebug("MainWindow::~MainWindow() "); |
281 | //save toolbar location | 281 | //save toolbar location |
282 | delete mCalendar; | 282 | delete mCalendar; |
283 | delete mSyncManager; | 283 | delete mSyncManager; |
284 | 284 | ||
285 | 285 | ||
286 | } | 286 | } |
287 | void MainWindow::showMaximized () | 287 | void MainWindow::showMaximized () |
288 | { | 288 | { |
289 | #ifndef DESKTOP_VERSION | 289 | #ifndef DESKTOP_VERSION |
290 | if ( ! globalFlagBlockStartup ) | 290 | if ( ! globalFlagBlockStartup ) |
291 | if ( mClosed ) | 291 | if ( mClosed ) |
292 | mView->goToday(); | 292 | mView->goToday(); |
293 | #endif | 293 | #endif |
294 | QWidget::showMaximized () ; | 294 | QWidget::showMaximized () ; |
295 | mClosed = false; | 295 | mClosed = false; |
296 | } | 296 | } |
297 | void MainWindow::closeEvent( QCloseEvent* ce ) | 297 | void MainWindow::closeEvent( QCloseEvent* ce ) |
298 | { | 298 | { |
299 | 299 | ||
300 | 300 | ||
301 | 301 | ||
302 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 302 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
303 | saveOnClose(); | 303 | saveOnClose(); |
304 | mClosed = true; | 304 | mClosed = true; |
305 | ce->accept(); | 305 | ce->accept(); |
306 | return; | 306 | return; |
307 | 307 | ||
308 | } | 308 | } |
309 | 309 | ||
310 | switch( QMessageBox::information( this, "KO/Pi", | 310 | switch( QMessageBox::information( this, "KO/Pi", |
311 | i18n("Do you really want\nto close KO/Pi?"), | 311 | i18n("Do you really want\nto close KO/Pi?"), |
312 | i18n("Close"), i18n("No"), | 312 | i18n("Close"), i18n("No"), |
313 | 0, 0 ) ) { | 313 | 0, 0 ) ) { |
314 | case 0: | 314 | case 0: |
315 | saveOnClose(); | 315 | saveOnClose(); |
316 | mClosed = true; | 316 | mClosed = true; |
317 | ce->accept(); | 317 | ce->accept(); |
318 | break; | 318 | break; |
319 | case 1: | 319 | case 1: |
320 | ce->ignore(); | 320 | ce->ignore(); |
321 | break; | 321 | break; |
322 | case 2: | 322 | case 2: |
323 | 323 | ||
324 | default: | 324 | default: |
325 | break; | 325 | break; |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | } | 329 | } |
330 | 330 | ||
331 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 331 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
332 | { | 332 | { |
333 | QDataStream stream( data, IO_ReadOnly ); | 333 | QDataStream stream( data, IO_ReadOnly ); |
334 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 334 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
335 | //QString datamess; | 335 | //QString datamess; |
336 | //qDebug("message "); | 336 | //qDebug("message "); |
337 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 337 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
338 | 338 | ||
339 | if ( cmsg == "setDocument(QString)" ) { | 339 | if ( cmsg == "setDocument(QString)" ) { |
340 | QDataStream stream( data, IO_ReadOnly ); | 340 | QDataStream stream( data, IO_ReadOnly ); |
341 | QString fileName; | 341 | QString fileName; |
342 | stream >> fileName; | 342 | stream >> fileName; |
343 | //qDebug("filename %s ", fileName.latin1()); | 343 | //qDebug("filename %s ", fileName.latin1()); |
344 | showMaximized(); | 344 | showMaximized(); |
345 | raise(); | 345 | raise(); |
346 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 346 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
347 | mSyncManager->slotSyncMenu( 1002 ); | 347 | mSyncManager->slotSyncMenu( 1002 ); |
348 | return; | 348 | return; |
349 | } | 349 | } |
350 | 350 | ||
351 | if ( cmsg == "-writeFile" ) { | 351 | if ( cmsg == "-writeFile" ) { |
352 | // I made from the "-writeFile" an "-writeAlarm" | 352 | // I made from the "-writeFile" an "-writeAlarm" |
353 | mView->viewManager()->showWhatsNextView(); | 353 | mView->viewManager()->showWhatsNextView(); |
354 | mCalendar->checkAlarmForIncidence( 0, true); | 354 | mCalendar->checkAlarmForIncidence( 0, true); |
355 | showMaximized(); | 355 | showMaximized(); |
356 | raise(); | 356 | raise(); |
357 | return; | 357 | return; |
358 | 358 | ||
359 | } | 359 | } |
360 | if ( cmsg == "-writeFileSilent" ) { | 360 | if ( cmsg == "-writeFileSilent" ) { |
361 | // I made from the "-writeFile" an "-writeAlarm" | 361 | // I made from the "-writeFile" an "-writeAlarm" |
362 | // mView->viewManager()->showWhatsNextView(); | 362 | // mView->viewManager()->showWhatsNextView(); |
363 | mCalendar->checkAlarmForIncidence( 0, true); | 363 | mCalendar->checkAlarmForIncidence( 0, true); |
364 | //showMaximized(); | 364 | //showMaximized(); |
365 | //raise(); | 365 | //raise(); |
366 | hide(); | 366 | hide(); |
367 | return; | 367 | return; |
368 | } | 368 | } |
369 | if ( cmsg == "-newCountdown" ) { | 369 | if ( cmsg == "-newCountdown" ) { |
370 | qDebug("newCountdown "); | 370 | qDebug("newCountdown "); |
371 | 371 | ||
372 | } | 372 | } |
373 | QString msg ; | 373 | QString msg ; |
374 | QString allmsg = cmsg; | 374 | QString allmsg = cmsg; |
375 | while ( allmsg.length() > 0 ) { | 375 | while ( allmsg.length() > 0 ) { |
376 | int nextC = allmsg.find( "-", 1 ); | 376 | int nextC = allmsg.find( "-", 1 ); |
377 | if ( nextC == -1 ) { | 377 | if ( nextC == -1 ) { |
378 | msg = allmsg; | 378 | msg = allmsg; |
379 | allmsg = ""; | 379 | allmsg = ""; |
380 | } else{ | 380 | } else{ |
381 | msg = allmsg.left( nextC ); | 381 | msg = allmsg.left( nextC ); |
382 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 382 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
383 | } | 383 | } |
384 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 384 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
385 | if ( msg == "-newEvent" ) { | 385 | if ( msg == "-newEvent" ) { |
386 | mView->newEvent(); | 386 | mView->newEvent(); |
387 | } | 387 | } |
388 | if ( msg == "-newTodo" ) { | 388 | if ( msg == "-newTodo" ) { |
389 | mView->newTodo(); | 389 | mView->newTodo(); |
390 | 390 | ||
391 | } | 391 | } |
392 | if ( msg == "-showWN" ) { | 392 | if ( msg == "-showWN" ) { |
393 | mView->viewManager()->showWhatsNextView(); | 393 | mView->viewManager()->showWhatsNextView(); |
394 | } | 394 | } |
395 | if ( msg == "-showTodo" ) { | 395 | if ( msg == "-showTodo" ) { |
396 | mView->viewManager()->showTodoView(); | 396 | mView->viewManager()->showTodoView(); |
397 | } | 397 | } |
398 | if ( msg == "-showList" ) { | 398 | if ( msg == "-showList" ) { |
399 | mView->viewManager()->showListView(); | 399 | mView->viewManager()->showListView(); |
400 | } | 400 | } |
401 | else if ( msg == "-showDay" ) { | 401 | else if ( msg == "-showDay" ) { |
402 | mView->viewManager()->showDayView(); | 402 | mView->viewManager()->showDayView(); |
403 | } | 403 | } |
404 | else if ( msg == "-showWWeek" ) { | 404 | else if ( msg == "-showWWeek" ) { |
405 | mView->viewManager()->showWorkWeekView(); | 405 | mView->viewManager()->showWorkWeekView(); |
406 | } | 406 | } |
407 | else if ( msg == "-ringSync" ) { | 407 | else if ( msg == "-ringSync" ) { |
408 | mSyncManager->multiSync( false ); | 408 | mSyncManager->multiSync( false ); |
409 | } | 409 | } |
410 | else if ( msg == "-showWeek" ) { | 410 | else if ( msg == "-showWeek" ) { |
411 | mView->viewManager()->showWeekView(); | 411 | mView->viewManager()->showWeekView(); |
412 | } | 412 | } |
413 | else if ( msg == "-showTodo" ) { | 413 | else if ( msg == "-showTodo" ) { |
414 | mView->viewManager()->showTodoView(); | 414 | mView->viewManager()->showTodoView(); |
415 | } | 415 | } |
416 | else if ( msg == "-showJournal" ) { | 416 | else if ( msg == "-showJournal" ) { |
417 | mView->dateNavigator()->selectDates( 1 ); | 417 | mView->dateNavigator()->selectDates( 1 ); |
418 | mView->dateNavigator()->selectToday(); | 418 | mView->dateNavigator()->selectToday(); |
419 | mView->viewManager()->showJournalView(); | 419 | mView->viewManager()->showJournalView(); |
420 | } | 420 | } |
421 | else if ( msg == "-showKO" ) { | 421 | else if ( msg == "-showKO" ) { |
422 | mView->viewManager()->showNextXView(); | 422 | mView->viewManager()->showNextXView(); |
423 | } | 423 | } |
424 | else if ( msg == "-showWNext" || msg == "nextView()" ) { | 424 | else if ( msg == "-showWNext" || msg == "nextView()" ) { |
425 | mView->viewManager()->showWhatsNextView(); | 425 | mView->viewManager()->showWhatsNextView(); |
426 | } | 426 | } |
427 | else if ( msg == "-showNextXView" ) { | 427 | else if ( msg == "-showNextXView" ) { |
428 | mView->viewManager()->showNextXView(); | 428 | mView->viewManager()->showNextXView(); |
429 | } | 429 | } |
430 | 430 | ||
431 | 431 | ||
432 | } | 432 | } |
433 | 433 | ||
434 | showMaximized(); | 434 | showMaximized(); |
435 | raise(); | 435 | raise(); |
436 | } | 436 | } |
437 | 437 | ||
438 | QPixmap MainWindow::loadPixmap( QString name ) | 438 | QPixmap MainWindow::loadPixmap( QString name ) |
439 | { | 439 | { |
440 | return SmallIcon( name ); | 440 | return SmallIcon( name ); |
441 | 441 | ||
442 | } | 442 | } |
443 | void MainWindow::initActions() | 443 | void MainWindow::initActions() |
444 | { | 444 | { |
445 | //KOPrefs::instance()->mShowFullMenu | 445 | //KOPrefs::instance()->mShowFullMenu |
446 | iconToolBar->clear(); | 446 | iconToolBar->clear(); |
447 | KOPrefs *p = KOPrefs::instance(); | 447 | KOPrefs *p = KOPrefs::instance(); |
448 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 448 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
449 | 449 | ||
450 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 450 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
451 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 451 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
452 | QPopupMenu *importMenu = new QPopupMenu( this ); | 452 | QPopupMenu *importMenu = new QPopupMenu( this ); |
453 | selectFilterMenu = new QPopupMenu( this ); | 453 | selectFilterMenu = new QPopupMenu( this ); |
454 | selectFilterMenu->setCheckable( true ); | 454 | selectFilterMenu->setCheckable( true ); |
455 | syncMenu = new QPopupMenu( this ); | 455 | syncMenu = new QPopupMenu( this ); |
456 | configureAgendaMenu = new QPopupMenu( this ); | 456 | configureAgendaMenu = new QPopupMenu( this ); |
457 | configureToolBarMenu = new QPopupMenu( this ); | 457 | configureToolBarMenu = new QPopupMenu( this ); |
458 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 458 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
459 | if ( KOPrefs::instance()->mShowFullMenu ) { | 459 | if ( KOPrefs::instance()->mShowFullMenu ) { |
460 | QMenuBar *menuBar1; | 460 | QMenuBar *menuBar1; |
461 | menuBar1 = menuBar(); | 461 | menuBar1 = menuBar(); |
462 | menuBar1->insertItem( i18n("File"), importMenu ); | 462 | menuBar1->insertItem( i18n("File"), importMenu ); |
463 | menuBar1->insertItem( i18n("View"), viewMenu ); | 463 | menuBar1->insertItem( i18n("View"), viewMenu ); |
464 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 464 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
465 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 465 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
466 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 466 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
467 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 467 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
468 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 468 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp index c21ebaa..a05e65f 100644 --- a/libkdepim/kpimprefs.cpp +++ b/libkdepim/kpimprefs.cpp | |||
@@ -1,82 +1,84 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 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 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | 35 | ||
36 | #include "kpimprefs.h" | 36 | #include "kpimprefs.h" |
37 | 37 | ||
38 | KPimPrefs::KPimPrefs( const QString &name ) : | 38 | KPimPrefs::KPimPrefs( const QString &name ) : |
39 | KPrefs( name ) | 39 | KPrefs( name ) |
40 | { | 40 | { |
41 | #ifdef _WIN32_ | 41 | #ifdef _WIN32_ |
42 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 42 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
43 | #else | 43 | #else |
44 | QString hdp= locateLocal("data","korganizer")+"/"; | 44 | QString hdp= locateLocal("data","korganizer")+"/"; |
45 | #endif | 45 | #endif |
46 | config()->setGroup("SyncOptions"); | 46 | config()->setGroup("SyncOptions"); |
47 | addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); | 47 | addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); |
48 | addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); | 48 | addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); |
49 | addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); | 49 | addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); |
50 | addItemBool("PassiveSyncWithDesktop",&mPassiveSyncWithDesktop,false ); | ||
51 | addItemBool("PassiveSyncAutoStart",&mPassiveSyncAutoStart,false ); | ||
50 | addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); | 52 | addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); |
51 | } | 53 | } |
52 | 54 | ||
53 | KPimPrefs::~KPimPrefs() | 55 | KPimPrefs::~KPimPrefs() |
54 | { | 56 | { |
55 | } | 57 | } |
56 | 58 | ||
57 | void KPimPrefs::usrSetDefaults() | 59 | void KPimPrefs::usrSetDefaults() |
58 | { | 60 | { |
59 | setCategoryDefaults(); | 61 | setCategoryDefaults(); |
60 | } | 62 | } |
61 | 63 | ||
62 | void KPimPrefs::usrReadConfig() | 64 | void KPimPrefs::usrReadConfig() |
63 | { | 65 | { |
64 | kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl; | 66 | kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl; |
65 | 67 | ||
66 | config()->setGroup("General"); | 68 | config()->setGroup("General"); |
67 | mCustomCategories = config()->readListEntry("Custom Categories"); | 69 | mCustomCategories = config()->readListEntry("Custom Categories"); |
68 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 70 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
69 | } | 71 | } |
70 | 72 | ||
71 | 73 | ||
72 | void KPimPrefs::usrWriteConfig() | 74 | void KPimPrefs::usrWriteConfig() |
73 | { | 75 | { |
74 | config()->setGroup("General"); | 76 | config()->setGroup("General"); |
75 | config()->writeEntry("Custom Categories",mCustomCategories); | 77 | config()->writeEntry("Custom Categories",mCustomCategories); |
76 | } | 78 | } |
77 | 79 | ||
78 | void KPimPrefs::setCategoryDefaults() | 80 | void KPimPrefs::setCategoryDefaults() |
79 | { | 81 | { |
80 | // empty implementation | 82 | // empty implementation |
81 | } | 83 | } |
82 | 84 | ||
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h index 9346f7d..c177bd6 100644 --- a/libkdepim/kpimprefs.h +++ b/libkdepim/kpimprefs.h | |||
@@ -1,71 +1,73 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 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 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef KPIMPREFS_H | 31 | #ifndef KPIMPREFS_H |
32 | #define KPIMPREFS_H | 32 | #define KPIMPREFS_H |
33 | 33 | ||
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | 35 | ||
36 | #include "kprefs.h" | 36 | #include "kprefs.h" |
37 | 37 | ||
38 | class KPimPrefs : public KPrefs | 38 | class KPimPrefs : public KPrefs |
39 | { | 39 | { |
40 | public: | 40 | public: |
41 | 41 | ||
42 | KPimPrefs( const QString &name = QString::null ); | 42 | KPimPrefs( const QString &name = QString::null ); |
43 | 43 | ||
44 | virtual ~KPimPrefs(); | 44 | virtual ~KPimPrefs(); |
45 | 45 | ||
46 | /** Set preferences to default values */ | 46 | /** Set preferences to default values */ |
47 | void usrSetDefaults(); | 47 | void usrSetDefaults(); |
48 | 48 | ||
49 | /** Read preferences from config file */ | 49 | /** Read preferences from config file */ |
50 | void usrReadConfig(); | 50 | void usrReadConfig(); |
51 | 51 | ||
52 | /** Write preferences to config file */ | 52 | /** Write preferences to config file */ |
53 | void usrWriteConfig(); | 53 | void usrWriteConfig(); |
54 | 54 | ||
55 | 55 | ||
56 | public: | 56 | public: |
57 | QStringList mCustomCategories; | 57 | QStringList mCustomCategories; |
58 | QString mPassiveSyncPort; | 58 | QString mPassiveSyncPort; |
59 | QString mPassiveSyncPw; | 59 | QString mPassiveSyncPw; |
60 | bool mPassiveSyncWithDesktop; | ||
61 | bool mPassiveSyncAutoStart; | ||
60 | int mRingSyncAlgoPrefs; | 62 | int mRingSyncAlgoPrefs; |
61 | QString mLastSyncedLocalFile; | 63 | QString mLastSyncedLocalFile; |
62 | 64 | ||
63 | 65 | ||
64 | protected: | 66 | protected: |
65 | virtual void setCategoryDefaults(); | 67 | virtual void setCategoryDefaults(); |
66 | 68 | ||
67 | 69 | ||
68 | 70 | ||
69 | }; | 71 | }; |
70 | 72 | ||
71 | #endif | 73 | #endif |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 40d8e47..75c0b2b 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,507 +1,536 @@ | |||
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 | 52 | ||
52 | #include <klocale.h> | 53 | #include <klocale.h> |
53 | #include <kglobal.h> | 54 | #include <kglobal.h> |
54 | #include <kconfig.h> | 55 | #include <kconfig.h> |
55 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
56 | 57 | ||
57 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 58 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
58 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) | 59 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) |
59 | { | 60 | { |
60 | mServerSocket = 0; | 61 | mServerSocket = 0; |
61 | bar = new QProgressBar ( 1, 0 ); | 62 | bar = new QProgressBar ( 1, 0 ); |
62 | bar->setCaption (""); | 63 | bar->setCaption (""); |
63 | 64 | ||
64 | int w = 300; | 65 | int w = 300; |
65 | if ( QApplication::desktop()->width() < 320 ) | 66 | if ( QApplication::desktop()->width() < 320 ) |
66 | w = 220; | 67 | w = 220; |
67 | int h = bar->sizeHint().height() ; | 68 | int h = bar->sizeHint().height() ; |
68 | int dw = QApplication::desktop()->width(); | 69 | int dw = QApplication::desktop()->width(); |
69 | int dh = QApplication::desktop()->height(); | 70 | int dh = QApplication::desktop()->height(); |
70 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 71 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
72 | if ( mPrefs->mPassiveSyncAutoStart ) | ||
73 | enableQuick( false ); | ||
71 | 74 | ||
72 | } | 75 | } |
73 | 76 | ||
74 | KSyncManager::~KSyncManager() | 77 | KSyncManager::~KSyncManager() |
75 | { | 78 | { |
76 | delete bar; | 79 | delete bar; |
77 | } | 80 | } |
78 | 81 | ||
79 | 82 | ||
80 | void KSyncManager::fillSyncMenu() | 83 | void KSyncManager::fillSyncMenu() |
81 | { | 84 | { |
82 | if ( mSyncMenu->count() ) | 85 | if ( mSyncMenu->count() ) |
83 | mSyncMenu->clear(); | 86 | mSyncMenu->clear(); |
84 | 87 | ||
85 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 88 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
86 | mSyncMenu->insertSeparator(); | 89 | mSyncMenu->insertSeparator(); |
87 | if ( mServerSocket == 0 ) { | 90 | if ( mServerSocket == 0 ) { |
88 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 91 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
89 | } else { | 92 | } else { |
90 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 93 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
91 | } | 94 | } |
92 | mSyncMenu->insertSeparator(); | 95 | mSyncMenu->insertSeparator(); |
93 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 96 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
94 | mSyncMenu->insertSeparator(); | 97 | mSyncMenu->insertSeparator(); |
95 | 98 | ||
96 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 99 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
97 | config.setGroup("General"); | 100 | config.setGroup("General"); |
98 | QStringList prof = config.readListEntry("SyncProfileNames"); | 101 | QStringList prof = config.readListEntry("SyncProfileNames"); |
99 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 102 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
100 | if ( prof.count() < 2 ) { | 103 | if ( prof.count() < 2 ) { |
101 | prof.clear(); | 104 | prof.clear(); |
102 | #ifdef DESKTOP_VERSION | 105 | #ifdef DESKTOP_VERSION |
103 | #ifdef _WIN32_ | 106 | #ifdef _WIN32_ |
104 | prof << i18n("OutLook(not_implemented)"); | 107 | prof << i18n("OutLook(not_implemented)"); |
105 | #else | 108 | #else |
106 | prof << i18n("KDE_Desktop"); | 109 | prof << i18n("KDE_Desktop"); |
107 | #endif | 110 | #endif |
108 | #else | 111 | #else |
109 | prof << i18n("Sharp_DTM"); | 112 | prof << i18n("Sharp_DTM"); |
110 | #endif | 113 | #endif |
111 | prof << i18n("Local_file"); | 114 | prof << i18n("Local_file"); |
112 | prof << i18n("Last_file"); | 115 | prof << i18n("Last_file"); |
113 | KSyncProfile* temp = new KSyncProfile (); | 116 | KSyncProfile* temp = new KSyncProfile (); |
114 | temp->setName( prof[0] ); | 117 | temp->setName( prof[0] ); |
115 | temp->writeConfig(&config); | 118 | temp->writeConfig(&config); |
116 | temp->setName( prof[1] ); | 119 | temp->setName( prof[1] ); |
117 | temp->writeConfig(&config); | 120 | temp->writeConfig(&config); |
118 | temp->setName( prof[2] ); | 121 | temp->setName( prof[2] ); |
119 | temp->writeConfig(&config); | 122 | temp->writeConfig(&config); |
120 | config.setGroup("General"); | 123 | config.setGroup("General"); |
121 | config.writeEntry("SyncProfileNames",prof); | 124 | config.writeEntry("SyncProfileNames",prof); |
122 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 125 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
123 | config.sync(); | 126 | config.sync(); |
124 | delete temp; | 127 | delete temp; |
125 | } | 128 | } |
126 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 129 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
127 | mSyncProfileNames = prof; | 130 | mSyncProfileNames = prof; |
128 | unsigned int i; | 131 | unsigned int i; |
129 | for ( i = 0; i < prof.count(); ++i ) { | 132 | for ( i = 0; i < prof.count(); ++i ) { |
130 | mSyncMenu->insertItem( prof[i], 1000+i ); | 133 | mSyncMenu->insertItem( prof[i], 1000+i ); |
131 | if ( i == 2 ) | 134 | if ( i == 2 ) |
132 | mSyncMenu->insertSeparator(); | 135 | mSyncMenu->insertSeparator(); |
133 | } | 136 | } |
134 | QDir app_dir; | 137 | QDir app_dir; |
135 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 138 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
136 | if ( mTargetApp == PWMPI) { | 139 | if ( mTargetApp == PWMPI) { |
137 | mSyncMenu->removeItem( 1000 ); | 140 | mSyncMenu->removeItem( 1000 ); |
138 | } | 141 | } |
139 | #ifndef DESKTOP_VERSION | 142 | #ifndef DESKTOP_VERSION |
140 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 143 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
141 | mSyncMenu->removeItem( 1000 ); | 144 | mSyncMenu->removeItem( 1000 ); |
142 | } | 145 | } |
143 | #endif | 146 | #endif |
144 | mSyncMenu->removeItem( 1002 ); | 147 | mSyncMenu->removeItem( 1002 ); |
145 | } | 148 | } |
146 | 149 | ||
147 | void KSyncManager::slotSyncMenu( int action ) | 150 | void KSyncManager::slotSyncMenu( int action ) |
148 | { | 151 | { |
149 | qDebug("syncaction %d ", action); | 152 | qDebug("syncaction %d ", action); |
150 | if ( action == 0 ) { | 153 | if ( action == 0 ) { |
151 | 154 | ||
152 | // seems to be a Qt2 event handling bug | 155 | // seems to be a Qt2 event handling bug |
153 | // syncmenu.clear causes a segfault at first time | 156 | // syncmenu.clear causes a segfault at first time |
154 | // when we call it after the main event loop, it is ok | 157 | // when we call it after the main event loop, it is ok |
155 | // same behaviour when calling OM/Pi via QCOP for the first time | 158 | // same behaviour when calling OM/Pi via QCOP for the first time |
156 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 159 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
157 | //confSync(); | 160 | //confSync(); |
158 | 161 | ||
159 | return; | 162 | return; |
160 | } | 163 | } |
161 | if ( action == 1 ) { | 164 | if ( action == 1 ) { |
162 | multiSync( true ); | 165 | multiSync( true ); |
163 | return; | 166 | return; |
164 | } | 167 | } |
165 | if ( action == 2 ) { | 168 | if ( action == 2 ) { |
166 | enableQuick(); | 169 | enableQuick(); |
167 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 170 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
168 | return; | 171 | return; |
169 | } | 172 | } |
170 | if ( action == 3 ) { | 173 | if ( action == 3 ) { |
171 | delete mServerSocket; | 174 | delete mServerSocket; |
172 | mServerSocket = 0; | 175 | mServerSocket = 0; |
173 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 176 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
174 | return; | 177 | return; |
175 | } | 178 | } |
176 | 179 | ||
177 | if (blockSave()) | 180 | if (blockSave()) |
178 | return; | 181 | return; |
179 | 182 | ||
180 | setBlockSave(true); | 183 | setBlockSave(true); |
181 | 184 | ||
182 | mCurrentSyncProfile = action - 1000 ; | 185 | mCurrentSyncProfile = action - 1000 ; |
183 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 186 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
184 | mCurrentSyncName = mLocalMachineName ; | 187 | mCurrentSyncName = mLocalMachineName ; |
185 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 188 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
186 | KSyncProfile* temp = new KSyncProfile (); | 189 | KSyncProfile* temp = new KSyncProfile (); |
187 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 190 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
188 | temp->readConfig(&config); | 191 | temp->readConfig(&config); |
189 | mAskForPreferences = temp->getAskForPreferences(); | 192 | mAskForPreferences = temp->getAskForPreferences(); |
190 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 193 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
191 | mWriteBackFile = temp->getWriteBackFile(); | 194 | mWriteBackFile = temp->getWriteBackFile(); |
192 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 195 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
193 | mIsKapiFile = temp->getIsKapiFile(); | 196 | mIsKapiFile = temp->getIsKapiFile(); |
194 | mWriteBackInFuture = 0; | 197 | mWriteBackInFuture = 0; |
195 | if ( temp->getWriteBackFuture() ) | 198 | if ( temp->getWriteBackFuture() ) |
196 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 199 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
197 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 200 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
198 | if ( action == 1000 ) { | 201 | if ( action == 1000 ) { |
199 | #ifdef DESKTOP_VERSION | 202 | #ifdef DESKTOP_VERSION |
200 | syncKDE(); | 203 | syncKDE(); |
201 | #else | 204 | #else |
202 | syncSharp(); | 205 | syncSharp(); |
203 | #endif | 206 | #endif |
204 | 207 | ||
205 | } else if ( action == 1001 ) { | 208 | } else if ( action == 1001 ) { |
206 | syncLocalFile(); | 209 | syncLocalFile(); |
207 | 210 | ||
208 | } else if ( action == 1002 ) { | 211 | } else if ( action == 1002 ) { |
209 | mWriteBackFile = false; | 212 | mWriteBackFile = false; |
210 | mAskForPreferences = false; | 213 | mAskForPreferences = false; |
211 | mShowSyncSummary = false; | 214 | mShowSyncSummary = false; |
212 | mSyncAlgoPrefs = 3; | 215 | mSyncAlgoPrefs = 3; |
213 | quickSyncLocalFile(); | 216 | quickSyncLocalFile(); |
214 | 217 | ||
215 | } else if ( action >= 1003 ) { | 218 | } else if ( action >= 1003 ) { |
216 | if ( temp->getIsLocalFileSync() ) { | 219 | if ( temp->getIsLocalFileSync() ) { |
217 | switch(mTargetApp) | 220 | switch(mTargetApp) |
218 | { | 221 | { |
219 | case (KAPI): | 222 | case (KAPI): |
220 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 223 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
221 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 224 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
222 | break; | 225 | break; |
223 | case (KOPI): | 226 | case (KOPI): |
224 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 227 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
225 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 228 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
226 | break; | 229 | break; |
227 | case (PWMPI): | 230 | case (PWMPI): |
228 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 231 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
229 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 232 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
230 | break; | 233 | break; |
231 | default: | 234 | default: |
232 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 235 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
233 | break; | 236 | break; |
234 | 237 | ||
235 | } | 238 | } |
236 | } else { | 239 | } else { |
237 | if ( temp->getIsPhoneSync() ) { | 240 | if ( temp->getIsPhoneSync() ) { |
238 | mPhoneDevice = temp->getPhoneDevice( ) ; | 241 | mPhoneDevice = temp->getPhoneDevice( ) ; |
239 | mPhoneConnection = temp->getPhoneConnection( ); | 242 | mPhoneConnection = temp->getPhoneConnection( ); |
240 | mPhoneModel = temp->getPhoneModel( ); | 243 | mPhoneModel = temp->getPhoneModel( ); |
241 | syncPhone(); | 244 | syncPhone(); |
242 | } else if ( temp->getIsPiSync() ) { | 245 | } else if ( temp->getIsPiSync() ) { |
243 | if ( mTargetApp == KAPI ) { | 246 | if ( mTargetApp == KAPI ) { |
244 | mPassWordPiSync = temp->getRemotePwAB(); | 247 | mPassWordPiSync = temp->getRemotePwAB(); |
245 | mActiveSyncPort = temp->getRemotePortAB(); | 248 | mActiveSyncPort = temp->getRemotePortAB(); |
246 | mActiveSyncIP = temp->getRemoteIPAB(); | 249 | mActiveSyncIP = temp->getRemoteIPAB(); |
247 | } else if ( mTargetApp == KOPI ) { | 250 | } else if ( mTargetApp == KOPI ) { |
248 | mPassWordPiSync = temp->getRemotePw(); | 251 | mPassWordPiSync = temp->getRemotePw(); |
249 | mActiveSyncPort = temp->getRemotePort(); | 252 | mActiveSyncPort = temp->getRemotePort(); |
250 | mActiveSyncIP = temp->getRemoteIP(); | 253 | mActiveSyncIP = temp->getRemoteIP(); |
251 | } else { | 254 | } else { |
252 | mPassWordPiSync = temp->getRemotePwPWM(); | 255 | mPassWordPiSync = temp->getRemotePwPWM(); |
253 | mActiveSyncPort = temp->getRemotePortPWM(); | 256 | mActiveSyncPort = temp->getRemotePortPWM(); |
254 | mActiveSyncIP = temp->getRemoteIPPWM(); | 257 | mActiveSyncIP = temp->getRemoteIPPWM(); |
255 | } | 258 | } |
256 | syncPi(); | 259 | syncPi(); |
257 | while ( !mPisyncFinished ) { | 260 | while ( !mPisyncFinished ) { |
258 | //qDebug("waiting "); | 261 | //qDebug("waiting "); |
259 | qApp->processEvents(); | 262 | qApp->processEvents(); |
260 | } | 263 | } |
261 | } else | 264 | } else |
262 | syncRemote( temp ); | 265 | syncRemote( temp ); |
263 | 266 | ||
264 | } | 267 | } |
265 | } | 268 | } |
266 | delete temp; | 269 | delete temp; |
267 | setBlockSave(false); | 270 | setBlockSave(false); |
268 | } | 271 | } |
269 | 272 | ||
270 | void KSyncManager::enableQuick() | 273 | void KSyncManager::enableQuick( bool ask ) |
271 | { | 274 | { |
272 | QDialog dia ( 0, "input-dialog", true ); | 275 | bool autoStart; |
273 | QLineEdit lab ( &dia ); | 276 | if ( ask ) { |
274 | QVBoxLayout lay( &dia ); | 277 | QDialog dia ( 0, "input-dialog", true ); |
275 | lab.setText( mPrefs->mPassiveSyncPort ); | 278 | QLineEdit lab ( &dia ); |
276 | lay.setMargin(7); | 279 | QVBoxLayout lay( &dia ); |
277 | lay.setSpacing(7); | 280 | lab.setText( mPrefs->mPassiveSyncPort ); |
278 | int po = 9197+mTargetApp; | 281 | lay.setMargin(7); |
279 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); | 282 | lay.setSpacing(7); |
280 | lay.addWidget( &label); | 283 | int po = 9197+mTargetApp; |
281 | lay.addWidget( &lab); | 284 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); |
282 | 285 | lay.addWidget( &label); | |
283 | QLineEdit lepw ( &dia ); | 286 | lay.addWidget( &lab); |
284 | lepw.setText( mPrefs->mPassiveSyncPw ); | 287 | |
285 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 288 | QLineEdit lepw ( &dia ); |
286 | lay.addWidget( &label2); | 289 | lepw.setText( mPrefs->mPassiveSyncPw ); |
287 | lay.addWidget( &lepw); | 290 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
288 | dia.setFixedSize( 230,80 ); | 291 | lay.addWidget( &label2); |
289 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 292 | lay.addWidget( &lepw); |
290 | QPushButton pb ( "OK", &dia); | 293 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
291 | lay.addWidget( &pb ); | 294 | lay.addWidget( &autostart); |
292 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 295 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
293 | dia.show(); | 296 | #ifdef DESKTOP_VERSION |
294 | if ( ! dia.exec() ) | 297 | #ifdef _WIN32_ |
295 | return; | 298 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
296 | dia.hide(); | 299 | #else |
297 | qApp->processEvents(); | 300 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
298 | mPrefs->mPassiveSyncPw = lepw.text(); | 301 | #endif |
299 | mPrefs->mPassiveSyncPort = lab.text(); | 302 | lay.addWidget( &syncdesktop); |
303 | #else | ||
304 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | ||
305 | syncdesktop.hide(); | ||
306 | #endif | ||
307 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | ||
308 | |||
309 | dia.setFixedSize( 230,120 ); | ||
310 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | ||
311 | QPushButton pb ( "OK", &dia); | ||
312 | lay.addWidget( &pb ); | ||
313 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | ||
314 | dia.show(); | ||
315 | if ( ! dia.exec() ) | ||
316 | return; | ||
317 | dia.hide(); | ||
318 | qApp->processEvents(); | ||
319 | mPrefs->mPassiveSyncPw = lepw.text(); | ||
320 | mPrefs->mPassiveSyncPort = lab.text(); | ||
321 | autoStart = autostart.isChecked(); | ||
322 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | ||
323 | } | ||
324 | else | ||
325 | autoStart = mPrefs->mPassiveSyncAutoStart; | ||
300 | bool ok; | 326 | bool ok; |
327 | mPrefs->mPassiveSyncAutoStart = false; | ||
301 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); | 328 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); |
302 | if ( ! ok ) { | 329 | if ( ! ok ) { |
303 | KMessageBox::information( 0, i18n("No valid port")); | 330 | KMessageBox::information( 0, i18n("No valid port")); |
304 | return; | 331 | return; |
305 | } | 332 | } |
306 | //qDebug("port %d ", port); | 333 | //qDebug("port %d ", port); |
307 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 334 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
308 | mServerSocket->setFileName( defaultFileName() ); | 335 | mServerSocket->setFileName( defaultFileName() ); |
309 | //qDebug("connected "); | 336 | //qDebug("connected "); |
310 | if ( !mServerSocket->ok() ) { | 337 | if ( !mServerSocket->ok() ) { |
311 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); | 338 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); |
312 | delete mServerSocket; | 339 | delete mServerSocket; |
313 | mServerSocket = 0; | 340 | mServerSocket = 0; |
314 | return; | 341 | return; |
315 | } | 342 | } |
343 | |||
344 | mPrefs->mPassiveSyncAutoStart = autoStart; | ||
316 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 345 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
317 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 346 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
318 | } | 347 | } |
319 | 348 | ||
320 | void KSyncManager::syncLocalFile() | 349 | void KSyncManager::syncLocalFile() |
321 | { | 350 | { |
322 | 351 | ||
323 | QString fn =mPrefs->mLastSyncedLocalFile; | 352 | QString fn =mPrefs->mLastSyncedLocalFile; |
324 | QString ext; | 353 | QString ext; |
325 | 354 | ||
326 | switch(mTargetApp) | 355 | switch(mTargetApp) |
327 | { | 356 | { |
328 | case (KAPI): | 357 | case (KAPI): |
329 | ext = "(*.vcf)"; | 358 | ext = "(*.vcf)"; |
330 | break; | 359 | break; |
331 | case (KOPI): | 360 | case (KOPI): |
332 | ext = "(*.ics/*.vcs)"; | 361 | ext = "(*.ics/*.vcs)"; |
333 | break; | 362 | break; |
334 | case (PWMPI): | 363 | case (PWMPI): |
335 | ext = "(*.pwm)"; | 364 | ext = "(*.pwm)"; |
336 | break; | 365 | break; |
337 | default: | 366 | default: |
338 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); | 367 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); |
339 | break; | 368 | break; |
340 | 369 | ||
341 | } | 370 | } |
342 | 371 | ||
343 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 372 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
344 | if ( fn == "" ) | 373 | if ( fn == "" ) |
345 | return; | 374 | return; |
346 | if ( syncWithFile( fn, false ) ) { | 375 | if ( syncWithFile( fn, false ) ) { |
347 | qDebug("syncLocalFile() successful "); | 376 | qDebug("syncLocalFile() successful "); |
348 | } | 377 | } |
349 | 378 | ||
350 | } | 379 | } |
351 | 380 | ||
352 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 381 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
353 | { | 382 | { |
354 | bool ret = false; | 383 | bool ret = false; |
355 | QFileInfo info; | 384 | QFileInfo info; |
356 | info.setFile( fn ); | 385 | info.setFile( fn ); |
357 | QString mess; | 386 | QString mess; |
358 | bool loadbup = true; | 387 | bool loadbup = true; |
359 | if ( !info. exists() ) { | 388 | if ( !info. exists() ) { |
360 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 389 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
361 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 390 | int result = QMessageBox::warning( mParent, i18n("Warning!"), |
362 | mess ); | 391 | mess ); |
363 | return ret; | 392 | return ret; |
364 | } | 393 | } |
365 | int result = 0; | 394 | int result = 0; |
366 | if ( !quick ) { | 395 | if ( !quick ) { |
367 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 396 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
368 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 397 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
369 | mess, | 398 | mess, |
370 | i18n("Sync"), i18n("Cancel"), 0, | 399 | i18n("Sync"), i18n("Cancel"), 0, |
371 | 0, 1 ); | 400 | 0, 1 ); |
372 | if ( result ) | 401 | if ( result ) |
373 | return false; | 402 | return false; |
374 | } | 403 | } |
375 | if ( mAskForPreferences ) | 404 | if ( mAskForPreferences ) |
376 | edit_sync_options(); | 405 | edit_sync_options(); |
377 | if ( result == 0 ) { | 406 | if ( result == 0 ) { |
378 | //qDebug("Now sycing ... "); | 407 | //qDebug("Now sycing ... "); |
379 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 408 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
380 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 409 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
381 | else | 410 | else |
382 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 411 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
383 | if ( ! quick ) | 412 | if ( ! quick ) |
384 | mPrefs->mLastSyncedLocalFile = fn; | 413 | mPrefs->mLastSyncedLocalFile = fn; |
385 | } | 414 | } |
386 | return ret; | 415 | return ret; |
387 | } | 416 | } |
388 | 417 | ||
389 | void KSyncManager::quickSyncLocalFile() | 418 | void KSyncManager::quickSyncLocalFile() |
390 | { | 419 | { |
391 | 420 | ||
392 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 421 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
393 | qDebug("quick syncLocalFile() successful "); | 422 | qDebug("quick syncLocalFile() successful "); |
394 | 423 | ||
395 | } | 424 | } |
396 | } | 425 | } |
397 | 426 | ||
398 | void KSyncManager::multiSync( bool askforPrefs ) | 427 | void KSyncManager::multiSync( bool askforPrefs ) |
399 | { | 428 | { |
400 | if (blockSave()) | 429 | if (blockSave()) |
401 | return; | 430 | return; |
402 | setBlockSave(true); | 431 | setBlockSave(true); |
403 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 432 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
404 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 433 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
405 | question, | 434 | question, |
406 | i18n("Yes"), i18n("No"), | 435 | i18n("Yes"), i18n("No"), |
407 | 0, 0 ) != 0 ) { | 436 | 0, 0 ) != 0 ) { |
408 | setBlockSave(false); | 437 | setBlockSave(false); |
409 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 438 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
410 | return; | 439 | return; |
411 | } | 440 | } |
412 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 441 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
413 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 442 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
414 | if ( askforPrefs ) { | 443 | if ( askforPrefs ) { |
415 | edit_sync_options(); | 444 | edit_sync_options(); |
416 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 445 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
417 | } | 446 | } |
418 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 447 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
419 | qApp->processEvents(); | 448 | qApp->processEvents(); |
420 | int num = ringSync() ; | 449 | int num = ringSync() ; |
421 | if ( num > 1 ) | 450 | if ( num > 1 ) |
422 | ringSync(); | 451 | ringSync(); |
423 | setBlockSave(false); | 452 | setBlockSave(false); |
424 | if ( num ) | 453 | if ( num ) |
425 | emit save(); | 454 | emit save(); |
426 | if ( num ) | 455 | if ( num ) |
427 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 456 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
428 | else | 457 | else |
429 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 458 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
430 | return; | 459 | return; |
431 | } | 460 | } |
432 | 461 | ||
433 | int KSyncManager::ringSync() | 462 | int KSyncManager::ringSync() |
434 | { | 463 | { |
435 | int syncedProfiles = 0; | 464 | int syncedProfiles = 0; |
436 | unsigned int i; | 465 | unsigned int i; |
437 | QTime timer; | 466 | QTime timer; |
438 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 467 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
439 | QStringList syncProfileNames = mSyncProfileNames; | 468 | QStringList syncProfileNames = mSyncProfileNames; |
440 | KSyncProfile* temp = new KSyncProfile (); | 469 | KSyncProfile* temp = new KSyncProfile (); |
441 | mAskForPreferences = false; | 470 | mAskForPreferences = false; |
442 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 471 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
443 | mCurrentSyncProfile = i; | 472 | mCurrentSyncProfile = i; |
444 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 473 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
445 | temp->readConfig(&config); | 474 | temp->readConfig(&config); |
446 | 475 | ||
447 | bool includeInRingSync; | 476 | bool includeInRingSync; |
448 | switch(mTargetApp) | 477 | switch(mTargetApp) |
449 | { | 478 | { |
450 | case (KAPI): | 479 | case (KAPI): |
451 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 480 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
452 | break; | 481 | break; |
453 | case (KOPI): | 482 | case (KOPI): |
454 | includeInRingSync = temp->getIncludeInRingSync(); | 483 | includeInRingSync = temp->getIncludeInRingSync(); |
455 | break; | 484 | break; |
456 | case (PWMPI): | 485 | case (PWMPI): |
457 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 486 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
458 | break; | 487 | break; |
459 | default: | 488 | default: |
460 | qDebug("KSyncManager::ringSync: invalid apptype selected"); | 489 | qDebug("KSyncManager::ringSync: invalid apptype selected"); |
461 | break; | 490 | break; |
462 | 491 | ||
463 | } | 492 | } |
464 | 493 | ||
465 | 494 | ||
466 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 495 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
467 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 496 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
468 | ++syncedProfiles; | 497 | ++syncedProfiles; |
469 | // mAskForPreferences = temp->getAskForPreferences(); | 498 | // mAskForPreferences = temp->getAskForPreferences(); |
470 | mWriteBackFile = temp->getWriteBackFile(); | 499 | mWriteBackFile = temp->getWriteBackFile(); |
471 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 500 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
472 | mWriteBackInFuture = 0; | 501 | mWriteBackInFuture = 0; |
473 | if ( temp->getWriteBackFuture() ) | 502 | if ( temp->getWriteBackFuture() ) |
474 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 503 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
475 | mShowSyncSummary = false; | 504 | mShowSyncSummary = false; |
476 | mCurrentSyncDevice = syncProfileNames[i] ; | 505 | mCurrentSyncDevice = syncProfileNames[i] ; |
477 | mCurrentSyncName = mLocalMachineName; | 506 | mCurrentSyncName = mLocalMachineName; |
478 | if ( i == 0 ) { | 507 | if ( i == 0 ) { |
479 | #ifdef DESKTOP_VERSION | 508 | #ifdef DESKTOP_VERSION |
480 | syncKDE(); | 509 | syncKDE(); |
481 | #else | 510 | #else |
482 | syncSharp(); | 511 | syncSharp(); |
483 | #endif | 512 | #endif |
484 | } else { | 513 | } else { |
485 | if ( temp->getIsLocalFileSync() ) { | 514 | if ( temp->getIsLocalFileSync() ) { |
486 | switch(mTargetApp) | 515 | switch(mTargetApp) |
487 | { | 516 | { |
488 | case (KAPI): | 517 | case (KAPI): |
489 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 518 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
490 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 519 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
491 | break; | 520 | break; |
492 | case (KOPI): | 521 | case (KOPI): |
493 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 522 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
494 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 523 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
495 | break; | 524 | break; |
496 | case (PWMPI): | 525 | case (PWMPI): |
497 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 526 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
498 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 527 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
499 | break; | 528 | break; |
500 | default: | 529 | default: |
501 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 530 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
502 | break; | 531 | break; |
503 | } | 532 | } |
504 | } else { | 533 | } else { |
505 | if ( temp->getIsPhoneSync() ) { | 534 | if ( temp->getIsPhoneSync() ) { |
506 | mPhoneDevice = temp->getPhoneDevice( ) ; | 535 | mPhoneDevice = temp->getPhoneDevice( ) ; |
507 | mPhoneConnection = temp->getPhoneConnection( ); | 536 | mPhoneConnection = temp->getPhoneConnection( ); |
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index ffb1ea4..7b9c499 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -1,211 +1,211 @@ | |||
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 | ||
33 | class QPopupMenu; | 33 | class QPopupMenu; |
34 | class KSyncProfile; | 34 | class KSyncProfile; |
35 | class KPimPrefs; | 35 | class KPimPrefs; |
36 | class QWidget; | 36 | class QWidget; |
37 | class KSyncManager; | 37 | class KSyncManager; |
38 | class KSyncInterface; | 38 | class KSyncInterface; |
39 | class QProgressBar; | 39 | class QProgressBar; |
40 | 40 | ||
41 | 41 | ||
42 | class KServerSocket : public QServerSocket | 42 | class 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 | ||
73 | class KCommandSocket : public QObject | 73 | class 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 | ||
104 | class KSyncManager : public QObject | 104 | class 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 | 124 | ||
124 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 125 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
125 | QString getCurrentSyncName() { return mCurrentSyncName; } | 126 | QString getCurrentSyncName() { return mCurrentSyncName; } |
126 | 127 | ||
127 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 128 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
128 | void hideProgressBar(); | 129 | void hideProgressBar(); |
129 | bool isProgressBarCanceled(); | 130 | bool isProgressBarCanceled(); |
130 | 131 | ||
131 | // sync stuff | 132 | // sync stuff |
132 | QString mLocalMachineName; | 133 | QString mLocalMachineName; |
133 | QStringList mExternSyncProfiles; | 134 | QStringList mExternSyncProfiles; |
134 | QStringList mSyncProfileNames; | 135 | QStringList mSyncProfileNames; |
135 | bool mAskForPreferences; | 136 | bool mAskForPreferences; |
136 | bool mShowSyncSummary; | 137 | bool mShowSyncSummary; |
137 | bool mIsKapiFile; | 138 | bool mIsKapiFile; |
138 | bool mWriteBackExistingOnly; | 139 | bool mWriteBackExistingOnly; |
139 | int mSyncAlgoPrefs; | 140 | int mSyncAlgoPrefs; |
140 | bool mWriteBackFile; | 141 | bool mWriteBackFile; |
141 | int mWriteBackInFuture; | 142 | int mWriteBackInFuture; |
142 | QString mPhoneDevice; | 143 | QString mPhoneDevice; |
143 | QString mPhoneConnection; | 144 | QString mPhoneConnection; |
144 | QString mPhoneModel; | 145 | QString mPhoneModel; |
145 | QString mPassWordPiSync; | 146 | QString mPassWordPiSync; |
146 | QString mActiveSyncPort; | 147 | QString mActiveSyncPort; |
147 | QString mActiveSyncIP ; | 148 | QString mActiveSyncIP ; |
148 | 149 | ||
149 | signals: | 150 | signals: |
150 | void save(); | 151 | void save(); |
151 | void request_file(); | 152 | void request_file(); |
152 | void getFile( bool ); | 153 | void getFile( bool ); |
153 | 154 | ||
154 | public slots: | 155 | public slots: |
155 | void slotSyncMenu( int ); | 156 | void slotSyncMenu( int ); |
156 | void deleteCommandSocket(KCommandSocket*s, int state); | 157 | void deleteCommandSocket(KCommandSocket*s, int state); |
157 | void readFileFromSocket(); | 158 | void readFileFromSocket(); |
158 | void fillSyncMenu(); | 159 | void fillSyncMenu(); |
159 | 160 | ||
160 | private: | 161 | private: |
161 | void syncPi(); | 162 | void syncPi(); |
162 | KServerSocket * mServerSocket; | 163 | KServerSocket * mServerSocket; |
163 | void enableQuick(); | ||
164 | KPimPrefs* mPrefs; | 164 | KPimPrefs* mPrefs; |
165 | QString mDefFileName; | 165 | QString mDefFileName; |
166 | QString mCurrentSyncDevice; | 166 | QString mCurrentSyncDevice; |
167 | QString mCurrentSyncName; | 167 | QString mCurrentSyncName; |
168 | void quickSyncLocalFile(); | 168 | void quickSyncLocalFile(); |
169 | bool syncWithFile( QString fn , bool quick ); | 169 | bool syncWithFile( QString fn , bool quick ); |
170 | void syncLocalFile(); | 170 | void syncLocalFile(); |
171 | void syncPhone(); | 171 | void syncPhone(); |
172 | void syncSharp(); | 172 | void syncSharp(); |
173 | void syncKDE(); | 173 | void syncKDE(); |
174 | bool syncExternalApplication(QString); | 174 | bool syncExternalApplication(QString); |
175 | int mCurrentSyncProfile ; | 175 | int mCurrentSyncProfile ; |
176 | void syncRemote( KSyncProfile* prof, bool ask = true); | 176 | void syncRemote( KSyncProfile* prof, bool ask = true); |
177 | void edit_sync_options(); | 177 | void edit_sync_options(); |
178 | void edit_pisync_options(); | 178 | void edit_pisync_options(); |
179 | int ringSync(); | 179 | int ringSync(); |
180 | QString getPassword( ); | 180 | QString getPassword( ); |
181 | bool mPisyncFinished; | 181 | bool mPisyncFinished; |
182 | bool mBlockSaveFlag; | 182 | bool mBlockSaveFlag; |
183 | QWidget* mParent; | 183 | QWidget* mParent; |
184 | KSyncInterface* mImplementation; | 184 | KSyncInterface* mImplementation; |
185 | TargetApp mTargetApp; | 185 | TargetApp mTargetApp; |
186 | QPopupMenu* mSyncMenu; | 186 | QPopupMenu* mSyncMenu; |
187 | QProgressBar* bar; | 187 | QProgressBar* bar; |
188 | 188 | ||
189 | private slots: | 189 | private slots: |
190 | void confSync(); | 190 | void confSync(); |
191 | 191 | ||
192 | 192 | ||
193 | }; | 193 | }; |
194 | 194 | ||
195 | 195 | ||
196 | class KSyncInterface | 196 | class KSyncInterface |
197 | { | 197 | { |
198 | public : | 198 | public : |
199 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; | 199 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; |
200 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 200 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
201 | { | 201 | { |
202 | // empty implementation, because some syncable applications do not | 202 | // empty implementation, because some syncable applications do not |
203 | // have an external(sharpdtm) syncmode, like pwmanager. | 203 | // have an external(sharpdtm) syncmode, like pwmanager. |
204 | return false; | 204 | return false; |
205 | } | 205 | } |
206 | 206 | ||
207 | 207 | ||
208 | }; | 208 | }; |
209 | 209 | ||
210 | 210 | ||
211 | #endif | 211 | #endif |