use NEC to handle muc admin events
This commit is contained in:
parent
0ca6705533
commit
d56bfb18e6
|
@ -2109,28 +2109,8 @@ ConnectionJingle, ConnectionIBBytestream):
|
|||
|
||||
def _MucAdminCB(self, con, iq_obj):
|
||||
log.debug('MucAdminCB')
|
||||
items = iq_obj.getTag('query', namespace=common.xmpp.NS_MUC_ADMIN).\
|
||||
getTags('item')
|
||||
users_dict = {}
|
||||
for item in items:
|
||||
if item.has_attr('jid') and item.has_attr('affiliation'):
|
||||
try:
|
||||
jid = helpers.parse_jid(item.getAttr('jid'))
|
||||
except common.helpers.InvalidFormat:
|
||||
log.warn('Invalid JID: %s, ignoring it' % item.getAttr('jid'))
|
||||
continue
|
||||
affiliation = item.getAttr('affiliation')
|
||||
users_dict[jid] = {'affiliation': affiliation}
|
||||
if item.has_attr('nick'):
|
||||
users_dict[jid]['nick'] = item.getAttr('nick')
|
||||
if item.has_attr('role'):
|
||||
users_dict[jid]['role'] = item.getAttr('role')
|
||||
reason = item.getTagData('reason')
|
||||
if reason:
|
||||
users_dict[jid]['reason'] = reason
|
||||
|
||||
self.dispatch('GC_AFFILIATION', (helpers.get_full_jid_from_iq(iq_obj),
|
||||
users_dict))
|
||||
gajim.nec.push_incoming_event(MucAdminReceivedEvent(None,
|
||||
conn=self, iq_obj=iq_obj))
|
||||
|
||||
def _MucErrorCB(self, con, iq_obj):
|
||||
log.debug('MucErrorCB')
|
||||
|
@ -2717,3 +2697,31 @@ class MucOwnerReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
|||
self.form_node = q
|
||||
self.dataform = dataforms.ExtendForm(node=self.form_node)
|
||||
return True
|
||||
|
||||
class MucAdminReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
||||
name = 'muc-admin-received'
|
||||
base_network_events = []
|
||||
|
||||
def generate(self):
|
||||
self.get_jid_resource()
|
||||
items = self.iq_obj.getTag('query',
|
||||
namespace=common.xmpp.NS_MUC_ADMIN).getTags('item')
|
||||
self.users_dict = {}
|
||||
for item in items:
|
||||
if item.has_attr('jid') and item.has_attr('affiliation'):
|
||||
try:
|
||||
jid = helpers.parse_jid(item.getAttr('jid'))
|
||||
except common.helpers.InvalidFormat:
|
||||
log.warn('Invalid JID: %s, ignoring it' % \
|
||||
item.getAttr('jid'))
|
||||
continue
|
||||
affiliation = item.getAttr('affiliation')
|
||||
self.users_dict[jid] = {'affiliation': affiliation}
|
||||
if item.has_attr('nick'):
|
||||
self.users_dict[jid]['nick'] = item.getAttr('nick')
|
||||
if item.has_attr('role'):
|
||||
self.users_dict[jid]['role'] = item.getAttr('role')
|
||||
reason = item.getTagData('reason')
|
||||
if reason:
|
||||
self.users_dict[jid]['reason'] = reason
|
||||
return True
|
||||
|
|
|
@ -1073,12 +1073,12 @@ class Interface:
|
|||
for change in changes:
|
||||
gc_control.print_conversation(change)
|
||||
|
||||
def handle_event_gc_affiliation(self, account, array):
|
||||
def handle_event_gc_affiliation(self, obj):
|
||||
#('GC_AFFILIATION', account, (room_jid, users_dict))
|
||||
room_jid = array[0]
|
||||
if room_jid in self.instances[account]['gc_config']:
|
||||
self.instances[account]['gc_config'][room_jid].\
|
||||
affiliation_list_received(array[1])
|
||||
account = obj.conn.name
|
||||
if obj.jid in self.instances[account]['gc_config']:
|
||||
self.instances[account]['gc_config'][obj.jid].\
|
||||
affiliation_list_received(obj.users_dict)
|
||||
|
||||
def handle_event_gc_password_required(self, account, array):
|
||||
#('GC_PASSWORD_REQUIRED', account, (room_jid, nick))
|
||||
|
@ -2107,7 +2107,6 @@ class Interface:
|
|||
'GC_SUBJECT': [self.handle_event_gc_subject],
|
||||
'GC_CONFIG_CHANGE': [self.handle_event_gc_config_change],
|
||||
'GC_INVITATION': [self.handle_event_gc_invitation],
|
||||
'GC_AFFILIATION': [self.handle_event_gc_affiliation],
|
||||
'GC_PASSWORD_REQUIRED': [self.handle_event_gc_password_required],
|
||||
'GC_ERROR': [self.handle_event_gc_error],
|
||||
'BAD_PASSPHRASE': [self.handle_event_bad_passphrase],
|
||||
|
@ -2164,6 +2163,7 @@ class Interface:
|
|||
'gmail-notify': [self.handle_event_gmail_notify],
|
||||
'http-auth-received': [self.handle_event_http_auth],
|
||||
'last-result-received': [self.handle_event_last_status_time],
|
||||
'muc-admin-received': [self.handle_event_gc_affiliation],
|
||||
'muc-owner-received': [self.handle_event_gc_config],
|
||||
'roster-info': [self.handle_event_roster_info],
|
||||
'roster-item-exchange-received': \
|
||||
|
|
Loading…
Reference in New Issue