*/
/** Avoid caching huge messages */
-#define MAX_MESSAGE_SIZE_TO_CACHE _DBUS_ONE_MEGABYTE
+#define MAX_MESSAGE_SIZE_TO_CACHE 10 * _DBUS_ONE_KILOBYTE
/** Avoid caching too many messages */
#define MAX_MESSAGE_CACHE_SIZE 5
}
/**
+ * Returns the current signature of a message iterator. This
+ * is useful primarily for dealing with variants; one can
+ * recurse into a variant and determine the signature of
+ * the variant's value.
+ *
+ * @param iter the message iterator
+ * @returns the contained signature, or NULL if out of memory
+ */
+char *
+dbus_message_iter_get_signature (DBusMessageIter *iter)
+{
+ const DBusString *sig;
+ DBusString retstr;
+ char *ret;
+ int start, len;
+ DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
+
+ _dbus_return_val_if_fail (_dbus_message_iter_check (real), NULL);
+
+ if (!_dbus_string_init (&retstr))
+ return NULL;
+
+ _dbus_type_reader_get_signature (&real->u.reader, &sig,
+ &start, &len);
+ if (!_dbus_string_append_len (&retstr,
+ _dbus_string_get_const_data (sig) + start,
+ len))
+ return NULL;
+ if (!_dbus_string_steal_data (&retstr, &ret))
+ return NULL;
+ _dbus_string_free (&retstr);
+ return ret;
+}
+
+/**
* Reads a basic-typed value from the message iterator.
* Basic types are the non-containers such as integer and string.
*
}
/**
+ * Returns the number of elements in the array;
+ *
+ * @param iter the iterator
+ * @returns the number of elements in the array
+ */
+int
+dbus_message_iter_get_array_len (DBusMessageIter *iter)
+{
+ DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
+
+ _dbus_return_val_if_fail (_dbus_message_iter_check (real), 0);
+
+ return _dbus_type_reader_get_array_length (&real->u.reader);
+}
+
+/**
* Reads a block of fixed-length values from the message iterator.
* Fixed-length values are those basic types that are not string-like,
* such as integers, bool, double. The block read will be from the
_dbus_return_if_fail (_dbus_message_iter_check (real));
_dbus_return_if_fail (value != NULL);
- _dbus_return_if_fail (dbus_type_is_fixed (_dbus_type_reader_get_element_type (&real->u.reader)));
+ _dbus_return_if_fail (dbus_type_is_fixed (_dbus_type_reader_get_current_type (&real->u.reader)));
_dbus_type_reader_read_fixed_multi (&real->u.reader,
value, n_elements);
}
/**
+ * Checks if the message has a path
+ *
+ * @param message the message
+ * @returns #TRUE if there is a path field in the header
+ */
+dbus_bool_t
+dbus_message_has_path (DBusMessage *message,
+ const char *path)
+{
+ const char *msg_path;
+ msg_path = dbus_message_get_path (message);
+
+ if (msg_path == NULL)
+ {
+ if (path == NULL)
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+ if (path == NULL)
+ return FALSE;
+
+ if (strcmp (msg_path, path) == 0)
+ return TRUE;
+
+ return FALSE;
+}
+
+/**
* Gets the object path this message is being sent to
* (for DBUS_MESSAGE_TYPE_METHOD_CALL) or being emitted
* from (for DBUS_MESSAGE_TYPE_SIGNAL) in a decomposed
}
/**
+ * Checks if the message has an interface
+ *
+ * @param message the message
+ * @returns #TRUE if there is a interface field in the header
+ */
+dbus_bool_t
+dbus_message_has_interface (DBusMessage *message,
+ const char *interface)
+{
+ const char *msg_interface;
+ msg_interface = dbus_message_get_interface (message);
+
+ if (msg_interface == NULL)
+ {
+ if (interface == NULL)
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+ if (interface == NULL)
+ return FALSE;
+
+ if (strcmp (msg_interface, interface) == 0)
+ return TRUE;
+
+ return FALSE;
+
+}
+
+/**
* Sets the interface member being invoked
* (DBUS_MESSAGE_TYPE_METHOD_CALL) or emitted
* (DBUS_MESSAGE_TYPE_SIGNAL).
}
/**
+ * Checks if the message has an interface member
+ *
+ * @param message the message
+ * @returns #TRUE if there is a member field in the header
+ */
+dbus_bool_t
+dbus_message_has_member (DBusMessage *message,
+ const char *member)
+{
+ const char *msg_member;
+ msg_member = dbus_message_get_member (message);
+
+ if (msg_member == NULL)
+ {
+ if (member == NULL)
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+ if (member == NULL)
+ return FALSE;
+
+ if (strcmp (msg_member, member) == 0)
+ return TRUE;
+
+ return FALSE;
+
+}
+
+/**
* Sets the name of the error (DBUS_MESSAGE_TYPE_ERROR).
* The name is fully-qualified (namespaced).
*
_dbus_string_get_length (&loader->data)))
{
_dbus_verbose ("Failed to load header for new message code %d\n", validity);
- if (validity == DBUS_VALID)
+
+ /* assert here so we can catch any code that still uses DBUS_VALID to indicate
+ oom errors. They should use DBUS_VALIDITY_UNKNOWN_OOM_ERROR instead */
+ _dbus_assert (validity != DBUS_VALID);
+
+ if (validity == DBUS_VALIDITY_UNKNOWN_OOM_ERROR)
oom = TRUE;
else
{