more usage of NEC to handle messages
[gajim.git] / src / features_window.py
blob33de37e2fe1b8e38196ab7b5b3826819654da356
1 # -*- coding:utf-8 -*-
2 ## src/features_window.py
3 ##
4 ## Copyright (C) 2007 Jean-Marie Traissard <jim AT lapin.org>
5 ## Julien Pivotto <roidelapluie AT gmail.com>
6 ## Stefan Bethge <stefan AT lanpartei.de>
7 ## Stephan Erb <steve-e AT h3c.de>
8 ## Copyright (C) 2007-2010 Yann Leboulanger <asterix AT lagaule.org>
9 ## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org>
11 ## This file is part of Gajim.
13 ## Gajim is free software; you can redistribute it and/or modify
14 ## it under the terms of the GNU General Public License as published
15 ## by the Free Software Foundation; version 3 only.
17 ## Gajim is distributed in the hope that it will be useful,
18 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ## GNU General Public License for more details.
22 ## You should have received a copy of the GNU General Public License
23 ## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
26 import os
27 import sys
28 import gtk
29 import gtkgui_helpers
31 from common import gajim
32 from common import helpers
33 from common import kwalletbinding
34 from common.i18n import Q_
36 class FeaturesWindow:
37 """
38 Class for features window
39 """
41 def __init__(self):
42 self.xml = gtkgui_helpers.get_gtk_builder('features_window.ui')
43 self.window = self.xml.get_object('features_window')
44 treeview = self.xml.get_object('features_treeview')
45 self.desc_label = self.xml.get_object('feature_desc_label')
47 # {name: (available_function, unix_text, windows_text)}
48 self.features = {
49 _('SSL certificat validation'): (self.pyopenssl_available,
50 _('A library used to validate server certificates to ensure a secure connection.'),
51 _('Requires python-pyopenssl.'),
52 _('Requires python-pyopenssl.')),
53 _('Bonjour / Zeroconf'): (self.zeroconf_available,
54 _('Serverless chatting with autodetected clients in a local network.'),
55 _('Requires python-avahi.'),
56 _('Requires pybonjour (http://o2s.csail.mit.edu/o2s-wiki/pybonjour).')),
57 _('Command line'): (self.dbus_available,
58 _('A script to control Gajim via commandline.'),
59 _('Requires python-dbus.'),
60 _('Feature not available under Windows.')),
61 _('OpenGPG message encryption'): (self.gpg_available,
62 _('Encrypting chat messages with gpg keys.'),
63 _('Requires gpg and python-gnupg (http://code.google.com/p/python-gnupg/).'),
64 _('Requires gpg.exe in PATH.')),
65 _('Network-manager'): (self.network_manager_available,
66 _('Autodetection of network status.'),
67 _('Requires gnome-network-manager and python-dbus.'),
68 _('Feature not available under Windows.')),
69 _('Session Management'): (self.session_management_available,
70 _('Gajim session is stored on logout and restored on login.'),
71 _('Requires python-gnome2.'),
72 _('Feature not available under Windows.')),
73 _('Password encryption'): (self.some_keyring_available,
74 _('Passwords can be stored securely and not just in plaintext.'),
75 _('Requires gnome-keyring and python-gnome2-desktop, or kwalletcli.'),
76 _('Feature not available under Windows.')),
77 _('SRV'): (self.srv_available,
78 _('Ability to connect to servers which are using SRV records.'),
79 _('Requires dnsutils.'),
80 _('Requires nslookup to use SRV records.')),
81 _('Spell Checker'): (self.speller_available,
82 _('Spellchecking of composed messages.'),
83 _('Requires libgtkspell.'),
84 _('Feature not available under Windows.')),
85 _('Notification'): (self.notification_available,
86 _('Passive popups notifying for new events.'),
87 _('Requires python-notify or instead python-dbus in conjunction with notification-daemon.'),
88 _('Feature not available under Windows.')),
89 _('Automatic status'): (self.idle_available,
90 _('Ability to measure idle time, in order to set auto status.'),
91 _('Requires libxss library.'),
92 _('Requires python2.5.')),
93 _('LaTeX'): (self.latex_available,
94 _('Transform LaTeX expressions between $$ $$.'),
95 _('Requires texlive-latex-base and (dvipng or ImageMagick). You have to set \'use_latex\' to True in the Advanced Configuration Editor.'),
96 _('Requires texlive-latex-base and (dvipng or ImageMagick) (All is in MikTeX). You have to set \'use_latex\' to True in the Advanced Configuration Editor.')),
97 _('End to End message encryption'): (self.pycrypto_available,
98 _('Encrypting chat messages.'),
99 _('Requires python-crypto.'),
100 _('Requires python-crypto.')),
101 _('RST Generator'): (self.docutils_available,
102 _('Generate XHTML output from RST code (see http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html).'),
103 _('Requires python-docutils.'),
104 _('Requires python-docutils.')),
105 _('Audio / Video'): (self.farsight_available,
106 _('Ability to start audio and video chat.'),
107 _('Requires python-farsight.'),
108 _('Feature not available under Windows.')),
111 # name, supported
112 self.model = gtk.ListStore(str, bool)
113 treeview.set_model(self.model)
115 col = gtk.TreeViewColumn(Q_('?features:Available'))
116 treeview.append_column(col)
117 cell = gtk.CellRendererToggle()
118 cell.set_property('radio', True)
119 col.pack_start(cell)
120 col.set_attributes(cell, active = 1)
122 col = gtk.TreeViewColumn(_('Feature'))
123 treeview.append_column(col)
124 cell = gtk.CellRendererText()
125 col.pack_start(cell, expand = True)
126 col.add_attribute(cell, 'text', 0)
128 # Fill model
129 for feature in self.features:
130 func = self.features[feature][0]
131 rep = func()
132 self.model.append([feature, rep])
134 self.model.set_sort_column_id(0, gtk.SORT_ASCENDING)
136 self.xml.connect_signals(self)
137 self.window.show_all()
138 self.xml.get_object('close_button').grab_focus()
140 def on_close_button_clicked(self, widget):
141 self.window.destroy()
143 def on_features_treeview_cursor_changed(self, widget):
144 selection = widget.get_selection()
145 if not selection:
146 return
147 rows = selection.get_selected_rows()[1]
148 if not rows:
149 return
150 path = rows[0]
151 feature = self.model[path][0].decode('utf-8')
152 text = self.features[feature][1] + '\n'
153 if os.name == 'nt':
154 text = text + self.features[feature][3]
155 else:
156 text = text + self.features[feature][2]
157 self.desc_label.set_text(text)
159 def pyopenssl_available(self):
160 try:
161 import OpenSSL.SSL
162 import OpenSSL.crypto
163 except Exception:
164 return False
165 return True
167 def zeroconf_available(self):
168 try:
169 import avahi
170 except Exception:
171 try:
172 import pybonjour
173 except Exception:
174 return False
175 return True
177 def dbus_available(self):
178 if os.name == 'nt':
179 return False
180 from common import dbus_support
181 return dbus_support.supported
183 def gpg_available(self):
184 return gajim.HAVE_GPG
186 def network_manager_available(self):
187 if os.name == 'nt':
188 return False
189 import network_manager_listener
190 return network_manager_listener.supported
192 def session_management_available(self):
193 if os.name == 'nt':
194 return False
195 try:
196 import gnome.ui
197 except Exception:
198 return False
199 return True
201 def some_keyring_available(self):
202 if os.name == 'nt':
203 return False
204 if kwalletbinding.kwallet_available():
205 return True
206 try:
207 import gnomekeyring
208 except Exception:
209 return False
210 return True
212 def srv_available(self):
213 if os.name == 'nt':
214 return True
215 return helpers.is_in_path('nslookup')
217 def speller_available(self):
218 if os.name == 'nt':
219 return False
220 try:
221 import gtkspell
222 except ImportError:
223 return False
224 return True
226 def notification_available(self):
227 if os.name == 'nt':
228 return False
229 from common import dbus_support
230 if self.dbus_available() and dbus_support.get_notifications_interface():
231 return True
232 try:
233 import pynotify
234 except Exception:
235 return False
236 return True
238 def idle_available(self):
239 from common import sleepy
240 return sleepy.SUPPORTED
242 def latex_available(self):
243 from common import latex
244 return latex.check_for_latex_support()
246 def pycrypto_available(self):
247 return gajim.HAVE_PYCRYPTO
249 def docutils_available(self):
250 try:
251 import docutils
252 except Exception:
253 return False
254 return True
256 def farsight_available(self):
257 return gajim.HAVE_FARSIGHT