Added p_contact_add_resource

This commit is contained in:
James Booth
2013-02-10 18:16:06 +00:00
parent 1a6490a5b7
commit 8c9f916246
5 changed files with 22 additions and 15 deletions

View File

@@ -20,6 +20,7 @@
*
*/
#include <assert.h>
#include <stdlib.h>
#include <string.h>
@@ -40,9 +41,7 @@ struct p_contact_t {
PContact
p_contact_new(const char * const barejid, const char * const name,
const char * const presence, const char * const status,
const char * const subscription, gboolean pending_out,
const char * const caps_str)
const char * const subscription, gboolean pending_out)
{
PContact contact = malloc(sizeof(struct p_contact_t));
contact->barejid = strdup(barejid);
@@ -63,16 +62,19 @@ p_contact_new(const char * const barejid, const char * const name,
contact->available_resources = g_hash_table_new_full(g_str_hash, g_str_equal, free,
(GDestroyNotify)resource_destroy);
// TODO, priority, last activity
if (g_strcmp0(presence, "offline") != 0) {
resource_presence_t resource_presence = resource_presence_from_string(presence);
Resource *resource = resource_new("default", resource_presence, status, 0, caps_str);
g_hash_table_insert(contact->available_resources, strdup(resource->name), resource);
}
return contact;
}
void
p_contact_add_resource(PContact contact, Resource *resource)
{
assert(contact != NULL);
assert(resource != NULL);
g_hash_table_insert(contact->available_resources, strdup(resource->name), resource);
}
PContact
p_contact_new_subscription(const char * const barejid,
const char * const subscription, gboolean pending_out)