summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
Unidiff
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 0109c02..28c48fe 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -732,49 +732,48 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
732 postCommand = prof->getPostSyncCommand(); 732 postCommand = prof->getPostSyncCommand();
733 localTempFile = prof->getLocalTempFile(); 733 localTempFile = prof->getLocalTempFile();
734 break; 734 break;
735 case (PWMPI): 735 case (PWMPI):
736 preCommand = prof->getPreSyncCommandPWM(); 736 preCommand = prof->getPreSyncCommandPWM();
737 postCommand = prof->getPostSyncCommandPWM(); 737 postCommand = prof->getPostSyncCommandPWM();
738 localTempFile = prof->getLocalTempFilePWM(); 738 localTempFile = prof->getLocalTempFilePWM();
739 break; 739 break;
740 default: 740 default:
741 qDebug("KSM::syncRemote: invalid apptype selected"); 741 qDebug("KSM::syncRemote: invalid apptype selected");
742 break; 742 break;
743 } 743 }
744 744
745 745
746 int fi; 746 int fi;
747 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 747 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
748 QString pwd = getPassword(); 748 QString pwd = getPassword();
749 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 749 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
750 750
751 } 751 }
752 int maxlen = 30; 752 int maxlen = 30;
753 if ( QApplication::desktop()->width() > 320 ) 753 if ( QApplication::desktop()->width() > 320 )
754 maxlen += 25; 754 maxlen += 25;
755 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 755 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
756 int fileSize = 0;
757 int result = system ( preCommand ); 756 int result = system ( preCommand );
758 // 0 : okay 757 // 0 : okay
759 // 256: no such file or dir 758 // 256: no such file or dir
760 // 759 //
761 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); 760 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result );
762 if ( result != 0 ) { 761 if ( result != 0 ) {
763 unsigned int len = maxlen; 762 unsigned int len = maxlen;
764 while ( len < preCommand.length() ) { 763 while ( len < preCommand.length() ) {
765 preCommand.insert( len , "\n" ); 764 preCommand.insert( len , "\n" );
766 len += maxlen +2; 765 len += maxlen +2;
767 } 766 }
768 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 767 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
769 QMessageBox::information( mParent, i18n("Sync - ERROR"), 768 QMessageBox::information( mParent, i18n("Sync - ERROR"),
770 question, 769 question,
771 i18n("Okay!")) ; 770 i18n("Okay!")) ;
772 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 771 mParent->topLevelWidget()->setCaption ("KDE-Pim");
773 return; 772 return;
774 } 773 }
775 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 774 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
776 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 775 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
777 776
778 if ( syncWithFile( localTempFile, true ) ) { 777 if ( syncWithFile( localTempFile, true ) ) {
779 778
780 if ( mWriteBackFile ) { 779 if ( mWriteBackFile ) {
@@ -903,49 +902,49 @@ QString KSyncManager::getPassword( )
903 retfile = lab.text(); 902 retfile = lab.text();
904 dia.hide(); 903 dia.hide();
905 qApp->processEvents(); 904 qApp->processEvents();
906 return retfile; 905 return retfile;
907 906
908} 907}
909 908
910 909
911void KSyncManager::confSync() 910void KSyncManager::confSync()
912{ 911{
913 static KSyncPrefsDialog* sp = 0; 912 static KSyncPrefsDialog* sp = 0;
914 if ( ! sp ) { 913 if ( ! sp ) {
915 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 914 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
916 } 915 }
917 sp->usrReadConfig(); 916 sp->usrReadConfig();
918#ifndef DESKTOP_VERSION 917#ifndef DESKTOP_VERSION
919 sp->showMaximized(); 918 sp->showMaximized();
920#else 919#else
921 sp->show(); 920 sp->show();
922#endif 921#endif
923 sp->exec(); 922 sp->exec();
924 QStringList oldSyncProfileNames = mSyncProfileNames; 923 QStringList oldSyncProfileNames = mSyncProfileNames;
925 mSyncProfileNames = sp->getSyncProfileNames(); 924 mSyncProfileNames = sp->getSyncProfileNames();
926 mLocalMachineName = sp->getLocalMachineName (); 925 mLocalMachineName = sp->getLocalMachineName ();
927 int ii; 926 uint ii;
928 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 927 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
929 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 928 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
930 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 929 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
931 } 930 }
932 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 931 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
933} 932}
934void KSyncManager::syncKDE() 933void KSyncManager::syncKDE()
935{ 934{
936 mSyncWithDesktop = true; 935 mSyncWithDesktop = true;
937 emit save(); 936 emit save();
938 switch(mTargetApp) 937 switch(mTargetApp)
939 { 938 {
940 case (KAPI): 939 case (KAPI):
941 { 940 {
942#ifdef DESKTOP_VERSION 941#ifdef DESKTOP_VERSION
943 QString command = "kdeabdump33"; 942 QString command = "kdeabdump33";
944 QString commandfile = "kdeabdump33"; 943 QString commandfile = "kdeabdump33";
945 QString commandpath = qApp->applicationDirPath () + "/"; 944 QString commandpath = qApp->applicationDirPath () + "/";
946#else 945#else
947 QString command = "kdeabdump33"; 946 QString command = "kdeabdump33";
948 QString commandfile = "kdeabdump33"; 947 QString commandfile = "kdeabdump33";
949 QString commandpath = QDir::homeDirPath ()+"/"; 948 QString commandpath = QDir::homeDirPath ()+"/";
950#endif 949#endif
951 if ( ! QFile::exists ( commandpath+commandfile ) ) 950 if ( ! QFile::exists ( commandpath+commandfile ) )
@@ -1120,57 +1119,57 @@ QString KSyncManager::syncFileName()
1120#endif 1119#endif
1121} 1120}
1122 1121
1123void KSyncManager::syncPi() 1122void KSyncManager::syncPi()
1124{ 1123{
1125 mIsKapiFile = true; 1124 mIsKapiFile = true;
1126 mPisyncFinished = false; 1125 mPisyncFinished = false;
1127 qApp->processEvents(); 1126 qApp->processEvents();
1128 if ( mAskForPreferences ) 1127 if ( mAskForPreferences )
1129 if ( !edit_pisync_options()) { 1128 if ( !edit_pisync_options()) {
1130 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1129 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1131 mPisyncFinished = true; 1130 mPisyncFinished = true;
1132 return; 1131 return;
1133 } 1132 }
1134 bool ok; 1133 bool ok;
1135 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1134 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1136 if ( ! ok ) { 1135 if ( ! ok ) {
1137 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1136 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1138 mPisyncFinished = true; 1137 mPisyncFinished = true;
1139 return; 1138 return;
1140 } 1139 }
1141 mCurrentResourceLocal = ""; 1140 mCurrentResourceLocal = "";
1142 mCurrentResourceRemote = ""; 1141 mCurrentResourceRemote = "";
1143 if ( mSpecificResources.count() ) { 1142 if ( mSpecificResources.count() ) {
1144 int lastSyncRes = mSpecificResources.count()/2; 1143 uint lastSyncRes = mSpecificResources.count()/2;
1145 int ccc = mSpecificResources.count()-1; 1144 int ccc = mSpecificResources.count()-1;
1146 while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { 1145 while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) {
1147 --ccc; 1146 --ccc;
1148 --lastSyncRes; 1147 --lastSyncRes;
1149 //qDebug ( "KSM: sync pi %d",ccc ); 1148 //qDebug ( "KSM: sync pi %d",ccc );
1150 } 1149 }
1151 int startLocal = 0; 1150 uint startLocal = 0;
1152 int startRemote = mSpecificResources.count()/2; 1151 uint startRemote = mSpecificResources.count()/2;
1153 emit multiResourceSyncStart( true ); 1152 emit multiResourceSyncStart( true );
1154 while ( startLocal < mSpecificResources.count()/2 ) { 1153 while ( startLocal < mSpecificResources.count()/2 ) {
1155 if ( startLocal+1 >= lastSyncRes ) 1154 if ( startLocal+1 >= lastSyncRes )
1156 emit multiResourceSyncStart( false ); 1155 emit multiResourceSyncStart( false );
1157 mPisyncFinished = false; 1156 mPisyncFinished = false;
1158 mCurrentResourceLocal = mSpecificResources[ startLocal ]; 1157 mCurrentResourceLocal = mSpecificResources[ startLocal ];
1159 mCurrentResourceRemote = mSpecificResources[ startRemote ]; 1158 mCurrentResourceRemote = mSpecificResources[ startRemote ];
1160 //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); 1159 //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
1161 if ( !mCurrentResourceRemote.isEmpty() ) { 1160 if ( !mCurrentResourceRemote.isEmpty() ) {
1162 qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); 1161 qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
1163 1162
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 mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) ); 1166 mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) );
1168 while ( !mPisyncFinished ) { 1167 while ( !mPisyncFinished ) {
1169 //qDebug("waiting "); 1168 //qDebug("waiting ");
1170 qApp->processEvents(); 1169 qApp->processEvents();
1171 } 1170 }
1172 if ( startLocal+1 < mSpecificResources.count()/2 ) { 1171 if ( startLocal+1 < mSpecificResources.count()/2 ) {
1173 mParent->topLevelWidget()->setCaption( i18n("Waiting 2 secs before syncing next resource...") ); 1172 mParent->topLevelWidget()->setCaption( i18n("Waiting 2 secs before syncing next resource...") );
1174 QTime timer; 1173 QTime timer;
1175 timer.start(); 1174 timer.start();
1176 while ( timer.elapsed () < 2000 ) { 1175 while ( timer.elapsed () < 2000 ) {