mirror of
https://github.com/profanity-im/profanity.git
synced 2024-10-27 20:30:13 -04:00
Rename Capabilties -> EntityCapabilities
This commit is contained in:
parent
e949114284
commit
80eb5bee90
@ -549,7 +549,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence)
|
|||||||
ProfWin *console = wins_get_console();
|
ProfWin *console = wins_get_console();
|
||||||
cons_show("");
|
cons_show("");
|
||||||
|
|
||||||
Capabilities *caps = caps_lookup(fulljid);
|
EntityCapabilities *caps = caps_lookup(fulljid);
|
||||||
if (caps) {
|
if (caps) {
|
||||||
const char *resource_presence = string_from_resource_presence(presence);
|
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, "", "");
|
win_vprint(console, '-', 0, NULL, NO_DATE, 0, "", "");
|
||||||
Jid *jidp = jid_create_from_bare_and_resource(account->jid, resource->name);
|
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);
|
jid_destroy(jidp);
|
||||||
|
|
||||||
if (caps) {
|
if (caps) {
|
||||||
|
@ -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);
|
win_vprint(window, '!', 0, NULL, 0, 0, "", " Role: %s", occupant_role);
|
||||||
|
|
||||||
Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick);
|
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);
|
jid_destroy(jidp);
|
||||||
|
|
||||||
if (caps) {
|
if (caps) {
|
||||||
@ -878,7 +878,7 @@ win_show_info(ProfWin *window, PContact contact)
|
|||||||
win_newline(window);
|
win_newline(window);
|
||||||
|
|
||||||
Jid *jidp = jid_create_from_bare_and_resource(barejid, resource->name);
|
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);
|
jid_destroy(jidp);
|
||||||
|
|
||||||
if (caps) {
|
if (caps) {
|
||||||
|
@ -71,9 +71,9 @@ static GList *prof_features;
|
|||||||
static char *my_sha1;
|
static char *my_sha1;
|
||||||
|
|
||||||
static void _save_cache(void);
|
static void _save_cache(void);
|
||||||
static Capabilities* _caps_by_ver(const char *const ver);
|
static EntityCapabilities* _caps_by_ver(const char *const ver);
|
||||||
static Capabilities* _caps_by_jid(const char *const jid);
|
static EntityCapabilities* _caps_by_jid(const char *const jid);
|
||||||
Capabilities* _caps_copy(Capabilities *caps);
|
EntityCapabilities* _caps_copy(EntityCapabilities *caps);
|
||||||
|
|
||||||
void
|
void
|
||||||
caps_init(void)
|
caps_init(void)
|
||||||
@ -107,7 +107,7 @@ caps_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
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);
|
gboolean cached = g_key_file_has_group(cache, ver);
|
||||||
if (!cached) {
|
if (!cached) {
|
||||||
@ -149,7 +149,7 @@ caps_add_by_ver(const char *const ver, Capabilities *caps)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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);
|
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));
|
return (g_key_file_has_group(cache, ver));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Capabilities*
|
static EntityCapabilities*
|
||||||
_caps_by_ver(const char *const ver)
|
_caps_by_ver(const char *const ver)
|
||||||
{
|
{
|
||||||
if (g_key_file_has_group(cache, 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);
|
char *category = g_key_file_get_string(cache, ver, "category", NULL);
|
||||||
if (category) {
|
if (category) {
|
||||||
@ -240,24 +240,24 @@ _caps_by_ver(const char *const ver)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Capabilities*
|
static EntityCapabilities*
|
||||||
_caps_by_jid(const char *const jid)
|
_caps_by_jid(const char *const jid)
|
||||||
{
|
{
|
||||||
return g_hash_table_lookup(jid_to_caps, jid);
|
return g_hash_table_lookup(jid_to_caps, jid);
|
||||||
}
|
}
|
||||||
|
|
||||||
Capabilities*
|
EntityCapabilities*
|
||||||
caps_lookup(const char *const jid)
|
caps_lookup(const char *const jid)
|
||||||
{
|
{
|
||||||
char *ver = g_hash_table_lookup(jid_to_ver, jid);
|
char *ver = g_hash_table_lookup(jid_to_ver, jid);
|
||||||
if (ver) {
|
if (ver) {
|
||||||
Capabilities *caps = _caps_by_ver(ver);
|
EntityCapabilities *caps = _caps_by_ver(ver);
|
||||||
if (caps) {
|
if (caps) {
|
||||||
log_debug("Capabilities lookup %s, found by verification string %s.", jid, ver);
|
log_debug("Capabilities lookup %s, found by verification string %s.", jid, ver);
|
||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Capabilities *caps = _caps_by_jid(jid);
|
EntityCapabilities *caps = _caps_by_jid(jid);
|
||||||
if (caps) {
|
if (caps) {
|
||||||
log_debug("Capabilities lookup %s, found by JID.", jid);
|
log_debug("Capabilities lookup %s, found by JID.", jid);
|
||||||
return _caps_copy(caps);
|
return _caps_copy(caps);
|
||||||
@ -268,13 +268,13 @@ caps_lookup(const char *const jid)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Capabilities*
|
EntityCapabilities*
|
||||||
_caps_copy(Capabilities *caps)
|
_caps_copy(EntityCapabilities *caps)
|
||||||
{
|
{
|
||||||
if (!caps) {
|
if (!caps) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
Capabilities *result = (Capabilities *)malloc(sizeof(Capabilities));
|
EntityCapabilities *result = (EntityCapabilities *)malloc(sizeof(EntityCapabilities));
|
||||||
result->category = caps->category ? strdup(caps->category) : NULL;
|
result->category = caps->category ? strdup(caps->category) : NULL;
|
||||||
result->type = caps->type ? strdup(caps->type) : NULL;
|
result->type = caps->type ? strdup(caps->type) : NULL;
|
||||||
result->name = caps->name ? strdup(caps->name) : NULL;
|
result->name = caps->name ? strdup(caps->name) : NULL;
|
||||||
@ -395,17 +395,13 @@ caps_create_sha1_str(xmpp_stanza_t *const query)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Capabilities*
|
EntityCapabilities*
|
||||||
caps_create(xmpp_stanza_t *query)
|
caps_create(xmpp_stanza_t *query)
|
||||||
{
|
{
|
||||||
const char *category = NULL;
|
|
||||||
const char *type = NULL;
|
|
||||||
const char *name = NULL;
|
|
||||||
char *software = NULL;
|
char *software = NULL;
|
||||||
char *software_version = NULL;
|
char *software_version = NULL;
|
||||||
char *os = NULL;
|
char *os = NULL;
|
||||||
char *os_version = NULL;
|
char *os_version = NULL;
|
||||||
GSList *features = NULL;
|
|
||||||
|
|
||||||
xmpp_stanza_t *softwareinfo = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA);
|
xmpp_stanza_t *softwareinfo = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA);
|
||||||
if (softwareinfo) {
|
if (softwareinfo) {
|
||||||
@ -437,6 +433,7 @@ caps_create(xmpp_stanza_t *query)
|
|||||||
|
|
||||||
xmpp_stanza_t *child = xmpp_stanza_get_children(query);
|
xmpp_stanza_t *child = xmpp_stanza_get_children(query);
|
||||||
GSList *identity_stanzas = NULL;
|
GSList *identity_stanzas = NULL;
|
||||||
|
GSList *features = NULL;
|
||||||
while (child) {
|
while (child) {
|
||||||
if (g_strcmp0(xmpp_stanza_get_name(child), "feature") == 0) {
|
if (g_strcmp0(xmpp_stanza_get_name(child), "feature") == 0) {
|
||||||
features = g_slist_append(features, strdup(xmpp_stanza_get_attribute(child, "var")));
|
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);
|
g_slist_free(identity_stanzas);
|
||||||
|
|
||||||
|
const char *category = NULL;
|
||||||
|
const char *type = NULL;
|
||||||
|
const char *name = NULL;
|
||||||
if (found) {
|
if (found) {
|
||||||
category = xmpp_stanza_get_attribute(found, "category");
|
category = xmpp_stanza_get_attribute(found, "category");
|
||||||
type = xmpp_stanza_get_attribute(found, "type");
|
type = xmpp_stanza_get_attribute(found, "type");
|
||||||
name = xmpp_stanza_get_attribute(found, "name");
|
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) {
|
if (category) {
|
||||||
new_caps->category = strdup(category);
|
new_caps->category = strdup(category);
|
||||||
@ -638,7 +638,7 @@ caps_close(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
caps_destroy(Capabilities *caps)
|
caps_destroy(EntityCapabilities *caps)
|
||||||
{
|
{
|
||||||
if (caps) {
|
if (caps) {
|
||||||
free(caps->category);
|
free(caps->category);
|
||||||
|
@ -49,14 +49,14 @@
|
|||||||
|
|
||||||
void caps_init(void);
|
void caps_init(void);
|
||||||
|
|
||||||
void caps_add_by_ver(const char *const ver, Capabilities *caps);
|
void caps_add_by_ver(const char *const ver, EntityCapabilities *caps);
|
||||||
void caps_add_by_jid(const char *const jid, Capabilities *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);
|
void caps_map_jid_to_ver(const char *const jid, const char *const ver);
|
||||||
gboolean caps_contains(const char *const ver);
|
gboolean caps_contains(const char *const ver);
|
||||||
|
|
||||||
char* caps_create_sha1_str(xmpp_stanza_t *const query);
|
char* caps_create_sha1_str(xmpp_stanza_t *const query);
|
||||||
xmpp_stanza_t* caps_create_query_response_stanza(xmpp_ctx_t *const ctx);
|
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);
|
char* caps_get_my_sha1(xmpp_ctx_t *const ctx);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -746,7 +746,7 @@ _caps_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
|||||||
log_info("Capabilties already cached: %s", given_sha1);
|
log_info("Capabilties already cached: %s", given_sha1);
|
||||||
} else {
|
} else {
|
||||||
log_info("Capabilities not cached: %s, storing", given_sha1);
|
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_add_by_ver(given_sha1, capabilities);
|
||||||
caps_destroy(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);
|
log_info("Associating capabilities with: %s", jid);
|
||||||
Capabilities *capabilities = caps_create(query);
|
EntityCapabilities *capabilities = caps_create(query);
|
||||||
caps_add_by_jid(jid, capabilities);
|
caps_add_by_jid(jid, capabilities);
|
||||||
|
|
||||||
free(jid);
|
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);
|
log_info("Capabilties already cached: %s", node);
|
||||||
} else {
|
} else {
|
||||||
log_info("Capabilities not cached: %s, storing", node);
|
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_add_by_ver(node, capabilities);
|
||||||
caps_destroy(capabilities);
|
caps_destroy(capabilities);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ typedef struct bookmark_t {
|
|||||||
gboolean autojoin;
|
gboolean autojoin;
|
||||||
} Bookmark;
|
} Bookmark;
|
||||||
|
|
||||||
typedef struct capabilities_t {
|
typedef struct entity_capabilities_t {
|
||||||
char *category;
|
char *category;
|
||||||
char *type;
|
char *type;
|
||||||
char *name;
|
char *name;
|
||||||
@ -91,7 +91,7 @@ typedef struct capabilities_t {
|
|||||||
char *os;
|
char *os;
|
||||||
char *os_version;
|
char *os_version;
|
||||||
GSList *features;
|
GSList *features;
|
||||||
} Capabilities;
|
} EntityCapabilities;
|
||||||
|
|
||||||
typedef struct disco_item_t {
|
typedef struct disco_item_t {
|
||||||
char *jid;
|
char *jid;
|
||||||
@ -173,9 +173,9 @@ void iq_room_role_list(const char * const room, char *role);
|
|||||||
void iq_autoping_check(void);
|
void iq_autoping_check(void);
|
||||||
void iq_http_upload_request(HTTPUpload *upload);
|
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_close(void);
|
||||||
void caps_destroy(Capabilities *caps);
|
void caps_destroy(EntityCapabilities *caps);
|
||||||
void caps_reset_ver(void);
|
void caps_reset_ver(void);
|
||||||
|
|
||||||
gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str);
|
gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str);
|
||||||
|
@ -203,13 +203,13 @@ void iq_last_activity_request(gchar *jid) {}
|
|||||||
void iq_autoping_check(void) {}
|
void iq_autoping_check(void) {}
|
||||||
|
|
||||||
// caps functions
|
// caps functions
|
||||||
Capabilities* caps_lookup(const char * const jid)
|
EntityCapabilities* caps_lookup(const char * const jid)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void caps_close(void) {}
|
void caps_close(void) {}
|
||||||
void caps_destroy(Capabilities *caps) {}
|
void caps_destroy(EntityCapabilities *caps) {}
|
||||||
void caps_reset_ver(void) {}
|
void caps_reset_ver(void) {}
|
||||||
|
|
||||||
gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str)
|
gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str)
|
||||||
|
Loading…
Reference in New Issue
Block a user