@ -20,7 +20,7 @@
# include <kprocess.h>
# include <kdebug.h>
# include < qfile.h>
# include < t qfile.h>
# include <keepsettings.h>
RDBManager : : RDBManager ( )
@ -33,42 +33,42 @@ RDBManager::~RDBManager()
void RDBManager : : slotCheckBackup ( )
{
QValueList< Backup > backups = outdatedBackupList ( ) ;
QValueList< Backup > : : iterator it ;
T QValueList< Backup > backups = outdatedBackupList ( ) ;
T QValueList< Backup > : : iterator it ;
for ( it = backups . begin ( ) ; it ! = backups . end ( ) ; + + it )
{
doBackup ( * it ) ;
}
}
void RDBManager : : slotForceBackup ( QValueList< Backup > backupList )
void RDBManager : : slotForceBackup ( T QValueList< Backup > backupList )
{
QValueList< Backup > : : iterator it ;
T QValueList< Backup > : : iterator it ;
for ( it = backupList . begin ( ) ; it ! = backupList . end ( ) ; + + it )
{
doBackup ( * it ) ;
}
}
QString RDBManager : : compareAtTime ( Backup backup , QDateTime date )
T QString RDBManager : : compareAtTime ( Backup backup , T QDateTime date )
{
// Gets the rdiff-backup process
KProcess * proc = RDBProcess ( ) ;
// Adds the options
* proc < < " --compare-at-time " ;
* proc < < QString: : number ( date . toTime_t ( ) ) ; // increment date
* proc < < T QString: : number ( date . toTime_t ( ) ) ; // increment date
// Adds source and dest
* proc < < QFile: : encodeName ( KProcess : : quote ( backup . source ( ) ) ) ;
* proc < < QFile: : encodeName ( KProcess : : quote ( backup . dest ( ) ) ) ;
* proc < < TQString( T QFile: : encodeName ( KProcess : : quote ( backup . source ( ) ) ) ) ;
* proc < < TQString( T QFile: : encodeName ( KProcess : : quote ( backup . dest ( ) ) ) ) ;
// Adds the listener
RDBListener * listen = new RDBListener ( ) ;
connect ( proc , SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
connect ( proc , TQT_ SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , TQT_ SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
// Starts the process
if ( ! proc - > start ( KProcess : : Block , KProcess : : AllOutput ) )
kdDebug ( ) < < " Error starting rdiff-backup " < < endl ;
QStringList output = listen - > stdOut ( ) ;
QStringList: : iterator it = output . begin ( ) ;
T QStringList output = listen - > stdOut ( ) ;
T QStringList: : iterator it = output . begin ( ) ;
kdDebug ( ) < < " Executed process: " < < proc - > args ( ) < < endl ;
@ -78,24 +78,24 @@ QString RDBManager::compareAtTime(Backup backup, QDateTime date)
return ( * it ) ;
}
QString RDBManager : : listChangedSince ( Backup backup , QDateTime date )
T QString RDBManager : : listChangedSince ( Backup backup , T QDateTime date )
{
// Gets the rdiff-backup process
KProcess * proc = RDBProcess ( ) ;
// Adds the options
* proc < < " --list-changed-since " ;
* proc < < QString: : number ( date . toTime_t ( ) ) ; // increment date
* proc < < T QString: : number ( date . toTime_t ( ) ) ; // increment date
// Adds the dest
* proc < < QFile: : encodeName ( KProcess : : quote ( backup . dest ( ) ) ) ;
* proc < < TQString( T QFile: : encodeName ( KProcess : : quote ( backup . dest ( ) ) ) ) ;
// Adds a listener
RDBListener * listen = new RDBListener ( ) ;
connect ( proc , SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
connect ( proc , TQT_ SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , TQT_ SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
// Starts the process
if ( ! proc - > start ( KProcess : : Block , KProcess : : AllOutput ) )
kdDebug ( ) < < " Error starting rdiff-backup " < < endl ;
QStringList output = listen - > stdOut ( ) ;
QStringList: : iterator it = output . begin ( ) ;
T QStringList output = listen - > stdOut ( ) ;
T QStringList: : iterator it = output . begin ( ) ;
kdDebug ( ) < < " Executed process: " < < proc - > args ( ) < < endl ;
@ -105,24 +105,24 @@ QString RDBManager::listChangedSince(Backup backup, QDateTime date)
return ( * it ) ;
}
QString RDBManager : : listAtTime ( Backup backup , QDateTime date )
T QString RDBManager : : listAtTime ( Backup backup , T QDateTime date )
{
// Gets the rdiff-backup process
KProcess * proc = RDBProcess ( ) ;
// Adds the options
* proc < < " --list-at-time " ;
* proc < < QString: : number ( date . toTime_t ( ) ) ; // increment date
* proc < < T QString: : number ( date . toTime_t ( ) ) ; // increment date
// Adds the dest
* proc < < QFile: : encodeName ( KProcess : : quote ( backup . dest ( ) ) ) ;
* proc < < TQString( T QFile: : encodeName ( KProcess : : quote ( backup . dest ( ) ) ) ) ;
// Adds a listener
RDBListener * listen = new RDBListener ( ) ;
connect ( proc , SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
connect ( proc , TQT_ SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , TQT_ SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
// Starts the process
if ( ! proc - > start ( KProcess : : Block , KProcess : : AllOutput ) )
kdDebug ( ) < < " Error starting rdiff-backup " < < endl ;
QStringList output = listen - > stdOut ( ) ;
QStringList: : iterator it = output . begin ( ) ;
T QStringList output = listen - > stdOut ( ) ;
T QStringList: : iterator it = output . begin ( ) ;
kdDebug ( ) < < " Executed process: " < < proc - > args ( ) < < endl ;
@ -132,7 +132,7 @@ QString RDBManager::listAtTime(Backup backup, QDateTime date)
return ( * it ) ;
}
QValueList< QDateTime> RDBManager : : incrementList ( Backup backup )
T QValueList< T QDateTime> RDBManager : : incrementList ( Backup backup )
{
// Gets the rdiff-backup process
KProcess * proc = RDBProcess ( ) ;
@ -141,27 +141,27 @@ QValueList<QDateTime> RDBManager::incrementList(Backup backup)
* proc < < " -v2 " ;
* proc < < " --parsable-output " ;
// Adds the dest
* proc < < QFile: : encodeName ( KProcess : : quote ( backup . dest ( ) ) ) ;
* proc < < TQString( T QFile: : encodeName ( KProcess : : quote ( backup . dest ( ) ) ) ) ;
// Adds a listener
RDBListener * listen = new RDBListener ( ) ;
connect ( proc , SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
connect ( proc , TQT_ SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , TQT_ SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
// Starts the process
if ( ! proc - > start ( KProcess : : Block , KProcess : : AllOutput ) )
kdDebug ( ) < < " Error starting rdiff-backup " < < endl ;
QStringList output = listen - > stdOut ( ) ;
QStringList: : iterator it = output . begin ( ) ;
T QStringList output = listen - > stdOut ( ) ;
T QStringList: : iterator it = output . begin ( ) ;
QStringList lines = QStringList: : split ( " \n " , * it ) ;
QValueList< QDateTime> dateList ;
T QStringList lines = T QStringList: : split ( " \n " , * it ) ;
T QValueList< T QDateTime> dateList ;
QStringList: : iterator it2 = output . begin ( ) ;
T QStringList: : iterator it2 = output . begin ( ) ;
for ( it2 = lines . begin ( ) ; it2 ! = lines . end ( ) ; + + it2 )
{
QStringList field = QStringList: : split ( " " , * it2 ) ;
QStringList: : iterator dateStr = field . begin ( ) ;
T QStringList field = T QStringList: : split ( " " , * it2 ) ;
T QStringList: : iterator dateStr = field . begin ( ) ;
long timestamp = ( * dateStr ) . toUInt ( ) ;
QDateTime datetime ;
T QDateTime datetime ;
datetime . setTime_t ( timestamp ) ;
dateList . append ( datetime ) ;
}
@ -174,24 +174,24 @@ QValueList<QDateTime> RDBManager::incrementList(Backup backup)
return dateList ;
}
QDateTime RDBManager : : lastIncrement ( Backup backup )
T QDateTime RDBManager : : lastIncrement ( Backup backup )
{
QValueList< QDateTime> increments = incrementList ( backup ) ;
QDateTime last = increments . last ( ) ;
T QValueList< T QDateTime> increments = incrementList ( backup ) ;
T QDateTime last = increments . last ( ) ;
return last ;
}
QValueList< Backup > RDBManager : : outdatedBackupList ( )
T QValueList< Backup > RDBManager : : outdatedBackupList ( )
{
BackupConfig config ;
QValueList< Backup > backups = config . backupList ( ) ;
QValueList< Backup > outdated ;
QValueList< Backup > : : iterator it ;
T QValueList< Backup > backups = config . backupList ( ) ;
T QValueList< Backup > outdated ;
T QValueList< Backup > : : iterator it ;
kdDebug ( ) < < " Detecting outdated backup. " < < endl ;
for ( it = backups . begin ( ) ; it ! = backups . end ( ) ; + + it )
{
QDateTime last = lastIncrement ( * it ) ;
QDate today = QDate: : currentDate( ) ;
T QDateTime last = lastIncrement ( * it ) ;
T QDate today = T QDate: : tq currentDate( ) ;
if ( last . date ( ) . daysTo ( today ) > = ( * it ) . interval ( ) )
{
kdDebug ( ) < < " Detected outdated backup: " < < ( * it ) . source ( ) < < endl ;
@ -201,21 +201,21 @@ QValueList<Backup> RDBManager::outdatedBackupList()
return outdated ;
}
void RDBManager : : slotRestoreBackup ( Backup backup , QDateTime time )
void RDBManager : : slotRestoreBackup ( Backup backup , T QDateTime time )
{
// Gets the rdiff-backup process
KProcess * proc = RDBProcess ( ) ;
// Adds the options
* proc < < " --force " ;
* proc < < " --restore-as-of " ;
* proc < < QString: : number ( time . toTime_t ( ) ) ; // Date of the increment to restore
* proc < < T QString: : number ( time . toTime_t ( ) ) ; // Date of the increment to restore
// Adds source and dest
* proc < < QFile: : encodeName ( KProcess : : quote ( backup . dest ( ) ) ) ;
* proc < < QFile: : encodeName ( KProcess : : quote ( backup . source ( ) ) ) ;
* proc < < TQString( T QFile: : encodeName ( KProcess : : quote ( backup . dest ( ) ) ) ) ;
* proc < < TQString( T QFile: : encodeName ( KProcess : : quote ( backup . source ( ) ) ) ) ;
// Adds a listener (for output recording)
RDBListener * listen = new RDBListener ( ) ;
connect ( proc , SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
connect ( proc , SIGNAL( receivedStderr ( KProcess * , char * , int ) ) , listen , SLOT( receivedStdErr ( KProcess * , char * , int ) ) ) ;
connect ( proc , TQT_ SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , TQT_ SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
connect ( proc , TQT_ SIGNAL( receivedStderr ( KProcess * , char * , int ) ) , listen , TQT_ SLOT( receivedStdErr ( KProcess * , char * , int ) ) ) ;
// Starts the process
if ( ! proc - > start ( KProcess : : Block , KProcess : : AllOutput ) )
kdDebug ( ) < < " Error starting rdiff-backup " < < endl ;
@ -239,13 +239,13 @@ bool RDBManager::isRDB()
* proc < < " -V " ;
// Adds a listener (for output recording)
RDBListener * listen = new RDBListener ( ) ;
connect ( proc , SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
connect ( proc , TQT_ SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , TQT_ SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
// Starts the process
if ( ! proc - > start ( KProcess : : Block , KProcess : : AllOutput ) )
kdDebug ( ) < < " Error starting rdiff-backup " < < endl ;
QStringList outList = listen - > stdOut ( ) ;
QStringList: : iterator out = outList . begin ( ) ;
T QStringList outList = listen - > stdOut ( ) ;
T QStringList: : iterator out = outList . begin ( ) ;
kdDebug ( ) < < " Executed process: " < < proc - > args ( ) < < endl ;
@ -257,20 +257,20 @@ bool RDBManager::isRDB()
return true ;
}
QString RDBManager : : RDBVersion ( )
T QString RDBManager : : RDBVersion ( )
{
// Gets the rdiff-backup process
KProcess * proc = RDBProcess ( ) ;
* proc < < " -V " ;
// Adds a listener (for output recording)
RDBListener * listen = new RDBListener ( ) ;
connect ( proc , SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
connect ( proc , TQT_ SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , TQT_ SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
// Starts the process
if ( ! proc - > start ( KProcess : : Block , KProcess : : AllOutput ) )
kdDebug ( ) < < " Error starting rdiff-backup " < < endl ;
QStringList outList = listen - > stdOut ( ) ;
QStringList: : iterator out = outList . begin ( ) ;
T QStringList outList = listen - > stdOut ( ) ;
T QStringList: : iterator out = outList . begin ( ) ;
kdDebug ( ) < < " Executed process: " < < proc - > args ( ) < < endl ;
@ -287,21 +287,21 @@ void RDBManager::doBackup(Backup backup)
// Adds include and exclude
if ( backup . useIncludeExclude ( ) )
{
QStringList includeExcludeList = backup . includeExcludeList ( ) ;
QStringList: : iterator it ;
T QStringList includeExcludeList = backup . includeExcludeList ( ) ;
T QStringList: : iterator it ;
for ( it = includeExcludeList . begin ( ) ; it ! = includeExcludeList . end ( ) ; + + it )
{
QString type = ( * it ) . left ( 1 ) ;
QString file = ( * it ) . right ( ( * it ) . length ( ) - 1 ) ;
T QString type = ( * it ) . left ( 1 ) ;
T QString file = ( * it ) . right ( ( * it ) . length ( ) - 1 ) ;
if ( type = = " I " )
{
* proc < < " --include " ;
* proc < < QFile: : encodeName ( KProcess : : quote ( file ) ) ;
* proc < < TQString( T QFile: : encodeName ( KProcess : : quote ( file ) ) ) ;
}
else if ( type = = " E " )
{
* proc < < " --exclude " ;
* proc < < QFile: : encodeName ( KProcess : : quote ( file ) ) ;
* proc < < TQString( T QFile: : encodeName ( KProcess : : quote ( file ) ) ) ;
}
}
}
@ -318,19 +318,19 @@ void RDBManager::doBackup(Backup backup)
// For advanced mode
else
{
QStringList optionList = backup . optionList ( ) ;
for ( QStringList: : Iterator it = optionList . begin ( ) ; it ! = optionList . end ( ) ; + + it )
T QStringList optionList = backup . optionList ( ) ;
for ( T QStringList: : Iterator it = optionList . begin ( ) ; it ! = optionList . end ( ) ; + + it )
{
* proc < < * it ;
}
}
// Adds source and dest
* proc < < QFile: : encodeName ( KProcess : : quote ( backup . source ( ) ) ) ;
* proc < < QFile: : encodeName ( KProcess : : quote ( backup . dest ( ) ) ) ;
* proc < < TQString( T QFile: : encodeName ( KProcess : : quote ( backup . source ( ) ) ) ) ;
* proc < < TQString( T QFile: : encodeName ( KProcess : : quote ( backup . dest ( ) ) ) ) ;
// Adds a listener (for output recording)
RDBListener * listen = new RDBListener ( ) ;
connect ( proc , SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
connect ( proc , SIGNAL( receivedStderr ( KProcess * , char * , int ) ) , listen , SLOT( receivedStdErr ( KProcess * , char * , int ) ) ) ;
connect ( proc , TQT_ SIGNAL( receivedStdout ( KProcess * , char * , int ) ) , listen , TQT_ SLOT( receivedStdOut ( KProcess * , char * , int ) ) ) ;
connect ( proc , TQT_ SIGNAL( receivedStderr ( KProcess * , char * , int ) ) , listen , TQT_ SLOT( receivedStdErr ( KProcess * , char * , int ) ) ) ;
// Starts the process
if ( ! proc - > start ( KProcess : : Block , KProcess : : AllOutput ) )
kdDebug ( ) < < " Error starting rdiff-backup " < < endl ;
@ -360,7 +360,7 @@ void RDBManager::removeOldIncrements(Backup backup)
// Gets the rdiff-backup process
KProcess * proc = RDBProcess ( ) ;
// Adds the options
* proc < < " --remove-older-than " < < QString( " %1 " ) . arg( backup . deleteAfter ( ) ) + " D " ;
* proc < < " --remove-older-than " < < T QString( " %1 " ) . tq arg( backup . deleteAfter ( ) ) + " D " ;
// Adds dest
* proc < < backup . dest ( ) ;
// Starts the process
@ -378,7 +378,7 @@ KProcess *RDBManager::RDBProcess(bool isNice,int niceLevel)
proc - > setUseShell ( true ) ;
if ( isNice )
{
* proc < < " nice " < < " -n " < < QString( " %1 " ) . arg( niceLevel ) ;
* proc < < " nice " < < " -n " < < T QString( " %1 " ) . tq arg( niceLevel ) ;
}
* proc < < " rdiff-backup " ;