Mercurial > libervia-backend
comparison src/core/sat_main.py @ 916:1a759096ccbd
core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 21 Mar 2014 16:27:09 +0100 |
parents | 1a3ba959f0ab |
children | a9401694d2dc |
comparison
equal
deleted
inserted
replaced
915:6f96ee4d8cc0 | 916:1a759096ccbd |
---|---|
217 self.plugins[import_name].is_handler = True | 217 self.plugins[import_name].is_handler = True |
218 else: | 218 else: |
219 self.plugins[import_name].is_handler = False | 219 self.plugins[import_name].is_handler = False |
220 #TODO: test xmppclient presence and register handler parent | 220 #TODO: test xmppclient presence and register handler parent |
221 | 221 |
222 def connect(self, profile_key='@NONE@'): | 222 def connect(self, profile_key=C.PROF_KEY_NONE): |
223 """Connect to jabber server""" | 223 """Connect to jabber server""" |
224 self.asyncConnect(profile_key) | 224 self.asyncConnect(profile_key) |
225 | 225 |
226 def asyncConnect(self, profile_key='@NONE@'): | 226 def asyncConnect(self, profile_key=C.PROF_KEY_NONE): |
227 """Connect to jabber server with asynchronous reply | 227 """Connect to jabber server with asynchronous reply |
228 @param profile_key: %(doc_profile)s | 228 @param profile_key: %(doc_profile)s |
229 """ | 229 """ |
230 | 230 |
231 profile = self.memory.getProfileName(profile_key) | 231 profile = self.memory.getProfileName(profile_key) |
390 profile = self.memory.getProfileName(profile_key) | 390 profile = self.memory.getProfileName(profile_key) |
391 if not profile: | 391 if not profile: |
392 return None | 392 return None |
393 return self.profiles[profile].getHostJid() | 393 return self.profiles[profile].getHostJid() |
394 | 394 |
395 def registerNewAccount(self, login, password, email, server, port=5222, id_=None, profile_key='@NONE@'): | 395 def registerNewAccount(self, login, password, email, server, port=5222, id_=None, profile_key=C.PROF_KEY_NONE): |
396 """Connect to a server and create a new account using in-band registration""" | 396 """Connect to a server and create a new account using in-band registration""" |
397 profile = self.memory.getProfileName(profile_key) | 397 profile = self.memory.getProfileName(profile_key) |
398 assert(profile) | 398 assert(profile) |
399 | 399 |
400 next_id = id_ or self.get_next_id() # the id is used to send server's answer | 400 next_id = id_ or self.get_next_id() # the id is used to send server's answer |
467 for conf_id in client._waiting_conf: | 467 for conf_id in client._waiting_conf: |
468 conf_type, data = client._waiting_conf[conf_id][:2] | 468 conf_type, data = client._waiting_conf[conf_id][:2] |
469 ret.append((conf_id, conf_type, data)) | 469 ret.append((conf_id, conf_type, data)) |
470 return ret | 470 return ret |
471 | 471 |
472 def _sendMessage(self, to_s, msg, subject=None, mess_type='auto', extra={}, profile_key='@NONE@'): | 472 def _sendMessage(self, to_s, msg, subject=None, mess_type='auto', extra={}, profile_key=C.PROF_KEY_NONE): |
473 to_jid = jid.JID(to_s) | 473 to_jid = jid.JID(to_s) |
474 #XXX: we need to use the dictionary comprehension because D-Bus return its own types, and pickle can't manage them. TODO: Need to find a better way | 474 #XXX: we need to use the dictionary comprehension because D-Bus return its own types, and pickle can't manage them. TODO: Need to find a better way |
475 return self.sendMessage(to_jid, msg, subject, mess_type, {unicode(key): unicode(value) for key, value in extra.items()}, profile_key=profile_key) | 475 return self.sendMessage(to_jid, msg, subject, mess_type, {unicode(key): unicode(value) for key, value in extra.items()}, profile_key=profile_key) |
476 | 476 |
477 def sendMessage(self, to_jid, msg, subject=None, mess_type='auto', extra={}, no_trigger=False, profile_key='@NONE@'): | 477 def sendMessage(self, to_jid, msg, subject=None, mess_type='auto', extra={}, no_trigger=False, profile_key=C.PROF_KEY_NONE): |
478 #FIXME: check validity of recipient | 478 #FIXME: check validity of recipient |
479 profile = self.memory.getProfileName(profile_key) | 479 profile = self.memory.getProfileName(profile_key) |
480 assert(profile) | 480 assert(profile) |
481 client = self.profiles[profile] | 481 client = self.profiles[profile] |
482 current_jid = client.jid | 482 current_jid = client.jid |
572 mess_type=mess_data["type"], | 572 mess_type=mess_data["type"], |
573 to_jid=mess_data['xml']['to'], | 573 to_jid=mess_data['xml']['to'], |
574 extra=mess_data['extra'], | 574 extra=mess_data['extra'], |
575 profile=profile) | 575 profile=profile) |
576 | 576 |
577 def _setPresence(self, to="", show="", priority=0, statuses=None, profile_key='@NONE@'): | 577 def _setPresence(self, to="", show="", priority=0, statuses=None, profile_key=C.PROF_KEY_NONE): |
578 return self.setPresence(jid.JID(to) if to else None, show, priority, statuses, profile_key) | 578 return self.setPresence(jid.JID(to) if to else None, show, priority, statuses, profile_key) |
579 | 579 |
580 def setPresence(self, to_jid=None, show="", priority=0, statuses=None, profile_key='@NONE@'): | 580 def setPresence(self, to_jid=None, show="", priority=0, statuses=None, profile_key=C.PROF_KEY_NONE): |
581 """Send our presence information""" | 581 """Send our presence information""" |
582 if statuses is None: | 582 if statuses is None: |
583 statuses = {} | 583 statuses = {} |
584 profile = self.memory.getProfileName(profile_key) | 584 profile = self.memory.getProfileName(profile_key) |
585 assert(profile) | 585 assert(profile) |
864 """ Remove a previously registered callback | 864 """ Remove a previously registered callback |
865 @param callback_id: id returned by [registerCallback] """ | 865 @param callback_id: id returned by [registerCallback] """ |
866 debug("Removing callback [%s]" % callback_id) | 866 debug("Removing callback [%s]" % callback_id) |
867 del self._cb_map[callback_id] | 867 del self._cb_map[callback_id] |
868 | 868 |
869 def launchCallback(self, callback_id, data=None, profile_key="@NONE@"): | 869 def launchCallback(self, callback_id, data=None, profile_key=C.PROF_KEY_NONE): |
870 """Launch a specific callback | 870 """Launch a specific callback |
871 @param callback_id: id of the action (callback) to launch | 871 @param callback_id: id of the action (callback) to launch |
872 @param data: optional data | 872 @param data: optional data |
873 @profile_key: %(doc_profile_key)s | 873 @profile_key: %(doc_profile_key)s |
874 @return: a deferred which fire a dict where key can be: | 874 @return: a deferred which fire a dict where key can be: |