ask authorization when a user request it
This commit is contained in:
parent
4d1bc47345
commit
4fb271ad1f
|
@ -64,7 +64,10 @@ class GajimCore:
|
|||
(prs.getFrom().getBasic(), 'offline', prs.getStatus()))
|
||||
elif type == 'subscribe':
|
||||
log.debug("subscribe request from %s" % who)
|
||||
if self.cfgParser.Core_alwaysauth == 1:
|
||||
self.con.send(common.jabber.Presence(who, 'subscribed'))
|
||||
else:
|
||||
self.hub.sendPlugin('SUBSCRIBE', who)
|
||||
elif type == 'subscribed':
|
||||
#plein de trucs a faire
|
||||
jid = prs.getFrom()
|
||||
|
@ -145,6 +148,9 @@ class GajimCore:
|
|||
#('REQ', jid)
|
||||
elif ev[0] == 'AUTH':
|
||||
self.con.send(common.jabber.Presence(ev[1], 'subscribed'))
|
||||
#('DENY', jid)
|
||||
elif ev[0] == 'DENY':
|
||||
self.con.send(common.jabber.Presence(ev[1], 'unsubscribed'))
|
||||
#('UNSUB', jid)
|
||||
elif ev[0] == 'UNSUB':
|
||||
delauth = self.cfgParser.Core_delauth
|
||||
|
@ -173,5 +179,6 @@ def start():
|
|||
gc.hub.register('gtkgui', 'NOTIFY')
|
||||
gc.hub.register('gtkgui', 'MSG')
|
||||
gc.hub.register('gtkgui', 'SUBSCRIBED')
|
||||
gc.hub.register('gtkgui', 'SUBSCRIBE')
|
||||
guiPl.load ()
|
||||
gc.mainLoop()
|
||||
|
|
|
@ -12,6 +12,7 @@ ressource = gajim
|
|||
|
||||
delauth = 1
|
||||
delroster = 1
|
||||
alwaysauth = 0
|
||||
|
||||
[GtkGui]
|
||||
|
||||
|
|
|
@ -1684,6 +1684,7 @@ David Ferlier (david@yazzy.org)</property>
|
|||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<signal name="clicked" handler="on_button_close_clicked" last_modification_time="Mon, 03 Nov 2003 19:01:49 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment11">
|
||||
|
@ -1749,6 +1750,7 @@ David Ferlier (david@yazzy.org)</property>
|
|||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<signal name="clicked" handler="on_button_deny_clicked" last_modification_time="Mon, 03 Nov 2003 19:01:54 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment12">
|
||||
|
@ -1814,6 +1816,7 @@ David Ferlier (david@yazzy.org)</property>
|
|||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<signal name="clicked" handler="on_button_auth_clicked" last_modification_time="Mon, 03 Nov 2003 19:02:02 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment13">
|
||||
|
|
|
@ -52,8 +52,6 @@ class user:
|
|||
# self.status = args[0].status
|
||||
# self.sub = args[0].sub
|
||||
else: raise TypeError, 'bad arguments'
|
||||
# self.jid = self.name + '@' + self.server + '/' + self.resource
|
||||
# self.jid = self.name + '@' + self.server
|
||||
|
||||
class add:
|
||||
def delete_event(self, widget):
|
||||
|
@ -68,9 +66,11 @@ class add:
|
|||
self.r.req_sub(self, who, txt)
|
||||
self.delete_event(self)
|
||||
|
||||
def __init__(self, roster):
|
||||
def __init__(self, roster, jid=None):
|
||||
self.r = roster
|
||||
self.xml = gtk.glade.XML('plugins/gtkgui.glade', 'Add')
|
||||
if jid:
|
||||
self.xml.get_widget('entry_who').set_text(jid)
|
||||
self.Wadd = self.xml.get_widget("Add")
|
||||
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
|
||||
self.xml.signal_connect('on_button_sub_clicked', self.on_subscribe)
|
||||
|
@ -112,6 +112,29 @@ class confirm:
|
|||
self.xml.signal_connect('on_okbutton_clicked', self.req_usub)
|
||||
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
|
||||
|
||||
class authorize:
|
||||
def delete_event(self, widget):
|
||||
self.window.destroy()
|
||||
|
||||
def auth(self, widget):
|
||||
self.r.queueOUT.put(('AUTH', self.jid))
|
||||
self.delete_event(self)
|
||||
add(self.r, self.jid)
|
||||
|
||||
def deny(self, widget):
|
||||
self.r.queueOUT.put(('DENY', self.jid))
|
||||
self.delete_event(self)
|
||||
|
||||
def __init__(self, roster, jid):
|
||||
self.xml = gtk.glade.XML('plugins/gtkgui.glade', 'Sub_req')
|
||||
self.window = self.xml.get_widget('Sub_req')
|
||||
self.r = roster
|
||||
self.jid = jid
|
||||
self.xml.get_widget('label').set_text('Subscription request from ' + self.jid)
|
||||
self.xml.signal_connect('on_button_auth_clicked', self.auth)
|
||||
self.xml.signal_connect('on_button_deny_clicked', self.deny)
|
||||
self.xml.signal_connect('on_button_close_clicked', self.delete_event)
|
||||
|
||||
class message:
|
||||
def delete_event(self, widget):
|
||||
del self.roster.tab_messages[self.user.jid]
|
||||
|
@ -288,9 +311,7 @@ class roster:
|
|||
def req_sub(self, widget, jid, txt):
|
||||
self.queueOUT.put(('SUB', (jid, txt)))
|
||||
if not self.l_contact.has_key(jid):
|
||||
#TODO: sub
|
||||
user1 = user(jid, jid, ['general'], 'requested', 'requested', 'sub')
|
||||
#TODO: ajouter un grp si necessaire
|
||||
if not self.l_group.has_key('general'):
|
||||
iterG = self.treestore.append(None, (None, 'general', 'group'))
|
||||
self.l_group['general'] = iterG
|
||||
|
@ -424,6 +445,8 @@ class plugin:
|
|||
#FIXME:message d'un inconne
|
||||
self.r.tab_messages[ev[1][0]] = message(self.r.l_contact[ev[1][0]]['user'], self.r)
|
||||
self.r.tab_messages[ev[1][0]].print_conversation(ev[1][1])
|
||||
elif ev[0] == 'SUBSCRIBE':
|
||||
authorize(self.r, ev[1])
|
||||
elif ev[0] == 'SUBSCRIBED':
|
||||
u = self.r.l_contact[ev[1]['jid']]['user']
|
||||
u.name = ev[1]['nom']
|
||||
|
|
Loading…
Reference in New Issue