1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge branch 'master' into osx-functional

This commit is contained in:
James Booth 2015-08-26 01:38:14 +01:00
commit 9e9d31cbac
19 changed files with 373 additions and 120 deletions

View File

@ -59,6 +59,9 @@
#ifdef HAVE_LIBOTR #ifdef HAVE_LIBOTR
#include "otr/otr.h" #include "otr/otr.h"
#endif #endif
#ifdef HAVE_LIBGPGME
#include "pgp/gpg.h"
#endif
#include "profanity.h" #include "profanity.h"
#include "tools/autocomplete.h" #include "tools/autocomplete.h"
#include "tools/parser.h" #include "tools/parser.h"
@ -1142,38 +1145,43 @@ static struct cmd_t command_defs[] =
{ "/pgp", { "/pgp",
cmd_pgp, parse_args, 1, 3, NULL, cmd_pgp, parse_args, 1, 3, NULL,
CMD_TAGS( CMD_TAGS(
CMD_TAG_CHAT) CMD_TAG_CHAT,
CMD_TAG_UI)
CMD_SYN( CMD_SYN(
"/pgp libver", "/pgp libver",
"/pgp keys", "/pgp keys",
"/pgp fps", "/pgp contacts",
"/pgp setkey <contact> <keyid>", "/pgp setkey <contact> <keyid>",
"/pgp start [<contact>]", "/pgp start [<contact>]",
"/pgp end", "/pgp end",
"/pgp log on|off|redact") "/pgp log on|off|redact",
"/pgp char <char>")
CMD_DESC( CMD_DESC(
"Open PGP commands to manage keys, and perform PGP encryption during chat sessions. " "Open PGP commands to manage keys, and perform PGP encryption during chat sessions. "
"See the /account command to set your own PGP key.") "See the /account command to set your own PGP key.")
CMD_ARGS( CMD_ARGS(
{ "libver", "Show which version of the libgpgme library is being used." }, { "libver", "Show which version of the libgpgme library is being used." },
{ "keys", "List all keys." }, { "keys", "List all keys known to the system." },
{ "fps", "Show known fingerprints." }, { "contacts", "Show contacts with assigned public keys." },
{ "setkey <contact> <keyid>", "Manually associate a key ID with a JID." }, { "setkey <contact> <keyid>", "Manually associate a contact with a public key." },
{ "start [<contact>]", "Start PGP encrypted chat, current contact will be used if not specified." }, { "start [<contact>]", "Start PGP encrypted chat, current contact will be used if not specified." },
{ "end", "End PGP encrypted chat with the current recipient." }, { "end", "End PGP encrypted chat with the current recipient." },
{ "log on|off", "Enable or disable plaintext logging of PGP encrypted messages." }, { "log on|off", "Enable or disable plaintext logging of PGP encrypted messages." },
{ "log redact", "Log PGP encrypted messages, but replace the contents with [redacted]. This is the default." }) { "log redact", "Log PGP encrypted messages, but replace the contents with [redacted]. This is the default." },
{ "char <char>", "Set the character to be displayed next to PGP encrypted messages." })
CMD_EXAMPLES( CMD_EXAMPLES(
"/pgp log off", "/pgp log off",
"/pgp setkey buddy@buddychat.org BA19CACE5A9592C5", "/pgp setkey buddy@buddychat.org BA19CACE5A9592C5",
"/pgp start buddy@buddychat.org", "/pgp start buddy@buddychat.org",
"/pgp end") "/pgp end",
"/pgp char P")
}, },
{ "/otr", { "/otr",
cmd_otr, parse_args, 1, 3, NULL, cmd_otr, parse_args, 1, 3, NULL,
CMD_TAGS( CMD_TAGS(
CMD_TAG_CHAT) CMD_TAG_CHAT,
CMD_TAG_UI)
CMD_SYN( CMD_SYN(
"/otr libver", "/otr libver",
"/otr gen", "/otr gen",
@ -1185,7 +1193,8 @@ static struct cmd_t command_defs[] =
"/otr question <question> <answer>", "/otr question <question> <answer>",
"/otr answer <answer>", "/otr answer <answer>",
"/otr policy manual|opportunistic|always", "/otr policy manual|opportunistic|always",
"/otr log on|off|redact") "/otr log on|off|redact",
"/otr char <char>")
CMD_DESC( CMD_DESC(
"Off The Record (OTR) commands to manage keys, and perform OTR encryption during chat sessions.") "Off The Record (OTR) commands to manage keys, and perform OTR encryption during chat sessions.")
CMD_ARGS( CMD_ARGS(
@ -1203,7 +1212,8 @@ static struct cmd_t command_defs[] =
{ "policy opportunistic", "Set the global OTR policy to opportunistic, and OTR sessions will be attempted upon starting a conversation." }, { "policy opportunistic", "Set the global OTR policy to opportunistic, and OTR sessions will be attempted upon starting a conversation." },
{ "policy always", "Set the global OTR policy to always, an error will be displayed if an OTR session cannot be initiated upon starting a conversation." }, { "policy always", "Set the global OTR policy to always, an error will be displayed if an OTR session cannot be initiated upon starting a conversation." },
{ "log on|off", "Enable or disable plaintext logging of OTR encrypted messages." }, { "log on|off", "Enable or disable plaintext logging of OTR encrypted messages." },
{ "log redact", "Log OTR encrypted messages, but replace the contents with [redacted]. This is the default." }) { "log redact", "Log OTR encrypted messages, but replace the contents with [redacted]. This is the default." },
{ "char <char>", "Set the character to be displayed next to OTR encrypted messages." })
CMD_EXAMPLES( CMD_EXAMPLES(
"/otr log off", "/otr log off",
"/otr policy manual", "/otr policy manual",
@ -1212,7 +1222,8 @@ static struct cmd_t command_defs[] =
"/otr myfp", "/otr myfp",
"/otr theirfp", "/otr theirfp",
"/otr question \"What is the name of my rabbit?\" fiffi", "/otr question \"What is the name of my rabbit?\" fiffi",
"/otr end") "/otr end",
"/otr char *")
}, },
{ "/outtype", { "/outtype",
@ -1946,6 +1957,7 @@ cmd_init(void)
autocomplete_add(otr_ac, "policy"); autocomplete_add(otr_ac, "policy");
autocomplete_add(otr_ac, "question"); autocomplete_add(otr_ac, "question");
autocomplete_add(otr_ac, "answer"); autocomplete_add(otr_ac, "answer");
autocomplete_add(otr_ac, "char");
otr_log_ac = autocomplete_new(); otr_log_ac = autocomplete_new();
autocomplete_add(otr_log_ac, "on"); autocomplete_add(otr_log_ac, "on");
@ -2053,12 +2065,13 @@ cmd_init(void)
pgp_ac = autocomplete_new(); pgp_ac = autocomplete_new();
autocomplete_add(pgp_ac, "keys"); autocomplete_add(pgp_ac, "keys");
autocomplete_add(pgp_ac, "fps"); autocomplete_add(pgp_ac, "contacts");
autocomplete_add(pgp_ac, "setkey"); autocomplete_add(pgp_ac, "setkey");
autocomplete_add(pgp_ac, "libver"); autocomplete_add(pgp_ac, "libver");
autocomplete_add(pgp_ac, "start"); autocomplete_add(pgp_ac, "start");
autocomplete_add(pgp_ac, "end"); autocomplete_add(pgp_ac, "end");
autocomplete_add(pgp_ac, "log"); autocomplete_add(pgp_ac, "log");
autocomplete_add(pgp_ac, "char");
pgp_log_ac = autocomplete_new(); pgp_log_ac = autocomplete_new();
autocomplete_add(pgp_log_ac, "on"); autocomplete_add(pgp_log_ac, "on");
@ -2242,6 +2255,9 @@ cmd_reset_autocomplete(ProfWin *window)
accounts_reset_enabled_search(); accounts_reset_enabled_search();
prefs_reset_boolean_choice(); prefs_reset_boolean_choice();
presence_reset_sub_request_search(); presence_reset_sub_request_search();
#ifdef HAVE_LIBGPGME
p_gpg_autocomplete_key_reset();
#endif
autocomplete_reset(help_ac); autocomplete_reset(help_ac);
autocomplete_reset(help_commands_ac); autocomplete_reset(help_commands_ac);
autocomplete_reset(notify_ac); autocomplete_reset(notify_ac);
@ -2983,6 +2999,26 @@ _pgp_autocomplete(ProfWin *window, const char * const input)
return found; return found;
} }
#ifdef HAVE_LIBGPGME
gboolean result;
gchar **args = parse_args(input, 2, 3, &result);
if ((strncmp(input, "/pgp", 4) == 0) && (result == TRUE)) {
GString *beginning = g_string_new("/pgp ");
g_string_append(beginning, args[0]);
if (args[1]) {
g_string_append(beginning, " ");
g_string_append(beginning, args[1]);
}
found = autocomplete_param_with_func(input, beginning->str, p_gpg_autocomplete_key);
g_string_free(beginning, TRUE);
if (found) {
g_strfreev(args);
return found;
}
}
g_strfreev(args);
#endif
found = autocomplete_param_with_func(input, "/pgp setkey", roster_barejid_autocomplete); found = autocomplete_param_with_func(input, "/pgp setkey", roster_barejid_autocomplete);
if (found) { if (found) {
return found; return found;
@ -3583,6 +3619,17 @@ _account_autocomplete(ProfWin *window, const char * const input)
g_strfreev(args); g_strfreev(args);
return found; return found;
} }
#ifdef HAVE_LIBGPGME
} else if ((g_strv_length(args) > 3) && (g_strcmp0(args[2], "pgpkeyid")) == 0) {
g_string_append(beginning, " ");
g_string_append(beginning, args[2]);
found = autocomplete_param_with_func(input, beginning->str, p_gpg_autocomplete_key);
g_string_free(beginning, TRUE);
if (found) {
g_strfreev(args);
return found;
}
#endif
} else { } else {
found = autocomplete_param_with_ac(input, beginning->str, account_set_ac, TRUE); found = autocomplete_param_with_ac(input, beginning->str, account_set_ac, TRUE);
g_string_free(beginning, TRUE); g_string_free(beginning, TRUE);

View File

@ -4191,7 +4191,17 @@ cmd_pgp(ProfWin *window, const char * const command, gchar **args)
return TRUE; return TRUE;
} }
if (g_strcmp0(args[0], "log") == 0) { if (strcmp(args[0], "char") == 0) {
if (args[1] == NULL) {
cons_bad_cmd_usage(command);
} else if (strlen(args[1]) != 1) {
cons_bad_cmd_usage(command);
} else {
prefs_set_pgp_char(args[1][0]);
cons_show("PGP char set to %c.", args[1][0]);
}
return TRUE;
} else if (g_strcmp0(args[0], "log") == 0) {
char *choice = args[1]; char *choice = args[1];
if (g_strcmp0(choice, "on") == 0) { if (g_strcmp0(choice, "on") == 0) {
prefs_set_string(PREF_PGP_LOG, "on"); prefs_set_string(PREF_PGP_LOG, "on");
@ -4270,25 +4280,29 @@ cmd_pgp(ProfWin *window, const char * const command, gchar **args)
return TRUE; return TRUE;
} }
if (g_strcmp0(args[0], "fps") == 0) { if (g_strcmp0(args[0], "contacts") == 0) {
jabber_conn_status_t conn_status = jabber_get_connection_status(); jabber_conn_status_t conn_status = jabber_get_connection_status();
if (conn_status != JABBER_CONNECTED) { if (conn_status != JABBER_CONNECTED) {
cons_show("You are not currently connected."); cons_show("You are not currently connected.");
return TRUE; return TRUE;
} }
GHashTable *fingerprints = p_gpg_fingerprints(); GHashTable *pubkeys = p_gpg_pubkeys();
GList *jids = g_hash_table_get_keys(fingerprints); GList *jids = g_hash_table_get_keys(pubkeys);
if (!jids) { if (!jids) {
cons_show("No PGP fingerprints available."); cons_show("No contacts found with PGP public keys assigned.");
return TRUE; return TRUE;
} }
cons_show("Known PGP fingerprints:"); cons_show("Assigned PGP public keys:");
GList *curr = jids; GList *curr = jids;
while (curr) { while (curr) {
char *jid = curr->data; char *jid = curr->data;
char *fingerprint = g_hash_table_lookup(fingerprints, jid); ProfPGPPubKeyId *pubkeyid = g_hash_table_lookup(pubkeys, jid);
cons_show(" %s: %s", jid, fingerprint); if (pubkeyid->received) {
cons_show(" %s: %s (received)", jid, pubkeyid->id);
} else {
cons_show(" %s: %s (stored)", jid, pubkeyid->id);
}
curr = g_list_next(curr); curr = g_list_next(curr);
} }
g_list_free(jids); g_list_free(jids);
@ -4410,7 +4424,17 @@ cmd_otr(ProfWin *window, const char * const command, gchar **args)
return TRUE; return TRUE;
} }
if (strcmp(args[0], "log") == 0) { if (strcmp(args[0], "char") == 0) {
if (args[1] == NULL) {
cons_bad_cmd_usage(command);
} else if (strlen(args[1]) != 1) {
cons_bad_cmd_usage(command);
} else {
prefs_set_otr_char(args[1][0]);
cons_show("OTR char set to %c.", args[1][0]);
}
return TRUE;
} else if (strcmp(args[0], "log") == 0) {
char *choice = args[1]; char *choice = args[1];
if (g_strcmp0(choice, "on") == 0) { if (g_strcmp0(choice, "on") == 0) {
prefs_set_string(PREF_OTR_LOG, "on"); prefs_set_string(PREF_OTR_LOG, "on");

View File

@ -376,6 +376,60 @@ prefs_get_roster_size(void)
} }
} }
char
prefs_get_otr_char(void)
{
char result = '~';
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_OTR, "otr.char", NULL);
if (!resultstr) {
result = '~';
} else {
result = resultstr[0];
}
free(resultstr);
return result;
}
void
prefs_set_otr_char(char ch)
{
char str[2];
str[0] = ch;
str[1] = '\0';
g_key_file_set_string(prefs, PREF_GROUP_OTR, "otr.char", str);
_save_prefs();
}
char
prefs_get_pgp_char(void)
{
char result = '~';
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_PGP, "pgp.char", NULL);
if (!resultstr) {
result = '~';
} else {
result = resultstr[0];
}
free(resultstr);
return result;
}
void
prefs_set_pgp_char(char ch)
{
char str[2];
str[0] = ch;
str[1] = '\0';
g_key_file_set_string(prefs, PREF_GROUP_PGP, "pgp.char", str);
_save_prefs();
}
gboolean gboolean
prefs_add_alias(const char * const name, const char * const value) prefs_add_alias(const char * const name, const char * const value)
{ {

View File

@ -143,6 +143,11 @@ gint prefs_get_roster_size(void);
gint prefs_get_autoaway_time(void); gint prefs_get_autoaway_time(void);
void prefs_set_autoaway_time(gint value); void prefs_set_autoaway_time(gint value);
char prefs_get_otr_char(void);
void prefs_set_otr_char(char ch);
char prefs_get_pgp_char(void);
void prefs_set_pgp_char(char ch);
void prefs_add_login(const char *jid); void prefs_add_login(const char *jid);
gboolean prefs_add_alias(const char * const name, const char * const value); gboolean prefs_add_alias(const char * const name, const char * const value);

View File

@ -465,6 +465,21 @@ _load_preferences(void)
_set_boolean_preference("intype", PREF_INTYPE); _set_boolean_preference("intype", PREF_INTYPE);
_set_boolean_preference("enc.warn", PREF_ENC_WARN); _set_boolean_preference("enc.warn", PREF_ENC_WARN);
if (g_key_file_has_key(theme, "ui", "otr.char", NULL)) {
gchar *ch = g_key_file_get_string(theme, "ui", "otr.char", NULL);
if (ch && strlen(ch) > 0) {
prefs_set_otr_char(ch[0]);
g_free(ch);
}
}
if (g_key_file_has_key(theme, "ui", "pgp.char", NULL)) {
gchar *ch = g_key_file_get_string(theme, "ui", "pgp.char", NULL);
if (ch && strlen(ch) > 0) {
prefs_set_pgp_char(ch[0]);
g_free(ch);
}
}
} }
static gchar * static gchar *

View File

@ -97,13 +97,13 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg)
if (!handled) { if (!handled) {
char *id = message_send_chat(chatwin->barejid, msg); char *id = message_send_chat(chatwin->barejid, msg);
chat_log_msg_out(chatwin->barejid, msg); chat_log_msg_out(chatwin->barejid, msg);
ui_outgoing_chat_msg(chatwin, msg, id); ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_NONE);
free(id); free(id);
} }
} else { // enc_mode = PROF_ENC_PGP } else { // enc_mode = PROF_ENC_PGP
char *id = message_send_chat_pgp(chatwin->barejid, msg); char *id = message_send_chat_pgp(chatwin->barejid, msg);
chat_log_pgp_msg_out(chatwin->barejid, msg); chat_log_pgp_msg_out(chatwin->barejid, msg);
ui_outgoing_chat_msg(chatwin, msg, id); ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_PGP);
free(id); free(id);
} }
return; return;
@ -117,7 +117,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg)
if (!handled) { if (!handled) {
char *id = message_send_chat(chatwin->barejid, msg); char *id = message_send_chat(chatwin->barejid, msg);
chat_log_msg_out(chatwin->barejid, msg); chat_log_msg_out(chatwin->barejid, msg);
ui_outgoing_chat_msg(chatwin, msg, id); ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_NONE);
free(id); free(id);
} }
return; return;
@ -131,12 +131,12 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg)
if (enc_mode == PROF_ENC_NONE) { if (enc_mode == PROF_ENC_NONE) {
char *id = message_send_chat(chatwin->barejid, msg); char *id = message_send_chat(chatwin->barejid, msg);
chat_log_msg_out(chatwin->barejid, msg); chat_log_msg_out(chatwin->barejid, msg);
ui_outgoing_chat_msg(chatwin, msg, id); ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_NONE);
free(id); free(id);
} else if (enc_mode == PROF_ENC_PGP) { } else if (enc_mode == PROF_ENC_PGP) {
char *id = message_send_chat_pgp(chatwin->barejid, msg); char *id = message_send_chat_pgp(chatwin->barejid, msg);
chat_log_pgp_msg_out(chatwin->barejid, msg); chat_log_pgp_msg_out(chatwin->barejid, msg);
ui_outgoing_chat_msg(chatwin, msg, id); ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_PGP);
free(id); free(id);
} }
return; return;
@ -148,7 +148,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg)
#ifndef HAVE_LIBGPGME #ifndef HAVE_LIBGPGME
char *id = message_send_chat(chatwin->barejid, msg); char *id = message_send_chat(chatwin->barejid, msg);
chat_log_msg_out(chatwin->barejid, msg); chat_log_msg_out(chatwin->barejid, msg);
ui_outgoing_chat_msg(chatwin, msg, id); ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_NONE;
free(id); free(id);
return; return;
#endif #endif

