[empathy] Add function ensure_chatroom to chatroom manager
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] Add function ensure_chatroom to chatroom manager
- Date: Thu, 27 May 2010 15:03:27 +0000 (UTC)
commit 2cf16f8c3b783ac09ed638633b34dffc50279106
Author: Jonas Bonn <jonas southpole se>
Date: Fri Mar 5 16:42:05 2010 +0100
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.
libempathy/empathy-chatroom-manager.c | 22 ++++++++++++++++++++++
libempathy/empathy-chatroom-manager.h | 4 ++++
2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c
index d5513ca..cf3b753 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 8ee2a89..9a1de18 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]