static void chatroom_manager_chat_invalidated_cb (EmpathyTpChat *chat, guint domain, gint code, gchar *message, gpointer manager) { EmpathyChatroomManagerPriv *priv = GET_PRIV (manager); GList *l; for (l = priv->chatrooms; l; l = l->next) { EmpathyChatroom *chatroom = l->data; if (empathy_chatroom_get_tp_chat (chatroom) != chat) continue; empathy_chatroom_set_tp_chat (chatroom, NULL); if (!empathy_chatroom_is_favorite (chatroom)) { /* Remove the chatroom from the list, unless it's in the list of * favourites.. * FIXME this policy should probably not be in libempathy */ chatroom_manager_remove_link (manager, l); } break; } }
gboolean empathy_chatroom_manager_add (EmpathyChatroomManager *manager, EmpathyChatroom *chatroom) { EmpathyChatroomManagerPriv *priv; g_return_val_if_fail (EMPATHY_IS_CHATROOM_MANAGER (manager), FALSE); g_return_val_if_fail (EMPATHY_IS_CHATROOM (chatroom), FALSE); priv = GET_PRIV (manager); /* don't add more than once */ if (!empathy_chatroom_manager_find (manager, empathy_chatroom_get_account (chatroom), empathy_chatroom_get_room (chatroom))) { add_chatroom (manager, chatroom); if (empathy_chatroom_is_favorite (chatroom)) reset_save_timeout (manager); g_signal_emit (manager, signals[CHATROOM_ADDED], 0, chatroom); return TRUE; } return FALSE; }
static gboolean chatroom_manager_file_save (EmpathyChatroomManager *manager) { EmpathyChatroomManagerPriv *priv; xmlDocPtr doc; xmlNodePtr root; GList *l; priv = GET_PRIV (manager); priv->writing = TRUE; doc = xmlNewDoc ((const xmlChar *) "1.0"); root = xmlNewNode (NULL, (const xmlChar *) "chatrooms"); xmlDocSetRootElement (doc, root); for (l = priv->chatrooms; l; l = l->next) { EmpathyChatroom *chatroom; xmlNodePtr node; const gchar *account_id; chatroom = l->data; if (!empathy_chatroom_is_favorite (chatroom)) continue; account_id = tp_proxy_get_object_path (empathy_chatroom_get_account ( chatroom)); node = xmlNewChild (root, NULL, (const xmlChar *) "chatroom", NULL); xmlNewTextChild (node, NULL, (const xmlChar *) "name", (const xmlChar *) empathy_chatroom_get_name (chatroom)); xmlNewTextChild (node, NULL, (const xmlChar *) "room", (const xmlChar *) empathy_chatroom_get_room (chatroom)); xmlNewTextChild (node, NULL, (const xmlChar *) "account", (const xmlChar *) account_id); xmlNewTextChild (node, NULL, (const xmlChar *) "auto_connect", empathy_chatroom_get_auto_connect (chatroom) ? (const xmlChar *) "yes" : (const xmlChar *) "no"); xmlNewTextChild (node, NULL, (const xmlChar *) "always_urgent", empathy_chatroom_is_always_urgent (chatroom) ? (const xmlChar *) "yes" : (const xmlChar *) "no"); } /* Make sure the XML is indented properly */ xmlIndentTreeOutput = 1; DEBUG ("Saving file:'%s'", priv->file); xmlSaveFormatFileEnc (priv->file, doc, "utf-8", 1); xmlFreeDoc (doc); xmlMemoryDump (); priv->writing = FALSE; return TRUE; }
static void chatroom_manager_remove_link (EmpathyChatroomManager *manager, GList *l) { EmpathyChatroomManagerPriv *priv; EmpathyChatroom *chatroom; priv = GET_PRIV (manager); chatroom = l->data; if (empathy_chatroom_is_favorite (chatroom)) reset_save_timeout (manager); priv->chatrooms = g_list_delete_link (priv->chatrooms, l); g_signal_emit (manager, signals[CHATROOM_REMOVED], 0, chatroom); g_signal_handlers_disconnect_by_func (chatroom, chatroom_changed_cb, manager); g_object_unref (chatroom); }