Skip to content

Commit

Permalink
import a copy of qdaapd, for now at least
Browse files Browse the repository at this point in the history
  • Loading branch information
RJ committed Feb 9, 2010
1 parent c733733 commit 9432774
Show file tree
Hide file tree
Showing 23 changed files with 6,622 additions and 44 deletions.
2 changes: 1 addition & 1 deletion conjist.pro
Expand Up @@ -2,4 +2,4 @@ TEMPLATE = subdirs
OBJECTS_DIR = build
MOC_DIR = build

SUBDIRS = qxmpp miniupnp src
SUBDIRS = qxmpp miniupnp qdaapd src
77 changes: 77 additions & 0 deletions qdaapd/collection.cpp
@@ -0,0 +1,77 @@
#include "collection.h"
using namespace QDaap;

Collection::Collection(QString name, QObject *parent) :
QObject(parent), m_tracksloaded(false), m_name(name)
{
}

int Collection::numTracks()
{
return tracks().size();
}

QMap<quint32,Track> & Collection::tracks()
{
return m_tracks;
}

void Collection::loadTracks()
{
qDebug() << "LoadTracks()";

QDaap::Track t;
t.id = t.perid = 1;
t.artist = "Test artist name 1";
t.album = "Test album name 1";
t.track = "Test track title 1";
t.duration = 300000;
t.filesize = 1024*1024*5;
t.albumposition = 1;
t.genre = "Rock";
t.comment = "no comment";
t.year = 1982;
t.albumdiscnumber = 1;
t.bitrate = 128;


m_tracks[t.id] = t;

QDaap::Track t2;
t2.id = t2.perid = 2;
t2.artist = "Test artist name 2";
t2.album = "Test album name 2";
t2.track = "Test track title 2";
t2.duration = 200000;
t2.filesize = 1024*1024*3;
t2.albumposition = 7;
t2.genre = "Rock";
t2.comment = "no comment";
t2.year = 1982;
t2.albumdiscnumber = 1;
t2.bitrate = 128;

m_tracks[t2.id] = t2;

m_tracksloaded = true;
emit finishedLoading();
}

QIODevice * Collection::getTrack(quint32 id)
{
if(!m_tracks.contains(id))
{
qDebug() << "no track id in collection : " << id;
return 0;
//Q_ASSERT(false);
}
QDaap::Track t = m_tracks[id];
QFile * f = new QFile("/tmp/angels.mp3");
f->open(QIODevice::ReadOnly);
return f;
}

int Collection::numPlaylists() const
{
return 0;
}
96 changes: 96 additions & 0 deletions qdaapd/collection.h
@@ -0,0 +1,96 @@
#ifndef COLLECTION_H
#define COLLECTION_H

#include <QObject>
#include <QList>
#include <QMap>
#include <QFile>
#include <QMutex>
#include <QWaitCondition>
#include <QDebug>

namespace QDaap
{


class Track
{
public:
Track() : extension("mp3"), disabled(false), trackcount(1), albumdiscnumber(1)
{};

quint32 id;
quint64 perid;
QString genre;
QString artist;
QString album;
QString track;
QString comment;
QString extension;
bool disabled;
quint16 bitrate;
quint32 duration; // ms
quint32 filesize;
quint16 trackcount;
quint16 albumposition;
quint16 year;
quint16 albumdiscnumber;
};



/*
class Playlist
{
public:
quint32 id;
quint64 perid;
QString title;
quint32 length; // num tracks in playlist
virtual QList<Track> getTracks()
{
return QList<Track>();
};
};
*/

class Collection : public QObject
{
Q_OBJECT
public:
explicit Collection(QString name, QObject *parent = 0);

QString name() const { return m_name; };

int numTracks();
QMap<quint32,Track> & tracks();

int numPlaylists() const;

// this should hit DB/peer get full current list of all tracks:
virtual void loadTracks();

virtual QIODevice * getTrack(quint32 id);

//QList<Playlist> playlists() const = 0;

bool isLoaded() const { return m_tracksloaded; };


signals:
void finishedLoading();

public slots:

protected:

QString m_name;

QMap<quint32,Track> m_tracks;
bool m_tracksloaded;
};

} // ns

#endif // COLLECTION_H
120 changes: 120 additions & 0 deletions qdaapd/daaplib/daaplib.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9432774

Please sign in to comment.