mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Moved pgp signature generation to cl_ev_presence_send
This commit is contained in:
parent
0db7bcbdcd
commit
acd2d2309f
@ -68,7 +68,6 @@ tests_sources = \
|
|||||||
src/event/ui_events.c src/event/ui_events.h \
|
src/event/ui_events.c src/event/ui_events.h \
|
||||||
tests/xmpp/stub_xmpp.c \
|
tests/xmpp/stub_xmpp.c \
|
||||||
tests/ui/stub_ui.c \
|
tests/ui/stub_ui.c \
|
||||||
tests/pgp/stub_gpg.c \
|
|
||||||
tests/log/stub_log.c \
|
tests/log/stub_log.c \
|
||||||
tests/config/stub_accounts.c \
|
tests/config/stub_accounts.c \
|
||||||
tests/helpers.c tests/helpers.h \
|
tests/helpers.c tests/helpers.h \
|
||||||
@ -103,6 +102,9 @@ git_include = src/gitversion.h
|
|||||||
pgp_sources = \
|
pgp_sources = \
|
||||||
src/pgp/gpg.h src/pgp/gpg.c
|
src/pgp/gpg.h src/pgp/gpg.c
|
||||||
|
|
||||||
|
pgp_test_sources = \
|
||||||
|
tests/pgp/stub_gpg.c
|
||||||
|
|
||||||
otr3_sources = \
|
otr3_sources = \
|
||||||
src/otr/otrlib.h src/otr/otrlibv3.c src/otr/otr.h src/otr/otr.c
|
src/otr/otrlib.h src/otr/otrlibv3.c src/otr/otr.h src/otr/otr.c
|
||||||
|
|
||||||
@ -120,6 +122,7 @@ man_sources = docs/profanity.1
|
|||||||
|
|
||||||
if BUILD_PGP
|
if BUILD_PGP
|
||||||
core_sources += $(pgp_sources)
|
core_sources += $(pgp_sources)
|
||||||
|
tests_sources += $(pgp_test_sources)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if BUILD_OTR
|
if BUILD_OTR
|
||||||
|
@ -42,6 +42,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
|
||||||
|
|
||||||
jabber_conn_status_t
|
jabber_conn_status_t
|
||||||
cl_ev_connect_jid(const char * const jid, const char * const passwd, const char * const altdomain, const int port)
|
cl_ev_connect_jid(const char * const jid, const char * const passwd, const char * const altdomain, const int port)
|
||||||
@ -63,7 +66,19 @@ cl_ev_connect_account(ProfAccount *account)
|
|||||||
void
|
void
|
||||||
cl_ev_presence_send(const resource_presence_t presence_type, const char * const msg, const int idle)
|
cl_ev_presence_send(const resource_presence_t presence_type, const char * const msg, const int idle)
|
||||||
{
|
{
|
||||||
presence_send(presence_type, msg, idle);
|
char *signed_status = NULL;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBGPGME
|
||||||
|
char *account_name = jabber_get_account_name();
|
||||||
|
ProfAccount *account = accounts_get_account(account_name);
|
||||||
|
if (account->pgp_keyid) {
|
||||||
|
signed_status = p_gpg_sign(msg, account->pgp_keyid);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
presence_send(presence_type, msg, idle, signed_status);
|
||||||
|
|
||||||
|
free(signed_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -196,7 +196,7 @@ presence_reset_sub_request_search(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
presence_send(const resource_presence_t presence_type, const char * const msg, const int idle)
|
presence_send(const resource_presence_t presence_type, const char * const msg, const int idle, char *signed_status)
|
||||||
{
|
{
|
||||||
if (jabber_get_connection_status() != JABBER_CONNECTED) {
|
if (jabber_get_connection_status() != JABBER_CONNECTED) {
|
||||||
log_warning("Error setting presence, not connected.");
|
log_warning("Error setting presence, not connected.");
|
||||||
@ -224,27 +224,17 @@ presence_send(const resource_presence_t presence_type, const char * const msg, c
|
|||||||
|
|
||||||
stanza_attach_status(ctx, presence, msg);
|
stanza_attach_status(ctx, presence, msg);
|
||||||
|
|
||||||
#ifdef HAVE_LIBGPGME
|
if (signed_status) {
|
||||||
char *account_name = jabber_get_account_name();
|
xmpp_stanza_t *x = xmpp_stanza_new(ctx);
|
||||||
ProfAccount *account = accounts_get_account(account_name);
|
xmpp_stanza_set_name(x, STANZA_NAME_X);
|
||||||
if (account->pgp_keyid) {
|
xmpp_stanza_set_ns(x, STANZA_NS_SIGNED);
|
||||||
char *signed_status = p_gpg_sign(msg, account->pgp_keyid);
|
xmpp_stanza_t *signed_text = xmpp_stanza_new(ctx);
|
||||||
|
xmpp_stanza_set_text(signed_text, signed_status);
|
||||||
if (signed_status) {
|
xmpp_stanza_add_child(x, signed_text);
|
||||||
xmpp_stanza_t *x = xmpp_stanza_new(ctx);
|
xmpp_stanza_release(signed_text);
|
||||||
xmpp_stanza_set_name(x, STANZA_NAME_X);
|
xmpp_stanza_add_child(presence, x);
|
||||||
xmpp_stanza_set_ns(x, STANZA_NS_SIGNED);
|
xmpp_stanza_release(x);
|
||||||
xmpp_stanza_t *signed_text = xmpp_stanza_new(ctx);
|
|
||||||
xmpp_stanza_set_text(signed_text, signed_status);
|
|
||||||
xmpp_stanza_add_child(x, signed_text);
|
|
||||||
xmpp_stanza_release(signed_text);
|
|
||||||
xmpp_stanza_add_child(presence, x);
|
|
||||||
xmpp_stanza_release(x);
|
|
||||||
|
|
||||||
free(signed_status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
stanza_attach_priority(ctx, presence, pri);
|
stanza_attach_priority(ctx, presence, pri);
|
||||||
stanza_attach_last_activity(ctx, presence, idle);
|
stanza_attach_last_activity(ctx, presence, idle);
|
||||||
|
@ -168,8 +168,7 @@ char * presence_sub_request_find(const char * const search_str);
|
|||||||
void presence_join_room(char *room, char *nick, char * passwd);
|
void presence_join_room(char *room, char *nick, char * passwd);
|
||||||
void presence_change_room_nick(const char * const room, const char * const nick);
|
void presence_change_room_nick(const char * const room, const char * const nick);
|
||||||
void presence_leave_chat_room(const char * const room_jid);
|
void presence_leave_chat_room(const char * const room_jid);
|
||||||
void presence_send(resource_presence_t status, const char * const msg,
|
void presence_send(resource_presence_t status, const char * const msg, int idle, char *signed_status);
|
||||||
int idle);
|
|
||||||
gboolean presence_sub_request_exists(const char * const bare_jid);
|
gboolean presence_sub_request_exists(const char * const bare_jid);
|
||||||
|
|
||||||
// iq functions
|
// iq functions
|
||||||
|
@ -24,3 +24,9 @@ const char* p_gpg_libver(void)
|
|||||||
void p_gpg_free_key(ProfPGPKey *key) {}
|
void p_gpg_free_key(ProfPGPKey *key) {}
|
||||||
|
|
||||||
void p_gpg_verify(const char * const barejid, const char *const sign) {}
|
void p_gpg_verify(const char * const barejid, const char *const sign) {}
|
||||||
|
|
||||||
|
char* p_gpg_sign(const char * const str, const char * const fp)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -926,6 +926,8 @@ void cmd_account_set_priority_updates_presence_when_account_connected_with_prese
|
|||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||||
gchar *args[] = { "set", "a_account", "online", "10", NULL };
|
gchar *args[] = { "set", "a_account", "online", "10", NULL };
|
||||||
|
ProfAccount *account = account_new("a_account", "a_jid", NULL, NULL, TRUE, NULL, 5222, "a_resource",
|
||||||
|
NULL, NULL, 10, 10, 10, 10, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
will_return(accounts_account_exists, TRUE);
|
will_return(accounts_account_exists, TRUE);
|
||||||
@ -934,16 +936,22 @@ void cmd_account_set_priority_updates_presence_when_account_connected_with_prese
|
|||||||
expect_any(accounts_set_priority_online, value);
|
expect_any(accounts_set_priority_online, value);
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
will_return(jabber_get_account_name, "a_account");
|
|
||||||
|
|
||||||
expect_any(accounts_get_last_presence, account_name);
|
expect_any(accounts_get_last_presence, account_name);
|
||||||
will_return(accounts_get_last_presence, RESOURCE_ONLINE);
|
will_return(accounts_get_last_presence, RESOURCE_ONLINE);
|
||||||
|
|
||||||
|
will_return(jabber_get_account_name, "a_account");
|
||||||
|
will_return(jabber_get_account_name, "a_account");
|
||||||
|
|
||||||
|
expect_any(accounts_get_account, name);
|
||||||
|
will_return(accounts_get_account, account);
|
||||||
|
|
||||||
will_return(jabber_get_presence_message, "Free to chat");
|
will_return(jabber_get_presence_message, "Free to chat");
|
||||||
|
|
||||||
expect_value(presence_send, status, RESOURCE_ONLINE);
|
expect_value(presence_send, status, RESOURCE_ONLINE);
|
||||||
expect_string(presence_send, msg, "Free to chat");
|
expect_string(presence_send, msg, "Free to chat");
|
||||||
expect_value(presence_send, idle, 0);
|
expect_value(presence_send, idle, 0);
|
||||||
|
expect_value(presence_send, signed_status, NULL);
|
||||||
|
|
||||||
expect_cons_show("Updated online priority for account a_account: 10");
|
expect_cons_show("Updated online priority for account a_account: 10");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
@ -114,11 +114,12 @@ void presence_join_room(char *room, char *nick, char * passwd)
|
|||||||
void presence_change_room_nick(const char * const room, const char * const nick) {}
|
void presence_change_room_nick(const char * const room, const char * const nick) {}
|
||||||
void presence_leave_chat_room(const char * const room_jid) {}
|
void presence_leave_chat_room(const char * const room_jid) {}
|
||||||
|
|
||||||
void presence_send(resource_presence_t status, const char * const msg, int idle)
|
void presence_send(resource_presence_t status, const char * const msg, int idle, char *signed_status)
|
||||||
{
|
{
|
||||||
check_expected(status);
|
check_expected(status);
|
||||||
check_expected(msg);
|
check_expected(msg);
|
||||||
check_expected(idle);
|
check_expected(idle);
|
||||||
|
check_expected(signed_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean presence_sub_request_exists(const char * const bare_jid)
|
gboolean presence_sub_request_exists(const char * const bare_jid)
|
||||||
|
Loading…
Reference in New Issue
Block a user