Ticket #1098: sugar-1098

File sugar-1098, 3.7 KB (added by alsroot, 15 years ago)
Line 
1From 7f4a060d89db9901bae66748c4747dfc023469c0 Mon Sep 17 00:00:00 2001
2From: Aleksey Lim <alsroot@member.fsf.org>
3Date: Mon, 27 Jul 2009 04:05:14 +0000
4Subject: Fix .xoj support #1098
5
6---
7 src/jarabe/journal/journalactivity.py    |    1 +
8 src/jarabe/journal/journalentrybundle.py |    5 ++++-
9 src/jarabe/model/bundleregistry.py       |   10 +++++++---
10 3 files changed, 12 insertions(+), 4 deletions(-)
11
12diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py
13index 4ca751c..bc0ba14 100644
14--- a/src/jarabe/journal/journalactivity.py
15+++ b/src/jarabe/journal/journalactivity.py
16@@ -288,6 +288,7 @@ class JournalActivity(Window):
17 
18         if metadata['mime_type'] == JournalEntryBundle.MIME_TYPE:
19             model.delete(object_id)
20+            return
21 
22         metadata['bundle_id'] = bundle.get_bundle_id()
23         model.write(metadata)
24diff --git a/src/jarabe/journal/journalentrybundle.py b/src/jarabe/journal/journalentrybundle.py
25index 5d4086c..ebe7ec3 100644
26--- a/src/jarabe/journal/journalentrybundle.py
27+++ b/src/jarabe/journal/journalentrybundle.py
28@@ -40,7 +40,7 @@ class JournalEntryBundle(Bundle):
29     def __init__(self, path):
30         Bundle.__init__(self, path)
31 
32-    def install(self):
33+    def install(self, install_path):
34         if os.environ.has_key('SUGAR_ACTIVITY_ROOT'):
35             install_dir = os.path.join(os.environ['SUGAR_ACTIVITY_ROOT'],
36                                        'data')
37@@ -62,6 +62,9 @@ class JournalEntryBundle(Bundle):
38         finally:
39             shutil.rmtree(bundle_dir, ignore_errors=True)
40 
41+    def get_bundle_id(self):
42+        return None
43+
44     def _read_metadata(self, bundle_dir):
45         metadata_path = os.path.join(bundle_dir, '_metadata.json')
46         if not os.path.exists(metadata_path):
47diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
48index 42d39b0..351459b 100644
49--- a/src/jarabe/model/bundleregistry.py
50+++ b/src/jarabe/model/bundleregistry.py
51@@ -26,6 +26,7 @@ import cjson
52 
53 from sugar.bundle.activitybundle import ActivityBundle
54 from sugar.bundle.contentbundle import ContentBundle
55+from jarabe.journal.journalentrybundle import JournalEntryBundle
56 from sugar.bundle.bundle import MalformedBundleException, \
57     AlreadyInstalledException, RegistrationException
58 from sugar import env
59@@ -309,7 +310,8 @@ class BundleRegistry(gobject.GObject):
60     def is_installed(self, bundle):
61         # TODO treat ContentBundle in special way
62         # needs rethinking while fixing ContentBundle support
63-        if isinstance(bundle, ContentBundle):
64+        if isinstance(bundle, ContentBundle) or \
65+                isinstance(bundle, JournalEntryBundle):
66             return bundle.is_installed()
67 
68         for installed_bundle in self._bundles:
69@@ -338,7 +340,8 @@ class BundleRegistry(gobject.GObject):
70         
71         # TODO treat ContentBundle in special way
72         # needs rethinking while fixing ContentBundle support
73-        if isinstance(bundle, ContentBundle):
74+        if isinstance(bundle, ContentBundle) or \
75+                isinstance(bundle, JournalEntryBundle):
76             pass
77         elif not self.add_bundle(install_path):
78             raise RegistrationException
79@@ -346,7 +349,8 @@ class BundleRegistry(gobject.GObject):
80     def uninstall(self, bundle, force=False):       
81         # TODO treat ContentBundle in special way
82         # needs rethinking while fixing ContentBundle support
83-        if isinstance(bundle, ContentBundle):
84+        if isinstance(bundle, ContentBundle) or \
85+                isinstance(bundle, JournalEntryBundle):
86             if bundle.is_installed():
87                 bundle.uninstall()
88             else:
89--
901.6.3.3
91