summaryrefslogtreecommitdiffstats
path: root/kexi/main/startup/KexiStartup_p.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kexi/main/startup/KexiStartup_p.cpp
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kexi/main/startup/KexiStartup_p.cpp')
-rw-r--r--kexi/main/startup/KexiStartup_p.cpp127
1 files changed, 127 insertions, 0 deletions
diff --git a/kexi/main/startup/KexiStartup_p.cpp b/kexi/main/startup/KexiStartup_p.cpp
new file mode 100644
index 00000000..df7cddc6
--- /dev/null
+++ b/kexi/main/startup/KexiStartup_p.cpp
@@ -0,0 +1,127 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include "KexiStartup_p.h"
+
+#include <kstandarddirs.h>
+#include <kprogress.h>
+#include <kprocess.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+#include <qfileinfo.h>
+#include <qdir.h>
+#include <qapplication.h>
+
+SQLite2ToSQLite3Migration::SQLite2ToSQLite3Migration(const QString& filePath)
+: m_filePath(filePath)
+{
+ m_process = 0;
+ m_dlg = 0;
+ result = false;
+ m_run = false;
+}
+
+SQLite2ToSQLite3Migration::~SQLite2ToSQLite3Migration()
+{
+ delete m_process;
+ m_dlg->close();
+ delete m_dlg;
+}
+
+tristate SQLite2ToSQLite3Migration::run()
+{
+ if (m_run)
+ return false;
+ m_run = true;
+ const QString ksqlite2to3_app = KStandardDirs::findExe( "ksqlite2to3" );
+ if (ksqlite2to3_app.isEmpty())
+ return false;
+
+ QFileInfo fi(m_filePath);
+ if (fi.isSymLink()) {
+ m_filePath = fi.readLink();
+ fi = QFileInfo(m_filePath);
+ }
+ //remember permissions of m_filePath
+ m_restoreStat = (0==stat(QFile::encodeName(m_filePath), &m_st));
+
+ m_process = new KProcess(this, "process");
+ *m_process << ksqlite2to3_app << m_filePath;
+ m_process->setWorkingDirectory( fi.dir(true).absPath() );
+ connect( m_process, SIGNAL(receivedStderr(KProcess*,char*,int)),
+ this, SLOT(receivedStderr(KProcess*,char*,int)));
+ connect( m_process, SIGNAL(processExited(KProcess*)), this, SLOT(processExited(KProcess*)) );
+ if (!m_process->start(KProcess::NotifyOnExit, KProcess::Stderr))
+ return false;
+
+ m_dlg = new KProgressDialog(0, 0, QString::null,
+ i18n("Saving \"%1\" project file to a new \"%2\" database format...")
+ .arg(QDir::convertSeparators(QFileInfo(m_filePath).fileName())).arg("SQLite3")
+ );
+ m_dlg->setModal(true);
+ connect(m_dlg, SIGNAL(cancelClicked()), this, SLOT(cancelClicked()));
+ m_dlg->setMinimumDuration(1000);
+ m_dlg->setAutoClose(true);
+ m_dlg->progressBar()->setTotalSteps(100);
+ m_dlg->progressBar()->setProgress(0);
+ m_dlg->exec();
+
+ if (result!=true)
+ return result;
+
+ return result;
+}
+
+extern void updateProgressBar(KProgressDialog *pd, char *buffer, int buflen);
+
+void SQLite2ToSQLite3Migration::receivedStderr(KProcess *, char *buffer, int buflen)
+{
+ updateProgressBar(m_dlg, buffer, buflen);
+}
+
+void SQLite2ToSQLite3Migration::processExited(KProcess* process)
+{
+ kdDebug() << "EXIT " << process->name() << endl;
+
+ kdDebug() << process->isRunning() << " " << process->exitStatus() << endl;
+ m_dlg->close();
+ result = !process->isRunning() && 0==process->exitStatus();//m_process->normalExit();
+ kdDebug() << result.toString() << endl;
+ if (result == true) {
+ if (m_restoreStat) {
+ //restore permissions for m_filePath
+ chmod(QFile::encodeName(m_filePath), m_st.st_mode);
+ chown(QFile::encodeName(m_filePath), m_st.st_uid, m_st.st_gid);
+ }
+ }
+}
+
+void SQLite2ToSQLite3Migration::cancelClicked()
+{
+ kdDebug() << result.toString() << " cancelClicked() " <<m_process->isRunning() << " "
+ << m_process->exitStatus() << endl;
+ if (!m_process->isRunning() && 0==m_process->exitStatus())
+ return;
+ result = cancelled;
+ m_process->kill();
+}
+
+#include "KexiStartup_p.moc"
+