-rw-r--r-- | libkdepim/ksyncmanager.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 795cd30..d2cb71b 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1095,115 +1095,114 @@ bool KSyncManager::isProgressBarCanceled() | |||
1095 | return !bar->isVisible(); | 1095 | return !bar->isVisible(); |
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | QString KSyncManager::syncFileName() | 1098 | QString KSyncManager::syncFileName() |
1099 | { | 1099 | { |
1100 | 1100 | ||
1101 | QString fn = "tempfile"; | 1101 | QString fn = "tempfile"; |
1102 | switch(mTargetApp) | 1102 | switch(mTargetApp) |
1103 | { | 1103 | { |
1104 | case (KAPI): | 1104 | case (KAPI): |
1105 | fn = "tempsyncab.vcf"; | 1105 | fn = "tempsyncab.vcf"; |
1106 | break; | 1106 | break; |
1107 | case (KOPI): | 1107 | case (KOPI): |
1108 | fn = "tempsynccal.ics"; | 1108 | fn = "tempsynccal.ics"; |
1109 | break; | 1109 | break; |
1110 | case (PWMPI): | 1110 | case (PWMPI): |
1111 | fn = "tempsyncpw.pwm"; | 1111 | fn = "tempsyncpw.pwm"; |
1112 | break; | 1112 | break; |
1113 | default: | 1113 | default: |
1114 | break; | 1114 | break; |
1115 | } | 1115 | } |
1116 | #ifdef DESKTOP_VERSION | 1116 | #ifdef DESKTOP_VERSION |
1117 | return locateLocal( "tmp", fn ); | 1117 | return locateLocal( "tmp", fn ); |
1118 | #else | 1118 | #else |
1119 | return (QString( "/tmp/" )+ fn ); | 1119 | return (QString( "/tmp/" )+ fn ); |
1120 | #endif | 1120 | #endif |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | void KSyncManager::syncPi() | 1123 | void KSyncManager::syncPi() |
1124 | { | 1124 | { |
1125 | mIsKapiFile = true; | 1125 | mIsKapiFile = true; |
1126 | mPisyncFinished = false; | 1126 | mPisyncFinished = false; |
1127 | qApp->processEvents(); | 1127 | qApp->processEvents(); |
1128 | if ( mAskForPreferences ) | 1128 | if ( mAskForPreferences ) |
1129 | if ( !edit_pisync_options()) { | 1129 | if ( !edit_pisync_options()) { |
1130 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1130 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1131 | mPisyncFinished = true; | 1131 | mPisyncFinished = true; |
1132 | return; | 1132 | return; |
1133 | } | 1133 | } |
1134 | bool ok; | 1134 | bool ok; |
1135 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 1135 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
1136 | if ( ! ok ) { | 1136 | if ( ! ok ) { |
1137 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1137 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1138 | mPisyncFinished = true; | 1138 | mPisyncFinished = true; |
1139 | return; | 1139 | return; |
1140 | } | 1140 | } |
1141 | mCurrentResourceLocal = ""; | 1141 | mCurrentResourceLocal = ""; |
1142 | mCurrentResourceRemote = ""; | 1142 | mCurrentResourceRemote = ""; |
1143 | qDebug ( "KSM: sync pi %d",mSpecificResources.count() ); | ||
1144 | if ( mSpecificResources.count() ) { | 1143 | if ( mSpecificResources.count() ) { |
1145 | int lastSyncRes = mSpecificResources.count()/2; | 1144 | int lastSyncRes = mSpecificResources.count()/2; |
1146 | int ccc = mSpecificResources.count()-1; | 1145 | int ccc = mSpecificResources.count()-1; |
1147 | while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { | 1146 | while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { |
1148 | --ccc; | 1147 | --ccc; |
1149 | --lastSyncRes; | 1148 | --lastSyncRes; |
1150 | qDebug ( "KSM: sync pi %d",ccc ); | 1149 | //qDebug ( "KSM: sync pi %d",ccc ); |
1151 | } | 1150 | } |
1152 | int startLocal = 0; | 1151 | int startLocal = 0; |
1153 | int startRemote = mSpecificResources.count()/2; | 1152 | int startRemote = mSpecificResources.count()/2; |
1154 | emit multiResourceSyncStart( true ); | 1153 | emit multiResourceSyncStart( true ); |
1155 | while ( startLocal < mSpecificResources.count()/2 ) { | 1154 | while ( startLocal < mSpecificResources.count()/2 ) { |
1156 | if ( startLocal+1 >= lastSyncRes ) | 1155 | if ( startLocal+1 >= lastSyncRes ) |
1157 | emit multiResourceSyncStart( false ); | 1156 | emit multiResourceSyncStart( false ); |
1158 | mPisyncFinished = false; | 1157 | mPisyncFinished = false; |
1159 | mCurrentResourceLocal = mSpecificResources[ startLocal ]; | 1158 | mCurrentResourceLocal = mSpecificResources[ startLocal ]; |
1160 | mCurrentResourceRemote = mSpecificResources[ startRemote ]; | 1159 | mCurrentResourceRemote = mSpecificResources[ startRemote ]; |
1161 | qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); | 1160 | //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); |
1162 | if ( !mCurrentResourceRemote.isEmpty() ) { | 1161 | if ( !mCurrentResourceRemote.isEmpty() ) { |
1163 | qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); | 1162 | qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); |
1164 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); | 1163 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); |
1165 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1164 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1166 | commandSocket->readFile( syncFileName() ); | 1165 | commandSocket->readFile( syncFileName() ); |
1167 | while ( !mPisyncFinished ) { | 1166 | while ( !mPisyncFinished ) { |
1168 | //qDebug("waiting "); | 1167 | //qDebug("waiting "); |
1169 | qApp->processEvents(); | 1168 | qApp->processEvents(); |
1170 | } | 1169 | } |
1171 | } | 1170 | } |
1172 | ++startRemote; | 1171 | ++startRemote; |
1173 | ++startLocal; | 1172 | ++startLocal; |
1174 | } | 1173 | } |
1175 | mPisyncFinished = true; | 1174 | mPisyncFinished = true; |
1176 | } else { | 1175 | } else { |
1177 | KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); | 1176 | KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); |
1178 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1177 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1179 | commandSocket->readFile( syncFileName() ); | 1178 | commandSocket->readFile( syncFileName() ); |
1180 | } | 1179 | } |
1181 | } | 1180 | } |
1182 | 1181 | ||
1183 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 1182 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
1184 | { | 1183 | { |
1185 | //enum { success, errorW, errorR, quiet }; | 1184 | //enum { success, errorW, errorR, quiet }; |
1186 | 1185 | ||
1187 | 1186 | ||
1188 | 1187 | ||
1189 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || | 1188 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || |
1190 | state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { | 1189 | state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { |
1191 | if ( state == KCommandSocket::errorPW ) | 1190 | if ( state == KCommandSocket::errorPW ) |
1192 | mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); | 1191 | mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); |
1193 | else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) | 1192 | else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) |
1194 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 1193 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
1195 | else if ( state == KCommandSocket::errorCA ) | 1194 | else if ( state == KCommandSocket::errorCA ) |
1196 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); | 1195 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); |
1197 | else if ( state == KCommandSocket::errorFI ) | 1196 | else if ( state == KCommandSocket::errorFI ) |
1198 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); | 1197 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); |
1199 | else if ( state == KCommandSocket::errorED ) | 1198 | else if ( state == KCommandSocket::errorED ) |
1200 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); | 1199 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); |
1201 | else if ( state == KCommandSocket::errorUN ) | 1200 | else if ( state == KCommandSocket::errorUN ) |
1202 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); | 1201 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); |
1203 | delete s; | 1202 | delete s; |
1204 | if ( state == KCommandSocket::errorR ) { | 1203 | if ( state == KCommandSocket::errorR ) { |
1205 | KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); | 1204 | KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); |
1206 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1205 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1207 | commandSocket->sendStop(); | 1206 | commandSocket->sendStop(); |
1208 | } | 1207 | } |
1209 | mPisyncFinished = true; | 1208 | mPisyncFinished = true; |