+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+(function() {
+
+ /**
+ * External storage file list
+ */
+ var FileList = function($el, options) {
+ this.initialize($el, options);
+ };
+
+ FileList.prototype = _.extend({}, OCA.Files.FileList.prototype, {
+ appName: 'External storage',
+
+ initialize: function($el, options) {
+ OCA.Files.FileList.prototype.initialize.apply(this, arguments);
+ if (this.initialized) {
+ return;
+ }
+ },
+
+ _createRow: function(fileData) {
+ // TODO: hook earlier and render the whole row here
+ var $tr = OCA.Files.FileList.prototype._createRow.apply(this, arguments);
+ var $scopeColumn = $(' | ');
+ var $backendColumn = $(' | ');
+ var scopeText = t('files_external', 'Personal');
+ if (fileData.scope === 'system') {
+ scopeText = t('files_external', 'System');
+ }
+ $tr.find('.filesize,.date').remove();
+ $scopeColumn.find('span').text(scopeText);
+ $backendColumn.text(fileData.backend);
+ $tr.find('td.filename').after($scopeColumn).after($backendColumn);
+ $tr.find('td.filename input:checkbox').remove();
+ return $tr;
+ },
+
+ updateEmptyContent: function() {
+ var dir = this.getCurrentDirectory();
+ if (dir === '/') {
+ // root has special permissions
+ this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty);
+ this.$el.find('#filestable thead th').toggleClass('hidden', this.isEmpty);
+ }
+ else {
+ OCA.Files.FileList.prototype.updateEmptyContent.apply(this, arguments);
+ }
+ },
+
+ getDirectoryPermissions: function() {
+ return OC.PERMISSION_READ | OC.PERMISSION_DELETE;
+ },
+
+ updateStorageStatistics: function() {
+ // no op because it doesn't have
+ // storage info like free space / used space
+ },
+
+ reload: function() {
+ var self = this;
+ this.showMask();
+ if (this._reloadCall) {
+ this._reloadCall.abort();
+ }
+ this._reloadCall = $.ajax({
+ url: OC.linkToOCS('apps/files_external/api/v1') + 'mounts',
+ data: {
+ format: 'json'
+ },
+ type: 'GET',
+ beforeSend: function(xhr) {
+ xhr.setRequestHeader('OCS-APIREQUEST', 'true');
+ },
+ error: function(result) {
+ self.reloadCallback(result);
+ },
+ success: function(result) {
+ self.reloadCallback(result);
+ }
+ });
+ },
+
+ reloadCallback: function(result) {
+ delete this._reloadCall;
+ this.hideMask();
+
+ if (result.ocs && result.ocs.data) {
+ this.setFiles(this._makeFiles(result.ocs.data));
+ }
+ else {
+ // TODO: error handling
+ }
+ },
+
+ /**
+ * Converts the OCS API response data to a file info
+ * list
+ * @param OCS API mounts array
+ * @return array of file info maps
+ */
+ _makeFiles: function(data) {
+ var files = _.map(data, function(fileData) {
+ fileData.icon = OC.imagePath('core', 'filetypes/folder-external');
+ return fileData;
+ });
+
+ files.sort(this._sortComparator);
+
+ return files;
+ }
+ });
+
+ OCA.External.FileList = FileList;
+})();
diff --git a/apps/files_external/lib/api.php b/apps/files_external/lib/api.php
new file mode 100644
index 0000000000..51c48427aa
--- /dev/null
+++ b/apps/files_external/lib/api.php
@@ -0,0 +1,83 @@
+.
+ *
+ */
+
+namespace OCA\Files\External;
+
+class Api {
+
+ /**
+ * Formats the given mount config to a mount entry.
+ *
+ * @param bool $isSystemMount true for system mount, false
+ * for personal mount
+ *
+ * @return array entry
+ */
+ private static function formatMount($mountConfig, $isSystemMount = false) {
+ // split user name from mount point
+ $path = dirname($mountConfig['mountpoint']);
+ if ($path === '.') {
+ $path = '';
+ }
+
+ $permissions = \OCP\PERMISSION_READ;
+ // personal mounts can be deleted
+ if (!$isSystemMount) {
+ $permissions |= \OCP\PERMISSION_DELETE;
+ }
+
+ // TODO: add storageType, might need to use another OC_Mount_Config method
+ $entry = array(
+ 'name' => basename($mountConfig['mountpoint']),
+ 'path' => $path,
+ 'type' => 'dir',
+ 'backend' => $mountConfig['backend'],
+ 'scope' => ( $isSystemMount ? 'system' : 'personal' ),
+ 'permissions' => $permissions
+ );
+ return $entry;
+ }
+
+ /**
+ * Returns the mount points visible for this user.
+ *
+ * @param array $params
+ * @return \OC_OCS_Result share information
+ */
+ public static function getUserMounts($params) {
+ $entries = array();
+ $user = \OC_User::getUser();
+
+ $personalMounts = \OC_Mount_Config::getPersonalMountPoints();
+ $systemMounts = \OC_Mount_Config::getSystemMountPoints();
+
+ foreach ($systemMounts as $mountConfig) {
+ $entries[] = self::formatMount($mountConfig, true);
+ }
+
+ foreach ($personalMounts as $mountConfig) {
+ $entries[] = self::formatMount($mountConfig, false);
+ }
+
+ return new \OC_OCS_Result($entries);
+ }
+}
diff --git a/apps/files_external/list.php b/apps/files_external/list.php
new file mode 100644
index 0000000000..e9517724f2
--- /dev/null
+++ b/apps/files_external/list.php
@@ -0,0 +1,11 @@
+printPage();
diff --git a/apps/files_external/templates/list.php b/apps/files_external/templates/list.php
new file mode 100644
index 0000000000..4e06bc7024
--- /dev/null
+++ b/apps/files_external/templates/list.php
@@ -0,0 +1,31 @@
+
+
+
+
+t( 'You don\'t have any external storages' )); ?>
+
+
+
+