JEP70 support (thx nicfit !)
This commit is contained in:
parent
fbd2633695
commit
6f6d5c0dcc
|
@ -154,6 +154,7 @@ class Config:
|
|||
# try for 2 minutes before giving up (aka. timeout after those seconds)
|
||||
'try_connecting_for_foo_secs': [ opt_int, 60 ],
|
||||
'max_stanza_per_sec': [ opt_int, 5],
|
||||
'http_auth': [opt_str, 'ask'], # yes, no, ask
|
||||
}, {}),
|
||||
'statusmsg': ({
|
||||
'message': [ opt_str, '' ],
|
||||
|
|
|
@ -127,7 +127,7 @@ class Connection:
|
|||
'GC_SUBJECT': [], 'GC_CONFIG': [], 'BAD_PASSPHRASE': [],
|
||||
'ROSTER_INFO': [], 'ERROR_ANSWER': [], 'BOOKMARKS': [], 'CON_TYPE': [],
|
||||
'FILE_REQUEST': [], 'FILE_RCV_COMPLETED': [], 'FILE_PROGRESS': [],
|
||||
'STANZA_ARRIVED': []
|
||||
'STANZA_ARRIVED': [], 'HTTP_AUTH': []
|
||||
}
|
||||
self.name = name
|
||||
self.connected = 0 # offline
|
||||
|
@ -859,7 +859,25 @@ class Connection:
|
|||
#Preferences data
|
||||
#http://www.jabber.org/jeps/jep-0049.html
|
||||
#TODO: implement this
|
||||
pass
|
||||
pass
|
||||
|
||||
def build_http_auth_answer(self, iq_obj, answer):
|
||||
if answer == 'yes':
|
||||
iq = iq_obj.buildReply('result')
|
||||
elif answer == 'no':
|
||||
iq = iq_obj.buildReply('error')
|
||||
iq.setError('not-authorized', 401)
|
||||
self.to_be_sent.append(iq)
|
||||
|
||||
def _HttpAuthCB(self, con, iq_obj):
|
||||
opt = gajim.config.get_per('accounts', self.name, 'http_auth')
|
||||
if opt in ['yes', 'no']:
|
||||
self.build_http_auth_answer(iq_obj, opt)
|
||||
else:
|
||||
method = iq_obj.getTagAttr('confirm', 'method')
|
||||
url = iq_obj.getTagAttr('confirm', 'url')
|
||||
self.dispatch('HTTP_AUTH', (method, url, iq_obj));
|
||||
raise common.xmpp.NodeProcessed
|
||||
|
||||
def _ErrorCB(self, con, iq_obj):
|
||||
errmsg = iq_obj.getError()
|
||||
|
@ -989,6 +1007,8 @@ class Connection:
|
|||
common.xmpp.NS_ROSTER)
|
||||
con.RegisterHandler('iq', self._PrivateCB, 'result',
|
||||
common.xmpp.NS_PRIVATE)
|
||||
con.RegisterHandler('iq', self._HttpAuthCB, 'get',
|
||||
common.xmpp.NS_HTTP_AUTH)
|
||||
con.RegisterHandler('iq', self._ErrorCB, 'error')
|
||||
con.RegisterHandler('iq', self._StanzaArrivedCB)
|
||||
con.RegisterHandler('presence', self._StanzaArrivedCB)
|
||||
|
|
|
@ -70,8 +70,9 @@ NS_SI ='http://jabber.org/protocol/si' # JEP-0096
|
|||
NS_FILE ='http://jabber.org/protocol/si/profile/file-transfer' # JEP-0096
|
||||
NS_FEATURE ='http://jabber.org/protocol/feature-neg'
|
||||
NS_BYTESTREAM ='http://jabber.org/protocol/bytestreams' # JEP-0065
|
||||
NS_DISCO ='http://jabber.org/protocol/disco#info' # JEP-0095
|
||||
NS_STREAM ='http://affinix.com/jabber/stream'
|
||||
NS_DISCO ='http://jabber.org/protocol/disco#info' # JEP-0095
|
||||
NS_STREAM ='http://affinix.com/jabber/stream'
|
||||
NS_HTTP_AUTH ='http://jabber.org/protocol/http-auth' # JEP-0070
|
||||
|
||||
xmpp_stream_error_conditions="""
|
||||
bad-format -- -- -- The entity has sent XML that cannot be processed.
|
||||
|
|
10
src/gajim.py
10
src/gajim.py
|
@ -197,6 +197,16 @@ class Interface:
|
|||
#('INFORMATION', account, (title_text, section_text))
|
||||
dialogs.InformationDialog(data[0], data[1]).get_response()
|
||||
|
||||
def handle_event_http_auth(self, account, data):
|
||||
#('HTTP_AUTH', account, (method, url, iq_obj))
|
||||
dialog = dialogs.ConfirmationDialog(_('HTTP (%s) Authorization for %s') \
|
||||
% (array[0], array[1]), _('Do you accept this request?'))
|
||||
if dialog.get_response() == gtk.RESPONSE_OK:
|
||||
answer = 'yes'
|
||||
else:
|
||||
answer = 'no'
|
||||
gajim.connections[account].build_http_auth_answer(data[2], answer)
|
||||
|
||||
def handle_event_error_answer(self, account, array):
|
||||
id, jid_from, errmsg, errcode = array
|
||||
if str(errcode) in ['403', '406'] and id:
|
||||
|
|
Loading…
Reference in New Issue