20#include "KexiStartup_p.h"
22#include <kstandarddirs.h>
28#include <tqfileinfo.h>
30#include <tqapplication.h>
32SQLite2ToSQLite3Migration::SQLite2ToSQLite3Migration(
const TQString& filePath)
41SQLite2ToSQLite3Migration::~SQLite2ToSQLite3Migration()
48tristate SQLite2ToSQLite3Migration::run()
53 const TQString ksqlite2to3_app = TDEStandardDirs::findExe(
"ksqlite2to3" );
54 if (ksqlite2to3_app.isEmpty())
57 TQFileInfo fi(m_filePath);
59 m_filePath = fi.readLink();
60 fi = TQFileInfo(m_filePath);
63 m_restoreStat = (0==stat(TQFile::encodeName(m_filePath), &m_st));
65 m_process =
new TDEProcess(
this,
"process");
66 *m_process << ksqlite2to3_app << m_filePath;
67 m_process->setWorkingDirectory( fi.dir(
true).absPath() );
68 connect( m_process, TQ_SIGNAL(receivedStderr(TDEProcess*,
char*,
int)),
69 this, TQ_SLOT(receivedStderr(TDEProcess*,
char*,
int)));
70 connect( m_process, TQ_SIGNAL(processExited(TDEProcess*)),
this, TQ_SLOT(processExited(TDEProcess*)) );
71 if (!m_process->start(TDEProcess::NotifyOnExit, TDEProcess::Stderr))
74 m_dlg =
new KProgressDialog(0, 0, TQString(),
75 i18n(
"Saving \"%1\" project file to a new \"%2\" database format...")
76 .arg(TQDir::convertSeparators(TQFileInfo(m_filePath).fileName())).arg(
"SQLite3")
78 m_dlg->setModal(
true);
79 connect(m_dlg, TQ_SIGNAL(cancelClicked()),
this, TQ_SLOT(cancelClicked()));
80 m_dlg->setMinimumDuration(1000);
81 m_dlg->setAutoClose(
true);
82 m_dlg->progressBar()->setTotalSteps(100);
83 m_dlg->progressBar()->setProgress(0);
92extern void updateProgressBar(KProgressDialog *pd,
char *buffer,
int buflen);
94void SQLite2ToSQLite3Migration::receivedStderr(TDEProcess *,
char *buffer,
int buflen)
96 updateProgressBar(m_dlg, buffer, buflen);
99void SQLite2ToSQLite3Migration::processExited(TDEProcess* process)
101 kdDebug() <<
"EXIT " << process->name() << endl;
103 kdDebug() << process->isRunning() <<
" " << process->exitStatus() << endl;
105 result = !process->isRunning() && 0==process->exitStatus();
106 kdDebug() << result.toString() << endl;
107 if (result ==
true) {
110 chmod(TQFile::encodeName(m_filePath), m_st.st_mode);
111 chown(TQFile::encodeName(m_filePath), m_st.st_uid, m_st.st_gid);
116void SQLite2ToSQLite3Migration::cancelClicked()
118 kdDebug() << result.toString() <<
" cancelClicked() " <<m_process->isRunning() <<
" "
119 << m_process->exitStatus() << endl;
120 if (!m_process->isRunning() && 0==m_process->exitStatus())
126#include "KexiStartup_p.moc"
3-state logical type with three values: true, false and cancelled and convenient operators.