diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-21 23:04:23 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-21 23:04:23 +0200 |
commit | 0de28b0aeff284eced9d9b63dd3126a8a12ee98c (patch) | |
tree | 08831d7946fa8649a9be6a9814b7322a1f091173 | |
parent | 6399feba186d29ac3a333001807caa3c905a4244 (diff) | |
download | edoors-0de28b0aeff284eced9d9b63dd3126a8a12ee98c.zip edoors-0de28b0aeff284eced9d9b63dd3126a8a12ee98c.tar.gz |
implement eiotas_room_add and eiotas_room_free
-rw-r--r-- | src/lib/eiotas_room.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/lib/eiotas_room.c b/src/lib/eiotas_room.c index 9cc4170..9ea9e10 100644 --- a/src/lib/eiotas_room.c +++ b/src/lib/eiotas_room.c @@ -23,16 +23,37 @@ #include "eiotas_room.h" #include "eiotas_private.h" -EAPI Eiotas_Room* -eiotas_room_add(const char* name, Eiotas_Room *parent) +EAPI Eiotas_Room* eiotas_room_add(const char* name, Eiotas_Room *parent) { - // TODO - return NULL; + CHECK_PARENT(); + + BUILD_INSTANCE(Eiotas_Room,room); + + if(eiotas_iota_init(&room->iota,name,parent,EIOTAS_TYPE_ROOM)) { + return NULL; + } + + if(eina_hash_find(parent->children,room->iota.name)) { + ERR("Room %s already exists in %s",name,parent->iota.path); + eiotas_iota_desinit(&room->iota); + return NULL; + } + eina_hash_direct_add(parent->children,room->iota.name,room); + + room->links = NULL; // TODO + room->children = eina_hash_stringshared_new((Eina_Free_Cb)&eiotas_iota_free); + + return room; } void eiotas_room_free(Eiotas_Room *room) { DBG("Room free 0x%X",room); - // TODO + + eiotas_iota_desinit(&room->iota); + // TODO room->links + eina_hash_free(room->children); + + free(room); } |