static gboolean
emit_notifications_in_idle (gpointer user_data)
{
  GObject *object = G_OBJECT (user_data);
  GDBusConnection *connection;
  const gchar *path;
  GHashTable *notification_queue;
  GHashTableIter iter;
  const gchar *property_name;
  GVariant *value;
  GVariantBuilder *builder;
  GVariantBuilder *invalidated_builder;
  GHashTable *pvc;
  gboolean has_changes;

  notification_queue = g_object_get_data (object, "gdbus-codegen-notification-queue");
  path = g_object_get_data (object, "gdbus-codegen-path");
  connection = g_object_get_data (object, "gdbus-codegen-connection");
  pvc = g_object_get_data (object, "gdbus-codegen-pvc");
  g_assert (notification_queue != NULL && path != NULL && connection != NULL && pvc != NULL);

  builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
  invalidated_builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
  g_hash_table_iter_init (&iter, notification_queue);
  has_changes = FALSE;
  while (g_hash_table_iter_next (&iter, (gpointer) &property_name, (gpointer) &value))
    {
      GVariant *cached_value;
      cached_value = g_hash_table_lookup (pvc, property_name);
      if (cached_value == NULL || !g_variant_equal (cached_value, value))
	{
	  g_hash_table_insert (pvc, (gpointer) property_name, (gpointer) g_variant_ref (value));
          g_variant_builder_add (builder, "{sv}", property_name, value);
	  has_changes = TRUE;
	}
    }

  if (has_changes)
    {
      g_dbus_connection_emit_signal (connection,
				     NULL,
				     path,
                                     "org.freedesktop.DBus.Properties",
                                     "PropertiesChanged",
                                     g_variant_new ("(sa{sv}as)",
                                                    "org.gnome.evolution.dataserver.CalendarFactory",
						    builder,
						    invalidated_builder),
				     NULL);
    }
  else
    {
      g_variant_builder_unref (builder);
      g_variant_builder_unref (invalidated_builder);
    }

  g_hash_table_remove_all (notification_queue);
  g_object_set_data (object, "gdbus-codegen-notification-idle-id", GUINT_TO_POINTER (0));
  return FALSE;
}
Пример #2
0
  static void ListExtraVideoDirectories(cDBusObject *Object, GVariant *Parameters, GDBusMethodInvocation *Invocation)
  {
    int replyCode = 500;
    cString replyMessage = "Missing extra-video-directories patch";
    cStringList dirs;
#ifdef EXTRA_VIDEO_DIRECTORIES_PATCH
    if (!LockExtraVideoDirectories(false)) {
       replyCode = 550;
       replyMessage = "Unable to lock extra video directory list";
       }
    else {
       if (ExtraVideoDirectories.Size() == 0) {
          replyCode = 550;
          replyMessage = "no extra video directories in list";
          }
       else {
          replyCode = 250;
          replyMessage = "";
          for (int i = 0; i < ExtraVideoDirectories.Size(); i++)
              dirs.Append(strdup(ExtraVideoDirectories.At(i)));
          }
       UnlockExtraVideoDirectories();
       }
#endif
    GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("(isas)"));
    g_variant_builder_add(builder, "i", replyCode);
    g_variant_builder_add(builder, "s", *replyMessage);
    GVariantBuilder *array = g_variant_builder_new(G_VARIANT_TYPE("as"));
    for (int i = 0; i < dirs.Size(); i++)
        g_variant_builder_add(array, "s", dirs.At(i));
    g_variant_builder_add_value(builder, g_variant_builder_end(array));
    g_dbus_method_invocation_return_value(Invocation, g_variant_builder_end(builder));
    g_variant_builder_unref(array);
    g_variant_builder_unref(builder);
  };
