2013-05-06 16:53:59 -04:00
|
|
|
/*
|
|
|
|
* roster.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com>
|
|
|
|
*
|
|
|
|
* This file is part of Profanity.
|
|
|
|
*
|
|
|
|
* Profanity is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Profanity is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Profanity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-05-06 18:04:46 -04:00
|
|
|
#include <assert.h>
|
2013-05-06 16:53:59 -04:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <strophe.h>
|
|
|
|
|
|
|
|
#include "log.h"
|
2013-05-06 18:04:46 -04:00
|
|
|
#include "tools/autocomplete.h"
|
2013-05-06 16:53:59 -04:00
|
|
|
#include "xmpp/connection.h"
|
2013-05-06 18:04:46 -04:00
|
|
|
#include "xmpp/roster.h"
|
2013-05-06 16:53:59 -04:00
|
|
|
#include "xmpp/stanza.h"
|
|
|
|
#include "xmpp/xmpp.h"
|
|
|
|
|
|
|
|
#define HANDLE(type, func) xmpp_handler_add(conn, func, XMPP_NS_ROSTER, STANZA_NAME_IQ, type, ctx)
|
|
|
|
|
2013-05-21 15:58:50 -04:00
|
|
|
static int _roster_handle_push(xmpp_conn_t * const conn,
|
2013-05-06 16:53:59 -04:00
|
|
|
xmpp_stanza_t * const stanza, void * const userdata);
|
|
|
|
static int _roster_handle_result(xmpp_conn_t * const conn,
|
|
|
|
xmpp_stanza_t * const stanza, void * const userdata);
|
|
|
|
|
2013-05-21 15:50:05 -04:00
|
|
|
// nicknames
|
2013-05-20 15:51:43 -04:00
|
|
|
static Autocomplete handle_ac;
|
2013-05-21 15:50:05 -04:00
|
|
|
|
|
|
|
// barejids
|
2013-05-20 15:51:43 -04:00
|
|
|
static Autocomplete jid_ac;
|
2013-05-21 15:50:05 -04:00
|
|
|
|
|
|
|
// fulljids
|
2013-05-06 18:04:46 -04:00
|
|
|
static Autocomplete resource_ac;
|
2013-05-21 15:50:05 -04:00
|
|
|
|
|
|
|
// contacts, indexed on barejid
|
2013-05-06 18:04:46 -04:00
|
|
|
static GHashTable *contacts;
|
2013-05-21 15:50:05 -04:00
|
|
|
|
|
|
|
// nickname to jid map
|
2013-05-19 18:35:02 -04:00
|
|
|
static GHashTable *handle_to_jid;
|
2013-05-06 18:04:46 -04:00
|
|
|
|
2013-05-21 15:50:05 -04:00
|
|
|
// helper functions
|
2013-05-06 18:04:46 -04:00
|
|
|
static gboolean _key_equals(void *key1, void *key2);
|
|
|
|
static gboolean _datetimes_equal(GDateTime *dt1, GDateTime *dt2);
|
|
|
|
|
2013-05-06 16:53:59 -04:00
|
|
|
void
|
|
|
|
roster_add_handlers(void)
|
|
|
|
{
|
|
|
|
xmpp_conn_t * const conn = connection_get_conn();
|
|
|
|
xmpp_ctx_t * const ctx = connection_get_ctx();
|
2013-05-21 15:58:50 -04:00
|
|
|
HANDLE(STANZA_TYPE_SET, _roster_handle_push);
|
2013-05-06 16:53:59 -04:00
|
|
|
HANDLE(STANZA_TYPE_RESULT, _roster_handle_result);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
roster_request(void)
|
|
|
|
{
|
|
|
|
xmpp_conn_t * const conn = connection_get_conn();
|
|
|
|
xmpp_ctx_t * const ctx = connection_get_ctx();
|
|
|
|
xmpp_stanza_t *iq = stanza_create_roster_iq(ctx);
|
|
|
|
xmpp_send(conn, iq);
|
|
|
|
xmpp_stanza_release(iq);
|
|
|
|
}
|
|
|
|
|
2013-05-19 18:35:02 -04:00
|
|
|
char *
|
2013-05-21 15:50:05 -04:00
|
|
|
roster_barejid_from_handle(const char * const handle)
|
2013-05-19 18:35:02 -04:00
|
|
|
{
|
|
|
|
return g_hash_table_lookup(handle_to_jid, handle);
|
|
|
|
}
|
|
|
|
|
2013-05-06 16:53:59 -04:00
|
|
|
static int
|
2013-05-21 15:58:50 -04:00
|
|
|
_roster_handle_push(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
2013-05-06 16:53:59 -04:00
|
|
|
void * const userdata)
|
|
|
|
{
|
|
|
|
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
|
|
|
xmpp_stanza_t *item =
|
|
|
|
xmpp_stanza_get_child_by_name(query, STANZA_NAME_ITEM);
|
|
|
|
|
|
|
|
if (item == NULL) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *jid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
|
2013-05-18 21:07:01 -04:00
|
|
|
const char *name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
|
2013-05-06 16:53:59 -04:00
|
|
|
const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
|
2013-05-21 15:58:50 -04:00
|
|
|
|
|
|
|
// remove from roster
|
2013-05-06 16:53:59 -04:00
|
|
|
if (g_strcmp0(sub, "remove") == 0) {
|
2013-05-20 15:51:43 -04:00
|
|
|
autocomplete_remove(jid_ac, jid);
|
|
|
|
autocomplete_remove(handle_ac, name);
|
2013-05-19 18:35:02 -04:00
|
|
|
g_hash_table_remove(handle_to_jid, name);
|
|
|
|
g_hash_table_remove(contacts, jid);
|
2013-05-06 16:53:59 -04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean pending_out = FALSE;
|
|
|
|
const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
|
|
|
|
if ((ask != NULL) && (strcmp(ask, "subscribe") == 0)) {
|
|
|
|
pending_out = TRUE;
|
|
|
|
}
|
|
|
|
|
2013-05-18 21:07:01 -04:00
|
|
|
roster_update(jid, name, sub, pending_out);
|
2013-05-06 16:53:59 -04:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_roster_handle_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
|
|
|
void * const userdata)
|
|
|
|
{
|
|
|
|
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
|
|
|
|
|
|
|
|
// handle initial roster response
|
|
|
|
if (g_strcmp0(id, "roster") == 0) {
|
|
|
|
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
|
|
|
xmpp_stanza_t *item = xmpp_stanza_get_children(query);
|
|
|
|
|
|
|
|
while (item != NULL) {
|
|
|
|
const char *barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
|
|
|
|
const char *name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
|
|
|
|
const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
|
|
|
|
|
|
|
|
gboolean pending_out = FALSE;
|
|
|
|
const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
|
|
|
|
if (g_strcmp0(ask, "subscribe") == 0) {
|
|
|
|
pending_out = TRUE;
|
|
|
|
}
|
|
|
|
|
2013-05-06 17:32:58 -04:00
|
|
|
gboolean added = roster_add(barejid, name, sub, NULL, pending_out);
|
2013-05-06 16:53:59 -04:00
|
|
|
|
|
|
|
if (!added) {
|
|
|
|
log_warning("Attempt to add contact twice: %s", barejid);
|
|
|
|
}
|
|
|
|
|
|
|
|
item = xmpp_stanza_get_next(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
contact_presence_t conn_presence = accounts_get_login_presence(jabber_get_account_name());
|
|
|
|
presence_update(conn_presence, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2013-05-06 18:04:46 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
roster_init(void)
|
|
|
|
{
|
2013-05-20 15:51:43 -04:00
|
|
|
handle_ac = autocomplete_new();
|
|
|
|
jid_ac = autocomplete_new();
|
2013-05-06 18:04:46 -04:00
|
|
|
resource_ac = autocomplete_new();
|
|
|
|
contacts = g_hash_table_new_full(g_str_hash, (GEqualFunc)_key_equals, g_free,
|
|
|
|
(GDestroyNotify)p_contact_free);
|
2013-05-19 18:35:02 -04:00
|
|
|
handle_to_jid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
|
2013-05-06 18:04:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
roster_clear(void)
|
|
|
|
{
|
2013-05-20 15:51:43 -04:00
|
|
|
autocomplete_clear(handle_ac);
|
|
|
|
autocomplete_clear(jid_ac);
|
2013-05-06 18:04:46 -04:00
|
|
|
autocomplete_clear(resource_ac);
|
|
|
|
g_hash_table_destroy(contacts);
|
|
|
|
contacts = g_hash_table_new_full(g_str_hash, (GEqualFunc)_key_equals, g_free,
|
|
|
|
(GDestroyNotify)p_contact_free);
|
2013-05-19 18:35:02 -04:00
|
|
|
g_hash_table_destroy(handle_to_jid);
|
|
|
|
handle_to_jid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
|
2013-05-06 18:04:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
roster_free()
|
|
|
|
{
|
2013-05-20 15:51:43 -04:00
|
|
|
autocomplete_free(handle_ac);
|
|
|
|
autocomplete_free(jid_ac);
|
2013-05-06 18:04:46 -04:00
|
|
|
autocomplete_free(resource_ac);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
roster_reset_search_attempts(void)
|
|
|
|
{
|
2013-05-20 15:51:43 -04:00
|
|
|
autocomplete_reset(handle_ac);
|
|
|
|
autocomplete_reset(jid_ac);
|
2013-05-06 18:04:46 -04:00
|
|
|
autocomplete_reset(resource_ac);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
roster_add(const char * const barejid, const char * const name,
|
|
|
|
const char * const subscription, const char * const offline_message,
|
|
|
|
gboolean pending_out)
|
|
|
|
{
|
|
|
|
gboolean added = FALSE;
|
|
|
|
PContact contact = g_hash_table_lookup(contacts, barejid);
|
|
|
|
|
|
|
|
if (contact == NULL) {
|
|
|
|
contact = p_contact_new(barejid, name, subscription, offline_message,
|
|
|
|
pending_out);
|
|
|
|
g_hash_table_insert(contacts, strdup(barejid), contact);
|
2013-05-19 18:35:02 -04:00
|
|
|
if (name != NULL) {
|
2013-05-20 15:51:43 -04:00
|
|
|
autocomplete_add(handle_ac, strdup(name));
|
2013-05-19 18:35:02 -04:00
|
|
|
g_hash_table_insert(handle_to_jid, strdup(name), strdup(barejid));
|
|
|
|
} else {
|
2013-05-20 15:51:43 -04:00
|
|
|
autocomplete_add(handle_ac, strdup(barejid));
|
2013-05-19 18:35:02 -04:00
|
|
|
g_hash_table_insert(handle_to_jid, strdup(barejid), strdup(barejid));
|
|
|
|
}
|
2013-05-20 15:51:43 -04:00
|
|
|
autocomplete_add(jid_ac, strdup(barejid));
|
|
|
|
|
2013-05-06 18:04:46 -04:00
|
|
|
added = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return added;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
roster_update_presence(const char * const barejid, Resource *resource,
|
|
|
|
GDateTime *last_activity)
|
|
|
|
{
|
|
|
|
assert(barejid != NULL);
|
|
|
|
assert(resource != NULL);
|
|
|
|
|
|
|
|
PContact contact = g_hash_table_lookup(contacts, barejid);
|
|
|
|
if (contact == NULL) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_datetimes_equal(p_contact_last_activity(contact), last_activity)) {
|
|
|
|
p_contact_set_last_activity(contact, last_activity);
|
|
|
|
}
|
|
|
|
p_contact_set_presence(contact, resource);
|
|
|
|
Jid *jid = jid_create_from_bare_and_resource(barejid, resource->name);
|
|
|
|
autocomplete_add(resource_ac, strdup(jid->fulljid));
|
|
|
|
jid_destroy(jid);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
roster_contact_offline(const char * const barejid,
|
|
|
|
const char * const resource, const char * const status)
|
|
|
|
{
|
|
|
|
PContact contact = g_hash_table_lookup(contacts, barejid);
|
|
|
|
if (contact == NULL) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (resource == NULL) {
|
|
|
|
return TRUE;
|
|
|
|
} else {
|
|
|
|
gboolean result = p_contact_remove_resource(contact, resource);
|
|
|
|
if (result == TRUE) {
|
|
|
|
Jid *jid = jid_create_from_bare_and_resource(barejid, resource);
|
|
|
|
autocomplete_remove(resource_ac, jid->fulljid);
|
|
|
|
jid_destroy(jid);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-05-20 16:43:20 -04:00
|
|
|
roster_change_handle(const char * const barejid, const char * const new_handle)
|
2013-05-18 21:07:01 -04:00
|
|
|
{
|
|
|
|
PContact contact = g_hash_table_lookup(contacts, barejid);
|
2013-05-20 16:43:20 -04:00
|
|
|
const char * current_handle = NULL;
|
2013-05-19 18:35:02 -04:00
|
|
|
if (p_contact_name(contact) != NULL) {
|
2013-05-20 16:43:20 -04:00
|
|
|
current_handle = strdup(p_contact_name(contact));
|
2013-05-19 18:35:02 -04:00
|
|
|
}
|
|
|
|
|
2013-05-18 21:07:01 -04:00
|
|
|
if (contact != NULL) {
|
2013-05-20 16:43:20 -04:00
|
|
|
p_contact_set_name(contact, new_handle);
|
|
|
|
|
|
|
|
// current handle exists already
|
|
|
|
if (current_handle != NULL) {
|
|
|
|
autocomplete_remove(handle_ac, current_handle);
|
|
|
|
g_hash_table_remove(handle_to_jid, current_handle);
|
|
|
|
|
|
|
|
if (new_handle != NULL) {
|
|
|
|
autocomplete_add(handle_ac, strdup(new_handle));
|
|
|
|
g_hash_table_insert(handle_to_jid, strdup(new_handle), strdup(barejid));
|
|
|
|
} else {
|
|
|
|
autocomplete_add(handle_ac, strdup(barejid));
|
|
|
|
g_hash_table_insert(handle_to_jid, strdup(barejid), strdup(barejid));
|
|
|
|
}
|
|
|
|
// no current handle
|
|
|
|
} else {
|
|
|
|
if (new_handle != NULL) {
|
|
|
|
autocomplete_remove(handle_ac, barejid);
|
|
|
|
g_hash_table_remove(handle_to_jid, barejid);
|
2013-05-18 21:07:01 -04:00
|
|
|
|
2013-05-20 16:43:20 -04:00
|
|
|
autocomplete_add(handle_ac, strdup(new_handle));
|
|
|
|
g_hash_table_insert(handle_to_jid, strdup(new_handle), strdup(barejid));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
xmpp_conn_t * const conn = connection_get_conn();
|
|
|
|
xmpp_ctx_t * const ctx = connection_get_ctx();
|
|
|
|
xmpp_stanza_t *iq = stanza_create_roster_set(ctx, barejid, new_handle);
|
|
|
|
xmpp_send(conn, iq);
|
|
|
|
xmpp_stanza_release(iq);
|
|
|
|
}
|
2013-05-18 21:07:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
roster_update(const char * const barejid, const char * const name,
|
2013-05-06 18:04:46 -04:00
|
|
|
const char * const subscription, gboolean pending_out)
|
|
|
|
{
|
|
|
|
PContact contact = g_hash_table_lookup(contacts, barejid);
|
|
|
|
|
|
|
|
if (contact == NULL) {
|
2013-05-18 21:07:01 -04:00
|
|
|
contact = p_contact_new(barejid, name, subscription, NULL, pending_out);
|
2013-05-06 18:04:46 -04:00
|
|
|
g_hash_table_insert(contacts, strdup(barejid), contact);
|
2013-05-20 16:43:20 -04:00
|
|
|
if (name != NULL) {
|
|
|
|
autocomplete_add(handle_ac, strdup(name));
|
|
|
|
g_hash_table_insert(handle_to_jid, strdup(name), strdup(barejid));
|
|
|
|
} else {
|
|
|
|
autocomplete_add(handle_ac, strdup(barejid));
|
|
|
|
g_hash_table_insert(handle_to_jid, strdup(barejid), strdup(barejid));
|
|
|
|
}
|
|
|
|
autocomplete_add(jid_ac, strdup(barejid));
|
2013-05-06 18:04:46 -04:00
|
|
|
} else {
|
|
|
|
p_contact_set_subscription(contact, subscription);
|
|
|
|
p_contact_set_pending_out(contact, pending_out);
|
2013-05-19 18:35:02 -04:00
|
|
|
|
2013-05-20 16:43:20 -04:00
|
|
|
const char * const new_handle = name;
|
|
|
|
const char * current_handle = NULL;
|
|
|
|
if (p_contact_name(contact) != NULL) {
|
|
|
|
current_handle = strdup(p_contact_name(contact));
|
|
|
|
}
|
|
|
|
|
|
|
|
p_contact_set_name(contact, new_handle);
|
|
|
|
|
|
|
|
// current handle exists already
|
|
|
|
if (current_handle != NULL) {
|
|
|
|
autocomplete_remove(handle_ac, current_handle);
|
|
|
|
g_hash_table_remove(handle_to_jid, current_handle);
|
|
|
|
|
|
|
|
if (new_handle != NULL) {
|
|
|
|
autocomplete_add(handle_ac, strdup(new_handle));
|
|
|
|
g_hash_table_insert(handle_to_jid, strdup(new_handle), strdup(barejid));
|
|
|
|
} else {
|
|
|
|
autocomplete_add(handle_ac, strdup(barejid));
|
|
|
|
g_hash_table_insert(handle_to_jid, strdup(barejid), strdup(barejid));
|
2013-05-19 18:35:02 -04:00
|
|
|
}
|
2013-05-20 16:43:20 -04:00
|
|
|
// no current handle
|
2013-05-19 18:35:02 -04:00
|
|
|
} else {
|
2013-05-20 16:43:20 -04:00
|
|
|
if (new_handle != NULL) {
|
|
|
|
autocomplete_remove(handle_ac, barejid);
|
|
|
|
g_hash_table_remove(handle_to_jid, barejid);
|
2013-05-19 18:35:02 -04:00
|
|
|
|
2013-05-20 16:43:20 -04:00
|
|
|
autocomplete_add(handle_ac, strdup(new_handle));
|
|
|
|
g_hash_table_insert(handle_to_jid, strdup(new_handle), strdup(barejid));
|
|
|
|
}
|
2013-05-18 21:07:01 -04:00
|
|
|
}
|
2013-05-06 18:04:46 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
roster_has_pending_subscriptions(void)
|
|
|
|
{
|
|
|
|
GHashTableIter iter;
|
|
|
|
gpointer key;
|
|
|
|
gpointer value;
|
|
|
|
|
|
|
|
g_hash_table_iter_init(&iter, contacts);
|
|
|
|
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
|
|
|
PContact contact = (PContact) value;
|
|
|
|
if (p_contact_pending_out(contact)) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GSList *
|
|
|
|
roster_get_contacts(void)
|
|
|
|
{
|
|
|
|
GSList *result = NULL;
|
|
|
|
GHashTableIter iter;
|
|
|
|
gpointer key;
|
|
|
|
gpointer value;
|
|
|
|
|
|
|
|
g_hash_table_iter_init(&iter, contacts);
|
|
|
|
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
|
|
|
result = g_slist_append(result, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
// resturn all contact structs
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
roster_find_contact(char *search_str)
|
|
|
|
{
|
2013-05-20 15:51:43 -04:00
|
|
|
return autocomplete_complete(handle_ac, search_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
roster_find_jid(char *search_str)
|
|
|
|
{
|
|
|
|
return autocomplete_complete(jid_ac, search_str);
|
2013-05-06 18:04:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
roster_find_resource(char *search_str)
|
|
|
|
{
|
|
|
|
return autocomplete_complete(resource_ac, search_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
PContact
|
|
|
|
roster_get_contact(const char const *barejid)
|
|
|
|
{
|
|
|
|
return g_hash_table_lookup(contacts, barejid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
gboolean _key_equals(void *key1, void *key2)
|
|
|
|
{
|
|
|
|
gchar *str1 = (gchar *) key1;
|
|
|
|
gchar *str2 = (gchar *) key2;
|
|
|
|
|
|
|
|
return (g_strcmp0(str1, str2) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_datetimes_equal(GDateTime *dt1, GDateTime *dt2)
|
|
|
|
{
|
|
|
|
if ((dt1 == NULL) && (dt2 == NULL)) {
|
|
|
|
return TRUE;
|
|
|
|
} else if ((dt1 == NULL) && (dt2 != NULL)) {
|
|
|
|
return FALSE;
|
|
|
|
} else if ((dt1 != NULL) && (dt2 == NULL)) {
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
return g_date_time_equal(dt1, dt2);
|
|
|
|
}
|
|
|
|
}
|