Skip to content

Commit

Permalink
helper: add hp_next() helper
Browse files Browse the repository at this point in the history
To do a timedout submission; wait for the metadata.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
  • Loading branch information
felipec committed Aug 22, 2011
1 parent 5401306 commit 8c11605
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions helper.c
Expand Up @@ -25,6 +25,7 @@ static int connected;

static DBusConnection *dbus_system;
static ConIcConnection *connection;
static int next_timer;

struct service {
const char *id;
Expand Down Expand Up @@ -267,6 +268,11 @@ void hp_deinit(void)

g_free(cache_dir);
g_free(conf_file);

if (next_timer) {
g_source_remove(next_timer);
next_timer = 0;
}
}

void hp_submit(void)
Expand Down Expand Up @@ -339,3 +345,20 @@ void hp_set_timestamp(void)
{
track->timestamp = time(NULL);
}

static gboolean do_next(void *data)
{
next_timer = 0;
hp_submit();
return FALSE;
}

void hp_next(void)
{
hp_set_timestamp();

if (next_timer)
g_source_remove(next_timer);

next_timer = g_timeout_add_seconds(10, do_next, NULL);
}
1 change: 1 addition & 0 deletions helper.h
Expand Up @@ -19,6 +19,7 @@ void hp_deinit(void);
void hp_submit(void);
void hp_love(bool on);
void hp_stop(void);
void hp_next(void);

void hp_set_artist(const char *value);
void hp_set_title(const char *value);
Expand Down

0 comments on commit 8c11605

Please sign in to comment.