author | zautrix <zautrix> | 2004-10-04 10:05:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-04 10:05:42 (UTC) |
commit | 743f44c45534a6e1df17ddc7b5f3c62b73921455 (patch) (unidiff) | |
tree | 83795806d28b2614639082e944558a470f039daf /korganizer | |
parent | aaea91151fe9a747e9eddfb8ba7d5896744faf30 (diff) | |
download | kdepimpi-743f44c45534a6e1df17ddc7b5f3c62b73921455.zip kdepimpi-743f44c45534a6e1df17ddc7b5f3c62b73921455.tar.gz kdepimpi-743f44c45534a6e1df17ddc7b5f3c62b73921455.tar.bz2 |
sync fixes
-rw-r--r-- | korganizer/mainwindow.cpp | 181 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 14 |
2 files changed, 124 insertions, 71 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 7bf33d3..8e2f956 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -9,129 +9,131 @@ | |||
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qapp.h> | 13 | #include <qapp.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qmap.h> | 16 | #include <qmap.h> |
17 | #include <qwmatrix.h> | 17 | #include <qwmatrix.h> |
18 | #include <qtextbrowser.h> | 18 | #include <qtextbrowser.h> |
19 | #include <qtextstream.h> | 19 | #include <qtextstream.h> |
20 | #ifndef DESKTOP_VERSION | 20 | #ifndef DESKTOP_VERSION |
21 | #include <qpe/global.h> | 21 | #include <qpe/global.h> |
22 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
23 | #include <qpe/qpetoolbar.h> | 23 | #include <qpe/qpetoolbar.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qtopia/alarmserver.h> | 26 | #include <qtopia/alarmserver.h> |
27 | #include <qtopia/qcopenvelope_qws.h> | 27 | #include <qtopia/qcopenvelope_qws.h> |
28 | #include <unistd.h> // for sleep | 28 | #include <unistd.h> // for sleep |
29 | #else | 29 | #else |
30 | #include <qmenubar.h> | 30 | #include <qmenubar.h> |
31 | #include <qtoolbar.h> | 31 | #include <qtoolbar.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | //#include <resource.h> | 33 | //#include <resource.h> |
34 | 34 | ||
35 | #endif | 35 | #endif |
36 | #include <libkcal/calendarlocal.h> | 36 | #include <libkcal/calendarlocal.h> |
37 | #include <libkcal/todo.h> | 37 | #include <libkcal/todo.h> |
38 | #include <libkdepim/ksyncprofile.h> | 38 | #include <libkdepim/ksyncprofile.h> |
39 | #include <libkcal/kincidenceformatter.h> | 39 | #include <libkcal/kincidenceformatter.h> |
40 | #include <libkdepim/kpimglobalprefs.h> | 40 | #include <libkdepim/kpimglobalprefs.h> |
41 | 41 | ||
42 | #include "calendarview.h" | 42 | #include "calendarview.h" |
43 | #include "koviewmanager.h" | 43 | #include "koviewmanager.h" |
44 | #include "datenavigator.h" | 44 | #include "datenavigator.h" |
45 | #include "koagendaview.h" | 45 | #include "koagendaview.h" |
46 | #include "koagenda.h" | 46 | #include "koagenda.h" |
47 | #include "kodialogmanager.h" | 47 | #include "kodialogmanager.h" |
48 | #include "kdialogbase.h" | 48 | #include "kdialogbase.h" |
49 | #include "kapplication.h" | 49 | #include "kapplication.h" |
50 | #include "kofilterview.h" | 50 | #include "kofilterview.h" |
51 | #include "kstandarddirs.h" | 51 | #include "kstandarddirs.h" |
52 | #include "koprefs.h" | 52 | #include "koprefs.h" |
53 | #include "kfiledialog.h" | 53 | #include "kfiledialog.h" |
54 | #include "koglobals.h" | 54 | #include "koglobals.h" |
55 | #include "kglobal.h" | 55 | #include "kglobal.h" |
56 | #include "klocale.h" | 56 | #include "klocale.h" |
57 | #include "kconfig.h" | 57 | #include "kconfig.h" |
58 | #include "simplealarmclient.h" | 58 | #include "simplealarmclient.h" |
59 | #include "externalapphandler.h" | 59 | #include "externalapphandler.h" |
60 | 60 | ||
61 | using namespace KCal; | 61 | using namespace KCal; |
62 | #ifndef _WIN32_ | 62 | #ifndef _WIN32_ |
63 | #include <unistd.h> | 63 | #include <unistd.h> |
64 | #else | 64 | #else |
65 | #include "koimportoldialog.h" | 65 | #include "koimportoldialog.h" |
66 | #endif | 66 | #endif |
67 | #include "mainwindow.h" | 67 | #include "mainwindow.h" |
68 | 68 | ||
69 | int globalFlagBlockStartup; | 69 | int globalFlagBlockStartup; |
70 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 70 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
71 | QMainWindow( parent, name ) | 71 | QMainWindow( parent, name ) |
72 | { | 72 | { |
73 | 73 | mPassWordPiSync = "abc"; | |
74 | mTimerCommandSocket = new QTimer ( this ); | ||
75 | connect( mTimerCommandSocket, SIGNAL ( timeout () ), this, SLOT ( deleteCommandSocket() ) ); | ||
74 | #ifdef DESKTOP_VERSION | 76 | #ifdef DESKTOP_VERSION |
75 | setFont( QFont("Arial"), 14 ); | 77 | setFont( QFont("Arial"), 14 ); |
76 | #endif | 78 | #endif |
77 | mCommandSocket = 0; | 79 | mCommandSocket = 0; |
78 | mCommandSocketFinish = 0; | 80 | mCommandSocketFinish = 0; |
79 | mSyncActionDialog = 0; | 81 | mSyncActionDialog = 0; |
80 | mServerSocket = 0; | 82 | mServerSocket = 0; |
81 | mClosed = false; | 83 | mClosed = false; |
82 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 84 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
83 | QString confFile = locateLocal("config","korganizerrc"); | 85 | QString confFile = locateLocal("config","korganizerrc"); |
84 | QFileInfo finf ( confFile ); | 86 | QFileInfo finf ( confFile ); |
85 | bool showWarning = !finf.exists(); | 87 | bool showWarning = !finf.exists(); |
86 | setIcon(SmallIcon( "ko24" ) ); | 88 | setIcon(SmallIcon( "ko24" ) ); |
87 | mBlockAtStartup = true; | 89 | mBlockAtStartup = true; |
88 | mFlagKeyPressed = false; | 90 | mFlagKeyPressed = false; |
89 | setCaption("KOrganizer/Pi"); | 91 | setCaption("KOrganizer/Pi"); |
90 | KOPrefs *p = KOPrefs::instance(); | 92 | KOPrefs *p = KOPrefs::instance(); |
91 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 93 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
92 | // if ( QApplication::desktop()->height() > 480 ) { | 94 | // if ( QApplication::desktop()->height() > 480 ) { |
93 | // if ( p->mHourSize == 4 ) | 95 | // if ( p->mHourSize == 4 ) |
94 | // p->mHourSize = 6; | 96 | // p->mHourSize = 6; |
95 | // } | 97 | // } |
96 | if ( p->mHourSize > 18 ) | 98 | if ( p->mHourSize > 18 ) |
97 | p->mHourSize = 18; | 99 | p->mHourSize = 18; |
98 | QMainWindow::ToolBarDock tbd; | 100 | QMainWindow::ToolBarDock tbd; |
99 | if ( p->mToolBarHor ) { | 101 | if ( p->mToolBarHor ) { |
100 | if ( p->mToolBarUp ) | 102 | if ( p->mToolBarUp ) |
101 | tbd = Bottom; | 103 | tbd = Bottom; |
102 | else | 104 | else |
103 | tbd = Top; | 105 | tbd = Top; |
104 | } | 106 | } |
105 | else { | 107 | else { |
106 | if ( p->mToolBarUp ) | 108 | if ( p->mToolBarUp ) |
107 | tbd = Right; | 109 | tbd = Right; |
108 | else | 110 | else |
109 | tbd = Left; | 111 | tbd = Left; |
110 | } | 112 | } |
111 | if ( KOPrefs::instance()->mUseAppColors ) | 113 | if ( KOPrefs::instance()->mUseAppColors ) |
112 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 114 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
113 | globalFlagBlockStartup = 1; | 115 | globalFlagBlockStartup = 1; |
114 | iconToolBar = new QPEToolBar( this ); | 116 | iconToolBar = new QPEToolBar( this ); |
115 | addToolBar (iconToolBar , tbd ); | 117 | addToolBar (iconToolBar , tbd ); |
116 | mBlockSaveFlag = false; | 118 | mBlockSaveFlag = false; |
117 | mCalendarModifiedFlag = false; | 119 | mCalendarModifiedFlag = false; |
118 | 120 | ||
119 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 121 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
120 | splash->setAlignment ( AlignCenter ); | 122 | splash->setAlignment ( AlignCenter ); |
121 | setCentralWidget( splash ); | 123 | setCentralWidget( splash ); |
122 | #ifndef DESKTOP_VERSION | 124 | #ifndef DESKTOP_VERSION |
123 | showMaximized(); | 125 | showMaximized(); |
124 | #endif | 126 | #endif |
125 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 127 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
126 | setDefaultPreferences(); | 128 | setDefaultPreferences(); |
127 | mCalendar = new CalendarLocal(); | 129 | mCalendar = new CalendarLocal(); |
128 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 130 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
129 | mView->hide(); | 131 | mView->hide(); |
130 | //mView->resize(splash->size() ); | 132 | //mView->resize(splash->size() ); |
131 | initActions(); | 133 | initActions(); |
132 | #ifndef DESKTOP_VERSION | 134 | #ifndef DESKTOP_VERSION |
133 | iconToolBar->show(); | 135 | iconToolBar->show(); |
134 | qApp->processEvents(); | 136 | qApp->processEvents(); |
135 | #endif | 137 | #endif |
136 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 138 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
137 | int vh = height() ; | 139 | int vh = height() ; |
@@ -1828,453 +1830,482 @@ void MainWindow::importIcal() | |||
1828 | if ( fn == "" ) | 1830 | if ( fn == "" ) |
1829 | return; | 1831 | return; |
1830 | importFile( fn, true ); | 1832 | importFile( fn, true ); |
1831 | 1833 | ||
1832 | } | 1834 | } |
1833 | 1835 | ||
1834 | void MainWindow::exportVCalendar() | 1836 | void MainWindow::exportVCalendar() |
1835 | { | 1837 | { |
1836 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1838 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1837 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1839 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1838 | if ( fn == "" ) | 1840 | if ( fn == "" ) |
1839 | return; | 1841 | return; |
1840 | QFileInfo info; | 1842 | QFileInfo info; |
1841 | info.setFile( fn ); | 1843 | info.setFile( fn ); |
1842 | QString mes; | 1844 | QString mes; |
1843 | bool createbup = true; | 1845 | bool createbup = true; |
1844 | if ( info. exists() ) { | 1846 | if ( info. exists() ) { |
1845 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1847 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1846 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1848 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1847 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1849 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1848 | 0, 1 ); | 1850 | 0, 1 ); |
1849 | if ( result != 0 ) { | 1851 | if ( result != 0 ) { |
1850 | createbup = false; | 1852 | createbup = false; |
1851 | } | 1853 | } |
1852 | } | 1854 | } |
1853 | if ( createbup ) { | 1855 | if ( createbup ) { |
1854 | if ( mView->exportVCalendar( fn ) ) { | 1856 | if ( mView->exportVCalendar( fn ) ) { |
1855 | KOPrefs::instance()->mLastVcalFile = fn; | 1857 | KOPrefs::instance()->mLastVcalFile = fn; |
1856 | if ( fn.length() > 20 ) | 1858 | if ( fn.length() > 20 ) |
1857 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1859 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1858 | else | 1860 | else |
1859 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1861 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1860 | setCaption(mes); | 1862 | setCaption(mes); |
1861 | } | 1863 | } |
1862 | } | 1864 | } |
1863 | 1865 | ||
1864 | } | 1866 | } |
1865 | QString MainWindow::getPassword( ) | 1867 | QString MainWindow::getPassword( ) |
1866 | { | 1868 | { |
1867 | QString retfile = ""; | 1869 | QString retfile = ""; |
1868 | QDialog dia ( this, "input-dialog", true ); | 1870 | QDialog dia ( this, "input-dialog", true ); |
1869 | QLineEdit lab ( &dia ); | 1871 | QLineEdit lab ( &dia ); |
1870 | lab.setEchoMode( QLineEdit::Password ); | 1872 | lab.setEchoMode( QLineEdit::Password ); |
1871 | QVBoxLayout lay( &dia ); | 1873 | QVBoxLayout lay( &dia ); |
1872 | lay.setMargin(7); | 1874 | lay.setMargin(7); |
1873 | lay.setSpacing(7); | 1875 | lay.setSpacing(7); |
1874 | lay.addWidget( &lab); | 1876 | lay.addWidget( &lab); |
1875 | dia.setFixedSize( 230,50 ); | 1877 | dia.setFixedSize( 230,50 ); |
1876 | dia.setCaption( i18n("Enter password") ); | 1878 | dia.setCaption( i18n("Enter password") ); |
1877 | QPushButton pb ( "OK", &dia); | 1879 | QPushButton pb ( "OK", &dia); |
1878 | lay.addWidget( &pb ); | 1880 | lay.addWidget( &pb ); |
1879 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1881 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1880 | dia.show(); | 1882 | dia.show(); |
1881 | int res = dia.exec(); | 1883 | int res = dia.exec(); |
1882 | if ( res ) | 1884 | if ( res ) |
1883 | retfile = lab.text(); | 1885 | retfile = lab.text(); |
1884 | dia.hide(); | 1886 | dia.hide(); |
1885 | qApp->processEvents(); | 1887 | qApp->processEvents(); |
1886 | return retfile; | 1888 | return retfile; |
1887 | 1889 | ||
1888 | } | 1890 | } |
1889 | 1891 | ||
1890 | void MainWindow::enableQuick() | 1892 | void MainWindow::enableQuick() |
1891 | { | 1893 | { |
1894 | QString passWordPiSync = "bhdrvmk"; | ||
1892 | QString retfile = ""; | 1895 | QString retfile = ""; |
1893 | QDialog dia ( this, "input-dialog", true ); | 1896 | QDialog dia ( this, "input-dialog", true ); |
1894 | QLineEdit lab ( &dia ); | 1897 | QLineEdit lab ( &dia ); |
1895 | QVBoxLayout lay( &dia ); | 1898 | QVBoxLayout lay( &dia ); |
1896 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); | 1899 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); |
1897 | lay.setMargin(7); | 1900 | lay.setMargin(7); |
1898 | lay.setSpacing(7); | 1901 | lay.setSpacing(7); |
1899 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); | 1902 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); |
1900 | lay.addWidget( &label); | 1903 | lay.addWidget( &label); |
1901 | lay.addWidget( &lab); | 1904 | lay.addWidget( &lab); |
1905 | |||
1906 | QLineEdit lepw ( &dia ); | ||
1907 | lepw.setText( "abc" ); | ||
1908 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | ||
1909 | lay.addWidget( &label2); | ||
1910 | lay.addWidget( &lepw); | ||
1902 | dia.setFixedSize( 230,80 ); | 1911 | dia.setFixedSize( 230,80 ); |
1903 | dia.setCaption( i18n("Enter port for Easy-Pi-Sync") ); | 1912 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
1904 | QPushButton pb ( "OK", &dia); | 1913 | QPushButton pb ( "OK", &dia); |
1905 | lay.addWidget( &pb ); | 1914 | lay.addWidget( &pb ); |
1906 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1915 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1907 | dia.show(); | 1916 | dia.show(); |
1908 | int res = dia.exec(); | 1917 | int res = dia.exec(); |
1909 | if ( res ) | 1918 | if ( res ) |
1910 | retfile = lab.text(); | 1919 | retfile = lab.text(); |
1911 | else | 1920 | else |
1912 | return; | 1921 | return; |
1913 | dia.hide(); | 1922 | dia.hide(); |
1923 | passWordPiSync = lepw.text(); | ||
1914 | qApp->processEvents(); | 1924 | qApp->processEvents(); |
1915 | KOPrefs::instance()->mPassiveSyncPort = retfile; | 1925 | KOPrefs::instance()->mPassiveSyncPort = retfile; |
1916 | bool ok; | 1926 | bool ok; |
1917 | Q_UINT16 port = retfile.toUInt(&ok); | 1927 | Q_UINT16 port = retfile.toUInt(&ok); |
1918 | if ( ! ok ) { | 1928 | if ( ! ok ) { |
1919 | qDebug("no valid port "); | 1929 | KMessageBox::information( this, i18n("No valid port")); |
1920 | return; | 1930 | return; |
1921 | } | 1931 | } |
1922 | qDebug("port %d ", port); | 1932 | qDebug("port %d ", port); |
1923 | mServerSocket = new KServerSocket ( port ,1 ); | 1933 | mServerSocket = new KServerSocket ( passWordPiSync, port ,1 ); |
1924 | qDebug("connected "); | 1934 | qDebug("connected "); |
1925 | if ( !mServerSocket->ok() ) { | 1935 | if ( !mServerSocket->ok() ) { |
1926 | qWarning("Failed to bind to port %d", port); | 1936 | qWarning("Failed to bind to port %d", port); |
1927 | delete mServerSocket; | 1937 | delete mServerSocket; |
1928 | mServerSocket = 0; | 1938 | mServerSocket = 0; |
1929 | return; | 1939 | return; |
1930 | } | 1940 | } |
1931 | connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); | 1941 | connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); |
1932 | connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); | 1942 | connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); |
1933 | } | 1943 | } |
1934 | void MainWindow::sendFile(QSocket* socket) | 1944 | void MainWindow::sendFile(QSocket* socket) |
1935 | { | 1945 | { |
1936 | setCaption( i18n("Received request for file") ); | 1946 | setCaption( i18n("Received request for file") ); |
1937 | qDebug("MainWindow::sendFile(QSocket* s) "); | 1947 | qDebug("MainWindow::sendFile(QSocket* s) "); |
1938 | if ( mSyncActionDialog ) | 1948 | if ( mSyncActionDialog ) |
1939 | delete mSyncActionDialog; | 1949 | delete mSyncActionDialog; |
1940 | mSyncActionDialog = new QDialog ( this, "input-dialog", true ); | 1950 | mSyncActionDialog = new QDialog ( this, "input-dialog", true ); |
1941 | mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING")); | 1951 | mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING")); |
1942 | QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog ); | 1952 | QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog ); |
1943 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1953 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1944 | lay->addWidget( label); | 1954 | lay->addWidget( label); |
1945 | lay->setMargin(7); | 1955 | lay->setMargin(7); |
1946 | lay->setSpacing(7); | 1956 | lay->setSpacing(7); |
1947 | mSyncActionDialog->setFixedSize( 200,100 ); | 1957 | mSyncActionDialog->setFixedSize( 200,100 ); |
1948 | mSyncActionDialog->show(); | 1958 | mSyncActionDialog->show(); |
1949 | qApp->processEvents(); | ||
1950 | qDebug("saving ... "); | 1959 | qDebug("saving ... "); |
1951 | save(); | 1960 | save(); |
1961 | qApp->processEvents(); | ||
1952 | QString fileName = defaultFileName(); | 1962 | QString fileName = defaultFileName(); |
1953 | QFile file( fileName ); | 1963 | QFile file( fileName ); |
1954 | if (!file.open( IO_ReadOnly ) ) { | 1964 | if (!file.open( IO_ReadOnly ) ) { |
1955 | setCaption( i18n("Error open file") ); | 1965 | setCaption( i18n("Error open file") ); |
1956 | delete mSyncActionDialog; | 1966 | delete mSyncActionDialog; |
1957 | mSyncActionDialog = 0; | 1967 | mSyncActionDialog = 0; |
1958 | qDebug("error open cal file "); | 1968 | qDebug("error open cal file "); |
1959 | return ; | 1969 | return ; |
1960 | 1970 | ||
1961 | } | 1971 | } |
1962 | setCaption( i18n("Sending file...") ); | 1972 | setCaption( i18n("Sending file...") ); |
1963 | QTextStream ts( &file ); | 1973 | QTextStream ts( &file ); |
1964 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 1974 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
1965 | QTextStream os( socket ); | 1975 | QTextStream os( socket ); |
1966 | os.setCodec( QTextCodec::codecForName("utf8") ); | 1976 | os.setCodec( QTextCodec::codecForName("utf8") ); |
1967 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | 1977 | //os.setEncoding( QTextStream::UnicodeUTF8 ); |
1968 | while ( ! ts.atEnd() ) { | 1978 | while ( ! ts.atEnd() ) { |
1969 | os << ts.readLine() << "\n"; | 1979 | os << ts.readLine() << "\n"; |
1970 | } | 1980 | } |
1971 | //os << ts.read(); | 1981 | //os << ts.read(); |
1972 | socket->close(); | 1982 | socket->close(); |
1973 | file.close(); | 1983 | file.close(); |
1974 | setCaption( i18n("File sent. Waiting to get back synced file") ); | 1984 | setCaption( i18n("File sent. Waiting to get back synced file") ); |
1975 | qDebug("file sent "); | 1985 | qDebug("file sent "); |
1976 | } | 1986 | } |
1977 | void MainWindow::getFile(QSocket* socket) | 1987 | void MainWindow::getFile(QSocket* socket) |
1978 | { | 1988 | { |
1979 | setCaption( i18n("Receiving synced file...") ); | 1989 | setCaption( i18n("Receiving synced file...") ); |
1980 | 1990 | ||
1991 | piTime.start(); | ||
1992 | piSocket = socket; | ||
1993 | piFileString = ""; | ||
1994 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | ||
1995 | |||
1996 | |||
1997 | } | ||
1998 | void MainWindow::readBackFileFromSocket() | ||
1999 | { | ||
2000 | qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | ||
2001 | while ( piSocket->canReadLine () ) { | ||
2002 | piTime.restart(); | ||
2003 | QString line = piSocket->readLine (); | ||
2004 | piFileString += line; | ||
2005 | qDebug("readline: %s ", line.latin1()); | ||
2006 | setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | ||
2007 | |||
2008 | } | ||
2009 | if ( piTime.elapsed () < 3000 ) { | ||
2010 | // wait for more | ||
2011 | qDebug("waitformore "); | ||
2012 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | ||
2013 | return; | ||
2014 | } | ||
1981 | QString fileName = defaultFileName(); | 2015 | QString fileName = defaultFileName(); |
1982 | QFile file( fileName ); | 2016 | QFile file ( fileName ); |
1983 | if (!file.open( IO_WriteOnly ) ) { | 2017 | if (!file.open( IO_WriteOnly ) ) { |
1984 | setCaption( i18n("Error open file") ); | 2018 | setCaption( i18n("Error open file for writing!") ); |
1985 | delete mSyncActionDialog; | 2019 | delete mSyncActionDialog; |
1986 | mSyncActionDialog = 0; | 2020 | mSyncActionDialog = 0; |
1987 | qDebug("error open cal file "); | 2021 | qDebug("error open cal file "); |
2022 | piFileString = ""; | ||
1988 | return ; | 2023 | return ; |
1989 | 2024 | ||
1990 | } | 2025 | } |
1991 | 2026 | ||
1992 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 2027 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1993 | QTextStream ts( &file ); | 2028 | QTextStream ts ( &file ); |
1994 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2029 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
1995 | bool first = true; | 2030 | qDebug("finish "); |
1996 | while ( socket->canReadLine () || first ) { | 2031 | setCaption( i18n("Writing file to disk...") ); |
1997 | first = false; | 2032 | ts << piFileString; |
1998 | while ( socket->canReadLine () ) { | ||
1999 | qDebug("avail %d ", socket->bytesAvailable () ); | ||
2000 | ts << socket->readLine (); | ||
2001 | } | ||
2002 | QTime ti; | ||
2003 | ti.start(); | ||
2004 | while ( ti.elapsed () < 5000 && !socket->canReadLine () ) { | ||
2005 | qDebug("waiting1a %d %d ",ti.elapsed (), socket->bytesAvailable () ); | ||
2006 | //qApp->processEvents(); | ||
2007 | qDebug("waiting1b %d ",ti.elapsed () ); | ||
2008 | if ( !socket->canReadLine () ) { | ||
2009 | qDebug("waiting1c %d ",ti.elapsed () ); | ||
2010 | #ifndef _WIN32_ | ||
2011 | usleep( 100000); | ||
2012 | #endif | ||
2013 | } | ||
2014 | //socket->waitForMore ( 100 ); | ||
2015 | } | ||
2016 | ts << socket->readLine (); | ||
2017 | #if 0 | ||
2018 | #ifdef DESKTOP_VERSION | ||
2019 | socket->waitForMore ( 5000 ); | ||
2020 | #else | ||
2021 | // socket->waitForMore ( 5000 ); | ||
2022 | // seems to be broken in qt2 | ||
2023 | bool stop = false; | ||
2024 | QTime ti; | ||
2025 | ti.start(); | ||
2026 | while ( ti.elapsed < 5000 && !stop ) { | ||
2027 | qApp->processEvents(); | ||
2028 | if ( socket->canReadLine () ) | ||
2029 | stop = true ; | ||
2030 | else { | ||
2031 | usleep( 100000 ); | ||
2032 | |||
2033 | } | ||
2034 | } | ||
2035 | #endif | ||
2036 | #endif | ||
2037 | } | ||
2038 | setCaption( i18n("File received - reloading calendar...") ); | 2033 | setCaption( i18n("File received - reloading calendar...") ); |
2039 | socket->close(); | 2034 | piSocket->close(); |
2040 | file.close(); | 2035 | file.close(); |
2041 | mView->watchSavedFile(); | 2036 | mView->watchSavedFile(); |
2042 | mView->openCalendar( defaultFileName() ); | 2037 | mView->openCalendar( defaultFileName() ); |
2043 | setCaption( i18n("Easy-Pi-Sync successful!") ); | 2038 | setCaption( i18n("Pi-Sync successful!") ); |
2044 | delete mSyncActionDialog; | 2039 | delete mSyncActionDialog; |
2045 | mSyncActionDialog = 0; | 2040 | mSyncActionDialog = 0; |
2041 | piFileString = ""; | ||
2046 | 2042 | ||
2047 | 2043 | ||
2048 | } | 2044 | } |
2049 | void MainWindow::endConnect() | 2045 | void MainWindow::endConnect() |
2050 | { | 2046 | { |
2051 | setCaption( i18n("No file received - syncing successful") ); | 2047 | setCaption( i18n("No file received - syncing successful") ); |
2052 | delete mSyncActionDialog; | 2048 | delete mSyncActionDialog; |
2053 | mSyncActionDialog = 0; | 2049 | mSyncActionDialog = 0; |
2054 | } | 2050 | } |
2055 | void MainWindow::performQuick() | 2051 | void MainWindow::performQuick() |
2056 | { | 2052 | { |
2053 | |||
2057 | setCaption( i18n("Please input connection settings") ); | 2054 | setCaption( i18n("Please input connection settings") ); |
2058 | QString retfile = ""; | 2055 | QString retfile = ""; |
2059 | QDialog dia ( this, "input-dialog", true ); | 2056 | QDialog dia ( this, "input-dialog", true ); |
2060 | QLineEdit lab ( &dia ); | 2057 | QLineEdit lab ( &dia ); |
2061 | QVBoxLayout lay( &dia ); | 2058 | QVBoxLayout lay( &dia ); |
2062 | QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); | 2059 | QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); |
2063 | lay.addWidget( &label); | 2060 | lay.addWidget( &label); |
2064 | lab.setText( KOPrefs::instance()->mActiveSyncIP ); | 2061 | lab.setText( KOPrefs::instance()->mActiveSyncIP ); |
2065 | lay.setMargin(7); | 2062 | lay.setMargin(7); |
2066 | lay.setSpacing(7); | 2063 | lay.setSpacing(7); |
2067 | lay.addWidget( &lab); | 2064 | lay.addWidget( &lab); |
2068 | QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); | 2065 | QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); |
2069 | lay.addWidget( &label2); | 2066 | lay.addWidget( &label2); |
2070 | QLineEdit lab2 ( &dia ); | 2067 | QLineEdit lab2 ( &dia ); |
2071 | lab2.setText( KOPrefs::instance()->mActiveSyncPort ); | 2068 | lab2.setText( KOPrefs::instance()->mActiveSyncPort ); |
2072 | lay.addWidget( &lab2); | 2069 | lay.addWidget( &lab2); |
2070 | |||
2071 | QLineEdit lepw ( &dia ); | ||
2072 | lepw.setText( mPassWordPiSync ); | ||
2073 | QLabel label3 ( i18n("Password to enable\naccess to remote:"), &dia ); | ||
2074 | lay.addWidget( &label3); | ||
2075 | lay.addWidget( &lepw); | ||
2076 | |||
2073 | dia.setFixedSize( 230,200 ); | 2077 | dia.setFixedSize( 230,200 ); |
2074 | dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") ); | 2078 | dia.setCaption( i18n("Enter port for Pi-Sync ") ); |
2075 | QPushButton pb ( "OK", &dia); | 2079 | QPushButton pb ( "OK", &dia); |
2076 | lay.addWidget( &pb ); | 2080 | lay.addWidget( &pb ); |
2077 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2081 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2078 | dia.show(); | 2082 | dia.show(); |
2079 | int res = dia.exec(); | 2083 | int res = dia.exec(); |
2080 | if ( !res ) { | 2084 | if ( !res ) { |
2081 | setCaption( i18n("Syncing cancelled!") ); | 2085 | setCaption( i18n("Syncing cancelled!") ); |
2082 | return; | 2086 | return; |
2083 | } | 2087 | } |
2088 | mPassWordPiSync = lepw.text(); | ||
2084 | dia.hide(); | 2089 | dia.hide(); |
2085 | KOPrefs::instance()->mActiveSyncPort = lab2.text(); | 2090 | KOPrefs::instance()->mActiveSyncPort = lab2.text(); |
2086 | KOPrefs::instance()->mActiveSyncIP = lab.text(); | 2091 | KOPrefs::instance()->mActiveSyncIP = lab.text(); |
2087 | qApp->processEvents(); | 2092 | qApp->processEvents(); |
2088 | performQuickQuick(); | 2093 | performQuickQuick(); |
2089 | } | 2094 | } |
2090 | 2095 | ||
2091 | void MainWindow::performQuickQuick() | 2096 | void MainWindow::performQuickQuick() |
2092 | { | 2097 | { |
2093 | // setCaption( i18n("") ); | 2098 | // setCaption( i18n("") ); |
2094 | 2099 | ||
2095 | bool ok; | 2100 | bool ok; |
2096 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); | 2101 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); |
2097 | if ( ! ok ) { | 2102 | if ( ! ok ) { |
2098 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 2103 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
2099 | return; | 2104 | return; |
2100 | } | 2105 | } |
2101 | if ( !mCommandSocket ) { | 2106 | if ( !mCommandSocket ) { |
2102 | mCommandSocket = new QSocket( this ); | 2107 | mCommandSocket = new QSocket( this ); |
2103 | // delete mCommandSocket; | 2108 | // delete mCommandSocket; |
2104 | //mCommandSocket = new QSocket( this ); | 2109 | //mCommandSocket = new QSocket( this ); |
2105 | connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); | 2110 | connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); |
2111 | connect( mCommandSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteCommandSocket()) ); | ||
2106 | } | 2112 | } |
2107 | QString host = KOPrefs::instance()->mActiveSyncIP; | 2113 | QString host = KOPrefs::instance()->mActiveSyncIP; |
2108 | mCommandSocket->connectToHost( host, port ); | 2114 | mCommandSocket->connectToHost( host, port ); |
2109 | QTextStream os( mCommandSocket ); | 2115 | QTextStream os( mCommandSocket ); |
2110 | os.setEncoding( QTextStream::UnicodeUTF8 ); | 2116 | os.setEncoding( QTextStream::UnicodeUTF8 ); |
2111 | os << "GET\r\n"; | 2117 | os << "GET " << mPassWordPiSync << "\r\n"; |
2112 | setCaption( i18n("Sending request for remote file ...") ); | 2118 | setCaption( i18n("Sending request for remote file ...") ); |
2119 | mTimerCommandSocket->start( 15000 ); | ||
2113 | 2120 | ||
2114 | } | 2121 | } |
2122 | void MainWindow::deleteCommandSocket() | ||
2123 | { | ||
2124 | if ( !mCommandSocket) | ||
2125 | return; | ||
2126 | if ( mTimerCommandSocket->isActive () ) { | ||
2127 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out ")); | ||
2128 | mTimerCommandSocket->stop(); | ||
2129 | } | ||
2130 | qDebug("MainWindow::deletemCommandSocket() "); | ||
2131 | delete mCommandSocket; | ||
2132 | mCommandSocket = 0; | ||
2133 | } | ||
2134 | void MainWindow::deleteCommandSocketFinish() | ||
2135 | { | ||
2136 | if ( ! mCommandSocketFinish) | ||
2137 | return; | ||
2138 | //KMessageBox::information( 0, i18n("MainWindow::deleteCommandSocketFinish() ")); | ||
2139 | qDebug("MainWindow::deletemCommandSocketFinish() "); | ||
2140 | delete mCommandSocketFinish; | ||
2141 | mCommandSocketFinish = 0; | ||
2142 | } | ||
2115 | void MainWindow::readFileFromSocket() | 2143 | void MainWindow::readFileFromSocket() |
2116 | { | 2144 | { |
2145 | mTimerCommandSocket->stop(); | ||
2117 | setCaption( i18n("Receiving remote file ...") ); | 2146 | setCaption( i18n("Receiving remote file ...") ); |
2118 | qDebug("MainWindow::readFileFromSocket() "); | 2147 | qDebug("MainWindow::readFileFromSocket() "); |
2119 | QString fileName; | 2148 | QString fileName; |
2120 | #ifdef _WIN32_ | 2149 | #ifdef _WIN32_ |
2121 | fileName = defaultFileName() +"sync"; | 2150 | fileName = defaultFileName() +"sync"; |
2122 | #else | 2151 | #else |
2123 | fileName = "/tmp/kopitempfile.ics"; | 2152 | fileName = "/tmp/kopitempfile.ics"; |
2124 | #endif | 2153 | #endif |
2125 | QFile file( fileName ); | 2154 | QFile file( fileName ); |
2126 | if (!file.open( IO_WriteOnly ) ) { | 2155 | if (!file.open( IO_WriteOnly ) ) { |
2127 | setCaption( i18n("Error: Cannot open temp file for write.") ); | 2156 | setCaption( i18n("Error: Cannot open temp file for write.") ); |
2128 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); | 2157 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); |
2129 | return ; | 2158 | return ; |
2130 | } | 2159 | } |
2131 | 2160 | ||
2132 | //QTextStream os2( mCommandSocket ); | 2161 | //QTextStream os2( mCommandSocket ); |
2133 | //os2.setEncoding( QTextStream::UnicodeUTF8 ); | 2162 | //os2.setEncoding( QTextStream::UnicodeUTF8 ); |
2134 | 2163 | ||
2135 | QTextStream ts( &file ); | 2164 | QTextStream ts( &file ); |
2136 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2165 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2137 | bool first = true; | 2166 | bool first = true; |
2138 | while ( mCommandSocket->canReadLine () || first) { | 2167 | while ( mCommandSocket->canReadLine () || first) { |
2139 | first = false; | 2168 | first = false; |
2140 | while ( mCommandSocket->canReadLine () ) { | 2169 | while ( mCommandSocket->canReadLine () ) { |
2141 | ts << mCommandSocket->readLine (); | 2170 | ts << mCommandSocket->readLine (); |
2142 | } | 2171 | } |
2143 | QTime ti; | 2172 | QTime ti; |
2144 | ti.start(); | 2173 | ti.start(); |
2145 | while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) { | 2174 | while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) { |
2146 | qApp->processEvents(); | 2175 | qApp->processEvents(); |
2147 | qDebug("waiting2 %d ",ti.elapsed () ); | 2176 | qDebug("waiting2 %d ",ti.elapsed () ); |
2148 | if ( !mCommandSocket->canReadLine () ) | 2177 | if ( !mCommandSocket->canReadLine () ) |
2149 | mCommandSocket->waitForMore ( 100 ); | 2178 | mCommandSocket->waitForMore ( 100 ); |
2150 | } | 2179 | } |
2151 | //mCommandSocket->waitForMore ( 5000 ); | 2180 | //mCommandSocket->waitForMore ( 5000 ); |
2152 | } | 2181 | } |
2153 | file.close(); | 2182 | file.close(); |
2154 | mCommandSocket->close(); | 2183 | mCommandSocket->close(); |
2184 | if ( mCommandSocket->state() == QSocket::Idle ) | ||
2185 | deleteCommandSocket(); | ||
2155 | // pending: deleting after signal SIGNAL(delayedCloseFinished()) | 2186 | // pending: deleting after signal SIGNAL(delayedCloseFinished()) |
2156 | //delete mCommandSocket; | 2187 | //delete mCommandSocket; |
2157 | setCaption( i18n("Remote file saved to temp file.") ); | 2188 | setCaption( i18n("Remote file saved to temp file.") ); |
2158 | //mCommandSocket = 0; | 2189 | //mCommandSocket = 0; |
2159 | mCurrentSyncProfile = 2 ; // last file | 2190 | mCurrentSyncProfile = 2 ; // last file |
2160 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 2191 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
2161 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 2192 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
2162 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2193 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2163 | KSyncProfile* temp = new KSyncProfile (); | 2194 | KSyncProfile* temp = new KSyncProfile (); |
2164 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2195 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2165 | temp->readConfig(&config); | 2196 | temp->readConfig(&config); |
2166 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2197 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2167 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 2198 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
2168 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2199 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2169 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2200 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2170 | KOPrefs::instance()->mWriteBackInFuture = 0; | 2201 | KOPrefs::instance()->mWriteBackInFuture = 0; |
2171 | if ( temp->getWriteBackFuture() ) | 2202 | if ( temp->getWriteBackFuture() ) |
2172 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2203 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2173 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 2204 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
2174 | 2205 | delete temp; | |
2175 | setCaption( i18n("Remote file saved to temp file.") ); | 2206 | setCaption( i18n("Remote file saved to temp file.") ); |
2176 | if ( ! syncWithFile( fileName , true ) ) { | 2207 | if ( ! syncWithFile( fileName , true ) ) { |
2177 | setCaption( i18n("Syncing failed.") ); | 2208 | setCaption( i18n("Syncing failed.") ); |
2178 | qDebug("Syncing failed "); | 2209 | qDebug("Syncing failed "); |
2179 | return; | 2210 | return; |
2180 | } | 2211 | } |
2181 | 2212 | ||
2182 | if ( !mCommandSocketFinish ) { | 2213 | if ( !mCommandSocketFinish ) { |
2183 | mCommandSocketFinish = new QSocket( this ); | 2214 | mCommandSocketFinish = new QSocket( this ); |
2215 | connect( mCommandSocketFinish, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteCommandSocketFinish()) ); | ||
2184 | } | 2216 | } |
2185 | mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); | 2217 | mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); |
2186 | 2218 | ||
2187 | // pending connect signals connected () and error to new slots | 2219 | // pending connect signals connected () and error to new slots |
2188 | QString host = KOPrefs::instance()->mActiveSyncIP; | 2220 | QString host = KOPrefs::instance()->mActiveSyncIP; |
2189 | QFile file2( fileName ); | 2221 | QFile file2( fileName ); |
2190 | if (!file2.open( IO_ReadOnly ) ) { | 2222 | if (!file2.open( IO_ReadOnly ) ) { |
2191 | setCaption( i18n("Error: Cannot open temp file for read.") ); | 2223 | setCaption( i18n("Error: Cannot open temp file for read.") ); |
2192 | qDebug("error open cal file "); | 2224 | qDebug("error open cal file "); |
2193 | return ; | 2225 | return ; |
2194 | 2226 | ||
2195 | } | 2227 | } |
2196 | setCaption( i18n("Sending back synced file...") ); | 2228 | setCaption( i18n("Sending back synced file...") ); |
2197 | QTextStream ts2( &file2 ); | 2229 | QTextStream ts2( &file2 ); |
2198 | ts2.setCodec( QTextCodec::codecForName("utf8") ); | 2230 | ts2.setCodec( QTextCodec::codecForName("utf8") ); |
2199 | QTextStream os2( mCommandSocketFinish ); | 2231 | QTextStream os2( mCommandSocketFinish ); |
2200 | os2.setCodec( QTextCodec::codecForName("utf8") ); | 2232 | os2.setCodec( QTextCodec::codecForName("utf8") ); |
2201 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | 2233 | //os.setEncoding( QTextStream::UnicodeUTF8 ); |
2202 | if ( KOPrefs::instance()->mWriteBackFile ) { | 2234 | if ( KOPrefs::instance()->mWriteBackFile ) { |
2203 | os2 << "PUT\r\n"; | 2235 | os2 << "PUT " << mPassWordPiSync << "\r\n";; |
2204 | while ( ! ts2.atEnd() ) { | 2236 | while ( ! ts2.atEnd() ) { |
2205 | os2 << ts2.readLine() << "\n"; | 2237 | os2 << ts2.readLine() << "\n"; |
2206 | } | 2238 | } |
2207 | } else { | 2239 | } else { |
2208 | os2 << "STOP\r\n"; | 2240 | os2 << "STOP\r\n"; |
2209 | } | 2241 | } |
2210 | mCommandSocketFinish->close(); | 2242 | mCommandSocketFinish->close(); |
2243 | if ( mCommandSocketFinish->state() == QSocket::Idle ) | ||
2244 | deleteCommandSocketFinish(); | ||
2211 | file.close(); | 2245 | file.close(); |
2212 | // pending: deleting after signal SIGNAL(delayedCloseFinished()) | ||
2213 | //delete ( mCommandSocket); | ||
2214 | //mCommandSocket = 0; | ||
2215 | qDebug("Syncing succesful! "); | 2246 | qDebug("Syncing succesful! "); |
2216 | setCaption( i18n("Easy-Pi-Sync succesful!") ); | 2247 | setCaption( i18n("Pi-Sync succesful!") ); |
2217 | 2248 | ||
2218 | 2249 | ||
2219 | } | 2250 | } |
2220 | 2251 | ||
2221 | void MainWindow::syncLocalFile() | 2252 | void MainWindow::syncLocalFile() |
2222 | { | 2253 | { |
2223 | 2254 | ||
2224 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | 2255 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; |
2225 | 2256 | ||
2226 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2257 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2227 | if ( fn == "" ) | 2258 | if ( fn == "" ) |
2228 | return; | 2259 | return; |
2229 | //mView->setSyncDevice("local-file" ); | 2260 | //mView->setSyncDevice("local-file" ); |
2230 | if ( syncWithFile( fn, false ) ) { | 2261 | if ( syncWithFile( fn, false ) ) { |
2231 | // Event* e = mView->getLastSyncEvent(); | 2262 | // Event* e = mView->getLastSyncEvent(); |
2232 | // e->setReadOnly( false ); | 2263 | // e->setReadOnly( false ); |
2233 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2264 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2234 | // e->setReadOnly( true ); | 2265 | // e->setReadOnly( true ); |
2235 | } | 2266 | } |
2236 | 2267 | ||
2237 | } | 2268 | } |
2238 | 2269 | ||
2239 | bool MainWindow::syncWithFile( QString fn , bool quick ) | 2270 | bool MainWindow::syncWithFile( QString fn , bool quick ) |
2240 | { | 2271 | { |
2241 | bool ret = false; | 2272 | bool ret = false; |
2242 | QFileInfo info; | 2273 | QFileInfo info; |
2243 | info.setFile( fn ); | 2274 | info.setFile( fn ); |
2244 | QString mess; | 2275 | QString mess; |
2245 | bool loadbup = true; | 2276 | bool loadbup = true; |
2246 | if ( !info. exists() ) { | 2277 | if ( !info. exists() ) { |
2247 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2278 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2248 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2279 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2249 | mess ); | 2280 | mess ); |
2250 | return ret; | 2281 | return ret; |
2251 | } | 2282 | } |
2252 | int result = 0; | 2283 | int result = 0; |
2253 | if ( !quick ) { | 2284 | if ( !quick ) { |
2254 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2285 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2255 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2286 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2256 | mess, | 2287 | mess, |
2257 | i18n("Sync"), i18n("Cancel"), 0, | 2288 | i18n("Sync"), i18n("Cancel"), 0, |
2258 | 0, 1 ); | 2289 | 0, 1 ); |
2259 | if ( result ) | 2290 | if ( result ) |
2260 | return false; | 2291 | return false; |
2261 | } | 2292 | } |
2262 | if ( KOPrefs::instance()->mAskForPreferences ) | 2293 | if ( KOPrefs::instance()->mAskForPreferences ) |
2263 | mView->edit_sync_options(); | 2294 | mView->edit_sync_options(); |
2264 | if ( result == 0 ) { | 2295 | if ( result == 0 ) { |
2265 | //qDebug("Now sycing ... "); | 2296 | //qDebug("Now sycing ... "); |
2266 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) | 2297 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) |
2267 | setCaption( i18n("Synchronization successful") ); | 2298 | setCaption( i18n("Synchronization successful") ); |
2268 | else | 2299 | else |
2269 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 2300 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
2270 | if ( ! quick ) | 2301 | if ( ! quick ) |
2271 | KOPrefs::instance()->mLastSyncedLocalFile = fn; | 2302 | KOPrefs::instance()->mLastSyncedLocalFile = fn; |
2272 | slotModifiedChanged( true ); | 2303 | slotModifiedChanged( true ); |
2273 | } | 2304 | } |
2274 | return ret; | 2305 | return ret; |
2275 | } | 2306 | } |
2276 | void MainWindow::quickSyncLocalFile() | 2307 | void MainWindow::quickSyncLocalFile() |
2277 | { | 2308 | { |
2278 | //mView->setSyncDevice("local-file" ); | 2309 | //mView->setSyncDevice("local-file" ); |
2279 | //qDebug("quickSyncLocalFile() "); | 2310 | //qDebug("quickSyncLocalFile() "); |
2280 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { | 2311 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { |
@@ -2435,127 +2466,137 @@ void MainWindow::syncSSH() | |||
2435 | result = system ( command ); | 2466 | result = system ( command ); |
2436 | if ( result != 0 ) { | 2467 | if ( result != 0 ) { |
2437 | int len = maxlen; | 2468 | int len = maxlen; |
2438 | while ( len < command.length() ) { | 2469 | while ( len < command.length() ) { |
2439 | command.insert( len , "\n" ); | 2470 | command.insert( len , "\n" ); |
2440 | len += maxlen +2; | 2471 | len += maxlen +2; |
2441 | } | 2472 | } |
2442 | question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2473 | question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2443 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2474 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2444 | question, | 2475 | question, |
2445 | i18n("Okay!")) ; | 2476 | i18n("Okay!")) ; |
2446 | setCaption ("KO/Pi"); | 2477 | setCaption ("KO/Pi"); |
2447 | return; | 2478 | return; |
2448 | } else { | 2479 | } else { |
2449 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2480 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2450 | } | 2481 | } |
2451 | } | 2482 | } |
2452 | } | 2483 | } |
2453 | return; | 2484 | return; |
2454 | #if 0 | 2485 | #if 0 |
2455 | system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); | 2486 | system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); |
2456 | while ( timer.elapsed() < 5000 ) | 2487 | while ( timer.elapsed() < 5000 ) |
2457 | qApp->processEvents(); | 2488 | qApp->processEvents(); |
2458 | 2489 | ||
2459 | qDebug("MainWindow::merging) "); | 2490 | qDebug("MainWindow::merging) "); |
2460 | mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); | 2491 | mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); |
2461 | while ( mBlockSaveFlag ) | 2492 | while ( mBlockSaveFlag ) |
2462 | qApp->processEvents(); | 2493 | qApp->processEvents(); |
2463 | save(); | 2494 | save(); |
2464 | system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); | 2495 | system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); |
2465 | #endif | 2496 | #endif |
2466 | 2497 | ||
2467 | } | 2498 | } |
2468 | 2499 | ||
2469 | 2500 | ||
2470 | void MainWindow::syncSharp() | 2501 | void MainWindow::syncSharp() |
2471 | { | 2502 | { |
2472 | if ( mCalendarModifiedFlag ) | 2503 | if ( mCalendarModifiedFlag ) |
2473 | save(); | 2504 | save(); |
2474 | mView->syncSharp(); | 2505 | mView->syncSharp(); |
2475 | slotModifiedChanged( true ); | 2506 | slotModifiedChanged( true ); |
2476 | 2507 | ||
2477 | } | 2508 | } |
2478 | void MainWindow::syncPhone() | 2509 | void MainWindow::syncPhone() |
2479 | { | 2510 | { |
2480 | if ( mCalendarModifiedFlag ) | 2511 | if ( mCalendarModifiedFlag ) |
2481 | save(); | 2512 | save(); |
2482 | mView->syncPhone(); | 2513 | mView->syncPhone(); |
2483 | slotModifiedChanged( true ); | 2514 | slotModifiedChanged( true ); |
2484 | 2515 | ||
2485 | } | 2516 | } |
2486 | 2517 | ||
2487 | void MainWindow::printSel( ) | 2518 | void MainWindow::printSel( ) |
2488 | { | 2519 | { |
2489 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2520 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2490 | } | 2521 | } |
2491 | 2522 | ||
2492 | void MainWindow::printCal() | 2523 | void MainWindow::printCal() |
2493 | { | 2524 | { |
2494 | mView->print();//mCp->showDialog(); | 2525 | mView->print();//mCp->showDialog(); |
2495 | } | 2526 | } |
2496 | 2527 | ||
2497 | 2528 | ||
2498 | 2529 | ||
2499 | KServerSocket:: KServerSocket ( Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 2530 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
2500 | { | 2531 | { |
2501 | 2532 | mPassWord = pw; | |
2502 | mSocket = 0; | 2533 | mSocket = 0; |
2503 | }; | 2534 | }; |
2504 | 2535 | ||
2505 | void KServerSocket::newConnection ( int socket ) | 2536 | void KServerSocket::newConnection ( int socket ) |
2506 | { | 2537 | { |
2507 | qDebug("KServerSocket:New connection %d ", socket); | 2538 | qDebug("KServerSocket:New connection %d ", socket); |
2508 | if ( mSocket ) { | 2539 | if ( mSocket ) { |
2509 | qDebug("KServerSocket::newConnection Socket deleted! "); | 2540 | qDebug("KServerSocket::newConnection Socket deleted! "); |
2510 | delete mSocket; | 2541 | delete mSocket; |
2511 | mSocket = 0; | 2542 | mSocket = 0; |
2512 | } | 2543 | } |
2513 | mSocket = new QSocket( this ); | 2544 | mSocket = new QSocket( this ); |
2514 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 2545 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
2515 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 2546 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
2516 | mSocket->setSocket( socket ); | 2547 | mSocket->setSocket( socket ); |
2517 | } | 2548 | } |
2518 | 2549 | ||
2519 | void KServerSocket::discardClient() | 2550 | void KServerSocket::discardClient() |
2520 | { | 2551 | { |
2521 | qDebug(" KServerSocket::discardClient()"); | 2552 | qDebug(" KServerSocket::discardClient()"); |
2522 | if ( mSocket ) { | 2553 | if ( mSocket ) { |
2523 | qDebug("delete "); | 2554 | qDebug("delete "); |
2524 | delete mSocket; | 2555 | delete mSocket; |
2525 | mSocket = 0; | 2556 | mSocket = 0; |
2526 | } | 2557 | } |
2527 | //emit endConnect(); | 2558 | //emit endConnect(); |
2528 | } | 2559 | } |
2529 | void KServerSocket::readClient() | 2560 | void KServerSocket::readClient() |
2530 | { | 2561 | { |
2531 | if ( mSocket == 0 ) { | 2562 | if ( mSocket == 0 ) { |
2532 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 2563 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); |
2533 | return; | 2564 | return; |
2534 | } | 2565 | } |
2535 | qDebug("KServerSocket readClient()"); | 2566 | qDebug("KServerSocket readClient()"); |
2536 | if ( mSocket->canReadLine() ) { | 2567 | if ( mSocket->canReadLine() ) { |
2537 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); | 2568 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); |
2538 | qDebug("KServerSocket socket->canReadLine()"); | 2569 | qDebug("KServerSocket socket->canReadLine()"); |
2539 | if ( tokens[0] == "GET" ) { | 2570 | if ( tokens[0] == "GET" ) { |
2540 | emit sendFile( mSocket ); | 2571 | if ( tokens[1] == mPassWord ) |
2572 | emit sendFile( mSocket ); | ||
2573 | else { | ||
2574 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); | ||
2575 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | ||
2576 | } | ||
2541 | } | 2577 | } |
2542 | if ( tokens[0] == "PUT" ) { | 2578 | if ( tokens[0] == "PUT" ) { |
2543 | emit getFile( mSocket ); | 2579 | if ( tokens[1] == mPassWord ) |
2580 | emit getFile( mSocket ); | ||
2581 | else { | ||
2582 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); | ||
2583 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | ||
2584 | } | ||
2544 | } | 2585 | } |
2545 | if ( tokens[0] == "STOP" ) { | 2586 | if ( tokens[0] == "STOP" ) { |
2546 | emit endConnect(); | 2587 | emit endConnect(); |
2547 | } | 2588 | } |
2548 | } | 2589 | } |
2549 | } | 2590 | } |
2550 | 2591 | ||
2551 | 2592 | ||
2552 | 2593 | ||
2553 | 2594 | ||
2554 | 2595 | ||
2555 | 2596 | ||
2556 | 2597 | ||
2557 | 2598 | ||
2558 | 2599 | ||
2559 | 2600 | ||
2560 | 2601 | ||
2561 | 2602 | ||
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index cc656a3..d217578 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -1,161 +1,173 @@ | |||
1 | #ifndef KORGE_MAINWINDOW_H | 1 | #ifndef KORGE_MAINWINDOW_H |
2 | #define KORGE_MAINWINDOW_H | 2 | #define KORGE_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qfile.h> | ||
8 | #include <qsocket.h> | ||
9 | #include <qtextstream.h> | ||
7 | #include <qregexp.h> | 10 | #include <qregexp.h> |
8 | 11 | ||
9 | #include <libkcal/incidence.h> | 12 | #include <libkcal/incidence.h> |
10 | #include "simplealarmclient.h" | 13 | #include "simplealarmclient.h" |
11 | 14 | ||
12 | class QAction; | 15 | class QAction; |
13 | class CalendarView; | 16 | class CalendarView; |
14 | class KSyncProfile; | 17 | class KSyncProfile; |
15 | #ifdef DESKTOP_VERSION | 18 | #ifdef DESKTOP_VERSION |
16 | 19 | ||
17 | #define QPEToolBar QToolBar | 20 | #define QPEToolBar QToolBar |
18 | #define QPEMenuBar QMenuBar | 21 | #define QPEMenuBar QMenuBar |
19 | #endif | 22 | #endif |
20 | class QPEToolBar; | 23 | class QPEToolBar; |
21 | #include <qserversocket.h> | 24 | #include <qserversocket.h> |
22 | #include <qsocket.h> | 25 | #include <qsocket.h> |
23 | #include <qnetworkprotocol.h> | 26 | #include <qnetworkprotocol.h> |
24 | 27 | ||
25 | class KServerSocket : public QServerSocket | 28 | class KServerSocket : public QServerSocket |
26 | { | 29 | { |
27 | Q_OBJECT | 30 | Q_OBJECT |
28 | 31 | ||
29 | public: | 32 | public: |
30 | KServerSocket ( 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 ); |
31 | 34 | ||
32 | void newConnection ( int socket ) ; | 35 | void newConnection ( int socket ) ; |
33 | 36 | ||
34 | signals: | 37 | signals: |
35 | void sendFile(QSocket*); | 38 | void sendFile(QSocket*); |
36 | void getFile(QSocket*); | 39 | void getFile(QSocket*); |
37 | void endConnect(); | 40 | void endConnect(); |
38 | private slots: | 41 | private slots: |
39 | void discardClient(); | 42 | void discardClient(); |
40 | void readClient(); | 43 | void readClient(); |
41 | private : | 44 | private : |
42 | QSocket* mSocket; | 45 | QSocket* mSocket; |
46 | QString mPassWord; | ||
43 | }; | 47 | }; |
44 | 48 | ||
45 | 49 | ||
46 | namespace KCal { | 50 | namespace KCal { |
47 | class CalendarLocal; | 51 | class CalendarLocal; |
48 | } | 52 | } |
49 | 53 | ||
50 | using namespace KCal; | 54 | using namespace KCal; |
51 | 55 | ||
52 | class MainWindow : public QMainWindow | 56 | class MainWindow : public QMainWindow |
53 | { | 57 | { |
54 | Q_OBJECT | 58 | Q_OBJECT |
55 | public: | 59 | public: |
56 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); | 60 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); |
57 | ~MainWindow(); | 61 | ~MainWindow(); |
58 | public slots: | 62 | public slots: |
59 | virtual void showMaximized (); | 63 | virtual void showMaximized (); |
60 | void configureAgenda( int ); | 64 | void configureAgenda( int ); |
61 | void recieve( const QCString& msg, const QByteArray& data ); | 65 | void recieve( const QCString& msg, const QByteArray& data ); |
62 | static QString defaultFileName(); | 66 | static QString defaultFileName(); |
63 | static QString resourcePath(); | 67 | static QString resourcePath(); |
64 | protected slots: | 68 | protected slots: |
65 | void setCaptionToDates(); | 69 | void setCaptionToDates(); |
66 | int ringSync(); | 70 | int ringSync(); |
67 | void multiSync( bool askforPrefs = false ); | 71 | void multiSync( bool askforPrefs = false ); |
68 | void about(); | 72 | void about(); |
69 | void licence(); | 73 | void licence(); |
70 | void faq(); | 74 | void faq(); |
71 | void usertrans(); | 75 | void usertrans(); |
72 | void features(); | 76 | void features(); |
73 | void synchowto(); | 77 | void synchowto(); |
74 | void whatsNew(); | 78 | void whatsNew(); |
75 | void keyBindings(); | 79 | void keyBindings(); |
76 | void aboutAutoSaving();; | 80 | void aboutAutoSaving();; |
77 | void aboutKnownBugs(); | 81 | void aboutKnownBugs(); |
78 | 82 | ||
79 | void processIncidenceSelection( Incidence * ); | 83 | void processIncidenceSelection( Incidence * ); |
80 | 84 | ||
81 | void importQtopia(); | 85 | void importQtopia(); |
82 | void importBday(); | 86 | void importBday(); |
83 | void importOL(); | 87 | void importOL(); |
84 | void importIcal(); | 88 | void importIcal(); |
85 | void importFile( QString, bool ); | 89 | void importFile( QString, bool ); |
86 | void quickImportIcal(); | 90 | void quickImportIcal(); |
87 | 91 | ||
88 | void slotModifiedChanged( bool ); | 92 | void slotModifiedChanged( bool ); |
89 | 93 | ||
90 | void save(); | 94 | void save(); |
91 | void configureToolBar( int ); | 95 | void configureToolBar( int ); |
92 | void printSel(); | 96 | void printSel(); |
93 | void printCal(); | 97 | void printCal(); |
94 | void saveCalendar(); | 98 | void saveCalendar(); |
95 | void loadCalendar(); | 99 | void loadCalendar(); |
96 | void exportVCalendar(); | 100 | void exportVCalendar(); |
97 | void fillFilterMenu(); | 101 | void fillFilterMenu(); |
98 | void selectFilter( int ); | 102 | void selectFilter( int ); |
99 | 103 | ||
100 | void slotSyncMenu( int ); | 104 | void slotSyncMenu( int ); |
101 | void syncSSH(); | 105 | void syncSSH(); |
102 | void confSync(); | 106 | void confSync(); |
103 | void syncSharp(); | 107 | void syncSharp(); |
104 | void syncPhone(); | 108 | void syncPhone(); |
105 | void syncLocalFile(); | 109 | void syncLocalFile(); |
106 | bool syncWithFile( QString, bool ); | 110 | bool syncWithFile( QString, bool ); |
107 | void quickSyncLocalFile(); | 111 | void quickSyncLocalFile(); |
108 | 112 | ||
109 | 113 | ||
110 | protected: | 114 | protected: |
111 | void displayText( QString, QString); | 115 | void displayText( QString, QString); |
112 | void displayFile( QString, QString); | 116 | void displayFile( QString, QString); |
113 | 117 | ||
114 | void enableIncidenceActions( bool ); | 118 | void enableIncidenceActions( bool ); |
115 | 119 | ||
116 | private slots: | 120 | private slots: |
121 | QSocket* piSocket; | ||
122 | QString piFileString; | ||
123 | QTime piTime; | ||
124 | void deleteCommandSocket(); | ||
125 | void deleteCommandSocketFinish(); | ||
117 | void fillSyncMenu(); | 126 | void fillSyncMenu(); |
118 | void sendFile(QSocket* s); | 127 | void sendFile(QSocket* s); |
119 | void getFile(QSocket* socket); | 128 | void getFile(QSocket* socket); |
120 | void readFileFromSocket(); | 129 | void readFileFromSocket(); |
130 | void readBackFileFromSocket(); | ||
121 | void endConnect(); | 131 | void endConnect(); |
122 | private: | 132 | private: |
133 | QTimer* mTimerCommandSocket; | ||
134 | QString mPassWordPiSync; | ||
123 | QSocket* mCommandSocket; | 135 | QSocket* mCommandSocket; |
124 | QSocket* mCommandSocketFinish; | 136 | QSocket* mCommandSocketFinish; |
125 | KServerSocket * mServerSocket; | 137 | KServerSocket * mServerSocket; |
126 | bool mClosed; | 138 | bool mClosed; |
127 | void saveOnClose(); | 139 | void saveOnClose(); |
128 | int mCurrentSyncProfile; | 140 | int mCurrentSyncProfile; |
129 | void enableQuick(); | 141 | void enableQuick(); |
130 | void performQuick(); | 142 | void performQuick(); |
131 | void performQuickQuick(); | 143 | void performQuickQuick(); |
132 | void syncRemote( KSyncProfile* , bool ask = true); | 144 | void syncRemote( KSyncProfile* , bool ask = true); |
133 | bool mFlagKeyPressed; | 145 | bool mFlagKeyPressed; |
134 | bool mBlockAtStartup; | 146 | bool mBlockAtStartup; |
135 | QPEToolBar *iconToolBar; | 147 | QPEToolBar *iconToolBar; |
136 | void initActions(); | 148 | void initActions(); |
137 | void setDefaultPreferences(); | 149 | void setDefaultPreferences(); |
138 | void keyPressEvent ( QKeyEvent * ) ; | 150 | void keyPressEvent ( QKeyEvent * ) ; |
139 | void keyReleaseEvent ( QKeyEvent * ) ; | 151 | void keyReleaseEvent ( QKeyEvent * ) ; |
140 | QPopupMenu *configureToolBarMenu; | 152 | QPopupMenu *configureToolBarMenu; |
141 | QPopupMenu *selectFilterMenu; | 153 | QPopupMenu *selectFilterMenu; |
142 | QPopupMenu *configureAgendaMenu, *syncMenu; | 154 | QPopupMenu *configureAgendaMenu, *syncMenu; |
143 | CalendarLocal *mCalendar; | 155 | CalendarLocal *mCalendar; |
144 | CalendarView *mView; | 156 | CalendarView *mView; |
145 | QString getPassword(); | 157 | QString getPassword(); |
146 | QAction *mNewSubTodoAction; | 158 | QAction *mNewSubTodoAction; |
147 | 159 | ||
148 | QAction *mShowAction; | 160 | QAction *mShowAction; |
149 | QAction *mEditAction; | 161 | QAction *mEditAction; |
150 | QAction *mDeleteAction; | 162 | QAction *mDeleteAction; |
151 | void closeEvent( QCloseEvent* ce ); | 163 | void closeEvent( QCloseEvent* ce ); |
152 | SimpleAlarmClient mAlarmClient; | 164 | SimpleAlarmClient mAlarmClient; |
153 | QTimer mSaveTimer; | 165 | QTimer mSaveTimer; |
154 | bool mBlockSaveFlag; | 166 | bool mBlockSaveFlag; |
155 | bool mCalendarModifiedFlag; | 167 | bool mCalendarModifiedFlag; |
156 | QPixmap loadPixmap( QString ); | 168 | QPixmap loadPixmap( QString ); |
157 | QDialog * mSyncActionDialog; | 169 | QDialog * mSyncActionDialog; |
158 | }; | 170 | }; |
159 | 171 | ||
160 | 172 | ||
161 | #endif | 173 | #endif |