Skip to content
Snippets Groups Projects
Commit 11f74c9e authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

improvements, status messages in chat window

parent fd9c01fc
No related branches found
No related tags found
No related merge requests found
......@@ -78,11 +78,11 @@ def presenceCB(self, con, prs):
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 @@ def connect(self, account):
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 @@ def connect(self, account):
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):
......
[Server]
[Profile]
hostname = SERVER HOSTNAME
accounts = Account1
[Profile]
[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
......
......@@ -233,10 +233,15 @@ def delete_event(self, widget):
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, '<moi> ', '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, '<moi> ', '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 @@ def __init__(self, user, roster):
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 @@ def read_queue(self):
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, '@', '')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment