[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: [PATCH] Fix 49564 - please review
From: Ravikiran Rajagopal <ravi () ee ! eng ! ohio-state ! edu>
Date: 2003-03-11 18:44:19
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tuesday 11 March 2003 07:23 am, Waldo Bastian wrote:
> I think it should mention the file that isn't writable. I would also like
> to see an explicit config key to disable the dialog instead of abusing the
> presence of the "[KDE Action Restrictions]" group for this.
>
> Other than that, I don't think it differentiates between the config file
> being unwritable because of file permissions and the config file being
> unwritable because the file starts with [$i] I think it's desirable not to
> give a warning in the latter case.
Objections noted, and hopefully fixed in the patch attached. Please review.
Regards,
Ravi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE+bi6DbI8Y8y0oVXcRAo/DAJ42ig8nRUDMUD5qij68nbkHAwFcEwCfSzfg
CmV14GotPHNMB1E0bpp9eNg=
=MszI
-----END PGP SIGNATURE-----
["49564.diff" (text/x-diff)]
Index: kconfigbackend.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kconfigbackend.cpp,v
retrieving revision 1.78
diff -u -p -r1.78 kconfigbackend.cpp
--- kconfigbackend.cpp 27 Feb 2003 21:13:05 -0000 1.78
+++ kconfigbackend.cpp 11 Mar 2003 18:31:33 -0000
@@ -871,3 +873,34 @@ void KConfigBackEnd::virtual_hook( int,
void KConfigINIBackEnd::virtual_hook( int id, void* data )
{ KConfigBackEnd::virtual_hook( id, data ); }
+bool KConfigBackEnd::checkConfigFilesWritable(bool warnUser)
+{
+ // WARNING: Do NOT use the event loop as it may not exist at this time.
+ bool allWritable = TRUE;
+ QString errorMsg( I18N_NOOP("Unable to save configuration.\n") );
+ if ( !mLocalFileName.isEmpty() && !mLocalFileName.contains('$') && \
!checkAccess(mLocalFileName,W_OK) ) + {
+ allWritable = FALSE;
+ errorMsg = errorMsg + QString(I18N_NOOP("Configuration file \"%1\" not \
writable.\n")).arg(mLocalFileName); + }
+ if ( !mGlobalFileName.isEmpty() && !mGlobalFileName.contains('$') && \
!checkAccess(mGlobalFileName,W_OK) ) + {
+ allWritable = FALSE;
+ errorMsg = errorMsg + QString(I18N_NOOP("Configuration file \"%1\" not \
writable.\n")).arg(mGlobalFileName); + }
+
+ if (warnUser && !allWritable)
+ {
+#ifdef Q_WS_X11
+ QString cmdToExec = KStandardDirs::findExe(QString("kdialog"));
+ KApplication *app = kapp;
+ if (!cmdToExec.isEmpty() && app)
+ {
+ KProcess lprocess;
+ lprocess << cmdToExec << "--title" << app->instanceName() << \
"--msgbox" << errorMsg; + lprocess.start( KProcess::Block );
+ }
+#endif
+ }
+ return allWritable;
+}
Index: kconfigbackend.h
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kconfigbackend.h,v
retrieving revision 1.24
diff -u -p -r1.24 kconfigbackend.h
--- kconfigbackend.h 27 Feb 2003 21:23:01 -0000 1.24
+++ kconfigbackend.h 11 Mar 2003 18:31:33 -0000
@@ -133,6 +133,13 @@ public:
* @param mode the filemode (as in chmod)
*/
void setFileWriteMode(int mode);
+
+ /**
+ * Check whether the config files are writable.
+ * @param warnUser Warn the user if the configuration files are not \
writable. + * @return Indicates that all of the configuration files used \
are writable. + */
+ bool checkConfigFilesWritable(bool warnUser);
#ifdef KDE_NO_COMPAT
private:
Index: kconfigbase.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kconfigbase.cpp,v
retrieving revision 1.151
diff -u -p -r1.151 kconfigbase.cpp
--- kconfigbase.cpp 21 Feb 2003 14:01:32 -0000 1.151
+++ kconfigbase.cpp 11 Mar 2003 18:31:33 -0000
@@ -1653,5 +1653,12 @@ void KConfigBase::virtual_hook( int, voi
void KConfigGroup::virtual_hook( int id, void* data )
{ KConfigBase::virtual_hook( id, data ); }
-#include "kconfigbase.moc"
+bool KConfigBase::checkConfigFilesWritable(bool warnUser)
+{
+ if (backEnd)
+ return backEnd->checkConfigFilesWritable(warnUser);
+ else
+ return FALSE;
+}
+#include "kconfigbase.moc"
Index: kconfigbase.h
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kconfigbase.h,v
retrieving revision 1.84
diff -u -p -r1.84 kconfigbase.h
--- kconfigbase.h 27 Feb 2003 21:13:05 -0000 1.84
+++ kconfigbase.h 11 Mar 2003 18:31:33 -0000
@@ -1597,7 +1597,14 @@ public:
*/
ConfigState getConfigState() const;
+ /**
+ * Check whether the config files are writable.
+ * @param warnUser Warn the user if the configuration files are not \
writable. + * @return Indicates that all of the configuration files used \
are writable. + */
+ bool checkConfigFilesWritable(bool warnUser);
+
protected:
/**
* Reads the locale and put in the configuration data struct.
Index: kapplication.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kapplication.cpp,v
retrieving revision 1.572
diff -u -p -r1.572 kapplication.cpp
--- kapplication.cpp 5 Mar 2003 04:45:19 -0000 1.572
+++ kapplication.cpp 11 Mar 2003 18:40:57 -0000
@@ -671,0 +671,0 @@ void KApplication::init(bool GUIenabled)
KConfig* config = KGlobal::config();
d->actionRestrictions = config->hasGroup("KDE Action Restrictions" );
+#ifdef Q_WS_X11
+ // For brain-dead configurations where the user's local config file is \
not writable. + if (config->readBoolEntry("CheckConfigFilesWritable",TRUE))
+ config->checkConfigFilesWritable(TRUE);
+#endif
if (GUIenabled)
{
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic