rerequest / reauthorize

This commit is contained in:
Yann Leboulanger 2003-11-02 21:39:40 +00:00
parent ebf82529d5
commit b1abaa2a56
3 changed files with 364 additions and 31 deletions

View File

@ -104,6 +104,8 @@ class GajimCore:
self.con.requestRoster()
roster = self.con.getRoster().getRaw()
if not roster :
roster = {}
self.hub.sendPlugin('ROSTER', roster)
self.con.sendInitPresence()
self.connected = 1
@ -121,13 +123,13 @@ class GajimCore:
return
#('STATUS', status)
elif ev[0] == 'STATUS':
if (ev[1] != 'offline') and (self.connected == 0):
self.connect()
elif (ev[1] == 'offline') and (self.connected == 1):
self.con.disconnect()
self.connected = 0
else:
print ev
return 1
p = common.jabber.Presence()
p.setShow(ev[1])
self.con.send(p)
@ -140,6 +142,9 @@ class GajimCore:
elif ev[0] == 'SUB':
log.debug('subscription request for %s' % ev[1][0])
self.con.send(common.jabber.Presence(ev[1][0], 'subscribe'))
#('REQ', jid)
elif ev[0] == 'AUTH':
self.con.send(common.jabber.Presence(ev[1], 'subscribed'))
#('UNSUB', jid)
elif ev[0] == 'UNSUB':
delauth = self.cfgParser.Core_delauth

View File

@ -40,7 +40,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image60">
<widget class="GtkImage" id="image72">
<property name="visible">True</property>
<property name="stock">gtk-convert</property>
<property name="icon_size">1</property>
@ -62,7 +62,7 @@
<signal name="activate" handler="on_preferences_activate" last_modification_time="Wed, 22 Oct 2003 21:18:29 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image61">
<widget class="GtkImage" id="image73">
<property name="visible">True</property>
<property name="stock">gtk-preferences</property>
<property name="icon_size">1</property>
@ -83,7 +83,7 @@
<signal name="activate" handler="on_accounts_activate" last_modification_time="Wed, 22 Oct 2003 21:18:21 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image62">
<widget class="GtkImage" id="image74">
<property name="visible">True</property>
<property name="stock">gtk-select-color</property>
<property name="icon_size">1</property>
@ -110,7 +110,7 @@
<signal name="activate" handler="on_add_activate" last_modification_time="Sun, 26 Oct 2003 17:26:34 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image63">
<widget class="GtkImage" id="image75">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
@ -137,7 +137,7 @@
<signal name="activate" handler="on_about_activate" last_modification_time="Fri, 03 Oct 2003 12:49:50 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image64">
<widget class="GtkImage" id="image76">
<property name="visible">True</property>
<property name="stock">gtk-help</property>
<property name="icon_size">1</property>
@ -159,7 +159,7 @@
<accelerator key="Q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image65">
<widget class="GtkImage" id="image77">
<property name="visible">True</property>
<property name="stock">gtk-quit</property>
<property name="icon_size">1</property>
@ -201,7 +201,7 @@
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="reorderable">True</property>
<property name="enable_search">True</property>
<signal name="button_press_event" handler="on_treeview_event" last_modification_time="Tue, 30 Sep 2003 09:11:17 GMT"/>
<signal name="row_activated" handler="on_row_activated" last_modification_time="Sun, 12 Oct 2003 18:11:52 GMT"/>
@ -1390,7 +1390,7 @@ David Ferlier (david@yazzy.org)</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes">I would like to add you to my contact list, please</property>
<property name="text" translatable="yes">I would like to add you to my contact list, please.</property>
</widget>
</child>
</widget>
@ -1555,7 +1555,7 @@ David Ferlier (david@yazzy.org)</property>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="padding">5</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
@ -1587,4 +1587,300 @@ David Ferlier (david@yazzy.org)</property>
</child>
</widget>
<widget class="GtkWindow" id="Sub_req">
<property name="visible">True</property>
<property name="title" translatable="yes">Subscription request</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">400</property>
<property name="default_height">200</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<child>
<widget class="GtkVBox" id="vbox10">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="label" translatable="yes">Subscription request from</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">10</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow8">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">False</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator5">
<property name="visible">True</property>
</widget>
<packing>
<property name="padding">5</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox3">
<property name="border_width">10</property>
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">20</property>
<child>
<widget class="GtkButton" id="button_close">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<child>
<widget class="GtkAlignment" id="alignment11">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<child>
<widget class="GtkHBox" id="hbox15">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image69">
<property name="visible">True</property>
<property name="stock">gtk-close</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label24">
<property name="visible">True</property>
<property name="label" translatable="yes">_Close</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkButton" id="button_deny">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<child>
<widget class="GtkAlignment" id="alignment12">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<child>
<widget class="GtkHBox" id="hbox16">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image70">
<property name="visible">True</property>
<property name="stock">gtk-cancel</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label25">
<property name="visible">True</property>
<property name="label" translatable="yes">_Deny</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkButton" id="button_auth">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<child>
<widget class="GtkAlignment" id="alignment13">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<child>
<widget class="GtkHBox" id="hbox17">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image71">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label26">
<property name="visible">True</property>
<property name="label" translatable="yes">_Authorize</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -64,7 +64,7 @@ class add:
start_iter = buf.get_start_iter()
end_iter = buf.get_end_iter()
txt = buf.get_text(start_iter, end_iter, 0)
self.r.req_sub(who, txt)
self.r.req_sub(self, who, txt)
self.delete_event(self)
def __init__(self, roster):
@ -223,23 +223,43 @@ class roster:
self.l_contact[u.jid]['iter'].append(iterU)
else:
if show == 'offline' and not self.showOffline:
self.treestore.remove(iter)
for i in self.l_contact[jid]['iter']:
self.treestore.remove(i)
else:
for i in self.l_contact[jid]['iter']:
self.treestore.set_value(i, 0, self.pixbufs[show])
u.show = show
u.status = status
def mk_menu_c(self, event, iter):
jid = self.treestore.get_value(iter, 2)
path = self.treestore.get_path(iter)
self.menu_c = gtk.Menu()
item = gtk.MenuItem("Start chat")
self.menu_c.append(item)
item.connect("activate", self.on_row_activated, path)
item = gtk.MenuItem("Rename")
self.menu_c.append(item)
# item.connect("activate", self.on_rename, iter)
item = gtk.MenuItem()
self.menu_c.append(item)
item = gtk.MenuItem("Subscription")
self.menu_c.append(item)
menu_sub = gtk.Menu()
item.set_submenu(menu_sub)
item = gtk.MenuItem("Resend authorization to")
menu_sub.append(item)
item.connect("activate", self.authorize, jid)
item = gtk.MenuItem("Rerequest authorization from")
menu_sub.append(item)
item.connect("activate", self.req_sub, jid, 'I would like to add you to my contact list, please.')
item = gtk.MenuItem()
self.menu_c.append(item)
item = gtk.MenuItem("Remove")
self.menu_c.append(item)
item.connect("activate", self.on_req_usub, iter)
# item = gtk.MenuItem("user2")
# self.menu_c.append(item)
self.menu_c.popup(None, None, None, event.button, event.time)
self.menu_c.show_all()
@ -254,6 +274,27 @@ class roster:
self.menu_c.popup(None, None, None, event.button, event.time)
self.menu_c.show_all()
def authorize(self, widget, jid):
self.queueOUT.put(('AUTH', jid))
def rename(self, widget, jid, name)
u = self.r.l_contact[jid]['user']
u.name = name
for i in self.r.l_contact[jid]['iter']:
self.r.treestore.set_value(i, 1, name)
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
iterU = self.treestore.append(self.l_group['general'], (self.pixbufs['requested'], jid, jid))
self.l_contact[jid] = {'user':user1, 'iter':[iterU]}
def on_treeview_event(self, widget, event):
if (event.button == 3) & (event.type == gtk.gdk.BUTTON_PRESS):
try:
@ -269,15 +310,6 @@ class roster:
return gtk.TRUE
return gtk.FALSE
def req_sub(self, 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
iterU = self.treestore.append(self.l_group['general'], (self.pixbufs['requested'], jid, jid))
self.l_contact[jid] = {'user':user1, 'iter':[iterU]}
def on_req_usub(self, widget, iter):
window_confirm = confirm(self, iter)
@ -297,7 +329,7 @@ class roster:
self.queueOUT.put(('QUIT',''))
gtk.mainquit()
def on_row_activated(self, widget, path, col):
def on_row_activated(self, widget, path, col=0):
iter = self.treestore.get_iter(path)
jid = self.treestore.get_value(iter, 2)
if self.tab_messages.has_key(jid):