sss_sifp.c revision 91cf6f4c6069d6aff01aab171825e83a1a669e2f
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder Pavel Březina <pbrezina@redhat.com>
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder Copyright (C) 2014 Red Hat
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder This program is free software; you can redistribute it and/or modify
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder it under the terms of the GNU General Public License as published by
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder the Free Software Foundation; either version 3 of the License, or
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder (at your option) any later version.
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder This program is distributed in the hope that it will be useful,
99b26e2ab8ba89bc9a050c1524137eb6269e2753Christian Maeder but WITHOUT ANY WARRANTY; without even the implied warranty of
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
92ae4d5885ea837ffe3dae9b2de742f871229b94Christian Maeder GNU General Public License for more details.
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder You should have received a copy of the GNU General Public License
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder along with this program. If not, see <http://www.gnu.org/licenses/>.
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder#define DBUS_IFACE_PROP "org.freedesktop.DBus.Properties"
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maederstatic void * default_alloc(size_t size, void *pvt)
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maederstatic void default_free(void *ptr, void *pvt)
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maederstatic DBusMessage * sss_sifp_create_prop_msg(const char *object_path,
d97700a22b2585ece83b05f3fff945fdfd0c44b4Christian Maeder return sss_sifp_create_message(object_path, DBUS_IFACE_PROP, method);
fd94a6f66ccb5cef99aa42069b61e4b8734dbd3fChristian Maeder return sss_sifp_init_ex(NULL, default_alloc, default_free, _ctx);
04c445e50a1d8b95e667595594e6b551c8b2ff59Simon Ulbricht if (_ctx == NULL || alloc_func == NULL || free_func == NULL) {
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder ctx = alloc_func(sizeof(sss_sifp_ctx), alloc_pvt);
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder ctx->io_error = alloc_func(sizeof(DBusError), alloc_pvt);
be1ce1c2b2819ef32743136c13101f1927375311Christian Maeder conn = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error);
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maedersss_sifp_get_last_io_error_name(sss_sifp_ctx *ctx)
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder return "Invalid sss_sifp context";
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maedersss_sifp_get_last_io_error_message(sss_sifp_ctx *ctx)
2f0ca8050a33fbc1a23c0bd2dec0d09c17e3c548Christian Maeder return "Invalid sss_sifp context";
99b26e2ab8ba89bc9a050c1524137eb6269e2753Christian Maeder if (ctx == NULL || object_path == NULL || interface == NULL
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder /* Message format:
cc9f19b1fe81424205736fe0ae73620395b1bb74Simon Ulbricht * In: string:interface
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht * In: string:attribute
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht * Out: variant(misc:value)
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht msg = sss_sifp_create_prop_msg(object_path, "Get");
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht bret = dbus_message_append_args(msg, DBUS_TYPE_STRING, &interface,
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht ret = sss_sifp_send_message(ctx, msg, &reply);
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht ret = sss_sifp_parse_attr(ctx, name, reply, _attrs);
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht if (ctx == NULL || object_path == NULL || interface == NULL
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht msg = sss_sifp_create_prop_msg(object_path, "GetAll");
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht bret = dbus_message_append_args(msg, DBUS_TYPE_STRING, &interface,
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht ret = sss_sifp_send_message(ctx, msg, &reply);
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht ret = sss_sifp_parse_attr_list(ctx, reply, _attrs);
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht if (ctx == NULL || object_path == NULL || interface == NULL
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht ret = sss_sifp_fetch_all_attrs(ctx, object_path, interface, &attrs);
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht ret = sss_sifp_find_attr_as_string(attrs, "name", &name);
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht object = _alloc_zero(ctx, sss_sifp_object, 1);
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht object->object_path = sss_sifp_strdup(ctx, object_path);
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht object->interface = sss_sifp_strdup(ctx, interface);
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht unsigned int i, j;
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder for (j = 0; j < attrs[i]->num_values; j++) {
de8eee2014437ec4020be15cd363257f87e79943Christian Maedersss_sifp_free_string_array(sss_sifp_ctx *ctx,
bd90cf050d470eb42f6e0b79327cc53bd0f80dc9Christian Maeder if (_str_array == NULL || *_str_array == NULL) {