--- 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: */