+/* called in any user thread, with the connection's lock not held */
+static GVariant *
+g_dbus_connection_call_sync_internal (GDBusConnection *connection,
+ const gchar *bus_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ const GVariantType *reply_type,
+ GDBusCallFlags flags,
+ gint timeout_msec,
+ GUnixFDList *fd_list,
+ GUnixFDList **out_fd_list,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GDBusMessage *message;
+ GDBusMessage *reply;
+ GVariant *result;
+ GError *local_error;
+ GDBusSendMessageFlags send_flags;
+
+ message = NULL;
+ reply = NULL;
+ result = NULL;
+
+ g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
+ g_return_val_if_fail (bus_name == NULL || g_dbus_is_name (bus_name), NULL);
+ g_return_val_if_fail (object_path != NULL && g_variant_is_object_path (object_path), NULL);
+ g_return_val_if_fail (interface_name != NULL && g_dbus_is_interface_name (interface_name), NULL);
+ g_return_val_if_fail (method_name != NULL && g_dbus_is_member_name (method_name), NULL);
+ g_return_val_if_fail (timeout_msec >= 0 || timeout_msec == -1, NULL);
+ g_return_val_if_fail ((parameters == NULL) || g_variant_is_of_type (parameters, G_VARIANT_TYPE_TUPLE), NULL);
+#ifdef G_OS_UNIX
+ g_return_val_if_fail (fd_list == NULL || G_IS_UNIX_FD_LIST (fd_list), NULL);
+#else
+ g_return_val_if_fail (fd_list == NULL, NULL);
+#endif
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ if (!(flags & CALL_FLAGS_INITIALIZING))
+ g_return_val_if_fail (check_initialized (connection), FALSE);
+
+ if (reply_type == NULL)
+ reply_type = G_VARIANT_TYPE_ANY;
+
+ message = g_dbus_message_new_method_call (bus_name,
+ object_path,
+ interface_name,
+ method_name);
+ add_call_flags (message, flags);
+ if (parameters != NULL)
+ g_dbus_message_set_body (message, parameters);
+
+#ifdef G_OS_UNIX
+ if (fd_list != NULL)
+ g_dbus_message_set_unix_fd_list (message, fd_list);
+#endif
+
+ if (G_UNLIKELY (_g_dbus_debug_call ()))
+ {
+ _g_dbus_debug_print_lock ();
+ g_print ("========================================================================\n"
+ "GDBus-debug:Call:\n"
+ " >>>> SYNC %s.%s()\n"
+ " on object %s\n"
+ " owned by name %s\n",
+ interface_name,
+ method_name,
+ object_path,
+ bus_name != NULL ? bus_name : "(none)");
+ _g_dbus_debug_print_unlock ();
+ }
+
+ local_error = NULL;
+
+ send_flags = G_DBUS_SEND_MESSAGE_FLAGS_NONE;
+
+ /* translate from one flavour of flags to another... */
+ if (flags & CALL_FLAGS_INITIALIZING)
+ send_flags |= SEND_MESSAGE_FLAGS_INITIALIZING;
+
+ reply = g_dbus_connection_send_message_with_reply_sync (connection,
+ message,
+ send_flags,
+ timeout_msec,
+ NULL, /* volatile guint32 *out_serial */
+ cancellable,
+ &local_error);
+
+ if (G_UNLIKELY (_g_dbus_debug_call ()))
+ {
+ _g_dbus_debug_print_lock ();
+ g_print ("========================================================================\n"
+ "GDBus-debug:Call:\n"
+ " <<<< SYNC COMPLETE %s.%s()\n"
+ " ",
+ interface_name,
+ method_name);
+ if (reply != NULL)
+ {
+ g_print ("SUCCESS\n");
+ }
+ else
+ {
+ g_print ("FAILED: %s\n",
+ local_error->message);
+ }
+ _g_dbus_debug_print_unlock ();
+ }
+
+ if (reply == NULL)
+ {
+ if (error != NULL)
+ *error = local_error;
+ else
+ g_error_free (local_error);
+ goto out;
+ }
+
+ result = decode_method_reply (reply, method_name, reply_type, out_fd_list, error);
+
+ out:
+ if (message != NULL)
+ g_object_unref (message);
+ if (reply != NULL)
+ g_object_unref (reply);
+
+ return result;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+