Logo Search packages:      
Sourcecode: hal version File versions

static int hal_device_set_property_helper ( LibHalContext ctx,
const char *  udi,
const char *  key,
int  type,
const char *  str_value,
dbus_int32_t  int_value,
dbus_uint64_t  uint64_value,
double  double_value,
dbus_bool_t  bool_value 
) [static]

Todo:
sanity check incoming params

Definition at line 1244 of file libhal.c.

References LibHalContext_s::connection.

Referenced by hal_device_remove_property(), hal_device_set_property_bool(), hal_device_set_property_double(), hal_device_set_property_int(), hal_device_set_property_string(), and hal_device_set_property_uint64().

{
      DBusError error;
      DBusMessage *message;
      DBusMessage *reply;
      DBusMessageIter iter;
      char *method_name = NULL;

      /** @todo  sanity check incoming params */

      switch (type) {
      case DBUS_TYPE_NIL:
            method_name = "RemoveProperty";
            break;
      case DBUS_TYPE_STRING:
            method_name = "SetPropertyString";
            break;
      case DBUS_TYPE_INT32:
      case DBUS_TYPE_UINT64:
            method_name = "SetPropertyInteger";
            break;
      case DBUS_TYPE_DOUBLE:
            method_name = "SetPropertyDouble";
            break;
      case DBUS_TYPE_BOOLEAN:
            method_name = "SetPropertyBoolean";
            break;

      default:
            /* cannot happen; is not callable from outside this file */
            break;
      }

      message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
                                    "org.freedesktop.Hal.Device",
                                    method_name);
      if (message == NULL) {
            fprintf (stderr,
                   "%s %d : Couldn't allocate D-BUS message\n",
                   __FILE__, __LINE__);
            return FALSE;
      }

      dbus_message_iter_init (message, &iter);
      dbus_message_iter_append_string (&iter, key);
      switch (type) {
      case DBUS_TYPE_NIL:
            dbus_message_iter_append_nil (&iter);
            break;
      case DBUS_TYPE_STRING:
            dbus_message_iter_append_string (&iter, str_value);
            break;
      case DBUS_TYPE_INT32:
            dbus_message_iter_append_int32 (&iter, int_value);
            break;
      case DBUS_TYPE_UINT64:
            dbus_message_iter_append_uint64 (&iter, uint64_value);
            break;
      case DBUS_TYPE_DOUBLE:
            dbus_message_iter_append_double (&iter, double_value);
            break;
      case DBUS_TYPE_BOOLEAN:
            dbus_message_iter_append_boolean (&iter, bool_value);
            break;
      }

      dbus_error_init (&error);
      reply = dbus_connection_send_with_reply_and_block (ctx->connection,
                                             message, -1,
                                             &error);
      if (dbus_error_is_set (&error)) {
            fprintf (stderr, "%s %d: %s raised\n\"%s\"\n\n", __FILE__,
                   __LINE__, error.name, error.message);
            dbus_message_unref (message);
            return FALSE;
      }

      if (reply == NULL) {
            dbus_message_unref (message);
            return FALSE;
      }

      return TRUE;
}


Generated by  Doxygen 1.6.0   Back to index