Example #1
0
    static void
fetion_contact_list_remove_contacts_async (TpBaseContactList *contact_list,
        TpHandleSet *contacts,
        GAsyncReadyCallback callback,
        gpointer user_data)
{
    FetionContactList *self = FETION_CONTACT_LIST (contact_list);
    FetionConnection *conn = FETION_CONNECTION (self->priv->conn);
    HybridAccount* account = conn->priv->account;

    TpHandleSet *removed = tp_handle_set_new (account->contact_repo);
    TpIntsetFastIter iter;
    TpHandle member;

    tp_intset_fast_iter_init (&iter, tp_handle_set_peek (contacts));

    while (tp_intset_fast_iter_next (&iter, &member))
    {
        HybridBuddy* buddy = hybrid_blist_find_buddy_by_handle(account,member);
        if (buddy == NULL)
            continue;
        if(!account->proto->info->im_ops->buddy_remove(account,buddy))
            continue;

        tp_handle_set_add (removed, member);
    }

    tp_base_contact_list_contacts_changed (contact_list, NULL, removed);

    tp_simple_async_report_success_in_idle ((GObject *) self, callback,
            user_data, fetion_contact_list_remove_contacts_async);
}
Example #2
0
static void
fetion_contact_list_request_subscription_async (
        TpBaseContactList *contact_list,
        TpHandleSet *contacts,
        const gchar *message,
        GAsyncReadyCallback callback,
        gpointer user_data)
{
    FetionContactList *self = FETION_CONTACT_LIST (contact_list);
    FetionConnection *conn = FETION_CONNECTION (self->priv->conn);
    HybridAccount* account = conn->priv->account;

    TpIntsetFastIter iter;
    TpHandle member;

    tp_intset_fast_iter_init (&iter, tp_handle_set_peek (contacts));

    while (tp_intset_fast_iter_next (&iter, &member))
    {
        HybridBuddy* buddy = hybrid_blist_find_buddy_by_handle(account,member);

        /* if they already authorized us, it's a no-op */
        if (buddy != NULL)
            continue;
        HybridGroup *default_group = hybrid_blist_find_group(account, "0"); 
        g_assert (default_group != NULL);

        account->proto->info->im_ops->buddy_add(account,default_group,tp_handle_inspect(account->contact_repo,member),NULL,message);

    }

    tp_simple_async_report_success_in_idle ((GObject *) self, callback,
            user_data, fetion_contact_list_request_subscription_async);
}
Example #3
0
    static void
fetion_contact_list_unpublish_async (TpBaseContactList *contact_list,
        TpHandleSet *contacts,
        GAsyncReadyCallback callback,
        gpointer user_data)
{
    // TODO
    FetionContactList *self = FETION_CONTACT_LIST (contact_list);
    tp_simple_async_report_success_in_idle ((GObject *) self, callback,
            user_data, fetion_contact_list_unpublish_async);
}
Example #4
0
    static void
fetion_contact_list_add_to_group_async (TpBaseContactList *contact_list,
        const gchar *group,
        TpHandleSet *contacts,
        GAsyncReadyCallback callback,
        gpointer user_data)
{
    FetionContactList *self = FETION_CONTACT_LIST (contact_list);
    FetionConnection *conn =
        FETION_CONNECTION (self->priv->conn);
    HybridAccount *account = conn->priv->account;
    HybridGroup *dest_group = hybrid_blist_find_group_by_name(account, group);
    if(dest_group == NULL)
        return ; // group must exist

    TpHandleSet *new_to_group = tp_handle_set_new (account->contact_repo);

    TpIntsetFastIter iter;
    TpHandle member;

    tp_intset_fast_iter_init (&iter, tp_handle_set_peek (contacts));

    while (tp_intset_fast_iter_next (&iter, &member))
    {
        HybridBuddy* buddy = hybrid_blist_find_buddy_by_handle(account,member);
        if (buddy == NULL)
            continue; // must existed
        HybridGroup *origin_group = buddy->parent;
        if (origin_group == dest_group)
            continue;

        if(!account->proto->info->im_ops->buddy_move(account,buddy,dest_group))
            continue;

        tp_handle_set_add (new_to_group, member);

    }


    if (!tp_handle_set_is_empty (new_to_group))
        tp_base_contact_list_groups_changed (contact_list, new_to_group, &group, 1,
                NULL, 0);

    tp_handle_set_destroy (new_to_group);
    tp_simple_async_report_success_in_idle ((GObject *) self, callback,
            user_data, fetion_contact_list_add_to_group_async);
}
Example #5
0
    static void
fetion_contact_list_set_contact_groups_async (TpBaseContactList *contact_list,
        TpHandle contact,
        const gchar * const *names,
        gsize n,
        GAsyncReadyCallback callback,
        gpointer user_data)
{
    FetionContactList *self = FETION_CONTACT_LIST (contact_list);
    FetionConnection *conn =
        FETION_CONNECTION (self->priv->conn);
    HybridAccount *account = conn->priv->account;


    if(n!=1)
        return ; // can only have one group

    //tp_base_contact_list_groups_created (contact_list, names, n); //here we assume the groups is already exist

    //tp_base_contact_list_one_contact_changed (contact_list, contact);

    HybridBuddy* buddy = hybrid_blist_find_buddy_by_handle(account,contact);

    // here we assume the account must have default group and only one
    gchar *oldgroup = buddy->parent->name; 



    if (!tp_strdiff (oldgroup,names[0] ))
        return; // the same group nothing need to do 

    HybridGroup *group = hybrid_blist_find_group_by_name(account, names[0]);
    if (group == NULL)
        return ; // the group must existed
    if(!account->proto->info->im_ops->buddy_move(account,buddy,group))
        return; // move group failed

    tp_base_contact_list_one_contact_groups_changed (contact_list, contact,
            (const gchar * const *) names[0], 1,
            (const gchar * const *) oldgroup, 1);
    tp_simple_async_report_success_in_idle ((GObject *) self, callback,
            user_data, fetion_contact_list_set_contact_groups_async);
}
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
empathy_tls_certificate_prepare_async (EmpathyTLSCertificate *self,
    GAsyncReadyCallback callback,
    gpointer user_data)
{
  EmpathyTLSCertificatePriv *priv = GET_PRIV (self);

  /* emit an error if we're already preparing the object */
  if (priv->async_prepare_res != NULL)
    {
      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, empathy_tls_certificate_prepare_async);

      return;
    }

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

  /* call GetAll() on the certificate */
  tp_cli_dbus_properties_call_get_all (self,
      -1, EMP_IFACE_AUTHENTICATION_TLS_CERTIFICATE,
      tls_certificate_got_all_cb, NULL, NULL,
      G_OBJECT (self));
}