[Florob] handle xmpp: and mailto: in a nicer way in conversations. Fixes #4245

This commit is contained in:
Yann Leboulanger 2008-11-21 11:05:11 +00:00
parent c69b4e90b6
commit f059f3948f
6 changed files with 61 additions and 11 deletions

View File

@ -1,5 +1,5 @@
AC_INIT([Gajim - A Jabber Instant Messager],
[0.12-beta1],[http://trac.gajim.org/],[gajim])
[0.12.0.1-svn],[http://trac.gajim.org/],[gajim])
AC_PREREQ([2.59])
AM_INIT_AUTOMAKE([1.8])
AC_CONFIG_HEADER(config.h)

View File

@ -264,7 +264,7 @@ class Config:
'attach_notifications_to_systray': [opt_bool, False, _('If True, notification windows from notification-daemon will be attached to systray icon.')],
'check_idle_every_foo_seconds': [opt_int, 2, _('Choose interval between 2 checks of idleness.')],
'latex_png_dpi': [opt_str, '108',_('Change the value to change the size of latex formulas displayed. The higher is larger.') ],
'uri_schemes': [opt_str, 'aaa aaas acap cap cid crid data dav dict dns fax file ftp go gopher h323 http https icap im imap info ipp iris iris.beep iris.xpc iris.xpcs iris.lwz ldap mailto mid modem msrp msrps mtqp mupdate news nfs nntp opaquelocktoken pop pres rtsp service shttp sip sips snmp soap.beep soap.beeps tag tel telnet tftp thismessage tip tv urn vemmi xmlrpc.beep xmlrpc.beeps xmpp z39.50r z39.50s about cvs daap ed2k feed fish git iax2 irc ircs ldaps magnet mms rsync ssh svn sftp smb webcal', _('Valid uri schemes. Only schemes in this list will be made accepted as "real" uri.')],
'uri_schemes': [opt_str, 'aaa aaas acap cap cid crid data dav dict dns fax file ftp go gopher h323 http https icap im imap info ipp iris iris.beep iris.xpc iris.xpcs iris.lwz ldap mid modem msrp msrps mtqp mupdate news nfs nntp opaquelocktoken pop pres rtsp service shttp sip sips snmp soap.beep soap.beeps tag tel telnet tftp thismessage tip tv urn vemmi xmlrpc.beep xmlrpc.beeps z39.50r z39.50s about cvs daap ed2k feed fish git iax2 irc ircs ldaps magnet mms rsync ssh svn sftp smb webcal', _('Valid uri schemes. Only schemes in this list will be accepted as "real" uri. (mailto and xmpp are handled seperately)')],
}
__options_per_key = {

View File

@ -28,7 +28,7 @@ import re
docdir = '../'
datadir = '../'
version = '0.12-beta1'
version = '0.12.0.1-svn'
import sys, os.path
for base in ('.', 'common'):

View File

@ -454,7 +454,7 @@ def launch_browser_mailer(kind, uri):
pass
else:
if kind == 'mail' and not uri.startswith('mailto:'):
if kind in ('mail', 'sth_at_sth') and not uri.startswith('mailto:'):
uri = 'mailto:' + uri
if gajim.config.get('openwith') == 'gnome-open':
@ -469,7 +469,7 @@ def launch_browser_mailer(kind, uri):
elif gajim.config.get('openwith') == 'custom':
if kind == 'url':
command = gajim.config.get('custombrowser')
if kind == 'mail':
if kind in ('mail', 'sth_at_sth'):
command = gajim.config.get('custommailapp')
if command == '': # if no app is configured
return

View File

@ -185,6 +185,8 @@ class OptionsParser:
self.update_config_to_01143()
if old < [0, 11, 4, 4] and new >= [0, 11, 4, 4]:
self.update_config_to_01144()
if old < [0, 12, 0, 1] and new >= [0, 12, 0, 1]:
self.update_config_to_01201()
gajim.logger.init_vars()
gajim.config.set('version', new_version)
@ -599,4 +601,11 @@ class OptionsParser:
con.close()
gajim.config.set('version', '0.11.4.4')
def update_config_to_01201(self):
if 'uri_schemes' in self.old_values:
new_value = self.old_values['uri_schemes'].replace(' mailto', '').\
replace(' xmpp', '')
gajim.config.set('uri_schemes', new_values)
gajim.config.set('version', '0.12.0.1')
# vim: se ts=3:

View File

@ -267,6 +267,18 @@ class ConversationTextview:
id = self.tagMail.connect('event', self.hyperlink_handler, 'mail')
self.handlers[id] = self.tagMail
self.tagXMPP = buffer.create_tag('xmpp')
self.tagXMPP.set_property('foreground', color)
self.tagXMPP.set_property('underline', pango.UNDERLINE_SINGLE)
id = self.tagXMPP.connect('event', self.hyperlink_handler, 'xmpp')
self.handlers[id] = self.tagXMPP
self.tagSthAtSth = buffer.create_tag('sth_at_sth')
self.tagSthAtSth.set_property('foreground', color)
self.tagSthAtSth.set_property('underline', pango.UNDERLINE_SINGLE)
id = self.tagSthAtSth.connect('event', self.hyperlink_handler, 'sth_at_sth')
self.handlers[id] = self.tagSthAtSth
tag = buffer.create_tag('bold')
tag.set_property('weight', pango.WEIGHT_BOLD)
@ -610,7 +622,8 @@ class ConversationTextview:
over_line = False
xep0184_warning = False
for tag in tags:
if tag in (tag_table.lookup('url'), tag_table.lookup('mail')):
if tag in (tag_table.lookup('url'), tag_table.lookup('mail'), \
tag_table.lookup('xmpp'), tag_table.lookup('sth_at_sth')):
self.tv.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor(
gtk.gdk.Cursor(gtk.gdk.HAND2))
self.change_cursor = tag
@ -755,7 +768,7 @@ class ConversationTextview:
if tags: # we clicked on sth special (it can be status message too)
for tag in tags:
tag_name = tag.get_property('name')
if tag_name in ('url', 'mail'):
if tag_name in ('url', 'mail', 'xmpp', 'sth_at_sth'):
return True # we block normal context menu
# we check if sth was selected and if it was we assign
@ -828,6 +841,8 @@ class ConversationTextview:
join_group_chat_menuitem.set_image(muc_icon)
text = text.lower()
if text.startswith('xmpp:'):
text = text[5:]
id = childs[2].connect('activate', self.on_copy_link_activate, text)
self.handlers[id] = childs[2]
id = childs[3].connect('activate', self.on_open_link_activate, kind,
@ -855,6 +870,16 @@ class ConversationTextview:
else:
childs[7].hide() # hide add to roster menuitem
if kind == 'xmpp':
childs[2].hide() # copy mail address
childs[3].hide() # open mail composer
childs[4].hide() # jid section separator
elif kind == 'mail':
childs[4].hide() # jid section separator
childs[5].hide() # start chat
childs[6].hide() # join group chat
childs[7].hide() # add to roster
childs[0].hide() # copy link location
childs[1].hide() # open link in browser
@ -876,7 +901,18 @@ class ConversationTextview:
self.make_link_menu(event, kind, word)
else:
# we launch the correct application
helpers.launch_browser_mailer(kind, word)
if kind == 'xmpp':
word = word[5:]
if '?' in word:
(jid, action) = word.split('?')
if action == 'join':
self.on_join_group_chat_menuitem_activate(None, jid)
else:
self.on_start_chat_activate(None, jid)
else:
self.on_start_chat_activate(None, word)
else:
helpers.launch_browser_mailer(kind, word)
def html_hyperlink_handler(self, texttag, widget, event, iter_, kind, href):
if event.type == gtk.gdk.BUTTON_PRESS:
@ -1040,11 +1076,16 @@ class ConversationTextview:
text_is_valid_uri:
tags.append('url')
use_other_tags = False
elif special_text.startswith('mailto:') or \
gajim.interface.sth_at_sth_dot_sth_re.match(special_text):
# it's a mail
elif special_text.startswith('mailto:'):
tags.append('mail')
use_other_tags = False
elif special_text.startswith('xmpp:'):
tags.append('xmpp')
use_other_tags = False
elif gajim.interface.sth_at_sth_dot_sth_re.match(special_text):
# it's a JID or mail
tags.append('sth_at_sth')
use_other_tags = False
elif special_text.startswith('*'): # it's a bold text
tags.append('bold')
if special_text[1] == '/' and special_text[-2] == '/' and\