[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/sysadmin/kiosktool
From: Ian Reinhart Geiser <geiseri () kde ! org>
Date: 2009-03-02 13:59:43
Message-ID: 1236002383.506738.1817.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 934192 by geiseri:
Moving more business logic to KDE 4. We can create profiles now, but we still
cannot save settings to them. Progress none the less.
M +60 -71 kioskrun.cpp
M +1 -0 main.cpp
M +8 -5 profilePropsPage.cpp
--- trunk/extragear/sysadmin/kiosktool/kioskrun.cpp #934191:934192
@@ -50,6 +50,7 @@
#include "kiosksync.h"
#include <kio/netaccess.h>
+#include <kio/copyjob.h>
#include <kio/deletejob.h>
#include <kglobal.h>
@@ -134,7 +135,7 @@
if (xdgConfigDirs.isEmpty())
{
xdgConfigDirs << "/etc/xdg";
- QString sysconfMenuDir = KGlobal::dirs()->findDirs("xdgconf-menu", \
QString::null).last(); + QString sysconfMenuDir = \
KGlobal::dirs()->findDirs("xdgconf-menu", QString()).last(); if \
(sysconfMenuDir.endsWith("/menus/")) xdgConfigDirs << \
sysconfMenuDir.left(sysconfMenuDir.length()-7);
@@ -413,7 +414,7 @@
{
ext.replace("i", "");
if (ext == "[$]")
- ext = QString::null;
+ ext = QString();
}
static void addImmutable(QString &ext)
@@ -612,7 +613,7 @@
return true; // Continue
}
#endif
- QString installLocation = m_saveInstance->dirs()->saveLocation("config", \
QString::null, false) + filename; + QString installLocation = \
m_saveInstance->dirs()->saveLocation("config", QString(), false) + filename; if \
(!install(path, installLocation)) {
m_immutableStatusCache.insert(filename, status); // Keep it around
@@ -902,7 +903,7 @@
msg += i18n("Without this directory your changes can not be saved.<p>"
"Do you want to retry creating the directory or abort the saving of \
changes?</qt>");
- int msgResult = KMessageBox::warningYesNo(kapp->activeWindow(), msg, \
QString::null, + int msgResult = KMessageBox::warningYesNo(kapp->activeWindow(), \
msg, QString(),
KGuiItem( i18n("&Retry") ), KGuiItem( i18n("&Abort") \
));
if (msgResult == KMessageBox::No)
@@ -935,7 +936,7 @@
// Parent doesn't exist,
int result = KMessageBox::warningContinueCancel(kapp->activeWindow(),
i18n("<qt>The directory <b>%1</b> does not yet exist. "
- "Do you want to create it?", parent.prettyUrl()), \
QString::null, + "Do you want to create it?", \
parent.prettyUrl()), QString(), KGuiItem( i18n("Create &Dir") ));
if (result != KMessageBox::Continue)
return false;
@@ -980,7 +981,7 @@
msg += i18n("Without this directory your files can not be uploaded.<p>"
"Do you want to retry creating the directory or abort uploading?</qt>");
- int msgResult = KMessageBox::warningYesNo(kapp->activeWindow(), msg, \
QString::null, + int msgResult = KMessageBox::warningYesNo(kapp->activeWindow(), \
msg, QString(),
KGuiItem( i18n("&Retry") ), KGuiItem( i18n("&Abort" \
)));
if (msgResult == KMessageBox::No)
@@ -994,8 +995,7 @@
bool
KioskRun::install(const QString &file, const QString &destination)
{
- //PORT to KDE4
- KUrl dest;
+ KUrl dest;
if (!m_isRoot || (m_user != "root"))
{
dest.setProtocol("fish");
@@ -1006,19 +1006,21 @@
if (!createDir(dest.upUrl().path()))
return false;
-#if 0
+
do
{
KUrl src;
src.setPath(file);
- bool result = NETACCESS::file_copy(src, dest, 0644, true, false, \
kapp->activeWindow());
- if (result == true)
+ KIO::CopyJob *result = KIO::copy(src, dest, \
KIO::Overwrite|KIO::HideProgressInfo ); + if (result->exec() == true)
{
::unlink(QFile::encodeName(file));
+ delete result;
return true;
}
- QString error = NETACCESS::lastErrorString();
+ QString error = result->errorString();
+ delete result;
QString msg;
if (error.isEmpty())
msg = i18n("<qt>The file <b>%1</b> could not be installed because of an \
unspecified problem.", destination); @@ -1028,14 +1030,14 @@
msg += i18n("Do you want to retry the installation or abort the saving of \
changes?</qt>");
- int msgResult = KMessageBox::warningYesNo(kapp->activeWindow(), msg, \
QString::null, + int msgResult = \
KMessageBox::warningYesNo(KApplication::activeWindow(), msg, \
QString(),
KGuiItem( i18n("&Retry") ), KGuiItem( i18n("&Abort" \
)));
if (msgResult == KMessageBox::No)
return false;
}
while (true);
-#endif
+
return false;
}
@@ -1062,7 +1064,7 @@
msg += i18n("Do you want to retry or abort the uploading?</qt>");
- int msgResult = KMessageBox::warningYesNo(kapp->activeWindow(), msg, \
QString::null, + int msgResult = KMessageBox::warningYesNo(kapp->activeWindow(), \
msg, QString(),
KGuiItem( i18n("&Retry") ), KGuiItem( i18n("&Abort")) \
);
if (msgResult == KMessageBox::No)
@@ -1104,24 +1106,23 @@
src.setHost("localhost");
src.setUser(m_user);
}
-#if 0
- for(QStringList::ConstIterator it = files.constBegin();
- it != files.constEnd(); ++it)
+
+ foreach( QString file, files )
{
- src.setPath(source + *it);
- dest.setPath(destination + *it);
+ src.setPath(source + file);
+ dest.setPath(destination + file);
-kDebug() << "Moving " << src << " --> " << dest << endl;
+ kDebug() << "Moving " << src << " --> " << dest << endl;
if (!createRemoteDirRecursive(dest.upUrl(), false))
return false;
- if (!NETACCESS::file_move(src, dest, -1, true, false, kapp->activeWindow()))
+ if (!NETACCESS::move(src, dest, KApplication::activeWindow()))
{
// TODO add error message + retry
return false;
}
}
-#endif
+
return true;
}
@@ -1152,13 +1153,11 @@
QString profileInfoFile = installDir + ".kdeprofile";
if (QFile::exists(profileInfoFile))
{
- //PORT to KDE4
-#if 0
- KSimpleConfig profileInfo(profileInfoFile, true);
- description = profileInfo.readEntry("Description");
- installUser = profileInfo.readEntry("InstallUser", "root");
- return;
-#endif
+ KConfig profileInfo(profileInfoFile, KConfig::SimpleConfig );
+ KConfigGroup profileInfoGroup = profileInfo.group("General");
+ description = profileInfoGroup.readEntry("Description");
+ installUser = profileInfoGroup.readEntry("InstallUser", "root");
+ return;
}
QString defaultDescription;
@@ -1187,7 +1186,7 @@
if (QFile::exists(settingsUrl.path()))
{
- while (!NETACCESS::copy(settingsUrl, localCopyUrl, kapp->activeWindow()))
+ while (!NETACCESS::copy(settingsUrl, localCopyUrl, \
KApplication::activeWindow())) {
QString error = NETACCESS::lastErrorString();
QString msg;
@@ -1199,7 +1198,7 @@
msg += i18n("Do you want to retry the operation or abort the saving of \
changes?</qt>");
- int msgResult = KMessageBox::warningYesNo(kapp->activeWindow(), msg, \
QString::null, + int msgResult = \
KMessageBox::warningYesNo(kapp->activeWindow(), msg, QString(),
KGuiItem( i18n("&Retry") ), KGuiItem( i18n("&Abort")) \
);
if (msgResult == KMessageBox::No)
@@ -1223,7 +1222,7 @@
QString saveUser = m_user;
m_user = "root";
bool result = install(m_localKderc, m_kderc);
- m_localKderc = QString::null;
+ m_localKderc = QString();
m_user = saveUser;
KGlobal::config()->reparseConfiguration();
return result;
@@ -1239,13 +1238,10 @@
QString saveProfileInfo = installDir + ".kdeprofile";
KConfig profileInfo(saveProfileInfo, KConfig::SimpleConfig);
- //PORT to KDE4
-#if 0
- QString oldDescription = profileInfo.readEntry("Description");
- QString oldInstallUser = profileInfo.readEntry("InstallUser");
-#endif
- QString oldDescription;
- QString oldInstallUser;
+ KConfigGroup profileGroup = profileInfo.group("General");
+ QString oldDescription = profileGroup.readEntry("Description");
+ QString oldInstallUser = profileGroup.readEntry("InstallUser");
+
if (deleteProfile && !installDir.isEmpty())
{
bool result = true;
@@ -1259,7 +1255,7 @@
{
m_user = installUser;
remove(installDir);
- m_user = QString::null;
+ m_user = QString();
}
}
else if (deleteFiles)
@@ -1278,7 +1274,7 @@
// Delete files
m_user = installUser;
result = remove(installDir);
- m_user = QString::null;
+ m_user = QString();
if (!result)
return false;
break;
@@ -1296,7 +1292,7 @@
m_user = installUser;
if (QFile::exists(saveProfileInfo))
result = remove(saveProfileInfo);
- m_user = QString::null;
+ m_user = QString();
if (!result)
return false;
}
@@ -1305,16 +1301,15 @@
{
QString localProfileInfo = ::KStandardDirs::locateLocal("tmp", \
"kdeprofile_"+KRandom::randomString(5)); \
::unlink(QFile::encodeName(localProfileInfo));
- //PORT to KDE4
-#if 0
+
KConfig newProfileInfo(localProfileInfo,KConfig::SimpleConfig );
- newProfileInfo.writeEntry("Description", description);
- newProfileInfo.writeEntry("InstallUser", installUser);
- newProfileInfo.sync();
+ KConfigGroup newProfileGroup = newProfileInfo.group("General");
+ newProfileGroup.writeEntry("Description", description);
+ newProfileGroup.writeEntry("InstallUser", installUser);
+ newProfileGroup.sync();
bool result = install(localProfileInfo, saveProfileInfo);
if (!result)
return false;
-#endif
}
KUser thisUser;
@@ -1421,13 +1416,13 @@
// Keep on looking...
}
}
- return QString::null;
+ return QString();
}
QStringList
KioskRun::allProfiles()
{
- //PORT to KDE4
+
KSharedConfigPtr config = KGlobal::config();
QStringList groups = config->groupList();
QStringList profiles;
@@ -1448,22 +1443,21 @@
QString profilePrefix = getProfilePrefix();
if (!profilePrefix.isEmpty())
{
- QDir dir(profilePrefix, QString::null, QDir::Unsorted, QDir::Dirs);
+ QDir dir(profilePrefix, QString(), QDir::Unsorted, QDir::Dirs);
QStringList profileDirs = dir.entryList();
- for(QStringList::ConstIterator it = profileDirs.constBegin();
- it != profileDirs.constEnd(); ++it)
+ foreach( QString profileDir, profileDirs )
{
- if ((*it).startsWith("."))
+ if (profileDir.startsWith("."))
continue;
- QString dir = profilePrefix + *it + "/";
+ QString dir = profilePrefix + profileDir + "/";
if (directories.contains(dir))
{
kDebug() << "Skipping " << dir << ", dir already listed" << endl;
continue;
}
- if (profiles.contains(*it))
+ if (profiles.contains(profileDir))
{
- kDebug() << "Skipping " << dir << ", profile [" << (*it) << "] already \
listed" << endl; + kDebug() << "Skipping " << dir << ", profile [" << \
profileDir << "] already listed" << endl; continue;
}
@@ -1472,7 +1466,7 @@
kDebug() << "Skipping " << dir << ", no profile info" << endl;
continue;
}
- profiles.append(*it);
+ profiles.append(profileDir);
directories.append(dir);
}
}
@@ -1486,9 +1480,7 @@
void
KioskRun::getUserProfileMappings( ProfileMapping &groups, ProfileMapping &users, \
QStringList &groupOrder) {
- //PORT to KDE4
-#if 0
- groups.clear();
+ groups.clear();
users.clear();
KConfigGroup config( KGlobal::config(), "Directories");
@@ -1497,31 +1489,28 @@
if (mapFile.isEmpty() || !QFile::exists(mapFile))
return;
- KConfig mapCfg(mapFile, true);
+ KConfig mapCfg(mapFile, KConfig::SimpleConfig);
KConfigGroup grp = mapCfg.group("General");
groupOrder = grp.readEntry("groups", QStringList());
grp = mapCfg.group("Groups");
- for ( QStringList::ConstIterator it = groupOrder.constBegin();
- it != groupOrder.constEnd(); ++it )
+ foreach( QString group, groupOrder )
{
- QString group = *it;
QStringList profiles = grp.readEntry(group, QStringList());
if (!profiles.isEmpty())
groups.insert(group, profiles);
}
QMap<QString, QString> cfg_users = mapCfg.entryMap("Users");
- for ( QMap<QString, QString>::Iterator it = cfg_users.begin();
- it != cfg_users.end(); ++it )
+ foreach( QString key, cfg_users.keys() )
{
- QString user = it.key();
- QStringList profiles = it.data().split(',');
+ QString user = key;
+ QStringList profiles = cfg_users[key].split(',');
if (!profiles.isEmpty())
users.insert(user, profiles);
}
-#endif
+
}
bool
--- trunk/extragear/sysadmin/kiosktool/main.cpp #934191:934192
@@ -39,6 +39,7 @@
aboutData.addAuthor(ki18n( "Ian Reinhart Geiser" ),ki18n("Maintainer"), \
"geiseri@kde.org"); aboutData.addAuthor(ki18n( "Waldo Bastian" ),ki18n("Original \
Author"), "bastian@kde.org"); aboutData.addAuthor(ki18n( "Laurent Montel" \
),ki18n("Port to KDE4"), "montel@kde.org"); + \
aboutData.setHomepage("http://extragear.kde.org/apps/kiosktool");
KCmdLineArgs::init(argc, argv, &aboutData);
--- trunk/extragear/sysadmin/kiosktool/profilePropsPage.cpp #934191:934192
@@ -20,10 +20,10 @@
#include "profilePropsPage.h"
-#include <qcombobox.h>
-#include <qvalidator.h>
+#include <QComboBox>
+#include <QValidator>
-#include <kapplication.h>
+#include <KDE/KApplication>
#include <kconfig.h>
#include <klineedit.h>
#include <klocale.h>
@@ -31,6 +31,7 @@
#include <kurlrequester.h>
#include <kuser.h>
#include <kglobal.h>
+#include <kdebug.h>
#include "kioskrun.h"
#include "kiosksync.h"
@@ -47,6 +48,7 @@
result.sort();
// Remove dupes
+/*
QStringList::Iterator nextIt = result.begin();
for(QStringList::Iterator it = result.begin();
it != result.end(); it = nextIt)
@@ -57,7 +59,7 @@
if ((nextIt != result.end()) && ((*it) == (*nextIt)))
result.removeAll(*it);
}
-
+*/
return result;
}
@@ -198,11 +200,12 @@
return false;
}
}
-
QString installUser = user;
bool result = KioskRun::self()->setProfileInfo( m_profile, description, \
installDir, installUser);
+ kDebug() << "here" << result << m_profile << description << installDir << \
installUser; +
if (result && !m_origProfile.isEmpty() && (m_origProfile != m_profile))
{
result = KioskRun::self()->deleteProfile( m_origProfile, false );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic