~mandel/ubuntuone-client/fix-805372

« back to all changes in this revision

Viewing changes to ubuntuone/platform/windows/ipc.py

  • Committer: Tarmac
  • Author(s): Alejandro J. Cura
  • Date: 2011-07-01 11:58:31 UTC
  • mfrom: (1031.1.11 use-standard-reactor)
  • Revision ID: tarmac-20110701115831-y0cnr2sxifkjje21
Use the standard reactor on windows. (LP: #803640)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import logging
22
22
 
23
23
from threading import Thread
24
 
from win32api import GetUserNameEx
25
 
from win32con import NameSamCompatible
26
24
 
27
25
from twisted.internet import defer, reactor
28
26
from twisted.spread.pb import Referenceable, Root, PBServerFactory
45
43
)
46
44
 
47
45
logger = logging.getLogger("ubuntuone.SyncDaemon.Pb")
48
 
NAMED_PIPE_URL = "\\\\.\\pipe\\ubuntuone_client\\%s"
 
46
HOST_PORT = "127.0.0.1", 50002
49
47
CLIENT_NOT_PROCESSED = -1
50
48
 
51
49
 
52
 
def get_pipe_name():
53
 
    """Builds the pipe name for this user."""
54
 
    return NAMED_PIPE_URL % GetUserNameEx(NameSamCompatible)
 
50
def get_sd_pb_hostport():
 
51
    """Returns the host and port for this user."""
 
52
    return HOST_PORT
55
53
 
56
54
 
57
55
def ipc_server_listen(server_factory):
58
56
    """Connect the IPC server factory."""
 
57
    host, port = get_sd_pb_hostport()
59
58
    # pylint: disable=E1101
60
 
    return reactor.listenPipe(get_pipe_name(), server_factory)
 
59
    return reactor.listenTCP(port, server_factory, interface=host)
61
60
 
62
61
 
63
62
def ipc_client_connect(client_factory):
64
63
    """Connect the IPC client factory."""
 
64
    host, port = get_sd_pb_hostport()
65
65
    # pylint: disable=E1101
66
 
    return reactor.connectPipe(get_pipe_name(), client_factory)
 
66
    return reactor.connectTCP(host, port, client_factory)
67
67
 
68
68
 
69
69
class NoAccessToken(Exception):