summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 2a75bfb..d71264f 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -913,385 +913,385 @@ void KSyncManager::confSync()
913 QStringList oldSyncProfileNames = mSyncProfileNames; 913 QStringList oldSyncProfileNames = mSyncProfileNames;
914 mSyncProfileNames = sp->getSyncProfileNames(); 914 mSyncProfileNames = sp->getSyncProfileNames();
915 mLocalMachineName = sp->getLocalMachineName (); 915 mLocalMachineName = sp->getLocalMachineName ();
916 int ii; 916 int ii;
917 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 917 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
918 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 918 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
919 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 919 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
920 } 920 }
921 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 921 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
922} 922}
923void KSyncManager::syncKDE() 923void KSyncManager::syncKDE()
924{ 924{
925 mSyncWithDesktop = true; 925 mSyncWithDesktop = true;
926 emit save(); 926 emit save();
927 switch(mTargetApp) 927 switch(mTargetApp)
928 { 928 {
929 case (KAPI): 929 case (KAPI):
930 { 930 {
931#ifdef DESKTOP_VERSION 931#ifdef DESKTOP_VERSION
932 QString command = "kdeabdump33"; 932 QString command = "kdeabdump33";
933 QString commandfile = "kdeabdump33"; 933 QString commandfile = "kdeabdump33";
934 QString commandpath = qApp->applicationDirPath () + "/"; 934 QString commandpath = qApp->applicationDirPath () + "/";
935#else 935#else
936 QString command = "kdeabdump33"; 936 QString command = "kdeabdump33";
937 QString commandfile = "kdeabdump33"; 937 QString commandfile = "kdeabdump33";
938 QString commandpath = QDir::homeDirPath ()+"/"; 938 QString commandpath = QDir::homeDirPath ()+"/";
939#endif 939#endif
940 if ( ! QFile::exists ( commandpath+commandfile ) ) 940 if ( ! QFile::exists ( commandpath+commandfile ) )
941 command = commandfile; 941 command = commandfile;
942 else 942 else
943 command = commandpath+commandfile; 943 command = commandpath+commandfile;
944 944
945 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 945 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
946 int result = system ( command.latin1()); 946 int result = system ( command.latin1());
947 qDebug("AB dump 33 command call result: %d ", result); 947 qDebug("AB dump 33 command call result: %d ", result);
948 if ( result != 0 ) { 948 if ( result != 0 ) {
949 qDebug("Calling AB dump version 33 failed. Trying 34... "); 949 qDebug("Calling AB dump version 33 failed. Trying 34... ");
950 commandfile = "kdeabdump34"; 950 commandfile = "kdeabdump34";
951 if ( ! QFile::exists ( commandpath+commandfile ) ) 951 if ( ! QFile::exists ( commandpath+commandfile ) )
952 command = commandfile; 952 command = commandfile;
953 else 953 else
954 command = commandpath+commandfile; 954 command = commandpath+commandfile;
955 result = system ( command.latin1()); 955 result = system ( command.latin1());
956 qDebug("AB dump 34 command call result: %d ", result); 956 qDebug("AB dump 34 command call result: %d ", result);
957 if ( result != 0 ) { 957 if ( result != 0 ) {
958 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 958 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
959 return; 959 return;
960 } 960 }
961 } 961 }
962 if ( syncWithFile( fileName,true ) ) { 962 if ( syncWithFile( fileName,true ) ) {
963 if ( mWriteBackFile ) { 963 if ( mWriteBackFile ) {
964 command += " --read"; 964 command += " --read";
965 system ( command.latin1()); 965 system ( command.latin1());
966 } 966 }
967 } 967 }
968 968
969 } 969 }
970 break; 970 break;
971 case (KOPI): 971 case (KOPI):
972 { 972 {
973#ifdef DESKTOP_VERSION 973#ifdef DESKTOP_VERSION
974 QString command = "kdecaldump33"; 974 QString command = "kdecaldump33";
975 QString commandfile = "kdecaldump33"; 975 QString commandfile = "kdecaldump33";
976 QString commandpath = qApp->applicationDirPath () + "/"; 976 QString commandpath = qApp->applicationDirPath () + "/";
977#else 977#else
978 QString command = "kdecaldump33"; 978 QString command = "kdecaldump33";
979 QString commandfile = "kdecaldump33"; 979 QString commandfile = "kdecaldump33";
980 QString commandpath = QDir::homeDirPath ()+"/"; 980 QString commandpath = QDir::homeDirPath ()+"/";
981#endif 981#endif
982 if ( ! QFile::exists ( commandpath+commandfile ) ) 982 if ( ! QFile::exists ( commandpath+commandfile ) )
983 command = commandfile; 983 command = commandfile;
984 else 984 else
985 command = commandpath+commandfile; 985 command = commandpath+commandfile;
986 986
987 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 987 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
988 int result = system ( command.latin1()); 988 int result = system ( command.latin1());
989 qDebug("Cal dump 33 command call result result: %d ", result); 989 qDebug("Cal dump 33 command call result result: %d ", result);
990 if ( result != 0 ) { 990 if ( result != 0 ) {
991 qDebug("Calling CAL dump version 33 failed. Trying 34... "); 991 qDebug("Calling CAL dump version 33 failed. Trying 34... ");
992 commandfile = "kdecaldump34"; 992 commandfile = "kdecaldump34";
993 if ( ! QFile::exists ( commandpath+commandfile ) ) 993 if ( ! QFile::exists ( commandpath+commandfile ) )
994 command = commandfile; 994 command = commandfile;
995 else 995 else
996 command = commandpath+commandfile; 996 command = commandpath+commandfile;
997 result = system ( command.latin1()); 997 result = system ( command.latin1());
998 qDebug("Cal dump 34 command call result result: %d ", result); 998 qDebug("Cal dump 34 command call result result: %d ", result);
999 if ( result != 0 ) { 999 if ( result != 0 ) {
1000 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 1000 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
1001 return; 1001 return;
1002 } 1002 }
1003 } 1003 }
1004 if ( syncWithFile( fileName,true ) ) { 1004 if ( syncWithFile( fileName,true ) ) {
1005 if ( mWriteBackFile ) { 1005 if ( mWriteBackFile ) {
1006 command += " --read"; 1006 command += " --read";
1007 system ( command.latin1()); 1007 system ( command.latin1());
1008 } 1008 }
1009 } 1009 }
1010 1010
1011 } 1011 }
1012 break; 1012 break;
1013 case (PWMPI): 1013 case (PWMPI):
1014 1014
1015 break; 1015 break;
1016 default: 1016 default:
1017 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 1017 qDebug("KSM::slotSyncMenu: invalid apptype selected");
1018 break; 1018 break;
1019 1019
1020 } 1020 }
1021} 1021}
1022 1022
1023void KSyncManager::syncSharp() 1023void KSyncManager::syncSharp()
1024{ 1024{
1025 1025
1026 if ( ! syncExternalApplication("sharp") ) 1026 if ( ! syncExternalApplication("sharp") )
1027 qDebug("KSM::ERROR sync sharp "); 1027 qDebug("KSM::ERROR sync sharp ");
1028} 1028}
1029 1029
1030bool KSyncManager::syncExternalApplication(QString resource) 1030bool KSyncManager::syncExternalApplication(QString resource)
1031{ 1031{
1032 1032
1033 emit save(); 1033 emit save();
1034 1034
1035 if ( mAskForPreferences ) 1035 if ( mAskForPreferences )
1036 if ( !edit_sync_options()) { 1036 if ( !edit_sync_options()) {
1037 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1037 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1038 return false; 1038 return false;
1039 } 1039 }
1040 1040
1041 qDebug("KSM::Sync extern %s", resource.latin1()); 1041 qDebug("KSM::Sync extern %s", resource.latin1());
1042 1042
1043 bool syncOK = mImplementation->syncExternal(this, resource); 1043 bool syncOK = mImplementation->syncExternal(this, resource);
1044 1044
1045 return syncOK; 1045 return syncOK;
1046 1046
1047} 1047}
1048 1048
1049void KSyncManager::syncPhone() 1049void KSyncManager::syncPhone()
1050{ 1050{
1051 1051
1052 syncExternalApplication("phone"); 1052 syncExternalApplication("phone");
1053 1053
1054} 1054}
1055 1055
1056void KSyncManager::showProgressBar(int percentage, QString caption, int total) 1056void KSyncManager::showProgressBar(int percentage, QString caption, int total)
1057{ 1057{
1058 if (!bar->isVisible()) 1058 if (!bar->isVisible())
1059 { 1059 {
1060 int w = 300; 1060 int w = 300;
1061 if ( QApplication::desktop()->width() < 320 ) 1061 if ( QApplication::desktop()->width() < 320 )
1062 w = 220; 1062 w = 220;
1063 int h = bar->sizeHint().height() ; 1063 int h = bar->sizeHint().height() ;
1064 int dw = QApplication::desktop()->width(); 1064 int dw = QApplication::desktop()->width();
1065 int dh = QApplication::desktop()->height(); 1065 int dh = QApplication::desktop()->height();
1066 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1066 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1067 bar->setCaption (caption); 1067 bar->setCaption (caption);
1068 bar->setTotalSteps ( total ) ; 1068 bar->setTotalSteps ( total ) ;
1069 bar->show(); 1069 bar->show();
1070 } 1070 }
1071 bar->raise(); 1071 bar->raise();
1072 bar->setProgress( percentage ); 1072 bar->setProgress( percentage );
1073 qApp->processEvents(); 1073 qApp->processEvents();
1074} 1074}
1075 1075
1076void KSyncManager::hideProgressBar() 1076void KSyncManager::hideProgressBar()
1077{ 1077{
1078 bar->hide(); 1078 bar->hide();
1079 qApp->processEvents(); 1079 qApp->processEvents();
1080} 1080}
1081 1081
1082bool KSyncManager::isProgressBarCanceled() 1082bool KSyncManager::isProgressBarCanceled()
1083{ 1083{
1084 return !bar->isVisible(); 1084 return !bar->isVisible();
1085} 1085}
1086 1086
1087QString KSyncManager::syncFileName() 1087QString KSyncManager::syncFileName()
1088{ 1088{
1089 1089
1090 QString fn = "tempfile"; 1090 QString fn = "tempfile";
1091 switch(mTargetApp) 1091 switch(mTargetApp)
1092 { 1092 {
1093 case (KAPI): 1093 case (KAPI):
1094 fn = "tempsyncab.vcf"; 1094 fn = "tempsyncab.vcf";
1095 break; 1095 break;
1096 case (KOPI): 1096 case (KOPI):
1097 fn = "tempsynccal.ics"; 1097 fn = "tempsynccal.ics";
1098 break; 1098 break;
1099 case (PWMPI): 1099 case (PWMPI):
1100 fn = "tempsyncpw.pwm"; 1100 fn = "tempsyncpw.pwm";
1101 break; 1101 break;
1102 default: 1102 default:
1103 break; 1103 break;
1104 } 1104 }
1105#ifdef _WIN32_ 1105#ifdef DESKTOP_VERSION
1106 return locateLocal( "tmp", fn ); 1106 return locateLocal( "tmp", fn );
1107#else 1107#else
1108 return (QString( "/tmp/" )+ fn ); 1108 return (QString( "/tmp/" )+ fn );
1109#endif 1109#endif
1110} 1110}
1111 1111
1112void KSyncManager::syncPi() 1112void KSyncManager::syncPi()
1113{ 1113{
1114 mIsKapiFile = true; 1114 mIsKapiFile = true;
1115 mPisyncFinished = false; 1115 mPisyncFinished = false;
1116 qApp->processEvents(); 1116 qApp->processEvents();
1117 if ( mAskForPreferences ) 1117 if ( mAskForPreferences )
1118 if ( !edit_pisync_options()) { 1118 if ( !edit_pisync_options()) {
1119 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1119 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1120 mPisyncFinished = true; 1120 mPisyncFinished = true;
1121 return; 1121 return;
1122 } 1122 }
1123 bool ok; 1123 bool ok;
1124 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1124 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1125 if ( ! ok ) { 1125 if ( ! ok ) {
1126 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1126 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1127 mPisyncFinished = true; 1127 mPisyncFinished = true;
1128 return; 1128 return;
1129 } 1129 }
1130 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1130 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1131 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1131 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1132 commandSocket->readFile( syncFileName() ); 1132 commandSocket->readFile( syncFileName() );
1133} 1133}
1134 1134
1135void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1135void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1136{ 1136{
1137 //enum { success, errorW, errorR, quiet }; 1137 //enum { success, errorW, errorR, quiet };
1138 1138
1139 1139
1140 1140
1141 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || 1141 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW ||
1142 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { 1142 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) {
1143 if ( state == KCommandSocket::errorPW ) 1143 if ( state == KCommandSocket::errorPW )
1144 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); 1144 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") );
1145 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) 1145 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO )
1146 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1146 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1147 else if ( state == KCommandSocket::errorCA ) 1147 else if ( state == KCommandSocket::errorCA )
1148 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); 1148 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") );
1149 else if ( state == KCommandSocket::errorFI ) 1149 else if ( state == KCommandSocket::errorFI )
1150 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); 1150 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") );
1151 else if ( state == KCommandSocket::errorED ) 1151 else if ( state == KCommandSocket::errorED )
1152 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); 1152 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") );
1153 else if ( state == KCommandSocket::errorUN ) 1153 else if ( state == KCommandSocket::errorUN )
1154 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); 1154 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") );
1155 delete s; 1155 delete s;
1156 if ( state == KCommandSocket::errorR ) { 1156 if ( state == KCommandSocket::errorR ) {
1157 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); 1157 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget());
1158 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1158 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1159 commandSocket->sendStop(); 1159 commandSocket->sendStop();
1160 } 1160 }
1161 mPisyncFinished = true; 1161 mPisyncFinished = true;
1162 return; 1162 return;
1163 1163
1164 } else if ( state == KCommandSocket::errorW ) { 1164 } else if ( state == KCommandSocket::errorW ) {
1165 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1165 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1166 mPisyncFinished = true; 1166 mPisyncFinished = true;
1167 1167
1168 } else if ( state == KCommandSocket::successR ) { 1168 } else if ( state == KCommandSocket::successR ) {
1169 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1169 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1170 1170
1171 } else if ( state == KCommandSocket::successW ) { 1171 } else if ( state == KCommandSocket::successW ) {
1172 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 1172 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
1173 mPisyncFinished = true; 1173 mPisyncFinished = true;
1174 } else if ( state == KCommandSocket::quiet ){ 1174 } else if ( state == KCommandSocket::quiet ){
1175 qDebug("KSS: quiet "); 1175 qDebug("KSS: quiet ");
1176 mPisyncFinished = true; 1176 mPisyncFinished = true;
1177 } else { 1177 } else {
1178 qDebug("KSS: Error: unknown state: %d ", state); 1178 qDebug("KSS: Error: unknown state: %d ", state);
1179 mPisyncFinished = true; 1179 mPisyncFinished = true;
1180 } 1180 }
1181 1181
1182 delete s; 1182 delete s;
1183} 1183}
1184 1184
1185void KSyncManager::readFileFromSocket() 1185void KSyncManager::readFileFromSocket()
1186{ 1186{
1187 QString fileName = syncFileName(); 1187 QString fileName = syncFileName();
1188 bool syncOK = true; 1188 bool syncOK = true;
1189 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1189 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1190 if ( ! syncWithFile( fileName , true ) ) { 1190 if ( ! syncWithFile( fileName , true ) ) {
1191 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1191 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1192 syncOK = false; 1192 syncOK = false;
1193 } 1193 }
1194 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); 1194 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
1195 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1195 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1196 if ( mWriteBackFile && syncOK ) { 1196 if ( mWriteBackFile && syncOK ) {
1197 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); 1197 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") );
1198 commandSocket->writeFile( fileName ); 1198 commandSocket->writeFile( fileName );
1199 } 1199 }
1200 else { 1200 else {
1201 commandSocket->sendStop(); 1201 commandSocket->sendStop();
1202 if ( syncOK ) 1202 if ( syncOK )
1203 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1203 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1204 mPisyncFinished = true; 1204 mPisyncFinished = true;
1205 } 1205 }
1206} 1206}
1207 1207
1208KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1208KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1209{ 1209{
1210 mPassWord = pw; 1210 mPassWord = pw;
1211 mSocket = 0; 1211 mSocket = 0;
1212 mSyncActionDialog = 0; 1212 mSyncActionDialog = 0;
1213 blockRC = false; 1213 blockRC = false;
1214 mErrorMessage = 0; 1214 mErrorMessage = 0;
1215} 1215}
1216 1216
1217void KServerSocket::newConnection ( int socket ) 1217void KServerSocket::newConnection ( int socket )
1218{ 1218{
1219 // qDebug("KServerSocket:New connection %d ", socket); 1219 // qDebug("KServerSocket:New connection %d ", socket);
1220 if ( mSocket ) { 1220 if ( mSocket ) {
1221 qDebug("KSS::newConnection Socket deleted! "); 1221 qDebug("KSS::newConnection Socket deleted! ");
1222 delete mSocket; 1222 delete mSocket;
1223 mSocket = 0; 1223 mSocket = 0;
1224 } 1224 }
1225 mSocket = new QSocket( this ); 1225 mSocket = new QSocket( this );
1226 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1226 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1227 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1227 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1228 mSocket->setSocket( socket ); 1228 mSocket->setSocket( socket );
1229} 1229}
1230 1230
1231void KServerSocket::discardClient() 1231void KServerSocket::discardClient()
1232{ 1232{
1233 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1233 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1234} 1234}
1235void KServerSocket::deleteSocket() 1235void KServerSocket::deleteSocket()
1236{ 1236{
1237 qDebug("KSS::deleteSocket"); 1237 qDebug("KSS::deleteSocket");
1238 if ( mSocket ) { 1238 if ( mSocket ) {
1239 delete mSocket; 1239 delete mSocket;
1240 mSocket = 0; 1240 mSocket = 0;
1241 } 1241 }
1242 if ( mErrorMessage ) 1242 if ( mErrorMessage )
1243 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); 1243 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage()));
1244} 1244}
1245void KServerSocket::readClient() 1245void KServerSocket::readClient()
1246{ 1246{
1247 if ( blockRC ) 1247 if ( blockRC )
1248 return; 1248 return;
1249 if ( mSocket == 0 ) { 1249 if ( mSocket == 0 ) {
1250 qDebug("ERROR::KSS::readClient(): mSocket == 0 "); 1250 qDebug("ERROR::KSS::readClient(): mSocket == 0 ");
1251 return; 1251 return;
1252 } 1252 }
1253 if ( mErrorMessage ) { 1253 if ( mErrorMessage ) {
1254 mErrorMessage = 999; 1254 mErrorMessage = 999;
1255 error_connect("ERROR_ED\r\n\r\n"); 1255 error_connect("ERROR_ED\r\n\r\n");
1256 return; 1256 return;
1257 } 1257 }
1258 mErrorMessage = 0; 1258 mErrorMessage = 0;
1259 //qDebug("KServerSocket::readClient()"); 1259 //qDebug("KServerSocket::readClient()");
1260 if ( mSocket->canReadLine() ) { 1260 if ( mSocket->canReadLine() ) {
1261 QString line = mSocket->readLine(); 1261 QString line = mSocket->readLine();
1262 //qDebug("KServerSocket readline: %s ", line.latin1()); 1262 //qDebug("KServerSocket readline: %s ", line.latin1());
1263 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1263 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1264 if ( tokens[0] == "GET" ) { 1264 if ( tokens[0] == "GET" ) {
1265 if ( tokens[1] == mPassWord ) { 1265 if ( tokens[1] == mPassWord ) {
1266 //emit sendFile( mSocket ); 1266 //emit sendFile( mSocket );
1267 bool ok = false; 1267 bool ok = false;
1268 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1268 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1269 if ( ok ) { 1269 if ( ok ) {
1270 KSyncManager::mRequestedSyncEvent = dt; 1270 KSyncManager::mRequestedSyncEvent = dt;
1271 } 1271 }
1272 else 1272 else
1273 KSyncManager::mRequestedSyncEvent = QDateTime(); 1273 KSyncManager::mRequestedSyncEvent = QDateTime();
1274 send_file(); 1274 send_file();
1275 } 1275 }
1276 else { 1276 else {
1277 mErrorMessage = 1; 1277 mErrorMessage = 1;
1278 error_connect("ERROR_PW\r\n\r\n"); 1278 error_connect("ERROR_PW\r\n\r\n");
1279 } 1279 }
1280 } 1280 }
1281 if ( tokens[0] == "PUT" ) { 1281 if ( tokens[0] == "PUT" ) {
1282 if ( tokens[1] == mPassWord ) { 1282 if ( tokens[1] == mPassWord ) {
1283 //emit getFile( mSocket ); 1283 //emit getFile( mSocket );
1284 blockRC = true; 1284 blockRC = true;
1285 get_file(); 1285 get_file();
1286 } 1286 }
1287 else { 1287 else {
1288 mErrorMessage = 2; 1288 mErrorMessage = 2;
1289 error_connect("ERROR_PW\r\n\r\n"); 1289 error_connect("ERROR_PW\r\n\r\n");
1290 end_connect(); 1290 end_connect();
1291 } 1291 }
1292 } 1292 }
1293 if ( tokens[0] == "STOP" ) { 1293 if ( tokens[0] == "STOP" ) {
1294 //emit endConnect(); 1294 //emit endConnect();
1295 end_connect(); 1295 end_connect();
1296 } 1296 }
1297 } 1297 }