Commit 957c1dc0 authored by Yann Leboulanger's avatar Yann Leboulanger

import buxfixes from trunk:

[10911] [10929] [10930] [10934] [10935] [10936] [10938] [10939] [10941] [10946] [10947] [10948] [10949] [10950] [10951] [10954] [10956] [10976] [10977] [10978] [10979] [10980] [10986] [10987] [10988] [10990] [10991] [10993] [10995] [10999] [11003] [11004] [11005] [11009] [11011] [11013] [11014] [11028] [11029] [11030] [11031] [11032] [11033] [11036] [11037] [11038] [11040] [11042] [11043] [11044] [11046] [11047] [11048] [11051] [11052] [11053] [11054] [11056] [11057] [11058] [r1060] [r1061] [11064] [11065] [11069] [11070] [11071] [11072] [11073] [11074] [11075] [11079] [11080] [11082] [11084] [11088] [11089] [11098] [11105] [11106] [11111] [11112] [11113] [11115] [11116] [11118] [11119] [11122] [11123] [11125] [11127] [11128] [11137] [11139] [11140]

Fixes #4616, #4605, #4627, #4638, #4624, #4618, #4641, #4652, #4631, #4667, #4670, #4642, #4650, #4618, #4692, #4658, #4630, #4705, #4629, #4712, #4684, #4720, #4672, #663, #4703, #4710, #3474, #4715, #4735, #4730, #4739, #4737, #4741, #4748, #4744, #4738, #4760, #4762, #4764, #4767, #4556, #4774, #4788, #4783, #4770, #4798, #4801, #4436, #4708, #2243, #4800, #4536, #4299, #3781, #4820, #4819, #4826, #4263, #4831, #4834, #4832, #4847, #4855, #4828
parent 212832d0
......@@ -8,7 +8,7 @@ else
OPTIONAL_BIN =
endif
bin_SCRIPTS = scripts/gajim $(OPTIONAL_BIN)
bin_SCRIPTS = scripts/gajim scripts/gajim-history-manager $(OPTIONAL_BIN)
docfilesdir = $(docdir)
......@@ -28,15 +28,15 @@ EXTRA_DIST = \
intltool-update.in \
gajim.nsi \
setup_win32.py \
scripts/gajim.in \
scripts/gajim-remote.in
scripts/gajim.in
DISTCLEANFILES = \
intltool-extract \
intltool-merge \
intltool-update \
scripts/gajim \
scripts/gajim-remote
scripts/gajim-remote \
scripts/gajim-histrory-manager
MAINTAINERCLEANFILES = \
configure \
......
......@@ -31,12 +31,12 @@ Gajim is a GTK+ app that loves GNOME. You can do 'make' so you don't require gno
<li><a href="http://pyopenssl.sourceforge.net/">PyOpenSSL</a> (python-pyopenssl package in Debian) for <em>secure</em> SSL/TLS. Python's default SSL is insecure, so this package is highly recommended!</li>
<li>python-crypto to enable End to end encryption</li>
<li>For zeroconf (bonjour), the "enable link-local messaging" checkbox, you need dbus-glib, python-avahi</li>
<li>dnsutils (or whatever package provides the nslookup binary) for SRV support; if you don't know what that is, you don't need it</li>
<li>dnsutils (or whatever package provides the nslookup binary) for SRV support</li>
<li>gtkspell and aspell-LANG where lang is your locale eg. en, fr etc</li>
<li>GnomePythonExtras 2.10 or above (aka gnome-python-desktop) so you can avoid compiling trayicon and gtkspell</li>
<li>gnome-python-desktop (for GnomeKeyring support)</li>
<li>notification-daemon or notify-python (and D-Bus) to get cooler popups</li>
<li>D-Bus running to have gajim-remote working</li>
<li>D-Bus running to have gajim-remote working. Some distributions split dbus-x11, which is needed for dbus to work with Gajim.</li>
<li>python-dbus bindings</li>
<li>python-sexy to have clickable URLs in chat windows</li>
<li>python-kerberos to use GSSAPI authentication. Note: version1.1 or higher is required</li>
......
AC_INIT([Gajim - A Jabber Instant Messager],
[0.12.1],[http://trac.gajim.org/],[gajim])
[0.12.2],[http://trac.gajim.org/],[gajim])
AC_PREREQ([2.59])
AM_INIT_AUTOMAKE([1.8])
AC_CONFIG_HEADER(config.h)
......@@ -207,18 +207,12 @@ AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
AC_SUBST([PYTHON_INCLUDES])
AS_AC_EXPAND(DATADIR, "${datadir}")
AS_AC_EXPAND(LIBDIR, ${libdir})
AS_AC_EXPAND(LIBDIR, "${libdir}")
AS_AC_EXPAND(DOCDIR, "${docdir}")
AS_AC_EXPAND(LOCALEDIR, "${localedir}")
AC_SUBST(VERSION)
AC_SUBST(PACKAGE)
AC_SUBST(DATADIR)
AC_SUBST(LIBDIR)
AS_AC_EXPAND(DATADIR, "${DATADIR}")
AC_SUBST(DOCDIR)
AS_AC_EXPAND(DOCDIR, "${DOCDIR}")
AC_CONFIG_FILES([
Makefile
......@@ -237,7 +231,8 @@ AC_CONFIG_FILES([
src/osx/growl/Makefile
src/osx/syncmenu/Makefile
scripts/gajim
scripts/gajim-remote
scripts/gajim-remote:scripts/gajim.in
scripts/gajim-history-manager:scripts/gajim.in
po/Makefile.in
])
AC_OUTPUT
......
......@@ -5,3 +5,5 @@ docdir = "@DOCDIR@"
datadir = "@DATADIR@"
version = "@VERSION@"
localedir = "@LOCALEDIR@"
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
dnl as-ac-expand.m4 0.2.0 -*- autoconf -*-
dnl autostars m4 macro for expanding directories using configure's prefix
dnl (C) 2003, 2004, 2005 Thomas Vander Stichele <thomas at apestaart dot org>
dnl Copying and distribution of this file, with or without modification,
dnl are permitted in any medium without royalty provided the copyright
dnl notice and this notice are preserved.
dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
dnl
dnl example
dnl example:
dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
......@@ -15,7 +24,7 @@ AC_DEFUN([AS_AC_EXPAND],
dnl if no prefix given, then use /usr/local, the default prefix
if test "x$prefix" = "xNONE"; then
prefix=$ac_default_prefix
prefix="$ac_default_prefix"
fi
dnl if no exec_prefix given, then use prefix
if test "x$exec_prefix" = "xNONE"; then
......@@ -26,7 +35,7 @@ AC_DEFUN([AS_AC_EXPAND],
dnl loop until it doesn't change anymore
while true; do
new_full_var="`eval echo $full_var`"
if test "x$new_full_var"="x$full_var"; then break; fi
if test "x$new_full_var" = "x$full_var"; then break; fi
full_var=$new_full_var
done
......
#!/bin/sh
## scripts/gajim-remote.in
##
## Copyright (C) 2006 Yann Leboulanger <asterix AT lagaule.org>
## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org>
##
## This file is part of Gajim.
##
## Gajim is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation; version 3 only.
##
## Gajim is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
##
if test $(id -u) -eq 0; then
echo "You must not launch gajim-remote as root, it is INSECURE"
exit 1
fi
datadir=@DATADIR@
PYTHON_EXEC=@PYTHON@
cd ${datadir}/gajim/src
export PYTHONPATH="$PYTHONPATH:@LIBDIR@/gajim"
exec ${PYTHON_EXEC} -OO gajim-remote.py "$@"
......@@ -21,14 +21,17 @@
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
##
APP=`basename $0`
if test $(id -u) -eq 0; then
echo "You must not launch Gajim as root, it is INSECURE"
echo "You must not launch $APP as root, it is INSECURE"
exit 1
fi
datadir=@DATADIR@
[ "$APP" = "gajim-history-manager" ] && APP="history_manager"
export datadir=@DATADIR@/gajim
PYTHON_EXEC=@PYTHON@
cd ${datadir}/gajim/src
cd ${datadir}/src
export PYTHONPATH="$PYTHONPATH:@LIBDIR@/gajim"
exec ${PYTHON_EXEC} -OO gajim.py $@
exec ${PYTHON_EXEC} -OO $APP.py "$@"
......@@ -8,7 +8,7 @@ export MACOSX_DEPLOYMENT_TARGET=10.4
if BUILD_GTKSPELL
gtkspelllib_LTLIBRARIES = gtkspell.la
gtkspelllibdir = $(libdir)/gajim
gtkspelllibdir = $(pkglibdir)
gtkspell_la_LIBADD = \
$(GTKSPELL_LIBS) $(PYGTK_LIBS)
......@@ -23,7 +23,7 @@ gtkspell_la_CFLAGS = $(GTKSPELL_CFLAGS) $(PYGTK_CFLAGS)
endif
if BUILD_TRAYICON
trayiconlib_LTLIBRARIES = trayicon.la
trayiconlibdir = $(libdir)/gajim
trayiconlibdir = $(pkglibdir)
trayicon_la_LIBADD = $(PYGTK_LIBS)
trayicon_la_SOURCES = \
eggtrayicon.c \
......
......@@ -135,7 +135,9 @@ class ChatControlBase(MessageControl):
def handle_message_textview_mykey_press(self, widget, event_keyval,
event_keymod):
pass # Derived should implement this rather than connecting to the event itself.
# Derived should implement this rather than connecting to the event
# itself.
pass
def status_url_clicked(self, widget, url):
helpers.launch_browser_mailer('url', url)
......@@ -164,17 +166,18 @@ class ChatControlBase(MessageControl):
# Create banner and connect signals
widget = self.xml.get_widget('banner_eventbox')
widget.set_property('height-request', gajim.config.get('chat_avatar_height'))
id = widget.connect('button-press-event',
self._on_banner_eventbox_button_press_event)
self.handlers[id] = widget
self.urlfinder = re.compile(r"(www\.(?!\.)|[a-z][a-z0-9+.-]*://)[^\s<>'\"]+[^!,\.\s<>\)'\"\]]")
self.urlfinder = re.compile(
r"(www\.(?!\.)|[a-z][a-z0-9+.-]*://)[^\s<>'\"]+[^!,\.\s<>\)'\"\]]")
if gajim.HAVE_PYSEXY:
import sexy
self.banner_status_label = sexy.UrlLabel()
self.banner_status_label.connect('url_activated', self.status_url_clicked)
self.banner_status_label.connect('url_activated',
self.status_url_clicked)
else:
self.banner_status_label = gtk.Label()
self.banner_status_label.set_selectable(True)
......@@ -273,29 +276,7 @@ class ChatControlBase(MessageControl):
# Attach speller
if gajim.config.get('use_speller') and HAS_GTK_SPELL:
try:
spell = gtkspell.Spell(self.msg_textview)
# loop removing non-existant dictionaries
# iterating on a copy
for lang in dict(langs):
try:
spell.set_language(langs[lang])
except Exception:
del langs[lang]
# now set the one the user selected
per_type = 'contacts'
if self.type_id == message_control.TYPE_GC:
per_type = 'rooms'
lang = gajim.config.get_per(per_type, self.contact.jid,
'speller_language')
if not lang:
# use the default one
lang = gajim.config.get('speller_language')
if lang:
self.msg_textview.lang = lang
spell.set_language(lang)
except (gobject.GError, RuntimeError), msg:
dialogs.AspellDictError(lang)
self.set_speller()
self.conv_textview.tv.show()
self._paint_banner()
......@@ -305,8 +286,37 @@ class ChatControlBase(MessageControl):
self.smooth = True
self.msg_textview.grab_focus()
def set_speller(self):
try:
lang = gajim.config.get('speller_language')
if not lang:
lang = gajim.LANG
spell = gtkspell.Spell(self.msg_textview, lang)
# loop removing non-existant dictionaries
# iterating on a copy
for lang in dict(langs):
try:
spell.set_language(langs[lang])
except Exception:
del langs[lang]
# now set the one the user selected
per_type = 'contacts'
if self.type_id == message_control.TYPE_GC:
per_type = 'rooms'
lang = gajim.config.get_per(per_type, self.contact.jid,
'speller_language')
if not lang:
# use the default one
lang = gajim.config.get('speller_language')
if lang:
self.msg_textview.lang = lang
spell.set_language(lang)
except (gobject.GError, RuntimeError), msg:
dialogs.AspellDictError(lang)
def on_msg_textview_populate_popup(self, textview, menu):
'''we override the default context menu and we prepend an option to switch languages'''
'''we override the default context menu and we prepend an option to switch
languages'''
def _on_select_dictionary(widget, lang):
per_type = 'contacts'
if self.type_id == message_control.TYPE_GC:
......@@ -668,7 +678,7 @@ class ChatControlBase(MessageControl):
# other_tags_for_text == ['marked'] --> highlighted gc message
gajim.last_message_time[self.account][full_jid] = time.time()
if kind in ('incoming', 'incoming_queue'):
if kind in ('incoming', 'incoming_queue', 'error'):
gc_message = False
if self.type_id == message_control.TYPE_GC:
gc_message = True
......@@ -678,7 +688,7 @@ class ChatControlBase(MessageControl):
not self.parent_win.is_active() or not end)) or \
(gc_message and \
jid in gajim.interface.minimized_controls[self.account])) and \
kind in ('incoming', 'incoming_queue'):
kind in ('incoming', 'incoming_queue', 'error'):
# we want to have save this message in events list
# other_tags_for_text == ['marked'] --> highlighted gc message
if gc_message:
......@@ -710,7 +720,7 @@ class ChatControlBase(MessageControl):
if (not self.parent_win.get_active_control() or \
self != self.parent_win.get_active_control() or \
not self.parent_win.is_active() or not end) and \
kind in ('incoming', 'incoming_queue'):
kind in ('incoming', 'incoming_queue', 'error'):
self.parent_win.redraw_tab(self)
if not self.parent_win.is_active():
self.parent_win.show_title(True, self) # Enabled Urgent hint
......@@ -1017,6 +1027,7 @@ class ChatControl(ChatControlBase):
ChatControlBase.__init__(self, self.TYPE_ID, parent_win,
'chat_child_vbox', contact, acct, resource)
self.gpg_is_active = False
# for muc use:
# widget = self.xml.get_widget('muc_window_actions_button')
self.actions_button = self.xml.get_widget('message_window_actions_button')
......@@ -1107,6 +1118,8 @@ class ChatControl(ChatControlBase):
self.handlers[id] = message_tv_buffer
widget = self.xml.get_widget('avatar_eventbox')
widget.set_property('height-request', gajim.config.get(
'chat_avatar_height'))
id = widget.connect('enter-notify-event',
self.on_avatar_eventbox_enter_notify_event)
self.handlers[id] = widget
......@@ -1139,7 +1152,6 @@ class ChatControl(ChatControlBase):
# Enable encryption if needed
self.no_autonegotiation = False
e2e_is_active = self.session and self.session.enable_encryption
self.gpg_is_active = False
gpg_pref = gajim.config.get_per('contacts', contact.jid,
'gpg_enabled')
......@@ -1549,7 +1561,8 @@ class ChatControl(ChatControlBase):
ChatControlBase.print_conversation_line(self, msg,
'status', '', None)
loggable = gajim.config.get('log_encrypted_sessions')
loggable = gajim.config.get_per('accounts', self.account,
'log_encrypted_sessions')
if self.session:
self.session.loggable = loggable
......@@ -1829,12 +1842,13 @@ class ChatControl(ChatControlBase):
def print_conversation(self, text, frm='', tim=None, encrypted=False,
subject=None, xhtml=None, simple=False, xep0184_id=None):
# TODO: contact? ITYM frm.
'''Print a line in the conversation:
if contact is set to status: it's a status message
if contact is set to another value: it's an outgoing message
if contact is set to print_queue: it is incomming from queue
if contact is not set: it's an incomming message'''
if frm is set to status: it's a status message
if frm is set to error: it's an error message
if frm is set to info: it's a information message
if frm is set to print_queue: it is incomming from queue
if frm is set to another value: it's an outgoing message
if frm is not set: it's an incomming message'''
contact = self.contact
jid = contact.jid
......@@ -1843,6 +1857,9 @@ class ChatControl(ChatControlBase):
return
kind = 'status'
name = ''
elif frm == 'error':
kind = 'error'
name = ''
elif frm == 'info':
kind = 'info'
name = ''
......@@ -2336,10 +2353,10 @@ class ChatControl(ChatControlBase):
e2e_is_active = self.session and \
self.session.enable_encryption
e2e_pref = gajim.config.get_per('accounts',
self.account, 'autonegotiate_esessions') and \
gajim.config.get_per('contacts',
self.contact.jid, 'autonegotiate_esessions')
e2e_pref = gajim.config.get_per('accounts', self.account,
'enable_esessions') and gajim.config.get_per('accounts',
self.account, 'autonegotiate_esessions') and gajim.config.get_per(
'contacts', self.contact.jid, 'autonegotiate_esessions')
want_e2e = not e2e_is_active and not self.gpg_is_active \
and e2e_pref
......
......@@ -35,11 +35,15 @@ if gajim.HAVE_GPG:
GnuPGInterface.GnuPG.__init__(self)
self.use_agent = use_agent
self._setup_my_options()
self.always_trust = False
def _setup_my_options(self):
self.options.armor = 1
self.options.meta_interactive = 0
self.options.extra_args.append('--no-secmem-warning')
# disable photo viewer when verifying keys
self.options.extra_args.append('--verify-options')
self.options.extra_args.append('no-show-photo')
if self.use_agent:
self.options.extra_args.append('--use-agent')
......@@ -68,10 +72,13 @@ if gajim.HAVE_GPG:
resp[ keyword ] = ""
return resp
def encrypt(self, str_, recipients):
def encrypt(self, str_, recipients, always_trust=False):
self.options.recipients = recipients # a list!
proc = self.run(['--encrypt'], create_fhs=['stdin', 'stdout', 'status',
opt = ['--encrypt']
if always_trust or self.always_trust:
opt.append('--always-trust')
proc = self.run(opt, create_fhs=['stdin', 'stdout', 'status',
'stderr'])
proc.handles['stdin'].write(str_)
try:
......@@ -97,6 +104,9 @@ if gajim.HAVE_GPG:
try: proc.wait()
except IOError: pass
if 'INV_RECP' in resp and resp['INV_RECP'].split()[0] == '10':
# unusable recipient "Key not trusted"
return '', 'NOT_TRUSTED'
if 'BEGIN_ENCRYPTION' in resp and 'END_ENCRYPTION' in resp:
# Encryption succeeded, even if there is output on stderr. Maybe
# verbose is on
......@@ -142,6 +152,8 @@ if gajim.HAVE_GPG:
except IOError: pass
if 'GOOD_PASSPHRASE' in resp or 'SIG_CREATED' in resp:
return self._stripHeaderFooter(output)
if 'KEYEXPIRED' in resp:
return 'KEYEXPIRED'
return 'BAD_PASSPHRASE'
def verify(self, str_, sign):
......
......@@ -64,7 +64,7 @@ class Entry(xmpp.Node, object):
xmpp.Node.__init__(self, 'entry', node=node)
def __repr__(self):
return '<Atom:Entry object of id="%r">' % self.id
return '<Atom:Entry object of id="%r">' % self.getAttr('id')
class OldEntry(xmpp.Node, object):
''' Parser for feeds from pubsub.com. They use old Atom 0.3 format with
......@@ -74,7 +74,7 @@ class OldEntry(xmpp.Node, object):
xmpp.Node.__init__(self, 'entry', node=node)
def __repr__(self):
return '<Atom0.3:Entry object of id="%r">' % self.id
return '<Atom0.3:Entry object of id="%r">' % self.getAttr('id')
def get_feed_title(self):
''' Returns title of feed, where the entry was created. The result is the feed name
......
......@@ -80,7 +80,6 @@ class Config:
'notify_on_new_message': [ opt_bool, True ],
'autopopupaway': [ opt_bool, False ],
'use_notif_daemon': [ opt_bool, True , _('Use D-Bus and Notification-Daemon to show notifications') ],
'ignore_unknown_contacts': [ opt_bool, False ],
'showoffline': [ opt_bool, False ],
'show_transports_group': [ opt_bool, True ],
'autoaway': [ opt_bool, True ],
......@@ -136,6 +135,7 @@ class Config:
'gc-hpaned-position': [opt_int, 430],
'gc_refer_to_nick_char': [opt_str, ',', _('Character to add after nickname when using nick completion (tab) in group chat.')],
'gc_proposed_nick_char': [opt_str, '_', _('Character to propose to add after desired nickname when desired nickname is used by someone else in group chat.')],
'msgwin-max-state': [opt_bool, False],
'msgwin-x-position': [opt_int, -1], # Default is to let the window manager decide
'msgwin-y-position': [opt_int, -1], # Default is to let the window manager decide
'msgwin-width': [opt_int, 500],
......@@ -161,7 +161,6 @@ class Config:
'time_stamp': [ opt_str, '[%X] ', _('This option let you customize timestamp that is printed in conversation. For exemple "[%H:%M] " will show "[hour:minute] ". See python doc on strftime for full documentation: http://docs.python.org/lib/module-time.html') ],
'before_nickname': [ opt_str, '', _('Characters that are printed before the nickname in conversations') ],
'after_nickname': [ opt_str, ':', _('Characters that are printed after the nickname in conversations') ],
'send_os_info': [ opt_bool, True ],
'notify_on_new_gmail_email': [ opt_bool, True ],
'notify_on_new_gmail_email_extra': [ opt_bool, False ],
'use_gpg_agent': [ opt_bool, False ],
......@@ -200,7 +199,6 @@ class Config:
'tabs_always_visible': [opt_bool, False, _('Show tab when only one conversation?')],
'tabs_border': [opt_bool, False, _('Show tabbed notebook border in chat windows?')],
'tabs_close_button': [opt_bool, True, _('Show close button in tab?')],
'log_encrypted_sessions': [opt_bool, True, _('When negotiating an encrypted session, should Gajim assume you want your messages to be logged?')],
'esession_modp': [opt_str, '5,14', _('A list of modp groups to use in a Diffie-Hellman, highest preference first, separated by commas. Valid groups are 1, 2, 5, 14, 15, 16, 17 and 18. Higher numbers are more secure, but take longer to calculate when you start a session.')],
'chat_avatar_width': [opt_int, 52],
'chat_avatar_height': [opt_int, 52],
......@@ -338,6 +336,9 @@ class Config:
'subscribe_activity': [opt_bool, True],
'subscribe_tune': [opt_bool, True],
'subscribe_nick': [opt_bool, True],
'ignore_unknown_contacts': [ opt_bool, False ],
'send_os_info': [ opt_bool, True ],
'log_encrypted_sessions': [opt_bool, True, _('When negotiating an encrypted session, should Gajim assume you want your messages to be logged?')],
}, {}),
'statusmsg': ({
'message': [ opt_str, '' ],
......
......@@ -114,9 +114,19 @@ class ConfigPaths:
for n, p in zip(k, v):
self.add_from_root(n, p)
self.add('DATA', os.path.join(u'..', windowsify(u'data')))
datadir = ''
if u'datadir' in os.environ:
datadir = fse(os.environ[u'datadir'])
if not datadir:
datadir = u'..'
self.add('DATA', os.path.join(datadir, windowsify(u'data')))
self.add('HOME', fse(os.path.expanduser('~')))
self.add('TMP', fse(tempfile.gettempdir()))
try:
self.add('TMP', fse(tempfile.gettempdir()))
except IOError, e:
print >> sys.stderr, 'Error opening tmp folder: %s\nUsing %s' % (
str(e), os.path.expanduser('~'))
self.add('TMP', fse(os.path.expanduser('~')))
try:
import svn_config
......
......@@ -153,6 +153,7 @@ class Connection(ConnectionHandlers):
self.blocked_list = []
self.blocked_contacts = []
self.blocked_groups = []
self.blocked_all = False
self.music_track_info = 0
self.pep_supported = False
self.mood = {}
......@@ -180,6 +181,7 @@ class Connection(ConnectionHandlers):
def put_event(self, ev):
if ev[0] in gajim.handlers:
log.debug('Sending %s event to GUI: %s' % (ev[0], ev[1:]))
gajim.handlers[ev[0]](self.name, ev[1])
def dispatch(self, event, data):
......@@ -222,7 +224,7 @@ class Connection(ConnectionHandlers):
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')
......@@ -680,6 +682,9 @@ class Connection(ConnectionHandlers):
self.dispatch('FINGERPRINT_ERROR',
(con.Connection.ssl_fingerprint_sha1,))
return True
else:
gajim.config.set_per('accounts', self.name, 'ssl_fingerprint_sha1',
con.Connection.ssl_fingerprint_sha1)
self._register_handlers(con, con_type)
con.auth(name, self.password, self.server_resource, 1, self.__on_auth)
......@@ -824,14 +829,39 @@ class Connection(ConnectionHandlers):
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:
......@@ -860,7 +890,7 @@ class Connection(ConnectionHandlers):
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})
......@@ -870,7 +900,7 @@ class Connection(ConnectionHandlers):
# 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)
......@@ -896,13 +926,18 @@ class Connection(ConnectionHandlers):
self.dispatch('SIGNED_IN', ())
def test_gpg_passphrase(self, password):
'''Returns 'ok', 'bad_pass' or 'expired' '''
if not self.gpg:
return False
self.gpg.passphrase = password
keyID = gajim.config.get_per('accounts', self.name, 'keyid')
signed = self.gpg.sign('test', keyID)
self.gpg.password = None
return signed != 'BAD_PASSPHRASE'
if signed == 'KEYEXPIRED':
return 'expired'
elif signed == 'BAD_PASSPHRASE':
return 'bad_pass'
return 'ok'
def get_signed_presence(self, msg, callback = None):
if gajim.config.get_per('accounts', self.name, 'gpg_sign_presence'):
......@@ -952,7 +987,7 @@ class Connection(ConnectionHandlers):
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
......@@ -978,7 +1013,7 @@ class Connection(ConnectionHandlers):
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:
......@@ -1033,8 +1068,8 @@ class Connection(ConnectionHandlers):
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)
......@@ -1054,11 +1089,11 @@ class Connection(ConnectionHandlers):
def _on_disconnected(self):
''' called when a disconnect request has completed successfully'''
self.disconnect(on_purpose=True)
self.dispatch('STATUS', 'offline')
self.disconnect()
def get_status(self):
return STATUS_LIST[self.connected]
return gajim.SHOW_LIST[self.connected]