1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Applied coding style to src/otr/

This commit is contained in:
James Booth 2015-10-25 22:40:09 +00:00
parent afbd2693cd
commit 894fa355e8
5 changed files with 63 additions and 64 deletions

View File

@ -63,13 +63,13 @@ otr_userstate(void)
return user_state; return user_state;
} }
OtrlMessageAppOps * OtrlMessageAppOps*
otr_messageops(void) otr_messageops(void)
{ {
return &ops; return &ops;
} }
GHashTable * GHashTable*
otr_smpinitators(void) otr_smpinitators(void)
{ {
return smp_initiators; return smp_initiators;
@ -146,13 +146,13 @@ cb_gone_secure(void *opdata, ConnContext *context)
ui_gone_secure(context->username, otr_is_trusted(context->username)); ui_gone_secure(context->username, otr_is_trusted(context->username));
} }
char * char*
otr_libotr_version(void) otr_libotr_version(void)
{ {
return OTRL_VERSION; return OTRL_VERSION;
} }
char * char*
otr_start_query(void) otr_start_query(void)
{ {
return otrlib_start_query(); return otrlib_start_query();
@ -274,7 +274,7 @@ otr_on_connect(ProfAccount *account)
} }
char* char*
otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message, gboolean *decrypted) otr_on_message_recv(const char *const barejid, const char *const resource, const char *const message, gboolean *decrypted)
{ {
prof_otrpolicy_t policy = otr_get_policy(barejid); prof_otrpolicy_t policy = otr_get_policy(barejid);
char *whitespace_base = strstr(message, OTRL_MESSAGE_TAG_BASE); char *whitespace_base = strstr(message, OTRL_MESSAGE_TAG_BASE);
@ -314,7 +314,7 @@ otr_on_message_recv(const char * const barejid, const char * const resource, con
} }
gboolean gboolean
otr_on_message_send(ProfChatWin *chatwin, const char * const message) otr_on_message_send(ProfChatWin *chatwin, const char *const message)
{ {
char *id = NULL; char *id = NULL;
prof_otrpolicy_t policy = otr_get_policy(chatwin->barejid); prof_otrpolicy_t policy = otr_get_policy(chatwin->barejid);
@ -451,8 +451,8 @@ otr_key_loaded(void)
return data_loaded; return data_loaded;
} }
char * char*
otr_tag_message(const char * const msg) otr_tag_message(const char *const msg)
{ {
GString *otr_message = g_string_new(msg); GString *otr_message = g_string_new(msg);
g_string_append(otr_message, OTRL_MESSAGE_TAG_BASE); g_string_append(otr_message, OTRL_MESSAGE_TAG_BASE);
@ -464,7 +464,7 @@ otr_tag_message(const char * const msg)
} }
gboolean gboolean
otr_is_secure(const char * const recipient) otr_is_secure(const char *const recipient)
{ {
ConnContext *context = otrlib_context_find(user_state, recipient, jid); ConnContext *context = otrlib_context_find(user_state, recipient, jid);
@ -480,7 +480,7 @@ otr_is_secure(const char * const recipient)
} }
gboolean gboolean
otr_is_trusted(const char * const recipient) otr_is_trusted(const char *const recipient)
{ {
ConnContext *context = otrlib_context_find(user_state, recipient, jid); ConnContext *context = otrlib_context_find(user_state, recipient, jid);
@ -506,7 +506,7 @@ otr_is_trusted(const char * const recipient)
} }
void void
otr_trust(const char * const recipient) otr_trust(const char *const recipient)
{ {
ConnContext *context = otrlib_context_find(user_state, recipient, jid); ConnContext *context = otrlib_context_find(user_state, recipient, jid);
@ -530,7 +530,7 @@ otr_trust(const char * const recipient)
} }
void void
otr_untrust(const char * const recipient) otr_untrust(const char *const recipient)
{ {
ConnContext *context = otrlib_context_find(user_state, recipient, jid); ConnContext *context = otrlib_context_find(user_state, recipient, jid);
@ -554,7 +554,7 @@ otr_untrust(const char * const recipient)
} }
void void
otr_smp_secret(const char * const recipient, const char *secret) otr_smp_secret(const char *const recipient, const char *secret)
{ {
ConnContext *context = otrlib_context_find(user_state, recipient, jid); ConnContext *context = otrlib_context_find(user_state, recipient, jid);
@ -578,7 +578,7 @@ otr_smp_secret(const char * const recipient, const char *secret)
} }
void void
otr_smp_question(const char * const recipient, const char *question, const char *answer) otr_smp_question(const char *const recipient, const char *question, const char *answer)
{ {
ConnContext *context = otrlib_context_find(user_state, recipient, jid); ConnContext *context = otrlib_context_find(user_state, recipient, jid);
@ -595,7 +595,7 @@ otr_smp_question(const char * const recipient, const char *question, const char
} }
void void
otr_smp_answer(const char * const recipient, const char *answer) otr_smp_answer(const char *const recipient, const char *answer)
{ {
ConnContext *context = otrlib_context_find(user_state, recipient, jid); ConnContext *context = otrlib_context_find(user_state, recipient, jid);
@ -612,12 +612,12 @@ otr_smp_answer(const char * const recipient, const char *answer)
} }
void void
otr_end_session(const char * const recipient) otr_end_session(const char *const recipient)
{ {
otrlib_end_session(user_state, recipient, jid, &ops); otrlib_end_session(user_state, recipient, jid, &ops);
} }
char * char*
otr_get_my_fingerprint(void) otr_get_my_fingerprint(void)
{ {
char fingerprint[45]; char fingerprint[45];
@ -627,8 +627,8 @@ otr_get_my_fingerprint(void)
return result; return result;
} }
char * char*
otr_get_their_fingerprint(const char * const recipient) otr_get_their_fingerprint(const char *const recipient)
{ {
ConnContext *context = otrlib_context_find(user_state, recipient, jid); ConnContext *context = otrlib_context_find(user_state, recipient, jid);
@ -643,7 +643,7 @@ otr_get_their_fingerprint(const char * const recipient)
} }
prof_otrpolicy_t prof_otrpolicy_t
otr_get_policy(const char * const recipient) otr_get_policy(const char *const recipient)
{ {
char *account_name = jabber_get_account_name(); char *account_name = jabber_get_account_name();
ProfAccount *account = accounts_get_account(account_name); ProfAccount *account = accounts_get_account(account_name);
@ -695,8 +695,8 @@ otr_get_policy(const char * const recipient)
return result; return result;
} }
char * char*
otr_encrypt_message(const char * const to, const char * const message) otr_encrypt_message(const char *const to, const char *const message)
{ {
char *newmessage = NULL; char *newmessage = NULL;
gcry_error_t err = otrlib_encrypt_message(user_state, &ops, jid, to, message, &newmessage); gcry_error_t err = otrlib_encrypt_message(user_state, &ops, jid, to, message, &newmessage);
@ -716,8 +716,8 @@ _otr_tlv_free(OtrlTLV *tlvs)
} }
} }
char * char*
otr_decrypt_message(const char * const from, const char * const message, gboolean *decrypted) otr_decrypt_message(const char *const from, const char *const message, gboolean *decrypted)
{ {
char *newmessage = NULL; char *newmessage = NULL;
OtrlTLV *tlvs = NULL; OtrlTLV *tlvs = NULL;

View File

@ -58,35 +58,35 @@ char* otr_start_query(void);
void otr_poll(void); void otr_poll(void);
void otr_on_connect(ProfAccount *account); void otr_on_connect(ProfAccount *account);
char* otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message, gboolean *decrypted); char* otr_on_message_recv(const char *const barejid, const char *const resource, const char *const message, gboolean *decrypted);
gboolean otr_on_message_send(ProfChatWin *chatwin, const char * const message); gboolean otr_on_message_send(ProfChatWin *chatwin, const char *const message);
void otr_keygen(ProfAccount *account); void otr_keygen(ProfAccount *account);
char* otr_tag_message(const char * const msg); char* otr_tag_message(const char *const msg);
gboolean otr_key_loaded(void); gboolean otr_key_loaded(void);
gboolean otr_is_secure(const char * const recipient); gboolean otr_is_secure(const char *const recipient);
gboolean otr_is_trusted(const char * const recipient); gboolean otr_is_trusted(const char *const recipient);
void otr_trust(const char * const recipient); void otr_trust(const char *const recipient);
void otr_untrust(const char * const recipient); void otr_untrust(const char *const recipient);
void otr_smp_secret(const char * const recipient, const char *secret); void otr_smp_secret(const char *const recipient, const char *secret);
void otr_smp_question(const char * const recipient, const char *question, const char *answer); void otr_smp_question(const char *const recipient, const char *question, const char *answer);
void otr_smp_answer(const char * const recipient, const char *answer); void otr_smp_answer(const char *const recipient, const char *answer);
void otr_end_session(const char * const recipient); void otr_end_session(const char *const recipient);
char * otr_get_my_fingerprint(void); char* otr_get_my_fingerprint(void);
char * otr_get_their_fingerprint(const char * const recipient); char* otr_get_their_fingerprint(const char *const recipient);
char * otr_encrypt_message(const char * const to, const char * const message); char* otr_encrypt_message(const char *const to, const char *const message);
char * otr_decrypt_message(const char * const from, const char * const message, char* otr_decrypt_message(const char *const from, const char *const message,
gboolean *decrypted); gboolean *decrypted);
void otr_free_message(char *message); void otr_free_message(char *message);
prof_otrpolicy_t otr_get_policy(const char * const recipient); prof_otrpolicy_t otr_get_policy(const char *const recipient);
#endif #endif

View File

@ -44,15 +44,15 @@ void otrlib_init_ops(OtrlMessageAppOps *ops);
void otrlib_init_timer(void); void otrlib_init_timer(void);
void otrlib_poll(void); void otrlib_poll(void);
ConnContext * otrlib_context_find(OtrlUserState user_state, const char * const recipient, char *jid); ConnContext* otrlib_context_find(OtrlUserState user_state, const char *const recipient, char *jid);
void otrlib_end_session(OtrlUserState user_state, const char * const recipient, char *jid, OtrlMessageAppOps *ops); void otrlib_end_session(OtrlUserState user_state, const char *const recipient, char *jid, OtrlMessageAppOps *ops);
gcry_error_t otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char * const to, gcry_error_t otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char *const to,
const char * const message, char **newmessage); const char *const message, char **newmessage);
int otrlib_decrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char * const from, int otrlib_decrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char *const from,
const char * const message, char **decrypted, OtrlTLV **tlvs); const char *const message, char **decrypted, OtrlTLV **tlvs);
void otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext *context, OtrlTLV *tlvs, GHashTable *smp_initiators); void otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext *context, OtrlTLV *tlvs, GHashTable *smp_initiators);

