2007-06-01 17:12:49 +00:00
import gtkgui_helpers
import dataforms_widget
2007-07-04 18:55:53 +00:00
import dialogs
2007-06-01 17:12:49 +00:00
from common import dataforms
2007-06-01 18:19:19 +00:00
from common import gajim
from common import xmpp
2007-06-01 17:12:49 +00:00
2007-07-02 16:53:19 +00:00
def describe_features ( features ) :
''' a human-readable description of the features that have been negotiated '''
if features [ ' logging ' ] == ' may ' :
2007-07-04 18:55:53 +00:00
return _ ( ' - messages will be logged ' )
2007-07-02 16:53:19 +00:00
elif features [ ' logging ' ] == ' mustnot ' :
2007-07-04 18:55:53 +00:00
return _ ( ' - messages will not be logged ' )
def show_sas_dialog ( jid , sas ) :
dialogs . InformationDialog ( _ ( ''' Verify the remote client ' s identity ''' ) , _ ( ''' You ' ve begun an encrypted session with %s , but it can ' t be guaranteed that you ' re talking directly to the person you think you are.
You should speak with them directly ( in person or on the phone ) and confirm that their Short Authentication String is identical to this one : % s ''' ) % (jid, sas))
2007-07-02 16:53:19 +00:00
2007-06-01 17:12:49 +00:00
class FeatureNegotiationWindow :
''' FeatureNegotiotionWindow class '''
2007-06-05 21:26:45 +00:00
def __init__ ( self , account , jid , session , form ) :
2007-06-01 17:12:49 +00:00
self . account = account
self . jid = jid
self . form = form
2007-06-05 21:26:45 +00:00
self . session = session
2007-06-01 17:12:49 +00:00
self . xml = gtkgui_helpers . get_glade ( ' data_form_window.glade ' , ' data_form_window ' )
self . window = self . xml . get_widget ( ' data_form_window ' )
config_vbox = self . xml . get_widget ( ' config_vbox ' )
dataform = dataforms . ExtendForm ( node = self . form )
self . data_form_widget = dataforms_widget . DataFormWidget ( dataform )
self . data_form_widget . show ( )
config_vbox . pack_start ( self . data_form_widget )
self . xml . signal_autoconnect ( self )
self . window . show_all ( )
2007-06-01 18:19:19 +00:00
2007-06-01 22:08:23 +00:00
def on_ok_button_clicked ( self , widget ) :
acceptance = xmpp . Message ( self . jid )
2007-06-05 21:26:45 +00:00
acceptance . setThread ( self . session . thread_id )
2007-06-01 22:08:23 +00:00
feature = acceptance . NT . feature
feature . setNamespace ( xmpp . NS_FEATURE )
form = self . data_form_widget . data_form
form . setAttr ( ' type ' , ' submit ' )
feature . addChild ( node = form )
gajim . connections [ self . account ] . send_stanza ( acceptance )
self . window . destroy ( )
2007-06-01 18:19:19 +00:00
def on_cancel_button_clicked ( self , widget ) :
# XXX determine whether to reveal presence
rejection = xmpp . Message ( self . jid )
2007-06-05 21:26:45 +00:00
rejection . setThread ( self . session . thread_id )
2007-06-01 18:19:19 +00:00
feature = rejection . NT . feature
feature . setNamespace ( xmpp . NS_FEATURE )
x = xmpp . DataForm ( typ = ' submit ' )
x . addChild ( node = xmpp . DataField ( ' FORM_TYPE ' , value = ' urn:xmpp:ssn ' ) )
x . addChild ( node = xmpp . DataField ( ' accept ' , value = ' false ' , typ = ' boolean ' ) )
feature . addChild ( node = x )
# XXX optional <body/>
gajim . connections [ self . account ] . send_stanza ( rejection )
self . window . destroy ( )