~ubuntu-branches/ubuntu/utopic/gossip/utopic

« back to all changes in this revision

Viewing changes to libgossip/gossip-chatroom-manager.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2006-07-31 22:07:39 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20060731220739-5ufsaxy8j4bwwl9z
Tags: 0.13-0ubuntu1
* New upstream release.
* debian/control.in:
  - added and bumped Build-Depends according to configure.ac

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include <config.h>
22
22
#include <string.h>
23
 
 
24
 
#include <libgnomevfs/gnome-vfs.h>
 
23
#include <sys/types.h>
 
24
#include <sys/stat.h>
25
25
#include <libxml/parser.h>
26
26
#include <libxml/tree.h>
27
27
 
28
28
#include "libgossip-marshal.h"
29
29
 
30
30
#include "gossip-utils.h"
 
31
#include "gossip-debug.h"
31
32
#include "gossip-chatroom-manager.h"
32
33
#include "gossip-protocol.h"
33
34
 
 
35
#define DEBUG_DOMAIN "ChatroomManager"
 
36
 
 
37
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GOSSIP_TYPE_CHATROOM_MANAGER, GossipChatroomManagerPriv))
 
38
 
34
39
#define CHATROOMS_XML_FILENAME "chatrooms.xml"
35
40
#define CHATROOMS_DTD_FILENAME "gossip-chatroom.dtd"
36
41
 
37
 
#define DEBUG_MSG(x)
38
 
/* #define DEBUG_MSG(args) g_printerr args ; g_printerr ("\n");  */
39
 
 
40
 
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GOSSIP_TYPE_CHATROOM_MANAGER, GossipChatroomManagerPriv))
41
 
 
42
42
typedef struct _GossipChatroomManagerPriv GossipChatroomManagerPriv;
43
43
 
44
44
struct _GossipChatroomManagerPriv {
179
179
        }
180
180
 
181
181
        if (priv->session) {
182
 
                g_object_unref (priv->session);
183
 
 
184
182
                g_signal_handlers_disconnect_by_func (priv->session, 
185
183
                                                      chatroom_manager_protocol_connected_cb, 
186
 
                                                      NULL);
 
184
                                                      object);
 
185
 
 
186
                g_object_unref (priv->session);
187
187
        }
188
188
        
189
189
        g_free (priv->chatrooms_file_name);
190
 
 
191
190
        g_free (priv->default_name);
192
191
 
193
192
        (G_OBJECT_CLASS (gossip_chatroom_manager_parent_class)->finalize) (object);
252
251
                type = gossip_chatroom_get_type (chatroom);
253
252
                name = gossip_chatroom_get_name (chatroom);
254
253
 
255
 
                DEBUG_MSG (("ChatroomManager: Adding %s%s chatroom with name:'%s'", 
256
 
                           gossip_chatroom_get_auto_connect (chatroom) ? "connecting on startup " : "", 
257
 
                           gossip_chatroom_type_to_string (type), 
258
 
                           name));
259
 
                
 
254
                gossip_debug (DEBUG_DOMAIN, "Adding %s%s chatroom with name:'%s'", 
 
255
                              gossip_chatroom_get_auto_connect (chatroom) ? "connecting on startup " : "", 
 
256
                              gossip_chatroom_type_to_string (type), 
 
257
                              name);
 
258
        
260
259
                g_signal_connect (chatroom, "notify::enabled", 
261
260
                                  G_CALLBACK (chatroom_manager_chatroom_enabled_cb), 
262
261
                                  manager);
292
291
 
293
292
        priv = GET_PRIV (manager);
294
293
 
295
 
        DEBUG_MSG (("ChatroomManager: Removing chatroom with name:'%s'",  
296
 
                   gossip_chatroom_get_name (chatroom)));
 
294
        gossip_debug (DEBUG_DOMAIN,
 
295
                      "Removing chatroom with name:'%s'",  
 
296
                      gossip_chatroom_get_name (chatroom));
297
297
 
