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

Applied coding style to src/xmpp/

This commit is contained in:
James Booth 2015-10-26 00:14:23 +00:00
parent 2ce43b633f
commit c8a6bdb381
14 changed files with 524 additions and 549 deletions

View File

@ -150,7 +150,7 @@ iq_room_list_request(gchar *conferencejid)
} }
void void
iq_enable_carbons() iq_enable_carbons(void)
{ {
xmpp_conn_t * const conn = connection_get_conn(); xmpp_conn_t * const conn = connection_get_conn();
xmpp_ctx_t * const ctx = connection_get_ctx(); xmpp_ctx_t * const ctx = connection_get_ctx();
@ -164,7 +164,7 @@ iq_enable_carbons()
} }
void void
iq_disable_carbons() iq_disable_carbons(void)
{ {
xmpp_conn_t * const conn = connection_get_conn(); xmpp_conn_t * const conn = connection_get_conn();
xmpp_ctx_t * const ctx = connection_get_ctx(); xmpp_ctx_t * const ctx = connection_get_ctx();
@ -1264,7 +1264,8 @@ _room_config_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
return 0; return 0;
} }
static int _room_affiliation_set_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, static int
_room_affiliation_set_result_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza,
void *const userdata) void *const userdata)
{ {
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
@ -1293,7 +1294,8 @@ static int _room_affiliation_set_result_handler(xmpp_conn_t * const conn, xmpp_s
return 0; return 0;
} }
static int _room_role_set_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, static int
_room_role_set_result_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza,
void *const userdata) void *const userdata)
{ {
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);

View File

@ -62,23 +62,15 @@
static Autocomplete sub_requests_ac; static Autocomplete sub_requests_ac;
#define HANDLE(ns, type, func) xmpp_handler_add(conn, func, ns, \ #define HANDLE(ns, type, func) xmpp_handler_add(conn, func, ns, STANZA_NAME_PRESENCE, type, ctx)
STANZA_NAME_PRESENCE, type, ctx)
static int _unavailable_handler(xmpp_conn_t * const conn, static int _unavailable_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata);
xmpp_stanza_t * const stanza, void * const userdata); static int _subscribe_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata);
static int _subscribe_handler(xmpp_conn_t * const conn, static int _subscribed_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata);
xmpp_stanza_t * const stanza, void * const userdata); static int _unsubscribed_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata);
static int _subscribed_handler(xmpp_conn_t * const conn, static int _available_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata);
xmpp_stanza_t * const stanza, void * const userdata); static int _muc_user_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata);
static int _unsubscribed_handler(xmpp_conn_t * const conn, static int _presence_error_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata);
xmpp_stanza_t * const stanza, void * const userdata);
static int _available_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata);
static int _muc_user_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata);
static int _presence_error_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata);
void _send_caps_request(char *node, char *caps_key, char *id, char *from); void _send_caps_request(char *node, char *caps_key, char *id, char *from);
static void _send_room_presence(xmpp_conn_t *conn, xmpp_stanza_t *presence); static void _send_room_presence(xmpp_conn_t *conn, xmpp_stanza_t *presence);

View File

@ -60,8 +60,7 @@
#include "xmpp/stanza.h" #include "xmpp/stanza.h"
#include "xmpp/xmpp.h" #include "xmpp/xmpp.h"
#define HANDLE(type, func) xmpp_handler_add(conn, func, XMPP_NS_ROSTER, \ #define HANDLE(type, func) xmpp_handler_add(conn, func, XMPP_NS_ROSTER, STANZA_NAME_IQ, type, ctx)
STANZA_NAME_IQ, type, ctx)
// callback data for group commands // callback data for group commands
typedef struct _group_data { typedef struct _group_data {
@ -70,18 +69,12 @@ typedef struct _group_data {
} GroupData; } GroupData;
// event handlers // event handlers
static int _roster_set_handler(xmpp_conn_t * const conn, static int _roster_set_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata);
xmpp_stanza_t * const stanza, void * const userdata); static int _roster_result_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata);
static int _roster_result_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata);
// id handlers // id handlers
static int static int _group_add_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata);
_group_add_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, static int _group_remove_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata);
void * const userdata);
static int
_group_remove_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
void * const userdata);
// helper functions // helper functions
GSList* _get_groups_from_item(xmpp_stanza_t *item); GSList* _get_groups_from_item(xmpp_stanza_t *item);

View File

