GLOBAL_VDRIVE_FURL_FILE = "vdrive.furl"
MY_FURL_FILE = "myself.furl"
SUICIDE_PREVENTION_HOTLINE_FILE = "suicide_prevention_hotline"
+ MY_VDRIVE_FURL_FILE = "my_vdrive.furl"
# we're pretty narrow-minded right now
OLDEST_SUPPORTED_VERSION = allmydata.__version__
self.global_vdrive_furl = f.read().strip()
f.close()
#self.add_service(VDrive())
+ self._my_vdrive = None
hotline_file = os.path.join(self.basedir,
self.SUICIDE_PREVENTION_HOTLINE_FILE)
self.log("connected to vdrive server")
d = vdrive_server.callRemote("get_public_root_furl")
d.addCallback(self._got_vdrive_root_furl, vdrive_server)
+ d.addCallback(self._create_my_vdrive)
+ d.addCallback(self._got_my_vdrive)
def _got_vdrive_root_furl(self, vdrive_root_furl, vdrive_server):
root = DirectoryNode(vdrive_root_furl, self)
webish = self.getServiceNamed("webish")
webish.set_vdrive_root(root)
+ def _create_my_vdrive(self, ignored=None):
+ MY_VDRIVE_FURL_FILE = os.path.join(self.basedir,
+ self.MY_VDRIVE_FURL_FILE)
+ try:
+ f = open(MY_VDRIVE_FURL_FILE, "r")
+ my_vdrive_furl = f.read().strip()
+ f.close()
+ return defer.succeed(DirectoryNode(my_vdrive_furl, self))
+ except EnvironmentError:
+ d = self._vdrive_server.callRemote("create_directory")
+ def _got_directory(dirnode):
+ f = open(MY_VDRIVE_FURL_FILE, "w")
+ f.write(dirnode.furl + "\n")
+ f.close()
+ dirnode._set_client(self)
+ return dirnode
+ d.addCallback(_got_directory)
+ return d
+
+ def _got_my_vdrive(self, my_vdrive):
+ assert isinstance(my_vdrive, DirectoryNode), my_vdrive
+ self._my_vdrive = my_vdrive
+
+ if "webish" in self.namedServices:
+ webish = self.getServiceNamed("webish")
+ webish.set_my_vdrive_root(my_vdrive)
+
+
def remote_get_versions(self):
return str(allmydata.__version__), str(self.OLDEST_SUPPORTED_VERSION)
ctx.fillSlots("peerid", nodeid_a)
return ctx.tag
- def render_vdrive(self, ctx, data):
- if IClient(ctx).connected_to_vdrive():
+ def render_global_vdrive(self, ctx, data):
+ if self.has_global_vdrive:
return T.p["To view the global shared filestore, ",
- T.a(href="../vdrive")["Click Here!"],
+ T.a(href="../global_vdrive")["Click Here!"],
+ ]
+ return T.p["vdrive.furl not specified (or vdrive server not "
+ "responding), no vdrive available."]
+
+ def render_my_vdrive(self, ctx, data):
+ if self.has_my_vdrive:
+ return T.p["To view your personal private non-shared filestore, ",
+ T.a(href="../my_vdrive")["Click Here!"],
]
- return T.p["vdrive.furl not specified, no vdrive available."]
+ return T.p["personal vdrive not available."]
# this is a form where users can download files by URI
def __init__(self, webport):
service.MultiService.__init__(self)
self.root = Root()
+ self.root.child_welcome.has_global_vdrive = False
+ self.root.child_welcome.has_my_vdrive = False
placeholder = static.Data("sorry, still initializing", "text/plain")
self.root.putChild("vdrive", placeholder)
self.root.putChild("", url.here.child("welcome"))#Welcome())
#self.site._client = self.parent
def set_vdrive_root(self, root):
- self.root.putChild("vdrive", Directory(root, "/"))
+ self.root.putChild("global_vdrive", Directory(root, "/"))
+ self.root.child_welcome.has_global_vdrive = True
# I tried doing it this way and for some reason it didn't seem to work
#print "REMEMBERING", self.site, dl, IDownloader
#self.site.remember(dl, IDownloader)
+ def set_my_vdrive_root(self, my_vdrive):
+ self.root.putChild("my_vdrive", Directory(my_vdrive, "~"))
+ self.root.child_welcome.has_my_vdrive = True
+