View File

@ -55,7 +55,7 @@ otrlib_poll(void)
{ {
} }
char * char*
otrlib_start_query(void) otrlib_start_query(void)
{ {
return "?OTR?v2? This user has requested an Off-the-Record private conversation. However, you do not have a plugin to support that. See http://otr.cypherpunks.ca/ for more information."; return "?OTR?v2? This user has requested an Off-the-Record private conversation. However, you do not have a plugin to support that. See http://otr.cypherpunks.ca/ for more information.";
@ -75,14 +75,14 @@ otrlib_init_ops(OtrlMessageAppOps *ops)
ops->display_otr_message = cb_display_otr_message; ops->display_otr_message = cb_display_otr_message;
} }
ConnContext * ConnContext*
otrlib_context_find(OtrlUserState user_state, const char * const recipient, char *jid) otrlib_context_find(OtrlUserState user_state, const char *const recipient, char *jid)
{ {
return otrl_context_find(user_state, recipient, jid, "xmpp", 0, NULL, NULL, NULL); return otrl_context_find(user_state, recipient, jid, "xmpp", 0, NULL, NULL, NULL);
} }
void void
otrlib_end_session(OtrlUserState user_state, const char * const recipient, char *jid, OtrlMessageAppOps *ops) otrlib_end_session(OtrlUserState user_state, const char *const recipient, char *jid, OtrlMessageAppOps *ops)
{ {
ConnContext *context = otrl_context_find(user_state, recipient, jid, "xmpp", ConnContext *context = otrl_context_find(user_state, recipient, jid, "xmpp",
0, NULL, NULL, NULL); 0, NULL, NULL, NULL);
@ -93,8 +93,8 @@ otrlib_end_session(OtrlUserState user_state, const char * const recipient, char
} }
gcry_error_t gcry_error_t
otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char * const to, otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char *const to,
const char * const message, char **newmessage) const char *const message, char **newmessage)
{ {
gcry_error_t err; gcry_error_t err;
err = otrl_message_sending( err = otrl_message_sending(
@ -114,8 +114,8 @@ otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *j
} }
int int
otrlib_decrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char * const from, otrlib_decrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char *const from,
const char * const message, char **decrypted, OtrlTLV **tlvs) const char *const message, char **decrypted, OtrlTLV **tlvs)
{ {
return otrl_message_receiving( return otrl_message_receiving(
user_state, user_state,

View File

@ -71,15 +71,14 @@ otrlib_poll(void)
} }
} }
char * char*
otrlib_start_query(void) otrlib_start_query(void)
{ {
return "?OTR?v2? This user has requested an Off-the-Record private conversation. However, you do not have a plugin to support that. See http://otr.cypherpunks.ca/ for more information."; return "?OTR?v2? This user has requested an Off-the-Record private conversation. However, you do not have a plugin to support that. See http://otr.cypherpunks.ca/ for more information.";
} }
static const char* static const char*
cb_otr_error_message(void *opdata, ConnContext *context, cb_otr_error_message(void *opdata, ConnContext *context, OtrlErrorCode err_code)
OtrlErrorCode err_code)
{ {
switch(err_code) switch(err_code)
{ {
@ -241,14 +240,14 @@ otrlib_init_ops(OtrlMessageAppOps *ops)
ops->timer_control = cb_timer_control; ops->timer_control = cb_timer_control;
} }
ConnContext * ConnContext*
otrlib_context_find(OtrlUserState user_state, const char * const recipient, char *jid) otrlib_context_find(OtrlUserState user_state, const char *const recipient, char *jid)
{ {
return otrl_context_find(user_state, recipient, jid, "xmpp", OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL); return otrl_context_find(user_state, recipient, jid, "xmpp", OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL);
} }
void void
otrlib_end_session(OtrlUserState user_state, const char * const recipient, char *jid, OtrlMessageAppOps *ops) otrlib_end_session(OtrlUserState user_state, const char *const recipient, char *jid, OtrlMessageAppOps *ops)
{ {
ConnContext *context = otrl_context_find(user_state, recipient, jid, "xmpp", ConnContext *context = otrl_context_find(user_state, recipient, jid, "xmpp",
OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL); OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL);
@ -259,8 +258,8 @@ otrlib_end_session(OtrlUserState user_state, const char * const recipient, char
} }
gcry_error_t gcry_error_t
otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char * const to, otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char *const to,
const char * const message, char **newmessage) const char *const message, char **newmessage)
{ {
gcry_error_t err; gcry_error_t err;
@ -284,8 +283,8 @@ otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *j
} }
int int
otrlib_decrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char * const from, otrlib_decrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char *const from,
const char * const message, char **decrypted, OtrlTLV **tlvs) const char *const message, char **decrypted, OtrlTLV **tlvs)
{ {
return otrl_message_receiving( return otrl_message_receiving(
user_state, user_state,