fixed show vcard info
This commit is contained in:
parent
d90801de18
commit
c99093c203
|
@ -38,10 +38,11 @@ _ = i18n._
|
||||||
i18n.init()
|
i18n.init()
|
||||||
|
|
||||||
def send_error(error_message):
|
def send_error(error_message):
|
||||||
''' Writes error message to stderr and exits '''
|
''' Writes error message to stderr and exits '''
|
||||||
sys.stderr.write(error_message + '\n')
|
sys.stderr.write(error_message + '\n')
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import dbus
|
import dbus
|
||||||
except:
|
except:
|
||||||
|
@ -155,7 +156,6 @@ using this account'), False)
|
||||||
sys.argv[1] not in self.commands.keys(): # no args or bad args
|
sys.argv[1] not in self.commands.keys(): # no args or bad args
|
||||||
send_error(self.compose_help())
|
send_error(self.compose_help())
|
||||||
self.command = sys.argv[1]
|
self.command = sys.argv[1]
|
||||||
|
|
||||||
if self.command == 'help':
|
if self.command == 'help':
|
||||||
if self.argv_len == 3:
|
if self.argv_len == 3:
|
||||||
print self.help_on_command(sys.argv[2])
|
print self.help_on_command(sys.argv[2])
|
||||||
|
@ -172,7 +172,7 @@ using this account'), False)
|
||||||
try:
|
try:
|
||||||
id = self.sbus.add_signal_receiver(self.show_vcard_info,
|
id = self.sbus.add_signal_receiver(self.show_vcard_info,
|
||||||
'VcardInfo', INTERFACE, SERVICE, OBJ_PATH)
|
'VcardInfo', INTERFACE, SERVICE, OBJ_PATH)
|
||||||
except:
|
except Exception, e:
|
||||||
send_error(_('Service not available'))
|
send_error(_('Service not available'))
|
||||||
|
|
||||||
res = self.call_remote_method()
|
res = self.call_remote_method()
|
||||||
|
@ -222,7 +222,7 @@ Please specify account for sending the message.') % sys.argv[2])
|
||||||
self.service = self.sbus.get_service(SERVICE)
|
self.service = self.sbus.get_service(SERVICE)
|
||||||
interface = self.service.get_object(OBJ_PATH, INTERFACE)
|
interface = self.service.get_object(OBJ_PATH, INTERFACE)
|
||||||
else:
|
else:
|
||||||
send_error(_('Unknown D-Bus version: %s') % _version)
|
send_error(_('Unknown D-Bus version: %s') % _version[1])
|
||||||
|
|
||||||
# get the function asked
|
# get the function asked
|
||||||
self.method = interface.__getattr__(self.command)
|
self.method = interface.__getattr__(self.command)
|
||||||
|
@ -296,6 +296,8 @@ Please specify account for sending the message.') % sys.argv[2])
|
||||||
res += self.print_info(level+1, items)
|
res += self.print_info(level+1, items)
|
||||||
if res != '':
|
if res != '':
|
||||||
ret_str += '\t' + res
|
ret_str += '\t' + res
|
||||||
|
elif type(val) == dict:
|
||||||
|
ret_str += self.print_info(level+1, val)
|
||||||
ret_str = '%s(%s)\n' % (spacing, ret_str[1:])
|
ret_str = '%s(%s)\n' % (spacing, ret_str[1:])
|
||||||
elif isinstance(prop_dict, dict):
|
elif isinstance(prop_dict, dict):
|
||||||
for key in prop_dict.keys():
|
for key in prop_dict.keys():
|
||||||
|
@ -315,8 +317,6 @@ Please specify account for sending the message.') % sys.argv[2])
|
||||||
res = self.print_info(level+1, val)
|
res = self.print_info(level+1, val)
|
||||||
if res != '':
|
if res != '':
|
||||||
ret_str += '%s%s: \n%s' % (spacing, key, res)
|
ret_str += '%s%s: \n%s' % (spacing, key, res)
|
||||||
else:
|
|
||||||
self.send_warning(_('Unknown type %s ') % type(val))
|
|
||||||
return ret_str
|
return ret_str
|
||||||
|
|
||||||
def unrepr(self, serialized_data):
|
def unrepr(self, serialized_data):
|
||||||
|
@ -441,13 +441,12 @@ Please specify account for sending the message.') % sys.argv[2])
|
||||||
else:
|
else:
|
||||||
if args and len(args) >= 5:
|
if args and len(args) >= 5:
|
||||||
props_dict = self.unrepr(args[4].get_args_list()[0])
|
props_dict = self.unrepr(args[4].get_args_list()[0])
|
||||||
|
|
||||||
if props_dict:
|
if props_dict:
|
||||||
print self.print_info(0,props_dict[0])
|
print self.print_info(0,props_dict[0])
|
||||||
# remove_signal_receiver is broken in lower versions (< 0.35),
|
# remove_signal_receiver is broken in lower versions (< 0.35),
|
||||||
# so we leave the leak - nothing can be done
|
# so we leave the leak - nothing can be done
|
||||||
if _version[1] >= 41:
|
if _version[1] >= 41:
|
||||||
self.sbus.remove_signal_receiver(show_vcard_info, 'VcardInfo',
|
self.sbus.remove_signal_receiver(self.show_vcard_info, 'VcardInfo',
|
||||||
INTERFACE, SERVICE, OBJ_PATH)
|
INTERFACE, SERVICE, OBJ_PATH)
|
||||||
|
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
|
@ -463,7 +462,7 @@ Type "%s help %s" for more info') % (args[argv_len][0], BASENAME, self.command))
|
||||||
|
|
||||||
def gtk_quit(self):
|
def gtk_quit(self):
|
||||||
if _version[1] >= 41:
|
if _version[1] >= 41:
|
||||||
self.sbus.remove_signal_receiver(show_vcard_info, 'VcardInfo',
|
self.sbus.remove_signal_receiver(self.show_vcard_info, 'VcardInfo',
|
||||||
INTERFACE, SERVICE, OBJ_PATH)
|
INTERFACE, SERVICE, OBJ_PATH)
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
|
|
||||||
|
@ -488,5 +487,6 @@ Type "%s help %s" for more info') % (args[argv_len][0], BASENAME, self.command))
|
||||||
send_error(_('Service not available'))
|
send_error(_('Service not available'))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
GajimRemote()
|
GajimRemote()
|
||||||
|
|
15
src/gajim.py
15
src/gajim.py
|
@ -159,7 +159,6 @@ class Interface:
|
||||||
gajim.connections[account].build_http_auth_answer(data[2], answer)
|
gajim.connections[account].build_http_auth_answer(data[2], answer)
|
||||||
|
|
||||||
def handle_event_error_answer(self, account, array):
|
def handle_event_error_answer(self, account, array):
|
||||||
#('ERROR_ANSWER', account, (id, jid_from. errmsg, errcode))
|
|
||||||
id, jid_from, errmsg, errcode = array
|
id, jid_from, errmsg, errcode = array
|
||||||
if unicode(errcode) in ['403', '406'] and id:
|
if unicode(errcode) in ['403', '406'] and id:
|
||||||
# show the error dialog
|
# show the error dialog
|
||||||
|
@ -186,10 +185,10 @@ class Interface:
|
||||||
(jid_from, file_props))
|
(jid_from, file_props))
|
||||||
conn.disconnect_transfer(file_props)
|
conn.disconnect_transfer(file_props)
|
||||||
return
|
return
|
||||||
|
#('ERROR_ANSWER', account, (id, jid_from. errmsg, errcode))
|
||||||
if jid_from in self.windows[account]['gc']:
|
if jid_from in self.windows[account]['gc']:
|
||||||
self.windows[account]['gc'][jid_from].print_conversation(
|
self.windows[account]['gc'][jid_from].print_conversation(
|
||||||
_('Error %s: %s') % (array[2], array[1]), jid_from)
|
'Error %s: %s' % (array[2], array[1]), jid_from)
|
||||||
|
|
||||||
def handle_event_con_type(self, account, con_type):
|
def handle_event_con_type(self, account, con_type):
|
||||||
# ('CON_TYPE', account, con_type) which can be 'ssl', 'tls', 'tcp'
|
# ('CON_TYPE', account, con_type) which can be 'ssl', 'tls', 'tcp'
|
||||||
|
@ -200,8 +199,6 @@ class Interface:
|
||||||
|
|
||||||
def handle_event_status(self, account, status): # OUR status
|
def handle_event_status(self, account, status): # OUR status
|
||||||
#('STATUS', account, status)
|
#('STATUS', account, status)
|
||||||
if status == 'connecting':
|
|
||||||
self.roster.set_connecting_state(account)
|
|
||||||
if status != 'offline':
|
if status != 'offline':
|
||||||
gobject.timeout_add(30000, self.allow_notif, account)
|
gobject.timeout_add(30000, self.allow_notif, account)
|
||||||
else:
|
else:
|
||||||
|
@ -384,10 +381,9 @@ class Interface:
|
||||||
not gajim.contacts[account].has_key(jid):
|
not gajim.contacts[account].has_key(jid):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Handle chat states
|
|
||||||
contact = gajim.get_first_contact_instance_from_jid(account, jid)
|
|
||||||
if self.windows[account]['chats'].has_key(jid):
|
if self.windows[account]['chats'].has_key(jid):
|
||||||
chat_win = self.windows[account]['chats'][jid]
|
chat_win = self.windows[account]['chats'][jid]
|
||||||
|
contact = gajim.get_first_contact_instance_from_jid(account, jid)
|
||||||
if chatstate is not None: # he sent us reply, so he supports jep85
|
if chatstate is not None: # he sent us reply, so he supports jep85
|
||||||
if contact.chatstate == 'ask': # we were jep85 disco?
|
if contact.chatstate == 'ask': # we were jep85 disco?
|
||||||
contact.chatstate = 'active' # no more
|
contact.chatstate = 'active' # no more
|
||||||
|
@ -396,10 +392,6 @@ class Interface:
|
||||||
else:
|
else:
|
||||||
# got no valid jep85 answer, peer does not support it
|
# got no valid jep85 answer, peer does not support it
|
||||||
contact.chatstate = False
|
contact.chatstate = False
|
||||||
else:
|
|
||||||
# Brand new message, incoming.
|
|
||||||
if chatstate == 'active':
|
|
||||||
contact.chatstate = chatstate
|
|
||||||
|
|
||||||
if not array[1]: #empty message text
|
if not array[1]: #empty message text
|
||||||
return
|
return
|
||||||
|
@ -618,6 +610,7 @@ class Interface:
|
||||||
array['resource']]
|
array['resource']]
|
||||||
if win:
|
if win:
|
||||||
win.set_avatar(array)
|
win.set_avatar(array)
|
||||||
|
self.remote.raise_signal('VcardInfo', (account, array))
|
||||||
|
|
||||||
def handle_event_os_info(self, account, array):
|
def handle_event_os_info(self, account, array):
|
||||||
win = None
|
win = None
|
||||||
|
|
|
@ -278,8 +278,9 @@ class SignalObject(DbusPrototype):
|
||||||
You have to register the 'VcardInfo' signal to get the real vcard. '''
|
You have to register the 'VcardInfo' signal to get the real vcard. '''
|
||||||
if self.disabled:
|
if self.disabled:
|
||||||
return
|
return
|
||||||
|
|
||||||
[jid] = self._get_real_arguments(args, 1)
|
[jid] = self._get_real_arguments(args, 1)
|
||||||
|
if not isinstance(jid, unicode):
|
||||||
|
jid = unicode(jid)
|
||||||
if not jid:
|
if not jid:
|
||||||
# FIXME: raise exception for missing argument (0.3+)
|
# FIXME: raise exception for missing argument (0.3+)
|
||||||
return None
|
return None
|
||||||
|
@ -287,10 +288,8 @@ class SignalObject(DbusPrototype):
|
||||||
accounts = gajim.contacts.keys()
|
accounts = gajim.contacts.keys()
|
||||||
|
|
||||||
for account in accounts:
|
for account in accounts:
|
||||||
if gajim.contacts[account].has_key(jid):
|
if gajim.contacts[account].__contains__(jid):
|
||||||
self.vcard_account = account
|
self.vcard_account = account
|
||||||
gajim.connections[account].register_handler('VCARD',
|
|
||||||
self._receive_vcard)
|
|
||||||
gajim.connections[account].request_vcard(jid)
|
gajim.connections[account].request_vcard(jid)
|
||||||
break
|
break
|
||||||
return None
|
return None
|
||||||
|
@ -302,7 +301,10 @@ class SignalObject(DbusPrototype):
|
||||||
if gajim.contacts:
|
if gajim.contacts:
|
||||||
result = gajim.contacts.keys()
|
result = gajim.contacts.keys()
|
||||||
if result and len(result) > 0:
|
if result and len(result) > 0:
|
||||||
return result
|
result_array = []
|
||||||
|
for account in result:
|
||||||
|
result_array.append(account.encode('utf-8'))
|
||||||
|
return result_array
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -324,7 +326,6 @@ class SignalObject(DbusPrototype):
|
||||||
result.append(item)
|
result.append(item)
|
||||||
else:
|
else:
|
||||||
# 'for_account: is not recognised:',
|
# 'for_account: is not recognised:',
|
||||||
# FIXME: there can be a return status for this [0.3+]
|
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
for account in gajim.contacts:
|
for account in gajim.contacts:
|
||||||
|
@ -358,19 +359,6 @@ class SignalObject(DbusPrototype):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _receive_vcard(self,account, array):
|
|
||||||
if self.vcard_account:
|
|
||||||
gajim.connections[self.vcard_account].unregister_handler('VCARD',
|
|
||||||
self._receive_vcard)
|
|
||||||
self.unregistered_vcard = None
|
|
||||||
if self.disabled:
|
|
||||||
return
|
|
||||||
if _version[1] >=30:
|
|
||||||
self.VcardInfo(repr(array))
|
|
||||||
else:
|
|
||||||
self.emit_signal(INTERFACE, 'VcardInfo',
|
|
||||||
repr(array))
|
|
||||||
|
|
||||||
def _get_real_arguments(self, args, desired_length):
|
def _get_real_arguments(self, args, desired_length):
|
||||||
# supresses the first 'message' argument, which is set in dbus 0.23
|
# supresses the first 'message' argument, which is set in dbus 0.23
|
||||||
if _version[1] == 20:
|
if _version[1] == 20:
|
||||||
|
|
Loading…
Reference in New Issue