def __init__(self, jid, password, configuration, name, auto_register=True, auto_reconnect=True): """ The constructor of the class. @type jid: string @param jid: the jid of the client. @type password: string @param password: the password of the JID account. @type configuration: Config object @param configuration: the configuration object @type name: string @param name: the name of the entity @type auto_register: Boolean @param auto_register: if rTue, entity will try to create a XMPP account if needed @type auto_reconnect: Boolean @param auto_reconnect: if True, entity will try to reconnect if disconnected """ self.name = name self.xmppstatus = None self.xmppstatusshow = None self.xmppclient = None self.vCard = None self.password = password self.jid = jid self.resource = self.jid.getResource() self.roster = None self.roster_retreived = False self.configuration = configuration self.auto_register = auto_register self.auto_reconnect = auto_reconnect self.messages_registrar = [] self.isAuth = False self.loop_status = ARCHIPEL_XMPP_LOOP_OFF self.pubsubserver = self.configuration.get("GLOBAL", "xmpp_pubsub_server") self.log = TNArchipelLogger(self) self.pubSubNodeEvent = None self.pubSubNodeLog = None self.entity_type = "not-defined" self.permission_center = None self.plugins = []; if isinstance(self, TNHookableEntity): TNHookableEntity.__init__(self, self.log) if isinstance(self, TNAvatarControllableEntity): TNAvatarControllableEntity.__init__(self, configuration, self.permission_center, self.xmppclient, self.log) if isinstance(self, TNTaggableEntity): TNTaggableEntity.__init__(self, self.pubsubserver, self.jid, self.xmppclient, self.permission_center, self.log) if isinstance(self, TNRosterQueryableEntity): TNRosterQueryableEntity.__init__(self, configuration, self.permission_center, self.xmppclient, self.log) if self.name == "auto": self.name = self.resource if isinstance(self, TNHookableEntity): self.create_hook("HOOK_ARCHIPELENTITY_XMPP_CONNECTED") self.create_hook("HOOK_ARCHIPELENTITY_XMPP_DISCONNECTED") self.create_hook("HOOK_ARCHIPELENTITY_XMPP_AUTHENTICATED") self.create_hook("HOOK_ARCHIPELENTITY_XMPP_LOOP_STARTED") self.create_hook("HOOK_ARCHIPELENTITY_XMPP_LOOP_STOPPED") ## recover/create pubsub after connection self.register_hook("HOOK_ARCHIPELENTITY_XMPP_AUTHENTICATED", self.recover_pubsubs) self.log.info("jid defined as %s" % (str(self.jid))) ip_conf = self.configuration.get("GLOBAL", "machine_ip") if ip_conf == "auto": self.ipaddr = socket.gethostbyname(socket.gethostname()) else: self.ipaddr = ip_conf
def init_vocabulary(self): """ initialize the vocabulary """ if isinstance(self, TNRosterQueryableEntity): TNRosterQueryableEntity.init_vocabulary(self)