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

Rename Capabilties -> EntityCapabilities

This commit is contained in:
James Booth 2016-08-13 16:39:25 +01:00
parent e949114284
commit 80eb5bee90
7 changed files with 37 additions and 37 deletions

View File

@ -549,7 +549,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence)
ProfWin *console = wins_get_console();
cons_show("");
Capabilities *caps = caps_lookup(fulljid);
EntityCapabilities *caps = caps_lookup(fulljid);
if (caps) {
const char *resource_presence = string_from_resource_presence(presence);
@ -1002,7 +1002,7 @@ cons_show_account(ProfAccount *account)
}
win_vprint(console, '-', 0, NULL, NO_DATE, 0, "", "");
Jid *jidp = jid_create_from_bare_and_resource(account->jid, resource->name);
Capabilities *caps = caps_lookup(jidp->fulljid);
EntityCapabilities *caps = caps_lookup(jidp->fulljid);
jid_destroy(jidp);
if (caps) {

View File

@ -760,7 +760,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa
win_vprint(window, '!', 0, NULL, 0, 0, "", " Role: %s", occupant_role);
Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick);
Capabilities *caps = caps_lookup(jidp->fulljid);
EntityCapabilities *caps = caps_lookup(jidp->fulljid);
jid_destroy(jidp);
if (caps) {
@ -878,7 +878,7 @@ win_show_info(ProfWin *window, PContact contact)
win_newline(window);
Jid *jidp = jid_create_from_bare_and_resource(barejid, resource->name);
Capabilities *caps = caps_lookup(jidp->fulljid);
EntityCapabilities *caps = caps_lookup(jidp->fulljid);
jid_destroy(jidp);
if (caps) {

View File

@ -71,9 +71,9 @@ static GList *prof_features;
static char *my_sha1;
static void _save_cache(void);
static Capabilities* _caps_by_ver(const char *const ver);
static Capabilities* _caps_by_jid(const char *const jid);
Capabilities* _caps_copy(Capabilities *caps);
static EntityCapabilities* _caps_by_ver(const char *const ver);
static EntityCapabilities* _caps_by_jid(const char *const jid);
EntityCapabilities* _caps_copy(EntityCapabilities *caps);
void
caps_init(void)
@ -107,7 +107,7 @@ caps_init(void)
}
void
caps_add_by_ver(const char *const ver, Capabilities *caps)
caps_add_by_ver(const char *const ver, EntityCapabilities *caps)
{
gboolean cached = g_key_file_has_group(cache, ver);
if (!cached) {
@ -149,7 +149,7 @@ caps_add_by_ver(const char *const ver, Capabilities *caps)
}
void
caps_add_by_jid(const char *const jid, Capabilities *caps)
caps_add_by_jid(const char *const jid, EntityCapabilities *caps)
{
g_hash_table_insert(jid_to_caps, strdup(jid), caps);
}
@ -166,11 +166,11 @@ caps_contains(const char *const ver)
return (g_key_file_has_group(cache, ver));
}
static Capabilities*
static EntityCapabilities*
_caps_by_ver(const char *const ver)
{
if (g_key_file_has_group(cache, ver)) {
Capabilities *new_caps = malloc(sizeof(struct capabilities_t));
EntityCapabilities *new_caps = malloc(sizeof(struct entity_capabilities_t));
char *category = g_key_file_get_string(cache, ver, "category", NULL);
if (category) {
@ -240,24 +240,24 @@ _caps_by_ver(const char *const ver)
}
}
static Capabilities*
static EntityCapabilities*
_caps_by_jid(const char *const jid)
{
return g_hash_table_lookup(jid_to_caps, jid);
}
Capabilities*
EntityCapabilities*
caps_lookup(const char *const jid)
{
char *ver = g_hash_table_lookup(jid_to_ver, jid);
if (ver) {
Capabilities *caps = _caps_by_ver(ver);
EntityCapabilities *caps = _caps_by_ver(ver);
if (caps) {
log_debug("Capabilities lookup %s, found by verification string %s.", jid, ver);
return caps;
}
} else {
Capabilities *caps = _caps_by_jid(jid);
EntityCapabilities *caps = _caps_by_jid(jid);
if (caps) {
log_debug("Capabilities lookup %s, found by JID.", jid);
return _caps_copy(caps);
@ -268,13 +268,13 @@ caps_lookup(const char *const jid)
return NULL;
}
Capabilities*
_caps_copy(Capabilities *caps)
EntityCapabilities*
_caps_copy(EntityCapabilities *caps)
{
if (!caps) {
return NULL;
} else {
Capabilities *result = (Capabilities *)malloc(sizeof(Capabilities));
EntityCapabilities *result = (EntityCapabilities *)malloc(sizeof(EntityCapabilities));
result->category = caps->category ? strdup(caps->category) : NULL;
result->type = caps->type ? strdup(caps->type) : NULL;
result->name = caps->name ? strdup(caps->name) : NULL;
@ -395,17 +395,13 @@ caps_create_sha1_str(xmpp_stanza_t *const query)
return result;
}
Capabilities*
EntityCapabilities*
caps_create(xmpp_stanza_t *query)
{
const char *category = NULL;
const char *type = NULL;
const char *name = NULL;
char *software = NULL;
char *software_version = NULL;
char *os = NULL;
char *os_version = NULL;
GSList *features = NULL;
xmpp_stanza_t *softwareinfo = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA);
if (softwareinfo) {
@ -437,6 +433,7 @@ caps_create(xmpp_stanza_t *query)
xmpp_stanza_t *child = xmpp_stanza_get_children(query);
GSList *identity_stanzas = NULL;
GSList *features = NULL;
while (child) {
if (g_strcmp0(xmpp_stanza_get_name(child), "feature") == 0) {
features = g_slist_append(features, strdup(xmpp_stanza_get_attribute(child, "var")));
@ -495,13 +492,16 @@ caps_create(xmpp_stanza_t *query)
g_slist_free(identity_stanzas);
const char *category = NULL;
const char *type = NULL;
const char *name = NULL;
if (found) {
category = xmpp_stanza_get_attribute(found, "category");
type = xmpp_stanza_get_attribute(found, "type");
name = xmpp_stanza_get_attribute(found, "name");
}
Capabilities *new_caps = malloc(sizeof(struct capabilities_t));
EntityCapabilities *new_caps = malloc(sizeof(struct entity_capabilities_t));
if (category) {
new_caps->category = strdup(category);
@ -638,7 +638,7 @@ caps_close(void)
}
void
caps_destroy(Capabilities *caps)
caps_destroy(EntityCapabilities *caps)
{
if (caps) {
free(caps->category);

View File

@ -49,14 +49,14 @@
void caps_init(void);
void caps_add_by_ver(const char *const ver, Capabilities *caps);
void caps_add_by_jid(const char *const jid, Capabilities *caps);
void caps_add_by_ver(const char *const ver, EntityCapabilities *caps);
void caps_add_by_jid(const char *const jid, EntityCapabilities *caps);
void caps_map_jid_to_ver(const char *const jid, const char *const ver);
gboolean caps_contains(const char *const ver);
char* caps_create_sha1_str(xmpp_stanza_t *const query);
xmpp_stanza_t* caps_create_query_response_stanza(xmpp_ctx_t *const ctx);
Capabilities* caps_create(xmpp_stanza_t *query);
EntityCapabilities* caps_create(xmpp_stanza_t *query);
char* caps_get_my_sha1(xmpp_ctx_t *const ctx);
#endif

View File

@ -746,7 +746,7 @@ _caps_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
log_info("Capabilties already cached: %s", given_sha1);
} else {
log_info("Capabilities not cached: %s, storing", given_sha1);
Capabilities *capabilities = caps_create(query);
EntityCapabilities *capabilities = caps_create(query);
caps_add_by_ver(given_sha1, capabilities);
caps_destroy(capabilities);
}
@ -810,7 +810,7 @@ _caps_response_for_jid_id_handler(xmpp_stanza_t *const stanza, void *const userd
}
log_info("Associating capabilities with: %s", jid);
Capabilities *capabilities = caps_create(query);
EntityCapabilities *capabilities = caps_create(query);
caps_add_by_jid(jid, capabilities);
free(jid);
@ -874,7 +874,7 @@ _caps_response_legacy_id_handler(xmpp_stanza_t *const stanza, void *const userda
log_info("Capabilties already cached: %s", node);
} else {
log_info("Capabilities not cached: %s, storing", node);
Capabilities *capabilities = caps_create(query);
EntityCapabilities *capabilities = caps_create(query);
caps_add_by_ver(node, capabilities);
caps_destroy(capabilities);
}

View File

@ -82,7 +82,7 @@ typedef struct bookmark_t {
gboolean autojoin;
} Bookmark;
typedef struct capabilities_t {
typedef struct entity_capabilities_t {
char *category;
char *type;
char *name;
@ -91,7 +91,7 @@ typedef struct capabilities_t {
char *os;
char *os_version;
GSList *features;
} Capabilities;
} EntityCapabilities;
typedef struct disco_item_t {
char *jid;
@ -173,9 +173,9 @@ void iq_room_role_list(const char * const room, char *role);
void iq_autoping_check(void);
void iq_http_upload_request(HTTPUpload *upload);
Capabilities* caps_lookup(const char *const jid);
EntityCapabilities* caps_lookup(const char *const jid);
void caps_close(void);
void caps_destroy(Capabilities *caps);
void caps_destroy(EntityCapabilities *caps);
void caps_reset_ver(void);
gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str);

View File

@ -203,13 +203,13 @@ void iq_last_activity_request(gchar *jid) {}
void iq_autoping_check(void) {}
// caps functions
Capabilities* caps_lookup(const char * const jid)
EntityCapabilities* caps_lookup(const char * const jid)
{
return NULL;
}
void caps_close(void) {}
void caps_destroy(Capabilities *caps) {}
void caps_destroy(EntityCapabilities *caps) {}
void caps_reset_ver(void) {}
gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str)