chiark / gitweb /
build: basic autoconfization
[elogind.git] / dbus-manager.c
index 3ccf8de650c6b9724cb79794062b162ac7ea58ef..bdc82df070aeaff9c8ea205134d2c0378e528107 100644 (file)
@@ -1,5 +1,24 @@
 /*-*- Mode: C; c-basic-offset: 8 -*-*/
 
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd 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
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
 #include <errno.h>
 
 #include "dbus.h"
@@ -35,7 +54,7 @@
 #define INTROSPECTION_END                                               \
         "</node>"
 
-DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusMessage *message, void *data) {
+static DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusMessage *message, void *data) {
         int r;
         Manager *m = data;
         DBusError error;
@@ -153,7 +172,7 @@ DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusM
                         goto oom;
 
                 HASHMAP_FOREACH_KEY(u, k, m->units, i) {
-                        char *unit_path, *job_path;
+                        char *u_path, *j_path;
                         const char *id, *description, *load_state, *active_state, *job_type;
                         DBusMessageIter sub2;
                         uint32_t job_id;
@@ -169,21 +188,21 @@ DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusM
                         load_state = unit_load_state_to_string(u->meta.load_state);
                         active_state = unit_active_state_to_string(unit_active_state(u));
 
-                        if (!(unit_path = unit_dbus_path(u)))
+                        if (!(u_path = unit_dbus_path(u)))
                                 goto oom;
 
                         if (u->meta.job) {
                                 job_id = (uint32_t) u->meta.job->id;
 
-                                if (!(job_path = job_dbus_path(u->meta.job))) {
-                                        free(unit_path);
+                                if (!(j_path = job_dbus_path(u->meta.job))) {
+                                        free(u_path);
                                         goto oom;
                                 }
 
-                                job_type = job_type_to_string(u->meta.job->state);
+                                job_type = job_type_to_string(u->meta.job->type);
                         } else {
                                 job_id = 0;
-                                job_path = unit_path;
+                                j_path = u_path;
                                 job_type = "";
                         }
 
@@ -191,19 +210,19 @@ DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusM
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &description) ||
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &load_state) ||
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &active_state) ||
-                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &unit_path) ||
+                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &u_path) ||
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT32, &job_id) ||
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &job_type) ||
-                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &job_path)) {
-                                free(unit_path);
+                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &j_path)) {
+                                free(u_path);
                                 if (u->meta.job)
-                                        free(job_path);
+                                        free(j_path);
                                 goto oom;
                         }
 
-                        free(unit_path);
+                        free(u_path);
                         if (u->meta.job)
-                                free(job_path);
+                                free(j_path);
 
                         if (!dbus_message_iter_close_container(&sub, &sub2))
                                 goto oom;
@@ -226,7 +245,7 @@ DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusM
                         goto oom;
 
                 HASHMAP_FOREACH(j, m->jobs, i) {
-                        char *unit_path, *job_path;
+                        char *u_path, *j_path;
                         const char *unit, *state, *type;
                         uint32_t id;
                         DBusMessageIter sub2;
@@ -237,13 +256,13 @@ DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusM
                         id = (uint32_t) j->id;
                         unit = unit_id(j->unit);
                         state = job_state_to_string(j->state);
-                        type = job_type_to_string(j->state);
+                        type = job_type_to_string(j->type);
 
-                        if (!(job_path = job_dbus_path(j)))
+                        if (!(j_path = job_dbus_path(j)))
                                 goto oom;
 
-                        if (!(unit_path = unit_dbus_path(j->unit))) {
-                                free(job_path);
+                        if (!(u_path = unit_dbus_path(j->unit))) {
+                                free(j_path);
                                 goto oom;
                         }
 
@@ -251,15 +270,15 @@ DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusM
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &unit) ||
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &type) ||
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &state) ||
-                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &job_path) ||
-                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &unit_path)) {
-                                free(job_path);
-                                free(unit_path);
+                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &j_path) ||
+                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &u_path)) {
+                                free(j_path);
+                                free(u_path);
                                 goto oom;
                         }
 
-                        free(job_path);
-                        free(unit_path);
+                        free(j_path);
+                        free(u_path);
 
                         if (!dbus_message_iter_close_container(&sub, &sub2))
                                 goto oom;