Пример #3
0
  static void List(cDBusObject *Object, GVariant *Parameters, GDBusMethodInvocation *Invocation)
  {
    if (g_strcmp0(g_dbus_method_invocation_get_interface_name(Invocation), DBUS_VDR_PLUGIN_INTERFACE) == 0)
       esyslog("dbus2vdr: use of deprecated interface: 'List' should be called with the interface '%s'!", DBUS_VDR_PLUGINMANAGER_INTERFACE);

#define EMPTY(s) (s == NULL ? "" : s)
    GVariantBuilder *array = g_variant_builder_new(G_VARIANT_TYPE("a(ss)"));
    int index = 0;
    do
    {
      cPlugin *plugin = cPluginManager::GetPlugin(index);
      if (plugin == NULL)
         break;
      const char *name = plugin->Name();
      const char *version = plugin->Version();
      g_variant_builder_add(array, "(ss)", EMPTY(name), EMPTY(version));
      index++;
    } while (true);
#undef EMPTY

    GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("(a(ss))"));
    g_variant_builder_add_value(builder, g_variant_builder_end(array));
    g_dbus_method_invocation_return_value(Invocation, g_variant_builder_end(builder));
    g_variant_builder_unref(array);
    g_variant_builder_unref(builder);
  }
static void _icd_req_context_free(void *ctx)
{
	struct icd_req_context *req_ctx = ctx;

	free(req_ctx->bus_name);
	if (req_ctx->payload)
		g_variant_unref(req_ctx->payload);
	g_variant_builder_unref(req_ctx->options);
	g_variant_builder_unref(req_ctx->query);
	free(req_ctx);
}
Пример #5
0
 static void ListSkins(cDBusObject *Object, GVariant *Parameters, GDBusMethodInvocation *Invocation)
 {
   GVariantBuilder *ret = g_variant_builder_new(G_VARIANT_TYPE("(ia(iss))"));
   g_variant_builder_add(ret, "i", 900);
   GVariantBuilder *array = g_variant_builder_new(G_VARIANT_TYPE("a(iss)"));
   for (cSkin* skin = Skins.First(); skin; skin = Skins.Next(skin))
       g_variant_builder_add_value(array, BuildSkin(skin));
   g_variant_builder_add_value(ret, g_variant_builder_end(array));
   g_dbus_method_invocation_return_value(Invocation, g_variant_builder_end(ret));
   g_variant_builder_unref(array);
   g_variant_builder_unref(ret);
 };
Пример #6
0
static void
emit_property_changes(XmrMprisPlugin *plugin, GHashTable *changes, const char *interface)
{
	GError *error = NULL;
	GVariantBuilder *properties;
	GVariantBuilder *invalidated;
	GVariant *parameters;
	gpointer propname, propvalue;
	GHashTableIter iter;

	/* build property changes */
	properties = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
	invalidated = g_variant_builder_new(G_VARIANT_TYPE ("as"));
	g_hash_table_iter_init(&iter, changes);
	while (g_hash_table_iter_next(&iter, &propname, &propvalue))
	{
		if (propvalue != NULL)
		{
			g_variant_builder_add(properties,
					       "{sv}",
					       propname,
					       propvalue);
		}
		else
		{
			g_variant_builder_add(invalidated, "s", propname);
		}

	}

	parameters = g_variant_new("(sa{sv}as)",
				    interface,
				    properties,
				    invalidated);
	g_variant_builder_unref(properties);
	g_variant_builder_unref(invalidated);
	g_dbus_connection_emit_signal(plugin->connection,
				       NULL,
				       MPRIS_OBJECT_NAME,
				       "org.freedesktop.DBus.Properties",
				       "PropertiesChanged",
				       parameters,
				       &error);
	if (error != NULL)
	{
		g_warning("Unable to send MPRIS property changes for %s: %s",
			   interface, error->message);
		g_clear_error(&error);
	}
}
Пример #7
0
 static void sReturnError(GDBusMethodInvocation *Invocation, int  ReplyCode, const char *ReplyMessage)
 {
   GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("(isaa(sv))"));
   g_variant_builder_add(builder, "i", ReplyCode);
   g_variant_builder_add(builder, "s", ReplyMessage);
   GVariantBuilder *array = g_variant_builder_new(G_VARIANT_TYPE("aa(sv)"));
   GVariantBuilder *innerArray = g_variant_builder_new(G_VARIANT_TYPE("a(sv)"));
   g_variant_builder_add_value(array, g_variant_builder_end(innerArray));
   g_variant_builder_add_value(builder, g_variant_builder_end(array));
   g_dbus_method_invocation_return_value(Invocation, g_variant_builder_end(builder));
   g_variant_builder_unref(innerArray);
   g_variant_builder_unref(array);
   g_variant_builder_unref(builder);
 };
