From 7143d9c7de17aa12bd6a6de2f857061dcc04f137 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 04 Jan 2009 10:47:49 +0000 Subject: #165 Install bundles when they get into the journal --- (limited to 'src') diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py index a1e28ac..ff73d16 100644 --- a/src/jarabe/journal/journalactivity.py +++ b/src/jarabe/journal/journalactivity.py @@ -246,18 +246,18 @@ class JournalActivity(Window): self._main_toolbox.search_toolbar.set_mount_point(mount_point) self._main_toolbox.set_current_toolbar(0) - def __model_created_cb(self, object_id): - self._check_for_bundle(object_id) + def __model_created_cb(self, sender, **kwargs): + self._check_for_bundle(kwargs['object_id']) self._main_toolbox.search_toolbar.refresh_filters() self._check_available_space() - def __model_updated_cb(self, object_id): - self._check_for_bundle(object_id) + def __model_updated_cb(self, sender, **kwargs): + self._check_for_bundle(kwargs['object_id']) self._check_available_space() - def __model_deleted_cb(self, object_id): + def __model_deleted_cb(self, sender, **kwargs): if self.canvas == self._secondary_view and \ - object_id == self._detail_view.props.metadata['uid']: + kwargs['object_id'] == self._detail_view.props.metadata['uid']: self.show_main_view() def _focus_in_event_cb(self, window, event): @@ -268,6 +268,10 @@ class JournalActivity(Window): registry = bundleregistry.get_registry() metadata = model.get(object_id) + if metadata.get('progress', '').isdigit(): + if int(metadata['progress']) < 100: + return + bundle = misc.get_bundle(metadata) if bundle is None: return diff --git a/src/jarabe/journal/misc.py b/src/jarabe/journal/misc.py index 729960b..581b2e2 100644 --- a/src/jarabe/journal/misc.py +++ b/src/jarabe/journal/misc.py @@ -87,12 +87,25 @@ def get_date(metadata): def get_bundle(metadata): try: - file_path = util.TempFilePath(model.get_file(metadata['uid'])) - if is_activity_bundle(metadata) and os.path.exists(file_path): + if is_activity_bundle(metadata): + file_path = util.TempFilePath(model.get_file(metadata['uid'])) + if not os.path.exists(file_path): + logging.warning('Invalid path: %r' % file_path) + return None return ActivityBundle(file_path) - elif is_content_bundle(metadata) and os.path.exists(file_path): + + elif is_content_bundle(metadata): + file_path = util.TempFilePath(model.get_file(metadata['uid'])) + if not os.path.exists(file_path): + logging.warning('Invalid path: %r' % file_path) + return None return ContentBundle(file_path) - elif is_journal_bundle(metadata) and os.path.exists(file_path): + + elif is_journal_bundle(metadata): + file_path = util.TempFilePath(model.get_file(metadata['uid'])) + if not os.path.exists(file_path): + logging.warning('Invalid path: %r' % file_path) + return None return JournalEntryBundle(file_path) else: return None @@ -197,8 +210,8 @@ def resume(metadata, bundle_id=None): activityfactory.create_with_object_id(bundle, object_id) def is_activity_bundle(metadata): - return metadata['mime_type'] in \ - [ActivityBundle.MIME_TYPE, ActivityBundle.DEPRECATED_MIME_TYPE] + return metadata['mime_type'] == ActivityBundle.MIME_TYPE or \ + metadata['mime_type'] == ActivityBundle.DEPRECATED_MIME_TYPE def is_content_bundle(metadata): return metadata['mime_type'] == ContentBundle.MIME_TYPE diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py index 56dad20..3a6efa1 100644 --- a/src/jarabe/journal/model.py +++ b/src/jarabe/journal/model.py @@ -256,8 +256,21 @@ def _get_datastore(): remote_object = bus.get_object(DS_DBUS_SERVICE, DS_DBUS_PATH) _datastore = dbus.Interface(remote_object, DS_DBUS_INTERFACE) + _datastore.connect_to_signal('Created', _datastore_created_cb) + _datastore.connect_to_signal('Updated', _datastore_updated_cb) + _datastore.connect_to_signal('Deleted', _datastore_deleted_cb) + return _datastore +def _datastore_created_cb(object_id): + created.send(None, object_id=object_id) + +def _datastore_updated_cb(object_id): + updated.send(None, object_id=object_id) + +def _datastore_deleted_cb(object_id): + deleted.send(None, object_id=object_id) + def find(query): """Returns a ResultSet """ -- cgit v0.9.1