Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Schampijer <simon@schampijer.de>2007-12-05 17:17:22 (GMT)
committer Simon Schampijer <simon@schampijer.de>2007-12-05 17:17:22 (GMT)
commitebfcd39e199a94bb3a04f9f0603096924d9d39a3 (patch)
tree1307c9f2b9a6bc51943248139fe2754255f88627
parentb3e4608704870aa3a283406a7fec6541d2a68fdb (diff)
Open an uri of type text/uri-list with browse #5080
-rw-r--r--NEWS5
-rwxr-xr-xwebactivity.py29
2 files changed, 22 insertions, 12 deletions
diff --git a/NEWS b/NEWS
index cca54c2..ccc8c9e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
-* Save view source to SAR/instance (erikos)
-* Move the profile in SAR/data (erikos)
+* Open an uri of type text/uri-list with browse #5080 (erikos)
+* Save view source to SAR/instance #5251 (erikos)
+* Move the profile in SAR/data #5221 (erikos)
76
diff --git a/webactivity.py b/webactivity.py
index 8d9b7b1..8ff8db4 100755
--- a/webactivity.py
+++ b/webactivity.py
@@ -19,14 +19,12 @@ import logging
from gettext import gettext as _
import gtk
-import dbus
import sha
import base64
import time
import shutil
from sugar.activity import activity
-from sugar import env
from sugar.graphics import style
import telepathy
import telepathy.client
@@ -35,6 +33,7 @@ from sugar.graphics.tray import HTray
from sugar import profile
from sugar.graphics.alert import Alert
from sugar.graphics.icon import Icon
+from sugar import mime
PROFILE_VERSION = 1
@@ -65,8 +64,6 @@ from browser import Browser
from webtoolbar import WebToolbar
from viewtoolbar import ViewToolbar
import downloadmanager
-import promptservice
-import filepicker
import sessionhistory
import progresslistener
@@ -275,14 +272,18 @@ class WebActivity(activity.Activity):
if embed.props.title is not '':
_logger.debug('Title changed=%s' % embed.props.title)
self.webtitle = embed.props.title
-
+
+ def _get_data_from_file_path(self, file_path):
+ fd = open(file_path, 'r')
+ try:
+ data = fd.read()
+ finally:
+ fd.close()
+ return data
+
def read_file(self, file_path):
if self.metadata['mime_type'] == 'text/plain':
- f = open(file_path, 'r')
- try:
- data = f.read()
- finally:
- f.close()
+ data = self._get_data_from_file_path(file_path)
self.model.deserialize(data)
for link in self.model.data['shared_links']:
@@ -294,6 +295,14 @@ class WebActivity(activity.Activity):
link['color'], link['title'],
link['owner'], -1, link['hash'])
self._browser.set_session(self.model.data['history'])
+ elif self.metadata['mime_type'] == 'text/uri-list':
+ data = self._get_data_from_file_path(file_path)
+ uris = mime.split_uri_list(data)
+ if len(uris) == 1:
+ self._browser.load_uri(uris[0])
+ else:
+ _logger.error('Open uri-list: Does not support'
+ 'list of multiple uris by now.')
else:
self._browser.load_uri(file_path)