/* * Copyright (C) 2014 Wim Taymans * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "hsd.h" #include "hsd-manager.h" #include "hsd-profile.h" static GDBusConnection *the_connection; static GMainLoop *loop; GDBusConnection * hsd_dbus_connection_get (void) { return the_connection; } static void on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { GError *error = NULL; HsdManager *manager; the_connection = connection; manager = hsd_manager_new (&error); if (manager == NULL) { g_printerr ("error registering manager: %s", error->message); g_clear_error (&error); g_main_loop_quit (loop); return; } hsd_profile_new (manager, HSD_PROFILE_ID_HSP_AG, &error); if (error != NULL) { g_printerr ("error registering profile: %s", error->message); g_clear_error (&error); g_main_loop_quit (loop); return; } } static void on_name_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { g_print ("Acquired the name %s on the session bus\n", name); } static void on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data) { g_print ("Lost the name %s on the session bus\n", name); } int main (int argc, char *argv[]) { GError *error = NULL; guint owner_id; owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM, HSD_SERVICE, G_BUS_NAME_OWNER_FLAGS_REPLACE, on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL); g_print ("going into mainloop\n"); loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); g_print ("exit mainloop\n"); g_bus_unown_name (owner_id); return 0; }