diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2013-04-05 18:28:17 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2013-04-05 18:28:17 (GMT) |
commit | c9038e71a9b6c3069e9a97d85031c8b67102d671 (patch) | |
tree | 1a01efb63cc6508b15dfc83b4605764bff1636db | |
parent | bbd9c716fc1b772aee595a3e3642a8d465004020 (diff) |
Implement read_file and write_file methods
The list of shared items is saved
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r-- | activity.py | 17 | ||||
-rw-r--r-- | activity/activity.info | 2 |
2 files changed, 16 insertions, 3 deletions
diff --git a/activity.py b/activity.py index 2512e45..91355b4 100644 --- a/activity.py +++ b/activity.py @@ -285,10 +285,23 @@ class JournalShare(activity.Activity): return True def read_file(self, file_path): - pass + f = open(file_path) + json_data = f.read() + f.close() + # the information is saved in a dictionary + # now is only the list of shared items + # but later we can add more info + state = json.loads(json_data) + if 'shared_items' in state: + self._shared_items = state['shared_items'] + self._update_shared_items() def write_file(self, file_path): - pass + state = {} + state['shared_items'] = self._shared_items + f = open(file_path, 'w') + f.write(json.dumps(state)) + f.close() def can_close(self): if self.server_proc is not None: diff --git a/activity/activity.info b/activity/activity.info index cfee50d..2439555 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -3,6 +3,6 @@ name = Journal Share summary = Want to share your work in easy way? Journal Share could help you, it's just a webserver which allow the users connected in the same network to see your starred objects in your Journal only using a web browser. activity_version = 2 bundle_id = org.sugarlabs.JournalShare -exec = sugar-activity activity.JournalShare -s +exec = sugar-activity activity.JournalShare icon = journal-share-icon license = GPLv3+ |