mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-22 01:16:21 +00:00
Add optional pgp public key autoimport
Refactor `p_gpg_list_keys` Add `/pgp autoimport` command, it's not described in XEP-0027, but used in some clients, such as PSI, Pidgin. It will autoimport keys received with `/pgp sendpub`, in plain text as a message, or using features, provided in other clients. It doesn't autoassign them, but shows command to assign, letting user to decide. Improve documentation for some preexisting functions Add contact argument to `/pgp sendpub`
This commit is contained in:
@@ -7361,7 +7361,9 @@ cmd_pgp(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(args[0], "log") == 0) {
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "log") == 0) {
|
||||
char* choice = args[1];
|
||||
if (g_strcmp0(choice, "on") == 0) {
|
||||
prefs_set_string(PREF_PGP_LOG, "on");
|
||||
@@ -7384,6 +7386,11 @@ cmd_pgp(ProfWin* window, const char* const command, gchar** args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "autoimport") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], "PGP keys autoimport from messages", PREF_PGP_PUBKEY_AUTOIMPORT);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "keys") == 0) {
|
||||
GHashTable* keys = p_gpg_list_keys();
|
||||
if (!keys || g_hash_table_size(keys) == 0) {
|
||||
@@ -7494,7 +7501,7 @@ cmd_pgp(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
|
||||
if (window->type != WIN_CHAT && args[1] == NULL) {
|
||||
cons_show("You must be in a regular chat window to start PGP encryption.");
|
||||
cons_show("You must set recipient in an argument or be in a regular chat window to start PGP encryption.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -7587,11 +7594,17 @@ cmd_pgp(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "sendpub") == 0) {
|
||||
if (window->type != WIN_CHAT) {
|
||||
cons_show_error("Please, use this command only in chat windows.");
|
||||
jabber_conn_status_t conn_status = connection_get_status();
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You must be connected to share your PGP public key.");
|
||||
return TRUE;
|
||||
}
|
||||
ProfChatWin* chatwin = (ProfChatWin*)window;
|
||||
|
||||
if (window->type != WIN_CHAT && args[1] == NULL) {
|
||||
cons_show("You must set recipient in an argument or use this command in a regular chat window to share your PGP key.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ProfAccount* account = accounts_get_account(session_get_account_name());
|
||||
|
||||
if (account->pgp_keyid == NULL) {
|
||||
@@ -7605,7 +7618,28 @@ cmd_pgp(ProfWin* window, const char* const command, gchar** args)
|
||||
account_free(account);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ProfChatWin* chatwin = NULL;
|
||||
|
||||
if (args[1]) {
|
||||
char* contact = args[1];
|
||||
char* barejid = roster_barejid_from_name(contact);
|
||||
if (barejid == NULL) {
|
||||
barejid = contact;
|
||||
}
|
||||
|
||||
chatwin = wins_get_chat(barejid);
|
||||
if (!chatwin) {
|
||||
chatwin = chatwin_new(barejid);
|
||||
}
|
||||
ui_focus_win((ProfWin*)chatwin);
|
||||
} else {
|
||||
chatwin = (ProfChatWin*)window;
|
||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||
}
|
||||
|
||||
cl_ev_send_msg(chatwin, pubkey, NULL);
|
||||
win_update_entry_message((ProfWin*)chatwin, chatwin->last_msg_id, "[you shared your PGP key]");
|
||||
cons_show("PGP key has been shared with %s.", chatwin->barejid);
|
||||
account_free(account);
|
||||
return TRUE;
|
||||
|
||||
Reference in New Issue
Block a user