[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    Re: [Kde-pim] [patch] Akonadi data connection
From:       Kevin Krammer <kevin.krammer () gmx ! at>
Date:       2007-08-19 16:05:17
Message-ID: 200708191805.23251.kevin.krammer () gmx ! at
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


On Saturday 18 August 2007, Volker Krause wrote:
> On Friday 17 August 2007 19:01:54 Kevin Krammer wrote:
> > I made another patch regarding Akonadi's data connection, this time
> > making the connection paramters (port on Windows, socket directory on
> > Unix) configurable through akonadiserverrc
> >
> > When starting up, akonadiserver will read "Connection/Port" on Windows
> > and "Connection/SocketDirectory" on Unix, defaulting to the previously
> > hardcoded values.
> >
> > After it has established its listening, it wil write the respective
> > settings into akonadiconnectionrc, which in turn is read by
> > libakonadi/session. This allows to configure the TCP port to "0", meaning
> > the server will just bind to any free port, and this port will then be
> > available in to the clients through the connetion config.
>
> thanks, patch looks good to me, please commit :)

Comitted.

Next thing I'd like to do is making use of the freedesktop.org base directory 
specification, essentially similar to KDEDIRS + KDEHOME.

Specifically using XDG_CONFIG_DIRS (and its specified default) will allow 
distributors and admins to install default configurations.

I already have the code for dealing with the environment variables and their 
defaults, see attached test program.

Cheers,
Kevin

-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring

["xdgdirstest.cpp" (text/x-c++src)]

#include <QtCore/QDebug>
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
#include <QtCore/QSettings>

#include <cstdlib>

namespace Akonadi
{
    QString xdgHomePath( const char* variable, const char* defaultSubDir );
    
    QStringList xdgPathList( const char* variable, const char* defaultDirList );
    
    QString findConfig( const QString& relPath );
};

int main()
{
    QString configHome = Akonadi::xdgHomePath( "XDG_CONFIG_HOME", ".config" );

    qDebug() << "configHome: " << configHome;
    
    QString dataHome = Akonadi::xdgHomePath( "XDG_DATA_HOME", ".local" );
    
    qDebug() << "dataHome: " << dataHome;

    QStringList configDirs = Akonadi::xdgPathList( "XDG_CONFIG_DIRS", "/etc/xdg" );
    
    qDebug() << "configDirs: " << configDirs;

    QStringList dataDirs = Akonadi::xdgPathList( "XDG_DATA_DIRS", "/usr/local/share:/usr/share" );
    
    qDebug() << "dataDirs: " << dataDirs;

    QString config = Akonadi::findConfig( "akonadi/test.cfg" );
    
    qDebug() << "config: " << config;

    return 0;
};

namespace Akonadi
{

QString xdgHomePath( const char* variable, const char* defaultSubDir )
{
    char* env = std::getenv( variable );
    
    QString xdgPath;
    if ( env == 0 || *env == '\0' )
        xdgPath = QDir::homePath() + QLatin1Char( '/' ) + QLatin1String( defaultSubDir );
    else if ( *env == '/' )
        xdgPath = QString::fromLocal8Bit( env );
    else
        xdgPath = QDir::homePath() + QLatin1Char( '/' ) + QString::fromLocal8Bit( env );
        
    xdgPath += QLatin1Char( '/' );
    
    return xdgPath;
}

QStringList xdgPathList( const char* variable, const char* defaultDirList )
{
    char* env = std::getenv( variable );
    
    QString xdgDirList;
    if ( env == 0 || *env == '\0' )
        xdgDirList = QLatin1String( defaultDirList );
    else
        xdgDirList = QString::fromLocal8Bit( env );
        
    QStringList xdgPathList = xdgDirList.split( QLatin1Char( ':' ) );
    
    QStringList::iterator it    = xdgPathList.begin();
    QStringList::iterator endIt = xdgPathList.end();
    for ( ; it != endIt; ++it )
    {
        *it += QLatin1Char( '/' );
    }
    
    return xdgPathList;
}

QString findConfig( const QString& relPath )
{
    QString fullPath = xdgHomePath( "XDG_CONFIG_HOME", ".config" ) + relPath;
    
    QFileInfo fileInfo(fullPath);
    if (fileInfo.exists()) return fullPath;
    
    QStringList pathList = xdgPathList( "XDG_CONFIG_DIRS", "/etc/xdg" );
    
    QStringList::const_iterator it    = pathList.begin();
    QStringList::const_iterator endIt = pathList.end();
    for ( ; it != endIt; ++it )
    {
        fileInfo = QFileInfo( *it + relPath );
        if ( fileInfo.exists() && fileInfo.isReadable() ) return fileInfo.absoluteFilePath();
    }
    
    return fullPath;
}

};

["signature.asc" (application/pgp-signature)]

_______________________________________________
KDE PIM mailing list kde-pim@kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic