PLEASE HAVE A LOOK. string module is deprecated. starting to change in order not to be deprecated. PLEASE HAVE A LOOK. I DID 2 times, maybe I missed sth though. split(' ') --> split() is the same so that's not an error [sep=' '] is the default one [and I don't expect that to change :P

This commit is contained in:
Nikos Kouremenos 2005-03-05 21:02:38 +00:00
parent c9d65729df
commit 893358edfe
4 changed files with 89 additions and 87 deletions

View file

@ -3,6 +3,7 @@
## Gajim Team: ## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org> ## - Yann Le Boulanger <asterix@lagaule.org>
## - Vincent Hanquez <tab@snarc.org> ## - Vincent Hanquez <tab@snarc.org>
## - Nikos Kouremenos <nkour@jabber.org>
## ##
## Copyright (C) 2003-2005 Gajim Team ## Copyright (C) 2003-2005 Gajim Team
## ##
@ -16,11 +17,17 @@
## GNU General Public License for more details. ## GNU General Public License for more details.
## ##
import sys, os, time, string, logging import sys
import os
import time
import logging
import common.hub, common.optparser import common.hub
import common.optparser
import common.jabber import common.jabber
import socket, select, pickle import socket
import select
import pickle
from tempfile import * from tempfile import *
from common import i18n from common import i18n
@ -75,11 +82,11 @@ else:
while 1: while 1:
line = child_stdout.readline() line = child_stdout.readline()
if line == "": break if line == "": break
line = string.rstrip( line ) line = line.rstrip()
if line[0:9] == '[GNUPG:] ': if line[0:9] == '[GNUPG:] ':
# Chop off the prefix # Chop off the prefix
line = line[9:] line = line[9:]
L = string.split(line, None, 1) L = line.split(None, 1)
keyword = L[0] keyword = L[0]
if len(L) > 1: if len(L) > 1:
resp[ keyword ] = L[1] resp[ keyword ] = L[1]
@ -162,9 +169,9 @@ else:
keyid = '' keyid = ''
if resp.has_key('GOODSIG'): if resp.has_key('GOODSIG'):
keyid = string.split(resp['GOODSIG'])[0] keyid = resp['GOODSIG'].split()[0]
elif resp.has_key('BADSIG'): elif resp.has_key('BADSIG'):
keyid = string.split(resp['BADSIG'])[0] keyid = resp['BADSIG'].split()[0]
return keyid return keyid
def get_secret_keys(self): def get_secret_keys(self):
@ -174,9 +181,9 @@ else:
proc.handles['stdout'].close() proc.handles['stdout'].close()
keys = {} keys = {}
lines = string.split(output, '\n') lines = output.split('\n')
for line in lines: for line in lines:
sline = string.split(line, ':') sline = line.split(':')
if sline[0] == 'sec': if sline[0] == 'sec':
keys[sline[4][8:]] = sline[9] keys[sline[4][8:]] = sline[9]
return keys return keys
@ -185,7 +192,7 @@ else:
def stripHeaderFooter(self, data): def stripHeaderFooter(self, data):
"""Remove header and footer from data""" """Remove header and footer from data"""
lines = string.split(data, '\n') lines = data.split('\n')
while lines[0] != '': while lines[0] != '':
lines.remove(lines[0]) lines.remove(lines[0])
while lines[0] == '': while lines[0] == '':
@ -195,7 +202,7 @@ else:
if line: if line:
if line[0] == '-': break if line[0] == '-': break
i = i+1 i = i+1
line = string.join(lines[0:i], '\n') line = '\n'.join(lines[0:i])
return line return line
def addHeaderFooter(self, data, type): def addHeaderFooter(self, data, type):
@ -248,7 +255,7 @@ class GajimCore:
"""Load defaults plugins : plugins in 'modules' option of Core section """Load defaults plugins : plugins in 'modules' option of Core section
in ConfFile and register them to the hub""" in ConfFile and register them to the hub"""
if moduleStr: if moduleStr:
mods = string.split (moduleStr, ' ') mods = moduleStr.split(' ')
for mod in mods: for mod in mods:
try: try:
@ -277,7 +284,7 @@ class GajimCore:
default_tab = {'Profile': {'log': 0}, 'Core_client': {'host': \ default_tab = {'Profile': {'log': 0}, 'Core_client': {'host': \
'localhost', 'port': 8255, 'modules': 'gtkgui'}} 'localhost', 'port': 8255, 'modules': 'gtkgui'}}
fname = os.path.expanduser(CONFPATH) fname = os.path.expanduser(CONFPATH)
reps = string.split(fname, '/') reps = fname.split('/')
path = '' path = ''
while len(reps) > 1: while len(reps) > 1:
path = path + reps[0] + '/' path = path + reps[0] + '/'
@ -315,7 +322,7 @@ class GajimCore:
if self.mode == 'server': if self.mode == 'server':
self.accounts = {} self.accounts = {}
if self.cfgParser.tab['Profile'].has_key('accounts'): if self.cfgParser.tab['Profile'].has_key('accounts'):
accts = string.split(self.cfgParser.tab['Profile']['accounts'], ' ') accts = self.cfgParser.tab['Profile']['accounts'].split()
if accts == ['']: if accts == ['']:
accts = [] accts = []
for a in accts: for a in accts:
@ -419,9 +426,9 @@ class GajimCore:
elif typ == 'subscribe': elif typ == 'subscribe':
log.debug("subscribe request from %s" % who) log.debug("subscribe request from %s" % who)
if self.cfgParser.Core['alwaysauth'] == 1 or \ if self.cfgParser.Core['alwaysauth'] == 1 or \
string.find(who, "@") <= 0: who.find("@") <= 0:
con.send(common.jabber.Presence(who, 'subscribed')) con.send(common.jabber.Presence(who, 'subscribed'))
if string.find(who, "@") <= 0: if who.find("@") <= 0:
self.hub.sendPlugin('NOTIFY', self.connexions[con], \ self.hub.sendPlugin('NOTIFY', self.connexions[con], \
(prs.getFrom().getStripped(), 'offline', 'offline', \ (prs.getFrom().getStripped(), 'offline', 'offline', \
prs.getFrom().getResource(), prio, keyID, None, None, None, \ prs.getFrom().getResource(), prio, keyID, None, None, None, \
@ -656,8 +663,7 @@ class GajimCore:
elif ev[0] == 'CONFIG': elif ev[0] == 'CONFIG':
if ev[2][0] == 'accounts': if ev[2][0] == 'accounts':
#Remove all old accounts #Remove all old accounts
accts = string.split(self.cfgParser.tab\ accts = self.cfgParser.tab['Profile']['accounts'].split()
['Profile']['accounts'], ' ')
if accts == ['']: if accts == ['']:
accts = [] accts = []
for a in accts: for a in accts:
@ -665,7 +671,7 @@ class GajimCore:
#Write all new accounts #Write all new accounts
accts = ev[2][1].keys() accts = ev[2][1].keys()
self.cfgParser.tab['Profile']['accounts'] = \ self.cfgParser.tab['Profile']['accounts'] = \
string.join(accts) ' '.join(accts)
for a in accts: for a in accts:
self.cfgParser.tab[a] = ev[2][1][a] self.cfgParser.tab[a] = ev[2][1][a]
if not a in self.connected.keys(): if not a in self.connected.keys():
@ -889,7 +895,7 @@ class GajimCore:
line = fic.readline() line = fic.readline()
nb = nb+1 nb = nb+1
if line: if line:
lineSplited = string.split(line, ':') lineSplited = line.split(':')
if len(lineSplited) > 2: if len(lineSplited) > 2:
self.hub.sendPlugin('LOG_LINE', ev[1], (ev[2][0], nb, \ self.hub.sendPlugin('LOG_LINE', ev[1], (ev[2][0], nb, \
lineSplited[0], lineSplited[1], lineSplited[2:])) lineSplited[0], lineSplited[1], lineSplited[2:]))

View file

@ -3,7 +3,8 @@
## Gajim Team: ## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org> ## - Yann Le Boulanger <asterix@lagaule.org>
## - Vincent Hanquez <tab@snarc.org> ## - Vincent Hanquez <tab@snarc.org>
## - Nikos Kouremenos <nkour@jabber.org> ## - Nikos Kouremenos <nkour@jabber.org>
## - Alex Podaras <bigpod@jabber.org>
## ##
## Copyright (C) 2003-2005 Gajim Team ## Copyright (C) 2003-2005 Gajim Team
## ##
@ -17,13 +18,10 @@
## GNU General Public License for more details. ## GNU General Public License for more details.
## ##
import pygtk
pygtk.require('2.0')
import gtk import gtk
import gtk.glade import gtk.glade
import gobject import gobject
import os import os
import string
import common.sleepy import common.sleepy
from common import i18n from common import i18n
_ = i18n._ _ = i18n._
@ -141,7 +139,7 @@ class preferences_window:
emots.append(model.get_value(iter, 0)) emots.append(model.get_value(iter, 0))
emots.append(model.get_value(iter, 1)) emots.append(model.get_value(iter, 1))
iter = model.iter_next(iter) iter = model.iter_next(iter)
self.plugin.config['emoticons'] = string.join(emots, '\t') self.plugin.config['emoticons'] = '\t'.join(emots)
#use emoticons #use emoticons
chk = self.xml.get_widget('use_emoticons_checkbutton') chk = self.xml.get_widget('use_emoticons_checkbutton')
if chk.get_active(): if chk.get_active():
@ -311,7 +309,7 @@ class preferences_window:
def load_emots(self): def load_emots(self):
emots = {} emots = {}
split_line = string.split(self.plugin.config['emoticons'], '\t') split_line = self.plugin.config['emoticons'].split('\t')
for i in range(0, len(split_line)/2): for i in range(0, len(split_line)/2):
if not self.image_is_ok(split_line[2*i+1]): if not self.image_is_ok(split_line[2*i+1]):
continue continue
@ -834,33 +832,33 @@ class account_window:
proxyhost = self.xml.get_widget('proxyhost_entry').get_text() proxyhost = self.xml.get_widget('proxyhost_entry').get_text()
proxyport = self.xml.get_widget('proxyport_entry').get_text() proxyport = self.xml.get_widget('proxyport_entry').get_text()
if (name == ''): if (name == ''):
warning_dialog(_('You must enter a name for this account')) Warning_dialog(_('You must enter a name for this account'))
return 0 return 0
if name.find(' ') != -1: if name.find(' ') != -1:
warning_dialog(_('Spaces are not permited in account name')) Warning_dialog(_('Spaces are not permited in account name'))
return 0 return 0
if (jid == '') or (string.count(jid, '@') != 1): if (jid == '') or (jid.count('@') != 1):
warning_dialog(_('You must enter a Jabber ID for this account\nFor example: someone@someserver.org')) Warning_dialog(_('You must enter a Jabber ID for this account\nFor example: someone@someserver.org'))
return 0 return 0
if new_account_checkbutton.get_active() and password == '': if new_account_checkbutton.get_active() and password == '':
warning_dialog(_('You must enter a password to register a new account')) Warning_dialog(_('You must enter a password to register a new account'))
return 0 return 0
if use_proxy: if use_proxy:
if proxyport != '': if proxyport != '':
try: try:
proxyport = string.atoi(proxyport) proxyport = int(proxyport)
except ValueError: except ValueError:
warning_dialog(_('Proxy Port must be a port number')) Warning_dialog(_('Proxy Port must be a port number'))
return 0 return 0
if proxyhost == '': if proxyhost == '':
warning_dialog(_('You must enter a proxy host to use proxy')) Warning_dialog(_('You must enter a proxy host to use proxy'))
if priority != '': if priority != '':
try: try:
priority = string.atoi(priority) priority = int(priority)
except ValueError: except ValueError:
warning_dialog(_('Priority must be a number')) Warning_dialog(_('Priority must be a number'))
return 0 return 0
(login, hostname) = string.split(jid, '@') (login, hostname) = jid.split('@')
key_name = self.xml.get_widget('gpg_name_label').get_text() key_name = self.xml.get_widget('gpg_name_label').get_text()
if key_name == '': #no key selected if key_name == '': #no key selected
keyID = '' keyID = ''
@ -916,7 +914,7 @@ class account_window:
return return
#if it's a new account #if it's a new account
if name in self.plugin.accounts.keys(): if name in self.plugin.accounts.keys():
warning_dialog(_('An account already has this name')) Warning_dialog(_('An account already has this name'))
return return
#if we neeed to register a new account #if we neeed to register a new account
if new_account_checkbutton.get_active(): if new_account_checkbutton.get_active():
@ -982,7 +980,7 @@ class account_window:
vcard_information_window(jid, self.plugin, self.account, True) vcard_information_window(jid, self.plugin, self.account, True)
self.plugin.send('ASK_VCARD', self.account, jid) self.plugin.send('ASK_VCARD', self.account, jid)
else: else:
warning_dialog(_('You must be connected to get your informations')) Warning_dialog(_('You must be connected to get your informations'))
def on_gpg_choose_button_clicked(self, widget, data=None): def on_gpg_choose_button_clicked(self, widget, data=None):
w = choose_gpg_key_dialog() w = choose_gpg_key_dialog()
@ -1285,8 +1283,8 @@ class agent_browser_window:
return return
service = model.get_value(iter, 1) service = model.get_value(iter, 1)
room = '' room = ''
if string.find(service, '@') > -1: if service.find('@') > -1:
services = string.split(service, '@') services = service.split('@')
room = services[0] room = services[0]
service = services[1] service = services[1]
if not self.plugin.windows.has_key('join_gc'): if not self.plugin.windows.has_key('join_gc'):
@ -1320,7 +1318,7 @@ class agent_browser_window:
def __init__(self, plugin, account): def __init__(self, plugin, account):
if not plugin.connected[account]: if not plugin.connected[account]:
warning_dialog(_("You must be connected to view Agents")) Warning_dialog(_("You must be connected to view Agents"))
return return
xml = gtk.glade.XML(GTKGUI_GLADE, 'agent_browser_window', APP) xml = gtk.glade.XML(GTKGUI_GLADE, 'agent_browser_window', APP)
self.window = xml.get_widget('agent_browser_window') self.window = xml.get_widget('agent_browser_window')

View file

@ -21,7 +21,6 @@
import gtk import gtk
import gtk.glade import gtk.glade
import gobject import gobject
import string
from common import i18n from common import i18n
_ = i18n._ _ = i18n._
APP = i18n.APP APP = i18n.APP
@ -67,7 +66,7 @@ class vcard_information_window:
if log and self.user.jid in no_log_for: if log and self.user.jid in no_log_for:
no_log_for.remove(self.user.jid) no_log_for.remove(self.user.jid)
if oldlog != log: if oldlog != log:
account_info['no_log_for'] = string.join(no_log_for, ' ') account_info['no_log_for'] = ' '.join(no_log_for)
self.plugin.accounts[self.account] = account_info self.plugin.accounts[self.account] = account_info
self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \ self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \
'Gtkgui')) 'Gtkgui'))
@ -122,7 +121,7 @@ class vcard_information_window:
def add_to_vcard(self, vcard, entry, txt): def add_to_vcard(self, vcard, entry, txt):
"""Add an information to the vCard dictionary""" """Add an information to the vCard dictionary"""
entries = string.split(entry, '_') entries = '_'.split(entry)
loc = vcard loc = vcard
while len(entries) > 1: while len(entries) > 1:
if not loc.has_key(entries[0]): if not loc.has_key(entries[0]):
@ -389,7 +388,7 @@ class add_contact_window:
#If login contains only numbers, it's probably an ICQ number #If login contains only numbers, it's probably an ICQ number
try: try:
string.atoi(uid) int(uid) # will raise ValueError if not all numbers
except: except:
pass pass
else: else:

View file

@ -44,7 +44,7 @@ if __name__ == "__main__":
sock.connect(('', 8255)) sock.connect(('', 8255))
except: except:
#TODO: use i18n #TODO: use i18n
print "unable to connect to localhost on port "+str(port) print "unable to connect to localhost on port ", port
else: else:
evp = pickle.dumps(('EXEC_PLUGIN', '', 'gtkgui')) evp = pickle.dumps(('EXEC_PLUGIN', '', 'gtkgui'))
sock.send('<'+evp+'>') sock.send('<'+evp+'>')
@ -57,7 +57,6 @@ import gtk
import gtk.glade import gtk.glade
import gobject import gobject
import os import os
import string
import time import time
import Queue import Queue
import sys import sys
@ -551,12 +550,12 @@ class tabbed_chat_window:
conversation_textview = self.xmls[jid].get_widget('conversation_textview') conversation_textview = self.xmls[jid].get_widget('conversation_textview')
conversation_buffer = conversation_textview.get_buffer() conversation_buffer = conversation_textview.get_buffer()
if not text: if not text:
text = "" text = ''
end_iter = conversation_buffer.get_end_iter() end_iter = conversation_buffer.get_end_iter()
if not tim: if not tim:
tim = time.localtime() tim = time.localtime()
tims = time.strftime("[%H:%M:%S]", tim) tim_format = time.strftime("[%H:%M:%S]", tim)
conversation_buffer.insert(end_iter, tims + ' ') conversation_buffer.insert(end_iter, tim_format + ' ')
otext = '' otext = ''
ttext = '' ttext = ''
@ -571,7 +570,7 @@ class tabbed_chat_window:
tag = 'incoming' tag = 'incoming'
name = user.name name = user.name
if string.find(text, '/me ') == 0: if text.find('/me ') == 0:
ttext = name + ' ' + text[4:] + '\n' ttext = name + ' ' + text[4:] + '\n'
else: else:
ttext = '<' + name + '> ' ttext = '<' + name + '> '
@ -898,20 +897,20 @@ class Groupchat_window:
message_textview.grab_focus() message_textview.grab_focus()
''' '''
def print_conversation(self, txt, room_jid, contact = None, tim = None): def print_conversation(self, text, room_jid, contact = None, tim = None):
"""Print a line in the conversation : """Print a line in the conversation :
if contact is set : it's a message from someone if contact is set : it's a message from someone
if contact is not set : it's a message from the server""" if contact is not set : it's a message from the server"""
conversation_textview = self.xmls[room_jid].\ conversation_textview = self.xmls[room_jid].\
get_widget('conversation_textview') get_widget('conversation_textview')
conversation_buffer = conversation_textview.get_buffer() conversation_buffer = conversation_textview.get_buffer()
if not txt: if not text:
txt = "" text = ''
end_iter = conversation_buffer.get_end_iter() end_iter = conversation_buffer.get_end_iter()
if not tim: if not tim:
tim = time.localtime() tim = time.localtime()
tims = time.strftime('[%H:%M:%S]', tim) tim_format = time.strftime('[%H:%M:%S]', time)
conversation_buffer.insert(end_iter, tims) conversation_buffer.insert(end_iter, tim_format) # CHECK! in tabbed print_conver you have + ' ' here
if contact: if contact:
if contact == self.nicks[room_jid]: if contact == self.nicks[room_jid]:
conversation_buffer.insert_with_tags_by_name(end_iter, '<' + \ conversation_buffer.insert_with_tags_by_name(end_iter, '<' + \
@ -919,9 +918,9 @@ class Groupchat_window:
else: else:
conversation_buffer.insert_with_tags_by_name(end_iter, '<' + \ conversation_buffer.insert_with_tags_by_name(end_iter, '<' + \
contact + '> ', 'incoming') contact + '> ', 'incoming')
conversation_buffer.insert(end_iter, txt + '\n') conversation_buffer.insert(end_iter, text + '\n')
else: else:
conversation_buffer.insert_with_tags_by_name(end_iter, txt + '\n', \ conversation_buffer.insert_with_tags_by_name(end_iter, text + '\n', \
'status') 'status')
#scroll to the end of the textview #scroll to the end of the textview
conversation_textview.scroll_to_mark(conversation_buffer.get_mark('end'),\ conversation_textview.scroll_to_mark(conversation_buffer.get_mark('end'),\
@ -1328,18 +1327,18 @@ class history_window:
tim = time.strftime("[%x %X] ", time.localtime(float(infos[1]))) tim = time.strftime("[%x %X] ", time.localtime(float(infos[1])))
self.history_buffer.insert(start_iter, tim) self.history_buffer.insert(start_iter, tim)
if infos[2] == 'recv': if infos[2] == 'recv':
msg = string.join(infos[3][0:], ':') msg = ':'.join(infos[3][0:])
msg = string.replace(msg, '\\n', '\n') msg = msg.replace('\\n', '\n')
self.history_buffer.insert_with_tags_by_name(start_iter, msg, \ self.history_buffer.insert_with_tags_by_name(start_iter, msg, \
'incoming') 'incoming')
elif infos[2] == 'sent': elif infos[2] == 'sent':
msg = string.join(infos[3][0:], ':') msg = ':'.join(infos[3][0:])
msg = string.replace(msg, '\\n', '\n') msg = msg.replace('\\n', '\n')
self.history_buffer.insert_with_tags_by_name(start_iter, msg, \ self.history_buffer.insert_with_tags_by_name(start_iter, msg, \
'outgoing') 'outgoing')
else: else:
msg = string.join(infos[3][1:], ':') msg = ':'.join(infos[3][1:], ':')
msg = string.replace(msg, '\\n', '\n') msg = msg.replace('\\n', '\n')
self.history_buffer.insert_with_tags_by_name(start_iter, \ self.history_buffer.insert_with_tags_by_name(start_iter, \
_('Status is now : ') + infos[3][0]+' : ' + msg, 'status') _('Status is now : ') + infos[3][0]+' : ' + msg, 'status')
@ -1450,7 +1449,7 @@ class roster_window:
users = self.contacts[account][jid] users = self.contacts[account][jid]
user = users[0] user = users[0]
if user.groups == []: if user.groups == []:
if string.find(user.jid, "@") <= 0: if user.jid.find("@") <= 0:
user.groups.append('Agents') user.groups.append('Agents')
else: else:
user.groups.append('general') user.groups.append('general')
@ -1607,7 +1606,7 @@ class roster_window:
if not self.groups.has_key(account): if not self.groups.has_key(account):
self.groups[account] = {} self.groups[account] = {}
for jid in array.keys(): for jid in array.keys():
jids = string.split(jid, '/') jids = jid.split('/')
#get jid #get jid
ji = jids[0] ji = jids[0]
#get resource #get resource
@ -1617,10 +1616,10 @@ class roster_window:
#get name #get name
name = array[jid]['name'] name = array[jid]['name']
if not name: if not name:
if string.find(ji, "@") <= 0: if ji.find("@") <= 0:
name = ji name = ji
else: else:
name = string.split(jid, '@')[0] name = jid.split('@')[0]
#get show #get show
show = array[jid]['show'] show = array[jid]['show']
if not show: if not show:
@ -2217,7 +2216,7 @@ class roster_window:
self.plugin.config['width'], self.plugin.config['height'] = \ self.plugin.config['width'], self.plugin.config['height'] = \
self.window.get_size() self.window.get_size()
self.plugin.config['hiddenlines'] = string.join(self.hidden_lines, '\t') self.plugin.config['hiddenlines'] = '\t'.join(self.hidden_lines)
self.plugin.send('CONFIG', None, ('GtkGui', self.plugin.config, 'GtkGui')) self.plugin.send('CONFIG', None, ('GtkGui', self.plugin.config, 'GtkGui'))
self.plugin.send('QUIT', None, ('gtkgui', 1)) self.plugin.send('QUIT', None, ('gtkgui', 1))
print _("plugin gtkgui stopped") print _("plugin gtkgui stopped")
@ -2353,7 +2352,7 @@ class roster_window:
"""initialize emoticons dictionary""" """initialize emoticons dictionary"""
self.emoticons = dict() self.emoticons = dict()
self.begin_emot = '' self.begin_emot = ''
split_line = string.split(self.plugin.config['emoticons'], '\t') split_line = self.plugin.config['emoticons'].split('\t')
for i in range(0, len(split_line)/2): for i in range(0, len(split_line)/2):
file = split_line[2*i+1] file = split_line[2*i+1]
if not self.image_is_ok(file): if not self.image_is_ok(file):
@ -2610,7 +2609,7 @@ class roster_window:
self.xml.signal_autoconnect(self) self.xml.signal_autoconnect(self)
self.id_signal_cb = self.cb.connect('changed', self.on_cb_changed) self.id_signal_cb = self.cb.connect('changed', self.on_cb_changed)
self.hidden_lines = string.split(self.plugin.config['hiddenlines'], '\t') self.hidden_lines = self.plugin.config['hiddenlines'].split('\t')
self.draw_roster() self.draw_roster()
class systrayDummy: class systrayDummy:
@ -2722,7 +2721,7 @@ class systray:
user = users[0] user = users[0]
if group in user.groups and user.show != 'offline' and \ if group in user.groups and user.show != 'offline' and \
user.show != 'error': user.show != 'error':
item = gtk.MenuItem(string.replace(user.name, '_', '__')) item = gtk.MenuItem(user.name.replace('_', '__'))
menu_user.append(item) menu_user.append(item)
item.connect("activate", self.start_chat, account, user.jid) item.connect("activate", self.start_chat, account, user.jid)
@ -2840,7 +2839,7 @@ class plugin:
try: try:
os.execvp(argv[0], argv) os.execvp(argv[0], argv)
except: except:
print _("error while running %s :") % string.join(argv, ' '), \ print _("error while running %s :") % ' '.join(argv), \
sys.exc_info()[1] sys.exc_info()[1]
os._exit(1) os._exit(1)
pidp, r = os.waitpid(pid, os.WNOHANG) pidp, r = os.waitpid(pid, os.WNOHANG)
@ -2892,15 +2891,15 @@ class plugin:
# role, affiliation, real_jid, reason, actor, statusCode)) # role, affiliation, real_jid, reason, actor, statusCode))
statuss = ['offline', 'error', 'online', 'chat', 'away', 'xa', 'dnd', 'invisible'] statuss = ['offline', 'error', 'online', 'chat', 'away', 'xa', 'dnd', 'invisible']
old_show = 0 old_show = 0
jid = string.split(array[0], '/')[0] jid = array[0].split('/')[0]
keyID = array[5] keyID = array[5]
resource = array[3] resource = array[3]
if not resource: if not resource:
resource = '' resource = ''
priority = array[4] priority = array[4]
if string.find(jid, "@") <= 0: if jid.find("@") <= 0:
#It must be an agent #It must be an agent
ji = string.replace(jid, '@', '') ji = jid.replace('@', '')
else: else:
ji = jid ji = jid
#Update user #Update user
@ -2920,7 +2919,7 @@ class plugin:
if user1.show in statuss: if user1.show in statuss:
old_show = statuss.index(user1.show) old_show = statuss.index(user1.show)
if (resources != [''] and (len(luser) != 1 or if (resources != [''] and (len(luser) != 1 or
luser[0].show != 'offline')) and not string.find(jid, "@") <= 0: luser[0].show != 'offline')) and not jid.find("@") <= 0:
old_show = 0 old_show = 0
user1 = User(user1.jid, user1.name, user1.groups, user1.show, \ user1 = User(user1.jid, user1.name, user1.groups, user1.show, \
user1.status, user1.sub, user1.ask, user1.resource, \ user1.status, user1.sub, user1.ask, user1.resource, \
@ -2931,7 +2930,7 @@ class plugin:
user1.status = array[2] user1.status = array[2]
user1.priority = priority user1.priority = priority
user1.keyID = keyID user1.keyID = keyID
if string.find(jid, "@") <= 0: if jid.find("@") <= 0:
#It must be an agent #It must be an agent
if self.roster.contacts[account].has_key(ji): if self.roster.contacts[account].has_key(ji):
#Update existing iter #Update existing iter
@ -2955,9 +2954,9 @@ class plugin:
def handle_event_msg(self, account, array): def handle_event_msg(self, account, array):
#('MSG', account, (user, msg, time)) #('MSG', account, (user, msg, time))
jid = string.split(array[0], '/')[0] jid = array[0].split('/')[0]
if string.find(jid, "@") <= 0: if jid.find("@") <= 0:
jid = string.replace(jid, '@', '') jid = jid.replace('@', '')
first = 0 first = 0
if not self.windows[account]['chats'].has_key(jid) and \ if not self.windows[account]['chats'].has_key(jid) and \
not self.queues[account].has_key(jid): not self.queues[account].has_key(jid):
@ -2970,9 +2969,9 @@ class plugin:
def handle_event_msgerror(self, account, array): def handle_event_msgerror(self, account, array):
#('MSGERROR', account, (user, error_code, error_msg, msg, time)) #('MSGERROR', account, (user, error_code, error_msg, msg, time))
jid = string.split(array[0], '/')[0] jid = array[0].split('/')[0]
if string.find(jid, "@") <= 0: if jid.find("@") <= 0:
jid = string.replace(jid, '@', '') jid = jid.replace('@', '')
self.roster.on_message(jid, _("error while sending") + " \"%s\" ( %s )"%\ self.roster.on_message(jid, _("error while sending") + " \"%s\" ( %s )"%\
(array[3], array[2]), array[4], account) (array[3], array[2]), array[4], account)
@ -3085,7 +3084,7 @@ class plugin:
def handle_event_gc_msg(self, account, array): def handle_event_gc_msg(self, account, array):
#('GC_MSG', account, (jid, msg, time)) #('GC_MSG', account, (jid, msg, time))
jids = string.split(array[0], '/') jids = array[0].split('/')
jid = jids[0] jid = jids[0]
if not self.windows[account]['gc'].has_key(jid): if not self.windows[account]['gc'].has_key(jid):
return return
@ -3103,7 +3102,7 @@ class plugin:
def handle_event_gc_subject(self, account, array): def handle_event_gc_subject(self, account, array):
#('GC_SUBJECT', account, (jid, subject)) #('GC_SUBJECT', account, (jid, subject))
jids = string.split(array[0], '/') jids = array[0].split('/')
jid = jids[0] jid = jids[0]
if not self.windows[account]['gc'].has_key(jid): if not self.windows[account]['gc'].has_key(jid):
return return