2008-08-15 19:31:51 +02:00
|
|
|
# -*- coding:utf-8 -*-
|
2008-08-15 05:20:23 +02:00
|
|
|
## src/features_window.py
|
2007-06-27 11:37:31 +02:00
|
|
|
##
|
2008-08-15 05:20:23 +02:00
|
|
|
## Copyright (C) 2007 Jean-Marie Traissard <jim AT lapin.org>
|
|
|
|
## Julien Pivotto <roidelapluie AT gmail.com>
|
|
|
|
## Stefan Bethge <stefan AT lanpartei.de>
|
|
|
|
## Stephan Erb <steve-e AT h3c.de>
|
|
|
|
## Copyright (C) 2007-2008 Yann Leboulanger <asterix AT lagaule.org>
|
|
|
|
## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org>
|
2007-06-27 11:37:31 +02:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## This file is part of Gajim.
|
|
|
|
##
|
|
|
|
## Gajim is free software; you can redistribute it and/or modify
|
2007-06-27 11:37:31 +02:00
|
|
|
## it under the terms of the GNU General Public License as published
|
2007-10-22 13:13:13 +02:00
|
|
|
## by the Free Software Foundation; version 3 only.
|
2007-06-27 11:37:31 +02:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## Gajim is distributed in the hope that it will be useful,
|
2007-06-27 11:37:31 +02:00
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2008-08-15 05:20:23 +02:00
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2007-06-27 11:37:31 +02:00
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## You should have received a copy of the GNU General Public License
|
2008-08-15 05:20:23 +02:00
|
|
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
2007-10-22 13:13:13 +02:00
|
|
|
##
|
2007-06-27 11:37:31 +02:00
|
|
|
|
|
|
|
import os
|
2007-11-14 20:47:52 +01:00
|
|
|
import sys
|
2007-06-27 11:37:31 +02:00
|
|
|
import gtk
|
|
|
|
import gtkgui_helpers
|
|
|
|
|
|
|
|
from common import gajim
|
|
|
|
from common import helpers
|
|
|
|
|
2007-07-20 01:36:25 +02:00
|
|
|
import random
|
|
|
|
from tempfile import gettempdir
|
|
|
|
from subprocess import Popen
|
|
|
|
|
2007-06-27 11:37:31 +02:00
|
|
|
class FeaturesWindow:
|
|
|
|
'''Class for features window'''
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.xml = gtkgui_helpers.get_glade('features_window.glade')
|
|
|
|
self.window = self.xml.get_widget('features_window')
|
|
|
|
treeview = self.xml.get_widget('features_treeview')
|
2007-06-27 14:38:00 +02:00
|
|
|
self.desc_label = self.xml.get_widget('feature_desc_label')
|
2007-06-27 11:37:31 +02:00
|
|
|
|
|
|
|
# {name: (available_function, unix_text, windows_text)}
|
|
|
|
self.features = {
|
|
|
|
_('PyOpenSSL'): (self.pyopenssl_available,
|
2007-07-07 01:51:41 +02:00
|
|
|
_('A library used to validate server certificates to ensure a secure connection.'),
|
|
|
|
_('Requires python-pyopenssl.'),
|
|
|
|
_('Requires python-pyopenssl.')),
|
2007-06-27 11:37:31 +02:00
|
|
|
_('Bonjour / Zeroconf'): (self.zeroconf_available,
|
2007-07-07 01:51:41 +02:00
|
|
|
_('Serverless chatting with autodetected clients in a local network.'),
|
2007-08-07 00:24:48 +02:00
|
|
|
_('Requires python-avahi.'),
|
2007-08-06 23:46:51 +02:00
|
|
|
_('Requires pybonjour (http://o2s.csail.mit.edu/o2s-wiki/pybonjour).')),
|
2007-07-07 01:51:41 +02:00
|
|
|
_('gajim-remote'): (self.dbus_available,
|
2008-08-25 12:06:22 +02:00
|
|
|
_('A script to control Gajim via commandline.'),
|
2007-07-07 01:51:41 +02:00
|
|
|
_('Requires python-dbus.'),
|
|
|
|
_('Feature not available under Windows.')),
|
2007-06-27 11:37:31 +02:00
|
|
|
_('OpenGPG'): (self.gpg_available,
|
2007-07-07 01:51:41 +02:00
|
|
|
_('Encrypting chatmessages with gpg keys.'),
|
|
|
|
_('Requires gpg and python-GnuPGInterface.'),
|
|
|
|
_('Feature not available under Windows.')),
|
|
|
|
_('network-manager'): (self.network_manager_available,
|
|
|
|
_('Autodetection of network status.'),
|
|
|
|
_('Requires gnome-network-manager and python-dbus.'),
|
|
|
|
_('Feature not available under Windows.')),
|
2007-06-27 11:37:31 +02:00
|
|
|
_('Session Management'): (self.session_management_available,
|
2007-07-07 01:51:41 +02:00
|
|
|
_('Gajim session is stored on logout and restored on login.'),
|
|
|
|
_('Requires python-gnome2.'),
|
|
|
|
_('Feature not available under Windows.')),
|
|
|
|
_('gnome-keyring'): (self.gnome_keyring_available,
|
|
|
|
_('Passwords can be stored securely and not just in plaintext.'),
|
|
|
|
_('Requires gnome-keyring and python-gnome2-desktop.'),
|
|
|
|
_('Feature not available under Windows.')),
|
2007-06-27 11:37:31 +02:00
|
|
|
_('SRV'): (self.srv_available,
|
2007-09-10 16:33:32 +02:00
|
|
|
_('Ability to connect to servers which are using SRV records.'),
|
2007-07-07 01:51:41 +02:00
|
|
|
_('Requires dnsutils.'),
|
|
|
|
_('Requires nslookup to use SRV records.')),
|
2007-06-27 11:37:31 +02:00
|
|
|
_('Spell Checker'): (self.speller_available,
|
2007-07-07 01:51:41 +02:00
|
|
|
_('Spellchecking of composed messages.'),
|
|
|
|
_('Requires python-gnome2-extras or compilation of gtkspell module from Gajim sources.'),
|
|
|
|
_('Feature not available under Windows.')),
|
2007-06-27 11:37:31 +02:00
|
|
|
_('Notification-daemon'): (self.notification_available,
|
2007-07-07 01:51:41 +02:00
|
|
|
_('Passive popups notifying for new events.'),
|
|
|
|
_('Requires python-notify or instead python-dbus in conjunction with notification-daemon.'),
|
|
|
|
_('Feature not available under Windows.')),
|
2007-06-27 11:37:31 +02:00
|
|
|
_('Trayicon'): (self.trayicon_available,
|
2007-07-07 01:51:41 +02:00
|
|
|
_('A icon in systemtray reflecting the current presence.'),
|
2008-01-06 21:50:30 +01:00
|
|
|
_('Requires python-gnome2-extras or compiled trayicon module from Gajim sources.'),
|
2007-07-07 01:51:41 +02:00
|
|
|
_('Requires PyGTK >= 2.10.')),
|
2007-06-27 11:37:31 +02:00
|
|
|
_('Idle'): (self.idle_available,
|
2007-07-07 01:51:41 +02:00
|
|
|
_('Ability to measure idle time, in order to set auto status.'),
|
|
|
|
_('Requires compilation of the idle module from Gajim sources.'),
|
|
|
|
_('Requires compilation of the idle module from Gajim sources.')),
|
2007-07-20 01:36:25 +02:00
|
|
|
_('LaTeX'): (self.latex_available,
|
2008-01-06 21:48:25 +01:00
|
|
|
_('Transform LaTeX expressions between $$ $$.'),
|
2008-09-27 18:46:18 +02:00
|
|
|
_('Requires texlive-latex-base and dvipng. You have to set \'use_latex\' to True in the Advanced Configuration Editor.'),
|
2008-10-08 19:48:05 +02:00
|
|
|
_('Requires texlive-latex-base and dvipng (All is in MikTeX). You have to set \'use_latex\' to True in the Advanced Configuration Editor.')),
|
2008-05-10 13:47:04 +02:00
|
|
|
_('End to End Encryption'): (self.pycrypto_available,
|
2007-08-27 15:46:25 +02:00
|
|
|
_('Encrypting chatmessages.'),
|
|
|
|
_('Requires python-crypto.'),
|
|
|
|
_('Requires python-crypto.')),
|
2007-09-02 11:34:21 +02:00
|
|
|
_('RST Generator'): (self.docutils_available,
|
|
|
|
_('Generate XHTML output from RST code (see http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html).'),
|
|
|
|
_('Requires python-docutils.'),
|
|
|
|
_('Requires python-docutils.')),
|
2007-10-09 19:48:22 +02:00
|
|
|
_('libsexy'): (self.pysexy_available,
|
2007-12-02 15:30:59 +01:00
|
|
|
_('Ability to have clickable URLs in chat and groupchat window banners.'),
|
2007-10-09 19:48:22 +02:00
|
|
|
_('Requires python-sexy.'),
|
|
|
|
_('Requires python-sexy.')),
|
2007-06-27 11:37:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# name, supported
|
|
|
|
self.model = gtk.ListStore(str, bool)
|
|
|
|
treeview.set_model(self.model)
|
|
|
|
|
|
|
|
col = gtk.TreeViewColumn(_('Available'))
|
|
|
|
treeview.append_column(col)
|
|
|
|
cell = gtk.CellRendererToggle()
|
2007-07-07 01:51:41 +02:00
|
|
|
cell.set_property('radio', True)
|
2007-06-27 11:37:31 +02:00
|
|
|
col.pack_start(cell)
|
|
|
|
col.set_attributes(cell, active = 1)
|
|
|
|
|
2007-07-07 01:51:41 +02:00
|
|
|
col = gtk.TreeViewColumn(_('Feature'))
|
|
|
|
treeview.append_column(col)
|
|
|
|
cell = gtk.CellRendererText()
|
|
|
|
col.pack_start(cell, expand = True)
|
|
|
|
col.add_attribute(cell, 'text', 0)
|
|
|
|
|
2007-06-27 11:37:31 +02:00
|
|
|
# Fill model
|
|
|
|
for feature in self.features:
|
|
|
|
func = self.features[feature][0]
|
|
|
|
rep = func()
|
|
|
|
self.model.append([feature, rep])
|
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
self.window.show_all()
|
|
|
|
self.xml.get_widget('close_button').grab_focus()
|
|
|
|
|
|
|
|
def on_close_button_clicked(self, widget):
|
|
|
|
self.window.destroy()
|
|
|
|
|
2007-06-28 12:42:24 +02:00
|
|
|
def on_features_treeview_cursor_changed(self, widget):
|
|
|
|
selection = widget.get_selection()
|
2007-12-24 11:24:52 +01:00
|
|
|
if not selection:
|
|
|
|
return
|
2008-02-05 10:34:56 +01:00
|
|
|
rows = selection.get_selected_rows()[1]
|
|
|
|
if not rows:
|
|
|
|
return
|
|
|
|
path = rows[0]
|
2007-11-24 20:00:10 +01:00
|
|
|
feature = self.model[path][0].decode('utf-8')
|
2007-07-07 01:51:41 +02:00
|
|
|
text = self.features[feature][1] + '\n'
|
2007-06-27 11:37:31 +02:00
|
|
|
if os.name == 'nt':
|
2007-07-07 01:51:41 +02:00
|
|
|
text = text + self.features[feature][3]
|
2007-06-27 11:37:31 +02:00
|
|
|
else:
|
2007-07-07 01:51:41 +02:00
|
|
|
text = text + self.features[feature][2]
|
2007-06-27 14:38:00 +02:00
|
|
|
self.desc_label.set_text(text)
|
2007-06-27 11:37:31 +02:00
|
|
|
|
|
|
|
def pyopenssl_available(self):
|
|
|
|
try:
|
|
|
|
import OpenSSL.SSL
|
|
|
|
import OpenSSL.crypto
|
2008-10-11 11:37:13 +02:00
|
|
|
except Exception:
|
2007-06-27 11:37:31 +02:00
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
def zeroconf_available(self):
|
|
|
|
try:
|
|
|
|
import avahi
|
2008-10-11 11:37:13 +02:00
|
|
|
except Exception:
|
2007-08-06 23:46:51 +02:00
|
|
|
try:
|
|
|
|
import pybonjour
|
2008-10-11 11:37:13 +02:00
|
|
|
except Exception:
|
2007-08-06 23:46:51 +02:00
|
|
|
return False
|
2007-06-27 11:37:31 +02:00
|
|
|
return True
|
|
|
|
|
|
|
|
def dbus_available(self):
|
|
|
|
if os.name == 'nt':
|
|
|
|
return False
|
|
|
|
from common import dbus_support
|
|
|
|
return dbus_support.supported
|
|
|
|
|
|
|
|
def gpg_available(self):
|
|
|
|
if os.name == 'nt':
|
|
|
|
return False
|
2007-12-28 19:49:28 +01:00
|
|
|
return gajim.HAVE_GPG
|
2007-06-27 11:37:31 +02:00
|
|
|
|
|
|
|
def network_manager_available(self):
|
|
|
|
if os.name == 'nt':
|
|
|
|
return False
|
|
|
|
import network_manager_listener
|
|
|
|
return network_manager_listener.supported
|
|
|
|
|
|
|
|
def session_management_available(self):
|
|
|
|
if os.name == 'nt':
|
|
|
|
return False
|
|
|
|
try:
|
|
|
|
import gnome.ui
|
2008-10-11 11:37:13 +02:00
|
|
|
except Exception:
|
2007-06-27 11:37:31 +02:00
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
def gnome_keyring_available(self):
|
|
|
|
if os.name == 'nt':
|
|
|
|
return False
|
|
|
|
try:
|
|
|
|
import gnomekeyring
|
2008-10-11 11:37:13 +02:00
|
|
|
except Exception:
|
2007-06-27 11:37:31 +02:00
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
def srv_available(self):
|
|
|
|
return helpers.is_in_path('nslookup')
|
|
|
|
|
|
|
|
def speller_available(self):
|
|
|
|
if os.name == 'nt':
|
|
|
|
return False
|
|
|
|
try:
|
|
|
|
import gtkspell
|
2008-10-11 11:37:13 +02:00
|
|
|
except Exception:
|
2007-06-27 11:37:31 +02:00
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
def notification_available(self):
|
|
|
|
if os.name == 'nt':
|
|
|
|
return False
|
2007-11-14 20:47:52 +01:00
|
|
|
elif sys.platform == 'darwin':
|
|
|
|
try:
|
|
|
|
import osx.growler
|
2008-10-11 11:37:13 +02:00
|
|
|
except Exception:
|
2007-11-14 20:47:52 +01:00
|
|
|
return False
|
|
|
|
return True
|
2007-06-27 11:49:58 +02:00
|
|
|
from common import dbus_support
|
2007-06-27 11:37:31 +02:00
|
|
|
if self.dbus_available() and dbus_support.get_notifications_interface():
|
|
|
|
return True
|
|
|
|
try:
|
|
|
|
import pynotify
|
2008-10-11 11:37:13 +02:00
|
|
|
except Exception:
|
2007-06-27 11:37:31 +02:00
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
def trayicon_available(self):
|
|
|
|
if os.name == 'nt' and gtk.pygtk_version >= (2, 10, 0) and \
|
|
|
|
gtk.gtk_version >= (2, 10, 0):
|
|
|
|
return True
|
|
|
|
try:
|
|
|
|
import systray
|
2008-10-11 11:37:13 +02:00
|
|
|
except Exception:
|
2007-06-27 11:37:31 +02:00
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
def idle_available(self):
|
|
|
|
from common import sleepy
|
|
|
|
return sleepy.SUPPORTED
|
2007-07-20 01:36:25 +02:00
|
|
|
|
|
|
|
def latex_available(self):
|
|
|
|
'''check is latex is available and if it can create a picture.'''
|
|
|
|
|
|
|
|
exitcode = 0
|
|
|
|
random.seed()
|
|
|
|
tmpfile = os.path.join(gettempdir(), "gajimtex_" + \
|
|
|
|
random.randint(0,100).__str__())
|
|
|
|
|
|
|
|
# build latex string
|
|
|
|
texstr = '\\documentclass[12pt]{article}\\usepackage[dvips]{graphicx}'
|
|
|
|
texstr += '\\usepackage{amsmath}\\usepackage{amssymb}\\pagestyle{empty}'
|
|
|
|
texstr += '\\begin{document}\\begin{large}\\begin{gather*}test'
|
|
|
|
texstr += '\\end{gather*}\\end{large}\\end{document}'
|
|
|
|
|
2008-12-03 18:16:04 +01:00
|
|
|
file_ = open(os.path.join(tmpfile + ".tex"), "w+")
|
|
|
|
file_.write(texstr)
|
|
|
|
file_.flush()
|
|
|
|
file_.close()
|
2007-07-20 02:05:38 +02:00
|
|
|
try:
|
2008-11-24 10:38:28 +01:00
|
|
|
if os.name == 'nt':
|
|
|
|
# CREATE_NO_WINDOW
|
|
|
|
p = Popen(['latex', '--interaction=nonstopmode', tmpfile + '.tex'],
|
|
|
|
creationflags=0x08000000, cwd=gettempdir())
|
|
|
|
else:
|
|
|
|
p = Popen(['latex', '--interaction=nonstopmode', tmpfile + '.tex'],
|
|
|
|
cwd=gettempdir())
|
2007-07-20 01:36:25 +02:00
|
|
|
exitcode = p.wait()
|
2008-10-11 11:37:13 +02:00
|
|
|
except Exception:
|
2007-07-20 02:05:38 +02:00
|
|
|
exitcode = 1
|
2007-07-20 01:36:25 +02:00
|
|
|
if exitcode == 0:
|
2007-07-20 02:05:38 +02:00
|
|
|
try:
|
2008-11-24 10:38:28 +01:00
|
|
|
if os.name == 'nt':
|
|
|
|
# CREATE_NO_WINDOW
|
|
|
|
p = Popen(['dvipng', '-bg', 'white', '-T', 'tight',
|
2008-11-24 10:43:06 +01:00
|
|
|
tmpfile + '.dvi', '-o', tmpfile + '.png'],
|
|
|
|
creationflags=0x08000000, cwd=gettempdir())
|
2008-11-24 10:38:28 +01:00
|
|
|
else:
|
|
|
|
p = Popen(['dvipng', '-bg', 'white', '-T', 'tight',
|
|
|
|
tmpfile + '.dvi', '-o', tmpfile + '.png'], cwd=gettempdir())
|
2007-07-20 02:05:38 +02:00
|
|
|
exitcode = p.wait()
|
2008-10-11 11:37:13 +02:00
|
|
|
except Exception:
|
2007-07-20 02:05:38 +02:00
|
|
|
exitcode = 1
|
2008-09-27 18:46:18 +02:00
|
|
|
extensions = ['.tex', '.log', '.aux', '.dvi', '.png']
|
2007-07-20 01:36:25 +02:00
|
|
|
for ext in extensions:
|
|
|
|
try:
|
|
|
|
os.remove(tmpfile + ext)
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
if exitcode == 0:
|
|
|
|
return True
|
2007-08-06 23:46:51 +02:00
|
|
|
return False
|
2007-08-27 15:46:25 +02:00
|
|
|
|
|
|
|
def pycrypto_available(self):
|
|
|
|
return gajim.HAVE_PYCRYPTO
|
2007-09-02 11:34:21 +02:00
|
|
|
|
|
|
|
def docutils_available(self):
|
|
|
|
try:
|
|
|
|
import docutils
|
2008-10-11 11:37:13 +02:00
|
|
|
except Exception:
|
2007-09-02 11:34:21 +02:00
|
|
|
return False
|
|
|
|
return True
|
2007-10-09 19:48:22 +02:00
|
|
|
|
|
|
|
def pysexy_available(self):
|
|
|
|
return gajim.HAVE_PYSEXY
|
2008-07-29 21:49:31 +02:00
|
|
|
|
2008-08-15 05:20:23 +02:00
|
|
|
# vim: se ts=3:
|