298
298
        g_signal_handlers_disconnect_by_func (chatroom, 
299
299
                                              chatroom_manager_chatroom_enabled_cb, 
482
482
 
483
483
        priv = GET_PRIV (manager);
484
484
        
485
 
        DEBUG_MSG (("ChatroomManager: Setting default chatroom with name:'%s'",  
486
 
                   gossip_chatroom_get_name (chatroom))); 
 
485
        gossip_debug (DEBUG_DOMAIN, 
 
486
                      "Setting default chatroom with name:'%s'",  
 
487
                      gossip_chatroom_get_name (chatroom)); 
487
488
 
488
489
        name = gossip_chatroom_get_name (chatroom);
489
490
        g_return_if_fail (name != NULL);
531
532
{
532
533
        g_return_val_if_fail (GOSSIP_IS_CHATROOM_MANAGER (manager), FALSE);
533
534
 
534
 
        DEBUG_MSG (("ChatroomManager: Saving chatrooms"));  
 
535
        gossip_debug (DEBUG_DOMAIN, "Saving chatrooms");  
535
536
        
536
537
        return chatroom_manager_file_save (manager);
537
538
}
742
743
 
743
744
        priv = GET_PRIV (manager);
744
745
        
745
 
        DEBUG_MSG (("ChatroomManager: Attempting to parse file:'%s'...", filename));
 
746
        gossip_debug (DEBUG_DOMAIN, "Attempting to parse file:'%s'...", filename);
746
747
 
747
748
        ctxt = xmlNewParserCtxt ();
748
749
 
781
782
                node = node->next;
782
783
        }
783
784
        
784
 
        DEBUG_MSG (("ChatroomManager: Parsed %d chatrooms", 
785
 
                   g_list_length (priv->chatrooms)));
 
785
        gossip_debug (DEBUG_DOMAIN, 
 
786
                      "Parsed %d chatrooms", 
 
787
                      g_list_length (priv->chatrooms));
786
788
 
787
 
        DEBUG_MSG (("ChatroomManager: Default chatroom is:'%s'", 
788
 
                   priv->default_name));
 
789
        gossip_debug (DEBUG_DOMAIN, 
 
790
                      "Default chatroom is:'%s'", 
 
791
                      priv->default_name);
789
792
        
790
793
        xmlFreeDoc(doc);
791
794
        xmlFreeParserCtxt (ctxt);
798
801
{
799
802
        GossipChatroomManagerPriv *priv;
800
803
        xmlDocPtr                 doc;  
801
 
        xmlDtdPtr                 dtd;  
802
804
        xmlNodePtr                root;
803
805
        GList                    *chatrooms;
804
806
        GList                    *l;
805
 
        gchar                    *dtd_file;
806
807
        gchar                    *dir;
807
808
        gchar                    *file;
808
809
 
820
821
                g_free (dir);
821
822
        }
822
823
 
823
 
        dtd_file = g_build_filename (DTDDIR, CHATROOMS_DTD_FILENAME, NULL);
824
 
 
825
824
        doc = xmlNewDoc ("1.0");
826
825
        root = xmlNewNode (NULL, "chatrooms");
827
826
        xmlDocSetRootElement (doc, root);
828
827
 
829
 
        dtd = xmlCreateIntSubset (doc, "chatrooms", NULL, dtd_file);
830
 
 
831
828
        if (!priv->default_name) {
832
829
                priv->default_name = g_strdup ("Default");
833
830
        }
868
865
                account = gossip_chatroom_get_account (chatroom);
869
866
                if (account) {
870
867
                        xmlNewTextChild (node, NULL, "account", gossip_account_get_name (account));
871
 
                        g_object_unref (account);
872
868
                }
873
869
 
874
870
                g_free (type);
875
871
        }
876
872
 
877
 
        DEBUG_MSG (("ChatroomManager: Saving file:'%s'", file));
 
873
        gossip_debug (DEBUG_DOMAIN, "Saving file:'%s'", file);
878
874
        xmlSaveFormatFileEnc (file, doc, "utf-8", 1);
879
875
        xmlFreeDoc (doc);
880
876
 
913
909
 
914
910
        priv = GET_PRIV (manager);
915
911
        
916
 
        DEBUG_MSG (("ChatroomManager: Account:'%s' connected, "
917
 
                    "checking chatroom auto connects.",
918
 
                   gossip_account_get_name (account)));
 
912
        gossip_debug (DEBUG_DOMAIN, 
 
913
                      "Account:'%s' connected, checking chatroom auto connects.",
 
914
                      gossip_account_get_name (account));
919
915
 
920
916
        chatrooms = gossip_chatroom_manager_get_chatrooms (manager, account);
921
917