static int map_probe(struct obc_session *session) { struct map_data *map; const char *path; path = obc_session_get_path(session); DBG("%s", path); map = g_try_new0(struct map_data, 1); if (!map) return -ENOMEM; map->session = obc_session_ref(session); map->messages = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, map_msg_remove); set_notification_registration(map, true); if (!g_dbus_register_interface(conn, path, MAP_INTERFACE, map_methods, NULL, NULL, map, map_free)) { map_free(map); return -ENOMEM; } return 0; }
static void map_remove(struct obc_session *session) { const char *path = obc_session_get_path(session); DBG("%s", path); g_dbus_unregister_interface(conn, path, MAP_INTERFACE); }
static struct obc_session *find_session(const char *path) { GSList *l; for (l = sessions; l; l = l->next) { struct obc_session *session = l->data; if (g_strcmp0(obc_session_get_path(session), path) == 0) return session; } return NULL; }
static struct map_msg *map_msg_create(struct map_data *data, const char *handle) { struct map_msg *msg; msg = g_new0(struct map_msg, 1); msg->data = data; msg->path = g_strdup_printf("%s/message%s", obc_session_get_path(data->session), handle); if (!g_dbus_register_interface(conn, msg->path, MAP_MSG_INTERFACE, map_msg_methods, NULL, map_msg_properties, msg, map_msg_free)) { map_msg_free(msg); return NULL; } msg->handle = g_strdup(handle); g_hash_table_insert(data->messages, msg->handle, msg); return msg; }
static int pbap_probe(struct obc_session *session) { struct pbap_data *pbap; const char *path; path = obc_session_get_path(session); DBG("%s", path); pbap = g_try_new0(struct pbap_data, 1); if (!pbap) return -ENOMEM; pbap->session = obc_session_ref(session); if (!g_dbus_register_interface(conn, path, PBAP_INTERFACE, pbap_methods, NULL, NULL, pbap, pbap_free)) { pbap_free(pbap); return -ENOMEM; } return 0; }