View File

@ -187,7 +187,7 @@ sv_ev_incoming_carbon(char *barejid, char *resource, char *message)
new_win = TRUE; new_win = TRUE;
} }
ui_incoming_msg(chatwin, resource, message, NULL, new_win); ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_ENC_NONE);
chat_log_msg_in(barejid, message); chat_log_msg_in(barejid, message);
} }
@ -215,12 +215,12 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m
if (enc_mode == PROF_ENC_NONE) { if (enc_mode == PROF_ENC_NONE) {
win_println((ProfWin*)chatwin, 0, "PGP encryption enabled."); win_println((ProfWin*)chatwin, 0, "PGP encryption enabled.");
} }
ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win); ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win, PROF_ENC_PGP);
chat_log_pgp_msg_in(barejid, decrypted); chat_log_pgp_msg_in(barejid, decrypted);
chatwin->enc_mode = PROF_ENC_PGP; chatwin->enc_mode = PROF_ENC_PGP;
p_gpg_free_decrypted(decrypted); p_gpg_free_decrypted(decrypted);
} else { } else {
ui_incoming_msg(chatwin, resource, message, NULL, new_win); ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_ENC_NONE);
chat_log_msg_in(barejid, message); chat_log_msg_in(barejid, message);
chatwin->enc_mode = PROF_ENC_NONE; chatwin->enc_mode = PROF_ENC_NONE;
} }
@ -228,14 +228,18 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m
} else { } else {
if (enc_mode == PROF_ENC_PGP) { if (enc_mode == PROF_ENC_PGP) {
win_println((ProfWin*)chatwin, 0, "PGP encryption disabled."); win_println((ProfWin*)chatwin, 0, "PGP encryption disabled.");
ui_incoming_msg(chatwin, resource, message, NULL, new_win); ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_ENC_NONE);
chat_log_msg_in(barejid, message); chat_log_msg_in(barejid, message);
chatwin->enc_mode = PROF_ENC_NONE; chatwin->enc_mode = PROF_ENC_NONE;
} else { } else {
gboolean decrypted = FALSE; gboolean decrypted = FALSE;
char *otr_res = otr_on_message_recv(barejid, resource, message, &decrypted); char *otr_res = otr_on_message_recv(barejid, resource, message, &decrypted);
if (otr_res) { if (otr_res) {
ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win); if (decrypted && g_strrstr(message, otr_res) == NULL) {
ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win, PROF_ENC_OTR);
} else {
ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win, PROF_ENC_NONE);
}
chat_log_otr_msg_in(barejid, otr_res, decrypted); chat_log_otr_msg_in(barejid, otr_res, decrypted);
otr_free_message(otr_res); otr_free_message(otr_res);
} }
@ -251,7 +255,11 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m
gboolean decrypted = FALSE; gboolean decrypted = FALSE;
char *otr_res = otr_on_message_recv(barejid, resource, message, &decrypted); char *otr_res = otr_on_message_recv(barejid, resource, message, &decrypted);
if (otr_res) { if (otr_res) {
ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win); if (decrypted && g_strrstr(message, otr_res) == NULL) {
ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win, PROF_ENC_OTR);
} else {
ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win, PROF_ENC_NONE);
}
chat_log_otr_msg_in(barejid, otr_res, decrypted); chat_log_otr_msg_in(barejid, otr_res, decrypted);
otr_free_message(otr_res); otr_free_message(otr_res);
} }
@ -265,17 +273,17 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m
if (enc_message) { if (enc_message) {
char *decrypted = p_gpg_decrypt(enc_message); char *decrypted = p_gpg_decrypt(enc_message);
if (decrypted) { if (decrypted) {
ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win); ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win, PROF_ENC_PGP);
chat_log_pgp_msg_in(barejid, decrypted); chat_log_pgp_msg_in(barejid, decrypted);
chatwin->enc_mode = PROF_ENC_PGP; chatwin->enc_mode = PROF_ENC_PGP;
p_gpg_free_decrypted(decrypted); p_gpg_free_decrypted(decrypted);
} else { } else {
ui_incoming_msg(chatwin, resource, message, NULL, new_win); ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_ENC_NONE);
chat_log_msg_in(barejid, message); chat_log_msg_in(barejid, message);
chatwin->enc_mode = PROF_ENC_NONE; chatwin->enc_mode = PROF_ENC_NONE;
} }
} else { } else {
ui_incoming_msg(chatwin, resource, message, NULL, new_win); ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_ENC_NONE);
chat_log_msg_in(barejid, message); chat_log_msg_in(barejid, message);
chatwin->enc_mode = PROF_ENC_NONE; chatwin->enc_mode = PROF_ENC_NONE;
} }
@ -286,7 +294,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m
// OTR unsupported, PGP unsupported // OTR unsupported, PGP unsupported
#ifndef HAVE_LIBOTR #ifndef HAVE_LIBOTR
#ifndef HAVE_LIBGPGME #ifndef HAVE_LIBGPGME
ui_incoming_msg(chatwin, resource, message, NULL, new_win); ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_ENC_NONE);
chat_log_msg_in(barejid, message); chat_log_msg_in(barejid, message);
chatwin->enc_mode = PROF_ENC_NONE; chatwin->enc_mode = PROF_ENC_NONE;
return; return;
@ -311,7 +319,7 @@ sv_ev_delayed_message(char *barejid, char *message, GDateTime *timestamp)
new_win = TRUE; new_win = TRUE;
} }
ui_incoming_msg(chatwin, NULL, message, timestamp, new_win); ui_incoming_msg(chatwin, NULL, message, timestamp, new_win, PROF_ENC_NONE);
chat_log_msg_in_delayed(barejid, message, timestamp); chat_log_msg_in_delayed(barejid, message, timestamp);
} }

