summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-17 10:24:36 (UTC)
committer zautrix <zautrix>2004-09-17 10:24:36 (UTC)
commite8dac946bcd8c080b9abb74b45221ca0c5f268c7 (patch) (unidiff)
treebbe396a67d21dbc8a4b97ecd9c34496509fa0d36
parent9421138854b85a9baced09649f617118502610c1 (diff)
downloadkdepimpi-e8dac946bcd8c080b9abb74b45221ca0c5f268c7.zip
kdepimpi-e8dac946bcd8c080b9abb74b45221ca0c5f268c7.tar.gz
kdepimpi-e8dac946bcd8c080b9abb74b45221ca0c5f268c7.tar.bz2
Bugfix in password asking in kopi syncing
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index b1c7709..b597a6a 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1886,193 +1886,199 @@ bool MainWindow::syncWithFile( QString fn , bool quick )
1886 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 1886 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
1887 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1887 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1888 mess ); 1888 mess );
1889 return ret; 1889 return ret;
1890 } 1890 }
1891 int result = 0; 1891 int result = 0;
1892 if ( !quick ) { 1892 if ( !quick ) {
1893 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1893 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1894 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1894 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1895 mess, 1895 mess,
1896 i18n("Sync"), i18n("Cancel"), 0, 1896 i18n("Sync"), i18n("Cancel"), 0,
1897 0, 1 ); 1897 0, 1 );
1898 if ( result ) 1898 if ( result )
1899 return false; 1899 return false;
1900 } 1900 }
1901 if ( KOPrefs::instance()->mAskForPreferences ) 1901 if ( KOPrefs::instance()->mAskForPreferences )
1902 mView->edit_sync_options(); 1902 mView->edit_sync_options();
1903 if ( result == 0 ) { 1903 if ( result == 0 ) {
1904 //qDebug("Now sycing ... "); 1904 //qDebug("Now sycing ... ");
1905 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 1905 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
1906 setCaption( i18n("Synchronization successful") ); 1906 setCaption( i18n("Synchronization successful") );
1907 else 1907 else
1908 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 1908 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
1909 if ( ! quick ) 1909 if ( ! quick )
1910 KOPrefs::instance()->mLastSyncedLocalFile = fn; 1910 KOPrefs::instance()->mLastSyncedLocalFile = fn;
1911 slotModifiedChanged( true ); 1911 slotModifiedChanged( true );
1912 } 1912 }
1913 return ret; 1913 return ret;
1914} 1914}
1915void MainWindow::quickSyncLocalFile() 1915void MainWindow::quickSyncLocalFile()
1916{ 1916{
1917 //mView->setSyncDevice("local-file" ); 1917 //mView->setSyncDevice("local-file" );
1918 //qDebug("quickSyncLocalFile() "); 1918 //qDebug("quickSyncLocalFile() ");
1919 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 1919 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
1920 // Event* e = mView->getLastSyncEvent(); 1920 // Event* e = mView->getLastSyncEvent();
1921// e->setReadOnly( false ); 1921// e->setReadOnly( false );
1922// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1922// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1923// e->setReadOnly( true ); 1923// e->setReadOnly( true );
1924 1924
1925 } 1925 }
1926} 1926}
1927 1927
1928void MainWindow::confSync() 1928void MainWindow::confSync()
1929{ 1929{
1930 mView->confSync(); 1930 mView->confSync();
1931 fillSyncMenu(); 1931 fillSyncMenu();
1932} 1932}
1933void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 1933void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
1934{ 1934{
1935 QString question; 1935 QString question;
1936 if ( ask ) { 1936 if ( ask ) {
1937 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 1937 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
1938 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1938 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1939 question, 1939 question,
1940 i18n("Yes"), i18n("No"), 1940 i18n("Yes"), i18n("No"),
1941 0, 0 ) != 0 ) 1941 0, 0 ) != 0 )
1942 return; 1942 return;
1943 } 1943 }
1944 QString command = prof->getPreSyncCommand(); 1944 QString command = prof->getPreSyncCommand();
1945 int fi; 1945 int fi;
1946 if ( (fi = command.find("$PWD$")) > 0 ) { 1946 if ( (fi = command.find("$PWD$")) > 0 ) {
1947 QString pwd = getPassword(); 1947 QString pwd = getPassword();
1948 command = command.left( fi )+ pwd + command.mid( fi+5 ); 1948 command = command.left( fi )+ pwd + command.mid( fi+5 );
1949 1949
1950 } 1950 }
1951 int maxlen = 30; 1951 int maxlen = 30;
1952 if ( QApplication::desktop()->width() > 320 ) 1952 if ( QApplication::desktop()->width() > 320 )
1953 maxlen += 25; 1953 maxlen += 25;
1954 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1954 setCaption ( i18n( "Copy remote file to local machine..." ) );
1955 int fileSize = 0; 1955 int fileSize = 0;
1956 int result = system ( command ); 1956 int result = system ( command );
1957 // 0 : okay 1957 // 0 : okay
1958 // 256: no such file or dir 1958 // 256: no such file or dir
1959 // 1959 //
1960 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1960 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1961 if ( result != 0 ) { 1961 if ( result != 0 ) {
1962 int len = maxlen; 1962 int len = maxlen;
1963 while ( len < command.length() ) { 1963 while ( len < command.length() ) {
1964 command.insert( len , "\n" ); 1964 command.insert( len , "\n" );
1965 len += maxlen +2; 1965 len += maxlen +2;
1966 } 1966 }
1967 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 (command) ; 1967 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 (command) ;
1968 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1968 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1969 question, 1969 question,
1970 i18n("Okay!")) ; 1970 i18n("Okay!")) ;
1971 setCaption ("KO/Pi"); 1971 setCaption ("KO/Pi");
1972 return; 1972 return;
1973 } 1973 }
1974 setCaption ( i18n( "Copying succeed." ) ); 1974 setCaption ( i18n( "Copying succeed." ) );
1975 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 1975 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
1976 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 1976 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
1977// Event* e = mView->getLastSyncEvent(); 1977// Event* e = mView->getLastSyncEvent();
1978// e->setReadOnly( false ); 1978// e->setReadOnly( false );
1979// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1979// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1980// e->setReadOnly( true ); 1980// e->setReadOnly( true );
1981 if ( KOPrefs::instance()->mWriteBackFile ) { 1981 if ( KOPrefs::instance()->mWriteBackFile ) {
1982 command = prof->getPostSyncCommand(); 1982 command = prof->getPostSyncCommand();
1983 int fi;
1984 if ( (fi = command.find("$PWD$")) > 0 ) {
1985 QString pwd = getPassword();
1986 command = command.left( fi )+ pwd + command.mid( fi+5 );
1987
1988 }
1983 setCaption ( i18n( "Writing back file ..." ) ); 1989 setCaption ( i18n( "Writing back file ..." ) );
1984 result = system ( command ); 1990 result = system ( command );
1985 qDebug("KO: Writing back file result: %d ", result); 1991 qDebug("KO: Writing back file result: %d ", result);
1986 if ( result != 0 ) { 1992 if ( result != 0 ) {
1987 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 1993 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
1988 return; 1994 return;
1989 } else { 1995 } else {
1990 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 1996 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1991 } 1997 }
1992 } 1998 }
1993 } 1999 }
1994 return; 2000 return;
1995} 2001}
1996void MainWindow::syncSSH() 2002void MainWindow::syncSSH()
1997{ 2003{
1998 // not used anymore 2004 // not used anymore
1999 QTime timer; 2005 QTime timer;
2000 timer.start(); 2006 timer.start();
2001 //qDebug("MainWindow::syncssh() "); 2007 //qDebug("MainWindow::syncssh() ");
2002 KOPrefs *p = KOPrefs::instance(); 2008 KOPrefs *p = KOPrefs::instance();
2003 QString localFile = p->mLocalTempFile; 2009 QString localFile = p->mLocalTempFile;
2004 QString remoteIP = p->mRemoteIP; 2010 QString remoteIP = p->mRemoteIP;
2005 QString remoteUser = p->mRemoteUser; 2011 QString remoteUser = p->mRemoteUser;
2006 QString remoteFile = p->mRemoteFile; 2012 QString remoteFile = p->mRemoteFile;
2007 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) 2013 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
2008 remoteUser += ":" + p->mRemotePassWd; 2014 remoteUser += ":" + p->mRemotePassWd;
2009 2015
2010 QString question = i18n("Do you really want\nto remote sync?\n \n") + 2016 QString question = i18n("Do you really want\nto remote sync?\n \n") +
2011 i18n("IP: " ) +remoteIP +"\n" + 2017 i18n("IP: " ) +remoteIP +"\n" +
2012 i18n("User: " ) + remoteUser +"\n" ; 2018 i18n("User: " ) + remoteUser +"\n" ;
2013 int maxlen = 30; 2019 int maxlen = 30;
2014 if ( QApplication::desktop()->width() > 320 ) 2020 if ( QApplication::desktop()->width() > 320 )
2015 maxlen += 25; 2021 maxlen += 25;
2016 if ( remoteFile.length() > maxlen ) 2022 if ( remoteFile.length() > maxlen )
2017 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; 2023 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
2018 else 2024 else
2019 question += i18n("Remote file:\n " ) + remoteFile +"\n"; 2025 question += i18n("Remote file:\n " ) + remoteFile +"\n";
2020 if ( localFile.length() > maxlen ) 2026 if ( localFile.length() > maxlen )
2021 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; 2027 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
2022 else 2028 else
2023 question += i18n("Local temp file:\n " ) + localFile +"\n"; 2029 question += i18n("Local temp file:\n " ) + localFile +"\n";
2024 2030
2025 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2031 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2026 question, 2032 question,
2027 i18n("Yes"), i18n("No"), 2033 i18n("Yes"), i18n("No"),
2028 0, 0 ) != 0 ) 2034 0, 0 ) != 0 )
2029 return; 2035 return;
2030 // if ( !p->mUsePassWd ) { 2036 // if ( !p->mUsePassWd ) {
2031 // QString pass = getPassword(); 2037 // QString pass = getPassword();
2032 // if ( pass.length() > 0 ) 2038 // if ( pass.length() > 0 )
2033 // remoteUser += ":" + pass; 2039 // remoteUser += ":" + pass;
2034 // } 2040 // }
2035 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; 2041 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
2036 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2042 setCaption ( i18n( "Copy remote file to local machine..." ) );
2037 int fileSize = 0; 2043 int fileSize = 0;
2038 int result = system ( command ); 2044 int result = system ( command );
2039 // 0 : okay 2045 // 0 : okay
2040 // 256: no such file or dir 2046 // 256: no such file or dir
2041 // 2047 //
2042 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2048 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2043 if ( result != 0 ) { 2049 if ( result != 0 ) {
2044 int len = maxlen; 2050 int len = maxlen;
2045 while ( len < command.length() ) { 2051 while ( len < command.length() ) {
2046 command.insert( len , "\n" ); 2052 command.insert( len , "\n" );
2047 len += maxlen +2; 2053 len += maxlen +2;
2048 } 2054 }
2049 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 (command) ; 2055 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 (command) ;
2050 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2056 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2051 question, 2057 question,
2052 i18n("Okay!")) ; 2058 i18n("Okay!")) ;
2053 setCaption ("KO/Pi"); 2059 setCaption ("KO/Pi");
2054 return; 2060 return;
2055 } 2061 }
2056 2062
2057 2063
2058 setCaption ( i18n( "Copying succeed." ) ); 2064 setCaption ( i18n( "Copying succeed." ) );
2059 //mView->setSyncDevice("ssh-scp" ); 2065 //mView->setSyncDevice("ssh-scp" );
2060 if ( syncWithFile(localFile , true ) ) { 2066 if ( syncWithFile(localFile , true ) ) {
2061// Event* e = mView->getLastSyncEvent(); 2067// Event* e = mView->getLastSyncEvent();
2062// e->setReadOnly( false ); 2068// e->setReadOnly( false );
2063// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2069// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2064// e->setReadOnly( true ); 2070// e->setReadOnly( true );
2065 if ( KOPrefs::instance()->mWriteBackFile ) { 2071 if ( KOPrefs::instance()->mWriteBackFile ) {
2066 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; 2072 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
2067 setCaption ( i18n( "Writing back file ..." ) ); 2073 setCaption ( i18n( "Writing back file ..." ) );
2068 result = system ( command ); 2074 result = system ( command );
2069 if ( result != 0 ) { 2075 if ( result != 0 ) {
2070 int len = maxlen; 2076 int len = maxlen;
2071 while ( len < command.length() ) { 2077 while ( len < command.length() ) {
2072 command.insert( len , "\n" ); 2078 command.insert( len , "\n" );
2073 len += maxlen +2; 2079 len += maxlen +2;
2074 } 2080 }
2075 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2081 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2076 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2082 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2077 question, 2083 question,
2078 i18n("Okay!")) ; 2084 i18n("Okay!")) ;