Пример #8
0
void  cDBusHelper::AddKeyValue(GVariantBuilder *Array, const char *Key, const gchar *Type, void **Value)
{
  GVariantBuilder *element = g_variant_builder_new(G_VARIANT_TYPE("(sv)"));

  g_variant_builder_add(element, "s", Key);

  GVariantBuilder *variant = g_variant_builder_new(G_VARIANT_TYPE("v"));
  g_variant_builder_add(variant, Type, *Value);
  g_variant_builder_add_value(element, g_variant_builder_end(variant));

  g_variant_builder_add_value(Array, g_variant_builder_end(element));

  g_variant_builder_unref(variant);
  g_variant_builder_unref(element);
}
static void _icd_crud_context_free(void *ctx)
{
	struct icd_crud_context *crud_ctx = ctx;

	g_variant_builder_unref(crud_ctx->options);
	free(crud_ctx);
}
Пример #10
0
static void
do_refresh (NAApplication *application)
{
  struct timeval t;
  gettimeofday (&t, NULL);
  GList *proc_info = na_process_info_get_all (t);

  if (proc_info == NULL)
    return;

  GVariantBuilder *builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
  while (proc_info != NULL)
    {
      NAProcInfo *info = (NAProcInfo *)proc_info->data;
      g_variant_builder_add (builder, "(sidd)", info->name, info->pid, tokbps (info->recv), tokbps (info->sent));
      proc_info = proc_info->next;
    }

  g_debug ("DBUS: Emitting signal on system bus");
  g_dbus_connection_emit_signal (na_application_get_system_bus (application),
                                 NULL,
                                 NETWORK_ANALYZER_DBUS_OBJECT_PATH,
                                 NETWORK_ANALYZER_DBUS_IFACE,
                                 "UsageChanged",
                                 g_variant_new ("(a(sidd))", builder),
                                 NULL);

  g_variant_builder_unref (builder);
}
static int _ocprocess_worker(_ocprocess_cb cb, int type, OCPayload *payload, int res,
		GVariantBuilder *options, void *ctx)
{
	int ret;
	struct icd_crud_context *crud_ctx;

	crud_ctx = calloc(1, sizeof(struct icd_crud_context));
	if (NULL == crud_ctx) {
		ERR("calloc() Fail(%d)", errno);
		return IOTCON_ERROR_OUT_OF_MEMORY;
	}

	crud_ctx->crud_type = type;
	crud_ctx->payload = icd_payload_to_gvariant(payload);
	crud_ctx->res = res;
	crud_ctx->options = options;
	crud_ctx->invocation = ctx;

	ret = _ocprocess_worker_start(cb, crud_ctx, _icd_crud_context_free);
	if (IOTCON_ERROR_NONE != ret) {
		ERR("_ocprocess_worker_start() Fail(%d)", ret);
		if (crud_ctx->payload)
			g_variant_unref(crud_ctx->payload);
		g_variant_builder_unref(crud_ctx->options);
		free(crud_ctx);
	}

	/* DO NOT FREE crud_ctx. It MUST be freed in the _worker_crud_cb func */

	return ret;
}
Пример #12
0
static void
async_context_free (SendAsyncContext *context)
{
	if (context->sent_folder != NULL)
		g_object_unref (context->sent_folder);
	if (context->message != NULL)
		g_object_unref (context->message);
	if (context->info != NULL)
		camel_message_info_free (context->info);
	if (context->recipients != NULL)
		g_object_unref (context->recipients);
	if (context->from != NULL)
		g_object_unref (context->from);
	if (context->driver != NULL)
		g_object_unref (context->driver);
	if (context->result != NULL)
		g_variant_builder_unref(context->result);
	if (context->sent_folder_uri)
		g_free (context->sent_folder_uri);
	if (context->ops_path)
		g_free (context->ops_path);
	if (context->cancellable != NULL) {
		camel_operation_pop_message (context->cancellable);
		g_object_unref (context->cancellable);
	}

	g_slice_free (SendAsyncContext, context);
}
Пример #13
0
void
gst_switch_server_mark_face (GstSwitchServer * srv, GVariant * faces,
    gboolean tracking)
{
  const int size = g_variant_n_children (faces);
  const double cw = srv->composite->a_width;
  const double ch = srv->composite->a_height;
  double rx = 1.0, ry = 1.0, dx, dy,
      sw = GST_SWITCH_FACEDETECT_FRAME_WIDTH,
      sh = GST_SWITCH_FACEDETECT_FRAME_HEIGHT;
  GVariantBuilder *vb = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
  int x, y, w, h, n;

  rx = sw / cw;
  ry = sh / ch;
  dx = rx * ((double) srv->composite->a_x);
  dy = ry * ((double) srv->composite->a_y);
  for (n = 0; n < size; ++n) {
    g_variant_get_child (faces, n, "(iiii)", &x, &y, &w, &h);
    x = rx * ((double) x) + 0.5 + dx;
    y = ry * ((double) y) + 0.5 + dy;
    w = rx * ((double) w) + 0.5;
    h = ry * ((double) h) + 0.5;
    g_variant_builder_add (vb, "(iiii)", x, y, w, h);
  }

  if (tracking) {
    gst_switch_controller_show_track_marker (srv->controller,
        g_variant_builder_end (vb));
  } else {
    gst_switch_controller_show_face_marker (srv->controller,
        g_variant_builder_end (vb));
  }
  g_variant_builder_unref (vb);
}
OCStackApplicationResult icd_ioty_ocprocess_observe_cb(void *ctx,
		OCDoHandle handle, OCClientResponse *resp)
{
	int ret, res;
	GVariantBuilder *options;
	struct icd_observe_context *observe_ctx;
	icd_sig_ctx_s *sig_context = ctx;
	OCStackApplicationResult cb_result;

	RETV_IF(NULL == ctx, OC_STACK_KEEP_TRANSACTION);
	RETV_IF(NULL == resp, OC_STACK_KEEP_TRANSACTION);

	cb_result = (OC_OBSERVE_DEREGISTER == resp->sequenceNumber) ?
		OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION;

	if (NULL == resp->payload) {
		ERR("payload is empty");
		_observe_cb_response_error(sig_context->bus_name, sig_context->signal_number,
				IOTCON_ERROR_IOTIVITY);
		return cb_result;
	}

	observe_ctx = calloc(1, sizeof(struct icd_observe_context));
	if (NULL == observe_ctx) {
		ERR("calloc() Fail(%d)", errno);
		_observe_cb_response_error(sig_context->bus_name, sig_context->signal_number,
				IOTCON_ERROR_OUT_OF_MEMORY);
		return cb_result;
	}

	res = _ocprocess_parse_oic_result(resp->result);

	options = _ocprocess_parse_header_options(resp->rcvdVendorSpecificHeaderOptions,
			resp->numRcvdVendorSpecificHeaderOptions);

	observe_ctx->payload = icd_payload_to_gvariant(resp->payload);
	observe_ctx->signal_number = sig_context->signal_number;
	observe_ctx->res = res;
	observe_ctx->bus_name = ic_utils_strdup(sig_context->bus_name);
	observe_ctx->options = options;
	observe_ctx->seqnum = resp->sequenceNumber;

	ret = _ocprocess_worker_start(_worker_observe_cb, observe_ctx,
			_icd_observe_context_free);
	if (IOTCON_ERROR_NONE != ret) {
		ERR("_ocprocess_worker_start() Fail(%d)", ret);
		_observe_cb_response_error(sig_context->bus_name, sig_context->signal_number, ret);
		free(observe_ctx->bus_name);
		if (observe_ctx->payload)
			g_variant_unref(observe_ctx->payload);
		g_variant_builder_unref(observe_ctx->options);
		free(observe_ctx);
		return cb_result;
	}

	/* DO NOT FREE sig_context. It MUST be freed in the ocstack */
	/* DO NOT FREE observe_ctx. It MUST be freed in the _worker_observe_cb func */

	return cb_result;
}
Пример #15
0
void
on_interpreter_cell_changed(GtkCellRendererCombo *combo, char *path_string, GtkTreeIter *new_iter, ChimaraGlk *glk)
{
	unsigned int format, interpreter;
	format = (unsigned int)strtol(path_string, NULL, 10);
	GtkTreeModel *combo_model;
	g_object_get(combo, "model", &combo_model, NULL);
	char *combo_string = gtk_tree_model_get_string_from_iter(combo_model, new_iter);
	interpreter = (unsigned int)strtol(combo_string, NULL, 10);
	g_free(combo_string);

	chimara_if_set_preferred_interpreter(CHIMARA_IF(glk), format, interpreter);

	/* Display the new setting in the list */
	GtkTreeIter iter;
	GtkTreePath *path = gtk_tree_path_new_from_string(path_string);
	gtk_tree_model_get_iter(GTK_TREE_MODEL(preferred_list), &iter, path);
	gtk_tree_path_free(path);
	gtk_list_store_set(preferred_list, &iter,
		1, interpreter_to_display_string(interpreter),
		-1);

	/* Save the new settings in the preferences file */
	extern GSettings *prefs_settings;
	GVariantBuilder *builder = g_variant_builder_new( G_VARIANT_TYPE("a{ss}") );
	unsigned int count;
	for(count = 0; count < CHIMARA_IF_NUM_FORMATS; count++) {
		g_variant_builder_add(builder, "{ss}",
			format_to_string(count),
			interpreter_to_string(chimara_if_get_preferred_interpreter(CHIMARA_IF(glk), count)));
	}
	g_settings_set(prefs_settings, "preferred-interpreters", "a{ss}", builder);
	g_variant_builder_unref(builder);
}
Пример #16
0
static gboolean
_sync_default_cb (OlConfigProxy *config)
{
  OlConfigProxyPrivate *priv = OL_CONFIG_PROXY_GET_PRIVATE (config);
  priv->default_sync_handler = 0;
  if (priv->default_builder != NULL)
  {
    GError *error = NULL;
    GVariant *ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (config),
                                            "SetDefaultValues",
                                            g_variant_new ("(a{sv})", priv->default_builder),
                                            G_DBUS_CALL_FLAGS_NO_AUTO_START,
                                            -1,   /* timeout_secs */
                                            NULL, /* cancellable */
                                            &error);
    if (ret)
    {
      g_variant_unref (ret);
    }
    else
    {
      ol_errorf ("Cannot set config default values: %s\n", error->message);
      g_error_free (error);
    }
    g_variant_builder_unref (priv->default_builder);
    priv->default_builder = NULL;
  }
  return FALSE;
}
Пример #17
0
/**
 * EscalateModuleStart:
 * @self: PAM module being described in the start message.
 * @action: Action being called on this module, like
 * #ESCALATE_MESSAGE_ACTION_AUTHENTICATE when pam_sm_authenticate() is being
 * used.
 * @error: (out)(allow-none): Error return location or #NULL.
 *
 * Returns: #TRUE if the message was sent.
 */
