Exemplo n.º 1
0
Arquivo: keytable.c Projeto: gpg/gpa
static void
first_half_done_cb (GpaContext *context, gpg_error_t err,
                    GpaKeyTable *keytable)
{
    if (keytable->did_first_half || !cms_hack)
    {
        /* We are here for the second time and thus we continue with the
           real done handler.  We do this also if the CMS_HACK has not
           been enabled.  We reset the protocol to OpenPGP because some
           old code might assume that it is in OpenPGP mode.  */
        keytable->fpr = NULL; /* Not needed anymore.  */
        gpgme_set_protocol (keytable->context->ctx, GPGME_PROTOCOL_OpenPGP);
        done_cb (context, err, keytable);
        return;
    }

    /* Now continue with a key listing for X.509 keys but save the error
       of the the PGP key listing.  */
    keytable->first_half_err = err;
    keytable->did_first_half = 1;

    gpgme_set_protocol (context->ctx, GPGME_PROTOCOL_CMS);
    err = gpgme_op_keylist_start (keytable->context->ctx,
                                  keytable->fpr,
                                  keytable->secret);
    keytable->fpr = NULL; /* Not needed anymore.  */
    if (err)
    {
        if (keytable->first_half_err)
            gpa_gpgme_warning (keytable->first_half_err);

        if ((gpg_err_code (err) == GPG_ERR_INV_ENGINE
                || gpg_err_code (err) == GPG_ERR_UNSUPPORTED_PROTOCOL)
                && gpg_err_source (err) == GPG_ERR_SOURCE_GPGME)
        {
            if (gpg_err_code (err) == GPG_ERR_UNSUPPORTED_PROTOCOL)
                g_message ("Note: Please check libgpgme has "
                           "been build with support for CMS");
            gpa_window_error
            (_("It seems that no CMS engine is installed.\n\n"
               "Temporary disabling support for X.509.\n\n"
               "Please install a CMS engine or invoke this program\n"
               "with the option --disable-x509 ."), NULL);
            cms_hack = 0;
            err = 0;
        }
        else
            gpa_gpgme_warning (err);
        if (keytable->end)
        {
            keytable->end (keytable->data);
        }
    }
}
Exemplo n.º 2
0
static void
update_objects (ECalClient *cal_client,
                icalcomponent *icalcomp,
                GCancellable *cancellable,
                void (*done_cb) (gpointer user_data),
                gpointer user_data)
{
	icalcomponent_kind kind;
	icalcomponent *vcal;
	struct UpdateObjectsData *uod;

	kind = icalcomponent_isa (icalcomp);
	if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT) {
		vcal = e_cal_util_new_top_level ();
		if (icalcomponent_get_method (icalcomp) == ICAL_METHOD_CANCEL)
			icalcomponent_set_method (vcal, ICAL_METHOD_CANCEL);
		else
			icalcomponent_set_method (vcal, ICAL_METHOD_PUBLISH);
		icalcomponent_add_component (vcal, icalcomponent_new_clone (icalcomp));
	} else if (kind == ICAL_VCALENDAR_COMPONENT) {
		vcal = icalcomponent_new_clone (icalcomp);
		if (!icalcomponent_get_first_property (vcal, ICAL_METHOD_PROPERTY))
			icalcomponent_set_method (vcal, ICAL_METHOD_PUBLISH);
	} else {
		if (done_cb)
			done_cb (user_data);
		return;
	}

	uod = g_new0 (struct UpdateObjectsData, 1);
	uod->done_cb = done_cb;
	uod->user_data = user_data;

	e_cal_client_receive_objects (cal_client, vcal, cancellable, receive_objects_ready_cb, uod);

	icalcomponent_free (vcal);

	return;
}