remove some now unused code from XMMSHandler and clean up headers

This commit is contained in:
Thomas Frauendorfer 2008-02-11 19:28:07 +01:00
parent ced09fc049
commit f10cd0465a
41 changed files with 407 additions and 242 deletions

3
lib/README Normal file
View file

@ -0,0 +1,3 @@
Contains a copy of some of Esperanzas src/lib/ directory
Will perhaps someday become a seperate lib

View file

@ -1,4 +0,0 @@
Contains a copy of some of Esperanzas src/lib/ directory
Will have to be removed as soon as those files become a seperate lib
Redo XSettings with something better

View file

@ -8,6 +8,7 @@ OBJECTS_DIR = .obj
SOURCES += xclient.cpp \
xclientcache.cpp \
xconfig.cpp \
xplayback.cpp \
xcollection.cpp \
playlistmodel.cpp \
xmmsqt4.cpp
@ -16,7 +17,9 @@ SOURCES += xclient.cpp \
HEADERS += xclient.h \
xclientcache.h \
xconfig.h \
xplayback.h \
xcollection.h \
xcollection_p.h \
playlistmodel.h \
xmmsqt4.h \
debug.h

View file

@ -26,6 +26,8 @@
#include <QFileInfo>
#include "playlistmodel.h"
#include "xclient.h"
#include "xclientcache.h"
PlaylistModel::PlaylistModel (QObject *parent, XClient *client, const QString &name) : QAbstractItemModel (parent)
{

View file

@ -20,13 +20,13 @@
#include <xmmsclient/xmmsclient++.h>
class XClient;
#include <QAbstractTableModel>
#include <QVariant>
#include <QHash>
#include <QIcon>
#include "xclient.h"
/**
* @class PlaylistModel playlistmodel.h
* @brief A model that represents a playlist on the server

View file

@ -24,7 +24,10 @@
#include <QSettings>
#include "xclient.h"
#include "xclientcache.h"
#include "xplayback.h"
#include "xcollection.h"
#include "xconfig.h"
#include "xmmsqt4.h"
#include "debug.h"
@ -53,6 +56,7 @@ XClient::qToStd (const QString &str)
return std::string (str.toUtf8 ().data ());
}
/*
QDir
XClient::esperanza_dir ()
{
@ -68,13 +72,15 @@ XClient::esperanza_dir ()
}
return QDir ();
}
*/
XClient::XClient (QObject *parent, const std::string &name) : QObject (parent), m_sync (name + "-sync")
{
m_client = NULL;
m_isconnected = false;
m_cache = new XClientCache (this, this);
m_cache = new XClientCache (this);
m_config = new XConfig (this);
m_playback = new XPlayback (this);
m_collection = new XCollection (this);
m_name = name;
}

View file

@ -20,32 +20,16 @@
#include <xmmsclient/xmmsclient++.h>
class XClient;
#include <QObject>
#include <QHash>
#include <QVariant>
#include <QDir>
#include <QWidget>
#include "xclientcache.h"
#include "xconfig.h"
class QWidget;
class XClientCache;
class XConfig;
class XPlayback;
class XCollection;
/*
class XSettings : public QObject
{
Q_OBJECT
public:
XSettings (QObject *);
void change_settings ();
signals:
void settingsChanged ();
};
*/
class XClient : public QObject {
Q_OBJECT
@ -53,7 +37,8 @@ class XClient : public QObject {
XClient (QObject *, const std::string &);
void disconnect ();
bool connect (const char *path = NULL, const bool &sync = false, QWidget* parent = NULL);
bool connect (const char *path = NULL, const bool &sync = false,
QWidget* parent = NULL);
static void propDictToQHash (const std::string &key,
const Xmms::Dict::Variant &value,
const std::string &source,
@ -74,6 +59,10 @@ class XClient : public QObject {
return m_config;
};
XPlayback *xplayback () const {
return m_playback;
}
XCollection *xcollection () const {
return m_collection;
}
@ -89,7 +78,7 @@ class XClient : public QObject {
return m_isconnected;
};
static QDir esperanza_dir ();
// static QDir esperanza_dir ();
void setDisconnectCallback (const Xmms::DisconnectCallback::slot_type &slot) { m_client->setDisconnectCallback (slot); }
const Xmms::Collection* collection () { if (m_client && m_client->isConnected ()) return &m_client->collection; else return NULL; }
const Xmms::Playlist* playlist () { if (m_client && m_client->isConnected ()) return &m_client->playlist; else return NULL; }
@ -111,6 +100,7 @@ class XClient : public QObject {
// Xmms::Client *m_client;
XClientCache *m_cache;
XConfig *m_config;
XPlayback *m_playback;
XCollection *m_collection;
bool m_isconnected;

View file

@ -16,6 +16,7 @@
#include "xclientcache.h"
#include "xclient.h"
#include <QObject>
#include <QIcon>
@ -26,10 +27,11 @@
#include <QPixmapCache>
#include <QSettings>
XClientCache::XClientCache (QObject *parent, XClient *client) : QObject (parent)
XClientCache::XClientCache (XClient *client) : QObject (client)
{
QSettings s;
connect (client, SIGNAL (gotConnection (XClient *)), this, SLOT (got_connection (XClient *)));
connect (client, SIGNAL (gotConnection (XClient *)),
this, SLOT (got_connection (XClient *)));
QPixmapCache::setCacheLimit (s.value ("core/pixmapcache").toInt ());
}
@ -37,10 +39,13 @@ void
XClientCache::got_connection (XClient *client)
{
m_client = client;
client->playback ()->signalPlaytime () (Xmms::bind (&XClientCache::handle_playtime, this));
client->playback ()->getPlaytime () (Xmms::bind (&XClientCache::handle_playtime, this));
client->playback ()->signalPlaytime () (
Xmms::bind (&XClientCache::handle_playtime, this));
client->playback ()->getPlaytime () (
Xmms::bind (&XClientCache::handle_playtime, this));
client->medialib ()->broadcastEntryChanged () (Xmms::bind (&XClientCache::handle_mlib_entry_changed, this));
client->medialib ()->broadcastEntryChanged () (
Xmms::bind (&XClientCache::handle_mlib_entry_changed, this));
}
bool
@ -129,7 +134,7 @@ XClientCache::get_pixmap (uint32_t id)
if (!QPixmapCache::find (hash, p)) {
m_client->bindata ()->retrieve (hash.toStdString ()) (
boost::bind (&XClientCache::handle_bindata, this, _1, hash));
boost::bind (&XClientCache::handle_bindata, this, _1, hash));
QPixmapCache::insert (hash, QPixmap ());
m_icon_map[hash].append (id);
}
@ -143,8 +148,10 @@ QHash<QString, QVariant>
XClientCache::get_info (uint32_t id)
{
if (!m_info.contains (id)) {
m_client->medialib ()->getInfo (id) (Xmms::bind (&XClientCache::handle_medialib_info, this),
boost::bind (&XClientCache::handle_medialib_info_error, this, _1, id));
m_client->medialib ()->getInfo (id) (
Xmms::bind (&XClientCache::handle_medialib_info, this),
boost::bind (&XClientCache::handle_medialib_info_error,
this, _1, id));
m_info[id] = QHash<QString, QVariant> ();
}

View file

@ -18,23 +18,31 @@
#ifndef __XCLIENTCACHE_H__
#define __XCLIENTCACHE_H__
class XClientCache;
// for Xmms::bin definition
#include "xmmsclient/xmmsclient++/result.h"
#include "xclient.h"
class XClient;
namespace Xmms {
class Dict;
class PropDict;
}
// class XClientCache;
// #include "xclient.h"
#include <QObject>
#include <QIcon>
#include <QPixmap>
#include <QHash>
#include <QList>
#include <QVariant>
#include <QPixmapCache>
class QIcon;
class QPixmap;
//#include <QPixmapCache>
class XClientCache : public QObject
{
Q_OBJECT
public:
XClientCache (QObject *, XClient *);
XClientCache (XClient *);
QHash<QString, QVariant> get_info (uint32_t id);
QIcon get_icon (uint32_t id);

View file

@ -13,43 +13,28 @@
* GNU General Public License for more details.
*/
#include <xmmsclient/xmmsclient++.h>
#include "xcollection.h"
#include "xcollection_p.h"
#include "xclient.h"
#include <QHash>
#include <QString>
#include <QStringList>
#include <QUrl>
#include <QVariant>
XCollection::XCollection (XClient * client) : QObject ( client)
/*
* Private implemention to hide <xmmsclient/xmmsclient++> from collection.h
*/
XCollection::Private::Private (XCollection *collection) : QObject (collection)
{
m_client = client;
connect (client, SIGNAL (gotConnection (XClient *)),
this, SLOT (on_connect (XClient *)));
if (client->isConnected ()) {
on_connect (client);
}
}
void
XCollection::on_connect (XClient *client)
{
client->collection ()->broadcastCollectionChanged ()
(Xmms::bind (&XCollection::on_collection_modified, this));
client->collection ()->list ("Playlists")
(Xmms::bind (&XCollection::handle_playlists_list, this));
client->playlist ()->currentActive ()
(Xmms::bind (&XCollection::handle_active_pls_changed, this));
client->playlist ()->broadcastLoaded ()
(Xmms::bind (&XCollection::handle_active_pls_changed, this));
m_client = client;
}
bool
XCollection::on_collection_modified (const Xmms::Dict &value)
XCollection::Private::on_collection_modified (const Xmms::Dict &value)
{
QString newname = QString ();
QHash<QString, QVariant> tmp = XClient::convert_dict (value);
@ -99,6 +84,48 @@ XCollection::on_collection_modified (const Xmms::Dict &value)
return true;
}
/*
* The XCollection class
*/
XCollection::XCollection (XClient * client) : QObject ( client)
{
m_client = client;
d = new XCollection::Private (this);
connect (client, SIGNAL (gotConnection (XClient *)),
this, SLOT (on_connect (XClient *)));
// emit signals from private implementation as our own
connect (d, SIGNAL (collectionModified(QString, QString, int, QString)),
this, SIGNAL (collectionModified(QString, QString, int, QString)));
connect (d, SIGNAL (activePlaylistChanged (QString, QString)),
this, SIGNAL (activePlaylistChanged (QString, QString)));
if (client->isConnected ()) {
on_connect (client);
}
}
void
XCollection::on_connect (XClient *client)
{
client->collection ()->broadcastCollectionChanged ()
(Xmms::bind (&XCollection::Private::on_collection_modified, d));
client->collection ()->list ("Playlists")
(Xmms::bind (&XCollection::Private::handle_playlists_list, d));
client->playlist ()->currentActive ()
(Xmms::bind (&XCollection::Private::handle_active_pls_changed, d));
client->playlist ()->broadcastLoaded ()
(Xmms::bind (&XCollection::Private::handle_active_pls_changed, d));
m_client = client;
}
bool
XCollection::remove (QString name, QString ns) {
if (!m_client->isConnected ()) return false;
@ -111,9 +138,15 @@ XCollection::remove (QString name, QString ns) {
/*
* idList (Playlist) stuff
*/
QString
XCollection::activePlaylist ()
{
return d->m_activePlaylist;
}
bool
XCollection::handle_playlists_list (const Xmms::List< std::string > &list)
XCollection::Private::handle_playlists_list (const Xmms::List< std::string > &list)
{
m_playlists.clear ();
@ -130,7 +163,7 @@ QStringList
XCollection::list (QString ns) {
// FIXME: use the ns parameter.
// We will need to handle querying the serverside playlists bettter...
return m_playlists;
return d->m_playlists;
}
@ -145,7 +178,7 @@ XCollection::setActivePlaylist (QString name) {
}
bool
XCollection::handle_active_pls_changed (const std::string &name) {
XCollection::Private::handle_active_pls_changed (const std::string &name) {
QString tmp = m_activePlaylist;
m_activePlaylist = XClient::stdToQ (name);
@ -173,7 +206,7 @@ XCollection::playlistAddUrl (QUrl url, QString plsname)
}
if (plsname == "") {
plsname = m_activePlaylist;
plsname = d->m_activePlaylist;
}
m_client->playlist ()->addUrl (url.toString ().toStdString (),

View file

@ -13,14 +13,14 @@
* GNU General Public License for more details.
*/
#ifndef __XCollection_H__
#define __XCollection_H__
#ifndef __XCOLLECTION_H__
#define __XCOLLECTION_H__
#include "xclient.h"
class XClient;
#include <QObject>
class QString;
class QStringList;
class QString;
class QUrl;
class XCollection : public QObject
@ -32,9 +32,10 @@ class XCollection : public QObject
QStringList list (QString ns = "Playlists");
bool remove (QString name, QString ns);
// idlist specific
bool setActivePlaylist (QString name);
QString activePlaylist () {return m_activePlaylist;}
QString activePlaylist ();
bool addIdlist (QString name);
bool playlistAddUrl (QUrl url, QString plsname = "");
@ -48,14 +49,10 @@ class XCollection : public QObject
void on_connect (XClient *);
private:
bool on_collection_modified (const Xmms::Dict &value);
bool handle_playlists_list (const Xmms::List< std::string > &list);
bool handle_active_pls_changed (const std::string &name);
class Private;
Private* d;
XClient *m_client;
QStringList m_playlists;
QString m_activePlaylist;
};
#endif

51
lib/xcollection_p.h Normal file
View file

@ -0,0 +1,51 @@
/**
* This file is a part of Promoe
*
* Copyright (C) 2008 Thomas Frauendorfer
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
// these headers are placed in here, so that the moc files are created and
// that these Objects can emit signals
#ifndef __XCOLLECTION_P_H__
#define __XCOLLECTION_P_H__
#include <xmmsclient/xmmsclient++.h>
#include "xcollection.h"
#include <QObject>
#include <QStringList>
#include <QString>
class XCollection::Private : public QObject {
Q_OBJECT
public:
Private (XCollection *collection);
bool on_collection_modified (const Xmms::Dict &value);
bool handle_playlists_list (const Xmms::List< std::string > &list);
bool handle_active_pls_changed (const std::string &name);
QStringList m_playlists;
QString m_activePlaylist;
signals:
void collectionModified (QString collection, QString ns, int type,
QString newname);
void activePlaylistChanged (QString newActive, QString oldActive);
};
#endif

View file

@ -17,8 +17,10 @@
#include <xmmsclient/xmmsclient++.h>
#include "xconfig.h"
#include "xclient.h"
#include <QList>
#include <QVariant>
XConfig::XConfig (XClient *parent) : QObject (parent)
{

View file

@ -14,10 +14,13 @@
* GNU General Public License for more details.
*/
#ifndef __XConfig__
#define __XConfig__
#ifndef __XConfig_H__
#define __XConfig_H__
#include "xclient.h"
class XClient;
namespace Xmms {
class Dict;
}
#include <QObject>
#include <QHash>

88
lib/xplayback.cpp Normal file
View file

@ -0,0 +1,88 @@
/**
* This file is a part of Promoe, an XMMS2 Client.
*
* Copyright (C) 2008 Thomas Frauendorfer
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <xmmsclient/xmmsclient++.h>
#include "xplayback.h"
#include "xclient.h"
#include <xmmsclient/xmmsclient++/playback.h>
#include <xmmsclient/xmmsclient++/playlist.h>
XPlayback::XPlayback (XClient *client)
{
m_client = client;
}
void
XPlayback::play ()
{
if (!m_client->isConnected ()) return;
m_client->playback ()->start ();
}
void
XPlayback::pause ()
{
if (!m_client->isConnected ()) return;
m_client->playback ()->pause ();
}
void
XPlayback::stop ()
{
if (!m_client->isConnected ()) return;
m_client->playback ()->stop ();
}
void
XPlayback::prev ()
{
if (!m_client->isConnected ()) return;
m_client->playlist ()->setNextRel (-1);
m_client->playback ()->tickle ();
}
void
XPlayback::next ()
{
if (!m_client->isConnected ()) return;
m_client->playlist ()->setNextRel (1);
m_client->playback ()->tickle ();
}
void
XPlayback::seekMs (uint milliseconds)
{
if (!m_client->isConnected ()) return;
m_client->playback ()->seekMs (milliseconds);
}
void
XPlayback::seekMsRel (int milliseconds)
{
if (!m_client->isConnected ()) return;
m_client->playback ()->seekMsRel (milliseconds);
}

49
lib/xplayback.h Normal file
View file

@ -0,0 +1,49 @@
/**
* This file is a part of Promoe, an XMMS2 Client.
*
* Copyright (C) 2008 Thomas Frauendorfer
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __XPLAYBACK_H__
#define __XPLAYBACK_H__
class XClient;
#include <QObject>
/**
* @class XPlayback
* @brief Thin wrapper around Xmms::Playback providing QT Signals and Slots
*
*/
class XPlayback : public QObject {
Q_OBJECT
public:
XPlayback (XClient *);
public slots:
void play ();
void pause ();
void stop ();
void prev ();
void next ();
void seekMs (uint milliseconds);
void seekMsRel (int milliseconds);
private:
XClient *m_client;
};
#endif