OTHER: remove some long dead code
This commit is contained in:
parent
cc2da0c89c
commit
23749446fa
7 changed files with 0 additions and 1682 deletions
|
@ -1,793 +0,0 @@
|
|||
// old File, not in use any more
|
||||
#include <xmmsclient/xmmsclient++.h>
|
||||
#include "XMMSHandler.h"
|
||||
|
||||
#include "PlaylistList.h"
|
||||
#include "Playlist.h"
|
||||
|
||||
#include <QStyleOptionHeader>
|
||||
#include <QPaintEvent>
|
||||
#include <QSettings>
|
||||
#include <QCursor>
|
||||
#include <QDrag>
|
||||
#include <QMenu>
|
||||
|
||||
PlaylistItem::PlaylistItem (PlaylistList *pl, uint id)
|
||||
{
|
||||
m_pl = pl;
|
||||
m_id = id;
|
||||
m_req = false;
|
||||
m_duration = QString ("00:00");
|
||||
pl->addItem (this);
|
||||
}
|
||||
|
||||
PlaylistItem::PlaylistItem (PlaylistList *pl, uint id, uint pos)
|
||||
{
|
||||
m_pl = pl;
|
||||
m_id = id;
|
||||
m_req = false;
|
||||
m_duration = QString ("00:00");
|
||||
pl->addItem (this, pos);
|
||||
}
|
||||
|
||||
QString
|
||||
PlaylistItem::text (void)
|
||||
{
|
||||
|
||||
if (m_text.count() < 1) {
|
||||
|
||||
if (!m_req) {
|
||||
XMMSHandler::getInstance ().requestMediainfo (m_id);
|
||||
m_req = true;
|
||||
}
|
||||
|
||||
QString q;
|
||||
q.setNum (m_id);
|
||||
return q;
|
||||
} else {
|
||||
m_req = false;
|
||||
return m_text;
|
||||
}
|
||||
}
|
||||
|
||||
PlaylistList::PlaylistList (QWidget *parent) : QWidget (parent)
|
||||
{
|
||||
QSettings s;
|
||||
XMMSHandler &xmmsh = XMMSHandler::getInstance ();
|
||||
Skin *skin = Skin::getInstance ();
|
||||
|
||||
if (!s.contains("playlist/fontsize"))
|
||||
s.setValue ("playlist/fontsize", 10);
|
||||
|
||||
setAttribute (Qt::WA_NoBackground);
|
||||
setFocusPolicy (Qt::StrongFocus);
|
||||
|
||||
setAcceptDrops (true);
|
||||
|
||||
connect (skin, SIGNAL (skinChanged (Skin *)),
|
||||
this, SLOT (setPixmaps(Skin *)));
|
||||
|
||||
m_font = NULL;
|
||||
m_fontmetrics = NULL;
|
||||
m_items = new QList<PlaylistItem *>;
|
||||
m_selected = new QList<uint>;
|
||||
m_itemmap = new QHash<uint, PlaylistItem *>;
|
||||
m_offset = 0;
|
||||
m_status = XMMS_PLAYBACK_STATUS_STOP;
|
||||
m_bar = -2;
|
||||
|
||||
connect (&xmmsh, SIGNAL(playlistList(const Xmms::List< unsigned int > &)),
|
||||
this, SLOT(playlistList(const Xmms::List< unsigned int > &)));
|
||||
|
||||
connect (&xmmsh, SIGNAL(currentID(uint)),
|
||||
this, SLOT(currentID(uint)));
|
||||
|
||||
connect (&xmmsh, SIGNAL(mediainfoChanged(uint, const Xmms::PropDict &)),
|
||||
this, SLOT(mediainfoChanged(uint, const Xmms::PropDict &)));
|
||||
|
||||
connect (&xmmsh, SIGNAL(playlistChanged(const Xmms::Dict &)),
|
||||
this, SLOT(playlistChanged(const Xmms::Dict &)));
|
||||
|
||||
connect (&xmmsh, SIGNAL(playbackStatusChanged(Xmms::Playback::Status)),
|
||||
this, SLOT(setStatus(Xmms::Playback::Status)));
|
||||
|
||||
connect (&xmmsh, SIGNAL(settingsSaved()),
|
||||
this, SLOT(settingsSaved()));
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::settingsSaved ()
|
||||
{
|
||||
QSettings s;
|
||||
m_font->setPixelSize (s.value ("playlist/fontsize").toInt ());
|
||||
|
||||
if (m_fontmetrics) {
|
||||
delete m_fontmetrics;
|
||||
}
|
||||
m_fontmetrics = new QFontMetrics (*m_font);
|
||||
update ();
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::setStatus (Xmms::Playback::Status s)
|
||||
{
|
||||
m_status = s;
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::playlistChanged (const Xmms::Dict &change)
|
||||
{
|
||||
int signal = change.get<int32_t> ("type");
|
||||
XMMSHandler &xmmsh = XMMSHandler::getInstance ();
|
||||
switch (signal) {
|
||||
case XMMS_PLAYLIST_CHANGED_ADD:
|
||||
{
|
||||
uint id = change.get<uint32_t> ("id");
|
||||
if (m_itemmap->contains (id)) {
|
||||
addItem (m_itemmap->value (id));
|
||||
} else {
|
||||
new PlaylistItem (this, id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XMMS_PLAYLIST_CHANGED_INSERT:
|
||||
{
|
||||
uint id = change.get<uint32_t> ("id");
|
||||
int pos = change.get<int32_t> ("position");
|
||||
|
||||
if (m_itemmap->contains (id)) {
|
||||
addItem (m_itemmap->value (id));
|
||||
} else {
|
||||
new PlaylistItem (this, id, pos);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case XMMS_PLAYLIST_CHANGED_REMOVE:
|
||||
{
|
||||
int pos = change.get<int32_t> ("position");
|
||||
PlaylistItem *i = m_items->value (pos);
|
||||
|
||||
if (!i) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_items->removeAt (pos);
|
||||
if (!m_items->contains (i)) {
|
||||
m_itemmap->remove (i->getID ());
|
||||
delete i;
|
||||
}
|
||||
|
||||
if (m_active) {
|
||||
if (m_active > pos) {
|
||||
m_active --;
|
||||
} else if (m_active == pos) {
|
||||
m_active = 0;
|
||||
}
|
||||
}
|
||||
|
||||
doResize ();
|
||||
|
||||
}
|
||||
break;
|
||||
case XMMS_PLAYLIST_CHANGED_MOVE:
|
||||
break;
|
||||
case XMMS_PLAYLIST_CHANGED_CLEAR:
|
||||
case XMMS_PLAYLIST_CHANGED_SHUFFLE:
|
||||
case XMMS_PLAYLIST_CHANGED_SORT:
|
||||
{
|
||||
while (!m_items->isEmpty()) {
|
||||
PlaylistItem *item = m_items->takeFirst();
|
||||
m_items->removeAll (item);
|
||||
delete item;
|
||||
}
|
||||
|
||||
m_itemmap->clear ();
|
||||
|
||||
if (signal != XMMS_PLAYLIST_CHANGED_CLEAR) {
|
||||
xmmsh.requestPlaylistList ();
|
||||
} else {
|
||||
doResize ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
update ();
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::currentID (uint id)
|
||||
{
|
||||
PlaylistItem *i = m_itemmap->value (id);
|
||||
if (!i) {
|
||||
m_active = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
m_active = m_items->indexOf (i);
|
||||
|
||||
update ();
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::mediainfoChanged (uint id, const Xmms::PropDict &info)
|
||||
{
|
||||
PlaylistItem *i = m_itemmap->value (id);
|
||||
if (i) {
|
||||
QString n;
|
||||
if (info.contains ("title")) {
|
||||
if (info.contains ("artist")) {
|
||||
n = QString::fromUtf8 (info.get<std::string> ("artist").c_str ()) + " - ";
|
||||
}
|
||||
if (info.contains ("album")) {
|
||||
n += QString::fromUtf8 (info.get<std::string> ("album").c_str ()) + " - ";
|
||||
}
|
||||
n += QString::fromUtf8 (info.get<std::string> ("title").c_str ());
|
||||
} else if (info.contains ("channel")) {
|
||||
n = QString::fromUtf8 (info.get<std::string> ("channel").c_str ())
|
||||
+ " - " +
|
||||
QString::fromUtf8 (info.get<std::string> ("title").c_str ());
|
||||
} else {
|
||||
n = QString::fromUtf8 (info.get<std::string> ("url").c_str ());
|
||||
n = n.section ("/", -1);
|
||||
}
|
||||
|
||||
i->setText (n);
|
||||
|
||||
if (info.contains ("duration")) {
|
||||
unsigned int duration = info.get<int32_t> ("duration");
|
||||
if (duration != (uint)-1) {
|
||||
QString dur;
|
||||
dur.sprintf ("%02d:%02d", duration/60000, (duration/1000)%60);
|
||||
i->setDuration (dur);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
update ();
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::playlistList (const Xmms::List< unsigned int > &list)
|
||||
{
|
||||
for (list.first (); list.isValid (); ++list) {
|
||||
if (m_itemmap->contains (*list)) {
|
||||
addItem (m_itemmap->value (*list));
|
||||
} else {
|
||||
new PlaylistItem (this, *list);
|
||||
}
|
||||
}
|
||||
|
||||
update ();
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::mouseDoubleClickEvent (QMouseEvent *event)
|
||||
{
|
||||
if (m_items->count() < 1 || m_selected->count() < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlaylistItem *it = m_items->value (m_selected->first());
|
||||
if (!it) {
|
||||
return;
|
||||
}
|
||||
|
||||
XMMSHandler &xmmsh = XMMSHandler::getInstance ();
|
||||
xmmsh.requestTrackChange (m_items->indexOf(it));
|
||||
if (m_status == XMMS_PLAYBACK_STATUS_STOP ||
|
||||
m_status == XMMS_PLAYBACK_STATUS_PAUSE)
|
||||
{
|
||||
xmmsh.play ();
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap
|
||||
PlaylistList::generatePixmap (int i)
|
||||
{
|
||||
QStyleOptionHeader opt;
|
||||
QString t (m_items->value(i)->text());
|
||||
|
||||
QPixmap p (m_fontmetrics->width(t), getFontH());
|
||||
|
||||
QPainter paint;
|
||||
paint.begin (&p);
|
||||
paint.setFont (*m_font);
|
||||
paint.setPen (QPen (m_color_normal));
|
||||
paint.fillRect (p.rect(), QBrush (m_color_normal_bg));
|
||||
paint.drawText (p.rect(), Qt::TextSingleLine, t);
|
||||
paint.end ();
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::showMenu (void)
|
||||
{
|
||||
QMenu qm(this);
|
||||
|
||||
QAction *a;
|
||||
|
||||
a = new QAction (tr ("Show file info"), this);
|
||||
a->setShortcut (tr ("Ctrl+Enter"));
|
||||
/*
|
||||
connect (a, SIGNAL (triggered ()), this, SLOT (showMlib ()));
|
||||
*/
|
||||
qm.addAction (a);
|
||||
qm.addSeparator ();
|
||||
|
||||
a = new QAction (tr ("Add file"), this);
|
||||
a->setShortcut (tr ("Ctrl+F"));
|
||||
qm.addAction (a);
|
||||
|
||||
a = new QAction (tr ("Remove selected"), this);
|
||||
qm.addAction (a);
|
||||
|
||||
qm.addSeparator ();
|
||||
|
||||
a = new QAction (tr ("Medialib browser"), this);
|
||||
qm.addAction (a);
|
||||
|
||||
qm.exec (QCursor::pos ());
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::mousePressEvent (QMouseEvent *event)
|
||||
{
|
||||
if (m_items->count() < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
int i = ((event->pos().y()+m_offset) / getFontH());
|
||||
|
||||
if (i < 0) {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
if (i > (m_items->count () - 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->button () == Qt::LeftButton) {
|
||||
if (event->modifiers() & Qt::ShiftModifier) {
|
||||
if (m_selected->count () > 0) {
|
||||
int o = m_selected->last ();
|
||||
if (o < i) {
|
||||
for (int y = o+1; y <= i; y++) {
|
||||
m_selected->append (y);
|
||||
}
|
||||
} else {
|
||||
for (int y = i; y < o; y++) {
|
||||
m_selected->append (y);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m_selected->append (i);
|
||||
}
|
||||
} else if (event->modifiers () & Qt::ControlModifier) {
|
||||
if (m_selected->contains (i)) {
|
||||
m_selected->removeAll (i);
|
||||
} else {
|
||||
m_selected->append (i);
|
||||
}
|
||||
} else {
|
||||
if (m_selected->contains (i)) {
|
||||
m_selected->clear();
|
||||
} else {
|
||||
m_selected->clear();
|
||||
m_selected->append(i);
|
||||
}
|
||||
|
||||
m_dragstart = event->pos ();
|
||||
}
|
||||
} else if (event->button () == Qt::RightButton) {
|
||||
showMenu ();
|
||||
}
|
||||
|
||||
update ();
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::mouseMoveEvent (QMouseEvent *event)
|
||||
{
|
||||
|
||||
if (!(event->buttons() & Qt::LeftButton))
|
||||
return;
|
||||
if ((event->pos() - m_dragstart).manhattanLength() < QApplication::startDragDistance())
|
||||
return;
|
||||
|
||||
if (m_selected->count() > 0) {
|
||||
int i = m_selected->last ();
|
||||
|
||||
m_drag = new QDrag (this);
|
||||
|
||||
m_md = new QMimeData();
|
||||
QByteArray encodedData;
|
||||
|
||||
QDataStream stream (&encodedData, QIODevice::WriteOnly);
|
||||
stream << QString::number (m_selected->last ());
|
||||
|
||||
m_md->setData("application/playlist.move", encodedData);
|
||||
|
||||
m_drag->setMimeData (m_md);
|
||||
|
||||
m_drag_id = m_items->value (i)->getID ();
|
||||
m_pos = i;
|
||||
|
||||
QPixmap p = generatePixmap (i);
|
||||
|
||||
m_drag->setPixmap (p);
|
||||
m_items->removeAt (i);
|
||||
m_selected->clear ();
|
||||
|
||||
m_drag->start ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::dragEnterEvent (QDragEnterEvent *event)
|
||||
{
|
||||
|
||||
if (event->mimeData()->hasFormat("application/mlib.album") ||
|
||||
event->mimeData()->hasFormat("application/mlib.artist") ||
|
||||
event->mimeData()->hasFormat("application/mlib.song") ||
|
||||
event->mimeData()->hasFormat("application/playlist.move"))
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::dragMoveEvent (QDragMoveEvent *event)
|
||||
{
|
||||
int i = ((event->pos().y()+m_offset) / getFontH());
|
||||
if (event->pos().y() < getFontH() / 2) {
|
||||
m_bar = -1;
|
||||
} else if (i >= m_items->count ()) {
|
||||
m_bar = m_items->count ()-1;
|
||||
} else {
|
||||
m_bar = i;
|
||||
}
|
||||
update ();
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::dragLeaveEvent (QDragLeaveEvent *event)
|
||||
{
|
||||
m_bar = -2;
|
||||
update ();
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::dropEvent (QDropEvent *event)
|
||||
{
|
||||
XMMSHandler &xmmsh = XMMSHandler::getInstance ();
|
||||
|
||||
if (event->mimeData()->hasFormat("application/playlist.move")) {
|
||||
if (m_bar == -2) {
|
||||
m_items->insert (m_pos, m_itemmap->value (m_drag_id));
|
||||
} else {
|
||||
m_items->insert (m_bar + 1, m_itemmap->value (m_drag_id));
|
||||
xmmsh.playlistMove (m_pos, m_bar + 1);
|
||||
}
|
||||
m_selected->append (m_drag_id);
|
||||
|
||||
event->acceptProposedAction ();
|
||||
}
|
||||
/*
|
||||
} else if (event->mimeData()->hasFormat("application/mlib.album")) {
|
||||
const QMimeData *md = event->mimeData ();
|
||||
QByteArray encodedData = md->data("application/mlib.album");
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
|
||||
QString artist;
|
||||
QString album;
|
||||
stream >> artist;
|
||||
stream >> album;
|
||||
|
||||
QString query;
|
||||
if (artist == "Various Artists") {
|
||||
query.sprintf ("select m1.id as id, ifnull(m3.value,-1) as tracknr from Media m1 join Media m2 on m1.id = m2.id and m2.key='compilation' left join Media m3 on m1.id = m3.id and m3.key='tracknr' where m1.key='album' and m1.value='%s' and m2.value=1 order by tracknr", album.toUtf8 ().data ());
|
||||
} else {
|
||||
query.sprintf ("select m1.id as id, ifnull(m3.value,-1) as tracknr from Media m1 join Media m2 on m1.id = m2.id and m2.key='album' left join Media m3 on m1.id = m3.id and m3.key='tracknr' where m1.key='artist' and m1.value='%s' and m2.value='%s' order by tracknr", artist.toUtf8 ().data (), album.toUtf8 ().data ());
|
||||
}
|
||||
|
||||
xmmsh->medialibQueryAdd (query);
|
||||
|
||||
event->acceptProposedAction ();
|
||||
} else if (event->mimeData()->hasFormat("application/mlib.artist")) {
|
||||
const QMimeData *md = event->mimeData ();
|
||||
QByteArray encodedData = md->data("application/mlib.artist");
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
|
||||
QString artist;
|
||||
stream >> artist;
|
||||
|
||||
QString query;
|
||||
if (artist == "Various Artists") {
|
||||
query.sprintf ("select m1.id as id, m2.value as album, ifnull(m3.value,-1) as tracknr from Media m1 left join Media m2 on m1.id = m2.id and m2.key='album' left join Media m3 on m1.id = m3.id and m3.key='tracknr' where m1.key='compilation' and m1.value=1 order by album, tracknr;");
|
||||
} else {
|
||||
query.sprintf ("select m1.id as id, m2.value as album, ifnull(m3.value,-1) as tracknr from Media m1 left join Media m2 on m1.id = m2.id and m2.key='album' left join Media m3 on m1.id = m3.id and m3.key='tracknr' where m1.key='artist' and m1.value='%s' order by album, tracknr", artist.toUtf8 ().data ());
|
||||
}
|
||||
|
||||
xmmsh->medialibQueryAdd (query);
|
||||
event->acceptProposedAction ();
|
||||
} else if (event->mimeData()->hasFormat("application/mlib.song")) {
|
||||
const QMimeData *md = event->mimeData ();
|
||||
QByteArray encodedData = md->data("application/mlib.song");
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
|
||||
QString artist;
|
||||
QString album;
|
||||
QString song;
|
||||
stream >> artist;
|
||||
stream >> album;
|
||||
stream >> song;
|
||||
|
||||
QString query;
|
||||
query.sprintf ("select m1.id as id, ifnull(m1.value, '[unknown]') as artist, ifnull(m2.value,'[unknown]') as album, ifnull(m4.value,m5.value) as song from Media m1 left join Media m2 on m1.id = m2.id and m2.key='album' left join Media m4 on m1.id = m4.id and m4.key='title' left join Media m5 on m1.id = m5.id and m5.key='url' where m1.key='artist' and artist='%s' and album='%s' and song='%s'", artist.toUtf8 ().data (), album.toUtf8 ().data (), song.toUtf8 ().data ());
|
||||
|
||||
xmmsh->medialibQueryAdd (query);
|
||||
|
||||
event->acceptProposedAction ();
|
||||
}
|
||||
m_bar = -2;
|
||||
update ();
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::keyPressEvent (QKeyEvent *event)
|
||||
{
|
||||
|
||||
QWidget *w = dynamic_cast<QWidget*>(parent());
|
||||
QSize s = w->size ();
|
||||
int lastitem = (m_offset + s.height()) / getFontH () - 1;
|
||||
if (lastitem > m_items->count())
|
||||
lastitem = m_items->count() - 1;
|
||||
int firstitem = m_offset / getFontH();
|
||||
|
||||
switch (event->key ()) {
|
||||
case Qt::Key_Down:
|
||||
{
|
||||
int i = m_selected->last ();
|
||||
i ++;
|
||||
|
||||
if (i > (m_items->count () - 1))
|
||||
i = m_items->count () - 1;
|
||||
|
||||
m_selected->clear ();
|
||||
m_selected->append (i);
|
||||
|
||||
if (i > lastitem)
|
||||
setOffset (m_offset += getFontH ());
|
||||
|
||||
update ();
|
||||
emit sizeChanged (size());
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Up:
|
||||
{
|
||||
int i = m_selected->last ();
|
||||
i --;
|
||||
if (i < 0)
|
||||
i = 0;
|
||||
m_selected->clear ();
|
||||
m_selected->append (i);
|
||||
if (i < firstitem)
|
||||
setOffset (m_offset -= getFontH ());
|
||||
|
||||
update ();
|
||||
emit sizeChanged (size());
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Backspace:
|
||||
case Qt::Key_Delete:
|
||||
{
|
||||
deleteFiles ();
|
||||
}
|
||||
break;
|
||||
case Qt::Key_A:
|
||||
{
|
||||
if (event->modifiers() == Qt::ControlModifier) {
|
||||
m_selected->clear ();
|
||||
for (int i = 0; i < m_items->count (); i ++) {
|
||||
m_selected->append (i);
|
||||
}
|
||||
update ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::deleteFiles ()
|
||||
{
|
||||
XMMSHandler &xmmsh = XMMSHandler::getInstance ();
|
||||
|
||||
//Sort list and remove in reverse order
|
||||
qSort (*m_selected);
|
||||
for (int i = (m_selected->count () - 1); i >= 0; i --) {
|
||||
xmmsh.playlistRemove (m_selected->value (i));
|
||||
}
|
||||
m_selected->clear ();
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::paintEvent (QPaintEvent *event)
|
||||
{
|
||||
int i;
|
||||
QPainter paint;
|
||||
paint.begin (this);
|
||||
paint.setFont (*m_font);
|
||||
/*
|
||||
paint.setClipping (false);
|
||||
*/
|
||||
paint.setPen (QPen (m_color_normal));
|
||||
|
||||
int cy = event->rect().y () + m_offset;
|
||||
int ch = event->rect().height();
|
||||
int sitem = cy / getFontH();
|
||||
int eitem = (cy + ch) / getFontH();
|
||||
int mod = m_offset - (getFontH() * sitem);
|
||||
|
||||
if (eitem > m_items->count())
|
||||
eitem = m_items->count();
|
||||
|
||||
QString q;
|
||||
QRect fullLine;
|
||||
QRect textLine;
|
||||
QRect numLine;
|
||||
|
||||
for (i = sitem; i < eitem; i++) {
|
||||
PlaylistItem *item = m_items->value (i);
|
||||
|
||||
int tw = m_fontmetrics->width(item->duration ())+2;
|
||||
|
||||
fullLine.setRect(0, (getFontH()*(i-sitem)) - mod,
|
||||
size().width(), getFontH());
|
||||
textLine.setRect(0, (getFontH()*(i-sitem)) - mod,
|
||||
size().width()-tw-4, getFontH());
|
||||
numLine.setRect(size().width()-tw, (getFontH()*(i-sitem)) - mod,
|
||||
tw, getFontH());
|
||||
|
||||
q = QString::number (i + 1) + ". " + item->text ();
|
||||
|
||||
if (m_selected->contains (i)) {
|
||||
paint.fillRect (fullLine, QBrush (m_color_selected));
|
||||
} else {
|
||||
paint.eraseRect (fullLine);
|
||||
}
|
||||
|
||||
if (m_active == i) {
|
||||
paint.setPen (QPen (m_color_active));
|
||||
paint.drawText (textLine, Qt::TextSingleLine, q);
|
||||
paint.drawText (numLine, item->duration ());
|
||||
paint.setPen (QPen (m_color_normal));
|
||||
} else {
|
||||
paint.drawText (textLine, Qt::TextSingleLine, q);
|
||||
paint.drawText (numLine, item->duration ());
|
||||
}
|
||||
|
||||
if (m_bar == -1) {
|
||||
paint.save ();
|
||||
QPen pen (m_color_active);
|
||||
pen.setWidth (2);
|
||||
paint.setPen (pen);
|
||||
paint.drawLine (2, 0, size().width()-2, 0);
|
||||
paint.restore ();
|
||||
} else if (m_bar == i) {
|
||||
paint.save ();
|
||||
QPen pen (m_color_active);
|
||||
pen.setWidth (5);
|
||||
paint.setPen (pen);
|
||||
paint.drawLine (2, fullLine.y()+getFontH(), size().width()-2,
|
||||
fullLine.y()+getFontH());
|
||||
paint.restore ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ((getFontH()*(i-sitem) - mod) < size().height()) {
|
||||
paint.eraseRect (QRect (0, (getFontH()*(i-sitem) - mod),
|
||||
size().width(),
|
||||
size().height()-(getFontH()*(i-sitem) - mod)));
|
||||
}
|
||||
|
||||
paint.end ();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::doResize (void)
|
||||
{
|
||||
QWidget *w = dynamic_cast<QWidget*>(parent());
|
||||
QSize s = w->size ();
|
||||
|
||||
if (m_items->count()*getFontH () > s.height ()) {
|
||||
resize (size().width(), m_items->count ()*getFontH ());
|
||||
} else {
|
||||
resize (size().width(), s.height());
|
||||
setOffset (0);
|
||||
}
|
||||
emit sizeChanged (size());
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::addItem (PlaylistItem *i, uint pos)
|
||||
{
|
||||
m_items->insert (pos, i);
|
||||
if (!m_itemmap->contains (i->getID())) {
|
||||
m_itemmap->insert (i->getID(), i);
|
||||
}
|
||||
doResize ();
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::addItem (PlaylistItem *i)
|
||||
{
|
||||
m_items->append (i);
|
||||
if (!m_itemmap->contains (i->getID())) {
|
||||
m_itemmap->insert (i->getID(), i);
|
||||
}
|
||||
doResize ();
|
||||
}
|
||||
|
||||
int
|
||||
PlaylistList::getFontH (void)
|
||||
{
|
||||
if (!m_fontmetrics) {
|
||||
return 0;
|
||||
}
|
||||
return m_fontmetrics->height();
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::setPixmaps (Skin *skin)
|
||||
{
|
||||
QSettings s;
|
||||
QPalette pal;
|
||||
QColor c;
|
||||
c.setNamedColor (skin->getPLeditValue ("normalbg"));
|
||||
QBrush b (c);
|
||||
pal.setBrush (QPalette::Window, b);
|
||||
setPalette (pal);
|
||||
|
||||
if (m_font) {
|
||||
delete m_font;
|
||||
}
|
||||
m_font = new QFont (skin->getPLeditValue ("font"));
|
||||
m_font->setPixelSize (s.value ("playlist/fontsize").toInt ());
|
||||
|
||||
if (m_fontmetrics) {
|
||||
delete m_fontmetrics;
|
||||
}
|
||||
m_fontmetrics = new QFontMetrics (*m_font);
|
||||
|
||||
m_color_active.setNamedColor (skin->getPLeditValue ("current"));
|
||||
m_color_selected.setNamedColor (skin->getPLeditValue ("selectedbg"));
|
||||
m_color_normal.setNamedColor (skin->getPLeditValue ("normal"));
|
||||
m_color_normal_bg.setNamedColor (skin->getPLeditValue ("normalbg"));
|
||||
|
||||
update ();
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistList::setSize (int width, int height)
|
||||
{
|
||||
int nx, ny;
|
||||
nx = width;
|
||||
|
||||
if (height > size().height()) {
|
||||
ny = height;
|
||||
} else {
|
||||
ny = size().height();
|
||||
}
|
||||
|
||||
resize (nx, ny);
|
||||
}
|
||||
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
#ifndef __PLAYLISTLIST_H__
|
||||
#define __PLAYLISTLIST_H__
|
||||
|
||||
#include <xmmsclient/xmmsclient++.h>
|
||||
#include "Skin.h"
|
||||
#include <QWidget>
|
||||
#include <QHash>
|
||||
|
||||
#include <QDrag>
|
||||
|
||||
class PlaylistItem;
|
||||
|
||||
class PlaylistView : public QWidget {
|
||||
public:
|
||||
PlaylistView (QWidget *parent) : QWidget (parent) {}
|
||||
~PlaylistView () {}
|
||||
};
|
||||
|
||||
class PlaylistList : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PlaylistList (QWidget *parent);
|
||||
~PlaylistList () {}
|
||||
|
||||
void setSize (int, int);
|
||||
void addItem (PlaylistItem *i);
|
||||
void addItem (PlaylistItem *i, uint pos);
|
||||
void setOffset (int i) { m_offset = i; }
|
||||
uint getOffset (void) const { return m_offset; }
|
||||
void doResize (void);
|
||||
|
||||
public slots:
|
||||
void setPixmaps (Skin *skin);
|
||||
void playlistList (const Xmms::List< unsigned int > &);
|
||||
void mediainfoChanged (uint, const Xmms::PropDict &);
|
||||
void playlistChanged (const Xmms::Dict &);
|
||||
void currentID (uint);
|
||||
void setStatus (Xmms::Playback::Status s);
|
||||
void settingsSaved ();
|
||||
void deleteFiles ();
|
||||
|
||||
signals:
|
||||
void sizeChanged (QSize);
|
||||
|
||||
private:
|
||||
void showMenu (void);
|
||||
void paintEvent (QPaintEvent *event);
|
||||
void mousePressEvent (QMouseEvent *event);
|
||||
void mouseMoveEvent (QMouseEvent *event);
|
||||
void mouseDoubleClickEvent (QMouseEvent *event);
|
||||
void keyPressEvent (QKeyEvent *event);
|
||||
|
||||
void dragMoveEvent (QDragMoveEvent *event);
|
||||
void dragEnterEvent (QDragEnterEvent *event);
|
||||
void dragLeaveEvent (QDragLeaveEvent *event);
|
||||
void dropEvent (QDropEvent *event);
|
||||
|
||||
QPixmap generatePixmap (int);
|
||||
|
||||
QList<PlaylistItem*> *m_items;
|
||||
QList<uint> *m_selected;
|
||||
QHash<uint,PlaylistItem*> *m_itemmap;
|
||||
|
||||
QFont *m_font;
|
||||
QFontMetrics *m_fontmetrics;
|
||||
QColor m_color_active;
|
||||
QColor m_color_selected;
|
||||
QColor m_color_normal;
|
||||
QColor m_color_normal_bg;
|
||||
|
||||
int getFontH (void);
|
||||
int m_offset;
|
||||
int m_active;
|
||||
int m_bar;
|
||||
int m_drag_id;
|
||||
int m_pos;
|
||||
QPoint m_dragstart;
|
||||
Xmms::Playback::Status m_status;
|
||||
|
||||
QDrag *m_drag;
|
||||
QMimeData *m_md;
|
||||
};
|
||||
|
||||
class PlaylistItem {
|
||||
public:
|
||||
PlaylistItem (PlaylistList *pl, uint, uint);
|
||||
PlaylistItem (PlaylistList *pl, uint);
|
||||
~PlaylistItem () {}
|
||||
|
||||
QString text (void);
|
||||
QString duration (void) { return m_duration; }
|
||||
|
||||
uint getID (void) { return m_id; }
|
||||
void setDuration (QString s) { m_duration = s; }
|
||||
void setText (QString s) { m_text = s; }
|
||||
|
||||
private:
|
||||
uint m_id;
|
||||
PlaylistList *m_pl;
|
||||
|
||||
bool m_req;
|
||||
QString m_text;
|
||||
QString m_duration;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -1,348 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 1992-2006 Trolltech AS. All rights reserved.
|
||||
**
|
||||
** This file is part of the qmake application of the Qt Toolkit.
|
||||
**
|
||||
** This file may be used under the terms of the GNU General Public
|
||||
** License version 2.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of
|
||||
** this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
** http://www.trolltech.com/products/qt/opensource.html
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** review the following information:
|
||||
** http://www.trolltech.com/products/qt/licensing.html or contact the
|
||||
** sales department at sales@trolltech.com.
|
||||
**
|
||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
rights reserved.
|
||||
|
||||
RSA Data Security, Inc. makes no representations concerning either
|
||||
the merchantability of this software or the suitability of this
|
||||
software for any particular purpose. It is provided "as is"
|
||||
without express or implied warranty of any kind.
|
||||
|
||||
License to copy and use this software is granted provided that it
|
||||
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
||||
Algorithm" in all material mentioning or referencing this software
|
||||
or this function.
|
||||
|
||||
License is also granted to make and use derivative works provided
|
||||
that such works are identified as "derived from the RSA Data
|
||||
Security, Inc. MD5 Message-Digest Algorithm" in all material
|
||||
mentioning or referencing the derived work.
|
||||
|
||||
These notices must be retained in any copies of any part of this
|
||||
documentation and/or software.
|
||||
*/
|
||||
|
||||
#include "qtmd5.h"
|
||||
|
||||
typedef unsigned char *POINTER;
|
||||
typedef unsigned short int UINT2;
|
||||
typedef unsigned long int UINT4;
|
||||
|
||||
typedef struct {
|
||||
UINT4 state[4]; // state(ABCD)
|
||||
UINT4 count[2]; // number of bits, modulo 2^64(lsb first)
|
||||
unsigned char buffer[64]; // input buffer
|
||||
} MD5_CTX;
|
||||
|
||||
static void MD5Init(MD5_CTX *);
|
||||
static void MD5Update(MD5_CTX *, unsigned char *, unsigned int);
|
||||
static void MD5Final(unsigned char [16], MD5_CTX *);
|
||||
static void MD5Transform(UINT4[4], unsigned char[64]);
|
||||
static void Encode(unsigned char *, UINT4 *, unsigned int);
|
||||
static void Decode(UINT4 *, unsigned char *, unsigned int);
|
||||
static void MD5_memset(POINTER, int, unsigned int);
|
||||
static void MD5_memcpy(POINTER output,POINTER input,unsigned int len);
|
||||
|
||||
// Constants for MD5Transform routine.
|
||||
enum {
|
||||
S11 = 7, S12 = 12, S13 = 17, S14 = 22, S21 = 5, S22 = 9, S23 = 14, S24 = 20,
|
||||
S31 = 4, S32 = 11, S33 = 16, S34 = 23, S41 = 6, S42 = 10, S43 = 15, S44 = 21
|
||||
};
|
||||
|
||||
static unsigned char PADDING[64] = {
|
||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
// F, G, H and I are basic MD5 functions.
|
||||
static inline UINT4 F(UINT4 x, UINT4 y, UINT4 z)
|
||||
{
|
||||
return (x & y) |((~x) & z);
|
||||
}
|
||||
|
||||
static inline UINT4 G(UINT4 x, UINT4 y, UINT4 z)
|
||||
{
|
||||
return (x & z) |(y &(~z));
|
||||
}
|
||||
|
||||
static inline UINT4 H(UINT4 x, UINT4 y, UINT4 z)
|
||||
{
|
||||
return x ^ y ^ z;
|
||||
}
|
||||
|
||||
static inline UINT4 I(UINT4 x, UINT4 y, UINT4 z)
|
||||
{
|
||||
return y ^(x |(~z));
|
||||
}
|
||||
|
||||
static inline UINT4 rotateLeft(UINT4 x, UINT4 n)
|
||||
{
|
||||
return (x << n) |(x >>(32-(n)));
|
||||
}
|
||||
|
||||
// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
|
||||
// Rotation is separate from addition to prevent recomputation.
|
||||
static inline void FF(UINT4 &a, UINT4 b, UINT4 c, UINT4 d, UINT4 x, UINT4 s, UINT4 ac)
|
||||
{
|
||||
a += F(b, c, d) + x + ac;
|
||||
a = rotateLeft(a, s);
|
||||
a += b;
|
||||
}
|
||||
|
||||
static inline void GG(UINT4 &a, UINT4 b, UINT4 c, UINT4 d, UINT4 x, UINT4 s, UINT4 ac)
|
||||
{
|
||||
a += G(b, c, d) + x +(UINT4)(ac);
|
||||
a = rotateLeft(a, s);
|
||||
a += b;
|
||||
}
|
||||
|
||||
static inline void HH(UINT4 &a, UINT4 b, UINT4 c, UINT4 d, UINT4 x, UINT4 s, UINT4 ac)
|
||||
{
|
||||
a += H(b, c, d) + x +(UINT4)(ac);
|
||||
a = rotateLeft(a, s);
|
||||
a += b;
|
||||
}
|
||||
|
||||
static inline void II(UINT4 &a, UINT4 b, UINT4 c, UINT4 d, UINT4 x, UINT4 s, UINT4 ac)
|
||||
{
|
||||
a += I(b, c, d) + x +(UINT4)(ac);
|
||||
a = rotateLeft(a, s);
|
||||
a += b;
|
||||
}
|
||||
|
||||
// MD5 initialization. Begins an MD5 operation, writing a new context.
|
||||
static void MD5Init(MD5_CTX *context)
|
||||
{
|
||||
context->count[0] = context->count[1] = 0;
|
||||
|
||||
// Load magic initialization constants.
|
||||
context->state[0] = 0x67452301;
|
||||
context->state[1] = 0xefcdab89;
|
||||
context->state[2] = 0x98badcfe;
|
||||
context->state[3] = 0x10325476;
|
||||
}
|
||||
|
||||
// MD5 block update operation. Continues an MD5 message-digest
|
||||
// operation, processing another message block, and updating the
|
||||
// context.
|
||||
static void MD5Update(MD5_CTX *context, unsigned char *input, unsigned int inputLen)
|
||||
{
|
||||
unsigned int i, index, partLen;
|
||||
// Compute number of bytes mod 64
|
||||
index =(unsigned int)((context->count[0] >> 3) & 0x3F);
|
||||
|
||||
// Update number of bits
|
||||
if ((context->count[0] +=((UINT4)inputLen << 3)) <((UINT4)inputLen << 3))
|
||||
context->count[1]++;
|
||||
|
||||
context->count[1] +=((UINT4)inputLen >> 29);
|
||||
partLen = 64 - index;
|
||||
|
||||
// Transform as many times as possible.
|
||||
if (inputLen >= partLen) {
|
||||
MD5_memcpy((POINTER)&context->buffer[index],(POINTER)input, partLen);
|
||||
MD5Transform(context->state, context->buffer);
|
||||
for (i = partLen; i + 63 < inputLen; i += 64)
|
||||
MD5Transform(context->state, &input[i]);
|
||||
index = 0;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
// Buffer remaining input
|
||||
MD5_memcpy((POINTER)&context->buffer[index],(POINTER)&input[i],
|
||||
inputLen-i);
|
||||
}
|
||||
|
||||
// MD5 finalization. Ends an MD5 message-digest operation, writing the
|
||||
// the message digest and zeroizing the context.
|
||||
static void MD5Final(unsigned char digest[16], MD5_CTX *context)
|
||||
{
|
||||
unsigned char bits[8];
|
||||
unsigned int index, padLen;
|
||||
|
||||
// Save number of bits
|
||||
Encode(bits, context->count, 8);
|
||||
|
||||
// Pad out to 56 mod 64.
|
||||
index =(unsigned int)((context->count[0] >> 3) & 0x3f);
|
||||
padLen =(index < 56) ?(56 - index) :(120 - index);
|
||||
MD5Update(context, PADDING, padLen);
|
||||
|
||||
// Append length(before padding)
|
||||
MD5Update(context, bits, 8);
|
||||
|
||||
// Store state in digest
|
||||
Encode(digest, context->state, 16);
|
||||
|
||||
// Zeroize sensitive information.
|
||||
MD5_memset((POINTER)context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
// MD5 basic transformation. Transforms state based on block.
|
||||
static void MD5Transform(UINT4 state[4], unsigned char block[64])
|
||||
{
|
||||
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
|
||||
Decode(x, block, 64);
|
||||
|
||||
// Round 1
|
||||
FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */
|
||||
FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */
|
||||
FF(c, d, a, b, x[2], S13, 0x242070db); /* 3 */
|
||||
FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */
|
||||
FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */
|
||||
FF(d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */
|
||||
FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */
|
||||
FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */
|
||||
FF(a, b, c, d, x[8], S11, 0x698098d8); /* 9 */
|
||||
FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */
|
||||
FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
|
||||
FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
|
||||
FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
|
||||
FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
|
||||
FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
|
||||
FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
|
||||
|
||||
// Round 2
|
||||
GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */
|
||||
GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */
|
||||
GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
|
||||
GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */
|
||||
GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */
|
||||
GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */
|
||||
GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
|
||||
GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */
|
||||
GG(a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */
|
||||
GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
|
||||
GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */
|
||||
GG(b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */
|
||||
GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
|
||||
GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */
|
||||
GG(c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */
|
||||
GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
|
||||
|
||||
// Round 3
|
||||
HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */
|
||||
HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */
|
||||
HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
|
||||
HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
|
||||
HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */
|
||||
HH(d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */
|
||||
HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */
|
||||
HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
|
||||
HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
|
||||
HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */
|
||||
HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */
|
||||
HH(b, c, d, a, x[6], S34, 0x4881d05); /* 44 */
|
||||
HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */
|
||||
HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
|
||||
HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
|
||||
HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */
|
||||
|
||||
// Round 4
|
||||
II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */
|
||||
II(d, a, b, c, x[7], S42, 0x432aff97); /* 50 */
|
||||
II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
|
||||
II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */
|
||||
II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
|
||||
II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */
|
||||
II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
|
||||
II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */
|
||||
II(a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */
|
||||
II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
|
||||
II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */
|
||||
II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
|
||||
II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */
|
||||
II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
|
||||
II(c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */
|
||||
II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
|
||||
// Zeroize sensitive information.
|
||||
MD5_memset((POINTER)x, 0, sizeof(x));
|
||||
}
|
||||
|
||||
// Encodes input(UINT4) into output(unsigned char). Assumes len is a
|
||||
// multiple of 4.
|
||||
static void Encode(unsigned char *output, UINT4 *input, unsigned int len)
|
||||
{
|
||||
unsigned int i, j;
|
||||
for (i = 0, j = 0; j < len; i++, j += 4) {
|
||||
output[j] = (unsigned char) (input[i] & 0xff);
|
||||
output[j+1] = (unsigned char) ((input[i] >> 8) & 0xff);
|
||||
output[j+2] = (unsigned char) ((input[i] >> 16) & 0xff);
|
||||
output[j+3] = (unsigned char) ((input[i] >> 24) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
// Decodes input(unsigned char) into output(UINT4). Assumes len is a
|
||||
// multiple of 4.
|
||||
static void Decode(UINT4 *output, unsigned char *input, unsigned int len)
|
||||
{
|
||||
unsigned int i, j;
|
||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
||||
output[i] =((UINT4)input[j]) |(((UINT4)input[j+1]) << 8) |
|
||||
(((UINT4)input[j+2]) << 16) |(((UINT4)input[j+3]) << 24);
|
||||
}
|
||||
|
||||
// Note: Replace "for loop" with standard memset if possible.
|
||||
static void MD5_memset(POINTER output, int value, unsigned int len)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < len; i++)
|
||||
((char *)output)[i] =(char)value;
|
||||
}
|
||||
|
||||
// Note: Replace "for loop" with standard memcpy if possible.
|
||||
static void MD5_memcpy(POINTER output,POINTER input,unsigned int len)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < len; i++)
|
||||
output[i] = input[i];
|
||||
}
|
||||
|
||||
void qtMD5(const QByteArray &src, unsigned char *digest)
|
||||
{
|
||||
MD5_CTX context;
|
||||
|
||||
MD5Init(&context);
|
||||
MD5Update(&context, (unsigned char *) src.data(), src.size());
|
||||
MD5Final(digest, &context);
|
||||
}
|
||||
|
||||
QString qtMD5(const QByteArray &src)
|
||||
{
|
||||
unsigned char digest[16];
|
||||
qtMD5(src, digest);
|
||||
|
||||
QString output, tmp;
|
||||
for (int i = 0; i < 16; ++i)
|
||||
output += tmp.sprintf("%02x", digest[i]);
|
||||
return output;
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 1992-2006 Trolltech AS. All rights reserved.
|
||||
**
|
||||
** This file is part of the qmake application of the Qt Toolkit.
|
||||
**
|
||||
** This file may be used under the terms of the GNU General Public
|
||||
** License version 2.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of
|
||||
** this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
** http://www.trolltech.com/products/qt/opensource.html
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** review the following information:
|
||||
** http://www.trolltech.com/products/qt/licensing.html or contact the
|
||||
** sales department at sales@trolltech.com.
|
||||
**
|
||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
rights reserved.
|
||||
|
||||
RSA Data Security, Inc. makes no representations concerning either
|
||||
the merchantability of this software or the suitability of this
|
||||
software for any particular purpose. It is provided "as is"
|
||||
without express or implied warranty of any kind.
|
||||
|
||||
License to copy and use this software is granted provided that it
|
||||
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
||||
Algorithm" in all material mentioning or referencing this software
|
||||
or this function.
|
||||
|
||||
License is also granted to make and use derivative works provided
|
||||
that such works are identified as "derived from the RSA Data
|
||||
Security, Inc. MD5 Message-Digest Algorithm" in all material
|
||||
mentioning or referencing the derived work.
|
||||
|
||||
These notices must be retained in any copies of any part of this
|
||||
documentation and/or software.
|
||||
*/
|
||||
|
||||
#ifndef QTMD5_H
|
||||
#define QTMD5_H
|
||||
|
||||
#include <qstring.h>
|
||||
#include <qbytearray.h>
|
||||
|
||||
void qtMD5(const QByteArray &src, unsigned char *digest);
|
||||
QString qtMD5(const QByteArray &src);
|
||||
|
||||
#endif // QTMD5_H
|
|
@ -1,66 +0,0 @@
|
|||
#ifndef XMMSCLIENTPP_METHODS_H
|
||||
#define XMMSCLIENTPP_METHODS_H
|
||||
XMMSResult *quit (void) { return new XMMSResult (xmmsc_quit (m_xmmsc)); }
|
||||
XMMSResult *plugin_list (uint32_t x) { return new XMMSResult (xmmsc_plugin_list (m_xmmsc, x)); }
|
||||
XMMSResult *main_stats (void) { return new XMMSResult (xmmsc_main_stats (m_xmmsc)); }
|
||||
XMMSResult *broadcast_quit (void) { return new XMMSResult (xmmsc_broadcast_quit (m_xmmsc)); }
|
||||
XMMSResult *playlist_shuffle (void) { return new XMMSResult (xmmsc_playlist_shuffle (m_xmmsc)); }
|
||||
XMMSResult *playlist_add (const char * x) { return new XMMSResult (xmmsc_playlist_add (m_xmmsc, x)); }
|
||||
XMMSResult *playlist_add_id (uint32_t x) { return new XMMSResult (xmmsc_playlist_add_id (m_xmmsc, x)); }
|
||||
XMMSResult *playlist_remove (uint32_t x) { return new XMMSResult (xmmsc_playlist_remove (m_xmmsc, x)); }
|
||||
XMMSResult *playlist_clear (void) { return new XMMSResult (xmmsc_playlist_clear (m_xmmsc)); }
|
||||
XMMSResultValueList<uint> *playlist_list (void) { return new XMMSResultValueList<uint> (xmmsc_playlist_list (m_xmmsc)); }
|
||||
XMMSResult *playlist_sort (char* x) { return new XMMSResult (xmmsc_playlist_sort (m_xmmsc, x)); }
|
||||
XMMSResult *playlist_set_next (uint32_t x) { return new XMMSResult (xmmsc_playlist_set_next (m_xmmsc, x)); }
|
||||
XMMSResult *playlist_set_next_rel (int32_t x) { return new XMMSResult (xmmsc_playlist_set_next_rel (m_xmmsc, x)); }
|
||||
XMMSResult *playlist_move (uint32_t x,uint32_t y) { return new XMMSResult (xmmsc_playlist_move (m_xmmsc, x, y)); }
|
||||
XMMSResultValue<uint> *playlist_current_pos (void) { return new XMMSResultValue<uint> (xmmsc_playlist_current_pos (m_xmmsc)); }
|
||||
XMMSResult *playlist_insert (int x,char * y) { return new XMMSResult (xmmsc_playlist_insert (m_xmmsc, x, y)); }
|
||||
XMMSResult *playlist_insert_id (int x,uint32_t y) { return new XMMSResult (xmmsc_playlist_insert_id (m_xmmsc, x, y)); }
|
||||
XMMSResultDict *broadcast_playlist_changed (void) { return new XMMSResultDict (xmmsc_broadcast_playlist_changed (m_xmmsc)); }
|
||||
XMMSResultValue<uint> *broadcast_playlist_current_pos (void) { return new XMMSResultValue<uint> (xmmsc_broadcast_playlist_current_pos (m_xmmsc)); }
|
||||
XMMSResult *playback_stop (void) { return new XMMSResult (xmmsc_playback_stop (m_xmmsc)); }
|
||||
XMMSResult *playback_tickle (void) { return new XMMSResult (xmmsc_playback_tickle (m_xmmsc)); }
|
||||
XMMSResult *playback_start (void) { return new XMMSResult (xmmsc_playback_start (m_xmmsc)); }
|
||||
XMMSResult *playback_pause (void) { return new XMMSResult (xmmsc_playback_pause (m_xmmsc)); }
|
||||
XMMSResultValue<uint> *playback_current_id (void) { return new XMMSResultValue<uint> (xmmsc_playback_current_id (m_xmmsc)); }
|
||||
XMMSResult *playback_seek_ms (uint32_t x) { return new XMMSResult (xmmsc_playback_seek_ms (m_xmmsc, x)); }
|
||||
XMMSResult *playback_seek_ms_rel (int x) { return new XMMSResult (xmmsc_playback_seek_ms_rel (m_xmmsc, x)); }
|
||||
XMMSResult *playback_seek_samples (uint32_t x) { return new XMMSResult (xmmsc_playback_seek_samples (m_xmmsc, x)); }
|
||||
XMMSResult *playback_seek_samples_rel (int x) { return new XMMSResult (xmmsc_playback_seek_samples_rel (m_xmmsc, x)); }
|
||||
XMMSResultValue<uint> *playback_playtime (void) { return new XMMSResultValue<uint> (xmmsc_playback_playtime (m_xmmsc)); }
|
||||
XMMSResultValue<uint> *playback_status (void) { return new XMMSResultValue<uint> (xmmsc_playback_status (m_xmmsc)); }
|
||||
XMMSResult *playback_volume_set (const char * x,uint32_t y) { return new XMMSResult (xmmsc_playback_volume_set (m_xmmsc, x, y)); }
|
||||
XMMSResultDict *playback_volume_get (void) { return new XMMSResultDict (xmmsc_playback_volume_get (m_xmmsc)); }
|
||||
XMMSResult *broadcast_playback_volume_changed (void) { return new XMMSResult (xmmsc_broadcast_playback_volume_changed (m_xmmsc)); }
|
||||
XMMSResultValue<uint> *broadcast_playback_status (void) { return new XMMSResultValue<uint> (xmmsc_broadcast_playback_status (m_xmmsc)); }
|
||||
XMMSResultValue<uint> *broadcast_playback_current_id (void) { return new XMMSResultValue<uint> (xmmsc_broadcast_playback_current_id (m_xmmsc)); }
|
||||
XMMSResultValue<uint> *signal_playback_playtime (void) { return new XMMSResultValue<uint> (xmmsc_signal_playback_playtime (m_xmmsc)); }
|
||||
XMMSResult *configval_set (char * x,char * y) { return new XMMSResult (xmmsc_configval_set (m_xmmsc, x, y)); }
|
||||
XMMSResultValueList<char*> *configval_list (void) { return new XMMSResultValueList<char*> (xmmsc_configval_list (m_xmmsc)); }
|
||||
XMMSResultValue<char*> *configval_get (char * x) { return new XMMSResultValue<char*> (xmmsc_configval_get (m_xmmsc, x)); }
|
||||
XMMSResult *configval_register (char * x,char * y) { return new XMMSResult (xmmsc_configval_register (m_xmmsc, x, y)); }
|
||||
XMMSResultValue<char*> *broadcast_configval_changed (void) { return new XMMSResultValue<char*> (xmmsc_broadcast_configval_changed (m_xmmsc)); }
|
||||
XMMSResult *broadcast_mediainfo_reader_status (void) { return new XMMSResult (xmmsc_broadcast_mediainfo_reader_status (m_xmmsc)); }
|
||||
XMMSResult *signal_visualisation_data (void) { return new XMMSResult (xmmsc_signal_visualisation_data (m_xmmsc)); }
|
||||
XMMSResult *signal_mediainfo_reader_unindexed (void) { return new XMMSResult (xmmsc_signal_mediainfo_reader_unindexed (m_xmmsc)); }
|
||||
XMMSResultDictList *medialib_select (const char * x) { return new XMMSResultDictList (xmmsc_medialib_select (m_xmmsc, x)); }
|
||||
XMMSResult *medialib_playlist_save_current (const char * x) { return new XMMSResult (xmmsc_medialib_playlist_save_current (m_xmmsc, x)); }
|
||||
XMMSResult *medialib_playlist_load (const char * x) { return new XMMSResult (xmmsc_medialib_playlist_load (m_xmmsc, x)); }
|
||||
XMMSResult *medialib_add_entry (const char * x) { return new XMMSResult (xmmsc_medialib_add_entry (m_xmmsc, x)); }
|
||||
XMMSResultDict *medialib_get_info (uint32_t x) { return new XMMSResultDict (xmmsc_medialib_get_info (m_xmmsc, x)); }
|
||||
XMMSResult *medialib_add_to_playlist (const char * x) { return new XMMSResult (xmmsc_medialib_add_to_playlist (m_xmmsc, x)); }
|
||||
XMMSResultValueList<char*> *medialib_playlists_list (void) { return new XMMSResultValueList<char*> (xmmsc_medialib_playlists_list (m_xmmsc)); }
|
||||
XMMSResultValueList<uint> *medialib_playlist_list (const char * x) { return new XMMSResultValueList<uint> (xmmsc_medialib_playlist_list (m_xmmsc, x)); }
|
||||
XMMSResult *medialib_playlist_import (const char * x,const char * y) { return new XMMSResult (xmmsc_medialib_playlist_import (m_xmmsc, x, y)); }
|
||||
XMMSResult *medialib_playlist_export (const char * x,const char * y) { return new XMMSResult (xmmsc_medialib_playlist_export (m_xmmsc, x, y)); }
|
||||
XMMSResult *medialib_playlist_remove (const char * x) { return new XMMSResult (xmmsc_medialib_playlist_remove (m_xmmsc, x)); }
|
||||
XMMSResult *medialib_path_import (const char * x) { return new XMMSResult (xmmsc_medialib_path_import (m_xmmsc, x)); }
|
||||
XMMSResult *medialib_rehash (uint32_t x) { return new XMMSResult (xmmsc_medialib_rehash (m_xmmsc, x)); }
|
||||
XMMSResult *medialib_get_id (const char * x) { return new XMMSResult (xmmsc_medialib_get_id (m_xmmsc, x)); }
|
||||
XMMSResult *medialib_remove_entry (int32_t x) { return new XMMSResult (xmmsc_medialib_remove_entry (m_xmmsc, x)); }
|
||||
XMMSResult *medialib_entry_property_set (uint32_t x,char * y,char * z) { return new XMMSResult (xmmsc_medialib_entry_property_set (m_xmmsc, x, y, z)); }
|
||||
XMMSResult *medialib_entry_property_set_with_source (uint32_t x,char * y,char * z,char * w) { return new XMMSResult (xmmsc_medialib_entry_property_set_with_source (m_xmmsc, x, y, z, w)); }
|
||||
XMMSResultValue<uint> *broadcast_medialib_entry_changed (void) { return new XMMSResultValue<uint> (xmmsc_broadcast_medialib_entry_changed (m_xmmsc)); }
|
||||
XMMSResult *broadcast_medialib_playlist_loaded (void) { return new XMMSResult (xmmsc_broadcast_medialib_playlist_loaded (m_xmmsc)); }
|
||||
#endif
|
|
@ -1,112 +0,0 @@
|
|||
#include <xmmsclient/xmmsclient.h>
|
||||
#include <sigc++/sigc++.h>
|
||||
|
||||
#include "xmmsclient_promoe.h"
|
||||
|
||||
static
|
||||
void generic_handler (xmmsc_result_t *res, void *userdata)
|
||||
{
|
||||
XMMSResult* r = static_cast<XMMSResult*>(userdata);
|
||||
if (!r) {
|
||||
cout << "********* FATAL ERROR ***********" << endl;
|
||||
cout << "The generic handler was called without a result!" << endl;
|
||||
return;
|
||||
}
|
||||
r->emit ();
|
||||
}
|
||||
|
||||
XMMSClient::XMMSClient (const char *name)
|
||||
{
|
||||
m_xmmsc = xmmsc_init (name);
|
||||
}
|
||||
|
||||
bool
|
||||
XMMSClient::connect (const char *path)
|
||||
{
|
||||
if (!xmmsc_connect (m_xmmsc, path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
XMMSClient::~XMMSClient ()
|
||||
{
|
||||
xmmsc_unref (m_xmmsc);
|
||||
}
|
||||
|
||||
XMMSResult::XMMSResult (xmmsc_result_t *res)
|
||||
: m_res(res), m_inited(false), m_signal()
|
||||
{
|
||||
}
|
||||
|
||||
XMMSResult::XMMSResult (const XMMSResult &src)
|
||||
: m_res(src.m_res)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
XMMSResult::restart (void)
|
||||
{
|
||||
xmmsc_result_t *nres;
|
||||
nres = xmmsc_result_restart (m_res);
|
||||
xmmsc_result_unref (m_res);
|
||||
xmmsc_result_unref (nres);
|
||||
m_res = nres;
|
||||
}
|
||||
|
||||
void
|
||||
XMMSResult::connect (const sigc::slot<void, XMMSResult*>& slot_)
|
||||
{
|
||||
if (!m_inited) {
|
||||
xmmsc_result_notifier_set (m_res, &generic_handler, this);
|
||||
m_inited = true;
|
||||
}
|
||||
m_signal.connect (slot_);
|
||||
}
|
||||
|
||||
static void
|
||||
dict_foreach (const void *key,
|
||||
xmmsc_result_value_type_t type,
|
||||
const void *value,
|
||||
void *udata)
|
||||
{
|
||||
list<const char *> *i (static_cast<list<const char*>*>(udata));
|
||||
i->push_front (static_cast<const char*>(key));
|
||||
}
|
||||
|
||||
list<const char *>
|
||||
XMMSResultDict::getDictKeys (void)
|
||||
{
|
||||
list<const char *> i;
|
||||
|
||||
xmmsc_result_dict_foreach (m_res, dict_foreach, static_cast<void*>(&i));
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static void
|
||||
propdict_foreach (const void *key,
|
||||
xmmsc_result_value_type_t type,
|
||||
const void *value,
|
||||
const char *source,
|
||||
void *udata)
|
||||
{
|
||||
list<const char *> *i (static_cast<list<const char*>*>(udata));
|
||||
i->push_front (static_cast<const char*>(key));
|
||||
}
|
||||
|
||||
list<const char *>
|
||||
XMMSResultDict::getPropDictKeys (void)
|
||||
{
|
||||
list<const char *> i;
|
||||
|
||||
xmmsc_result_propdict_foreach (m_res, propdict_foreach, static_cast<void*>(&i));
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
XMMSResult::~XMMSResult ()
|
||||
{
|
||||
xmmsc_result_unref (m_res);
|
||||
}
|
|
@ -1,199 +0,0 @@
|
|||
#ifndef __XMMSCLIENTPP_H
|
||||
#define __XMMSCLIENTPP_H
|
||||
|
||||
#include <sigc++/sigc++.h>
|
||||
#include <iostream>
|
||||
#include <xmmsclient/xmmsclient.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class XMMSResult
|
||||
{
|
||||
public:
|
||||
XMMSResult (xmmsc_result_t*);
|
||||
XMMSResult (const XMMSResult &);
|
||||
virtual ~XMMSResult ();
|
||||
|
||||
uint getClass (void) { return xmmsc_result_get_class (m_res); }
|
||||
uint getType (void) { return xmmsc_result_get_type (m_res); }
|
||||
void restart (void);
|
||||
|
||||
/* error */
|
||||
bool isError (void) { return xmmsc_result_iserror (m_res); }
|
||||
const char *getError (void) { return xmmsc_result_get_error (m_res); }
|
||||
|
||||
/* wait for this resultset */
|
||||
void wait (void) const { xmmsc_result_wait (m_res); }
|
||||
|
||||
void connect (const sigc::slot<void, XMMSResult*>& slot_);
|
||||
void emit (void) { m_signal.emit(this); }
|
||||
|
||||
protected:
|
||||
xmmsc_result_t *m_res;
|
||||
|
||||
bool m_inited;
|
||||
sigc::signal<void, XMMSResult*> m_signal;
|
||||
};
|
||||
|
||||
|
||||
class XMMSResultList
|
||||
{
|
||||
public:
|
||||
XMMSResultList (xmmsc_result_t* res) : m_list_res(res) { }
|
||||
XMMSResultList (const XMMSResultList &src) : m_list_res(src.m_list_res) { }
|
||||
virtual ~XMMSResultList () { }
|
||||
|
||||
bool listValid (void) { return xmmsc_result_list_valid (m_list_res); }
|
||||
bool listNext (void) { return xmmsc_result_list_next (m_list_res); }
|
||||
bool listFirst (void) { return xmmsc_result_list_first (m_list_res); }
|
||||
|
||||
bool isList (void) { return xmmsc_result_is_list (m_list_res); }
|
||||
|
||||
private:
|
||||
xmmsc_result_t *m_list_res;
|
||||
};
|
||||
|
||||
|
||||
class XMMSResultDict : public XMMSResult
|
||||
{
|
||||
public:
|
||||
XMMSResultDict (xmmsc_result_t* res) : XMMSResult(res) { }
|
||||
XMMSResultDict (const XMMSResultDict &src) : XMMSResult(src) { }
|
||||
virtual ~XMMSResultDict () { }
|
||||
|
||||
void connect (const sigc::slot<void, XMMSResultDict*>& slot_) {
|
||||
XMMSResult::connect(sigc::retype(slot_));
|
||||
}
|
||||
|
||||
std::list<const char*> getPropDictKeys ();
|
||||
std::list<const char*> getDictKeys ();
|
||||
|
||||
uint getDictValueType (const char *key) {
|
||||
return xmmsc_result_get_dict_entry_type (m_res, key);
|
||||
}
|
||||
|
||||
int entryFormat (char *target, int len, const char *format) {
|
||||
return xmmsc_entry_format (target, len, format, m_res);
|
||||
}
|
||||
|
||||
bool getValue (const char* key, int *var) {
|
||||
return xmmsc_result_get_dict_entry_int32 (m_res, key, var);
|
||||
}
|
||||
bool getValue (const char* key, uint *var) {
|
||||
return xmmsc_result_get_dict_entry_uint32 (m_res, key, var);
|
||||
}
|
||||
bool getValue (const char* key, char **var) {
|
||||
return xmmsc_result_get_dict_entry_str (m_res, key, var);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class XMMSResultValue : public XMMSResult
|
||||
{
|
||||
public:
|
||||
XMMSResultValue (xmmsc_result_t* res) : XMMSResult(res) { }
|
||||
XMMSResultValue (const XMMSResultValue<T> &src) : XMMSResult(src) { }
|
||||
virtual ~XMMSResultValue () { }
|
||||
|
||||
void connect (const sigc::slot<void, XMMSResultValue<T>*>& slot_) = 0;
|
||||
bool getValue (T *var) = 0;
|
||||
};
|
||||
|
||||
template <>
|
||||
class XMMSResultValue<int> : public XMMSResult
|
||||
{
|
||||
public:
|
||||
XMMSResultValue (xmmsc_result_t* res) : XMMSResult(res) { }
|
||||
XMMSResultValue (const XMMSResultValue<int> &src) : XMMSResult(src) { }
|
||||
virtual ~XMMSResultValue () { }
|
||||
|
||||
void connect (const sigc::slot<void, XMMSResultValue<int>*>& slot_) {
|
||||
XMMSResult::connect(sigc::retype(slot_));
|
||||
}
|
||||
|
||||
bool getValue (int *var) { return xmmsc_result_get_int (m_res, var); }
|
||||
};
|
||||
|
||||
template <>
|
||||
class XMMSResultValue<uint> : public XMMSResult
|
||||
{
|
||||
public:
|
||||
XMMSResultValue (xmmsc_result_t* res) : XMMSResult(res) { }
|
||||
XMMSResultValue (const XMMSResultValue<uint> &src) : XMMSResult(src) { }
|
||||
virtual ~XMMSResultValue () { }
|
||||
|
||||
void connect (const sigc::slot<void, XMMSResultValue<uint>*>& slot_) {
|
||||
XMMSResult::connect(sigc::retype(slot_));
|
||||
}
|
||||
|
||||
bool getValue (uint *var) { return xmmsc_result_get_uint (m_res, var); }
|
||||
};
|
||||
|
||||
template <>
|
||||
class XMMSResultValue<char*> : public XMMSResult
|
||||
{
|
||||
public:
|
||||
XMMSResultValue (xmmsc_result_t* res) : XMMSResult(res) { }
|
||||
XMMSResultValue (const XMMSResultValue<char*> &src) : XMMSResult(src) { }
|
||||
virtual ~XMMSResultValue () { }
|
||||
|
||||
void connect (const sigc::slot<void, XMMSResultValue<char*>*>& slot_) {
|
||||
XMMSResult::connect(sigc::retype(slot_));
|
||||
}
|
||||
|
||||
bool getValue (char **var) { return xmmsc_result_get_string (m_res, var); }
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class XMMSResultValueList : public XMMSResultList, public XMMSResultValue<T>
|
||||
{
|
||||
public:
|
||||
XMMSResultValueList (xmmsc_result_t* res)
|
||||
: XMMSResultList(res), XMMSResultValue<T>(res) { }
|
||||
XMMSResultValueList (const XMMSResultValueList<T> &src)
|
||||
: XMMSResultList(src), XMMSResultValue<T>(src) { }
|
||||
virtual ~XMMSResultValueList() { }
|
||||
|
||||
void connect (const sigc::slot<void, XMMSResultValueList<T>*>& slot_) {
|
||||
XMMSResult::connect(sigc::retype(slot_));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class XMMSResultDictList : public XMMSResultList, public XMMSResultDict
|
||||
{
|
||||
public:
|
||||
XMMSResultDictList (xmmsc_result_t* res)
|
||||
: XMMSResultList(res), XMMSResultDict(res) { }
|
||||
XMMSResultDictList (const XMMSResultDictList &src)
|
||||
: XMMSResultList(src), XMMSResultDict(src) { }
|
||||
virtual ~XMMSResultDictList() { }
|
||||
|
||||
void connect (const sigc::slot<void, XMMSResultDictList*>& slot_) {
|
||||
XMMSResult::connect(sigc::retype(slot_));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class XMMSClient
|
||||
{
|
||||
public:
|
||||
XMMSClient (const char *name);
|
||||
~XMMSClient ();
|
||||
|
||||
bool connect (const char *path);
|
||||
|
||||
xmmsc_connection_t *getConn(void) { return m_xmmsc; }
|
||||
|
||||
#include "xmmsclient_methods.h"
|
||||
|
||||
private:
|
||||
xmmsc_connection_t *m_xmmsc;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue