Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make stat response include plugin capabilities. make audioscrobbler p…

…lugin report some capabilities. addresses issue #20
  • Loading branch information...
commit 535d15f39cf28b726341f306230bcf77db8e6c91 1 parent ce5a92b
@RJ authored
View
8 CMakeLists.txt
@@ -17,7 +17,8 @@ SET(CMAKE_INSTALL_PREFIX "/usr/local")
# then: cmake .. ; make
# alternatively, recompile boost with -fPIC like so:
# bjam --v2 cxxflags=-fPIC stage
-SET(Boost_USE_STATIC_LIBS ON)
+#SET(Boost_USE_STATIC_LIBS ON)
+SET(Boost_USE_STATIC_LIBS OFF)
SET(Boost_USE_MULTITHREADED ON)
FIND_PACKAGE(Boost 1.35 REQUIRED COMPONENTS filesystem system regex thread program_options date_time)
@@ -26,6 +27,7 @@ FIND_PACKAGE(Sqlite3 REQUIRED)
FIND_PACKAGE(CURL REQUIRED)
INCLUDE_DIRECTORIES(
${PLAYDAR_PATH}/includes # playdar includes
+ /home/rj/src/libf2f/include # TODO hack
${Boost_INCLUDE_DIR}
${SQLITE3_INCLUDE_DIR}
${TAGLIB_INCLUDES}
@@ -40,7 +42,9 @@ INCLUDE_DIRECTORIES(
)
# Always check local/lib first:
-LINK_DIRECTORIES(/usr/local/lib)
+LINK_DIRECTORIES( /usr/local/lib
+ /home/rj/src/libf2f/lib # TODO hack
+ )
SET(CMAKE_VERBOSE_MAKEFILE ON)
INCLUDE(InstallRequiredSystemLibraries)
View
2  etc/playdar.conf
@@ -1,6 +1,6 @@
{
"name" : "YOURNAMEHERE",
- "db" : "collection.db",
+ "db" : "collection-empty.db",
"http_port" : 8888,
"load_plugins" : true,
"load_scripts" : true,
View
1  includes/playdar/playdar_request_handler.h
@@ -65,7 +65,6 @@ class playdar_request_handler : public moost::http::request_handler_base<playdar
void handle_sid( const playdar_request&, moost::http::reply& );
void handle_quickplay( const playdar_request&, moost::http::reply& );
void handle_pluginurl( const playdar_request&, moost::http::reply& );
- void handle_capabilities( const playdar_request&, moost::http::reply& );
void handle_comet( const playdar_request& , moost::http::reply& );
std::string handle_queries_root(const playdar_request& req);
View
3  includes/playdar/pluginadaptor.h
@@ -66,6 +66,9 @@ class PluginAdaptor
virtual ResolverService * rs() const { return m_rs; }
virtual const std::string hostname() const = 0;
+ /// what plugins/capabilities does playdar have available?
+ virtual const json_spirit::Object capabilities() const = 0;
+
unsigned int targettime() const { return m_targettime; }
unsigned short weight() const { return m_weight; }
unsigned short preference() const { return m_preference; }
View
13 includes/playdar/pluginadaptor_impl.hpp
@@ -164,6 +164,19 @@ class PluginAdaptorImpl : public PluginAdaptor
return m_resolver->sid2ri( sid );
}
+ virtual const json_spirit::Object capabilities() const
+ {
+ json_spirit::Object obj;
+ json_spirit::Value vfalse = json_spirit::Value(false);
+ BOOST_FOREACH( pa_ptr pap, m_resolver->resolvers() )
+ {
+ json_spirit::Value v = pap->rs()->capabilities();
+ if( v == vfalse ) continue;
+ obj.push_back( json_spirit::Pair( pap->classname(), v ) );
+ }
+ return obj;
+ }
+
private:
Config* m_config;
Resolver* m_resolver;
View
11 includes/playdar/resolver_service.h
@@ -45,8 +45,7 @@ class ResolverService
/// called once at startup.
virtual bool init(pa_ptr pap) = 0;
- /// can return an instance of itself: non-cloneable
- /// resolvers will return an empty shared ptr
+ /// can return an instance of itself, or a clone.
/// note: ResolverServicePlugin are ALWAYS cloneable!
virtual boost::shared_ptr<ResolverService> clone()
{ return boost::shared_ptr<ResolverService>(); }
@@ -109,7 +108,13 @@ class ResolverService
return false;
}
- virtual json_spirit::Object get_capabilities() const{ return json_spirit::Object();}
+ /// if you want this plugin to be listed in the stat call, return a non-empty
+ /// Object. It will be listed in the json array: [ <name> : getCapabilities(), ... ]
+ /// not implementing means plugin doesnt report itself in stat calls etc.
+ virtual json_spirit::Value capabilities() const
+ { return json_spirit::Value(false);}
+
+
};
View
4 playdar.kdevelop
@@ -677,8 +677,8 @@
<includestyle>3</includestyle>
<root>/usr/share/qt3</root>
<designerintegration>EmbeddedKDevDesigner</designerintegration>
- <qmake>/usr/bin/qmake-qt3</qmake>
- <designer>/usr/bin/designer</designer>
+ <qmake>/usr/local/Trolltech/Qt-4.4.3/bin/qmake</qmake>
+ <designer>/usr/local/Trolltech/Qt-4.4.3/bin/designer</designer>
<designerpluginpaths/>
</qt>
<codecompletion>
View
BIN  playdar.kdevelop.pcs
Binary file not shown
View
12 playdar.kdevses
@@ -1,17 +1,7 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
- <DocsAndViews NumberOfDocuments="3" >
- <Doc0 NumberOfViews="1" URL="file:///mnt/ssd/playdar/contrib/darknet/darknet.cpp" >
- <View0 Encoding="UTF-8" line="0" Type="Source" />
- </Doc0>
- <Doc1 NumberOfViews="1" URL="file:///mnt/ssd/playdar/contrib/darknet/darknet.h" >
- <View0 Encoding="UTF-8" line="0" Type="Source" />
- </Doc1>
- <Doc2 NumberOfViews="1" URL="file:///mnt/ssd/playdar/contrib/darknet/ss_darknet.h" >
- <View0 Encoding="UTF-8" line="74" Type="Source" />
- </Doc2>
- </DocsAndViews>
+ <DocsAndViews NumberOfDocuments="0" />
<pluginList>
<kdevdebugger>
<breakpointList/>
View
1  resolvers/api/api.cpp
@@ -43,6 +43,7 @@ api::anon_http_handler(const playdar_request& req, playdar_response& resp, playd
r.push_back( Pair("name", "playdar") );
r.push_back( Pair("version", m_pap->playdar_version()) );
r.push_back( Pair("authenticated", false) );
+ r.push_back( Pair("capabilities", m_pap->capabilities()) );
write_formatted( r, response );
}
else
View
7 resolvers/audioscrobbler/audioscrobbler_plugin.h
@@ -43,6 +43,13 @@ namespace playdar
// we don't do any actual resolving:
virtual unsigned short weight() const { return 0; }
virtual unsigned int target_time() const { return 0; }
+
+ virtual json_spirit::Value capabilities() const
+ {
+ json_spirit::Object obj;
+ obj.push_back( json_spirit::Pair( "version", "1.0" ) );
+ return obj;
+ }
private:
/** pure virtual, so reimplemented but does nothing */
View
19 src/playdar_request_handler.cpp
@@ -71,7 +71,7 @@ playdar_request_handler::init(MyApplication * app)
m_urlHandlers[ "queries" ] = boost::bind( &playdar_request_handler::handle_queries, this, _1, _2 );
m_urlHandlers[ "static" ] = boost::bind( &playdar_request_handler::serve_static_file, this, _1, _2 );
m_urlHandlers[ "sid" ] = boost::bind( &playdar_request_handler::handle_sid, this, _1, _2 );
- m_urlHandlers[ "capabilities" ] = boost::bind( &playdar_request_handler::handle_capabilities, this, _1, _2 );
+ //m_urlHandlers[ "capabilities" ] = boost::bind( &playdar_request_handler::handle_capabilities, this, _1, _2 );
m_urlHandlers[ "comet" ] = boost::bind( &playdar_request_handler::handle_comet, this, _1, _2 );
//Local Collection / Main API plugin callbacks:
@@ -671,23 +671,6 @@ playdar_request_handler::handle_json_query(string query, const moost::http::requ
rep.write_finish();
}
-void
-playdar_request_handler::handle_capabilities(const playdar_request& req, moost::http::reply& rep)
-{
- using namespace json_spirit;
- json_spirit::Array a;
- BOOST_FOREACH( const pa_ptr pap, m_app->resolver()->resolvers() )
- {
- json_spirit::Object o = pap->rs()->get_capabilities();
- if( !o.empty() )
- a.push_back( o );
- }
- std::string s = write_formatted( a );
- rep.add_header("Content-Length", s.length());
- rep.write_content( s );
- rep.write_finish();
-}
-
void
playdar_request_handler::serve_body(const playdar_response& response, moost::http::reply& rep)
{
Please sign in to comment.
Something went wrong with that request. Please try again.