Bug 157526 - [Patch provided] Add a function KGlobalSettings::readXdgUserDir(const QString path) to retrieve xdg path
Summary: [Patch provided] Add a function KGlobalSettings::readXdgUserDir(const QString...
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Mandriva RPMs Linux
: NOR wishlist
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-09 15:52 UTC by rapsys
Modified: 2009-02-18 01:40 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch that add retrieve the xdg path (3.79 KB, patch)
2008-02-09 16:01 UTC, rapsys
Details
Same patch but in right kstandarddirs class as requested, plz apply ;) (3.23 KB, patch)
2008-02-09 21:41 UTC, rapsys
Details
Patch following the kde policy rules (for kde3) (3.39 KB, patch)
2008-02-09 22:04 UTC, rapsys
Details
New patch following naming rules like localxdgconfigdir. (3.22 KB, patch)
2008-02-14 22:07 UTC, rapsys
Details
Final version using kdelibs api (3.41 KB, patch)
2008-02-21 19:41 UTC, rapsys
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rapsys 2008-02-09 15:52:28 UTC
Version:           3.5.8-9mdv2008.1 (using KDE 3.5.8)
Installed from:    Mandriva RPMs
Compiler:          Target: i586-mandriva-linux-gnu version gcc 4.2.2 20071128 (prerelease) (4.2.2-2mdv2008.1) Linux (i686) release 2.6.24-laptop-1mdv
OS:                Linux

Hi,

I went into change konversation default configuration that sux
(store download in $HOME/dccrecv, logs in $HOME/logs, etc...)

But i went to discover there is no way to retrieve the xdg user directory stored in : $HOME/.config/user-dirs.dirs

Next patch would allow me to retrieve that path with the following call KGlobalSettings::readXdgUserDir("download") the download directory ($HOME/Téléchargement in my case for example)

Plz add it for 3.5.9 version.
Comment 1 rapsys 2008-02-09 16:01:50 UTC
Created attachment 23501 [details]
Patch that add retrieve the xdg path

This patch add the readXdgUserDir function to retrieve user xdg directories.
Comment 2 Pino Toscano 2008-02-09 16:59:14 UTC
Wrong place for the function, it should be in KStandardDirs, as it's that class responsible for handling paths.
Comment 3 rapsys 2008-02-09 21:41:17 UTC
Created attachment 23508 [details]
Same patch but in right kstandarddirs class as requested, plz apply ;)
Comment 4 rapsys 2008-02-09 22:04:08 UTC
Created attachment 23510 [details]
Patch following the kde policy rules (for kde3)
Comment 5 rapsys 2008-02-14 22:07:51 UTC
Created attachment 23578 [details]
New patch following naming rules like localxdgconfigdir.
Comment 6 rapsys 2008-02-21 19:41:53 UTC
Created attachment 23654 [details]
Final version using kdelibs api
Comment 7 David Faure 2008-02-21 23:00:52 UTC
First the implementation details:
* QFile f( (new KStandardDirs())->localxdgconfdir() + "/user-dirs.dirs" ): memory leak. Use something like self() instead of creating a new KStandardDirs instance.
* All this line-parsing looks like something that could be done with KConfig+KConfigGroup(&cfg,QString()) instead (which handles $HOME etc.)

About the API:
* This method should take an enum instead of a string, otherwise there's a too big risk for typos.
* The all-lowercase method name matches some old method names from Waldo but it's not good Qt/KDE API IMHO, I would make it something like userPath(...) or standardUserDirectory(...).

Where's the spec for this user-dirs.dirs file?

Also with this we have two notions of "the user's document directory": KGlobalSettings::documentPath() and the new KStandardDirs::localxdguserdir(KStandardDirs::Document).
A complete solution to that problem would invove:
* porting KGlobalSettings::desktopPath()/documentPath() to localxdguserdir(...) so that we don't have conflicting results from the two
* changing the kcontrol module to write to user-dirs.dirs - otherwise the user has to edit a file by hand to set those paths....
* ... and even migrating existing paths from kdeglobals to user-dirs.dirs so that users don't lose their configuration after upgrading kde

Alternatively, localxdguserdir should not provide access to the desktop and document paths for now, those can be marked as TODO for later I guess,
but we still need to provide a way to set those other paths (download, music, picture, video etc) from the GUI.

And finally: this is a patch for 3.5.8??? It will never go into 3.5.8, this is post-end-of-life especially for new API.
This has to go into kdelibs trunk (4.1).
Comment 8 rapsys 2008-02-22 01:51:19 UTC
I was hopping to have it for kde 3.5.9 release :'(
(mandriva refused because too close to release date)

But it's dead right now...

I will try what you say, but i got a problem on kde4 version i tried to code, it was failing because of a charset problem in file reading.

I will investigate it asap (around 7d before i may take a look on it).
Comment 9 David Faure 2009-02-18 01:40:04 UTC
This has been implemented in Qt4 and KDE4 (Qt has the code for reading these dirs, and I extended the GUI in KDE for setting them).