author | zautrix <zautrix> | 2004-10-05 07:22:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-05 07:22:35 (UTC) |
commit | fc2c103f45a6d4e4105259436266538c645f2c87 (patch) (unidiff) | |
tree | 7cab481e080b7db555129a17735152051882a31c | |
parent | 0dd4cb1ff2bbd47788a5220363758226e5639edf (diff) | |
download | kdepimpi-fc2c103f45a6d4e4105259436266538c645f2c87.zip kdepimpi-fc2c103f45a6d4e4105259436266538c645f2c87.tar.gz kdepimpi-fc2c103f45a6d4e4105259436266538c645f2c87.tar.bz2 |
sync fixes
-rw-r--r-- | korganizer/mainwindow.cpp | 113 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 10 |
2 files changed, 48 insertions, 75 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index b7176a1..5aa75f5 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1238,96 +1238,104 @@ void MainWindow::keyBindings() | |||
1238 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1238 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1239 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1239 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1240 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1240 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1241 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1241 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1242 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1242 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1243 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1243 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1244 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1244 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1245 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1245 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1246 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1246 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1247 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1247 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1248 | displayText( text, cap); | 1248 | displayText( text, cap); |
1249 | 1249 | ||
1250 | } | 1250 | } |
1251 | void MainWindow::aboutAutoSaving() | 1251 | void MainWindow::aboutAutoSaving() |
1252 | { | 1252 | { |
1253 | QMessageBox* msg; | 1253 | QMessageBox* msg; |
1254 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1254 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1255 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, | 1255 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, |
1256 | QMessageBox::Ok, | 1256 | QMessageBox::Ok, |
1257 | QMessageBox::NoButton, | 1257 | QMessageBox::NoButton, |
1258 | QMessageBox::NoButton); | 1258 | QMessageBox::NoButton); |
1259 | msg->exec(); | 1259 | msg->exec(); |
1260 | delete msg; | 1260 | delete msg; |
1261 | 1261 | ||
1262 | 1262 | ||
1263 | } | 1263 | } |
1264 | void MainWindow::aboutKnownBugs() | 1264 | void MainWindow::aboutKnownBugs() |
1265 | { | 1265 | { |
1266 | QMessageBox* msg; | 1266 | QMessageBox* msg; |
1267 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1267 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1268 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1268 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1269 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1269 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1270 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1270 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1271 | i18n("\nor report them in the bugtracker on\n") + | 1271 | i18n("\nor report them in the bugtracker on\n") + |
1272 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1272 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1273 | QMessageBox::NoIcon, | 1273 | QMessageBox::NoIcon, |
1274 | QMessageBox::Ok, | 1274 | QMessageBox::Ok, |
1275 | QMessageBox::NoButton, | 1275 | QMessageBox::NoButton, |
1276 | QMessageBox::NoButton); | 1276 | QMessageBox::NoButton); |
1277 | msg->exec(); | 1277 | msg->exec(); |
1278 | delete msg; | 1278 | delete msg; |
1279 | 1279 | ||
1280 | } | 1280 | } |
1281 | 1281 | ||
1282 | QString MainWindow::defaultFileName() | 1282 | QString MainWindow::defaultFileName() |
1283 | { | 1283 | { |
1284 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1284 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1285 | } | 1285 | } |
1286 | QString MainWindow::syncFileName() | ||
1287 | { | ||
1288 | #ifdef _WIN32_ | ||
1289 | return locateLocal( "tmp", "synccalendar.ics" ); | ||
1290 | #else | ||
1291 | return QString( "/tmp/kopitempfile.ics" ); | ||
1292 | #endif | ||
1293 | } | ||
1286 | 1294 | ||
1287 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1295 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1288 | { | 1296 | { |
1289 | if ( !incidence ) { | 1297 | if ( !incidence ) { |
1290 | enableIncidenceActions( false ); | 1298 | enableIncidenceActions( false ); |
1291 | 1299 | ||
1292 | mNewSubTodoAction->setEnabled( false ); | 1300 | mNewSubTodoAction->setEnabled( false ); |
1293 | setCaptionToDates(); | 1301 | setCaptionToDates(); |
1294 | return; | 1302 | return; |
1295 | 1303 | ||
1296 | } | 1304 | } |
1297 | 1305 | ||
1298 | //KGlobal::locale()->formatDateTime(nextA, true); | 1306 | //KGlobal::locale()->formatDateTime(nextA, true); |
1299 | QString startString = ""; | 1307 | QString startString = ""; |
1300 | if ( incidence->type() != "Todo" ) { | 1308 | if ( incidence->type() != "Todo" ) { |
1301 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1309 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1302 | if ( incidence->doesFloat() ) { | 1310 | if ( incidence->doesFloat() ) { |
1303 | startString += ": "+incidence->dtStartDateStr( true ); | 1311 | startString += ": "+incidence->dtStartDateStr( true ); |
1304 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1312 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1305 | 1313 | ||
1306 | } else { | 1314 | } else { |
1307 | startString = ": "+incidence->dtStartStr(true); | 1315 | startString = ": "+incidence->dtStartStr(true); |
1308 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1316 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1309 | 1317 | ||
1310 | } | 1318 | } |
1311 | 1319 | ||
1312 | } else { | 1320 | } else { |
1313 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1321 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1314 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1322 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1315 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1323 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1316 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1324 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1317 | } | 1325 | } |
1318 | 1326 | ||
1319 | } | 1327 | } |
1320 | else | 1328 | else |
1321 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1329 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1322 | if ( !incidence->location().isEmpty() ) | 1330 | if ( !incidence->location().isEmpty() ) |
1323 | startString += " (" +incidence->location()+")"; | 1331 | startString += " (" +incidence->location()+")"; |
1324 | setCaption( incidence->summary()+startString); | 1332 | setCaption( incidence->summary()+startString); |
1325 | 1333 | ||
1326 | enableIncidenceActions( true ); | 1334 | enableIncidenceActions( true ); |
1327 | 1335 | ||
1328 | if ( incidence->type() == "Event" ) { | 1336 | if ( incidence->type() == "Event" ) { |
1329 | mShowAction->setText( i18n("Show Event...") ); | 1337 | mShowAction->setText( i18n("Show Event...") ); |
1330 | mEditAction->setText( i18n("Edit Event...") ); | 1338 | mEditAction->setText( i18n("Edit Event...") ); |
1331 | mDeleteAction->setText( i18n("Delete Event...") ); | 1339 | mDeleteAction->setText( i18n("Delete Event...") ); |
1332 | 1340 | ||
1333 | mNewSubTodoAction->setEnabled( false ); | 1341 | mNewSubTodoAction->setEnabled( false ); |
@@ -1879,220 +1887,186 @@ QString MainWindow::getPassword( ) | |||
1879 | if ( res ) | 1887 | if ( res ) |
1880 | retfile = lab.text(); | 1888 | retfile = lab.text(); |
1881 | dia.hide(); | 1889 | dia.hide(); |
1882 | qApp->processEvents(); | 1890 | qApp->processEvents(); |
1883 | return retfile; | 1891 | return retfile; |
1884 | 1892 | ||
1885 | } | 1893 | } |
1886 | 1894 | ||
1887 | void MainWindow::enableQuick() | 1895 | void MainWindow::enableQuick() |
1888 | { | 1896 | { |
1889 | QString passWordPiSync = "bhdrvmk"; | 1897 | QString passWordPiSync = "bhdrvmk"; |
1890 | QString retfile = ""; | 1898 | QString retfile = ""; |
1891 | QDialog dia ( this, "input-dialog", true ); | 1899 | QDialog dia ( this, "input-dialog", true ); |
1892 | QLineEdit lab ( &dia ); | 1900 | QLineEdit lab ( &dia ); |
1893 | QVBoxLayout lay( &dia ); | 1901 | QVBoxLayout lay( &dia ); |
1894 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); | 1902 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); |
1895 | lay.setMargin(7); | 1903 | lay.setMargin(7); |
1896 | lay.setSpacing(7); | 1904 | lay.setSpacing(7); |
1897 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); | 1905 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); |
1898 | lay.addWidget( &label); | 1906 | lay.addWidget( &label); |
1899 | lay.addWidget( &lab); | 1907 | lay.addWidget( &lab); |
1900 | 1908 | ||
1901 | QLineEdit lepw ( &dia ); | 1909 | QLineEdit lepw ( &dia ); |
1902 | lepw.setText( "abc" ); | 1910 | lepw.setText( "abc" ); |
1903 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 1911 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
1904 | lay.addWidget( &label2); | 1912 | lay.addWidget( &label2); |
1905 | lay.addWidget( &lepw); | 1913 | lay.addWidget( &lepw); |
1906 | dia.setFixedSize( 230,80 ); | 1914 | dia.setFixedSize( 230,80 ); |
1907 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 1915 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
1908 | QPushButton pb ( "OK", &dia); | 1916 | QPushButton pb ( "OK", &dia); |
1909 | lay.addWidget( &pb ); | 1917 | lay.addWidget( &pb ); |
1910 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1918 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1911 | dia.show(); | 1919 | dia.show(); |
1912 | int res = dia.exec(); | 1920 | int res = dia.exec(); |
1913 | if ( res ) | 1921 | if ( res ) |
1914 | retfile = lab.text(); | 1922 | retfile = lab.text(); |
1915 | else | 1923 | else |
1916 | return; | 1924 | return; |
1917 | dia.hide(); | 1925 | dia.hide(); |
1918 | passWordPiSync = lepw.text(); | 1926 | passWordPiSync = lepw.text(); |
1919 | qApp->processEvents(); | 1927 | qApp->processEvents(); |
1920 | KOPrefs::instance()->mPassiveSyncPort = retfile; | 1928 | KOPrefs::instance()->mPassiveSyncPort = retfile; |
1921 | bool ok; | 1929 | bool ok; |
1922 | Q_UINT16 port = retfile.toUInt(&ok); | 1930 | Q_UINT16 port = retfile.toUInt(&ok); |
1923 | if ( ! ok ) { | 1931 | if ( ! ok ) { |
1924 | KMessageBox::information( this, i18n("No valid port")); | 1932 | KMessageBox::information( this, i18n("No valid port")); |
1925 | return; | 1933 | return; |
1926 | } | 1934 | } |
1927 | qDebug("port %d ", port); | 1935 | //qDebug("port %d ", port); |
1928 | mServerSocket = new KServerSocket ( passWordPiSync, port ,1 ); | 1936 | mServerSocket = new KServerSocket ( passWordPiSync, port ,1 ); |
1929 | mServerSocket->setFileName( defaultFileName() ); | 1937 | mServerSocket->setFileName( defaultFileName() ); |
1930 | qDebug("connected "); | 1938 | //qDebug("connected "); |
1931 | if ( !mServerSocket->ok() ) { | 1939 | if ( !mServerSocket->ok() ) { |
1932 | qWarning("Failed to bind to port %d", port); | 1940 | qWarning("Failed to bind to port %d", port); |
1933 | delete mServerSocket; | 1941 | delete mServerSocket; |
1934 | mServerSocket = 0; | 1942 | mServerSocket = 0; |
1935 | return; | 1943 | return; |
1936 | } | 1944 | } |
1937 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); | 1945 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); |
1938 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); | 1946 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); |
1939 | // connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); | ||
1940 | //connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); | ||
1941 | } | 1947 | } |
1942 | 1948 | ||
1943 | void MainWindow::getFile( bool success ) | 1949 | void MainWindow::getFile( bool success ) |
1944 | { | 1950 | { |
1945 | if ( ! success ) { | 1951 | if ( ! success ) { |
1946 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 1952 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
1947 | return; | 1953 | return; |
1948 | } | 1954 | } |
1949 | // pending adjust time for watchSavedFile() | 1955 | // pending adjust time for watchSavedFile() |
1950 | //mView->watchSavedFile(); | 1956 | //mView->watchSavedFile(); |
1951 | mView->openCalendar( defaultFileName() ); | 1957 | mView->openCalendar( defaultFileName() ); |
1952 | setCaption( i18n("Pi-Sync successful!") ); | 1958 | setCaption( i18n("Pi-Sync successful!") ); |
1953 | 1959 | ||
1954 | } | 1960 | } |
1955 | 1961 | ||
1956 | 1962 | ||
1957 | void MainWindow::syncPi() | 1963 | void MainWindow::syncPi() |
1958 | { | 1964 | { |
1959 | qApp->processEvents(); | 1965 | qApp->processEvents(); |
1960 | performQuickQuick(); | 1966 | performQuickQuick(); |
1961 | } | 1967 | } |
1962 | 1968 | ||
1963 | void MainWindow::performQuickQuick() | 1969 | void MainWindow::performQuickQuick() |
1964 | { | 1970 | { |
1965 | // setCaption( i18n("") ); | ||
1966 | |||
1967 | bool ok; | 1971 | bool ok; |
1968 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); | 1972 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); |
1969 | if ( ! ok ) { | 1973 | if ( ! ok ) { |
1970 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1974 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1971 | return; | 1975 | return; |
1972 | } | 1976 | } |
1973 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); | 1977 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); |
1974 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, bool )), this, SLOT(deleteCommandSocket(KCommandSocket*,bool)) ); | 1978 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1975 | setCaption( i18n("Sending request for remote file ...") ); | 1979 | setCaption( i18n("Sending request for remote file ...") ); |
1976 | QString fileName; | 1980 | commandSocket->readFile( syncFileName() ); |
1977 | #ifdef _WIN32_ | ||
1978 | fileName = defaultFileName() +"sync"; | ||
1979 | #else | ||
1980 | fileName = "/tmp/kopitempfile.ics"; | ||
1981 | #endif | ||
1982 | commandSocket->readFile( fileName ); | ||
1983 | } | 1981 | } |
1984 | void MainWindow::deleteCommandSocket(KCommandSocket*s, bool success) | 1982 | void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) |
1985 | { | 1983 | { |
1986 | if ( ! success ) { | 1984 | qDebug("MainWindow::deleteCommandSocket %d", state); |
1987 | setCaption( i18n("ERROR:Receiving remote file failed.") ); | 1985 | |
1986 | //enum { success, errorW, errorR, quiet }; | ||
1987 | if ( state == KCommandSocket::errorR ) { | ||
1988 | setCaption( i18n("ERROR: Receiving remote file failed.") ); | ||
1988 | delete s; | 1989 | delete s; |
1989 | // pending : send stop | 1990 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); |
1991 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | ||
1992 | commandSocket->sendStop(); | ||
1990 | return; | 1993 | return; |
1991 | 1994 | ||
1992 | } | 1995 | } else if ( state == KCommandSocket::errorW ) { |
1993 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | ||
1994 | qDebug("MainWindow::deleteCommandSocket "); | ||
1995 | delete s; | ||
1996 | } | ||
1997 | void MainWindow::deleteCommandSocketFinish(KCommandSocket* s, bool success ) | ||
1998 | { | ||
1999 | if ( ! success ) { | ||
2000 | setCaption( i18n("ERROR:Writing back file failed.") ); | 1996 | setCaption( i18n("ERROR:Writing back file failed.") ); |
2001 | } else { | 1997 | |
2002 | qDebug("Syncing succesful! "); | 1998 | } else if ( state == KCommandSocket::successR ) { |
1999 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | ||
2000 | |||
2001 | } else if ( state == KCommandSocket::successW ) { | ||
2003 | setCaption( i18n("Pi-Sync succesful!") ); | 2002 | setCaption( i18n("Pi-Sync succesful!") ); |
2004 | } | 2003 | } |
2005 | qDebug("MainWindow::deleteCommandSocketFinish "); | 2004 | |
2006 | delete s; | 2005 | delete s; |
2007 | } | 2006 | } |
2007 | |||
2008 | void MainWindow::readFileFromSocket() | 2008 | void MainWindow::readFileFromSocket() |
2009 | { | 2009 | { |
2010 | // mTimerCommandSocket->stop(); | 2010 | QString fileName = syncFileName(); |
2011 | setCaption( i18n("Receiving remote file ...") ); | ||
2012 | qDebug("MainWindow::readFileFromSocket() "); | ||
2013 | QString fileName; | ||
2014 | #ifdef _WIN32_ | ||
2015 | fileName = defaultFileName() +"sync"; | ||
2016 | #else | ||
2017 | fileName = "/tmp/kopitempfile.ics"; | ||
2018 | #endif | ||
2019 | |||
2020 | setCaption( i18n("Remote file saved to temp file.") ); | ||
2021 | //mCommandSocket = 0; | ||
2022 | mCurrentSyncProfile = 2 ; // last file | ||
2023 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | ||
2024 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | ||
2025 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | ||
2026 | KSyncProfile* temp = new KSyncProfile (); | ||
2027 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | ||
2028 | temp->readConfig(&config); | ||
2029 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | ||
2030 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | ||
2031 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | ||
2032 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | ||
2033 | KOPrefs::instance()->mWriteBackInFuture = 0; | ||
2034 | if ( temp->getWriteBackFuture() ) | ||
2035 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
2036 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | ||
2037 | delete temp; | ||
2038 | setCaption( i18n("Remote file saved to temp file.") ); | 2011 | setCaption( i18n("Remote file saved to temp file.") ); |
2039 | if ( ! syncWithFile( fileName , true ) ) { | 2012 | if ( ! syncWithFile( fileName , true ) ) { |
2040 | setCaption( i18n("Syncing failed.") ); | 2013 | setCaption( i18n("Syncing failed.") ); |
2041 | qDebug("Syncing failed "); | 2014 | qDebug("Syncing failed "); |
2042 | return; | 2015 | return; |
2043 | } | 2016 | } |
2044 | |||
2045 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); | 2017 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); |
2046 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, bool )), this, SLOT(deleteCommandSocketFinish(KCommandSocket*,bool)) ); | 2018 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
2047 | if ( KOPrefs::instance()->mWriteBackFile ) | 2019 | if ( KOPrefs::instance()->mWriteBackFile ) |
2048 | commandSocket->writeFile( fileName ); | 2020 | commandSocket->writeFile( fileName ); |
2049 | else | 2021 | else { |
2050 | commandSocket->sendStop(); | 2022 | commandSocket->sendStop(); |
2023 | setCaption( i18n("Pi-Sync succesful!") ); | ||
2024 | } | ||
2051 | } | 2025 | } |
2052 | 2026 | ||
2053 | void MainWindow::syncLocalFile() | 2027 | void MainWindow::syncLocalFile() |
2054 | { | 2028 | { |
2055 | 2029 | ||
2056 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | 2030 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; |
2057 | 2031 | ||
2058 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2032 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2059 | if ( fn == "" ) | 2033 | if ( fn == "" ) |
2060 | return; | 2034 | return; |
2061 | //mView->setSyncDevice("local-file" ); | 2035 | //mView->setSyncDevice("local-file" ); |
2062 | if ( syncWithFile( fn, false ) ) { | 2036 | if ( syncWithFile( fn, false ) ) { |
2063 | // Event* e = mView->getLastSyncEvent(); | 2037 | // Event* e = mView->getLastSyncEvent(); |
2064 | // e->setReadOnly( false ); | 2038 | // e->setReadOnly( false ); |
2065 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2039 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2066 | // e->setReadOnly( true ); | 2040 | // e->setReadOnly( true ); |
2067 | } | 2041 | } |
2068 | 2042 | ||
2069 | } | 2043 | } |
2070 | 2044 | ||
2071 | bool MainWindow::syncWithFile( QString fn , bool quick ) | 2045 | bool MainWindow::syncWithFile( QString fn , bool quick ) |
2072 | { | 2046 | { |
2073 | bool ret = false; | 2047 | bool ret = false; |
2074 | QFileInfo info; | 2048 | QFileInfo info; |
2075 | info.setFile( fn ); | 2049 | info.setFile( fn ); |
2076 | QString mess; | 2050 | QString mess; |
2077 | bool loadbup = true; | 2051 | bool loadbup = true; |
2078 | if ( !info. exists() ) { | 2052 | if ( !info. exists() ) { |
2079 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2053 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2080 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2054 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2081 | mess ); | 2055 | mess ); |
2082 | return ret; | 2056 | return ret; |
2083 | } | 2057 | } |
2084 | int result = 0; | 2058 | int result = 0; |
2085 | if ( !quick ) { | 2059 | if ( !quick ) { |
2086 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2060 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2087 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2061 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2088 | mess, | 2062 | mess, |
2089 | i18n("Sync"), i18n("Cancel"), 0, | 2063 | i18n("Sync"), i18n("Cancel"), 0, |
2090 | 0, 1 ); | 2064 | 0, 1 ); |
2091 | if ( result ) | 2065 | if ( result ) |
2092 | return false; | 2066 | return false; |
2093 | } | 2067 | } |
2094 | if ( KOPrefs::instance()->mAskForPreferences ) | 2068 | if ( KOPrefs::instance()->mAskForPreferences ) |
2095 | mView->edit_sync_options(); | 2069 | mView->edit_sync_options(); |
2096 | if ( result == 0 ) { | 2070 | if ( result == 0 ) { |
2097 | //qDebug("Now sycing ... "); | 2071 | //qDebug("Now sycing ... "); |
2098 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) | 2072 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) |
@@ -2458,183 +2432,182 @@ void KServerSocket::readBackFileFromSocket() | |||
2458 | piTime.restart(); | 2432 | piTime.restart(); |
2459 | QString line = mSocket->readLine (); | 2433 | QString line = mSocket->readLine (); |
2460 | piFileString += line; | 2434 | piFileString += line; |
2461 | //qDebug("readline: %s ", line.latin1()); | 2435 | //qDebug("readline: %s ", line.latin1()); |
2462 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 2436 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
2463 | 2437 | ||
2464 | } | 2438 | } |
2465 | if ( piTime.elapsed () < 3000 ) { | 2439 | if ( piTime.elapsed () < 3000 ) { |
2466 | // wait for more | 2440 | // wait for more |
2467 | //qDebug("waitformore "); | 2441 | //qDebug("waitformore "); |
2468 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 2442 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
2469 | return; | 2443 | return; |
2470 | } | 2444 | } |
2471 | QString fileName = mFileName; | 2445 | QString fileName = mFileName; |
2472 | QFile file ( fileName ); | 2446 | QFile file ( fileName ); |
2473 | if (!file.open( IO_WriteOnly ) ) { | 2447 | if (!file.open( IO_WriteOnly ) ) { |
2474 | delete mSyncActionDialog; | 2448 | delete mSyncActionDialog; |
2475 | mSyncActionDialog = 0; | 2449 | mSyncActionDialog = 0; |
2476 | qDebug("error open cal file "); | 2450 | qDebug("error open cal file "); |
2477 | piFileString = ""; | 2451 | piFileString = ""; |
2478 | emit file_received( false ); | 2452 | emit file_received( false ); |
2479 | return ; | 2453 | return ; |
2480 | 2454 | ||
2481 | } | 2455 | } |
2482 | 2456 | ||
2483 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 2457 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
2484 | QTextStream ts ( &file ); | 2458 | QTextStream ts ( &file ); |
2485 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2459 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2486 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 2460 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
2487 | ts << piFileString; | 2461 | ts << piFileString; |
2488 | mSocket->close(); | 2462 | mSocket->close(); |
2489 | if ( mSocket->state() == QSocket::Idle ) | 2463 | if ( mSocket->state() == QSocket::Idle ) |
2490 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 2464 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
2491 | file.close(); | 2465 | file.close(); |
2492 | delete mSyncActionDialog; | 2466 | delete mSyncActionDialog; |
2493 | mSyncActionDialog = 0; | 2467 | mSyncActionDialog = 0; |
2494 | piFileString = ""; | 2468 | piFileString = ""; |
2495 | emit file_received( true ); | 2469 | emit file_received( true ); |
2496 | 2470 | ||
2497 | } | 2471 | } |
2498 | 2472 | ||
2499 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | 2473 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) |
2500 | { | 2474 | { |
2501 | mPassWord = password; | 2475 | mPassWord = password; |
2502 | mSocket = 0; | 2476 | mSocket = 0; |
2503 | mPort = port; | 2477 | mPort = port; |
2504 | mHost = host; | 2478 | mHost = host; |
2505 | 2479 | ||
2506 | mRetVal = false; | 2480 | mRetVal = quiet; |
2507 | mTimerSocket = new QTimer ( this ); | 2481 | mTimerSocket = new QTimer ( this ); |
2508 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | 2482 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); |
2509 | } | 2483 | } |
2510 | void KCommandSocket::readFile( QString fn ) | 2484 | void KCommandSocket::readFile( QString fn ) |
2511 | { | 2485 | { |
2512 | if ( !mSocket ) { | 2486 | if ( !mSocket ) { |
2513 | mSocket = new QSocket( this ); | 2487 | mSocket = new QSocket( this ); |
2514 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 2488 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
2515 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2489 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2516 | } | 2490 | } |
2517 | mFileString = ""; | 2491 | mFileString = ""; |
2518 | mFileName = fn; | 2492 | mFileName = fn; |
2519 | mFirst = true; | 2493 | mFirst = true; |
2520 | mSocket->connectToHost( mHost, mPort ); | 2494 | mSocket->connectToHost( mHost, mPort ); |
2521 | QTextStream os( mSocket ); | 2495 | QTextStream os( mSocket ); |
2522 | os.setEncoding( QTextStream::UnicodeUTF8 ); | 2496 | os.setEncoding( QTextStream::UnicodeUTF8 ); |
2523 | os << "GET " << mPassWord << "\r\n"; | 2497 | os << "GET " << mPassWord << "\r\n"; |
2524 | mTimerSocket->start( 10000 ); | 2498 | mTimerSocket->start( 10000 ); |
2525 | } | 2499 | } |
2526 | 2500 | ||
2527 | void KCommandSocket::writeFile( QString fileName ) | 2501 | void KCommandSocket::writeFile( QString fileName ) |
2528 | { | 2502 | { |
2529 | if ( !mSocket ) { | 2503 | if ( !mSocket ) { |
2530 | mSocket = new QSocket( this ); | 2504 | mSocket = new QSocket( this ); |
2531 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2505 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2532 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 2506 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
2533 | } | 2507 | } |
2534 | mFileName = fileName ; | 2508 | mFileName = fileName ; |
2535 | mSocket->connectToHost( mHost, mPort ); | 2509 | mSocket->connectToHost( mHost, mPort ); |
2536 | } | 2510 | } |
2537 | void KCommandSocket::writeFileToSocket() | 2511 | void KCommandSocket::writeFileToSocket() |
2538 | { | 2512 | { |
2539 | QFile file2( mFileName ); | 2513 | QFile file2( mFileName ); |
2540 | if (!file2.open( IO_ReadOnly ) ) { | 2514 | if (!file2.open( IO_ReadOnly ) ) { |
2541 | mRetVal= false; | 2515 | mRetVal= errorW; |
2542 | mSocket->close(); | 2516 | mSocket->close(); |
2543 | if ( mSocket->state() == QSocket::Idle ) | 2517 | if ( mSocket->state() == QSocket::Idle ) |
2544 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 2518 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
2545 | return ; | 2519 | return ; |
2546 | } | 2520 | } |
2547 | QTextStream ts2( &file2 ); | 2521 | QTextStream ts2( &file2 ); |
2548 | ts2.setCodec( QTextCodec::codecForName("utf8") ); | 2522 | ts2.setCodec( QTextCodec::codecForName("utf8") ); |
2549 | QTextStream os2( mSocket ); | 2523 | QTextStream os2( mSocket ); |
2550 | os2.setCodec( QTextCodec::codecForName("utf8") ); | 2524 | os2.setCodec( QTextCodec::codecForName("utf8") ); |
2551 | os2 << "PUT " << mPassWord << "\r\n";; | 2525 | os2 << "PUT " << mPassWord << "\r\n";; |
2552 | while ( ! ts2.atEnd() ) { | 2526 | while ( ! ts2.atEnd() ) { |
2553 | os2 << ts2.readLine() << "\n"; | 2527 | os2 << ts2.readLine() << "\n"; |
2554 | } | 2528 | } |
2555 | mRetVal= true; | 2529 | mRetVal= successW; |
2556 | file2.close(); | 2530 | file2.close(); |
2557 | mSocket->close(); | 2531 | mSocket->close(); |
2558 | if ( mSocket->state() == QSocket::Idle ) | 2532 | if ( mSocket->state() == QSocket::Idle ) |
2559 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 2533 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
2560 | } | 2534 | } |
2561 | void KCommandSocket::sendStop() | 2535 | void KCommandSocket::sendStop() |
2562 | { | 2536 | { |
2563 | if ( !mSocket ) { | 2537 | if ( !mSocket ) { |
2564 | mSocket = new QSocket( this ); | 2538 | mSocket = new QSocket( this ); |
2565 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2539 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2566 | } | 2540 | } |
2567 | mSocket->connectToHost( mHost, mPort ); | 2541 | mSocket->connectToHost( mHost, mPort ); |
2568 | QTextStream os2( mSocket ); | 2542 | QTextStream os2( mSocket ); |
2569 | os2.setCodec( QTextCodec::codecForName("utf8") ); | 2543 | os2.setCodec( QTextCodec::codecForName("utf8") ); |
2570 | os2 << "STOP\r\n"; | 2544 | os2 << "STOP\r\n"; |
2571 | mRetVal= true; | ||
2572 | mSocket->close(); | 2545 | mSocket->close(); |
2573 | if ( mSocket->state() == QSocket::Idle ) | 2546 | if ( mSocket->state() == QSocket::Idle ) |
2574 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 2547 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
2575 | } | 2548 | } |
2576 | 2549 | ||
2577 | void KCommandSocket::startReadFileFromSocket() | 2550 | void KCommandSocket::startReadFileFromSocket() |
2578 | { | 2551 | { |
2579 | if ( ! mFirst ) | 2552 | if ( ! mFirst ) |
2580 | return; | 2553 | return; |
2581 | mFirst = false; | 2554 | mFirst = false; |
2582 | mTimerSocket->stop(); | 2555 | mTimerSocket->stop(); |
2583 | mFileString = ""; | 2556 | mFileString = ""; |
2584 | mTime.start(); | 2557 | mTime.start(); |
2585 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 2558 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
2586 | 2559 | ||
2587 | } | 2560 | } |
2588 | void KCommandSocket::readFileFromSocket() | 2561 | void KCommandSocket::readFileFromSocket() |
2589 | { | 2562 | { |
2590 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 2563 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
2591 | while ( mSocket->canReadLine () ) { | 2564 | while ( mSocket->canReadLine () ) { |
2592 | mTime.restart(); | 2565 | mTime.restart(); |
2593 | QString line = mSocket->readLine (); | 2566 | QString line = mSocket->readLine (); |
2594 | mFileString += line; | 2567 | mFileString += line; |
2595 | //qDebug("readline: %s ", line.latin1()); | 2568 | //qDebug("readline: %s ", line.latin1()); |
2596 | } | 2569 | } |
2597 | if ( mTime.elapsed () < 3000 ) { | 2570 | if ( mTime.elapsed () < 3000 ) { |
2598 | // wait for more | 2571 | // wait for more |
2599 | //qDebug("waitformore "); | 2572 | //qDebug("waitformore "); |
2600 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 2573 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
2601 | return; | 2574 | return; |
2602 | } | 2575 | } |
2603 | QString fileName = mFileName; | 2576 | QString fileName = mFileName; |
2604 | QFile file ( fileName ); | 2577 | QFile file ( fileName ); |
2605 | if (!file.open( IO_WriteOnly ) ) { | 2578 | if (!file.open( IO_WriteOnly ) ) { |
2606 | mFileString = ""; | 2579 | mFileString = ""; |
2607 | mRetVal = false; | 2580 | mRetVal = errorR; |
2608 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); | 2581 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); |
2609 | deleteSocket(); | 2582 | deleteSocket(); |
2610 | return ; | 2583 | return ; |
2611 | 2584 | ||
2612 | } | 2585 | } |
2613 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 2586 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
2614 | QTextStream ts ( &file ); | 2587 | QTextStream ts ( &file ); |
2615 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2588 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2616 | ts << mFileString; | 2589 | ts << mFileString; |
2617 | file.close(); | 2590 | file.close(); |
2618 | mFileString = ""; | 2591 | mFileString = ""; |
2619 | mRetVal = true; | 2592 | mRetVal = successR; |
2620 | mSocket->close(); | 2593 | mSocket->close(); |
2621 | // if state is not idle, deleteSocket(); is called via | 2594 | // if state is not idle, deleteSocket(); is called via |
2622 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2595 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2623 | if ( mSocket->state() == QSocket::Idle ) | 2596 | if ( mSocket->state() == QSocket::Idle ) |
2624 | deleteSocket(); | 2597 | deleteSocket(); |
2625 | } | 2598 | } |
2626 | 2599 | ||
2627 | void KCommandSocket::deleteSocket() | 2600 | void KCommandSocket::deleteSocket() |
2628 | { | 2601 | { |
2629 | if ( mTimerSocket->isActive () ) { | 2602 | if ( mTimerSocket->isActive () ) { |
2630 | mTimerSocket->stop(); | 2603 | mTimerSocket->stop(); |
2631 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | 2604 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); |
2632 | mRetVal = false; | 2605 | mRetVal = errorR; |
2633 | } | 2606 | } |
2634 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 2607 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
2635 | if ( mSocket) | 2608 | if ( mSocket) |
2636 | delete mSocket; | 2609 | delete mSocket; |
2637 | mSocket = 0; | 2610 | mSocket = 0; |
2638 | emit commandFinished( this, mRetVal ); | 2611 | emit commandFinished( this, mRetVal ); |
2639 | } | 2612 | } |
2640 | 2613 | ||
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 90b3a88..4da371e 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -16,195 +16,195 @@ class QAction; | |||
16 | class CalendarView; | 16 | class CalendarView; |
17 | class KSyncProfile; | 17 | class KSyncProfile; |
18 | #ifdef DESKTOP_VERSION | 18 | #ifdef DESKTOP_VERSION |
19 | 19 | ||
20 | #define QPEToolBar QToolBar | 20 | #define QPEToolBar QToolBar |
21 | #define QPEMenuBar QMenuBar | 21 | #define QPEMenuBar QMenuBar |
22 | #endif | 22 | #endif |
23 | class QPEToolBar; | 23 | class QPEToolBar; |
24 | #include <qserversocket.h> | 24 | #include <qserversocket.h> |
25 | #include <qsocket.h> | 25 | #include <qsocket.h> |
26 | #include <qnetworkprotocol.h> | 26 | #include <qnetworkprotocol.h> |
27 | 27 | ||
28 | class KServerSocket : public QServerSocket | 28 | class KServerSocket : public QServerSocket |
29 | { | 29 | { |
30 | Q_OBJECT | 30 | Q_OBJECT |
31 | 31 | ||
32 | public: | 32 | public: |
33 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); | 33 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); |
34 | 34 | ||
35 | void newConnection ( int socket ) ; | 35 | void newConnection ( int socket ) ; |
36 | void setFileName( QString fn ) {mFileName = fn;}; | 36 | void setFileName( QString fn ) {mFileName = fn;}; |
37 | 37 | ||
38 | signals: | 38 | signals: |
39 | //void sendFile(QSocket*); | 39 | //void sendFile(QSocket*); |
40 | //void getFile(QSocket*); | 40 | //void getFile(QSocket*); |
41 | void file_received( bool ); | 41 | void file_received( bool ); |
42 | //void file_sent(); | 42 | //void file_sent(); |
43 | void saveFile(); | 43 | void saveFile(); |
44 | void endConnect(); | 44 | void endConnect(); |
45 | private slots: | 45 | private slots: |
46 | void discardClient(); | 46 | void discardClient(); |
47 | void readClient(); | 47 | void readClient(); |
48 | void readBackFileFromSocket(); | 48 | void readBackFileFromSocket(); |
49 | private : | 49 | private : |
50 | void send_file(); | 50 | void send_file(); |
51 | void get_file(); | 51 | void get_file(); |
52 | void end_connect(); | 52 | void end_connect(); |
53 | QDialog* mSyncActionDialog; | 53 | QDialog* mSyncActionDialog; |
54 | QSocket* mSocket; | 54 | QSocket* mSocket; |
55 | QString mPassWord; | 55 | QString mPassWord; |
56 | QString mFileName; | 56 | QString mFileName; |
57 | QTime piTime; | 57 | QTime piTime; |
58 | QString piFileString; | 58 | QString piFileString; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | class KCommandSocket : public QObject | 61 | class KCommandSocket : public QObject |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | |||
65 | public: | 64 | public: |
65 | enum state { successR, errorR, successW, errorW, quiet }; | ||
66 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | 66 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); |
67 | void readFile( QString ); | 67 | void readFile( QString ); |
68 | void writeFile( QString ); | 68 | void writeFile( QString ); |
69 | void sendStop(); | 69 | void sendStop(); |
70 | 70 | ||
71 | 71 | ||
72 | signals: | 72 | signals: |
73 | void commandFinished( KCommandSocket*, bool ); | 73 | void commandFinished( KCommandSocket*, int ); |
74 | private slots: | 74 | private slots: |
75 | void startReadFileFromSocket(); | 75 | void startReadFileFromSocket(); |
76 | void readFileFromSocket(); | 76 | void readFileFromSocket(); |
77 | void deleteSocket(); | 77 | void deleteSocket(); |
78 | void writeFileToSocket(); | 78 | void writeFileToSocket(); |
79 | private : | 79 | private : |
80 | QSocket* mSocket; | 80 | QSocket* mSocket; |
81 | QString mPassWord; | 81 | QString mPassWord; |
82 | Q_UINT16 mPort; | 82 | Q_UINT16 mPort; |
83 | QString mHost; | 83 | QString mHost; |
84 | QString mFileName; | 84 | QString mFileName; |
85 | QTimer* mTimerSocket; | 85 | QTimer* mTimerSocket; |
86 | bool mRetVal; | 86 | int mRetVal; |
87 | QTime mTime; | 87 | QTime mTime; |
88 | QString mFileString; | 88 | QString mFileString; |
89 | bool mFirst; | 89 | bool mFirst; |
90 | }; | 90 | }; |
91 | 91 | ||
92 | namespace KCal { | 92 | namespace KCal { |
93 | class CalendarLocal; | 93 | class CalendarLocal; |
94 | } | 94 | } |
95 | 95 | ||
96 | using namespace KCal; | 96 | using namespace KCal; |
97 | 97 | ||
98 | class MainWindow : public QMainWindow | 98 | class MainWindow : public QMainWindow |
99 | { | 99 | { |
100 | Q_OBJECT | 100 | Q_OBJECT |
101 | public: | 101 | public: |
102 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); | 102 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); |
103 | ~MainWindow(); | 103 | ~MainWindow(); |
104 | public slots: | 104 | public slots: |
105 | virtual void showMaximized (); | 105 | virtual void showMaximized (); |
106 | void configureAgenda( int ); | 106 | void configureAgenda( int ); |
107 | void recieve( const QCString& msg, const QByteArray& data ); | 107 | void recieve( const QCString& msg, const QByteArray& data ); |
108 | static QString defaultFileName(); | 108 | static QString defaultFileName(); |
109 | static QString syncFileName(); | ||
109 | static QString resourcePath(); | 110 | static QString resourcePath(); |
110 | protected slots: | 111 | protected slots: |
111 | void setCaptionToDates(); | 112 | void setCaptionToDates(); |
112 | int ringSync(); | 113 | int ringSync(); |
113 | void multiSync( bool askforPrefs = false ); | 114 | void multiSync( bool askforPrefs = false ); |
114 | void about(); | 115 | void about(); |
115 | void licence(); | 116 | void licence(); |
116 | void faq(); | 117 | void faq(); |
117 | void usertrans(); | 118 | void usertrans(); |
118 | void features(); | 119 | void features(); |
119 | void synchowto(); | 120 | void synchowto(); |
120 | void whatsNew(); | 121 | void whatsNew(); |
121 | void keyBindings(); | 122 | void keyBindings(); |
122 | void aboutAutoSaving();; | 123 | void aboutAutoSaving();; |
123 | void aboutKnownBugs(); | 124 | void aboutKnownBugs(); |
124 | 125 | ||
125 | void processIncidenceSelection( Incidence * ); | 126 | void processIncidenceSelection( Incidence * ); |
126 | 127 | ||
127 | void importQtopia(); | 128 | void importQtopia(); |
128 | void importBday(); | 129 | void importBday(); |
129 | void importOL(); | 130 | void importOL(); |
130 | void importIcal(); | 131 | void importIcal(); |
131 | void importFile( QString, bool ); | 132 | void importFile( QString, bool ); |
132 | void quickImportIcal(); | 133 | void quickImportIcal(); |
133 | 134 | ||
134 | void slotModifiedChanged( bool ); | 135 | void slotModifiedChanged( bool ); |
135 | 136 | ||
136 | void save(); | 137 | void save(); |
137 | void configureToolBar( int ); | 138 | void configureToolBar( int ); |
138 | void printSel(); | 139 | void printSel(); |
139 | void printCal(); | 140 | void printCal(); |
140 | void saveCalendar(); | 141 | void saveCalendar(); |
141 | void loadCalendar(); | 142 | void loadCalendar(); |
142 | void exportVCalendar(); | 143 | void exportVCalendar(); |
143 | void fillFilterMenu(); | 144 | void fillFilterMenu(); |
144 | void selectFilter( int ); | 145 | void selectFilter( int ); |
145 | 146 | ||
146 | void slotSyncMenu( int ); | 147 | void slotSyncMenu( int ); |
147 | void syncSSH(); | 148 | void syncSSH(); |
148 | void confSync(); | 149 | void confSync(); |
149 | void syncSharp(); | 150 | void syncSharp(); |
150 | void syncPhone(); | 151 | void syncPhone(); |
151 | void syncPi(); | 152 | void syncPi(); |
152 | void syncLocalFile(); | 153 | void syncLocalFile(); |
153 | bool syncWithFile( QString, bool ); | 154 | bool syncWithFile( QString, bool ); |
154 | void quickSyncLocalFile(); | 155 | void quickSyncLocalFile(); |
155 | 156 | ||
156 | 157 | ||
157 | protected: | 158 | protected: |
158 | void displayText( QString, QString); | 159 | void displayText( QString, QString); |
159 | void displayFile( QString, QString); | 160 | void displayFile( QString, QString); |
160 | 161 | ||
161 | void enableIncidenceActions( bool ); | 162 | void enableIncidenceActions( bool ); |
162 | 163 | ||
163 | private slots: | 164 | private slots: |
164 | QSocket* piSocket; | 165 | QSocket* piSocket; |
165 | QString piFileString; | 166 | QString piFileString; |
166 | QTime piTime; | 167 | QTime piTime; |
167 | void deleteCommandSocket(KCommandSocket* s, bool success); | 168 | void deleteCommandSocket(KCommandSocket* s, int state ); |
168 | void deleteCommandSocketFinish(KCommandSocket* s, bool success); | ||
169 | void fillSyncMenu(); | 169 | void fillSyncMenu(); |
170 | void getFile( bool ); | 170 | void getFile( bool ); |
171 | void readFileFromSocket(); | 171 | void readFileFromSocket(); |
172 | private: | 172 | private: |
173 | //QTimer* mTimerCommandSocket; | 173 | //QTimer* mTimerCommandSocket; |
174 | QString mPassWordPiSync; | 174 | QString mPassWordPiSync; |
175 | KServerSocket * mServerSocket; | 175 | KServerSocket * mServerSocket; |
176 | bool mClosed; | 176 | bool mClosed; |
177 | void saveOnClose(); | 177 | void saveOnClose(); |
178 | int mCurrentSyncProfile; | 178 | int mCurrentSyncProfile; |
179 | void enableQuick(); | 179 | void enableQuick(); |
180 | void performQuickQuick(); | 180 | void performQuickQuick(); |
181 | void syncRemote( KSyncProfile* , bool ask = true); | 181 | void syncRemote( KSyncProfile* , bool ask = true); |
182 | bool mFlagKeyPressed; | 182 | bool mFlagKeyPressed; |
183 | bool mBlockAtStartup; | 183 | bool mBlockAtStartup; |
184 | QPEToolBar *iconToolBar; | 184 | QPEToolBar *iconToolBar; |
185 | void initActions(); | 185 | void initActions(); |
186 | void setDefaultPreferences(); | 186 | void setDefaultPreferences(); |
187 | void keyPressEvent ( QKeyEvent * ) ; | 187 | void keyPressEvent ( QKeyEvent * ) ; |
188 | void keyReleaseEvent ( QKeyEvent * ) ; | 188 | void keyReleaseEvent ( QKeyEvent * ) ; |
189 | QPopupMenu *configureToolBarMenu; | 189 | QPopupMenu *configureToolBarMenu; |
190 | QPopupMenu *selectFilterMenu; | 190 | QPopupMenu *selectFilterMenu; |
191 | QPopupMenu *configureAgendaMenu, *syncMenu; | 191 | QPopupMenu *configureAgendaMenu, *syncMenu; |
192 | CalendarLocal *mCalendar; | 192 | CalendarLocal *mCalendar; |
193 | CalendarView *mView; | 193 | CalendarView *mView; |
194 | QString getPassword(); | 194 | QString getPassword(); |
195 | QAction *mNewSubTodoAction; | 195 | QAction *mNewSubTodoAction; |
196 | 196 | ||
197 | QAction *mShowAction; | 197 | QAction *mShowAction; |
198 | QAction *mEditAction; | 198 | QAction *mEditAction; |
199 | QAction *mDeleteAction; | 199 | QAction *mDeleteAction; |
200 | void closeEvent( QCloseEvent* ce ); | 200 | void closeEvent( QCloseEvent* ce ); |
201 | SimpleAlarmClient mAlarmClient; | 201 | SimpleAlarmClient mAlarmClient; |
202 | QTimer mSaveTimer; | 202 | QTimer mSaveTimer; |
203 | bool mBlockSaveFlag; | 203 | bool mBlockSaveFlag; |
204 | bool mCalendarModifiedFlag; | 204 | bool mCalendarModifiedFlag; |
205 | QPixmap loadPixmap( QString ); | 205 | QPixmap loadPixmap( QString ); |
206 | QDialog * mSyncActionDialog; | 206 | QDialog * mSyncActionDialog; |
207 | }; | 207 | }; |
208 | 208 | ||
209 | 209 | ||
210 | #endif | 210 | #endif |