Ejemplo n.º 1
0
    def dcc_start_chat(self, nick):
        """ 
            start a dcc chat with 'nick' - i.e. open local socket,
            send appropriate ctcp message, update model
        """
        s = dccSession(dccSession.DCCSESSION_CHAT, nick)
        factory = dccFactory(self, s, dcc_chat)
        conn = Port(0, factory, backlog=1)
        conn.startListening()
        
        (prot, dcchost, dccport) = conn.getHost()

        #
        # don't trust the host reported by dcc_chat - it's unconnected,
        # so it's not clear on which interface the connection will be
        serverhost = self.irc.getHost()[1]
        self.ctcp(nick, "DCC", "CHAT chat %lu %u" % \
                             (net.inet_aton(serverhost), dccport))

        self.dccsessions.append(s) # move to factory?
        if self.queries.has_key(nick):
            target = self.queries[nick]
        else:
            target = self.viewtext
        target.announce("Starting dcc chat with %s" % nick)
Ejemplo n.º 2
0
 def port(self, portNumber, factory, interface):
     """
     Create, start, and return a new L{Port}, also tracking it so it can
     be stopped in the test tear down.
     """
     p = Port(portNumber, factory, interface=interface)
     p.startListening()
     self.ports.append(p)
     return p
Ejemplo n.º 3
0
 def test_connectionLostFailed(self):
     """
     L{Port.stopListening} returns a L{Deferred} which errbacks if
     L{Port.connectionLost} raises an exception.
     """
     port = Port(12345, ServerFactory())
     port.connected = True
     port.connectionLost = lambda reason: 1 // 0
     return self.assertFailure(port.stopListening(), ZeroDivisionError)
Ejemplo n.º 4
0
 def test_connectionLostFailed(self):
     """
     L{Port.stopListening} returns a L{Deferred} which errbacks if
     L{Port.connectionLost} raises an exception.
     """
     port = Port(12345, ServerFactory())
     port.connected = True
     port.connectionLost = lambda reason: 1 // 0
     return self.assertFailure(port.stopListening(), ZeroDivisionError)
 def port(self, portNumber, factory, interface):
     """
     Create, start, and return a new L{Port}, also tracking it so it can
     be stopped in the test tear down.
     """
     p = Port(portNumber, factory, interface=interface)
     p.startListening()
     self.ports.append(p)
     return p
Ejemplo n.º 6
0
    def dcc_send_file(self, nick, file):
        s = dccSend(nick, file)
        factory = dccFactory(self, s, dcc_fileoffer)
        conn = Port(0, factory, backlog=1)
        conn.startListening()
        
        (prot, dcchost, dccport) = conn.getHost()

        #
        # don't trust the host reported by dcc_chat - it's unconnected,
        # so it's not clear on which interface the connection will be
        serverhost = self.getHost()[1]
        self.ctcp(nick, "DCC", "SEND %s %lu %u" % \
                             (file, net.inet_aton(serverhost), dccport))
        self.dccsessions.append(s)
        self.viewtext.announce("Waiting for %s to accept %s" % (nick, file))