Apply coding style
Regards https://github.com/profanity-im/profanity/issues/1396
This commit is contained in:
@@ -46,19 +46,19 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "common.h"
|
||||
#include "log.h"
|
||||
#include "ui/ui.h"
|
||||
#include "xmpp/session.h"
|
||||
#include "xmpp/connection.h"
|
||||
#include "xmpp/stanza.h"
|
||||
#include "xmpp/iq.h"
|
||||
#include "xmpp/session.h"
|
||||
#include "xmpp/stanza.h"
|
||||
|
||||
static int _blocklist_result_handler(xmpp_stanza_t *const stanza, void *const userdata);
|
||||
static int _block_add_result_handler(xmpp_stanza_t *const stanza, void *const userdata);
|
||||
static int _block_remove_result_handler(xmpp_stanza_t *const stanza, void *const userdata);
|
||||
static int _blocklist_result_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _block_add_result_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _block_remove_result_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
|
||||
static GList *blocked;
|
||||
static GList* blocked;
|
||||
static Autocomplete blocked_ac;
|
||||
|
||||
void
|
||||
@@ -74,11 +74,11 @@ blocking_request(void)
|
||||
}
|
||||
blocked_ac = autocomplete_new();
|
||||
|
||||
char *id = connection_create_stanza_id();
|
||||
char* id = connection_create_stanza_id();
|
||||
iq_id_handler_add(id, _blocklist_result_handler, NULL, NULL);
|
||||
|
||||
xmpp_ctx_t *ctx = connection_get_ctx();
|
||||
xmpp_stanza_t *iq = stanza_create_blocked_list_request(ctx);
|
||||
xmpp_ctx_t* ctx = connection_get_ctx();
|
||||
xmpp_stanza_t* iq = stanza_create_blocked_list_request(ctx);
|
||||
xmpp_stanza_set_id(iq, id);
|
||||
free(id);
|
||||
|
||||
@@ -93,7 +93,7 @@ blocked_list(void)
|
||||
}
|
||||
|
||||
char*
|
||||
blocked_ac_find(const char *const search_str, gboolean previous, void *context)
|
||||
blocked_ac_find(const char* const search_str, gboolean previous, void* context)
|
||||
{
|
||||
return autocomplete_complete(blocked_ac, search_str, TRUE, previous);
|
||||
}
|
||||
@@ -107,23 +107,23 @@ blocked_ac_reset(void)
|
||||
}
|
||||
|
||||
gboolean
|
||||
blocked_add(char *jid)
|
||||
blocked_add(char* jid)
|
||||
{
|
||||
GList *found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0);
|
||||
GList* found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0);
|
||||
if (found) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
xmpp_ctx_t *ctx = connection_get_ctx();
|
||||
xmpp_ctx_t* ctx = connection_get_ctx();
|
||||
|
||||
char *id = connection_create_stanza_id();
|
||||
xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
|
||||
char* id = connection_create_stanza_id();
|
||||
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
|
||||
|
||||
xmpp_stanza_t *block = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_t* block = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(block, STANZA_NAME_BLOCK);
|
||||
xmpp_stanza_set_ns(block, STANZA_NS_BLOCKING);
|
||||
|
||||
xmpp_stanza_t *item = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_t* item = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
|
||||
xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, jid);
|
||||
|
||||
@@ -143,23 +143,23 @@ blocked_add(char *jid)
|
||||
}
|
||||
|
||||
gboolean
|
||||
blocked_remove(char *jid)
|
||||
blocked_remove(char* jid)
|
||||
{
|
||||
GList *found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0);
|
||||
GList* found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0);
|
||||
if (!found) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
xmpp_ctx_t *ctx = connection_get_ctx();
|
||||
xmpp_ctx_t* ctx = connection_get_ctx();
|
||||
|
||||
char *id = connection_create_stanza_id();
|
||||
xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
|
||||
char* id = connection_create_stanza_id();
|
||||
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
|
||||
|
||||
xmpp_stanza_t *block = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_t* block = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(block, STANZA_NAME_UNBLOCK);
|
||||
xmpp_stanza_set_ns(block, STANZA_NS_BLOCKING);
|
||||
|
||||
xmpp_stanza_t *item = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_t* item = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
|
||||
xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, jid);
|
||||
|
||||
@@ -179,28 +179,27 @@ blocked_remove(char *jid)
|
||||
}
|
||||
|
||||
int
|
||||
blocked_set_handler(xmpp_stanza_t *stanza)
|
||||
blocked_set_handler(xmpp_stanza_t* stanza)
|
||||
{
|
||||
xmpp_stanza_t *block = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BLOCK);
|
||||
xmpp_stanza_t* block = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BLOCK);
|
||||
if (block) {
|
||||
xmpp_stanza_t *child = xmpp_stanza_get_children(block);
|
||||
xmpp_stanza_t* child = xmpp_stanza_get_children(block);
|
||||
while (child) {
|
||||
if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_ITEM) == 0) {
|
||||
const char *jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
|
||||
const char* jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
|
||||
if (jid) {
|
||||
blocked = g_list_append(blocked, strdup(jid));
|
||||
autocomplete_add(blocked_ac, jid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
child = xmpp_stanza_get_next(child);
|
||||
}
|
||||
}
|
||||
|
||||
xmpp_stanza_t *unblock = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_UNBLOCK);
|
||||
xmpp_stanza_t* unblock = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_UNBLOCK);
|
||||
if (unblock) {
|
||||
xmpp_stanza_t *child = xmpp_stanza_get_children(unblock);
|
||||
xmpp_stanza_t* child = xmpp_stanza_get_children(unblock);
|
||||
if (!child) {
|
||||
g_list_free_full(blocked, free);
|
||||
blocked = NULL;
|
||||
@@ -208,16 +207,15 @@ blocked_set_handler(xmpp_stanza_t *stanza)
|
||||
} else {
|
||||
while (child) {
|
||||
if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_ITEM) == 0) {
|
||||
const char *jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
|
||||
const char* jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
|
||||
if (jid) {
|
||||
GList *found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0);
|
||||
GList* found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0);
|
||||
if (found) {
|
||||
blocked = g_list_remove_link(blocked, found);
|
||||
g_list_free_full(found, free);
|
||||
autocomplete_remove(blocked_ac, jid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
child = xmpp_stanza_get_next(child);
|
||||
@@ -229,11 +227,11 @@ blocked_set_handler(xmpp_stanza_t *stanza)
|
||||
}
|
||||
|
||||
static int
|
||||
_block_add_result_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
||||
_block_add_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
{
|
||||
char *jid = (char*)userdata;
|
||||
char* jid = (char*)userdata;
|
||||
|
||||
const char *type = xmpp_stanza_get_type(stanza);
|
||||
const char* type = xmpp_stanza_get_type(stanza);
|
||||
if (!type) {
|
||||
log_info("Block response received for %s with no type attribute.", jid);
|
||||
return 0;
|
||||
@@ -250,11 +248,11 @@ _block_add_result_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
||||
}
|
||||
|
||||
static int
|
||||
_block_remove_result_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
||||
_block_remove_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
{
|
||||
char *jid = (char*)userdata;
|
||||
char* jid = (char*)userdata;
|
||||
|
||||
const char *type = xmpp_stanza_get_type(stanza);
|
||||
const char* type = xmpp_stanza_get_type(stanza);
|
||||
if (!type) {
|
||||
log_info("Unblock response received for %s with no type attribute.", jid);
|
||||
return 0;
|
||||
@@ -271,17 +269,17 @@ _block_remove_result_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
||||
}
|
||||
|
||||
static int
|
||||
_blocklist_result_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
||||
_blocklist_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
{
|
||||
log_debug("Blocked list result handler fired.");
|
||||
|
||||
const char *type = xmpp_stanza_get_type(stanza);
|
||||
const char* type = xmpp_stanza_get_type(stanza);
|
||||
if (g_strcmp0(type, "result") != 0) {
|
||||
log_info("Received blocklist without result type");
|
||||
return 0;
|
||||
}
|
||||
|
||||
xmpp_stanza_t *blocklist = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BLOCKLIST);
|
||||
xmpp_stanza_t* blocklist = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BLOCKLIST);
|
||||
if (!blocklist) {
|
||||
log_info("Received blocklist without blocklist element");
|
||||
return 0;
|
||||
@@ -292,17 +290,17 @@ _blocklist_result_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
||||
blocked = NULL;
|
||||
}
|
||||
|
||||
xmpp_stanza_t *items = xmpp_stanza_get_children(blocklist);
|
||||
xmpp_stanza_t* items = xmpp_stanza_get_children(blocklist);
|
||||
if (!items) {
|
||||
log_debug("No blocked users.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
xmpp_stanza_t *curr = items;
|
||||
xmpp_stanza_t* curr = items;
|
||||
while (curr) {
|
||||
const char *name = xmpp_stanza_get_name(curr);
|
||||
const char* name = xmpp_stanza_get_name(curr);
|
||||
if (g_strcmp0(name, "item") == 0) {
|
||||
const char *jid = xmpp_stanza_get_attribute(curr, STANZA_ATTR_JID);
|
||||
const char* jid = xmpp_stanza_get_attribute(curr, STANZA_ATTR_JID);
|
||||
if (jid) {
|
||||
blocked = g_list_append(blocked, strdup(jid));
|
||||
autocomplete_add(blocked_ac, jid);
|
||||
|
||||
Reference in New Issue
Block a user