Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tmp

  • Loading branch information...
commit 9f2efc0cc780e584b46667a48910c8fd092b8ac1 1 parent bc34ed2
@RJ authored
View
8 playdar-daemon/etc/schema.sql
@@ -77,4 +77,10 @@ CREATE TABLE IF NOT EXISTS file_join (
--
-
+CREATE TABLE IF NOT EXISTS settings (
+ category TEXT NOT NULL,
+ key TEXT NOT NULL,
+ value TEXT,
+ description TEXT
+);
+CREATE PRIMARY KEY ON settings(category,key);
View
7 playdar-daemon/src/application/application.cpp
@@ -14,6 +14,8 @@ MyApplication::MyApplication(boost::program_options::variables_map opt)
m_po = opt;
string db_path = option<string>("app.db");
+ m_db = sqlite3pp::database(db_path.c_str());
+
m_library = new Library( db_path, this );
m_resolver = new Resolver(this);
}
@@ -21,8 +23,13 @@ MyApplication::MyApplication(boost::program_options::variables_map opt)
MyApplication::~MyApplication()
{
delete(m_library);
+ delete(m_resolver);
}
+
+
+
+
string
MyApplication::gen_uuid()
{
View
16 playdar-daemon/src/application/application.h
@@ -7,7 +7,7 @@
#include "application/types.h"
#include <boost/thread.hpp>
-
+#include "sqlite3pp.h"
#include <boost/program_options.hpp>
@@ -42,6 +42,18 @@ class MyApplication
template <typename T> T option(string o, T def);
template <typename T> T option(string o);
+ template <typename T>
+ opt(string cat, string key, T def)
+ {
+ sqlite3pp::query qry(m_db, string("SELECT value FROM setting WHERE lower(category)=? AND lower(key)=?").c_str() );
+ qry.bind(1, cat);
+ qry.bind(2, key);
+ for(sqlite3pp::query::iterator i = qry.begin(); i!=qry.end(); ++i){
+ return boost::lexical_cast<T>((*i).get<const char *>(0));
+ break; // should only be one row
+ }
+ return def;
+ }
// RANDOM UTILITY FUNCTIONS TOSSED IN HERE FOR NOW:
@@ -58,6 +70,8 @@ class MyApplication
private:
+ sqlite3pp::database m_db;
+ sqlite3pp::database * db(){ return &m_db; }
Library * m_library;
Resolver * m_resolver;
boost::program_options::variables_map m_po;
View
3  playdar-daemon/src/application/appsettings.h
@@ -80,7 +80,8 @@ class SettingsManager
}
private:
- map< string, string > m_settings;
+ // category -> key -> value
+ map< string, map< string, string > > m_settings;
string m_filename;
// if rewrite, will replace config with existing settings in m_settings
Please sign in to comment.
Something went wrong with that request. Please try again.