gboolean EscalateModuleStart(EscalateModule *self, EscalateMessageAction action,
                             GError **error) {
  GVariantBuilder *items = NULL;
  EscalateMessage *message = NULL;
  gboolean result = FALSE;

  items = g_variant_builder_new(G_VARIANT_TYPE("a{ims}"));
  for (guint i = 0; i < G_N_ELEMENTS(escalate_module_include_items); i++) {
    gint item = escalate_module_include_items[i];
    if (!EscalateModuleStartAddItem(self, items, item, error)) {
      goto done;
    }
  }

  // TODO(vonhollen): Include environment variables?
  message = EscalateMessageNew(ESCALATE_MESSAGE_TYPE_START, action, self->flags,
                               self->username, items);
  if (EscalateSubprocessSend(self->child, message, error))
    result = TRUE;

done:
  if (message)
    EscalateMessageUnref(message);
  g_variant_builder_unref(items);
  return result;
}
Пример #18
0
/**
 * EscalateUtilPamEnvToVariant:
 * @pamh: PAM handle with environment variables to serialize.
 * @error: (out)(allow-none): Error return location or #NULL.
 *
 * Returns: New GVariantBuilder with a map of environment key to value strings,
 * or #NULL if there was an error getting the values.
 */
GVariantBuilder *EscalateUtilPamEnvToVariant(pam_handle_t *pamh,
                                             GError **error) {
  char **env_list = NULL;
  GVariantBuilder *builder = NULL;

  env_list = pam_getenvlist(pamh);
  if (!env_list) {
    g_set_error(error, ESCALATE_UTIL_ERROR, ESCALATE_UTIL_ERROR_ENVIRONMENT,
                "Failed to fetch PAM environment list.");
    return NULL;
  }

  builder = g_variant_builder_new(G_VARIANT_TYPE("a{ss}"));
  for (guint i = 0; builder && env_list[i]; i++) {
    gchar **parts = g_strsplit(env_list[i], "=", 2);
    if (parts[0] && parts[1] && strlen(parts[0]) > 0) {
      g_variant_builder_add(builder, "{ss}", parts[0], parts[1]);
    } else {
      g_set_error(error, ESCALATE_UTIL_ERROR, ESCALATE_UTIL_ERROR_ENVIRONMENT,
                  "Failed to parse environment variable '%s'", env_list[i]);
      g_variant_builder_unref(builder);
      builder = NULL;
    }
    g_strfreev(parts);
  }

  for (guint i = 0; env_list[i]; i++) {
    free(env_list[i]);
  }
  free(env_list);

  return builder;
}
Пример #19
0
static void hev_dbus_object_test_notify_value_handler(GObject *obj,
			GParamSpec *pspec, gpointer user_data)
{
	HevDBusInterfaceTest *self = HEV_DBUS_INTERFACE_TEST(user_data);
	HevDBusInterfaceTestPrivate *priv = HEV_DBUS_INTERFACE_TEST_GET_PRIVATE(self);
	GDBusConnection *connection = NULL;
	const gchar *object_path = NULL;
	GVariantBuilder *builder = NULL;
	GVariant *variant = NULL;
	gchar *p = NULL;

	g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__);

	connection = g_dbus_interface_skeleton_get_connection(G_DBUS_INTERFACE_SKELETON(self));
	object_path = g_dbus_interface_skeleton_get_object_path(G_DBUS_INTERFACE_SKELETON(self));

	builder = g_variant_builder_new(G_VARIANT_TYPE_VARDICT);
	g_object_get(obj, "value", &p, NULL);
	g_variant_builder_add(builder, "{sv}", "Value", g_variant_new_string(p));
	variant = g_variant_builder_end(builder);
	g_variant_builder_unref(builder);
	variant = g_variant_new("(@a{sv})", variant);
	g_free(p);

	g_dbus_connection_emit_signal(connection, NULL, object_path,
				"org.freedesktop.DBus.Properties", "PropertiesChanged",
				variant, NULL);

	g_variant_unref(variant);
}
Пример #20
0
GVariant *
_secret_session_encode_secret (SecretSession *session,
                               SecretValue *value)
{
	GVariantBuilder *builder;
	GVariant *result = NULL;
	GVariantType *type;
	gboolean ret;

	g_return_val_if_fail (session != NULL, NULL);
	g_return_val_if_fail (value != NULL, NULL);

	type = g_variant_type_new ("(oayays)");
	builder = g_variant_builder_new (type);

#ifdef WITH_GCRYPT
	if (session->key)
		ret = service_encode_aes_secret (session, value, builder);
	else
#endif
		ret = service_encode_plain_secret (session, value, builder);
	if (ret)
		result = g_variant_builder_end (builder);

	g_variant_builder_unref (builder);
	g_variant_type_free (type);
	return result;
}
Пример #21
0
/*
** DBus method call: "CrownChallenge"
*/
gboolean on_handle_crown_challenge ( Warfacebot *object,
									 GDBusMethodInvocation *invocation )
{
	if ( invalidated )
	{
		struct list *ml = session.wf.missions;

		GVariantBuilder *marr_builder;

		if ( marr != NULL )
			g_variant_unref ( marr );

		marr_builder = g_variant_builder_new ( G_VARIANT_TYPE ( "a(sssii)" ) );

		list_foreach ( ml, (f_list_callback) mlist_to_array, marr_builder );

		marr = g_variant_new ( "a(sssii)", marr_builder );

		g_variant_ref ( marr );

		g_variant_builder_unref ( marr_builder );

		invalidated = FALSE;
	}

	warfacebot_complete_crown_challenge ( object, invocation, marr );

	return TRUE;
}
Пример #22
0
void dls_async_task_delete(dls_async_task_t *cb_data)
{
	switch (cb_data->task.type) {
	case DLS_TASK_GET_CHILDREN:
	case DLS_TASK_SEARCH:
		if (cb_data->ut.bas.vbs)
			g_ptr_array_unref(cb_data->ut.bas.vbs);
		break;
	case DLS_TASK_GET_ALL_PROPS:
	case DLS_TASK_GET_RESOURCE:
		if (cb_data->ut.get_all.vb)
			g_variant_builder_unref(cb_data->ut.get_all.vb);
		break;
	case DLS_TASK_UPLOAD_TO_ANY:
	case DLS_TASK_UPLOAD:
		g_free(cb_data->ut.upload.mime_type);
		break;
	case DLS_TASK_UPDATE_OBJECT:
		g_free(cb_data->ut.update.current_tag_value);
		g_free(cb_data->ut.update.new_tag_value);
		break;
	case DLS_TASK_CREATE_PLAYLIST:
	case DLS_TASK_CREATE_PLAYLIST_IN_ANY:
		g_free(cb_data->ut.playlist.didl);
		if (cb_data->ut.playlist.collection)
			g_object_unref(cb_data->ut.playlist.collection);
		break;
	default:
		break;
	}

	if (cb_data->cancellable)
		g_object_unref(cb_data->cancellable);
}
Пример #23
0
/**
 * autolink_emitsig_recvmcuinfo - recv mcu info frome uart, 
 *                                and emit signal mcuinfo to other process
 *
 * @pmcu_info  : mcu info
 *
 * returns:
 *     TRUE
 */
