Ejemplo n.º 1
0
void
gclue_locator_stop (GClueLocator        *locator,
                    GCancellable        *cancellable,
                    GAsyncReadyCallback  callback,
                    gpointer             user_data)
{
        GSimpleAsyncResult *simple;

        g_return_if_fail (GCLUE_IS_LOCATOR (locator));

        gclue_locator_stop_sync (locator);

        simple = g_simple_async_result_new (G_OBJECT (locator),
                                            callback,
                                            user_data,
                                            gclue_locator_stop);
        g_simple_async_result_complete_in_idle (simple);

        g_object_unref (simple);
}
Ejemplo n.º 2
0
void mpd_async_request(MpdAsyncCallback * callback, gpointer callback_data, MpdAsyncFunction * function,
					   gpointer function_data)
{
	gchar *string = NULL;
	GSimpleAsyncResult *res = NULL;
	MpdAsyncData *data = g_new0(MpdAsyncData, 1);
	data->mi = mpd_new_default();
	data->function = function;
	data->function_data = function_data;
	data->callback = callback;
	data->callback_data = callback_data;
	/**
     * Set Hostname
     */
	string = connection_get_hostname();
	mpd_set_hostname(data->mi, string);
	/**
	 * Set port
	 */
	mpd_set_port(data->mi, connection_get_port());
	/**
	 * Timeout
	 */
	mpd_set_connection_timeout(data->mi,
							   cfg_get_single_value_as_float_with_default(config, "connection", "timeout",
																		  DEFAULT_TIMEOUT));

	if (connection_use_auth())
	{
		string = connection_get_password();
		mpd_set_password(data->mi, string);
	} else
	{
		mpd_set_password(data->mi, "");
	}

	res = g_simple_async_result_new(NULL, __mpd_async_simple_callback, NULL, mpd_async_request);
	g_simple_async_result_set_op_res_gpointer(G_SIMPLE_ASYNC_RESULT(res), data, __mpd_async_result_free_data);
	g_log(LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Start async thread %p\n", data);
	g_simple_async_result_run_in_thread(res, __async_handler_function, G_PRIORITY_LOW, NULL);
}
Ejemplo n.º 3
0
/**
 * gom_repository_migrate_sync:
 * @repository: (in): A #GomRepository.
 * @version: (in): The version to migrate to.
 * @migrator: (in) (scope call): A function to perform the migrations.
 * @migrator_data: (in): User data for @migrator.
 * @error: a #GError
 *
 * Performs a migration on the underlying database. This will
 * call @migrator from the SQLite thread for each migration to perform.
 *
 * Returns: #TRUE in case of success.
 */
gboolean
gom_repository_migrate_sync (GomRepository          *repository,
                             guint                   version,
                             GomRepositoryMigrator   migrator,
                             gpointer                migrator_data,
                             GError                **error)
{
   GomRepositoryPrivate *priv;
   GSimpleAsyncResult *simple;
   GAsyncQueue *queue;
   gboolean ret;

   g_return_val_if_fail(GOM_IS_REPOSITORY(repository), FALSE);
   g_return_val_if_fail(migrator != NULL, FALSE);
   g_return_val_if_fail(version >= 1, FALSE);

   priv = repository->priv;

   queue = g_async_queue_new();

   simple = g_simple_async_result_new(G_OBJECT(repository), NULL, NULL,
                                      gom_repository_migrate_sync);
   g_object_set_data(G_OBJECT(simple), "version", GINT_TO_POINTER(version));
   g_object_set_data(G_OBJECT(simple), "migrator", migrator);
   g_object_set_data(G_OBJECT(simple), "migrator_data", migrator_data);
   g_object_set_data(G_OBJECT(simple), "queue", queue);

   gom_adapter_queue_write(priv->adapter,
                           gom_repository_migrate_cb,
                           simple);
   g_async_queue_pop(queue);
   g_async_queue_unref(queue);

   if (!(ret = g_simple_async_result_get_op_res_gboolean(simple))) {
      g_simple_async_result_propagate_error(simple, error);
   }

   g_object_unref(simple);

   return ret;
}
void hev_impathy_tls_certificate_prepare_async(HevImpathyTLSCertificate *self,
			GAsyncReadyCallback callback, gpointer user_data)
{
	HevImpathyTLSCertificatePrivate *priv = NULL;

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

	g_return_if_fail(HEV_IS_IMPATHY_TLS_CERTIFICATE(self));
	priv = HEV_IMPATHY_TLS_CERTIFICATE_GET_PRIVATE(self);

	/* emit an error if we're already preparing the object */
	if(NULL != priv->async_prepare_res)
	{
		g_simple_async_report_error_in_idle(G_OBJECT(self),
					callback, user_data,
					G_IO_ERROR, G_IO_ERROR_PENDING,
					"%s",
					"Prepare operation already in progress"
					" on the TLS certificate.");
		return;
	}

	/* if the object is already prepared, just complete in idle */
	if(priv->is_prepared)
	{
		tp_simple_async_report_success_in_idle(G_OBJECT(self),
					callback, user_data,
					hev_impathy_tls_certificate_prepare_async);
		return;
	}

	priv->async_prepare_res = g_simple_async_result_new(G_OBJECT(self),
				callback, user_data,
				hev_impathy_tls_certificate_prepare_async);

	/* call GetAll() on the certificate */
	tp_cli_dbus_properties_call_get_all(self,
				-1, TP_IFACE_AUTHENTICATION_TLS_CERTIFICATE,
				tls_certificate_got_all_handler, NULL, NULL,
				G_OBJECT(self));
}
void
mm_iface_modem_messaging_initialize (MMIfaceModemMessaging *self,
                                     GCancellable *cancellable,
                                     GAsyncReadyCallback callback,
                                     gpointer user_data)
{
    InitializationContext *ctx;
    MmGdbusModemMessaging *skeleton = NULL;

    /* Did we already create it? */
    g_object_get (self,
                  MM_IFACE_MODEM_MESSAGING_DBUS_SKELETON, &skeleton,
                  NULL);
    if (!skeleton) {
        skeleton = mm_gdbus_modem_messaging_skeleton_new ();
        mm_gdbus_modem_messaging_set_supported_storages (skeleton, NULL);

        /* Bind our Default messaging property */
        g_object_bind_property (self, MM_IFACE_MODEM_MESSAGING_SMS_DEFAULT_STORAGE,
                                skeleton, "default-storage",
                                G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);

        g_object_set (self,
                      MM_IFACE_MODEM_MESSAGING_DBUS_SKELETON, skeleton,
                      NULL);
    }

    /* Perform async initialization here */

    ctx = g_new0 (InitializationContext, 1);
    ctx->self = g_object_ref (self);
    ctx->cancellable = g_object_ref (cancellable);
    ctx->result = g_simple_async_result_new (G_OBJECT (self),
                                             callback,
                                             user_data,
                                             mm_iface_modem_messaging_initialize);
    ctx->step = INITIALIZATION_STEP_FIRST;
    ctx->skeleton = skeleton;

    interface_initialization_step (ctx);
}
static void
rejilla_track_image_cfg_get_info (RejillaTrackImageCfg *track,
				  const gchar *uri)
{
	RejillaTrackImageCfgPrivate *priv;
	RejillaTrackImageInfo *info;
	GSimpleAsyncResult *res;

	priv = REJILLA_TRACK_IMAGE_CFG_PRIVATE (track);

	/* Cancel a possible ongoing thread */
	if (priv->cancel) {
		g_cancellable_cancel (priv->cancel);
		g_object_unref (priv->cancel);
		priv->cancel = NULL;
	}

	if (priv->error) {
		g_error_free (priv->error);
		priv->error = NULL;
	}

	res = g_simple_async_result_new (G_OBJECT (track),
					 rejilla_track_image_cfg_get_info_cb,
					 NULL,
					 rejilla_track_image_cfg_get_info);

	priv->cancel = g_cancellable_new ();

	info = g_new0 (RejillaTrackImageInfo, 1);
	info->uri = g_strdup (uri);
	info->format = priv->format;
	info->cancel = g_object_ref (priv->cancel);

	g_simple_async_result_set_op_res_gpointer (res, info, rejilla_track_image_info_free);
	g_simple_async_result_run_in_thread (res,
					     rejilla_track_image_cfg_get_info_thread,
					     G_PRIORITY_LOW,
					     priv->cancel);
	g_object_unref (res);
}
Ejemplo n.º 7
0
static void
seahorse_ldap_source_import_async (SeahorseServerSource *source,
                                   GInputStream *input,
                                   GCancellable *cancellable,
                                   GAsyncReadyCallback callback,
                                   gpointer user_data)
{
	SeahorseLDAPSource *self = SEAHORSE_LDAP_SOURCE (source);
	source_import_closure *closure;
	GSimpleAsyncResult *res;
	gchar *keydata;
	guint len;

	res = g_simple_async_result_new (G_OBJECT (source), callback, user_data,
	                                 seahorse_ldap_source_import_async);
	closure = g_new0 (source_import_closure, 1);
	closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
	closure->current_index = -1;
	g_simple_async_result_set_op_res_gpointer (res, closure, source_import_free);

	closure->keydata =g_ptr_array_new_with_free_func (g_free);
	for (;;) {
		GString *buf = g_string_sized_new (2048);
		len = seahorse_util_read_data_block (buf, input, "-----BEGIN PGP PUBLIC KEY BLOCK-----",
		                                     "-----END PGP PUBLIC KEY BLOCK-----");
		if (len > 0) {
			keydata = g_string_free (buf, FALSE);
			g_ptr_array_add (closure->keydata, keydata);
			seahorse_progress_prep (closure->cancellable, keydata, NULL);
		} else {
			g_string_free (buf, TRUE);
			break;
		}
	}

	seahorse_ldap_source_connect_async (self, cancellable,
	                                    on_import_connect_completed,
	                                    g_object_ref (res));

	g_object_unref (res);
}
Ejemplo n.º 8
0
void
mmcli_get_modem (GDBusConnection *connection,
                 const gchar *path_or_index,
                 GCancellable *cancellable,
                 GAsyncReadyCallback callback,
                 gpointer user_data)
{
    GetModemContext *ctx;

    ctx = g_new0 (GetModemContext, 1);
    ctx->modem_path = get_modem_path (path_or_index);
    ctx->result = g_simple_async_result_new (G_OBJECT (connection),
                                             callback,
                                             user_data,
                                             mmcli_get_modem);

    mmcli_get_manager (connection,
                       cancellable,
                       (GAsyncReadyCallback)get_manager_ready,
                       ctx);
}
Ejemplo n.º 9
0
void
mm_manager_set_logging (MMManager           *manager,
                        const gchar         *level,
                        GCancellable        *cancellable,
                        GAsyncReadyCallback  callback,
                        gpointer             user_data)
{
    GSimpleAsyncResult *result;

    result = g_simple_async_result_new (G_OBJECT (manager),
                                        callback,
                                        user_data,
                                        mm_manager_set_logging);

    mm_gdbus_org_freedesktop_modem_manager1_call_set_logging (
        manager->priv->manager_iface_proxy,
        level,
        cancellable,
        (GAsyncReadyCallback)set_logging_ready,
        result);
}
Ejemplo n.º 10
0
void
ostree_checksum_file_async (GFile                 *f,
                            OstreeObjectType       objtype,
                            int                    io_priority,
                            GCancellable          *cancellable,
                            GAsyncReadyCallback    callback,
                            gpointer               user_data)
{
  GSimpleAsyncResult  *res;
  ChecksumFileAsyncData *data;

  data = g_new0 (ChecksumFileAsyncData, 1);
  data->f = g_object_ref (f);
  data->objtype = objtype;

  res = g_simple_async_result_new (G_OBJECT (f), callback, user_data, ostree_checksum_file_async);
  g_simple_async_result_set_op_res_gpointer (res, data, (GDestroyNotify)checksum_file_async_data_free);
  
  g_simple_async_result_run_in_thread (res, checksum_file_async_thread, io_priority, cancellable);
  g_object_unref (res);
}
Ejemplo n.º 11
0
static GetIpConfig3gppContext *
get_ip_config_3gpp_context_new (MMBroadbandBearerHso *self,
                                MMBaseModem *modem,
                                MMAtSerialPort *primary,
                                guint cid,
                                GAsyncReadyCallback callback,
                                gpointer user_data)
{
    GetIpConfig3gppContext *ctx;

    ctx = g_new0 (GetIpConfig3gppContext, 1);
    ctx->self = g_object_ref (self);
    ctx->modem = g_object_ref (modem);
    ctx->primary = g_object_ref (primary);
    ctx->cid = cid;
    ctx->result = g_simple_async_result_new (G_OBJECT (self),
                                             callback,
                                             user_data,
                                             get_ip_config_3gpp_context_new);
    return ctx;
}
static void
modem_after_power_up (MMIfaceModem *self,
                      GAsyncReadyCallback callback,
                      gpointer user_data)
{
    MMBroadbandModemOption *option = MM_BROADBAND_MODEM_OPTION (self);
    GSimpleAsyncResult *result;

    /* Some Option devices return OK on +CFUN=1 right away but need some time
     * to finish initialization.
     */
    result = g_simple_async_result_new (G_OBJECT (self),
                                        callback,
                                        user_data,
                                        modem_after_power_up);
    g_warn_if_fail (option->priv->after_power_up_wait_id == 0);
    option->priv->after_power_up_wait_id =
        g_timeout_add_seconds (10,
                               (GSourceFunc)after_power_up_wait_cb,
                               result);
}
Ejemplo n.º 13
0
void
g_vfs_mount_info_query_xdg_volume_info (GFile               *directory,
                                        GCancellable        *cancellable,
                                        GAsyncReadyCallback  callback,
                                        gpointer             user_data)
{
  GSimpleAsyncResult *simple;
  GFile *file;

  simple = g_simple_async_result_new (G_OBJECT (directory),
                                      callback,
                                      user_data,
                                      g_vfs_mount_info_query_xdg_volume_info);

  file = g_file_resolve_relative_path (directory, ".xdg-volume-info");
  g_file_load_contents_async (file,
                              cancellable,
                              on_xdg_volume_info_loaded,
                              simple);
  g_object_unref (file);
}
Ejemplo n.º 14
0
static GUnixResolverRequest *
resolve_async (GUnixResolver         *gur,
               _g_asyncns_query_t    *qy,
               GUnixResolverFunc      process_func,
               GUnixResolverFunc      free_func,
               GCancellable          *cancellable,
               GAsyncReadyCallback    callback,
               gpointer               user_data,
               gpointer               tag)
{
  GSimpleAsyncResult *result;
  GUnixResolverRequest *req;

  result = g_simple_async_result_new (G_OBJECT (gur), callback, user_data, tag);
  req = g_unix_resolver_request_new (gur, qy, process_func, free_func,
                                     cancellable, result);
  g_object_unref (result);
  _g_asyncns_setuserdata (gur->asyncns, qy, req);

  return req;
}
Ejemplo n.º 15
0
static void
sierra_custom_init (MMPortProbe *probe,
                    MMAtSerialPort *port,
                    GCancellable *cancellable,
                    GAsyncReadyCallback callback,
                    gpointer user_data)
{
    SierraCustomInitContext *ctx;

    ctx = g_slice_new (SierraCustomInitContext);
    ctx->result = g_simple_async_result_new (G_OBJECT (probe),
                                             callback,
                                             user_data,
                                             sierra_custom_init);
    ctx->probe = g_object_ref (probe);
    ctx->port = g_object_ref (port);
    ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
    ctx->retries = 3;

    sierra_custom_init_step (ctx);
}
static void
modem_3gpp_cleanup_unsolicited_events (MMIfaceModem3gpp *self,
                                       GAsyncReadyCallback callback,
                                       gpointer user_data)
{
    GSimpleAsyncResult *result;

    result = g_simple_async_result_new (G_OBJECT (self),
                                        callback,
                                        user_data,
                                        modem_3gpp_cleanup_unsolicited_events);

    /* Our own cleanup first */
    set_unsolicited_events_handlers (MM_BROADBAND_MODEM_MBM (self), FALSE);

    /* And now chain up parent's cleanup */
    iface_modem_3gpp_parent->cleanup_unsolicited_events (
        self,
        (GAsyncReadyCallback)parent_cleanup_unsolicited_events_ready,
        result);
}
static void
modem_create_bearer (MMIfaceModem *self,
                     MMBearerProperties *properties,
                     GAsyncReadyCallback callback,
                     gpointer user_data)
{
    GSimpleAsyncResult *result;

    /* Set a new ref to the bearer object as result */
    result = g_simple_async_result_new (G_OBJECT (self),
                                        callback,
                                        user_data,
                                        modem_create_bearer);

    /* We just create a MMBroadbandBearer */
    mm_broadband_bearer_novatel_new (MM_BROADBAND_MODEM_NOVATEL (self),
                                     properties,
                                     NULL, /* cancellable */
                                     (GAsyncReadyCallback)broadband_bearer_new_ready,
                                     result);
}
Ejemplo n.º 18
0
void
tpaw_keyring_delete_account_password_async (TpAccount *account,
    GAsyncReadyCallback callback,
    gpointer user_data)
{
  GSimpleAsyncResult *simple;
  const gchar *account_id;

  g_return_if_fail (TP_IS_ACCOUNT (account));

  simple = g_simple_async_result_new (G_OBJECT (account), callback,
      user_data, tpaw_keyring_delete_account_password_async);

  account_id = tp_proxy_get_object_path (account) +
    strlen (TP_ACCOUNT_OBJECT_PATH_BASE);

  DEBUG ("Deleting password for %s", account_id);

#ifdef HAVE_UOA
    {
      const gchar *provider;

      provider = tp_account_get_storage_provider (account);
      if (!tp_strdiff (provider, TPAW_UOA_PROVIDER))
        {
          /* I see no other way to forget the stored password than overwriting
           * with an empty one. */
          uoa_set_account_password (account, "", FALSE, simple);
          g_object_unref (simple);
          return;
        }
    }
#endif

  secret_password_clear (&account_keyring_schema, NULL,
          items_delete_cb, simple,
          "account-id", account_id,
          "param-name", "password",
          NULL);
}
Ejemplo n.º 19
0
void
nm_ppp_manager_stop (NMPPPManager *manager,
                     GCancellable *cancellable,
                     GAsyncReadyCallback callback,
                     gpointer user_data)
{
	NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
	StopContext *ctx;

	ctx = g_slice_new0 (StopContext);
	ctx->manager = g_object_ref (manager);
	ctx->result = g_simple_async_result_new (G_OBJECT (manager),
	                                         callback,
	                                         user_data,
	                                         nm_ppp_manager_stop);

	/* Setup cancellable */
	ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
	if (stop_context_complete_if_cancelled (ctx))
		return;

	/* Cleanup internals */
	_ppp_cleanup (manager);

	/* If no pppd running, we're done */
	if (!priv->pid) {
		stop_context_complete (ctx);
		return;
	}

	/* No cancellable operation, so just wait until it returns always */
	nm_utils_kill_child_async (priv->pid,
	                           SIGTERM,
	                           LOGD_PPP,
	                           "pppd",
	                           2000,
	                           (NMUtilsKillChildAsyncCb) kill_child_ready,
	                           ctx);
	priv->pid = 0;
}
Ejemplo n.º 20
0
/* This function can be called in any thread */
void
tracker_extract_file (TrackerExtract      *extract,
                      const gchar         *file,
                      const gchar         *mimetype,
                      const gchar         *graph,
                      GCancellable        *cancellable,
                      GAsyncReadyCallback  cb,
                      gpointer             user_data)
{
	GSimpleAsyncResult *res;
	GError *error = NULL;
	TrackerExtractTask *task;

	g_return_if_fail (TRACKER_IS_EXTRACT (extract));
	g_return_if_fail (file != NULL);
	g_return_if_fail (cb != NULL);

#ifdef THREAD_ENABLE_TRACE
	g_debug ("Thread:%p <-- File:'%s' - Extracting\n",
	         g_thread_self (),
	         file);
#endif /* THREAD_ENABLE_TRACE */

	res = g_simple_async_result_new (G_OBJECT (extract), cb, user_data, NULL);

	task = extract_task_new (extract, file, mimetype, graph,
	                         cancellable, G_ASYNC_RESULT (res), &error);

	if (error) {
		g_warning ("Could not get mimetype, %s", error->message);
		g_simple_async_result_set_from_error (res, error);
		g_simple_async_result_complete_in_idle (res);
		g_error_free (error);
	} else {
		g_idle_add ((GSourceFunc) dispatch_task_cb, task);
	}

	/* Task takes a ref and if this fails, we want to unref anyway */
	g_object_unref (res);
}
Ejemplo n.º 21
0
void hev_serial_port_close_async(HevSerialPort *self,
			GCancellable *cancellable, GAsyncReadyCallback callback,
			gpointer user_data)
{
	HevSerialPortPrivate *priv = NULL;
	GSimpleAsyncResult *simple = NULL;

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

	g_return_if_fail(HEV_IS_SERIAL_PORT(self));
	priv = HEV_SERIAL_PORT_GET_PRIVATE(self);

	/* Simple async result */
	simple = g_simple_async_result_new(G_OBJECT(self),
				callback, user_data, hev_serial_port_close_async);
	g_simple_async_result_set_check_cancellable(simple, cancellable);

	g_simple_async_result_run_in_thread(simple, g_simple_async_close_thread_handler,
				G_PRIORITY_DEFAULT, cancellable);

	g_object_unref(simple);
}
Ejemplo n.º 22
0
static void fso_gsm_gsm_pdp_service_real_internal_status_update (FreeSmartphoneGSMPDP* base, const gchar* status, GHashTable* properties, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	FsoGsmGsmPdpService * self;
	FsoGsmGsmPdpServiceInternalStatusUpdateData* _data_;
	FsoGsmGsmPdpService* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	GHashTable* _tmp3_;
	GHashTable* _tmp4_;
	self = (FsoGsmGsmPdpService*) base;
	_data_ = g_slice_new0 (FsoGsmGsmPdpServiceInternalStatusUpdateData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, fso_gsm_gsm_pdp_service_real_internal_status_update);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, fso_gsm_gsm_pdp_service_real_internal_status_update_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = status;
	_tmp2_ = g_strdup (_tmp1_);
	_data_->status = _tmp2_;
	_tmp3_ = properties;
	_tmp4_ = _g_hash_table_ref0 (_tmp3_);
	_data_->properties = _tmp4_;
	fso_gsm_gsm_pdp_service_real_internal_status_update_co (_data_);
}
static void
create_bearer (MMIfaceModem *self,
               MMBearerProperties *properties,
               GAsyncReadyCallback callback,
               gpointer user_data)
{
    MMBearer *bearer;
    GSimpleAsyncResult *result;

    result = g_simple_async_result_new (G_OBJECT (self),
                                        callback,
                                        user_data,
                                        create_bearer);
    mm_dbg ("Creating Iridium bearer...");
    bearer = mm_bearer_iridium_new (MM_BROADBAND_MODEM_IRIDIUM (self),
                                    properties);
    g_simple_async_result_set_op_res_gpointer (result,
                                               bearer,
                                               (GDestroyNotify)g_object_unref);
    g_simple_async_result_complete_in_idle (result);
    g_object_unref (result);
}
Ejemplo n.º 24
0
static void
load_texture_async (StTextureCache       *cache,
                    AsyncTextureLoadData *data)
{
  if (data->file)
    {
      GSimpleAsyncResult *result;
      result = g_simple_async_result_new (G_OBJECT (cache), on_pixbuf_loaded, data, load_texture_async);
      g_simple_async_result_run_in_thread (result, load_pixbuf_thread, G_PRIORITY_DEFAULT, NULL);
      g_object_unref (result);
    }
  else if (data->icon_info)
    {
      StIconColors *colors = data->colors;
      if (colors)
        {
          GdkRGBA foreground_color;
          GdkRGBA success_color;
          GdkRGBA warning_color;
          GdkRGBA error_color;

          rgba_from_clutter (&foreground_color, &colors->foreground);
          rgba_from_clutter (&success_color, &colors->success);
          rgba_from_clutter (&warning_color, &colors->warning);
          rgba_from_clutter (&error_color, &colors->error);

          gtk_icon_info_load_symbolic_async (data->icon_info,
                                             &foreground_color, &success_color,
                                             &warning_color, &error_color,
                                             NULL, on_symbolic_icon_loaded, data);
        }
      else
        {
          gtk_icon_info_load_icon_async (data->icon_info, NULL, on_icon_loaded, data);
        }
    }
  else
    g_assert_not_reached ();
}
static void
initiate_authentication (PolkitAgentListener  *listener,
                         const gchar          *action_id,
                         const gchar          *message,
                         const gchar          *icon_name,
                         PolkitDetails        *details,
                         const gchar          *cookie,
                         GList                *identities,
                         GCancellable         *cancellable,
                         GAsyncReadyCallback   callback,
                         gpointer              user_data)
{
    ShellPolkitAuthenticationAgent *agent = SHELL_POLKIT_AUTHENTICATION_AGENT (listener);
    AuthRequest *request;

    request = g_new0 (AuthRequest, 1);
    request->agent = agent;
    request->action_id = g_strdup (action_id);
    request->message = g_strdup (message);
    request->icon_name = g_strdup (icon_name);
    request->details = g_object_ref (details);
    request->cookie = g_strdup (cookie);
    request->identities = g_list_copy (identities);
    g_list_foreach (request->identities, (GFunc) g_object_ref, NULL);
    request->simple = g_simple_async_result_new (G_OBJECT (listener),
                      callback,
                      user_data,
                      initiate_authentication);
    request->cancellable = cancellable;
    request->handler_id = g_cancellable_connect (request->cancellable,
                          G_CALLBACK (on_request_cancelled),
                          request,
                          NULL); /* GDestroyNotify for request */

    print_debug ("SCHEDULING %s cookie %s", request->action_id, request->cookie);
    agent->scheduled_requests = g_list_append (agent->scheduled_requests, request);

    maybe_process_next_request (agent);
}
Ejemplo n.º 26
0
void
nm_modem_deactivate_async (NMModem *self,
                           NMDevice *device,
                           GCancellable *cancellable,
                           GAsyncReadyCallback callback,
                           gpointer user_data)
{
	DeactivateContext *ctx;

	ctx = g_slice_new0 (DeactivateContext);
	ctx->self = g_object_ref (self);
	ctx->device = g_object_ref (device);
	ctx->result = g_simple_async_result_new (G_OBJECT (self),
	                                         callback,
	                                         user_data,
	                                         nm_modem_deactivate_async);
	ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;

	/* Start */
	ctx->step = DEACTIVATE_CONTEXT_STEP_FIRST;
	deactivate_step (ctx);
}
static void
app_chooser_online_pk_init_async (GAsyncInitable *init,
                                  int io_priority,
                                  GCancellable *cancellable,
                                  GAsyncReadyCallback callback,
                                  gpointer user_data)
{
  GtkAppChooserOnlinePk *self = GTK_APP_CHOOSER_ONLINE_PK (init);

  self->priv->init_result = g_simple_async_result_new (G_OBJECT (self),
                                                       callback, user_data,
                                                       _gtk_app_chooser_online_get_default_async);

  self->priv->watch_id =
    g_bus_watch_name (G_BUS_TYPE_SESSION,
                      "org.freedesktop.PackageKit",
                      G_BUS_NAME_WATCHER_FLAGS_AUTO_START,
                      pk_appeared_cb,
                      pk_vanished_cb,
                      self,
                      NULL);
}
Ejemplo n.º 28
0
void
g_vfs_mount_info_query_autorun_info (GFile               *directory,
                                     GCancellable        *cancellable,
                                     GAsyncReadyCallback  callback,
                                     gpointer             user_data)
{
  GSimpleAsyncResult *simple;

  simple = g_simple_async_result_new (G_OBJECT (directory),
                                      callback,
                                      user_data,
                                      g_vfs_mount_info_query_autorun_info);

  if (cancellable != NULL)
    g_object_set_data_full (G_OBJECT (simple), "cancellable", g_object_ref (cancellable), g_object_unref);

  _g_find_file_insensitive_async (directory,
                                  "autorun.inf",
                                  cancellable,
                                  on_autorun_located,
                                  simple);
}
void
empathy_connection_managers_prepare_async (
    EmpathyConnectionManagers *self,
    GAsyncReadyCallback callback,
    gpointer user_data)
{
  EmpathyConnectionManagersPriv *priv = GET_PRIV (self);
  GSimpleAsyncResult *result;

  result = g_simple_async_result_new (G_OBJECT (managers),
      callback, user_data, empathy_connection_managers_prepare_finish);

  if (priv->ready)
    {
      g_simple_async_result_complete_in_idle (result);
      g_object_unref (result);
      return;
    }

  g_signal_connect (self, "notify::ready", G_CALLBACK (notify_ready_cb),
      result);
}
Ejemplo n.º 30
0
static void pdp_qmi_real_statusUpdate (FsoGsmPdpHandler* base, const gchar* status, GHashTable* properties, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	PdpQmi * self;
	pdp_qmi_statusUpdateData* _data_;
	PdpQmi* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	GHashTable* _tmp3_;
	GHashTable* _tmp4_;
	self = (PdpQmi*) base;
	_data_ = g_slice_new0 (pdp_qmi_statusUpdateData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, pdp_qmi_real_statusUpdate);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, pdp_qmi_real_statusUpdate_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = status;
	_tmp2_ = g_strdup (_tmp1_);
	_data_->status = _tmp2_;
	_tmp3_ = properties;
	_tmp4_ = _g_hash_table_ref0 (_tmp3_);
	_data_->properties = _tmp4_;
	pdp_qmi_real_statusUpdate_co (_data_);
}