Ejemplo n.º 1
0
static QString databaseName(const MPDConnectionDetails &details)
{
    QString fileName=(!details.isLocal() ? details.hostname+'_'+QString::number(details.port) : details.hostname)+LibraryDb::constFileExt;
    fileName.replace('/', '_');
    fileName.replace('~', '_');
    return Utils::dataDir(constDirName, true)+fileName;
}
Ejemplo n.º 2
0
static QString cacheFileName(const MPDConnectionDetails &details, bool withPort=true)
{
    QString fileName=(withPort && !details.isLocal() ? details.hostname+'_'+QString::number(details.port) : details.hostname)
                     +MusicLibraryModel::constLibraryCompressedExt;
    fileName.replace('/', '_');
    fileName.replace('~', '_');
    return Utils::cacheDir(MusicLibraryModel::constLibraryCache)+fileName;
}
Ejemplo n.º 3
0
MPDConnectionDetails Settings::connectionDetails(const QString &name)
{
    MPDConnectionDetails details;
    QString n=MPDConnectionDetails::configGroupName(name);
    details.name=name;
    if (!cfg.hasGroup(n)) {
        details.name=QString();
        n=MPDConnectionDetails::configGroupName(details.name);
    }
    if (cfg.hasGroup(n)) {
        Configuration grp(n);
        details.hostname=grp.get("host", name.isEmpty() ? mpdDefaults.host : QString());
        details.port=grp.get("port", name.isEmpty() ? mpdDefaults.port : 6600);
        details.dir=grp.getDirPath("dir", name.isEmpty() ? mpdDefaults.dir : "/var/lib/mpd/music");
        details.topLevel=grp.get("topLevel", QString());
        #if defined ENABLE_KDE_SUPPORT && defined ENABLE_KWALLET
        if (KWallet::Wallet::isEnabled()) {
            if (grp.get("passwd", false)) {
                if (openWallet()) {
                    wallet->readPassword(name.isEmpty() ? "mpd" : name, details.password);
                }
            } else if (name.isEmpty()) {
                details.password=mpdDefaults.passwd;
            }
        } else
        #endif // ENABLE_KWALLET
            details.password=grp.get("passwd", name.isEmpty() ? mpdDefaults.passwd : QString());
        details.coverName=grp.get("coverName", QString());
        #ifdef ENABLE_HTTP_STREAM_PLAYBACK
        details.streamUrl=grp.get("streamUrl", QString());
        #endif
    } else {
        details.hostname=mpdDefaults.host;
        details.port=mpdDefaults.port;
        details.dir=mpdDefaults.dir;
        details.password=mpdDefaults.passwd;
        details.coverName=QString();
        #ifdef ENABLE_HTTP_STREAM_PLAYBACK
        details.streamUrl=QString();
        #endif
    }
    details.setDirReadable();
    return details;
}