extern gboolean
autolink_emitsig_recvmcuinfo (const autolink_mcu_info_dbus_ptr pmcu_info)
{
  GVariantBuilder *builder;
  GVariant *value;
  guchar *pos;
  int i;

  if (pmcu_info == NULL) return FALSE;

  DBG_LOG ("emit signal mcuinfo, info type: %d.\n", pmcu_info->mcu_info_type);

  pos = pmcu_info;

  builder = g_variant_builder_new (G_VARIANT_TYPE ("ay"));

  for (i = 0; i < MCUINFO_LEN; i++) {
    g_variant_builder_add (builder, "y", *pos);
    pos++;
  }

  value = g_variant_new ("(ay)", builder);
  g_variant_builder_unref (builder);

  gdbus_mcuinfo_emit_recv_mcuinfo(pSkeleton, value);

  return TRUE;
}
Пример #24
0
 static void CurrentSkin(cDBusObject *Object, GVariant *Parameters, GDBusMethodInvocation *Invocation)
 {
   GVariantBuilder *ret = g_variant_builder_new(G_VARIANT_TYPE("(i(iss))"));
   g_variant_builder_add(ret, "i", 900);
   g_variant_builder_add_value(ret, BuildSkin(Skins.Current()));
   g_dbus_method_invocation_return_value(Invocation, g_variant_builder_end(ret));
   g_variant_builder_unref(ret);
 };
Пример #25
0
void  cDBusHelper::SendReply(GDBusMethodInvocation *Invocation, int  ReplyCode, const char *ReplyMessage)
{
  GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("(is)"));
  g_variant_builder_add(builder, "i", ReplyCode);
  g_variant_builder_add(builder, "s", ReplyMessage);
  g_dbus_method_invocation_return_value(Invocation, g_variant_builder_end(builder));
  g_variant_builder_unref(builder);
}
static void _icd_observe_context_free(void *ctx)
{
	struct icd_observe_context *observe_ctx = ctx;

	g_variant_builder_unref(observe_ctx->options);
	free(observe_ctx->bus_name);
	free(observe_ctx);
}
Пример #27
0
void cDBusUpstart::EmitPluginEvent(cDBusConnection *Connection, const char *Action)
{
  if ((Connection == NULL) || (Action == NULL) || (*Action == 0))
     return;
  GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("(sasb)"));
  g_variant_builder_add(builder, "s", "vdr-plugin");
  GVariantBuilder *array = g_variant_builder_new(G_VARIANT_TYPE("as"));
  cPlugin *plugin;
  for (int i = 0; (plugin = cPluginManager::GetPlugin(i)) != NULL; i++)
      g_variant_builder_add(array, "s", *cString::sprintf("%s=%s", plugin->Name(), Action));
  g_variant_builder_add_value(builder, g_variant_builder_end(array));
  g_variant_builder_add(builder, "b", FALSE);

  Connection->CallMethod(new cDBusMethodCall("com.ubuntu.Upstart", "/com/ubuntu/Upstart", "com.ubuntu.Upstart0_6", "EmitEvent", g_variant_builder_end(builder), OnUpstartReply, NULL));

  g_variant_builder_unref(array);
  g_variant_builder_unref(builder);
}
Пример #28
0
 static void SendReply(GDBusMethodInvocation *Invocation, int ReplyCode, const char *ReplyMessage, int ShExitCode, const char *ShParameter)
 {
   GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("(isis)"));
   g_variant_builder_add(builder, "i", ReplyCode);
   g_variant_builder_add(builder, "s", ReplyMessage);
   g_variant_builder_add(builder, "i", ShExitCode);
   g_variant_builder_add(builder, "s", ShParameter);
   g_dbus_method_invocation_return_value(Invocation, g_variant_builder_end(builder));
   g_variant_builder_unref(builder);
 };