@ -207,7 +207,8 @@ stanza_create_bookmarks_pubsub_add(xmpp_ctx_t *ctx, const char * const jid,
#endif #endif
xmpp_stanza_t* xmpp_stanza_t*
stanza_enable_carbons(xmpp_ctx_t *ctx){ stanza_enable_carbons(xmpp_ctx_t *ctx)
{
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
char *id = create_unique_id("carbons"); char *id = create_unique_id("carbons");
@ -227,7 +228,8 @@ stanza_enable_carbons(xmpp_ctx_t *ctx){
} }
xmpp_stanza_t* xmpp_stanza_t*
stanza_disable_carbons(xmpp_ctx_t *ctx){ stanza_disable_carbons(xmpp_ctx_t *ctx)
{
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
char *id = create_unique_id("carbons"); char *id = create_unique_id("carbons");

View File

@ -246,16 +246,11 @@ gboolean stanza_is_room_nick_change(xmpp_stanza_t * const stanza);
gboolean stanza_muc_requires_config(xmpp_stanza_t *const stanza); gboolean stanza_muc_requires_config(xmpp_stanza_t *const stanza);
char* stanza_get_new_nick(xmpp_stanza_t *const stanza); char* stanza_get_new_nick(xmpp_stanza_t *const stanza);
xmpp_stanza_t* stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx, xmpp_stanza_t* stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx, const char *const room_jid);
const char * const room_jid); xmpp_stanza_t* stanza_create_instant_room_destroy_iq(xmpp_ctx_t *ctx, const char *const room_jid);
xmpp_stanza_t* stanza_create_instant_room_destroy_iq(xmpp_ctx_t *ctx, xmpp_stanza_t* stanza_create_room_config_request_iq(xmpp_ctx_t *ctx, const char *const room_jid);
const char * const room_jid); xmpp_stanza_t* stanza_create_room_config_cancel_iq(xmpp_ctx_t *ctx, const char *const room_jid);
xmpp_stanza_t* stanza_create_room_config_request_iq(xmpp_ctx_t *ctx, xmpp_stanza_t* stanza_create_room_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, DataForm *form);
const char * const room_jid);
xmpp_stanza_t* stanza_create_room_config_cancel_iq(xmpp_ctx_t *ctx,
const char * const room_jid);
xmpp_stanza_t* stanza_create_room_config_submit_iq(xmpp_ctx_t *ctx,
const char * const room, DataForm *form);
xmpp_stanza_t* stanza_create_room_affiliation_list_iq(xmpp_ctx_t *ctx, const char *const room, xmpp_stanza_t* stanza_create_room_affiliation_list_iq(xmpp_ctx_t *ctx, const char *const room,
const char *const affiliation); const char *const affiliation);
xmpp_stanza_t* stanza_create_room_affiliation_set_iq(xmpp_ctx_t *ctx, const char *const room, const char *const jid, xmpp_stanza_t* stanza_create_room_affiliation_set_iq(xmpp_ctx_t *ctx, const char *const room, const char *const jid,
@ -274,28 +269,22 @@ char * stanza_get_caps_str(xmpp_stanza_t * const stanza);
DataForm* stanza_create_form(xmpp_stanza_t *const stanza); DataForm* stanza_create_form(xmpp_stanza_t *const stanza);
void stanza_destroy_form(DataForm *form); void stanza_destroy_form(DataForm *form);
void stanza_attach_priority(xmpp_ctx_t * const ctx, void stanza_attach_priority(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const int pri);
xmpp_stanza_t * const presence, const int pri); void stanza_attach_last_activity(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const int idle);
void stanza_attach_last_activity(xmpp_ctx_t * const ctx,
xmpp_stanza_t * const presence, const int idle);
void stanza_attach_caps(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence); void stanza_attach_caps(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence);
void stanza_attach_show(xmpp_ctx_t * const ctx, xmpp_stanza_t * const presence, void stanza_attach_show(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const char *const show);
const char * const show); void stanza_attach_status(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const char *const status);
void stanza_attach_status(xmpp_ctx_t * const ctx, xmpp_stanza_t * const presence,
const char * const status);
const char* stanza_get_presence_string_from_type(resource_presence_t presence_type); const char* stanza_get_presence_string_from_type(resource_presence_t presence_type);
xmpp_stanza_t* stanza_create_software_version_iq(xmpp_ctx_t *ctx, const char *const fulljid); xmpp_stanza_t* stanza_create_software_version_iq(xmpp_ctx_t *ctx, const char *const fulljid);
xmpp_stanza_t * stanza_create_disco_items_iq(xmpp_ctx_t *ctx, const char * const id, xmpp_stanza_t* stanza_create_disco_items_iq(xmpp_ctx_t *ctx, const char *const id, const char *const jid);
const char * const jid);
char* stanza_get_status(xmpp_stanza_t *stanza, char *def); char* stanza_get_status(xmpp_stanza_t *stanza, char *def);
char* stanza_get_show(xmpp_stanza_t *stanza, char *def); char* stanza_get_show(xmpp_stanza_t *stanza, char *def);
xmpp_stanza_t * stanza_create_roster_set(xmpp_ctx_t *ctx, const char * const id, xmpp_stanza_t* stanza_create_roster_set(xmpp_ctx_t *ctx, const char *const id, const char *const jid,
const char * const jid, const char * const handle, GSList *groups); const char *const handle, GSList *groups);
xmpp_stanza_t * stanza_create_roster_remove_set(xmpp_ctx_t *ctx, xmpp_stanza_t* stanza_create_roster_remove_set(xmpp_ctx_t *ctx, const char *const barejid);
const char * const barejid);
char* stanza_get_error_message(xmpp_stanza_t *const stanza); char* stanza_get_error_message(xmpp_stanza_t *const stanza);

View File

@ -138,8 +138,8 @@ typedef struct data_form_t {
// connection functions // connection functions
void jabber_init(void); void jabber_init(void);
jabber_conn_status_t jabber_connect_with_details(const char * const jid, jabber_conn_status_t jabber_connect_with_details(const char *const jid, const char *const passwd,
const char * const passwd, const char * const altdomain, const int port, const char *const tls_policy); const char *const altdomain, const int port, const char *const tls_policy);
jabber_conn_status_t jabber_connect_with_account(const ProfAccount *const account); jabber_conn_status_t jabber_connect_with_account(const ProfAccount *const account);
void jabber_disconnect(void); void jabber_disconnect(void);
void jabber_shutdown(void); void jabber_shutdown(void);
@ -166,8 +166,7 @@ void message_send_composing(const char * const jid);
void message_send_paused(const char *const jid); void message_send_paused(const char *const jid);
void message_send_gone(const char *const jid); void message_send_gone(const char *const jid);
void message_send_invite(const char * const room, const char * const contact, void message_send_invite(const char *const room, const char *const contact, const char *const reason);
const char * const reason);
// presence functions // presence functions
void presence_subscription(const char *const jid, const jabber_subscr_t action); void presence_subscription(const char *const jid, const jabber_subscr_t action);
@ -182,8 +181,8 @@ void presence_send(resource_presence_t status, const char * const msg, 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
void iq_enable_carbons(); void iq_enable_carbons(void);
void iq_disable_carbons(); void iq_disable_carbons(void);
void iq_send_software_version(const char *const fulljid); void iq_send_software_version(const char *const fulljid);
void iq_room_list_request(gchar *conferencejid); void iq_room_list_request(gchar *conferencejid);
void iq_disco_info_request(gchar *jid); void iq_disco_info_request(gchar *jid);
@ -196,19 +195,17 @@ void iq_request_room_config_form(const char * const room_jid);
void iq_submit_room_config(const char *const room, DataForm *form); void iq_submit_room_config(const char *const room, DataForm *form);
void iq_room_config_cancel(const char *const room_jid); void iq_room_config_cancel(const char *const room_jid);
void iq_send_ping(const char *const target); void iq_send_ping(const char *const target);
void iq_send_caps_request(const char * const to, const char * const id, void iq_send_caps_request(const char *const to, const char *const id, const char *const node, const char *const ver);
const char * const node, const char * const ver); void iq_send_caps_request_for_jid(const char *const to, const char *const id, const char *const node,
void iq_send_caps_request_for_jid(const char * const to, const char * const id, const char *const ver);
const char * const node, const char * const ver); void iq_send_caps_request_legacy(const char *const to, const char *const id, const char *const node,
void iq_send_caps_request_legacy(const char * const to, const char * const id, const char *const ver);
const char * const node, const char * const ver);
void iq_room_info_request(const char *const room, gboolean display_result); void iq_room_info_request(const char *const room, gboolean display_result);
void iq_room_affiliation_list(const char *const room, char *affiliation); void iq_room_affiliation_list(const char *const room, char *affiliation);
void iq_room_affiliation_set(const char *const room, const char *const jid, char *affiliation, void iq_room_affiliation_set(const char *const room, const char *const jid, char *affiliation,
const char *const reason); const char *const reason);
void iq_room_kick_occupant(const char *const room, const char *const nick, const char *const reason); void iq_room_kick_occupant(const char *const room, const char *const nick, const char *const reason);
void iq_room_role_set(const char * const room, const char * const nick, char *role, void iq_room_role_set(const char *const room, const char *const nick, char *role, const char *const reason);
const char * const reason);
void iq_room_role_list(const char * const room, char *role); void iq_room_role_list(const char * const room, char *role);
// caps functions // caps functions