Ejemplo n.º 1
0
 def __init__(self):
     if 'JID' in settings.SERVER:
         self.jid = jid.JID(settings.SERVER['JID'])
     else:
         self.jid = jid.JID('{user}@{host}'.format(user=settings.SERVER['USERNAME'],
                                                   host=settings.SERVER['HOST']))
     self.auth = client.XMPPAuthenticator(self.jid, settings.SERVER['PASSWORD'])
     XmlStreamFactoryMixin.__init__(self, self.auth)
     self.client = Client(factory=self)
Ejemplo n.º 2
0
    def connect(self, secret, host=None):
        a = twisted_client.XMPPAuthenticator(self.myjid, secret)
        factory = MyXmlStreamFactory(a)
        factory.maxRetries = 2

        if host is None:
            host = self.myjid.host
        connector = XMPPClientConnector(reactor, host, factory)

        return self.generic_connect(factory, connector)
Ejemplo n.º 3
0
    def __init__(self, id, request, deferred):
        self.id = id
        self.request = request
        self.deferred = deferred

        jabber_id = request.args.get('username', [request.getUser()])[0]
        self.jabber_id = jid.JID(jabber_id)
        secret = request.args.get('password', [request.getPassword()])[0]
        a = client.XMPPAuthenticator(self.jabber_id, secret)
        xmlstream.XmlStreamFactory.__init__(self, a)

        self.addBootstrap('//event/stream/authd', self.authenticated)
Ejemplo n.º 4
0
    def __init__(self, jid, password, settings_provider):
        a = client.XMPPAuthenticator(jid, password)
        xmlstream.XmlStreamFactory.__init__(self, a)
        self.addBootstrap(xmlstream.STREAM_CONNECTED_EVENT,
                          self.clientConnected)

        self.jid = jid
        self.reconnect = True
        self.connection_failed = False
        self.connection_lost = False
        self.cb_connection_error = None
        self.settings_provider = settings_provider
        self.port = self.settings_provider.retrieve_preferred_port()
Ejemplo n.º 5
0
    def __init__(self, jid, password):
        self.authenticator = client.XMPPAuthenticator(jid, password)
        XmlStreamFactoryMixin.__init__(self, self.authenticator)

        deferred = defer.Deferred()
        self.deferred = deferred

        self.addBootstrap(xmlstream.INIT_FAILED_EVENT, deferred.errback)

        class ConnectionInitializedHandler(XMPPHandler):
            def connectionInitialized(self):
                deferred.callback(None)

        self.streamManager = StreamManager(self)
        self.addHandler(ConnectionInitializedHandler())
Ejemplo n.º 6
0
    def start(self):
        jid = JID(str(self._jid) + "@gcm.googleapis.com")

        secret = _CONF.get(None, 'fcm_server_secret')
        if secret == None:
            _log.error("No secret specified")
            return
        authenticator = client.XMPPAuthenticator(jid, secret)

        callbacks = {'connected': [CalvinCB(self._connected)]}
        xmppfactory = CalvinXMLStreamFactory(authenticator, callbacks, self,
                                             self._uri)
        xmppfactory.addBootstrap(xmlstream.STREAM_AUTHD_EVENT,
                                 self.authenticated)

        self.protocol_factory = xmppfactory

        cf = ssl.ClientContextFactory()
        reactor.connectSSL("gcm-preprod.googleapis.com", 5236, xmppfactory, cf)
Ejemplo n.º 7
0
 def __init__(self, jid, password):
     authenticator = client.XMPPAuthenticator(jid, password)
     generic.DeferredXmlStreamFactory.__init__(self, authenticator)
     self.streamManager = StreamManager(self)