improvements, status messages in chat window
This commit is contained in:
parent
fd9c01fc4f
commit
11f74c9e30
3 changed files with 35 additions and 12 deletions
10
core/core.py
10
core/core.py
|
@ -78,11 +78,11 @@ class GajimCore:
|
||||||
log.debug("unsubscribe request from %s" % who)
|
log.debug("unsubscribe request from %s" % who)
|
||||||
elif type == 'unsubscribed':
|
elif type == 'unsubscribed':
|
||||||
log.debug("we are now unsubscribed to %s" % who)
|
log.debug("we are now unsubscribed to %s" % who)
|
||||||
|
|
||||||
# END presenceCB
|
# END presenceCB
|
||||||
|
|
||||||
def disconnectedCB(self, con):
|
def disconnectedCB(self, con):
|
||||||
log.debug("disconnectedCB")
|
log.debug("disconnectedCB")
|
||||||
|
self.con.disconnect()
|
||||||
# END disconenctedCB
|
# END disconenctedCB
|
||||||
|
|
||||||
def connect(self, account):
|
def connect(self, account):
|
||||||
|
@ -95,14 +95,15 @@ class GajimCore:
|
||||||
try:
|
try:
|
||||||
self.con.connect()
|
self.con.connect()
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
log.debug("Couldn't connect to %s" % e)
|
log.debug("Couldn't connect to %s %s" % (hostname, e))
|
||||||
sys.exit(0)
|
return 0
|
||||||
else:
|
else:
|
||||||
log.debug("Connected to server")
|
log.debug("Connected to server")
|
||||||
|
|
||||||
self.con.setMessageHandler(self.messageCB)
|
self.con.setMessageHandler(self.messageCB)
|
||||||
self.con.setPresenceHandler(self.presenceCB)
|
self.con.setPresenceHandler(self.presenceCB)
|
||||||
self.con.setDisconnectHandler(self.disconnectedCB)
|
self.con.setDisconnectHandler(self.disconnectedCB)
|
||||||
|
#BUG in jabberpy library : if hostname is wrong : "boucle"
|
||||||
if self.con.auth(name, password, ressource):
|
if self.con.auth(name, password, ressource):
|
||||||
self.con.requestRoster()
|
self.con.requestRoster()
|
||||||
roster = self.con.getRoster().getRaw()
|
roster = self.con.getRoster().getRaw()
|
||||||
|
@ -112,7 +113,8 @@ class GajimCore:
|
||||||
self.con.sendInitPresence()
|
self.con.sendInitPresence()
|
||||||
self.connected = 1
|
self.connected = 1
|
||||||
else:
|
else:
|
||||||
sys.exit(1)
|
log.debug("Couldn't authentificate to %s" % hostname)
|
||||||
|
return 0
|
||||||
# END connect
|
# END connect
|
||||||
|
|
||||||
def mainLoop(self):
|
def mainLoop(self):
|
||||||
|
|
10
doc/gajimrc
10
doc/gajimrc
|
@ -1,9 +1,10 @@
|
||||||
[Server]
|
|
||||||
|
|
||||||
hostname = SERVER HOSTNAME
|
|
||||||
|
|
||||||
[Profile]
|
[Profile]
|
||||||
|
|
||||||
|
accounts = Account1
|
||||||
|
|
||||||
|
[Account1]
|
||||||
|
|
||||||
|
hostname = SERVER HOSTNAME
|
||||||
name = LOGIN NAME
|
name = LOGIN NAME
|
||||||
password = PASSWORD
|
password = PASSWORD
|
||||||
ressource = gajim
|
ressource = gajim
|
||||||
|
@ -20,6 +21,7 @@ modules = sock
|
||||||
showoffline = 0
|
showoffline = 0
|
||||||
inmsgcolor = red
|
inmsgcolor = red
|
||||||
outmsgcolor = blue
|
outmsgcolor = blue
|
||||||
|
statusmsgcolor = green
|
||||||
iconstyle = sun
|
iconstyle = sun
|
||||||
autopopup = 0
|
autopopup = 0
|
||||||
|
|
||||||
|
|
|
@ -233,10 +233,15 @@ class message:
|
||||||
def print_conversation(self, txt, contact = None):
|
def print_conversation(self, txt, contact = None):
|
||||||
end_iter = self.convTxtBuffer.get_end_iter()
|
end_iter = self.convTxtBuffer.get_end_iter()
|
||||||
if contact:
|
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:
|
else:
|
||||||
self.convTxtBuffer.insert_with_tags_by_name(end_iter, '<' + self.user.name + '> ', 'incoming')
|
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.conversation.scroll_to_mark(\
|
||||||
self.convTxtBuffer.get_mark('end'), 0.1, 0, 0, 0)
|
self.convTxtBuffer.get_mark('end'), 0.1, 0, 0, 0)
|
||||||
|
|
||||||
|
@ -287,12 +292,17 @@ class message:
|
||||||
self.tag = self.convTxtBuffer.create_tag("incoming")
|
self.tag = self.convTxtBuffer.create_tag("incoming")
|
||||||
color = self.cfgParser.GtkGui_inmsgcolor
|
color = self.cfgParser.GtkGui_inmsgcolor
|
||||||
if not color:
|
if not color:
|
||||||
color = red
|
color = 'red'
|
||||||
self.tag.set_property("foreground", color)
|
self.tag.set_property("foreground", color)
|
||||||
self.tag = self.convTxtBuffer.create_tag("outgoing")
|
self.tag = self.convTxtBuffer.create_tag("outgoing")
|
||||||
color = self.cfgParser.GtkGui_outmsgcolor
|
color = self.cfgParser.GtkGui_outmsgcolor
|
||||||
if not color:
|
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)
|
self.tag.set_property("foreground", color)
|
||||||
|
|
||||||
class roster:
|
class roster:
|
||||||
|
@ -570,6 +580,15 @@ class plugin:
|
||||||
self.r.mkroster(ev[1])
|
self.r.mkroster(ev[1])
|
||||||
elif ev[0] == 'NOTIFY':
|
elif ev[0] == 'NOTIFY':
|
||||||
jid = string.split(ev[1][0], '/')[0]
|
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:
|
if string.find(jid, "@") <= 0:
|
||||||
#It must be an agent
|
#It must be an agent
|
||||||
jid = string.replace(jid, '@', '')
|
jid = string.replace(jid, '@', '')
|
||||||
|
|
Loading…
Add table
Reference in a new issue