Пример #29
0
  static void List(cDBusObject *Object, GVariant *Parameters, GDBusMethodInvocation *Invocation)
  {
    recordings.Update(true);

    GVariantBuilder *array = g_variant_builder_new(G_VARIANT_TYPE("a(ia(sv))"));
    for (cRecording *r = recordings.First(); r; r = recordings.Next(r))
        g_variant_builder_add_value(array, BuildRecording(r));
    GVariant *a = g_variant_builder_end(array);
    g_dbus_method_invocation_return_value(Invocation, g_variant_new_tuple(&a, 1));
    g_variant_builder_unref(array);
  };
Пример #30
0
/**
 * Convert an array of Scheme objects to a GVariant that serves as
 * the primary parameter to g_dbus_proxy_call.
 */
static GVariant *
scheme_objects_to_parameter_tuple (gchar *fun,
                                   int arity,
                                   Scheme_Object **objects,
                                   GDBusArgInfo *formals[])
{
  int i;                // Counter variable
  GVariantBuilder *builder;
                        // Something to let us build tuples
  GVariant *result;     // The GVariant we build
  GVariant *actual;     // One actual

  builder = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);

  // Annotations for garbage collector.
  // Since we're converting Scheme_Object values to GVariants, it should
  // not be the case that we have an "allocating call".  However, I am
  // worried that conversion to a string, which requires
  // scheme_char_string_to_byte_string_locale, might be considered an
  // allocating call.  So let's be in the safe side.  The sample code suggests
  // that we can put an array of GObjects in a single variable (see
  // the supplied makeadder3m.c for more details).
  MZ_GC_DECL_REG (1);
  MZ_GC_VAR_IN_REG (0, objects);
  MZ_GC_REG ();

  // Process all the parameters
  for (i = 0; i < arity; i++)
    {
      actual = scheme_object_to_parameter (objects[i], formals[i]->signature);
      // If we can't convert the parameter, we give up.
      if (actual == NULL)
        {
          // Early exit - Clean up for garbage collection
          MZ_GC_UNREG ();
          // Get rid of the builder
          g_variant_builder_unref (builder);
          // And return an arror message.
          scheme_wrong_type (fun, 
                             dbus_signature_to_string (formals[i]->signature), 
                             i, 
                             arity, 
                             objects);
        } // If we could not convert
      // Otherwise, we add the value to the builder and go on
      g_variant_builder_add_value (builder, actual);
    } // for

  // Clean up garbage collection info.
  MZ_GC_UNREG ();
  // And we're done.
  result = g_variant_builder_end (builder);
  return result;
} // scheme_objects_to_parameter_tuple