/** * counter-service.c * A simple DBUS service. All it does is count. You can increment * it and get its value. * * Copyright (c) 2011 Samuel A. Rebelsky * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ // +---------+-------------------------------------------------------- // | Headers | // +---------+ #include #include #include message); g_error_free (error); return 1; // Failure } // Create the proxy to the main dbus thing proxy = dbus_g_proxy_new_for_name (connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); if (proxy == NULL) { g_printerr ("Error: Failed to create proxy to Dbus.\n"); return 1; } // Install information on counter objects. (This should probably be // in the class constructor, but, hey, that's life.) dbus_g_object_type_install_info (TYPE_GLIM_COUNTER, &dbus_glib_glim_counter_object_info); // Create the object we're trying to register. object = g_object_new (object_type, TYPE_GLIM_COUNTER); if (object == NULL) { g_printerr ("Error: Failed to create object to register.\n"); g_object_unref (proxy); return 1; } // Register that object dbus_g_connection_register_g_object (connection, DBUS_GLIM_COUNTER_PATH, object); } // main