# HG changeset patch # User Myhailo Danylenko # Date 1337560731 -10800 # Node ID a66ed0454ca8bd903469f5df89674371b7c7261c # Parent 23fa36d480fb6aa36e164f041cfe148c1779b842 Handle 'state' hook argument * handle 'state' argument of 'tune-out' * option 'pep_tune_pause_is_stop' * 'tune_interval' changed to 'pep_tune_interval' diff -r 23fa36d480fb -r a66ed0454ca8 doc/api.mdwn --- a/doc/api.mdwn Sun May 20 22:15:51 2012 +0300 +++ b/doc/api.mdwn Mon May 21 03:38:51 2012 +0300 @@ -27,6 +27,7 @@ * title * track * uri +* state (stop, pause, play) ## mood-* * mood diff -r 23fa36d480fb -r a66ed0454ca8 pep.rc --- a/pep.rc Sun May 20 22:15:51 2012 +0300 +++ b/pep.rc Mon May 21 03:38:51 2012 +0300 @@ -11,7 +11,12 @@ # Minimum interval betweet two publishes. Any too frequent # publish requests will be discarded. Set to 0 to disable. # (pep_tune option) -set tune_interval = 10 +set pep_tune_interval = 10 + +# Set to non-zero, if paused state should be considered +# stopped state (and thus publish empty data). +# (pep_tune option) +set pep_tune_pause_is_stop = 1 # Minimum interval between two publishes. Any too frequent # publish requests will be discarded. Set to 0 to disable. diff -r 23fa36d480fb -r a66ed0454ca8 pep_tune.c --- a/pep_tune.c Sun May 20 22:15:51 2012 +0300 +++ b/pep_tune.c Mon May 21 03:38:51 2012 +0300 @@ -43,7 +43,7 @@ #define DESCRIPTION ( \ "PEP tune event handler\n" \ - "Recognizes option tune_interval" ) + "Optios: " OPT_TUNE_PAUSE_IS_STOP ", " OPT_TUNE_INTERVAL ) static const gchar *deps[] = { "pep", NULL }; @@ -138,7 +138,7 @@ else reason = "undefined"; - scr_log_print (LPRINT_LOGNORM, "tune: Publish failed: %s - %s", type, reason); + scr_log_print (LPRINT_LOGNORM, "pep_tune: Publish failed: %s - %s", type, reason); } break; @@ -161,7 +161,7 @@ static void tune_publish_info (void) { if (!xmpp_is_online ()) { - scr_log_print (LPRINT_DEBUG, "tune: Not online, delaying publish."); + scr_log_print (LPRINT_DEBUG, "pep_tune: Not online, delaying publish."); publish_delayed = TRUE; return; } @@ -172,7 +172,7 @@ if (now - tune_timestamp < tune_interval) { - scr_log_print (LPRINT_DEBUG, "tune: Publish interval not passed, delaying publish."); + scr_log_print (LPRINT_DEBUG, "pep_tune: Publish interval not passed, delaying publish."); if (!tune_source) tune_source = g_timeout_add_seconds ( tune_interval - ( now - tune_timestamp ), tune_delayed_publish_cb, NULL ); return; @@ -211,7 +211,7 @@ lm_connection_send_with_reply (lconnection, request, tune_reply_handler, &error); if (error) { - scr_log_print (LPRINT_DEBUG, "tune: Publishing error: %s.", error -> message); + scr_log_print (LPRINT_DEBUG, "pep_tune: Publishing error: %s.", error -> message); g_error_free (error); } } @@ -235,12 +235,22 @@ }; // populate new_info with new values - for (tag = pairs; tag->name; ++tag) { - int i; - for (i = 0; i <= MAX_NO; ++i) - if (!g_strcmp0 (tag->name, new_info[i].name)) - new_info[i].value = tag->value; - } + for ( tag = pairs; tag -> name; ++ tag ) + if ( ! g_strcmp0 ( tag -> name, "state" ) ) { + if ( ( ! g_strcmp0 ( tag -> value, "stop" ) ) || + ( ( ! g_strcmp0 ( tag -> value, "pause" ) ) && + settings_opt_get_int ( OPT_TUNE_PAUSE_IS_STOP ) ) ) { + int i; + for ( i = 0; i <= MAX_NO; ++ i ) + new_info [ i ] .value = NULL; + break; + } + } else { + int i; + for ( i = 0; i <= MAX_NO; ++ i ) + if ( ! g_strcmp0 ( tag -> name, new_info [ i ] .name ) ) + new_info [ i ] .value = tag -> value; + } { // check, if it differ from info int i; @@ -336,7 +346,7 @@ static guint tune_hch (const gchar *htype, hk_arg_t *args, gpointer udata) { if (publish_delayed) { - scr_log_print (LPRINT_DEBUG, "tune: Publishing delayed data."); + scr_log_print (LPRINT_DEBUG, "pep_tune: Publishing delayed data."); publish_delayed = FALSE; tune_publish_info (); @@ -382,11 +392,11 @@ { tune_gerror_quark = g_quark_from_string ( "pep-tune-gerror-quark" ); - tune_interval = settings_opt_get_int ("tune_interval"); + tune_interval = settings_opt_get_int ( OPT_TUNE_INTERVAL ); - tune_guard_installed = settings_set_guard ("tune_interval", tune_guard); - if (!tune_guard_installed) - scr_log_print (LPRINT_LOGNORM, "tune: Warning: cannot install option guard for 'tune_interval'"); + tune_guard_installed = settings_set_guard ( OPT_TUNE_INTERVAL, tune_guard ); + if ( ! tune_guard_installed ) + scr_log_print (LPRINT_LOGNORM, "pep_tune: Warning: cannot install option guard for '" OPT_TUNE_INTERVAL "'"); pep_register_xmlns_handler (NS_TUNE, tune_handler, NULL, NULL); @@ -431,7 +441,7 @@ } if ( tune_guard_installed ) - settings_del_guard ( "tune_interval" ); + settings_del_guard ( OPT_TUNE_INTERVAL ); } /* vim: se ts=4 sw=4: */ diff -r 23fa36d480fb -r a66ed0454ca8 tune.h --- a/tune.h Sun May 20 22:15:51 2012 +0300 +++ b/tune.h Mon May 21 03:38:51 2012 +0300 @@ -28,6 +28,9 @@ #define NS_TUNE ( "http:/" "/jabber.org/protocol/tune" ) #define NS_TUNE_NOTIFY ( "http:/" "/jabber.org/protocol/tune+notify" ) +#define OPT_TUNE_PAUSE_IS_STOP "pep_tune_pause_is_stop" +#define OPT_TUNE_INTERVAL "pep_tune_interval" + #define HOOK_TUNE_IN ( "tune-in" ) #define HOOK_TUNE_OUT ( "tune-out" )