aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorJonas Bonn <jonas@southpole.se>2010-03-05 23:42:05 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-05-27 22:32:35 +0800
commit2cf16f8c3b783ac09ed638633b34dffc50279106 (patch)
tree2695fcb9d2896ca1d2cade03d9727eb2e962bbef /libempathy
parent09969c342e7b887bdfc92ff52a6862ae0fe8fa3b (diff)
downloadgsoc2013-empathy-2cf16f8c3b783ac09ed638633b34dffc50279106.tar
gsoc2013-empathy-2cf16f8c3b783ac09ed638633b34dffc50279106.tar.gz
gsoc2013-empathy-2cf16f8c3b783ac09ed638633b34dffc50279106.tar.bz2
gsoc2013-empathy-2cf16f8c3b783ac09ed638633b34dffc50279106.tar.lz
gsoc2013-empathy-2cf16f8c3b783ac09ed638633b34dffc50279106.tar.xz
gsoc2013-empathy-2cf16f8c3b783ac09ed638633b34dffc50279106.tar.zst
gsoc2013-empathy-2cf16f8c3b783ac09ed638633b34dffc50279106.zip
Add function ensure_chatroom to chatroom manager
This function tries to find an existing chatroom, but if it fails to do so it creates a new room and returns that instead.
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-chatroom-manager.c22
-rw-r--r--libempathy/empathy-chatroom-manager.h4
2 files changed, 26 insertions, 0 deletions
diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c
index d5513caf1..cf3b75331 100644
--- a/libempathy/empathy-chatroom-manager.c
+++ b/libempathy/empathy-chatroom-manager.c
@@ -632,6 +632,28 @@ empathy_chatroom_manager_find (EmpathyChatroomManager *manager,
return NULL;
}
+EmpathyChatroom *
+empathy_chatroom_manager_ensure_chatroom (EmpathyChatroomManager *manager,
+ TpAccount *account,
+ const gchar *room,
+ const gchar *name)
+{
+ EmpathyChatroom *chatroom;
+
+ chatroom = empathy_chatroom_manager_find (manager, account, room);
+
+ if (chatroom) {
+ return g_object_ref(chatroom);
+ } else {
+ chatroom = empathy_chatroom_new_full (account,
+ room,
+ name,
+ FALSE);
+ empathy_chatroom_manager_add (manager, chatroom);
+ return chatroom;
+ }
+}
+
GList *
empathy_chatroom_manager_get_chatrooms (EmpathyChatroomManager *manager,
TpAccount *account)
diff --git a/libempathy/empathy-chatroom-manager.h b/libempathy/empathy-chatroom-manager.h
index 8ee2a897a..9a1de1828 100644
--- a/libempathy/empathy-chatroom-manager.h
+++ b/libempathy/empathy-chatroom-manager.h
@@ -62,6 +62,10 @@ void empathy_chatroom_manager_remove (EmpathyChatroomMa
EmpathyChatroom * empathy_chatroom_manager_find (EmpathyChatroomManager *manager,
TpAccount *account,
const gchar *room);
+EmpathyChatroom * empathy_chatroom_manager_ensure_chatroom (EmpathyChatroomManager *manager,
+ TpAccount *account,
+ const gchar *room,
+ const gchar *name);
GList * empathy_chatroom_manager_get_chatrooms (EmpathyChatroomManager *manager,
TpAccount *account);
guint empathy_chatroom_manager_get_count (EmpathyChatroomManager *manager,