View File

@ -325,7 +325,7 @@ otr_on_message_send(ProfChatWin *chatwin, const char * const message)
if (encrypted) { if (encrypted) {
id = message_send_chat_otr(chatwin->barejid, encrypted); id = message_send_chat_otr(chatwin->barejid, encrypted);
chat_log_otr_msg_out(chatwin->barejid, message); chat_log_otr_msg_out(chatwin->barejid, message);
ui_outgoing_chat_msg(chatwin, message, id); ui_outgoing_chat_msg(chatwin, message, id, PROF_ENC_OTR);
otr_free_message(encrypted); otr_free_message(encrypted);
free(id); free(id);
return TRUE; return TRUE;
@ -345,7 +345,7 @@ otr_on_message_send(ProfChatWin *chatwin, const char * const message)
if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) { if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
char *otr_tagged_msg = otr_tag_message(message); char *otr_tagged_msg = otr_tag_message(message);
id = message_send_chat_otr(chatwin->barejid, otr_tagged_msg); id = message_send_chat_otr(chatwin->barejid, otr_tagged_msg);
ui_outgoing_chat_msg(chatwin, message, id); ui_outgoing_chat_msg(chatwin, message, id, PROF_ENC_NONE);
chat_log_msg_out(chatwin->barejid, message); chat_log_msg_out(chatwin->barejid, message);
free(otr_tagged_msg); free(otr_tagged_msg);
free(id); free(id);

View File

@ -47,6 +47,7 @@
#include "pgp/gpg.h" #include "pgp/gpg.h"
#include "log.h" #include "log.h"
#include "common.h" #include "common.h"
#include "tools/autocomplete.h"
#define PGP_SIGNATURE_HEADER "-----BEGIN PGP SIGNATURE-----" #define PGP_SIGNATURE_HEADER "-----BEGIN PGP SIGNATURE-----"
#define PGP_SIGNATURE_FOOTER "-----END PGP SIGNATURE-----" #define PGP_SIGNATURE_FOOTER "-----END PGP SIGNATURE-----"
@ -54,14 +55,25 @@
#define PGP_MESSAGE_FOOTER "-----END PGP MESSAGE-----" #define PGP_MESSAGE_FOOTER "-----END PGP MESSAGE-----"
static const char *libversion; static const char *libversion;
static GHashTable *fingerprints; static GHashTable *pubkeys;
static gchar *fpsloc; static gchar *pubsloc;
static GKeyFile *fpskeyfile; static GKeyFile *pubkeyfile;
static Autocomplete key_ac;
static char* _remove_header_footer(char *str, const char * const footer); static char* _remove_header_footer(char *str, const char * const footer);
static char* _add_header_footer(const char * const str, const char * const header, const char * const footer); static char* _add_header_footer(const char * const str, const char * const header, const char * const footer);
static void _save_fps(void); static void _save_pubkeys(void);
void
_p_gpg_free_pubkeyid(ProfPGPPubKeyId *pubkeyid)
{
if (pubkeyid) {
free(pubkeyid->id);
}
free(pubkeyid);
}
void void
p_gpg_init(void) p_gpg_init(void)
@ -70,65 +82,72 @@ p_gpg_init(void)
log_debug("GPG: Found gpgme version: %s", libversion); log_debug("GPG: Found gpgme version: %s", libversion);
gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL)); gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL));
fingerprints = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); pubkeys = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)_p_gpg_free_pubkeyid);
key_ac = autocomplete_new();
GHashTable *keys = p_gpg_list_keys();
p_gpg_free_keys(keys);
} }
void void
p_gpg_close(void) p_gpg_close(void)
{ {
if (fingerprints) { if (pubkeys) {
g_hash_table_destroy(fingerprints); g_hash_table_destroy(pubkeys);
fingerprints = NULL; pubkeys = NULL;
} }
if (fpskeyfile) { if (pubkeyfile) {
g_key_file_free(fpskeyfile); g_key_file_free(pubkeyfile);
fpskeyfile = NULL; pubkeyfile = NULL;
} }
free(fpsloc); free(pubsloc);
fpsloc = NULL; pubsloc = NULL;
autocomplete_free(key_ac);
key_ac = NULL;
} }
void void
p_gpg_on_connect(const char * const barejid) p_gpg_on_connect(const char * const barejid)
{ {
gchar *data_home = xdg_get_data_home(); gchar *data_home = xdg_get_data_home();
GString *fpsfile = g_string_new(data_home); GString *pubsfile = g_string_new(data_home);
free(data_home); free(data_home);
gchar *account_dir = str_replace(barejid, "@", "_at_"); gchar *account_dir = str_replace(barejid, "@", "_at_");
g_string_append(fpsfile, "/profanity/pgp/"); g_string_append(pubsfile, "/profanity/pgp/");
g_string_append(fpsfile, account_dir); g_string_append(pubsfile, account_dir);
free(account_dir); free(account_dir);
// mkdir if doesn't exist for account // mkdir if doesn't exist for account
errno = 0; errno = 0;
int res = g_mkdir_with_parents(fpsfile->str, S_IRWXU); int res = g_mkdir_with_parents(pubsfile->str, S_IRWXU);
if (res == -1) { if (res == -1) {
char *errmsg = strerror(errno); char *errmsg = strerror(errno);
if (errmsg) { if (errmsg) {
log_error("Error creating directory: %s, %s", fpsfile->str, errmsg); log_error("Error creating directory: %s, %s", pubsfile->str, errmsg);
} else { } else {
log_error("Error creating directory: %s", fpsfile->str); log_error("Error creating directory: %s", pubsfile->str);
} }
} }
// create or read fingerprints keyfile // create or read publickeys
g_string_append(fpsfile, "/fingerprints"); g_string_append(pubsfile, "/pubkeys");
fpsloc = fpsfile->str; pubsloc = pubsfile->str;
g_string_free(fpsfile, FALSE); g_string_free(pubsfile, FALSE);
if (g_file_test(fpsloc, G_FILE_TEST_EXISTS)) { if (g_file_test(pubsloc, G_FILE_TEST_EXISTS)) {
g_chmod(fpsloc, S_IRUSR | S_IWUSR); g_chmod(pubsloc, S_IRUSR | S_IWUSR);
} }
fpskeyfile = g_key_file_new(); pubkeyfile = g_key_file_new();
g_key_file_load_from_file(fpskeyfile, fpsloc, G_KEY_FILE_KEEP_COMMENTS, NULL); g_key_file_load_from_file(pubkeyfile, pubsloc, G_KEY_FILE_KEEP_COMMENTS, NULL);
// load each keyid // load each keyid
gsize len = 0; gsize len = 0;
gchar **jids = g_key_file_get_groups(fpskeyfile, &len); gchar **jids = g_key_file_get_groups(pubkeyfile, &len);
gpgme_ctx_t ctx; gpgme_ctx_t ctx;
gpgme_error_t error = gpgme_new(&ctx); gpgme_error_t error = gpgme_new(&ctx);
@ -143,21 +162,24 @@ p_gpg_on_connect(const char * const barejid)
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
GError *gerr = NULL; GError *gerr = NULL;
gchar *jid = jids[i]; gchar *jid = jids[i];
gchar *keyid = g_key_file_get_string(fpskeyfile, jid, "keyid", &gerr); gchar *keyid = g_key_file_get_string(pubkeyfile, jid, "keyid", &gerr);
if (gerr) { if (gerr) {
log_error("Error loading PGP key id for %s", jid); log_error("Error loading PGP key id for %s", jid);
g_error_free(gerr); g_error_free(gerr);
g_free(keyid); g_free(keyid);
} else { } else {
gpgme_key_t key = NULL; gpgme_key_t key = NULL;
error = gpgme_get_key(ctx, keyid, &key, 1); error = gpgme_get_key(ctx, keyid, &key, 0);
g_free(keyid);
if (error || key == NULL) { if (error || key == NULL) {
log_warning("GPG: Failed to get key for %s: %s %s", jid, gpgme_strsource(error), gpgme_strerror(error)); log_warning("GPG: Failed to get key for %s: %s %s", jid, gpgme_strsource(error), gpgme_strerror(error));
continue; continue;
} }
g_hash_table_replace(fingerprints, strdup(jid), strdup(key->subkeys->fpr)); ProfPGPPubKeyId *pubkeyid = malloc(sizeof(ProfPGPPubKeyId));
pubkeyid->id = strdup(keyid);
pubkeyid->received = FALSE;
g_hash_table_replace(pubkeys, strdup(jid), pubkeyid);
g_free(keyid);
gpgme_key_unref(key); gpgme_key_unref(key);
} }
} }
@ -165,24 +187,24 @@ p_gpg_on_connect(const char * const barejid)
gpgme_release(ctx); gpgme_release(ctx);
g_strfreev(jids); g_strfreev(jids);
_save_fps(); _save_pubkeys();
} }
void void
p_gpg_on_disconnect(void) p_gpg_on_disconnect(void)
{ {
if (fingerprints) { if (pubkeys) {
g_hash_table_destroy(fingerprints); g_hash_table_destroy(pubkeys);
fingerprints = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); pubkeys = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)_p_gpg_free_pubkeyid);
} }
if (fpskeyfile) { if (pubkeyfile) {
g_key_file_free(fpskeyfile); g_key_file_free(pubkeyfile);
fpskeyfile = NULL; pubkeyfile = NULL;
} }
free(fpsloc); free(pubsloc);
fpsloc = NULL; pubsloc = NULL;
} }
gboolean gboolean
@ -196,7 +218,7 @@ p_gpg_addkey(const char * const jid, const char * const keyid)
} }
gpgme_key_t key = NULL; gpgme_key_t key = NULL;
error = gpgme_get_key(ctx, keyid, &key, 1); error = gpgme_get_key(ctx, keyid, &key, 0);
gpgme_release(ctx); gpgme_release(ctx);
if (error || key == NULL) { if (error || key == NULL) {
@ -204,12 +226,15 @@ p_gpg_addkey(const char * const jid, const char * const keyid)
return FALSE; return FALSE;
} }
// save to ID keyfile // save to public key file
g_key_file_set_string(fpskeyfile, jid, "keyid", keyid); g_key_file_set_string(pubkeyfile, jid, "keyid", keyid);
_save_fps(); _save_pubkeys();
// update in memory fingerprint list // update in memory pubkeys list
g_hash_table_replace(fingerprints, strdup(jid), strdup(key->subkeys->fpr)); ProfPGPPubKeyId *pubkeyid = malloc(sizeof(ProfPGPPubKeyId));
pubkeyid->id = strdup(keyid);
pubkeyid->received = FALSE;
g_hash_table_replace(pubkeys, strdup(jid), pubkeyid);
gpgme_key_unref(key); gpgme_key_unref(key);
return TRUE; return TRUE;
@ -312,6 +337,16 @@ p_gpg_list_keys(void)
gpgme_release(ctx); gpgme_release(ctx);
autocomplete_clear(key_ac);
GList *ids = g_hash_table_get_keys(result);
GList *curr = ids;
while (curr) {
ProfPGPKey *key = g_hash_table_lookup(result, curr->data);
autocomplete_add(key_ac, key->id);
curr = curr->next;
}
g_list_free(ids);
return result; return result;
} }
@ -323,9 +358,9 @@ p_gpg_free_keys(GHashTable *keys)
GHashTable * GHashTable *
p_gpg_fingerprints(void) p_gpg_pubkeys(void)
{ {
return fingerprints; return pubkeys;
} }
const char* const char*
@ -366,8 +401,8 @@ p_gpg_valid_key(const char * const keyid)
gboolean gboolean
p_gpg_available(const char * const barejid) p_gpg_available(const char * const barejid)
{ {
char *fp = g_hash_table_lookup(fingerprints, barejid); char *pubkey = g_hash_table_lookup(pubkeys, barejid);
return (fp != NULL); return (pubkey != NULL);
} }
void void
@ -406,8 +441,19 @@ p_gpg_verify(const char * const barejid, const char *const sign)
gpgme_verify_result_t result = gpgme_op_verify_result(ctx); gpgme_verify_result_t result = gpgme_op_verify_result(ctx);
if (result) { if (result) {
if (result->signatures) { if (result->signatures) {
log_debug("Fingerprint found for %s: %s ", barejid, result->signatures->fpr); gpgme_key_t key = NULL;
g_hash_table_replace(fingerprints, strdup(barejid), strdup(result->signatures->fpr)); error = gpgme_get_key(ctx, result->signatures->fpr, &key, 0);
if (error) {
log_debug("Could not find PGP key with ID %s for %s", result->signatures->fpr, barejid);
} else {
log_debug("Fingerprint found for %s: %s ", barejid, key->subkeys->fpr);
ProfPGPPubKeyId *pubkeyid = malloc(sizeof(ProfPGPPubKeyId));
pubkeyid->id = strdup(key->subkeys->keyid);
pubkeyid->received = TRUE;
g_hash_table_replace(pubkeys, strdup(barejid), pubkeyid);
}
gpgme_key_unref(key);
} }
} }
@ -485,9 +531,11 @@ p_gpg_sign(const char * const str, const char * const fp)
char * char *
p_gpg_encrypt(const char * const barejid, const char * const message) p_gpg_encrypt(const char * const barejid, const char * const message)
{ {
char *fp = g_hash_table_lookup(fingerprints, barejid); ProfPGPPubKeyId *pubkeyid = g_hash_table_lookup(pubkeys, barejid);
if (!pubkeyid) {
if (!fp) { return NULL;
}
if (!pubkeyid->id) {
return NULL; return NULL;
} }
@ -504,7 +552,7 @@ p_gpg_encrypt(const char * const barejid, const char * const message)
} }
gpgme_key_t key; gpgme_key_t key;
error = gpgme_get_key(ctx, fp, &key, 0); error = gpgme_get_key(ctx, pubkeyid->id, &key, 0);
if (error || key == NULL) { if (error || key == NULL) {
log_error("GPG: Failed to get key. %s %s", gpgme_strsource(error), gpgme_strerror(error)); log_error("GPG: Failed to get key. %s %s", gpgme_strsource(error), gpgme_strerror(error));
@ -580,7 +628,7 @@ p_gpg_decrypt(const char * const cipher)
gpgme_recipient_t recipient = res->recipients; gpgme_recipient_t recipient = res->recipients;
if (recipient) { if (recipient) {
gpgme_key_t key; gpgme_key_t key;
error = gpgme_get_key(ctx, recipient->keyid, &key, 0); error = gpgme_get_key(ctx, recipient->keyid, &key, 1);
if (!error && key) { if (!error && key) {
const char *addr = gpgme_key_get_string_attr(key, GPGME_ATTR_EMAIL, NULL, 0); const char *addr = gpgme_key_get_string_attr(key, GPGME_ATTR_EMAIL, NULL, 0);
@ -611,6 +659,18 @@ p_gpg_free_decrypted(char *decrypted)
g_free(decrypted); g_free(decrypted);
} }
char *
p_gpg_autocomplete_key(const char * const search_str)
{
return autocomplete_complete(key_ac, search_str, TRUE);
}
void
p_gpg_autocomplete_key_reset(void)
{
autocomplete_reset(key_ac);
}
static char* static char*
_remove_header_footer(char *str, const char * const footer) _remove_header_footer(char *str, const char * const footer)
{ {
@ -653,11 +713,11 @@ _add_header_footer(const char * const str, const char * const header, const char
} }
static void static void
_save_fps(void) _save_pubkeys(void)
{ {
gsize g_data_size; gsize g_data_size;
gchar *g_fps_data = g_key_file_to_data(fpskeyfile, &g_data_size, NULL); gchar *g_pubkeys_data = g_key_file_to_data(pubkeyfile, &g_data_size, NULL);
g_file_set_contents(fpsloc, g_fps_data, g_data_size, NULL); g_file_set_contents(pubsloc, g_pubkeys_data, g_data_size, NULL);
g_chmod(fpsloc, S_IRUSR | S_IWUSR); g_chmod(pubsloc, S_IRUSR | S_IWUSR);
g_free(g_fps_data); g_free(g_pubkeys_data);
} }

View File

@ -46,6 +46,11 @@ typedef struct pgp_key_t {
gboolean secret; gboolean secret;
} ProfPGPKey; } ProfPGPKey;
typedef struct pgp_pubkeyid_t {
char *id;
gboolean received;
} ProfPGPPubKeyId;
void p_gpg_init(void); void p_gpg_init(void);
void p_gpg_close(void); void p_gpg_close(void);
void p_gpg_on_connect(const char * const barejid); void p_gpg_on_connect(const char * const barejid);
@ -53,7 +58,7 @@ void p_gpg_on_disconnect(void);
GHashTable* p_gpg_list_keys(void); GHashTable* p_gpg_list_keys(void);
void p_gpg_free_keys(GHashTable *keys); void p_gpg_free_keys(GHashTable *keys);
gboolean p_gpg_addkey(const char * const jid, const char * const keyid); gboolean p_gpg_addkey(const char * const jid, const char * const keyid);
GHashTable* p_gpg_fingerprints(void); GHashTable* p_gpg_pubkeys(void);
gboolean p_gpg_valid_key(const char * const keyid); gboolean p_gpg_valid_key(const char * const keyid);
gboolean p_gpg_available(const char * const barejid); gboolean p_gpg_available(const char * const barejid);
const char* p_gpg_libver(void); const char* p_gpg_libver(void);
@ -62,5 +67,7 @@ void p_gpg_verify(const char * const barejid, const char *const sign);
char* p_gpg_encrypt(const char * const barejid, const char * const message); char* p_gpg_encrypt(const char * const barejid, const char * const message);
char* p_gpg_decrypt(const char * const cipher); char* p_gpg_decrypt(const char * const cipher);
void p_gpg_free_decrypted(char *decrypted); void p_gpg_free_decrypted(char *decrypted);
char* p_gpg_autocomplete_key(const char * const search_str);
void p_gpg_autocomplete_key_reset(void);
#endif #endif

View File

@ -1453,6 +1453,9 @@ cons_show_otr_prefs(void)
} }
prefs_free_string(log_value); prefs_free_string(log_value);
char ch = prefs_get_otr_char();
cons_show("OTR char (/otr char) : %c", ch);
cons_alert(); cons_alert();
} }
@ -1472,6 +1475,9 @@ cons_show_pgp_prefs(void)
} }
prefs_free_string(log_value); prefs_free_string(log_value);
char ch = prefs_get_pgp_char();
cons_show("PGP char (/pgp char) : %c", ch);
cons_alert(); cons_alert();
} }

