summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
Unidiff
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 80fb147..df53235 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -571,13 +571,13 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
571 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 571 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
572 int fileSize = 0; 572 int fileSize = 0;
573 int result = system ( preCommand ); 573 int result = system ( preCommand );
574 // 0 : okay 574 // 0 : okay
575 // 256: no such file or dir 575 // 256: no such file or dir
576 // 576 //
577 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 577 qDebug("Sync: Remote copy result(0 = okay): %d ",result );
578 if ( result != 0 ) { 578 if ( result != 0 ) {
579 unsigned int len = maxlen; 579 unsigned int len = maxlen;
580 while ( len < preCommand.length() ) { 580 while ( len < preCommand.length() ) {
581 preCommand.insert( len , "\n" ); 581 preCommand.insert( len , "\n" );
582 len += maxlen +2; 582 len += maxlen +2;
583 } 583 }
@@ -599,13 +599,13 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
599 QString pwd = getPassword(); 599 QString pwd = getPassword();
600 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 600 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
601 601
602 } 602 }
603 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 603 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
604 result = system ( postCommand ); 604 result = system ( postCommand );
605 qDebug("Writing back file result: %d ", result); 605 qDebug("Sync:Writing back file result: %d ", result);
606 if ( result != 0 ) { 606 if ( result != 0 ) {
607 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 607 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
608 return; 608 return;
609 } else { 609 } else {
610 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 610 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
611 } 611 }
@@ -742,24 +742,24 @@ void KSyncManager::confSync()
742} 742}
743 743
744void KSyncManager::syncSharp() 744void KSyncManager::syncSharp()
745{ 745{
746 746
747 if ( ! syncExternalApplication("sharp") ) 747 if ( ! syncExternalApplication("sharp") )
748 qDebug("ERROR sync sharp ");; 748 qDebug("ERROR sync sharp ");
749} 749}
750 750
751bool KSyncManager::syncExternalApplication(QString resource) 751bool KSyncManager::syncExternalApplication(QString resource)
752{ 752{
753 753
754 emit save(); 754 emit save();
755 755
756 if ( mAskForPreferences ) 756 if ( mAskForPreferences )
757 edit_sync_options(); 757 edit_sync_options();
758 758
759 qDebug("sync %s", resource.latin1()); 759 qDebug("Sync extern %s", resource.latin1());
760 760
761 bool syncOK = mImplementation->syncExternal(this, resource); 761 bool syncOK = mImplementation->syncExternal(this, resource);
762 762
763 return syncOK; 763 return syncOK;
764 764
765} 765}
@@ -835,14 +835,12 @@ void KSyncManager::syncPi()
835 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 835 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
836 commandSocket->readFile( syncFileName() ); 836 commandSocket->readFile( syncFileName() );
837} 837}
838 838
839void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 839void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
840{ 840{
841 qDebug("MainWindow::deleteCommandSocket %d", state);
842
843 //enum { success, errorW, errorR, quiet }; 841 //enum { success, errorW, errorR, quiet };
844 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 842 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
845 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 843 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
846 delete s; 844 delete s;
847 if ( state == KCommandSocket::errorR ) { 845 if ( state == KCommandSocket::errorR ) {
848 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 846 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
@@ -867,13 +865,12 @@ void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
867void KSyncManager::readFileFromSocket() 865void KSyncManager::readFileFromSocket()
868{ 866{
869 QString fileName = syncFileName(); 867 QString fileName = syncFileName();
870 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 868 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
871 if ( ! syncWithFile( fileName , true ) ) { 869 if ( ! syncWithFile( fileName , true ) ) {
872 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 870 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
873 qDebug("Syncing failed ");
874 return; 871 return;
875 } 872 }
876 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 873 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
877 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 874 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
878 if ( mWriteBackFile ) 875 if ( mWriteBackFile )
879 commandSocket->writeFile( fileName ); 876 commandSocket->writeFile( fileName );
@@ -919,35 +916,35 @@ void KServerSocket::readClient()
919 if ( blockRC ) 916 if ( blockRC )
920 return; 917 return;
921 if ( mSocket == 0 ) { 918 if ( mSocket == 0 ) {
922 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 919 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
923 return; 920 return;
924 } 921 }
925 qDebug("KServerSocket readClient()"); 922 //qDebug("KServerSocket::readClient()");
926 if ( mSocket->canReadLine() ) { 923 if ( mSocket->canReadLine() ) {
927 QString line = mSocket->readLine(); 924 QString line = mSocket->readLine();
928 qDebug("KServerSocket readline: %s ", line.latin1()); 925 //qDebug("KServerSocket readline: %s ", line.latin1());
929 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 926 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
930 if ( tokens[0] == "GET" ) { 927 if ( tokens[0] == "GET" ) {
931 if ( tokens[1] == mPassWord ) 928 if ( tokens[1] == mPassWord )
932 //emit sendFile( mSocket ); 929 //emit sendFile( mSocket );
933 send_file(); 930 send_file();
934 else { 931 else {
935 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); 932 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
936 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 933 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
937 } 934 }
938 } 935 }
939 if ( tokens[0] == "PUT" ) { 936 if ( tokens[0] == "PUT" ) {
940 if ( tokens[1] == mPassWord ) { 937 if ( tokens[1] == mPassWord ) {
941 //emit getFile( mSocket ); 938 //emit getFile( mSocket );
942 blockRC = true; 939 blockRC = true;
943 get_file(); 940 get_file();
944 } 941 }
945 else { 942 else {
946 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); 943 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
947 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 944 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
948 } 945 }
949 } 946 }
950 if ( tokens[0] == "STOP" ) { 947 if ( tokens[0] == "STOP" ) {
951 //emit endConnect(); 948 //emit endConnect();
952 end_connect(); 949 end_connect();
953 } 950 }
@@ -970,13 +967,12 @@ void KServerSocket::send_file()
970 lay->addWidget( label); 967 lay->addWidget( label);
971 lay->setMargin(7); 968 lay->setMargin(7);
972 lay->setSpacing(7); 969 lay->setSpacing(7);
973 mSyncActionDialog->setFixedSize( 230, 120); 970 mSyncActionDialog->setFixedSize( 230, 120);
974 mSyncActionDialog->show(); 971 mSyncActionDialog->show();
975 mSyncActionDialog->raise(); 972 mSyncActionDialog->raise();
976 qDebug("KSS::saving ... ");
977 emit request_file(); 973 emit request_file();
978 qApp->processEvents(); 974 qApp->processEvents();
979 QString fileName = mFileName; 975 QString fileName = mFileName;
980 QFile file( fileName ); 976 QFile file( fileName );
981 if (!file.open( IO_ReadOnly ) ) { 977 if (!file.open( IO_ReadOnly ) ) {
982 delete mSyncActionDialog; 978 delete mSyncActionDialog;
@@ -1033,13 +1029,13 @@ void KServerSocket::readBackFileFromSocket()
1033 } 1029 }
1034 QString fileName = mFileName; 1030 QString fileName = mFileName;
1035 QFile file ( fileName ); 1031 QFile file ( fileName );
1036 if (!file.open( IO_WriteOnly ) ) { 1032 if (!file.open( IO_WriteOnly ) ) {
1037 delete mSyncActionDialog; 1033 delete mSyncActionDialog;
1038 mSyncActionDialog = 0; 1034 mSyncActionDialog = 0;
1039 qDebug("error open cal file "); 1035 qDebug("KSS:Error open read back file ");
1040 piFileString = ""; 1036 piFileString = "";
1041 emit file_received( false ); 1037 emit file_received( false );
1042 blockRC = false; 1038 blockRC = false;
1043 return ; 1039 return ;
1044 1040
1045 } 1041 }
@@ -1166,13 +1162,13 @@ void KCommandSocket::readFileFromSocket()
1166 } 1162 }
1167 QString fileName = mFileName; 1163 QString fileName = mFileName;
1168 QFile file ( fileName ); 1164 QFile file ( fileName );
1169 if (!file.open( IO_WriteOnly ) ) { 1165 if (!file.open( IO_WriteOnly ) ) {
1170 mFileString = ""; 1166 mFileString = "";
1171 mRetVal = errorR; 1167 mRetVal = errorR;
1172 qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); 1168 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1173 deleteSocket(); 1169 deleteSocket();
1174 return ; 1170 return ;
1175 1171
1176 } 1172 }
1177 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1173 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1178 QTextStream ts ( &file ); 1174 QTextStream ts ( &file );