Exemplo n.º 1
0
static void
seahorse_pgp_subkey_set_property (GObject *object, guint prop_id, const GValue *value,
                                  GParamSpec *pspec)
{
    SeahorsePgpSubkey *self = SEAHORSE_PGP_SUBKEY (object);

    switch (prop_id) {
    case PROP_INDEX:
        seahorse_pgp_subkey_set_index (self, g_value_get_uint (value));
        break;
    case PROP_KEYID:
        seahorse_pgp_subkey_set_keyid (self, g_value_get_string (value));
        break;
    case PROP_FLAGS:
        seahorse_pgp_subkey_set_flags (self, g_value_get_uint (value));
        break;
    case PROP_LENGTH:
        seahorse_pgp_subkey_set_length (self, g_value_get_uint (value));
        break;
    case PROP_ALGORITHM:
        seahorse_pgp_subkey_set_algorithm (self, g_value_get_string (value));
        break;
    case PROP_CREATED:
        seahorse_pgp_subkey_set_created (self, g_value_get_ulong (value));
        break;
    case PROP_EXPIRES:
        seahorse_pgp_subkey_set_expires (self, g_value_get_ulong (value));
        break;
    case PROP_FINGERPRINT:
        seahorse_pgp_subkey_set_fingerprint (self, g_value_get_string (value));
        break;
    case PROP_DESCRIPTION:
        seahorse_pgp_subkey_set_description (self, g_value_get_string (value));
        break;
    }
}
Exemplo n.º 2
0
void
seahorse_gpgme_subkey_set_subkey (SeahorseGpgmeSubkey *self, gpgme_subkey_t subkey)
{
	gchar *description, *fingerprint, *name;
	SeahorsePgpSubkey *base;
	const gchar *algo_type;
	GObject *obj;
	gpgme_subkey_t sub;
	gint i, index;
	guint flags;
	
	g_return_if_fail (SEAHORSE_IS_GPGME_SUBKEY (self));
	g_return_if_fail (subkey);
	
	/* Make sure that this subkey is in the pubkey */
	index = -1;
	for (i = 0, sub = self->pv->pubkey->subkeys; sub; ++i, sub = sub->next) {
		if(sub == subkey) {
			index = i;
			break;
		}
	}
	g_return_if_fail (index >= 0);
	
	/* Calculate the algorithm */
	algo_type = gpgme_pubkey_algo_name (subkey->pubkey_algo);
	if (algo_type == NULL)
		algo_type = C_("Algorithm", "Unknown");
	else if (g_str_equal ("Elg", algo_type) || g_str_equal("ELG-E", algo_type))
		algo_type = _("ElGamal");

	/* Additional properties */
	fingerprint = seahorse_pgp_subkey_calc_fingerprint (subkey->fpr);
	name = seahorse_gpgme_uid_calc_name (self->pv->pubkey->uids);
	description = seahorse_pgp_subkey_calc_description (name, index);
	
	self->pv->subkey = subkey;
	
	obj = G_OBJECT (self);
	g_object_freeze_notify (obj);
	
	base = SEAHORSE_PGP_SUBKEY (self);
	seahorse_pgp_subkey_set_index (base, index);
	seahorse_pgp_subkey_set_keyid (base, subkey->keyid);
	seahorse_pgp_subkey_set_algorithm (base, algo_type);
	seahorse_pgp_subkey_set_length (base, subkey->length);
	seahorse_pgp_subkey_set_description (base, description);
	seahorse_pgp_subkey_set_fingerprint (base, fingerprint);
	seahorse_pgp_subkey_set_created (base, subkey->timestamp);
	seahorse_pgp_subkey_set_expires (base, subkey->expires);
	
	/* The order below is significant */
	flags = 0;
	if (subkey->revoked)
		flags |= SEAHORSE_FLAG_REVOKED;
	if (subkey->expired)
		flags |= SEAHORSE_FLAG_EXPIRED;
	if (subkey->disabled)
		flags |= SEAHORSE_FLAG_DISABLED;
	if (flags == 0 && !subkey->invalid)
		flags |= SEAHORSE_FLAG_IS_VALID;
	if (subkey->can_encrypt)
		flags |= SEAHORSE_FLAG_CAN_ENCRYPT;
	if (subkey->can_sign)
		flags |= SEAHORSE_FLAG_CAN_SIGN;
	if (subkey->can_certify)
		flags |= SEAHORSE_FLAG_CAN_CERTIFY;
	if (subkey->can_authenticate)
		flags |= SEAHORSE_FLAG_CAN_AUTHENTICATE;
	
	seahorse_pgp_subkey_set_flags (base, flags);
	
	g_object_notify (obj, "subkey");
	g_object_thaw_notify (obj);
	
	g_free (description);
	g_free (name);
	g_free (fingerprint);
}