Permalink
Browse files

library stuff

  • Loading branch information...
1 parent ad3f489 commit 76c75e8bc90141592db901acf596858f4f323344 @RJ committed Feb 8, 2010
View
@@ -18,6 +18,8 @@ conjist::conjist(int argc, char *argv[])
void conjist::setup()
{
+ setupLibrary();
+
QString domain, username, password, server, sport, slport;
int jport;
bool noupnp, xmpplog;
@@ -74,6 +76,17 @@ void conjist::setup()
startServent(!noupnp);
}
+void conjist::setupLibrary()
+{
+ QString dbname = "./library.sqlite";
+ m_library = new Library(dbname, this);
+ if(!QFile(dbname).exists())
+ {
+ m_scanner = new MusicScanner("/mnt/redbeard/media/music");
+ connect(m_scanner,SIGNAL(fileScanned(QVariantMap)), m_library, SLOT(addFile(QVariantMap)),Qt::QueuedConnection);
+ m_scanner->start();
+ }
+}
// figure out ports, external ips, and start the servent listening
void conjist::startServent(bool upnp)
View
@@ -9,6 +9,9 @@
#include <qjson/serializer.h>
#include <qjson/qobjecthelper.h>
+#include "library/library.h"
+#include "library/scanner.h"
+
#include "jabberclient.h"
#include "servent.h"
#include "getopt_helper.h"
@@ -21,6 +24,7 @@ class conjist : public QCoreApplication
Q_OBJECT
public:
explicit conjist(int argc, char *argv[]);
+ Library * library() { return m_library; };
signals:
@@ -32,6 +36,7 @@ private slots:
void setup();
private:
+ void setupLibrary();
void startServent(bool upnp);
helper::GetOpt m_go;
QString m_ourjid;
@@ -41,6 +46,9 @@ private slots:
QHostAddress m_externalAddress;
QJson::Parser parser;
+ Library * m_library;
+ MusicScanner * m_scanner;
+
};
#endif // CONJIST_H
View
@@ -54,6 +54,8 @@ class Connection : public QObject
void setOnceOnly(bool b){ m_onceonly = b; };
bool onceOnly() const { return m_onceonly; };
+ bool isReady() const { return m_ready; } ;
+
protected:
virtual void handleMsg(QByteArray msg);
virtual void setup(){};
@@ -45,6 +45,12 @@ void ControlConnection::handleMsg(QByteArray msg)
QString name= m["name"].toString();
m_servent->createDaapListener(this, key, name);
}
+ else if(m.value("method").toString() == "library-offer")
+ {
+ QString key = m["key"].toString();
+ QString name= m["name"].toString();
+ m_servent->createRemoteCollection(this, key, name);
+ }
return;
}
@@ -0,0 +1,28 @@
+#!/bin/bash
+schema=$1
+name=$2
+
+if [ -e "$schema" -a -n "$name" ]
+then
+cat <<EOF
+/*
+ This file was automatically generated from $schema on `date`.
+*/
+
+static const char * ${name}_schema_sql =
+EOF
+ awk '!/^-/ && length($0) {gsub(/[ \t]+$/, "", $0); gsub("\"","\\\"",$0); printf("\"%s\"\n",$0);}' "$schema"
+cat <<EOF
+ ;
+
+const char * get_${name}_sql()
+{
+ return ${name}_schema_sql;
+}
+
+
+EOF
+else
+ echo "Usage: $0 <schema.sql> <name>"
+ exit 1
+fi
Oops, something went wrong.

0 comments on commit 76c75e8

Please sign in to comment.