View File

@ -412,7 +412,7 @@ ui_message_receipt(const char * const barejid, const char * const id)
} }
void void
ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GDateTime *timestamp, gboolean win_created) ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GDateTime *timestamp, gboolean win_created, prof_enc_t enc_mode)
{ {
ProfWin *window = (ProfWin*)chatwin; ProfWin *window = (ProfWin*)chatwin;
int num = wins_get_num(window); int num = wins_get_num(window);
@ -421,7 +421,7 @@ ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char *
// currently viewing chat window with sender // currently viewing chat window with sender
if (wins_is_current(window)) { if (wins_is_current(window)) {
win_print_incoming_message(window, timestamp, display_name, message); win_print_incoming_message(window, timestamp, display_name, message, enc_mode);
title_bar_set_typing(FALSE); title_bar_set_typing(FALSE);
status_bar_active(num); status_bar_active(num);
@ -447,7 +447,7 @@ ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char *
} }
} }
win_print_incoming_message(window, timestamp, display_name, message); win_print_incoming_message(window, timestamp, display_name, message, enc_mode);
} }
if (prefs_get_boolean(PREF_BEEP)) { if (prefs_get_boolean(PREF_BEEP)) {
@ -478,7 +478,7 @@ ui_incoming_private_msg(const char * const fulljid, const char * const message,
// currently viewing chat window with sender // currently viewing chat window with sender
if (wins_is_current(window)) { if (wins_is_current(window)) {
win_print_incoming_message(window, timestamp, display_from, message); win_print_incoming_message(window, timestamp, display_from, message, PROF_ENC_NONE);
title_bar_set_typing(FALSE); title_bar_set_typing(FALSE);
status_bar_active(num); status_bar_active(num);
@ -487,7 +487,7 @@ ui_incoming_private_msg(const char * const fulljid, const char * const message,
privatewin->unread++; privatewin->unread++;
status_bar_new(num); status_bar_new(num);
cons_show_incoming_message(display_from, num); cons_show_incoming_message(display_from, num);
win_print_incoming_message(window, timestamp, display_from, message); win_print_incoming_message(window, timestamp, display_from, message, PROF_ENC_NONE);
if (prefs_get_boolean(PREF_FLASH)) { if (prefs_get_boolean(PREF_FLASH)) {
flash(); flash();
@ -1287,12 +1287,19 @@ ui_new_chat_win(const char * const barejid)
} }
void void
ui_outgoing_chat_msg(ProfChatWin *chatwin, const char * const message, char *id) ui_outgoing_chat_msg(ProfChatWin *chatwin, const char * const message, char *id, prof_enc_t enc_mode)
{ {
char enc_char = '-';
if (enc_mode == PROF_ENC_OTR) {
enc_char = prefs_get_otr_char();
} else if (enc_mode == PROF_ENC_PGP) {
enc_char = prefs_get_pgp_char();
}
if (prefs_get_boolean(PREF_RECEIPTS_REQUEST) && id) { if (prefs_get_boolean(PREF_RECEIPTS_REQUEST) && id) {
win_print_with_receipt((ProfWin*)chatwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message, id); win_print_with_receipt((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message, id);
} else { } else {
win_print((ProfWin*)chatwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message); win_print((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message);
} }
} }

View File

@ -102,14 +102,14 @@ void ui_handle_stanza(const char * const msg);
// ui events // ui events
void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity); void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity);
void ui_contact_typing(const char * const barejid, const char * const resource); void ui_contact_typing(const char * const barejid, const char * const resource);
void ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GDateTime *timestamp, gboolean win_created); void ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GDateTime *timestamp, gboolean win_created, prof_enc_t enc_mode);
void ui_incoming_private_msg(const char * const fulljid, const char * const message, GDateTime *timestamp); void ui_incoming_private_msg(const char * const fulljid, const char * const message, GDateTime *timestamp);
void ui_message_receipt(const char * const barejid, const char * const id); void ui_message_receipt(const char * const barejid, const char * const id);
void ui_disconnected(void); void ui_disconnected(void);
void ui_recipient_gone(const char * const barejid, const char * const resource); void ui_recipient_gone(const char * const barejid, const char * const resource);
void ui_outgoing_chat_msg(ProfChatWin *chatwin, const char * const message, char *id); void ui_outgoing_chat_msg(ProfChatWin *chatwin, const char * const message, char *id, prof_enc_t enc_mode);
void ui_outgoing_chat_msg_carbon(const char * const barejid, const char * const message); void ui_outgoing_chat_msg_carbon(const char * const barejid, const char * const message);
void ui_outgoing_private_msg(ProfPrivateWin *privwin, const char * const message); void ui_outgoing_private_msg(ProfPrivateWin *privwin, const char * const message);

View File

@ -877,11 +877,20 @@ win_show_status_string(ProfWin *window, const char * const from,
void void
win_print_incoming_message(ProfWin *window, GDateTime *timestamp, win_print_incoming_message(ProfWin *window, GDateTime *timestamp,
const char * const from, const char * const message) const char * const from, const char * const message, prof_enc_t enc_mode)
{ {
char enc_char = '-';
switch (window->type) switch (window->type)
{ {
case WIN_CHAT: case WIN_CHAT:
if (enc_mode == PROF_ENC_OTR) {
enc_char = prefs_get_otr_char();
} else if (enc_mode == PROF_ENC_PGP) {
enc_char = prefs_get_pgp_char();
}
win_print(window, enc_char, 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message);
break;
case WIN_PRIVATE: case WIN_PRIVATE:
win_print(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); win_print(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message);
break; break;

View File

@ -60,7 +60,7 @@ void win_show_status_string(ProfWin *window, const char * const from,
GDateTime *last_activity, const char * const pre, GDateTime *last_activity, const char * const pre,
const char * const default_show); const char * const default_show);
void win_print_incoming_message(ProfWin *window, GDateTime *timestamp, void win_print_incoming_message(ProfWin *window, GDateTime *timestamp,
const char * const from, const char * const message); const char * const from, const char * const message, prof_enc_t enc_mode);
void win_print_with_receipt(ProfWin *window, const char show_char, int pad_indent, GTimeVal *tstamp, int flags, void win_print_with_receipt(ProfWin *window, const char show_char, int pad_indent, GTimeVal *tstamp, int flags,
theme_item_t theme_item, const char * const from, const char * const message, char *id); theme_item_t theme_item, const char * const from, const char * const message, char *id);
void win_newline(ProfWin *window); void win_newline(ProfWin *window);

View File

@ -11,7 +11,7 @@ GHashTable* p_gpg_list_keys(void)
} }
GHashTable* GHashTable*
p_gpg_fingerprints(void) p_gpg_pubkeys(void)
{ {
return NULL; return NULL;
} }
@ -54,3 +54,10 @@ void p_gpg_free_decrypted(char *decrypted) {}
void p_gpg_free_keys(GHashTable *keys) {} void p_gpg_free_keys(GHashTable *keys) {}
void p_gpg_autocomplete_key_reset(void) {}
char * p_gpg_autocomplete_key(const char * const search_str)
{
return NULL;
}

View File

@ -179,7 +179,7 @@ void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activi
} }
void ui_contact_typing(const char * const barejid, const char * const resource) {} void ui_contact_typing(const char * const barejid, const char * const resource) {}
void ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GDateTime *timestamp, gboolean win_created) {} void ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GDateTime *timestamp, gboolean win_created, prof_enc_t enc_mode) {}
void ui_message_receipt(const char * const barejid, const char * const id) {} void ui_message_receipt(const char * const barejid, const char * const id) {}
void ui_incoming_private_msg(const char * const fulljid, const char * const message, GDateTime *timestamp) {} void ui_incoming_private_msg(const char * const fulljid, const char * const message, GDateTime *timestamp) {}
@ -187,7 +187,7 @@ void ui_incoming_private_msg(const char * const fulljid, const char * const mess
void ui_disconnected(void) {} void ui_disconnected(void) {}
void ui_recipient_gone(const char * const barejid, const char * const resource) {} void ui_recipient_gone(const char * const barejid, const char * const resource) {}
void ui_outgoing_chat_msg(ProfChatWin *chatwin, const char * const message, char *id) {} void ui_outgoing_chat_msg(ProfChatWin *chatwin, const char * const message, char *id, prof_enc_t enc_mode) {}
void ui_outgoing_chat_msg_carbon(const char * const barejid, const char * const message) {} void ui_outgoing_chat_msg_carbon(const char * const barejid, const char * const message) {}
void ui_outgoing_private_msg(ProfPrivateWin *privwin, const char * const message) {} void ui_outgoing_private_msg(ProfPrivateWin *privwin, const char * const message) {}

View File

@ -75,3 +75,5 @@ occupants=
occupants.size= occupants.size=
occupants.jid= occupants.jid=
wins.autotidy= wins.autotidy=
otr.char=
pgp.char=

View File

@ -75,3 +75,5 @@ occupants=true
occupants.size=15 occupants.size=15
occupants.jid=false occupants.jid=false
wins.autotidy=true wins.autotidy=true
otr.char=@
pgp.char=%