~jamesh/account-polld/account-refresh

« back to all changes in this revision

Viewing changes to accounts/accounts.c

  • Committer: James Henstridge
  • Date: 2014-07-24 05:06:56 UTC
  • Revision ID: james@jamesh.id.au-20140724050656-knt3qcqmz73i4c16
Convert account watcher to track a single service type rather than a set 
of service names.  This is needed to properly receive enabled event 
notifications.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "_cgo_export.h"
2
2
 
3
 
AccountWatcher *watch_for_services(void *array_of_service_names, int length) {
 
3
AccountWatcher *watch_for_service_type(const char *service_type) {
4
4
    /* Transfer service names to hash table */
5
 
    GoString *service_names = (GoString *)array_of_service_names;
6
 
    GHashTable *services_to_watch = g_hash_table_new_full(
7
 
        g_str_hash, g_str_equal, g_free, NULL);
8
 
    int i;
9
 
    for (i = 0; i < length; i++) {
10
 
        g_hash_table_insert(services_to_watch, g_strdup(service_names[i].p), NULL);
11
 
    }
12
 
 
13
5
    if (FALSE) {
14
6
        /* The Go callback doesn't quite match the
15
7
         * AccountEnabledCallback function prototype, so we cast the
27
19
    }
28
20
 
29
21
    AccountWatcher *watcher = account_watcher_new(
30
 
        services_to_watch, (AccountEnabledCallback)authCallback, NULL);
31
 
    g_hash_table_unref(services_to_watch);
 
22
        service_type, (AccountEnabledCallback)authCallback, NULL);
32
23
    return watcher;
33
24
}