Author: js
Date: 2009-01-10 23:03:22 +0100 (Sat, 10 Jan 2009)
New Revision: 10962
Modified:
branches/osx_newbuildsys/src/common/connection.py
branches/osx_newbuildsys/src/common/connection_handlers.py
branches/osx_newbuildsys/src/common/latex.py
branches/osx_newbuildsys/src/common/xmpp/bosh.py
branches/osx_newbuildsys/src/common/xmpp/transports_nb.py
branches/osx_newbuildsys/src/roster_window.py
Log:
Complete merge with latest trunk (r10956).
Modified: branches/osx_newbuildsys/src/common/connection.py
===================================================================
--- branches/osx_newbuildsys/src/common/connection.py 2009-01-10 21:58:13 UTC (rev 10961)
+++ branches/osx_newbuildsys/src/common/connection.py 2009-01-10 22:03:22 UTC (rev 10962)
@@ -223,7 +223,7 @@
if gajim.account_is_connected(self.name):
# we cannot change our status to offline or connecting
# after we auth to server
- self.old_show = STATUS_LIST[self.connected]
+ self.old_show = gajim.SHOW_LIST[self.connected]
self.connected = 0
if not self.on_purpose:
self.dispatch('STATUS', 'offline')
@@ -856,14 +856,39 @@
return
common.xmpp.features_nb.setDefaultPrivacyList(self.connection, listname)
- def build_privacy_rule(self, name, action):
+ def build_privacy_rule(self, name, action, order=1):
'''Build a Privacy rule stanza for invisibility'''
iq = common.xmpp.Iq('set', common.xmpp.NS_PRIVACY, xmlns = '')
l = iq.getTag('query').setTag('list', {'name': name})
- i = l.setTag('item', {'action': action, 'order': '1'})
+ i = l.setTag('item', {'action': action, 'order': str(order)})
i.setTag('presence-out')
return iq
+ def build_invisible_rule(self):
+ iq = common.xmpp.Iq('set', common.xmpp.NS_PRIVACY, xmlns = '')
+ l = iq.getTag('query').setTag('list', {'name': 'invisible'})
+ if self.name in gajim.interface.status_sent_to_groups and \
+ len(gajim.interface.status_sent_to_groups[self.name]) > 0:
+ for group in gajim.interface.status_sent_to_groups[self.name]:
+ i = l.setTag('item', {'type': 'group', 'value': group,
+ 'action': 'allow', 'order': '1'})
+ i.setTag('presence-out')
+ if self.name in gajim.interface.status_sent_to_users and \
+ len(gajim.interface.status_sent_to_users[self.name]) > 0:
+ for jid in gajim.interface.status_sent_to_users[self.name]:
+ i = l.setTag('item', {'type': 'jid', 'value': jid,
+ 'action': 'allow', 'order': '2'})
+ i.setTag('presence-out')
+ i = l.setTag('item', {'action': 'deny', 'order': '3'})
+ i.setTag('presence-out')
+ return iq
+
+ def set_invisible_rule(self):
+ if not gajim.account_is_connected(self.name):
+ return
+ iq = self.build_invisible_rule()
+ self.connection.send(iq)
+
def activate_privacy_rule(self, name):
'''activate a privacy rule'''
if not self.connection:
@@ -892,7 +917,7 @@
self.connection.send(p)
# try to set the privacy rule
- iq = self.build_privacy_rule('invisible', 'deny')
+ iq = self.build_invisible_rule()
self.connection.SendAndCallForResponse(iq, self._continue_invisible,
{'msg': msg, 'signed': signed, 'initial': initial})
@@ -902,7 +927,7 @@
# active the privacy rule
self.privacy_rules_supported = True
self.activate_privacy_rule('invisible')
- self.connected = STATUS_LIST.index('invisible')
+ self.connected = gajim.SHOW_LIST.index('invisible')
self.status = msg
priority = unicode(gajim.get_priority(self.name, 'invisible'))
p = common.xmpp.Presence(priority = priority)
@@ -984,7 +1009,7 @@
self.connection.send(iq)
def send_custom_status(self, show, msg, jid):
- if not show in STATUS_LIST:
+ if not show in gajim.SHOW_LIST:
return -1
if not self.connection:
return
@@ -1009,7 +1034,7 @@
self.connection.send(p)
def change_status(self, show, msg, auto = False):
- if not show in STATUS_LIST:
+ if not show in gajim.SHOW_LIST:
return -1
sshow = helpers.get_xmpp_show(show)
if not msg:
@@ -1067,8 +1092,8 @@
signed = self.get_signed_presence(msg)
self.send_invisible_presence(msg, signed)
return
- was_invisible = self.connected == STATUS_LIST.index('invisible')
- self.connected = STATUS_LIST.index(show)
+ was_invisible = self.connected == gajim.SHOW_LIST.index('invisible')
+ self.connected = gajim.SHOW_LIST.index(show)
if was_invisible and self.privacy_rules_supported:
iq = self.build_privacy_rule('visible', 'allow')
self.connection.send(iq)
@@ -1092,7 +1117,7 @@
self.dispatch('STATUS', 'offline')
def get_status(self):
- return STATUS_LIST[self.connected]
+ return gajim.SHOW_LIST[self.connected]
def send_motd(self, jid, subject = '', msg = '', xhtml = None):
@@ -1536,7 +1561,7 @@
def send_agent_status(self, agent, ptype):
if not self.connection:
return
- show = helpers.get_xmpp_show(STATUS_LIST[self.connected])
+ show = helpers.get_xmpp_show(gajim.SHOW_LIST[self.connected])
p = common.xmpp.Presence(to = agent, typ = ptype, show = show)
p = self.add_sha(p, ptype != 'unavailable')
self.connection.send(p)
@@ -1559,7 +1584,7 @@
# FIXME: This room JID needs to be normalized; see #1364
if not self.connection:
return
- show = helpers.get_xmpp_show(STATUS_LIST[self.connected])
+ show = helpers.get_xmpp_show(gajim.SHOW_LIST[self.connected])
if show == 'invisible':
# Never join a room when invisible
return
Modified: branches/osx_newbuildsys/src/common/connection_handlers.py
===================================================================
--- branches/osx_newbuildsys/src/common/connection_handlers.py 2009-01-10 21:58:13 UTC (rev 10961)
+++ branches/osx_newbuildsys/src/common/connection_handlers.py 2009-01-10 22:03:22 UTC (rev 10962)
@@ -59,8 +59,6 @@
import logging
log = logging.getLogger('gajim.c.connection_handlers')
-STATUS_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd',
- 'invisible', 'error']
# kind of events we can wait for an answer
VCARD_PUBLISHED = 'vcard_published'
VCARD_ARRIVED = 'vcard_arrived'
@@ -1084,12 +1082,12 @@
self.save_vcard_to_hd(our_jid, vcard_iq)
# Send new presence if sha changed and we are not invisible
- if self.vcard_sha != new_sha and STATUS_LIST[self.connected] != \
+ if self.vcard_sha != new_sha and gajim.SHOW_LIST[self.connected] !=\
'invisible':
if not self.connection or self.connected < 2:
return
self.vcard_sha = new_sha
- sshow = helpers.get_xmpp_show(STATUS_LIST[self.connected])
+ sshow = helpers.get_xmpp_show(gajim.SHOW_LIST[self.connected])
p = common.xmpp.Presence(typ = None, priority = self.priority,
show = sshow, status = self.status)
p = self.add_sha(p)
@@ -1256,11 +1254,11 @@
if self.vcard_sha == avatar_sha:
return
self.vcard_sha = avatar_sha
- if STATUS_LIST[self.connected] == 'invisible':
+ if gajim.SHOW_LIST[self.connected] == 'invisible':
return
if not self.connection:
return
- sshow = helpers.get_xmpp_show(STATUS_LIST[self.connected])
+ sshow = helpers.get_xmpp_show(gajim.SHOW_LIST[self.connected])
p = common.xmpp.Presence(typ = None, priority = self.priority,
show = sshow, status = self.status)
p = self.add_sha(p)
@@ -2042,7 +2040,7 @@
status = prs.getStatus() or ''
show = prs.getShow()
- if not show in STATUS_LIST:
+ if not show in gajim.SHOW_LIST:
show = '' # We ignore unknown show
if not ptype and not show:
show = 'online'
@@ -2399,7 +2397,7 @@
_('You will be connected to %s without OpenPGP.') % self.name))
self.USE_GPG = False
signed = ''
- self.connected = STATUS_LIST.index(show)
+ self.connected = gajim.SHOW_LIST.index(show)
sshow = helpers.get_xmpp_show(show)
# send our presence
if show == 'invisible':
Modified: branches/osx_newbuildsys/src/common/latex.py
===================================================================
--- branches/osx_newbuildsys/src/common/latex.py 2009-01-10 21:58:13 UTC (rev 10961)
+++ branches/osx_newbuildsys/src/common/latex.py 2009-01-10 22:03:22 UTC (rev 10962)
@@ -30,8 +30,11 @@
import os
import random
from tempfile import gettempdir
-from subprocess import Popen
+from subprocess import Popen, PIPE
+import logging
+log = logging.getLogger('gajim.c.latex')
+
import gajim
from exceptions import LatexError
@@ -72,12 +75,14 @@
file_.close()
# a wrapper for Popen so that no window gets opened on Windows
+# (i think this is the reason we're using Popen rather than just system())
+# stdout goes to a pipe so that it can be read
def popen_nt_friendly(command):
if os.name == 'nt':
# CREATE_NO_WINDOW
- return Popen(command, creationflags=0x08000000, cwd=gettempdir())
+ return Popen(command, creationflags=0x08000000, cwd=gettempdir(), stdout=PIPE)
else:
- return Popen(command, cwd=gettempdir())
+ return Popen(command, cwd=gettempdir(), stdout=PIPE)
def check_for_latex_support():
'''check is latex is available and if it can create a picture.'''
@@ -110,6 +115,8 @@
try:
p = popen_nt_friendly(['latex', '--interaction=nonstopmode',
tmpfile + '.tex'])
+ out = p.communicate()[0]
+ log.info(out)
exitcode = p.wait()
except Exception, e:
exitcode = _('Error executing "%(command)s": %(error)s') % {
@@ -123,6 +130,8 @@
p = popen_nt_friendly(['dvipng', '-bg', 'rgb 1.0 1.0 1.0', '-T',
'tight', '-D', latex_png_dpi, tmpfile + '.dvi', '-o',
tmpfile + '.png'])
+ out = p.communicate()[0]
+ log.info(out)
exitcode = p.wait()
except Exception, e:
exitcode = _('Error executing "%(command)s": %(error)s') % {
Modified: branches/osx_newbuildsys/src/common/xmpp/bosh.py
===================================================================
--- branches/osx_newbuildsys/src/common/xmpp/bosh.py 2009-01-10 21:58:13 UTC (rev 10961)
+++ branches/osx_newbuildsys/src/common/xmpp/bosh.py 2009-01-10 22:03:22 UTC (rev 10962)
@@ -104,7 +104,7 @@
self.after_init = True
self.http_socks.append(self.get_new_http_socket())
- self.tcp_connecting_started()
+ self._tcp_connecting_started()
self.http_socks[0].connect(
conn_5tuple = conn_5tuple,
Modified: branches/osx_newbuildsys/src/common/xmpp/transports_nb.py
===================================================================
--- branches/osx_newbuildsys/src/common/xmpp/transports_nb.py 2009-01-10 21:58:13 UTC (rev 10961)
+++ branches/osx_newbuildsys/src/common/xmpp/transports_nb.py 2009-01-10 22:03:22 UTC (rev 10962)
@@ -200,7 +200,7 @@
Do not confuse it with on_receive() method, which is the callback itself.
'''
if not recv_handler:
- if hasattr(self._owner, 'Dispatcher'):
+ if hasattr(self, '_owner') and hasattr(self._owner, 'Dispatcher'):
self.on_receive = self._owner.Dispatcher.ProcessNonBlocking
else:
log.warning('No Dispatcher plugged. Received data will not be processed')
@@ -208,7 +208,7 @@
return
self.on_receive = recv_handler
- def tcp_connecting_started(self):
+ def _tcp_connecting_started(self):
self.set_state(CONNECTING)
def read_timeout(self):
@@ -313,7 +313,7 @@
# connecting in progress
log.info('After NB connect() of %s. "%s" raised => CONNECTING' %
(id(self), errstr))
- self.tcp_connecting_started()
+ self._tcp_connecting_started()
return
# if there was some other exception, call failure callback and unplug
@@ -397,7 +397,8 @@
return
self.set_state(DISCONNECTED)
self.idlequeue.unplug_idle(self.fd)
- if 'NonBlockingTLS' in self.__dict__: self.NonBlockingTLS.PlugOut()
+ if 'NonBlockingTLS' in self.__dict__:
+ self.NonBlockingTLS.PlugOut()
try:
self._sock.shutdown(socket.SHUT_RDWR)
self._sock.close()
@@ -513,7 +514,8 @@
exc_info=True)
errnum, errstr = e.exc
- if received == '': errstr = 'zero bytes on recv'
+ if received == '':
+ errstr = 'zero bytes on recv'
if (self.ssl_lib is None and received == '') or \
(self.ssl_lib == tls_nb.PYSTDLIB and errnum == 8 ) or \
@@ -563,7 +565,7 @@
def __init__(self, raise_event, on_disconnect, idlequeue, estabilish_tls,
certs, on_http_request_possible, on_persistent_fallback, http_dict,
- proxy_dict = None):
+ proxy_dict=None):
'''
:param on_http_request_possible: method to call when HTTP request to
socket owned by transport is possible.
Modified: branches/osx_newbuildsys/src/roster_window.py
===================================================================
--- branches/osx_newbuildsys/src/roster_window.py 2009-01-10 21:58:13 UTC (rev 10961)
+++ branches/osx_newbuildsys/src/roster_window.py 2009-01-10 22:03:22 UTC (rev 10962)
@@ -2045,7 +2045,7 @@
# unset custom status
if account in gajim.interface.status_sent_to_users and \
- contact.jid in gajim.interface.status_sent_to_users[account]:
+ contact.jid in gajim.interface.status_sent_to_users[account]:
del gajim.interface.status_sent_to_users[account][contact.jid]
# Delete pep if needed
@@ -3156,24 +3156,40 @@
def on_send_custom_status(self, widget, contact_list, show, group=None):
'''send custom status'''
+ # contact_list has only one element except if group != None
def on_response(message):
if message is None: # None if user pressed Cancel
return
+ account_list = []
for (contact, account) in contact_list:
- our_jid = gajim.get_jid_from_account(account)
- accounts = []
- if group and account not in accounts:
+ if account not in account_list:
+ account_list.append(account)
+ # 1. update status_sent_to_[groups|users] list
+ if group:
+ for account in account_list:
if account not in gajim.interface.status_sent_to_groups:
gajim.interface.status_sent_to_groups[account] = {}
gajim.interface.status_sent_to_groups[account][group] = show
- accounts.append(group)
+ else:
+ for (contact, account) in contact_list:
+ if account not in gajim.interface.status_sent_to_users:
+ gajim.interface.status_sent_to_users[account] = {}
+ gajim.interface.status_sent_to_users[account][contact.jid] = show
+
+ # 2. update privacy lists if main status is invisible
+ for account in account_list:
+ if gajim.SHOW_LIST[gajim.connections[account].connected] == \
+ 'invisible':
+ gajim.connections[account].set_invisible_rule()
+
+ # 3. send directed presence
+ for (contact, account) in contact_list:
+ our_jid = gajim.get_jid_from_account(account)
jid = contact.jid
if jid == our_jid:
jid += '/' + contact.resource
self.send_status(account, show, message, to=jid)
- if account not in gajim.interface.status_sent_to_users:
- gajim.interface.status_sent_to_users[account] = {}
- gajim.interface.status_sent_to_users[account][contact.jid] = show
+
dialogs.ChangeStatusMessageDialog(on_response, show)
def on_status_combobox_changed(self, widget):