summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-11-04 15:12:01 (UTC)
committer mickeyl <mickeyl>2004-11-04 15:12:01 (UTC)
commit5f56ab623c99c12ce246f775e065632fbfbbfc1f (patch) (side-by-side diff)
tree0035922070d36de69226bfcefc4d959b5a453f61
parent18684ddb43d4d79304dee6b20ab62513ee50b883 (diff)
downloadopie-5f56ab623c99c12ce246f775e065632fbfbbfc1f.zip
opie-5f56ab623c99c12ce246f775e065632fbfbbfc1f.tar.gz
opie-5f56ab623c99c12ce246f775e065632fbfbbfc1f.tar.bz2
- prepare for backing up root file systems (aka clone)
- add file headers - add version to .pro
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/backup/backup.pro2
-rw-r--r--noncore/settings/backup/backuprestore.cpp54
-rw-r--r--noncore/settings/backup/backuprestore.h31
-rw-r--r--noncore/settings/backup/backuprestorebase.ui99
4 files changed, 167 insertions, 19 deletions
diff --git a/noncore/settings/backup/backup.pro b/noncore/settings/backup/backup.pro
index 390c599..e964c3a 100644
--- a/noncore/settings/backup/backup.pro
+++ b/noncore/settings/backup/backup.pro
@@ -1,10 +1,10 @@
CONFIG = qt warn_on quick-app
HEADERS = backuprestore.h
SOURCES = main.cpp backuprestore.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopiecore2 -lopieui2
INTERFACES = backuprestorebase.ui errordialog.ui
TARGET = backup
-
+VERSION = 0.8.1
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp
index 1748e8d..c944c6d 100644
--- a/noncore/settings/backup/backuprestore.cpp
+++ b/noncore/settings/backup/backuprestore.cpp
@@ -1,89 +1,115 @@
+/*
+                This file is part of the Opie Project
+ =.
+             .=l. Copyright (c) 2002-2004 The Opie Team <opie-devel@handhelds.org>
+           .>+-=
+ _;:,     .>    :=|. This file is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This file is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
+..}^=.=       =       ; Public License for more details.
+++=   -.     .`     .:
+ :     =  ...= . :.=- You should have received a copy of the GNU
+ -.   .:....=;==+<; General Public License along with this file;
+  -_. . .   )=.  = see the file COPYING. If not, write to the
+    --        :-=` Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
#include "backuprestore.h"
#include "errordialog.h"
-
/* OPIE */
+#include <qpe/qpeapplication.h>
+#include <qpe/resource.h>
+#include <qpe/config.h>
#include <opie2/odebug.h>
#include <opie2/ostorageinfo.h>
-using namespace Opie::Core;
-
#include <opie2/ofiledialog.h>
#include <opie2/owait.h>
+using namespace Opie::Core;
using namespace Opie::Ui;
-#include <qpe/qpeapplication.h>
-#include <qpe/resource.h>
-#include <qpe/config.h>
-
/* QT */
#include <qapplication.h>
#include <qmultilineedit.h>
#include <qdir.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qlistview.h>
#include <qpushbutton.h>
+#include <qradiobutton.h>
#include <qheader.h>
#include <qmessagebox.h>
#include <qcombobox.h>
#include <qlist.h>
#include <qregexp.h>
#include <qtextstream.h>
#include <qtextview.h>
#include <qlineedit.h>
#include <qstringlist.h>
/* STD */
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
#define HEADER_NAME 0
#define HEADER_BACKUP 1
#define BACKUP_LOCATION 2
#define EXTENSION ".bck"
const QString tempFileName = "/tmp/backup.err";
BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl)
: BackupAndRestoreBase(parent, name, fl)
{
backupList->header()->hide();
restoreList->header()->hide();
locationList->header()->hide();
connect( backupButton, SIGNAL( clicked() ), this, SLOT( backup() ) );
connect( restoreButton, SIGNAL( clicked() ), this, SLOT( restore() ) );
connect( backupList, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectItem( QListViewItem* ) ) );
connect( restoreSource, SIGNAL( activated( int ) ), this, SLOT( sourceDirChanged( int ) ) );
connect( addLocationButton, SIGNAL( clicked() ), this, SLOT( addLocation() ) );
connect( removeLocationButton, SIGNAL( clicked() ), this, SLOT( removeLocation() ) );
connect( saveLocationsButton, SIGNAL( clicked() ), this, SLOT( saveLocations() ) );
connect( selectLocationButton, SIGNAL( clicked() ), this, SLOT( selectLocation() ) );
//add directorys for backing up
applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/");
selectItem(applicationSettings);
applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/");
selectItem(applicationSettings);
documents= new QListViewItem(backupList, "Documents", "", "Documents/");
selectItem(documents);
scanForApplicationSettings();
refreshLocations();
refreshBackupLocations();
// Read the list of items to ignore.
QList<QString> dontBackupList;
dontBackupList.setAutoDelete(true);
Config config("BackupAndRestore");
config.setGroup("DontBackup");
int total = config.readNumEntry("Total", 0);
for(int i = 0; i < total; i++)
{
dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), "")));
}
QList<QListViewItem> list;
@@ -183,128 +209,142 @@ void BackupAndRestore::refreshBackupLocations()
}
}
QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list)
{
while(item)
{
if(item->childCount() > 0)
getAllItems(item->firstChild(), list);
list.append(item);
item = item->nextSibling();
}
return list;
}
/**
* Selects and unselects the item by setting the HEADER_BACKUP to B or !.
* and changing the icon to match
* @param currentItem the item to swich the selection choice.
*/
void BackupAndRestore::selectItem(QListViewItem *currentItem)
{
if(!currentItem)
return;
if(currentItem->text(HEADER_BACKUP) == "B")
{
currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null"));
currentItem->setText(HEADER_BACKUP, "");
}
else
{
currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check"));
currentItem->setText(HEADER_BACKUP, "B");
}
}
void BackupAndRestore::scanForApplicationSettings()
{
QDir d( QDir::homeDirPath() + "/" + QString( applicationSettings->text(BACKUP_LOCATION) ) );
d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) )
{
//odebug << (d.path()+"/"+fi->fileName()).latin1() << oendl;
if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) )
{
QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName());
selectItem(newItem);
}
++it;
}
}
/**
* The "Backup" button has been pressed. Get a list of all of the files that
* should be backed up. If there are no files, emit and error and exit.
* Determine the file name to store the backup in. Backup the file(s) using
* tar and gzip --best. Report failure or success
*/
void BackupAndRestore::backup()
{
+ if ( cb_type_userdata->isChecked() )
+ backupUserData();
+ else
+ backupRootFs();
+}
+
+
+void BackupAndRestore::backupRootFs()
+{
+ QMessageBox::critical(this, "Message", "Not Yet Implemented", "Ok" );
+}
+
+void BackupAndRestore::backupUserData()
+{
QString backupFiles;
if(getBackupFiles(backupFiles, NULL) == 0)
{
QMessageBox::critical(this, "Message",
"No items selected.",QString("Ok") );
return;
}
OWait *owait = new OWait();
Global::statusMessage( tr( "Backing up..." ) );
owait->show();
qApp->processEvents();
QString outputFile = backupLocations[storeToLocation->currentText()];
QDateTime datetime = QDateTime::currentDateTime();
QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') +
QString::number( datetime.date().day() ).rightJustify(2, '0');
outputFile += "/" + dateString;
QString t = outputFile;
int c = 1;
while(QFile::exists(outputFile + EXTENSION))
{
outputFile = t + QString("%1").arg(c);
c++;
}
// We execute tar and compressing its output with gzip..
// The error output will be written into a temp-file which could be provided
// for debugging..
odebug << "Storing file: " << outputFile.latin1() << "" << oendl;
outputFile += EXTENSION;
QString commandLine = QString( "cd %1 && (tar -X %1 -cz %2 Applications/backup/exclude -f %3 ) 2> %4" ).arg( QDir::homeDirPath() )
.arg( getExcludeFile() )
.arg( backupFiles )
.arg( outputFile.latin1() )
.arg( tempFileName.latin1() );
odebug << commandLine << oendl;
int r = system( commandLine );
owait->hide();
delete owait;
//Error-Handling
if(r != 0)
{
perror("Error: ");
QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno );
switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n"
+ errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) )
{
case 1:
owarn << "Details pressed !" << oendl;
ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true );
QFile errorFile( tempFileName );
if ( errorFile.open(IO_ReadOnly) )
{
diff --git a/noncore/settings/backup/backuprestore.h b/noncore/settings/backup/backuprestore.h
index 332123a..015f854 100644
--- a/noncore/settings/backup/backuprestore.h
+++ b/noncore/settings/backup/backuprestore.h
@@ -1,54 +1,85 @@
+/*
+                This file is part of the Opie Project
+ =.
+             .=l. Copyright (c) 2002-2004 The Opie Team <opie-devel@handhelds.org>
+           .>+-=
+ _;:,     .>    :=|. This file is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This file is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
+..}^=.=       =       ; Public License for more details.
+++=   -.     .`     .:
+ :     =  ...= . :.=- You should have received a copy of the GNU
+ -.   .:....=;==+<; General Public License along with this file;
+  -_. . .   )=.  = see the file COPYING. If not, write to the
+    --        :-=` Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
#ifndef WINDOW_H
#define WINDOW_H
#include <qmainwindow.h>
#include "backuprestorebase.h"
#include <qmap.h>
#include <qlist.h>
class QListViewItem;
class QStringList;
class BackupAndRestore : public BackupAndRestoreBase
{
Q_OBJECT
public:
BackupAndRestore( QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
~BackupAndRestore();
static QString appName() { return QString::fromLatin1("backup"); }
private slots:
void backup();
void restore();
void selectItem(QListViewItem *currentItem);
void sourceDirChanged(int);
void rescanFolder(QString directory);
void fileListUpdate();
void addLocation();
void removeLocation();
void saveLocations();
void selectLocation();
private:
void scanForApplicationSettings();
int getBackupFiles(QString &backupFiles, QListViewItem *parent);
QString getExcludeFile();
QMap<QString, QString> backupLocations;
QList<QListViewItem> getAllItems(QListViewItem *item, QList<QListViewItem> &list);
void refreshBackupLocations();
void refreshLocations();
+ void backupUserData();
+ void backupRootFs();
+
QListViewItem *systemSettings;
QListViewItem *applicationSettings;
QListViewItem *documents;
};
#endif
// backuprestore.h
diff --git a/noncore/settings/backup/backuprestorebase.ui b/noncore/settings/backup/backuprestorebase.ui
index b464556..6186d68 100644
--- a/noncore/settings/backup/backuprestorebase.ui
+++ b/noncore/settings/backup/backuprestorebase.ui
@@ -1,191 +1,268 @@
<!DOCTYPE UI><UI>
<class>BackupAndRestoreBase</class>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>BackupAndRestoreBase</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>282</width>
- <height>243</height>
+ <width>278</width>
+ <height>298</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Backup And Restore</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>0</number>
</property>
<widget>
<class>QTabWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tabWidget</cstring>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Widget2</cstring>
</property>
<attribute>
<name>title</name>
<string>Backup</string>
</attribute>
<grid>
<property stdset="1">
<name>margin</name>
<number>4</number>
</property>
<property stdset="1">
<name>spacing</name>
- <number>4</number>
+ <number>2</number>
</property>
<widget row="0" column="0" >
- <class>QLabel</class>
+ <class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
- <cstring>TextLabel1</cstring>
+ <cstring>Layout1</cstring>
</property>
+ <grid>
<property stdset="1">
- <name>text</name>
- <string>Save To</string>
+ <name>margin</name>
+ <number>0</number>
</property>
- </widget>
- <widget row="0" column="1" >
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget row="1" column="1" >
<class>QComboBox</class>
<property stdset="1">
<name>name</name>
<cstring>storeToLocation</cstring>
</property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>1</vsizetype>
+ </sizepolicy>
+ </property>
</widget>
- <widget row="2" column="0" rowspan="1" colspan="2" >
+ <widget row="1" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Destination</string>
+ </property>
+ </widget>
+ <widget row="3" column="0" rowspan="1" colspan="2" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>backupButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Backup</string>
</property>
</widget>
- <widget row="1" column="0" rowspan="1" colspan="2" >
+ <widget row="0" column="0" rowspan="1" colspan="2" >
+ <class>QButtonGroup</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>frame_type</cstring>
+ </property>
+ <property stdset="1">
+ <name>title</name>
+ <string>Type</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>4</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>2</number>
+ </property>
+ <widget>
+ <class>QRadioButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>cb_type_userdata</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>User Data (Configuration + PIM)</string>
+ </property>
+ <property stdset="1">
+ <name>checked</name>
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget>
+ <class>QRadioButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>cb_type_fullbackup</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Full Backup (Root File System)</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget row="2" column="0" rowspan="1" colspan="2" >
<class>QListView</class>
<column>
<property>
<name>text</name>
<string>Applications</string>
</property>
<property>
<name>clickable</name>
<bool>true</bool>
</property>
<property>
<name>resizeable</name>
<bool>true</bool>
</property>
</column>
<property stdset="1">
<name>name</name>
<cstring>backupList</cstring>
</property>
<property stdset="1">
<name>allColumnsShowFocus</name>
<bool>true</bool>
</property>
<property stdset="1">
<name>rootIsDecorated</name>
<bool>true</bool>
</property>
</widget>
</grid>
</widget>
+ </grid>
+ </widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Widget3</cstring>
</property>
<attribute>
<name>title</name>
<string>Restore</string>
</attribute>
<grid>
<property stdset="1">
<name>margin</name>
<number>4</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>4</number>
</property>
<widget row="0" column="1" >
<class>QComboBox</class>
<property stdset="1">
<name>name</name>
<cstring>restoreSource</cstring>
</property>
</widget>
<widget row="2" column="0" rowspan="1" colspan="2" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>restoreButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Restore</string>
</property>
</widget>
<widget row="0" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel1_2</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Select Source</string>
</property>
</widget>
<widget row="1" column="0" rowspan="1" colspan="2" >
<class>QListView</class>
<column>
<property>
<name>text</name>
<string>Column 1</string>
</property>
<property>
<name>clickable</name>
<bool>true</bool>
</property>
<property>
<name>resizeable</name>
<bool>true</bool>
</property>
</column>