From 11f74c9e30506e3ea6b3c464f0c1d1a23f5052bf Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 2 Dec 2003 12:39:28 +0000 Subject: [PATCH] improvements, status messages in chat window --- core/core.py | 10 ++++++---- doc/gajimrc | 10 ++++++---- plugins/gtkgui/gtkgui.py | 27 +++++++++++++++++++++++---- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/core/core.py b/core/core.py index dab503896..fb04a5734 100644 --- a/core/core.py +++ b/core/core.py @@ -78,11 +78,11 @@ class GajimCore: log.debug("unsubscribe request from %s" % who) elif type == 'unsubscribed': log.debug("we are now unsubscribed to %s" % who) - # END presenceCB def disconnectedCB(self, con): log.debug("disconnectedCB") + self.con.disconnect() # END disconenctedCB def connect(self, account): @@ -95,14 +95,15 @@ class GajimCore: try: self.con.connect() except IOError, e: - log.debug("Couldn't connect to %s" % e) - sys.exit(0) + log.debug("Couldn't connect to %s %s" % (hostname, e)) + return 0 else: log.debug("Connected to server") self.con.setMessageHandler(self.messageCB) self.con.setPresenceHandler(self.presenceCB) self.con.setDisconnectHandler(self.disconnectedCB) + #BUG in jabberpy library : if hostname is wrong : "boucle" if self.con.auth(name, password, ressource): self.con.requestRoster() roster = self.con.getRoster().getRaw() @@ -112,7 +113,8 @@ class GajimCore: self.con.sendInitPresence() self.connected = 1 else: - sys.exit(1) + log.debug("Couldn't authentificate to %s" % hostname) + return 0 # END connect def mainLoop(self): diff --git a/doc/gajimrc b/doc/gajimrc index c6d79bcf5..2080f52eb 100644 --- a/doc/gajimrc +++ b/doc/gajimrc @@ -1,9 +1,10 @@ -[Server] - -hostname = SERVER HOSTNAME - [Profile] +accounts = Account1 + +[Account1] + +hostname = SERVER HOSTNAME name = LOGIN NAME password = PASSWORD ressource = gajim @@ -20,6 +21,7 @@ modules = sock showoffline = 0 inmsgcolor = red outmsgcolor = blue +statusmsgcolor = green iconstyle = sun autopopup = 0 diff --git a/plugins/gtkgui/gtkgui.py b/plugins/gtkgui/gtkgui.py index f6dfabb4f..0594fd1cc 100644 --- a/plugins/gtkgui/gtkgui.py +++ b/plugins/gtkgui/gtkgui.py @@ -233,10 +233,15 @@ class message: def print_conversation(self, txt, contact = None): end_iter = self.convTxtBuffer.get_end_iter() if contact: - self.convTxtBuffer.insert_with_tags_by_name(end_iter, ' ', 'outgoing') + if contact == 'status': + self.convTxtBuffer.insert_with_tags_by_name(end_iter, txt+'\n', \ + 'status') + else: + self.convTxtBuffer.insert_with_tags_by_name(end_iter, ' ', 'outgoing') + self.convTxtBuffer.insert(end_iter, txt+'\n') else: self.convTxtBuffer.insert_with_tags_by_name(end_iter, '<' + self.user.name + '> ', 'incoming') - self.convTxtBuffer.insert(end_iter, txt+'\n') + self.convTxtBuffer.insert(end_iter, txt+'\n') self.conversation.scroll_to_mark(\ self.convTxtBuffer.get_mark('end'), 0.1, 0, 0, 0) @@ -287,12 +292,17 @@ class message: self.tag = self.convTxtBuffer.create_tag("incoming") color = self.cfgParser.GtkGui_inmsgcolor if not color: - color = red + color = 'red' self.tag.set_property("foreground", color) self.tag = self.convTxtBuffer.create_tag("outgoing") color = self.cfgParser.GtkGui_outmsgcolor if not color: - color = blue + color = 'blue' + self.tag.set_property("foreground", color) + self.tag = self.convTxtBuffer.create_tag("status") + color = self.cfgParser.GtkGui_statusmsgcolor + if not color: + color = 'green' self.tag.set_property("foreground", color) class roster: @@ -570,6 +580,15 @@ class plugin: self.r.mkroster(ev[1]) elif ev[0] == 'NOTIFY': jid = string.split(ev[1][0], '/')[0] + #Update user + if self.r.l_contact.has_key(jid): + u = self.r.l_contact[jid]['user'] + u.show = ev[1][1] + u.status = ev[1][2] + #Print status in chat window + if self.r.tab_messages.has_key(jid): + self.r.tab_messages[jid].print_conversation(\ + "%s is now %s (%s)" % (u.name, ev[1][1], ev[1][2]), 'status') if string.find(jid, "@") <= 0: #It must be an agent jid = string.replace(jid, '@', '')