Mercurial > ~mikael > mcabber > hg
diff mcabber/src/settings.c @ 1197:6f602d3270a4
Add /pgp [-]force
With this command it becomes possible to enforce PGP encryption without
checking if the remote client has PGP support. It can be used to send
encrypted offline messages too.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 27 Apr 2007 00:37:57 +0200 |
parents | 7b8765c10abb |
children | c96fef31ff96 |
line wrap: on
line diff
--- a/mcabber/src/settings.c Sun Apr 22 15:01:20 2007 +0200 +++ b/mcabber/src/settings.c Fri Apr 27 00:37:57 2007 +0200 @@ -38,6 +38,7 @@ typedef struct { gchar *pgp_keyid; /* KeyId the contact is supposed to use */ guint pgp_disabled; /* If TRUE, PGP is disabled for outgoing messages */ + guint pgp_force; /* If TRUE, PGP is used w/o negotiation */ } T_pgpopt; #endif @@ -403,12 +404,52 @@ if (pgpdata) return pgpdata->pgp_disabled; else - return FALSE; // default: not disabled + return FALSE; // Default: not disabled #else return TRUE; // No PGP support, let's say it's disabled. #endif } +// settings_pgp_setforce(jid, value) +// Force (or not) PGP encryption for jid. +// When value is TRUE, PGP support will be assumed for the remote client. +void settings_pgp_setforce(const char *bjid, guint value) +{ +#ifdef HAVE_GPGME + T_pgpopt *pgpdata; + pgpdata = g_hash_table_lookup(pgpopt, bjid); + if (!pgpdata) { + // If value is 0, we do not need to create a structure (that's + // the default value). + if (value) { + pgpdata = g_new0(T_pgpopt, 1); + pgpdata->pgp_force = value; + g_hash_table_insert(pgpopt, g_strdup(bjid), pgpdata); + } + } else { + pgpdata->pgp_force = value; + } + if (!pgpdata->pgp_keyid) + scr_LogPrint(LPRINT_NORMAL, "Warning: the Key Id is not set!"); +#endif +} + +// settings_pgp_getforce(jid) +// Return TRUE if PGP enforcement is set for jid. +guint settings_pgp_getforce(const char *bjid) +{ +#ifdef HAVE_GPGME + T_pgpopt *pgpdata; + pgpdata = g_hash_table_lookup(pgpopt, bjid); + if (pgpdata) + return pgpdata->pgp_force; + else + return FALSE; // Default +#else + return FALSE; // No PGP support +#endif +} + // settings_pgp_setkeyid(jid, keyid) // Set the PGP KeyId for user jid. // Use keyid = NULL to erase the previous KeyId.