Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAjay Garg <ajay@activitycentral.com>2012-08-27 11:25:09 (GMT)
committer Ajay Garg <ajay@activitycentral.com>2012-08-27 11:30:21 (GMT)
commit945a8ac199c31459a6a074de942b2780c00b5439 (patch)
treeca88cd9978600b376d1829df18c0e84346a7d0ea
parent55db4d555690d3ef1700d9e19eb999c95ddb2f3d (diff)
[Version-2] 1-to-N feature via School-Server.
Changes of version-2 over version-1 : ====================================== a) Fixed the bug, wherein files present in nested directories under "Documents", and Mounted-Drives, were not uploaded to school-server. b) When the passphrase pops up, clicking the "x" icon, should not cause a UI freeze.
-rw-r--r--rpms/sugar/0130-1-to-N-feature-via-School-Server.patch172
1 files changed, 115 insertions, 57 deletions
diff --git a/rpms/sugar/0130-1-to-N-feature-via-School-Server.patch b/rpms/sugar/0130-1-to-N-feature-via-School-Server.patch
index b2babe3..b03c8fd 100644
--- a/rpms/sugar/0130-1-to-N-feature-via-School-Server.patch
+++ b/rpms/sugar/0130-1-to-N-feature-via-School-Server.patch
@@ -1,24 +1,23 @@
-From 5a3da2cb5bea8c15b2cbc0ba76d1cb96e4beaced Mon Sep 17 00:00:00 2001
+From 011c4b94fe4d3caf3b2ada5ab55bf12e2507e78c Mon Sep 17 00:00:00 2001
From: Ajay Garg <ajay@activitycentral.com>
-Date: Sun, 26 Aug 2012 14:53:11 +0530
-Subject: [sugar PATCH] 1-to-N feature via School Server
+Date: Mon, 27 Aug 2012 16:40:48 +0530
+Subject: [PATCH] [Version-13] 1-to-N feature via School Server
Organization: Sugar Labs Foundation
-Signed-off-by: Ajay Garg <ajay@activitycentral.com>
----
-
+Signed-off-by: Ajay Garg <ajay@activitycentral.com>
+---
src/jarabe/journal/journalactivity.py | 17 ++-
src/jarabe/journal/journaltoolbox.py | 44 +++++-
- src/jarabe/journal/model.py | 285 +++++++++++++++++++++------------
- src/jarabe/journal/palettes.py | 201 ++++++++++++++++++++----
+ src/jarabe/journal/model.py | 313 +++++++++++++++++++++------------
+ src/jarabe/journal/palettes.py | 202 ++++++++++++++++++---
src/jarabe/journal/volumestoolbar.py | 41 ++---
- src/jarabe/journal/webdavmanager.py | 146 ++++++++++-------
- src/jarabe/view/palettes.py | 31 +----
+ src/jarabe/journal/webdavmanager.py | 146 +++++++++------
+ src/jarabe/view/palettes.py | 31 +---
src/webdav/Connection.py | 11 +-
src/webdav/WebdavClient.py | 16 ++-
src/webdav/davlib.py | 9 +-
- 10 files changed, 536 insertions(+), 265 deletions(-)
+ 10 files changed, 557 insertions(+), 273 deletions(-)
diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py
index fc4773d..5f2a734 100644
@@ -155,7 +154,7 @@ index 6b2494e..b1c0cac 100644
return self._selected_entries
diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
-index 422e947..cc17956 100644
+index 422e947..b1514f1 100644
--- a/src/jarabe/journal/model.py
+++ b/src/jarabe/journal/model.py
@@ -43,7 +43,7 @@ from sugar import dispatch
@@ -171,7 +170,7 @@ index 422e947..cc17956 100644
MIN_PAGES_TO_CACHE = 3
MAX_PAGES_TO_CACHE = 5
-+WEBDAV_MOUNT_POINT = '/tmp'
++WEBDAV_MOUNT_POINT = '/tmp/'
JOURNAL_METADATA_DIR = '.Sugar-Metadata'
_datastore = None
@@ -213,7 +212,7 @@ index 422e947..cc17956 100644
+ More importantly, whatever the "name" be, it does NOT have a
+ forward-slash.
+ """
-+ return mount_point.find('/') == -1
++ return mount_point.find(WEBDAV_MOUNT_POINT) == 0
+
+
class _Cache(object):
@@ -243,9 +242,14 @@ index 422e947..cc17956 100644
for metadata in metadata_list_complete:
add_to_list = False
-@@ -557,11 +599,6 @@ def _get_file_metadata(path, stat, fetch_preview=True):
- dir_path = os.path.dirname(path)
- metadata = _get_file_metadata_from_json(dir_path, filename, fetch_preview)
+@@ -553,15 +595,8 @@ def _get_file_metadata(path, stat, fetch_preview=True):
+ metadata based on the file properties.
+
+ """
+- filename = os.path.basename(path)
+- dir_path = os.path.dirname(path)
+- metadata = _get_file_metadata_from_json(dir_path, filename, fetch_preview)
++ metadata = _get_file_metadata_from_json(path, fetch_preview)
if metadata:
- # For Documents/Shares/Mounted-Drives.
- # Special case: for locally-mounted-remote-files, ensure that
@@ -255,7 +259,47 @@ index 422e947..cc17956 100644
if 'filesize' not in metadata:
if stat is not None:
metadata['filesize'] = stat.st_size
-@@ -678,56 +715,13 @@ def find(query_, page_size):
+@@ -582,17 +617,26 @@ def _get_file_metadata(path, stat, fetch_preview=True):
+ 'description': path}
+
+
+-def _get_file_metadata_from_json(dir_path, filename, fetch_preview):
++def _get_file_metadata_from_json(path, fetch_preview):
+ """Read the metadata from the json file and the preview
+ stored on the external device.
+
+ If the metadata is corrupted we do remove it and the preview as well.
+
+ """
++ filename = os.path.basename(path)
++ dir_path = os.path.dirname(path)
++
++ # In case of nested mount-points, (eg. ~/Documents/in1/in2/in3.txt),
++ # "dir_path = ~/Documents/in1/in2"; while
++ # "metadata_dir_path = ~/Documents".
++ from jarabe.journal.journalactivity import get_mount_point
++ metadata_dir_path = get_mount_point()
++
+ metadata = None
+- metadata_path = os.path.join(dir_path, JOURNAL_METADATA_DIR,
++ metadata_path = os.path.join(metadata_dir_path, JOURNAL_METADATA_DIR,
+ filename + '.metadata')
+- preview_path = os.path.join(dir_path, JOURNAL_METADATA_DIR,
++ preview_path = os.path.join(metadata_dir_path, JOURNAL_METADATA_DIR,
+ filename + '.preview')
+
+ if not os.path.exists(metadata_path):
+@@ -670,7 +714,8 @@ def find(query_, page_size):
+ Regex Matching is used, to ensure that the mount-point is an
+ IP-Address.
+ """
+- return RemoteShareResultSet(mount_points[0], query)
++ ip_address = extract_ip_address_or_dns_name_from_locally_mounted_remote_share_path(mount_points[0])
++ return RemoteShareResultSet(ip_address, query)
+ else:
+ """
+ For Documents/Shares/Mounted-Drives.
+@@ -678,56 +723,13 @@ def find(query_, page_size):
return InplaceResultSet(query, page_size, mount_points[0])
@@ -312,7 +356,7 @@ index 422e947..cc17956 100644
stat = None
metadata = _get_file_metadata(object_id, stat)
-@@ -812,7 +806,21 @@ def delete(object_id):
+@@ -812,7 +814,21 @@ def delete(object_id):
def copy(metadata, mount_point):
"""Copies an object to another mount point
"""
@@ -334,7 +378,7 @@ index 422e947..cc17956 100644
if mount_point == '/' and metadata['icon-color'] == '#000000,#ffffff':
client = gconf.client_get_default()
metadata['icon-color'] = client.get_string('/desktop/sugar/user/color')
-@@ -823,7 +831,7 @@ def copy(metadata, mount_point):
+@@ -823,7 +839,7 @@ def copy(metadata, mount_point):
metadata['mountpoint'] = mount_point
del metadata['uid']
@@ -343,7 +387,7 @@ index 422e947..cc17956 100644
def write(metadata, file_path='', update_mtime=True, transfer_ownership=True):
-@@ -845,13 +853,69 @@ def write(metadata, file_path='', update_mtime=True, transfer_ownership=True):
+@@ -845,13 +861,69 @@ def write(metadata, file_path='', update_mtime=True, transfer_ownership=True):
object_id = _get_datastore().create(dbus.Dictionary(metadata),
file_path,
transfer_ownership)
@@ -419,7 +463,7 @@ index 422e947..cc17956 100644
return object_id
-@@ -876,41 +940,17 @@ def _rename_entry_on_external_device(file_path, destination_path,
+@@ -876,41 +948,17 @@ def _rename_entry_on_external_device(file_path, destination_path,
'for file=%s', ofile, old_fname)
@@ -469,7 +513,7 @@ index 422e947..cc17956 100644
metadata_dir_path = os.path.join(metadata['mountpoint'],
JOURNAL_METADATA_DIR)
-@@ -939,25 +979,58 @@ def _write_entry_on_external_device(metadata, file_path):
+@@ -939,25 +987,64 @@ def _write_entry_on_external_device(metadata, file_path):
os.close(fh)
os.rename(fn, os.path.join(metadata_dir_path, preview_fname))
@@ -482,14 +526,6 @@ index 422e947..cc17956 100644
- _rename_entry_on_external_device(file_path, destination_path,
- metadata_dir_path)
+ preview_destination_path = None
-+
-+ return (metadata_destination_path, preview_destination_path)
-+
-+
-+def _write_entry_on_external_device(metadata, file_path,
-+ transfer_ownership):
-+ """Create and update an entry copied from the
-+ DS to an external storage device.
- # For "Shares" folder, we need to set the permissions of the newly
- # copied file to 0777, else it will not be accessible by "httpd"
@@ -498,18 +534,32 @@ index 422e947..cc17956 100644
- fd = os.open(destination_path, os.O_RDONLY)
- os.fchmod(fd, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
- os.close(fd)
-+ Besides copying the associated file a file for the preview
-+ and one for the metadata are stored in the hidden directory
-+ .Sugar-Metadata.
++ return (metadata_destination_path, preview_destination_path)
- metadata_file_path = os.path.join(metadata_dir_path, file_name + '.metadata')
- fd = os.open(metadata_file_path, os.O_RDONLY)
- os.fchmod(fd, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
- os.close(fd)
+
++def update_only_metadata_and_preview_files_and_return_file_paths(metadata):
++ file_name = get_file_name(metadata['title'], metadata['mime_type'])
++ _write_metadata_and_preview_files_and_return_file_paths(metadata,
++ file_name)
++
++
++def _write_entry_on_external_device(metadata, file_path,
++ transfer_ownership):
++ """Create and update an entry copied from the
++ DS to an external storage device.
++
++ Besides copying the associated file a file for the preview
++ and one for the metadata are stored in the hidden directory
++ .Sugar-Metadata.
++
+ This function handles renames of an entry on the
+ external device and avoids name collisions. Renames are
+ handled failsafe.
-
++
+ """
+ if 'uid' in metadata and os.path.exists(metadata['uid']):
+ file_path = metadata['uid']
@@ -544,7 +594,7 @@ index 422e947..cc17956 100644
object_id = destination_path
created.send(None, object_id=object_id)
diff --git a/src/jarabe/journal/palettes.py b/src/jarabe/journal/palettes.py
-index 66dcadc..dc3a691 100644
+index 66dcadc..645ed3a 100644
--- a/src/jarabe/journal/palettes.py
+++ b/src/jarabe/journal/palettes.py
@@ -30,6 +30,7 @@ import gio
@@ -571,7 +621,7 @@ index 66dcadc..dc3a691 100644
friends_model = friends.get_model()
-@@ -59,6 +59,50 @@ friends_model = friends.get_model()
+@@ -59,6 +59,49 @@ friends_model = friends.get_model()
_copy_menu_helper = None
_current_action_item = None
@@ -613,16 +663,15 @@ index 66dcadc..dc3a691 100644
+ return self._response
+
+ def _key_dialog_response_cb(self, widget, response_id):
-+ if response_id == gtk.RESPONSE_OK:
-+ self.hide()
-+ gobject.idle_add(self._callback, self._metadata,
-+ self._entry.get_text())
++ self.hide()
++ gobject.idle_add(self._callback, self._metadata,
++ self._entry.get_text())
+
+
class ObjectPalette(Palette):
__gtype_name__ = 'ObjectPalette'
-@@ -528,6 +572,7 @@ class ActionItem(gobject.GObject):
+@@ -528,6 +571,7 @@ class ActionItem(gobject.GObject):
This is the stage, just after EVERY metadata has been
processed.
"""
@@ -630,7 +679,7 @@ index 66dcadc..dc3a691 100644
# Toggle the corresponding checkbox - but only for batch-mode.
if self._batch_mode and self._auto_deselect_source_entries:
-@@ -573,6 +618,25 @@ class ActionItem(gobject.GObject):
+@@ -573,6 +617,25 @@ class ActionItem(gobject.GObject):
from jarabe.journal.journalactivity import get_journal
get_journal().get_list_view().refresh()
@@ -656,7 +705,7 @@ index 66dcadc..dc3a691 100644
def _handle_error_alert(self, error_message, metadata):
"""
This handles any error scenarios. Examples are of entries that
-@@ -593,19 +657,11 @@ class ActionItem(gobject.GObject):
+@@ -593,19 +656,11 @@ class ActionItem(gobject.GObject):
current_len = len(self._metadata_list)
@@ -678,7 +727,7 @@ index 66dcadc..dc3a691 100644
self._process_error_skipping,
metadata)
else:
-@@ -639,19 +695,55 @@ class ActionItem(gobject.GObject):
+@@ -639,19 +694,55 @@ class ActionItem(gobject.GObject):
if model.is_mount_point_for_locally_mounted_remote_share(current_mount_point):
file_path = metadata['uid']
filename = os.path.basename(file_path)
@@ -739,7 +788,7 @@ index 66dcadc..dc3a691 100644
_('Error'))
return False
-@@ -662,7 +754,7 @@ class ActionItem(gobject.GObject):
+@@ -662,7 +753,7 @@ class ActionItem(gobject.GObject):
if self._batch_mode:
self._handle_error_alert(error_message, metadata)
else:
@@ -748,7 +797,7 @@ index 66dcadc..dc3a691 100644
return False
else:
return True
-@@ -674,12 +766,12 @@ class ActionItem(gobject.GObject):
+@@ -674,12 +765,12 @@ class ActionItem(gobject.GObject):
model.copy(metadata, mount_point)
return True
except Exception, e:
@@ -763,7 +812,16 @@ index 66dcadc..dc3a691 100644
return False
finally:
self._set_bundle_installation_allowed(True)
-@@ -698,7 +790,7 @@ class ActionItem(gobject.GObject):
+@@ -689,7 +780,7 @@ class ActionItem(gobject.GObject):
+ self._set_bundle_installation_allowed(False)
+
+ try:
+- model.write(metadata, update_mtime=False)
++ model.update_only_metadata_and_preview_files_and_return_file_paths(metadata)
+ return True
+ except Exception, e:
+ logging.exception('Error while writing the metadata. %s', e)
+@@ -698,7 +789,7 @@ class ActionItem(gobject.GObject):
if self._batch_mode:
self._handle_error_alert(error_message, metadata)
else:
@@ -772,7 +830,7 @@ index 66dcadc..dc3a691 100644
return False
finally:
self._set_bundle_installation_allowed(True)
-@@ -751,6 +843,29 @@ class BaseCopyMenuItem(MenuItem, ActionItem):
+@@ -751,6 +842,29 @@ class BaseCopyMenuItem(MenuItem, ActionItem):
def _get_info_alert_title(self):
return _('Copying')
@@ -802,7 +860,7 @@ index 66dcadc..dc3a691 100644
class VolumeMenu(BaseCopyMenuItem):
def __init__(self, metadata_list, label, mount_point,
-@@ -761,9 +876,10 @@ class VolumeMenu(BaseCopyMenuItem):
+@@ -761,9 +875,10 @@ class VolumeMenu(BaseCopyMenuItem):
show_progress_info_alert, batch_mode)
self._mount_point = mount_point
@@ -814,7 +872,7 @@ index 66dcadc..dc3a691 100644
if not self._metadata_copy_valid(metadata, self._mount_point):
return False
-@@ -780,7 +896,7 @@ class ClipboardMenu(BaseCopyMenuItem):
+@@ -780,7 +895,7 @@ class ClipboardMenu(BaseCopyMenuItem):
batch_mode)
self._temp_file_path_list = []
@@ -823,7 +881,7 @@ index 66dcadc..dc3a691 100644
if not self._file_path_valid(metadata):
return False
-@@ -813,9 +929,10 @@ class DocumentsMenu(BaseCopyMenuItem):
+@@ -813,9 +928,10 @@ class DocumentsMenu(BaseCopyMenuItem):
show_progress_info_alert,
batch_mode)
@@ -835,7 +893,7 @@ index 66dcadc..dc3a691 100644
if not self._metadata_copy_valid(metadata,
model.get_documents_path()):
return False
-@@ -824,10 +941,10 @@ class DocumentsMenu(BaseCopyMenuItem):
+@@ -824,10 +940,10 @@ class DocumentsMenu(BaseCopyMenuItem):
self._post_operate_per_metadata_per_action(metadata)
@@ -848,7 +906,7 @@ index 66dcadc..dc3a691 100644
show_editing_alert,
show_progress_info_alert,
batch_mode)
-@@ -835,8 +952,34 @@ class SharesMenu(BaseCopyMenuItem):
+@@ -835,8 +951,34 @@ class SharesMenu(BaseCopyMenuItem):
def _operate(self, metadata):
if not self._file_path_valid(metadata):
return False
@@ -884,7 +942,7 @@ index 66dcadc..dc3a691 100644
return False
# This is sync-operation. Call the post-operation now.
-@@ -970,8 +1113,8 @@ class CopyMenuHelper(gtk.Menu):
+@@ -970,8 +1112,8 @@ class CopyMenuHelper(gtk.Menu):
menu.append(documents_menu)
documents_menu.show()
@@ -896,7 +954,7 @@ index 66dcadc..dc3a691 100644
show_progress_info_alert,
batch_mode)
diff --git a/src/jarabe/journal/volumestoolbar.py b/src/jarabe/journal/volumestoolbar.py
-index c24475d..8453682 100644
+index c24475d..e251300 100644
--- a/src/jarabe/journal/volumestoolbar.py
+++ b/src/jarabe/journal/volumestoolbar.py
@@ -211,7 +211,7 @@ class VolumesToolbar(gtk.Toolbar):
@@ -976,7 +1034,7 @@ index c24475d..8453682 100644
- def __init__(self, buddy):
- BaseButton.__init__(self, mount_point=buddy.props.ip_address)
+ def __init__(self, ip_address_or_dns_name):
-+ BaseButton.__init__(self, mount_point=ip_address_or_dns_name)
++ BaseButton.__init__(self, mount_point=(model.WEBDAV_MOUNT_POINT + ip_address_or_dns_name))
- self._buddy = buddy
+ self._ip_address_or_dns_name = ip_address_or_dns_name