-rw-r--r-- | libkdepim/ksyncmanager.cpp | 12 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 4 |
2 files changed, 12 insertions, 4 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 28af135..fad9a76 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -774,38 +774,40 @@ void KSyncManager::syncPi() | |||
774 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 774 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
775 | if ( ! ok ) { | 775 | if ( ! ok ) { |
776 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 776 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
777 | return; | 777 | return; |
778 | } | 778 | } |
779 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 779 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
780 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 780 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
781 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); | 781 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
782 | commandSocket->readFile( syncFileName() ); | 782 | commandSocket->readFile( syncFileName() ); |
783 | } | 783 | } |
784 | 784 | ||
785 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 785 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
786 | { | 786 | { |
787 | qDebug("MainWindow::deleteCommandSocket %d", state); | 787 | qDebug("MainWindow::deleteCommandSocket %d", state); |
788 | 788 | ||
789 | //enum { success, errorW, errorR, quiet }; | 789 | //enum { success, errorW, errorR, quiet }; |
790 | if ( state == KCommandSocket::errorR ) { | 790 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { |
791 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 791 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
792 | delete s; | 792 | delete s; |
793 | if ( state == KCommandSocket::errorR ) { | ||
793 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 794 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
794 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 795 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
795 | commandSocket->sendStop(); | 796 | commandSocket->sendStop(); |
797 | } | ||
796 | return; | 798 | return; |
797 | 799 | ||
798 | } else if ( state == KCommandSocket::errorW ) { | 800 | } else if ( state == KCommandSocket::errorW ) { |
799 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 801 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
800 | 802 | ||
801 | } else if ( state == KCommandSocket::successR ) { | 803 | } else if ( state == KCommandSocket::successR ) { |
802 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 804 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
803 | 805 | ||
804 | } else if ( state == KCommandSocket::successW ) { | 806 | } else if ( state == KCommandSocket::successW ) { |
805 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 807 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
806 | } | 808 | } |
807 | 809 | ||
808 | delete s; | 810 | delete s; |
809 | } | 811 | } |
810 | 812 | ||
811 | void KSyncManager::readFileFromSocket() | 813 | void KSyncManager::readFileFromSocket() |
@@ -1124,25 +1126,31 @@ void KCommandSocket::readFileFromSocket() | |||
1124 | ts << mFileString; | 1126 | ts << mFileString; |
1125 | file.close(); | 1127 | file.close(); |
1126 | mFileString = ""; | 1128 | mFileString = ""; |
1127 | mRetVal = successR; | 1129 | mRetVal = successR; |
1128 | mSocket->close(); | 1130 | mSocket->close(); |
1129 | // if state is not idle, deleteSocket(); is called via | 1131 | // if state is not idle, deleteSocket(); is called via |
1130 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1132 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1131 | if ( mSocket->state() == QSocket::Idle ) | 1133 | if ( mSocket->state() == QSocket::Idle ) |
1132 | deleteSocket(); | 1134 | deleteSocket(); |
1133 | } | 1135 | } |
1134 | 1136 | ||
1135 | void KCommandSocket::deleteSocket() | 1137 | void KCommandSocket::deleteSocket() |
1136 | { | 1138 | { |
1137 | if ( mTimerSocket->isActive () ) { | 1139 | if ( mTimerSocket->isActive () ) { |
1138 | mTimerSocket->stop(); | 1140 | mTimerSocket->stop(); |
1139 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | 1141 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); |
1140 | mRetVal = errorR; | 1142 | mRetVal = errorTO; |
1143 | if ( mSocket ) { | ||
1144 | mSocket->close(); | ||
1145 | if ( mSocket->state() == QSocket::Idle ) | ||
1146 | deleteSocket(); | ||
1147 | return; | ||
1148 | } | ||
1141 | } | 1149 | } |
1142 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1150 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1143 | if ( mSocket) | 1151 | if ( mSocket) |
1144 | delete mSocket; | 1152 | delete mSocket; |
1145 | mSocket = 0; | 1153 | mSocket = 0; |
1146 | emit commandFinished( this, mRetVal ); | 1154 | emit commandFinished( this, mRetVal ); |
1147 | } | 1155 | } |
1148 | 1156 | ||
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 32400af..25892d8 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -62,33 +62,33 @@ private slots: | |||
62 | bool blockRC; | 62 | bool blockRC; |
63 | void send_file(); | 63 | void send_file(); |
64 | void get_file(); | 64 | void get_file(); |
65 | void end_connect(); | 65 | void end_connect(); |
66 | QDialog* mSyncActionDialog; | 66 | QDialog* mSyncActionDialog; |
67 | QSocket* mSocket; | 67 | QSocket* mSocket; |
68 | QString mPassWord; | 68 | QString mPassWord; |
69 | QString mFileName; | 69 | QString mFileName; |
70 | QTime piTime; | 70 | QTime piTime; |
71 | QString piFileString; | 71 | QString piFileString; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | class KCommandSocket : public QObject | 74 | class KCommandSocket : public QObject |
75 | { | 75 | { |
76 | Q_OBJECT | 76 | Q_OBJECT |
77 | public: | 77 | public: |
78 | enum state { successR, errorR, successW, errorW, quiet }; | 78 | enum state { successR, errorR, successW, errorW, errorTO, quiet }; |
79 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | 79 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); |
80 | void readFile( QString ); | 80 | void readFile( QString ); |
81 | void writeFile( QString ); | 81 | void writeFile( QString ); |
82 | void sendStop(); | 82 | void sendStop(); |
83 | 83 | ||
84 | 84 | ||
85 | signals: | 85 | signals: |
86 | void commandFinished( KCommandSocket*, int ); | 86 | void commandFinished( KCommandSocket*, int ); |
87 | private slots: | 87 | private slots: |
88 | void startReadFileFromSocket(); | 88 | void startReadFileFromSocket(); |
89 | void readFileFromSocket(); | 89 | void readFileFromSocket(); |
90 | void deleteSocket(); | 90 | void deleteSocket(); |
91 | void writeFileToSocket(); | 91 | void writeFileToSocket(); |
92 | private : | 92 | private : |
93 | QSocket* mSocket; | 93 | QSocket* mSocket; |
94 | QString mPassWord; | 94 | QString mPassWord; |
@@ -109,32 +109,33 @@ class KSyncManager : public QObject | |||
109 | 109 | ||
110 | public: | 110 | public: |
111 | enum TargetApp { | 111 | enum TargetApp { |
112 | KOPI = 0, | 112 | KOPI = 0, |
113 | KAPI = 1, | 113 | KAPI = 1, |
114 | PWMPI = 2 }; | 114 | PWMPI = 2 }; |
115 | 115 | ||
116 | 116 | ||
117 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 117 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
118 | ~KSyncManager() ; | 118 | ~KSyncManager() ; |
119 | 119 | ||
120 | bool blockSave() { return mBlockSaveFlag; } | 120 | bool blockSave() { return mBlockSaveFlag; } |
121 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 121 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
122 | void setDefaultFileName( QString s) { mDefFileName = s ;} | 122 | void setDefaultFileName( QString s) { mDefFileName = s ;} |
123 | QString defaultFileName() { return mDefFileName ;} | 123 | QString defaultFileName() { return mDefFileName ;} |
124 | QString syncFileName(); | 124 | QString syncFileName(); |
125 | void fillSyncMenu(); | ||
125 | 126 | ||
126 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 127 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
127 | QString getCurrentSyncName() { return mCurrentSyncName; } | 128 | QString getCurrentSyncName() { return mCurrentSyncName; } |
128 | 129 | ||
129 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 130 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
130 | void hideProgressBar(); | 131 | void hideProgressBar(); |
131 | bool isProgressBarCanceled(); | 132 | bool isProgressBarCanceled(); |
132 | 133 | ||
133 | // sync stuff | 134 | // sync stuff |
134 | QString mLocalMachineName; | 135 | QString mLocalMachineName; |
135 | QStringList mExternSyncProfiles; | 136 | QStringList mExternSyncProfiles; |
136 | QStringList mSyncProfileNames; | 137 | QStringList mSyncProfileNames; |
137 | bool mAskForPreferences; | 138 | bool mAskForPreferences; |
138 | bool mShowSyncSummary; | 139 | bool mShowSyncSummary; |
139 | bool mShowSyncEvents; | 140 | bool mShowSyncEvents; |
140 | bool mShowTodoInAgenda; | 141 | bool mShowTodoInAgenda; |
@@ -144,33 +145,32 @@ class KSyncManager : public QObject | |||
144 | bool mWriteBackFile; | 145 | bool mWriteBackFile; |
145 | int mWriteBackInFuture; | 146 | int mWriteBackInFuture; |
146 | QString mPhoneDevice; | 147 | QString mPhoneDevice; |
147 | QString mPhoneConnection; | 148 | QString mPhoneConnection; |
148 | QString mPhoneModel; | 149 | QString mPhoneModel; |
149 | QString mLastSyncedLocalFile; // save! | 150 | QString mLastSyncedLocalFile; // save! |
150 | QString mPassWordPiSync; | 151 | QString mPassWordPiSync; |
151 | QString mActiveSyncPort; | 152 | QString mActiveSyncPort; |
152 | QString mActiveSyncIP ; | 153 | QString mActiveSyncIP ; |
153 | 154 | ||
154 | signals: | 155 | signals: |
155 | void save(); | 156 | void save(); |
156 | void request_file(); | 157 | void request_file(); |
157 | void getFile( bool ); | 158 | void getFile( bool ); |
158 | 159 | ||
159 | public slots: | 160 | public slots: |
160 | void fillSyncMenu(); | ||
161 | void slotSyncMenu( int ); | 161 | void slotSyncMenu( int ); |
162 | void deleteCommandSocket(KCommandSocket*s, int state); | 162 | void deleteCommandSocket(KCommandSocket*s, int state); |
163 | void readFileFromSocket(); | 163 | void readFileFromSocket(); |
164 | 164 | ||
165 | private: | 165 | private: |
166 | // LR ******************************* | 166 | // LR ******************************* |
167 | // sync stuff! | 167 | // sync stuff! |
168 | void syncPi(); | 168 | void syncPi(); |
169 | KServerSocket * mServerSocket; | 169 | KServerSocket * mServerSocket; |
170 | void enableQuick(); | 170 | void enableQuick(); |
171 | KPimPrefs* mPrefs; | 171 | KPimPrefs* mPrefs; |
172 | QString mDefFileName; | 172 | QString mDefFileName; |
173 | QString mCurrentSyncDevice; | 173 | QString mCurrentSyncDevice; |
174 | QString mCurrentSyncName; | 174 | QString mCurrentSyncName; |
175 | void quickSyncLocalFile(); | 175 | void quickSyncLocalFile(); |
176 | bool syncWithFile( QString fn , bool quick ); | 176 | bool syncWithFile( QString fn , bool quick ); |