node.Node.__init__(self, basedir)
self.my_furl = None
self.introducer_client = None
- self.connected_to_vdrive = False
+ self._connected_to_vdrive = False
self.add_service(StorageServer(os.path.join(basedir, self.STOREDIR)))
self.add_service(Uploader())
self.add_service(Downloader())
def _got_vdrive(self, vdrive_root):
# vdrive_root implements RIMutableDirectoryNode
self.log("connected to vdrive")
- self.connected_to_vdrive = True
+ self._connected_to_vdrive = True
self.getServiceNamed("vdrive").set_root(vdrive_root)
if "webish" in self.namedServices:
self.getServiceNamed("webish").set_root_dirnode(vdrive_root)
def _disconnected():
- self.connected_to_vdrive = False
+ self._connected_to_vdrive = False
vdrive_root.notifyOnDisconnect(_disconnected)
def remote_get_versions(self):
def get_all_peerids(self):
+ if not self.introducer_client:
+ return []
return self.introducer_client.connections.iterkeys()
def get_permuted_peers(self, key):
results.append((permuted, peerid, connection))
results.sort()
return results
+
+ def connected_to_vdrive(self):
+ return self._connected_to_vdrive
+
+ def connected_to_introducer(self):
+ if self.introducer_client:
+ return self.introducer_client.connected_to_introducer()
+ return False
self.connections = {} # k: nodeid, v: ref
self.reconnectors = {} # k: FURL, v: reconnector
+ self._connected = False
self.connection_observers = observer.ObserverList()
def _got_introducer(self, introducer):
self.log(" introducing ourselves: %s, %s" % (self, self.my_furl))
+ self._connected = True
d = introducer.callRemote("hello",
node=self,
furl=self.my_furl)
+ introducer.notifyOnDisconnect(self._disconnected)
+
+ def _disconnected(self):
+ self._connected = False
def notify_on_new_connection(self, cb):
"""Register a callback that will be fired (with nodeid, rref) when
a new connection is established."""
self.connection_observers.subscribe(cb)
+ def connected_to_introducer(self):
+ return self._connected
<h1>Welcome To AllMyData! (tahoe2)</h1>
-<p>To view the global shared filestore, <a href="../vdrive">Click Here!</a></p>
+<div n:render="vdrive" />
<h2>Grid Status</h2>
<div>My nodeid: <span n:render="string" n:data="my_nodeid" /></div>
<div>Introducer: <span n:render="string" n:data="introducer_furl" /></div>
<div>Connected to introducer?: <span n:render="string" n:data="connected_to_introducer" /></div>
+<div>Connected to vdrive?: <span n:render="string" n:data="connected_to_vdrive" /></div>
<div>Known+Connected Peers: <span n:render="string" n:data="num_peers" /></div>
<div>
def data_introducer_furl(self, ctx, data):
return IClient(ctx).introducer_furl
def data_connected_to_introducer(self, ctx, data):
- if IClient(ctx).connected_to_vdrive:
+ if IClient(ctx).connected_to_introducer():
+ return "yes"
+ return "no"
+ def data_connected_to_vdrive(self, ctx, data):
+ if IClient(ctx).connected_to_vdrive():
return "yes"
return "no"
def data_num_peers(self, ctx, data):
ctx.fillSlots("peerid", nodeid_a)
return ctx.tag
+ def render_vdrive(self, ctx, data):
+ if IClient(ctx).connected_to_vdrive():
+ return T.p["To view the global shared filestore, ",
+ T.a(href="../vdrive")["Click Here!"],
+ ]
+ return T.p["vdrive.furl not specified, no vdrive available."]
+
# this is a form where users can download files by URI
def bind_download(self, ctx):