summaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/ajax/addRootCertificate.php6
-rw-r--r--apps/files_external/appinfo/app.php18
-rw-r--r--apps/files_external/appinfo/info.xml2
-rw-r--r--apps/files_external/js/dropbox.js8
-rw-r--r--apps/files_external/js/google.js12
-rw-r--r--apps/files_external/js/settings.js8
-rw-r--r--apps/files_external/l10n/af_ZA.php3
-rw-r--r--apps/files_external/l10n/fa.php7
-rw-r--r--apps/files_external/l10n/fi_FI.php2
-rw-r--r--apps/files_external/l10n/ko.php4
-rw-r--r--apps/files_external/l10n/lv.php23
-rw-r--r--apps/files_external/l10n/pt_BR.php2
-rw-r--r--apps/files_external/l10n/ro.php8
-rw-r--r--apps/files_external/l10n/sk_SK.php2
-rw-r--r--apps/files_external/lib/amazons3.php79
-rwxr-xr-xapps/files_external/lib/config.php79
-rwxr-xr-xapps/files_external/lib/dropbox.php61
-rw-r--r--apps/files_external/lib/ftp.php21
-rw-r--r--apps/files_external/lib/google.php34
-rw-r--r--apps/files_external/lib/smb.php21
-rw-r--r--apps/files_external/lib/streamwrapper.php55
-rw-r--r--apps/files_external/lib/swift.php115
-rw-r--r--apps/files_external/lib/webdav.php87
-rwxr-xr-xapps/files_external/personal.php2
-rw-r--r--apps/files_external/tests/amazons3.php8
-rw-r--r--apps/files_external/tests/config.php4
-rw-r--r--apps/files_external/tests/dropbox.php6
-rw-r--r--apps/files_external/tests/ftp.php8
-rw-r--r--apps/files_external/tests/google.php5
-rw-r--r--apps/files_external/tests/smb.php9
-rw-r--r--apps/files_external/tests/swift.php6
-rw-r--r--apps/files_external/tests/webdav.php7
32 files changed, 427 insertions, 285 deletions
diff --git a/apps/files_external/ajax/addRootCertificate.php b/apps/files_external/ajax/addRootCertificate.php
index be60b415e1b..2f67e801b2c 100644
--- a/apps/files_external/ajax/addRootCertificate.php
+++ b/apps/files_external/ajax/addRootCertificate.php
@@ -12,8 +12,10 @@ $data = fread($fh, filesize($_FILES['rootcert_import']['tmp_name']));
fclose($fh);
$filename = $_FILES['rootcert_import']['name'];
-$view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_external/uploads');
-if ( ! $view->file_exists('')) $view->mkdir('');
+$view = new \OC\Files\View('/'.\OCP\User::getUser().'/files_external/uploads');
+if (!$view->file_exists('')){
+ $view->mkdir('');
+}
$isValid = openssl_pkey_get_public($data);
diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php
index cafd0637b8c..d976c017523 100644
--- a/apps/files_external/appinfo/app.php
+++ b/apps/files_external/appinfo/app.php
@@ -6,15 +6,15 @@
* See the COPYING-README file.
*/
-OC::$CLASSPATH['OC_FileStorage_StreamWrapper']='apps/files_external/lib/streamwrapper.php';
-OC::$CLASSPATH['OC_Filestorage_FTP']='apps/files_external/lib/ftp.php';
-OC::$CLASSPATH['OC_Filestorage_DAV']='apps/files_external/lib/webdav.php';
-OC::$CLASSPATH['OC_Filestorage_Google']='apps/files_external/lib/google.php';
-OC::$CLASSPATH['OC_Filestorage_SWIFT']='apps/files_external/lib/swift.php';
-OC::$CLASSPATH['OC_Filestorage_SMB']='apps/files_external/lib/smb.php';
-OC::$CLASSPATH['OC_Filestorage_AmazonS3']='apps/files_external/lib/amazons3.php';
-OC::$CLASSPATH['OC_Filestorage_Dropbox']='apps/files_external/lib/dropbox.php';
-OC::$CLASSPATH['OC_Filestorage_SFTP']='apps/files_external/lib/sftp.php';
+OC::$CLASSPATH['OC\Files\Storage\StreamWrapper']='apps/files_external/lib/streamwrapper.php';
+OC::$CLASSPATH['OC\Files\Storage\FTP']='apps/files_external/lib/ftp.php';
+OC::$CLASSPATH['OC\Files\Storage\DAV']='apps/files_external/lib/webdav.php';
+OC::$CLASSPATH['OC\Files\Storage\Google']='apps/files_external/lib/google.php';
+OC::$CLASSPATH['OC\Files\Storage\SWIFT']='apps/files_external/lib/swift.php';
+OC::$CLASSPATH['OC\Files\Storage\SMB']='apps/files_external/lib/smb.php';
+OC::$CLASSPATH['OC\Files\Storage\AmazonS3']='apps/files_external/lib/amazons3.php';
+OC::$CLASSPATH['OC\Files\Storage\Dropbox']='apps/files_external/lib/dropbox.php';
+OC::$CLASSPATH['OC\Files\Storage\SFTP']='apps/files_external/lib/sftp.php';
OC::$CLASSPATH['OC_Mount_Config']='apps/files_external/lib/config.php';
OCP\App::registerAdmin('files_external', 'settings');
diff --git a/apps/files_external/appinfo/info.xml b/apps/files_external/appinfo/info.xml
index 3da1913c5fc..2c04216a9fb 100644
--- a/apps/files_external/appinfo/info.xml
+++ b/apps/files_external/appinfo/info.xml
@@ -5,7 +5,7 @@
<description>Mount external storage sources</description>
<licence>AGPL</licence>
<author>Robin Appelman, Michael Gapczynski</author>
- <require>4.9</require>
+ <require>4.91</require>
<shipped>true</shipped>
<types>
<filesystem/>
diff --git a/apps/files_external/js/dropbox.js b/apps/files_external/js/dropbox.js
index c1e38640708..cd3c957e0a8 100644
--- a/apps/files_external/js/dropbox.js
+++ b/apps/files_external/js/dropbox.js
@@ -1,6 +1,6 @@
$(document).ready(function() {
- $('#externalStorage tbody tr.OC_Filestorage_Dropbox').each(function() {
+ $('#externalStorage tbody tr.\\\\OC\\\\Files\\\\Storage\\\\Dropbox').each(function() {
var configured = $(this).find('[data-parameter="configured"]');
if ($(configured).val() == 'true') {
$(this).find('.configuration input').attr('disabled', 'disabled');
@@ -36,9 +36,9 @@ $(document).ready(function() {
}
});
- $('#externalStorage tbody tr input').live('keyup', function() {
+ $('#externalStorage tbody').on('keyup', 'tr input', function() {
var tr = $(this).parent().parent();
- if ($(tr).hasClass('OC_Filestorage_Dropbox') && $(tr).find('[data-parameter="configured"]').val() != 'true') {
+ if ($(tr).hasClass('\\\\OC\\\\Files\\\\Storage\\\\Dropbox') && $(tr).find('[data-parameter="configured"]').val() != 'true') {
var config = $(tr).find('.configuration');
if ($(tr).find('.mountPoint input').val() != '' && $(config).find('[data-parameter="app_key"]').val() != '' && $(config).find('[data-parameter="app_secret"]').val() != '') {
if ($(tr).find('.dropbox').length == 0) {
@@ -52,7 +52,7 @@ $(document).ready(function() {
}
});
- $('.dropbox').live('click', function(event) {
+ $('.dropbox').on('click', function(event) {
event.preventDefault();
var app_key = $(this).parent().find('[data-parameter="app_key"]').val();
var app_secret = $(this).parent().find('[data-parameter="app_secret"]').val();
diff --git a/apps/files_external/js/google.js b/apps/files_external/js/google.js
index 0b3c314eb5d..9b7f9514f12 100644
--- a/apps/files_external/js/google.js
+++ b/apps/files_external/js/google.js
@@ -1,6 +1,6 @@
$(document).ready(function() {
- $('#externalStorage tbody tr.OC_Filestorage_Google').each(function() {
+ $('#externalStorage tbody tr.\\\\OC\\\\Files\\\\Storage\\\\Google').each(function() {
var configured = $(this).find('[data-parameter="configured"]');
if ($(configured).val() == 'true') {
$(this).find('.configuration')
@@ -33,8 +33,8 @@ $(document).ready(function() {
}
});
- $('#externalStorage tbody tr').live('change', function() {
- if ($(this).hasClass('OC_Filestorage_Google') && $(this).find('[data-parameter="configured"]').val() != 'true') {
+ $('#externalStorage tbody').on('change', 'tr', function() {
+ if ($(this).hasClass('\\\\OC\\\\Files\\\\Storage\\\\Google') && $(this).find('[data-parameter="configured"]').val() != 'true') {
if ($(this).find('.mountPoint input').val() != '') {
if ($(this).find('.google').length == 0) {
$(this).find('.configuration').append('<a class="button google">'+t('files_external', 'Grant access')+'</a>');
@@ -43,9 +43,9 @@ $(document).ready(function() {
}
});
- $('#externalStorage tbody tr .mountPoint input').live('keyup', function() {
+ $('#externalStorage tbody').on('keyup', 'tr .mountPoint input', function() {
var tr = $(this).parent().parent();
- if ($(tr).hasClass('OC_Filestorage_Google') && $(tr).find('[data-parameter="configured"]').val() != 'true' && $(tr).find('.google').length > 0) {
+ if ($(tr).hasClass('\\\\OC\\\\Files\\\\Storage\\\\Google') && $(tr).find('[data-parameter="configured"]').val() != 'true' && $(tr).find('.google').length > 0) {
if ($(this).val() != '') {
$(tr).find('.google').show();
} else {
@@ -54,7 +54,7 @@ $(document).ready(function() {
}
});
- $('.google').live('click', function(event) {
+ $('.google').on('click', function(event) {
event.preventDefault();
var tr = $(this).parent().parent();
var configured = $(this).parent().find('[data-parameter="configured"]');
diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js
index 0dc983ca8ad..172ef097fbf 100644
--- a/apps/files_external/js/settings.js
+++ b/apps/files_external/js/settings.js
@@ -71,7 +71,7 @@ OC.MountConfig={
$(document).ready(function() {
$('.chzn-select').chosen();
- $('#selectBackend').live('change', function() {
+ $('#selectBackend').on('change', function() {
var tr = $(this).parent().parent();
$('#externalStorage tbody').append($(tr).clone());
$('#externalStorage tbody tr').last().find('.mountPoint input').val('');
@@ -100,7 +100,7 @@ $(document).ready(function() {
td.append('<input type="text" data-parameter="'+parameter+'" placeholder="'+placeholder+'" />');
}
});
- if (parameters['custom'] && $('#externalStorage tbody tr.'+backendClass).length == 1) {
+ if (parameters['custom'] && $('#externalStorage tbody tr.'+backendClass.replace(/\\/g, '\\\\')).length == 1) {
OC.addScript('files_external', parameters['custom']);
}
return false;
@@ -135,11 +135,11 @@ $(document).ready(function() {
return defaultMountPoint+append;
}
- $('#externalStorage td').live('change', function() {
+ $('#externalStorage').on('change', 'td', function() {
OC.MountConfig.saveStorage($(this).parent());
});
- $('td.remove>img').live('click', function() {
+ $('td.remove>img').on('click', function() {
var tr = $(this).parent().parent();
var mountPoint = $(tr).find('.mountPoint input').val();
if ( ! mountPoint) {
diff --git a/apps/files_external/l10n/af_ZA.php b/apps/files_external/l10n/af_ZA.php
new file mode 100644
index 00000000000..cf9b951828d
--- /dev/null
+++ b/apps/files_external/l10n/af_ZA.php
@@ -0,0 +1,3 @@
+<?php $TRANSLATIONS = array(
+"Users" => "Gebruikers"
+);
diff --git a/apps/files_external/l10n/fa.php b/apps/files_external/l10n/fa.php
index b866201361a..5acf3eac5a5 100644
--- a/apps/files_external/l10n/fa.php
+++ b/apps/files_external/l10n/fa.php
@@ -1,5 +1,10 @@
<?php $TRANSLATIONS = array(
+"External Storage" => "حافظه خارجی",
+"Configuration" => "پیکربندی",
+"Options" => "تنظیمات",
+"Applicable" => "قابل اجرا",
"Groups" => "گروه ها",
"Users" => "کاربران",
-"Delete" => "حذف"
+"Delete" => "حذف",
+"Enable User External Storage" => "فعال سازی حافظه خارجی کاربر"
);
diff --git a/apps/files_external/l10n/fi_FI.php b/apps/files_external/l10n/fi_FI.php
index d7b16e0d3ee..8c7381db71d 100644
--- a/apps/files_external/l10n/fi_FI.php
+++ b/apps/files_external/l10n/fi_FI.php
@@ -4,6 +4,8 @@
"Grant access" => "Salli pääsy",
"Fill out all required fields" => "Täytä kaikki vaaditut kentät",
"Error configuring Google Drive storage" => "Virhe Google Drive levyn asetuksia tehtäessä",
+"<b>Warning:</b> \"smbclient\" is not installed. Mounting of CIFS/SMB shares is not possible. Please ask your system administrator to install it." => "<b>Varoitus:</b> \"smbclient\" ei ole asennettuna. CIFS-/SMB-jakojen liittäminen ei ole mahdollista. Pyydä järjestelmän ylläpitäjää asentamaan smbclient.",
+"<b>Warning:</b> The FTP support in PHP is not enabled or installed. Mounting of FTP shares is not possible. Please ask your system administrator to install it." => "<b>Varoitus:</b> PHP:n FTP-tuki ei ole käytössä tai sitä ei ole asennettu. FTP-jakojen liittäminen ei ole mahdollista. Pyydä järjestelmän ylläpitäjää ottamaan FTP-tuki käyttöön.",
"External Storage" => "Erillinen tallennusväline",
"Mount point" => "Liitospiste",
"Backend" => "Taustaosa",
diff --git a/apps/files_external/l10n/ko.php b/apps/files_external/l10n/ko.php
index cb691cf5e3d..47b75f74b86 100644
--- a/apps/files_external/l10n/ko.php
+++ b/apps/files_external/l10n/ko.php
@@ -5,8 +5,8 @@
"Fill out all required fields" => "모든 필수 항목을 입력하십시오",
"Please provide a valid Dropbox app key and secret." => "올바른 Dropbox 앱 키와 암호를 입력하십시오.",
"Error configuring Google Drive storage" => "Google 드라이브 저장소 설정 오류",
-"<b>Warning:</b> \"smbclient\" is not installed. Mounting of CIFS/SMB shares is not possible. Please ask your system administrator to install it." => "<b>경고</b>\"smbclient\"가 설치되지 않았습니다. CIFS/SMB 공유애 연결이 불가능 합니다.. 시스템 관리자에게 요청하여 설치하시기 바랍니다.",
-"<b>Warning:</b> The FTP support in PHP is not enabled or installed. Mounting of FTP shares is not possible. Please ask your system administrator to install it." => "<b>경고</b>PHP용 FTP 지원이 사용 불가능 하거나 설치되지 않았습니다. FTP 공유에 연결이 불가능 합니다. 시스템 관리자에게 요청하여 설치하시기 바랍니다. ",
+"<b>Warning:</b> \"smbclient\" is not installed. Mounting of CIFS/SMB shares is not possible. Please ask your system administrator to install it." => "<b>경고:</b> \"smbclient\"가 설치되지 않았습니다. CIFS/SMB 공유 자원에 연결할 수 없습니다. 시스템 관리자에게 설치를 요청하십시오.",
+"<b>Warning:</b> The FTP support in PHP is not enabled or installed. Mounting of FTP shares is not possible. Please ask your system administrator to install it." => "<b>경고:</b> PHP FTP 지원이 비활성화되어 있거나 설치되지 않았습니다. FTP 공유를 마운트할 수 없습니다. 시스템 관리자에게 설치를 요청하십시오.",
"External Storage" => "외부 저장소",
"Mount point" => "마운트 지점",
"Backend" => "백엔드",
diff --git a/apps/files_external/l10n/lv.php b/apps/files_external/l10n/lv.php
index 26452f98b01..ee53346fcde 100644
--- a/apps/files_external/l10n/lv.php
+++ b/apps/files_external/l10n/lv.php
@@ -1,5 +1,26 @@
<?php $TRANSLATIONS = array(
+"Access granted" => "Piešķirta pieeja",
+"Error configuring Dropbox storage" => "Kļūda, konfigurējot Dropbox krātuvi",
+"Grant access" => "Piešķirt pieeju",
+"Fill out all required fields" => "Aizpildīt visus pieprasītos laukus",
+"Please provide a valid Dropbox app key and secret." => "Lūdzu, norādiet derīgu Dropbox lietotnes atslēgu un noslēpumu.",
+"Error configuring Google Drive storage" => "Kļūda, konfigurējot Google Drive krātuvi",
+"<b>Warning:</b> \"smbclient\" is not installed. Mounting of CIFS/SMB shares is not possible. Please ask your system administrator to install it." => "<b>Brīdinājums:</b> nav uzinstalēts “smbclient”. Nevar montēt CIFS/SMB koplietojumus. Lūdzu, vaicājiet savam sistēmas administratoram, lai to uzinstalē.",
+"<b>Warning:</b> The FTP support in PHP is not enabled or installed. Mounting of FTP shares is not possible. Please ask your system administrator to install it." => "<b>Brīdinājums: </b> uz PHP nav aktivēts vai instalēts FTP atbalsts. Nevar montēt FTP koplietojumus. Lūdzu, vaicājiet savam sistēmas administratoram, lai to uzinstalē.",
+"External Storage" => "Ārējā krātuve",
+"Mount point" => "Montēšanas punkts",
+"Backend" => "Aizmugure",
+"Configuration" => "Konfigurācija",
+"Options" => "Opcijas",
+"Applicable" => "Piemērojams",
+"Add mount point" => "Pievienot montēšanas punktu",
+"None set" => "Neviens nav iestatīts",
+"All Users" => "Visi lietotāji",
"Groups" => "Grupas",
"Users" => "Lietotāji",
-"Delete" => "Izdzēst"
+"Delete" => "Dzēst",
+"Enable User External Storage" => "Aktivēt lietotāja ārējo krātuvi",
+"Allow users to mount their own external storage" => "Ļaut lietotājiem montēt pašiem savu ārējo krātuvi",
+"SSL root certificates" => "SSL saknes sertifikāti",
+"Import Root Certificate" => "Importēt saknes sertifikātus"
);
diff --git a/apps/files_external/l10n/pt_BR.php b/apps/files_external/l10n/pt_BR.php
index 26e927a423e..85393954886 100644
--- a/apps/files_external/l10n/pt_BR.php
+++ b/apps/files_external/l10n/pt_BR.php
@@ -5,6 +5,8 @@
"Fill out all required fields" => "Preencha todos os campos obrigatórios",
"Please provide a valid Dropbox app key and secret." => "Por favor forneça um app key e secret válido do Dropbox",
"Error configuring Google Drive storage" => "Erro ao configurar armazenamento do Google Drive",
+"<b>Warning:</b> \"smbclient\" is not installed. Mounting of CIFS/SMB shares is not possible. Please ask your system administrator to install it." => "<b>Aviso:</b> \"smbclient\" não está instalado. Não será possível montar compartilhamentos de CIFS/SMB. Por favor, peça ao seu administrador do sistema para instalá-lo.",
+"<b>Warning:</b> The FTP support in PHP is not enabled or installed. Mounting of FTP shares is not possible. Please ask your system administrator to install it." => "<b>Aviso:</b> O suporte para FTP do PHP não está ativado ou instalado. Não será possível montar compartilhamentos FTP. Por favor, peça ao seu administrador do sistema para instalá-lo.",
"External Storage" => "Armazenamento Externo",
"Mount point" => "Ponto de montagem",
"Backend" => "Backend",
diff --git a/apps/files_external/l10n/ro.php b/apps/files_external/l10n/ro.php
index 6a152786808..ca2c9f7e5c8 100644
--- a/apps/files_external/l10n/ro.php
+++ b/apps/files_external/l10n/ro.php
@@ -1,4 +1,12 @@
<?php $TRANSLATIONS = array(
+"Access granted" => "Acces permis",
+"Error configuring Dropbox storage" => "Eroare la configurarea mediului de stocare Dropbox",
+"Grant access" => "Permite accesul",
+"Fill out all required fields" => "Completează toate câmpurile necesare",
+"Please provide a valid Dropbox app key and secret." => "Prezintă te rog o cheie de Dropbox validă și parola",
+"Error configuring Google Drive storage" => "Eroare la configurarea mediului de stocare Google Drive",
+"<b>Warning:</b> \"smbclient\" is not installed. Mounting of CIFS/SMB shares is not possible. Please ask your system administrator to install it." => "<b>Atenție:</b> \"smbclient\" nu este instalat. Montarea mediilor CIFS/SMB partajate nu este posibilă. Solicită administratorului sistemului tău să îl instaleaze.",
+"<b>Warning:</b> The FTP support in PHP is not enabled or installed. Mounting of FTP shares is not possible. Please ask your system administrator to install it." => "<b>Atenție:</b> suportul pentru FTP în PHP nu este activat sau instalat. Montarea mediilor FPT partajate nu este posibilă. Solicită administratorului sistemului tău să îl instaleze.",
"External Storage" => "Stocare externă",
"Mount point" => "Punctul de montare",
"Backend" => "Backend",
diff --git a/apps/files_external/l10n/sk_SK.php b/apps/files_external/l10n/sk_SK.php
index 04d5e3c7ee4..0b6878a5427 100644
--- a/apps/files_external/l10n/sk_SK.php
+++ b/apps/files_external/l10n/sk_SK.php
@@ -5,6 +5,8 @@
"Fill out all required fields" => "Vyplňte všetky vyžadované kolónky",
"Please provide a valid Dropbox app key and secret." => "Zadajte platný kľúč aplikácie a heslo Dropbox",
"Error configuring Google Drive storage" => "Chyba pri konfigurácii úložiska Google drive",
+"<b>Warning:</b> \"smbclient\" is not installed. Mounting of CIFS/SMB shares is not possible. Please ask your system administrator to install it." => "<b>Upozornenie:</b> \"smbclient\" nie je nainštalovaný. Nie je možné pripojenie oddielov CIFS/SMB. Požiadajte administrátora systému, nech ho nainštaluje.",
+"<b>Warning:</b> The FTP support in PHP is not enabled or installed. Mounting of FTP shares is not possible. Please ask your system administrator to install it." => "<b>Upozornenie:</b> Podpora FTP v PHP nie je povolená alebo nainštalovaná. Nie je možné pripojenie oddielov FTP. Požiadajte administrátora systému, nech ho nainštaluje.",
"External Storage" => "Externé úložisko",
"Mount point" => "Prípojný bod",
"Backend" => "Backend",
diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php
index e5ef4eb097c..494885a1dd3 100644
--- a/apps/files_external/lib/amazons3.php
+++ b/apps/files_external/lib/amazons3.php
@@ -1,39 +1,43 @@
<?php
/**
-* ownCloud
-*
-* @author Michael Gapczynski
-* @copyright 2012 Michael Gapczynski mtgap@owncloud.com
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-* License as published by the Free Software Foundation; either
-* version 3 of the License, or any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
-*
-* You should have received a copy of the GNU Affero General Public
-* License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
+ * ownCloud
+ *
+ * @author Michael Gapczynski
+ * @copyright 2012 Michael Gapczynski mtgap@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace OC\Files\Storage;
require_once 'aws-sdk/sdk.class.php';
-class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
+class AmazonS3 extends \OC\Files\Storage\Common {
private $s3;
private $bucket;
private $objects = array();
+ private $id;
private static $tempFiles = array();
// TODO options: storage class, encryption server side, encrypt before upload?
public function __construct($params) {
- $this->s3 = new AmazonS3(array('key' => $params['key'], 'secret' => $params['secret']));
+ $this->id = 'amazon::' . $params['key'] . md5($params['secret']);
+ $this->s3 = new \AmazonS3(array('key' => $params['key'], 'secret' => $params['secret']));
$this->bucket = $params['bucket'];
}
@@ -47,7 +51,7 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
return $response;
// This object could be a folder, a '/' must be at the end of the path
} else if (substr($path, -1) != '/') {
- $response = $this->s3->get_object_metadata($this->bucket, $path.'/');
+ $response = $this->s3->get_object_metadata($this->bucket, $path . '/');
if ($response) {
$this->objects[$path] = $response;
return $response;
@@ -57,6 +61,10 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
return false;
}
+ public function getId() {
+ return $this->id;
+ }
+
public function mkdir($path) {
// Folders in Amazon S3 are 0 byte objects with a '/' at the end of the name
if (substr($path, -1) != '/') {
@@ -96,8 +104,8 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
foreach ($response->body->CommonPrefixes as $object) {
$files[] = basename($object->Prefix);
}
- OC_FakeDirStream::$dirs['amazons3'.$path] = $files;
- return opendir('fakedir://amazons3'.$path);
+ \OC\Files\Stream\Dir::register('amazons3' . $path, $files);
+ return opendir('fakedir://amazons3' . $path);
}
return false;
}
@@ -107,15 +115,10 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
$stat['size'] = $this->s3->get_bucket_filesize($this->bucket);
$stat['atime'] = time();
$stat['mtime'] = $stat['atime'];
- $stat['ctime'] = $stat['atime'];
- } else {
- $object = $this->getObject($path);
- if ($object) {
- $stat['size'] = $object['Size'];
- $stat['atime'] = time();
- $stat['mtime'] = strtotime($object['LastModified']);
- $stat['ctime'] = $stat['mtime'];
- }
+ } else if ($object = $this->getObject($path)) {
+ $stat['size'] = $object['Size'];
+ $stat['atime'] = time();
+ $stat['mtime'] = strtotime($object['LastModified']);
}
if (isset($stat)) {
return $stat;
@@ -166,7 +169,7 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
switch ($mode) {
case 'r':
case 'rb':
- $tmpFile = OC_Helper::tmpFile();
+ $tmpFile = \OC_Helper::tmpFile();
$handle = fopen($tmpFile, 'w');
$response = $this->s3->get_object($this->bucket, $path, array('fileDownload' => $handle));
if ($response->isOK()) {
@@ -190,14 +193,14 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
} else {
$ext = '';
}
- $tmpFile = OC_Helper::tmpFile($ext);
- OC_CloseStreamWrapper::$callBacks[$tmpFile] = array($this, 'writeBack');
+ $tmpFile = \OC_Helper::tmpFile($ext);
+ \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
file_put_contents($tmpFile, $source);
}
self::$tempFiles[$tmpFile] = $path;
- return fopen('close://'.$tmpFile, $mode);
+ return fopen('close://' . $tmpFile, $mode);
}
return false;
}
@@ -206,8 +209,8 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
if (isset(self::$tempFiles[$tmpFile])) {
$handle = fopen($tmpFile, 'r');
$response = $this->s3->create_object($this->bucket,
- self::$tempFiles[$tmpFile],
- array('fileUpload' => $handle));
+ self::$tempFiles[$tmpFile],
+ array('fileUpload' => $handle));
if ($response->isOK()) {
unlink($tmpFile);
}
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 2038939153c..47f0810ec54 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -38,20 +38,20 @@ class OC_Mount_Config {
* @return array
*/
public static function getBackends() {
-
- $backends['OC_Filestorage_Local']=array(
+
+ $backends['\OC\Files\Storage\Local']=array(
'backend' => 'Local',
'configuration' => array(
'datadir' => 'Location'));
- $backends['OC_Filestorage_AmazonS3']=array(
+ $backends['\OC\Files\Storage\AmazonS3']=array(
'backend' => 'Amazon S3',
'configuration' => array(
'key' => 'Key',
'secret' => '*Secret',
'bucket' => 'Bucket'));
- $backends['OC_Filestorage_Dropbox']=array(
+ $backends['\OC\Files\Storage\Dropbox']=array(
'backend' => 'Dropbox',
'configuration' => array(
'configured' => '#configured',
@@ -61,7 +61,7 @@ class OC_Mount_Config {
'token_secret' => '#token_secret'),
'custom' => 'dropbox');
- if(OC_Mount_Config::checkphpftp()) $backends['OC_Filestorage_FTP']=array(
+ if(OC_Mount_Config::checkphpftp()) $backends['\OC\Files\Storage\FTP']=array(
'backend' => 'FTP',
'configuration' => array(
'host' => 'URL',
@@ -70,15 +70,15 @@ class OC_Mount_Config {
'root' => '&Root',
'secure' => '!Secure ftps://'));
- $backends['OC_Filestorage_Google']=array(
+ $backends['\OC\Files\Storage\Google']=array(
'backend' => 'Google Drive',
'configuration' => array(
'configured' => '#configured',
'token' => '#token',
'token_secret' => '#token secret'),
'custom' => 'google');
-
- $backends['OC_Filestorage_SWIFT']=array(
+
+ $backends['\OC\Files\Storage\SWIFT']=array(
'backend' => 'OpenStack Swift',
'configuration' => array(
'host' => 'URL',
@@ -86,8 +86,8 @@ class OC_Mount_Config {
'token' => '*Token',
'root' => '&Root',
'secure' => '!Secure ftps://'));
-
- if(OC_Mount_Config::checksmbclient()) $backends['OC_Filestorage_SMB']=array(
+
+ if(OC_Mount_Config::checksmbclient()) $backends['\OC\Files\Storage\SMB']=array(
'backend' => 'SMB / CIFS',
'configuration' => array(
'host' => 'URL',
@@ -95,8 +95,8 @@ class OC_Mount_Config {
'password' => '*Password',
'share' => 'Share',
'root' => '&Root'));
-
- $backends['OC_Filestorage_DAV']=array(
+
+ $backends['\OC\Files\Storage\DAV']=array(
'backend' => 'ownCloud / WebDAV',
'configuration' => array(
'host' => 'URL',
@@ -128,6 +128,10 @@ class OC_Mount_Config {
if (isset($mountPoints[self::MOUNT_TYPE_GROUP])) {
foreach ($mountPoints[self::MOUNT_TYPE_GROUP] as $group => $mounts) {
foreach ($mounts as $mountPoint => $mount) {
+ // Update old classes to new namespace
+ if (strpos($mount['class'], 'OC_Filestorage_') !== false) {
+ $mount['class'] = '\OC\Files\Storage\\'.substr($mount['class'], 15);
+ }
// Remove '/$user/files/' from mount point
$mountPoint = substr($mountPoint, 13);
// Merge the mount point into the current mount points
@@ -147,6 +151,10 @@ class OC_Mount_Config {
if (isset($mountPoints[self::MOUNT_TYPE_USER])) {
foreach ($mountPoints[self::MOUNT_TYPE_USER] as $user => $mounts) {
foreach ($mounts as $mountPoint => $mount) {
+ // Update old classes to new namespace
+ if (strpos($mount['class'], 'OC_Filestorage_') !== false) {
+ $mount['class'] = '\OC\Files\Storage\\'.substr($mount['class'], 15);
+ }
// Remove '/$user/files/' from mount point
$mountPoint = substr($mountPoint, 13);
// Merge the mount point into the current mount points
@@ -177,6 +185,10 @@ class OC_Mount_Config {
$personal = array();
if (isset($mountPoints[self::MOUNT_TYPE_USER][$uid])) {
foreach ($mountPoints[self::MOUNT_TYPE_USER][$uid] as $mountPoint => $mount) {
+ // Update old classes to new namespace
+ if (strpos($mount['class'], 'OC_Filestorage_') !== false) {
+ $mount['class'] = '\OC\Files\Storage\\'.substr($mount['class'], 15);
+ }
// Remove '/uid/files/' from mount point
$personal[substr($mountPoint, strlen($uid) + 8)] = array('class' => $mount['class'],
'backend' => $backends[$mount['class']]['backend'],
@@ -187,22 +199,6 @@ class OC_Mount_Config {
}
/**
- * Add directory for mount point to the filesystem
- * @param OC_Fileview instance $view
- * @param string path to mount point
- */
- private static function addMountPointDirectory($view, $path) {
- $dir = '';
- foreach ( explode('/', $path) as $pathPart) {
- $dir = $dir.'/'.$pathPart;
- if ( !$view->file_exists($dir)) {
- $view->mkdir($dir);
- }
- }
- }
-
-
- /**
* Add a mount point to the filesystem
* @param string Mount point
* @param string Backend class
@@ -221,36 +217,11 @@ class OC_Mount_Config {
if ($isPersonal) {
// Verify that the mount point applies for the current user
// Prevent non-admin users from mounting local storage
- if ($applicable != OCP\User::getUser() || $class == 'OC_Filestorage_Local') {
+ if ($applicable != OCP\User::getUser() || $class == '\OC\Files\Storage\Local') {
return false;
}
- $view = new OC_FilesystemView('/'.OCP\User::getUser().'/files');
- self::addMountPointDirectory($view, ltrim($mountPoint, '/'));
$mountPoint = '/'.$applicable.'/files/'.ltrim($mountPoint, '/');
} else {
- $view = new OC_FilesystemView('/');
- switch ($mountType) {
- case 'user':
- if ($applicable == "all") {
- $users = OCP\User::getUsers();
- foreach ( $users as $user ) {
- $path = $user.'/files/'.ltrim($mountPoint, '/');
- self::addMountPointDirectory($view, $path);
- }
- } else {
- $path = $applicable.'/files/'.ltrim($mountPoint, '/');
- self::addMountPointDirectory($view, $path);
- }
- break;
- case 'group' :
- $groupMembers = OC_Group::usersInGroups(array($applicable));
- foreach ( $groupMembers as $user ) {
- $path = $user.'/files/'.ltrim($mountPoint, '/');
- self::addMountPointDirectory($view, $path);
- }
- break;
- }
-
$mountPoint = '/$user/files/'.ltrim($mountPoint, '/');
}
$mount = array($applicable => array($mountPoint => array('class' => $class, 'options' => $classOptions)));
diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php
index 33ca14cab15..11644e4a2c8 100755
--- a/apps/files_external/lib/dropbox.php
+++ b/apps/files_external/lib/dropbox.php
@@ -20,12 +20,15 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+namespace OC\Files\Storage;
+
require_once 'Dropbox/autoload.php';
-class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
+class Dropbox extends \OC\Files\Storage\Common {
private $dropbox;
private $root;
+ private $id;
private $metaData = array();
private static $tempFiles = array();
@@ -37,13 +40,14 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
&& isset($params['token'])
&& isset($params['token_secret'])
) {
+ $this->id = 'dropbox::'.$params['app_key'] . $params['token']. '/' . $params['root'];
$this->root=isset($params['root'])?$params['root']:'';
- $oauth = new Dropbox_OAuth_Curl($params['app_key'], $params['app_secret']);
+ $oauth = new \Dropbox_OAuth_Curl($params['app_key'], $params['app_secret']);
$oauth->setToken($params['token'], $params['token_secret']);
- $this->dropbox = new Dropbox_API($oauth, 'dropbox');
+ $this->dropbox = new \Dropbox_API($oauth, 'dropbox');
$this->mkdir('');
} else {
- throw new Exception('Creating OC_Filestorage_Dropbox storage failed');
+ throw new \Exception('Creating \OC\Files\Storage\Dropbox storage failed');
}
}
@@ -55,8 +59,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
if ($list) {
try {
$response = $this->dropbox->getMetaData($path);
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
if ($response && isset($response['contents'])) {
@@ -76,21 +80,25 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$response = $this->dropbox->getMetaData($path, 'false');
$this->metaData[$path] = $response;
return $response;
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
}
}
}
+ public function getId(){
+ return $this->id;
+ }
+
public function mkdir($path) {
$path = $this->root.$path;
try {
$this->dropbox->createFolder($path);
return true;
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
}
@@ -106,7 +114,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
foreach ($contents as $file) {
$files[] = basename($file['path']);
}
- OC_FakeDirStream::$dirs['dropbox'.$path] = $files;
+ \OC\Files\Stream\Dir::register('dropbox'.$path, $files);
return opendir('fakedir://dropbox'.$path);
}
return false;
@@ -118,7 +126,6 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$stat['size'] = $metaData['bytes'];
$stat['atime'] = time();
$stat['mtime'] = (isset($metaData['modified'])) ? strtotime($metaData['modified']) : time();
- $stat['ctime'] = $stat['mtime'];
return $stat;
}
return false;
@@ -163,8 +170,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
try {
$this->dropbox->delete($path);
return true;
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
}
@@ -175,8 +182,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
try {
$this->dropbox->move($path1, $path2);
return true;
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
}
@@ -187,8 +194,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
try {
$this->dropbox->copy($path1, $path2);
return true;
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
}
@@ -198,13 +205,13 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
switch ($mode) {
case 'r':
case 'rb':
- $tmpFile = OC_Helper::tmpFile();
+ $tmpFile = \OC_Helper::tmpFile();
try {
$data = $this->dropbox->getFile($path);
file_put_contents($tmpFile, $data);
return fopen($tmpFile, 'r');
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
case 'w':
@@ -224,8 +231,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
} else {
$ext = '';
}
- $tmpFile = OC_Helper::tmpFile($ext);
- OC_CloseStreamWrapper::$callBacks[$tmpFile] = array($this, 'writeBack');
+ $tmpFile = \OC_Helper::tmpFile($ext);
+ \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
file_put_contents($tmpFile, $source);
@@ -242,8 +249,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
try {
$this->dropbox->putFile(self::$tempFiles[$tmpFile], $handle);
unlink($tmpFile);
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
}
}
}
@@ -264,8 +271,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
try {
$info = $this->dropbox->getAccountInfo();
return $info['quota_info']['quota'] - $info['quota_info']['normal'];
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
}
diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php
index e796ae446bf..9a27b63323a 100644
--- a/apps/files_external/lib/ftp.php
+++ b/apps/files_external/lib/ftp.php
@@ -6,7 +6,9 @@
* See the COPYING-README file.
*/
-class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
+namespace OC\Files\Storage;
+
+class FTP extends \OC\Files\Storage\StreamWrapper{
private $password;
private $user;
private $host;
@@ -38,9 +40,13 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
}
}
+ public function getId(){
+ return 'ftp::' . $this->user . '@' . $this->host . '/' . $this->root;
+ }
+
/**
* construct the ftp url
- * @param string path
+ * @param string $path
* @return string
*/
public function constructUrl($path) {
@@ -51,7 +57,8 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
$url.='://'.$this->user.':'.$this->password.'@'.$this->host.$this->root.$path;
return $url;
}
- public function fopen($path, $mode) {
+ public function fopen($path,$mode) {
+ $this->init();
switch($mode) {
case 'r':
case 'rb':
@@ -61,7 +68,7 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
case 'ab':
//these are supported by the wrapper
$context = stream_context_create(array('ftp' => array('overwrite' => true)));
- return fopen($this->constructUrl($path), $mode, false, $context);
+ return fopen($this->constructUrl($path),$mode, false,$context);
case 'r+':
case 'w+':
case 'wb+':
@@ -77,16 +84,18 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
$ext='';
}
$tmpFile=OCP\Files::tmpFile($ext);
- OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack');
+ \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$this->getFile($path, $tmpFile);
}
self::$tempFiles[$tmpFile]=$path;
- return fopen('close://'.$tmpFile, $mode);
+ return fopen('close://'.$tmpFile,$mode);
}
+ return false;
}
public function writeBack($tmpFile) {
+ $this->init();
if (isset(self::$tempFiles[$tmpFile])) {
$this->uploadFile($tmpFile, self::$tempFiles[$tmpFile]);
unlink($tmpFile);
diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php
index c836a5a07c0..7396c7e3f27 100644
--- a/apps/files_external/lib/google.php
+++ b/apps/files_external/lib/google.php
@@ -20,14 +20,17 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+namespace OC\Files\Storage;
+
require_once 'Google/common.inc.php';
-class OC_Filestorage_Google extends OC_Filestorage_Common {
+class Google extends \OC\Files\Storage\Common {
private $consumer;
private $oauth_token;
private $sig_method;
private $entries;
+ private $id;
private static $tempFiles = array();
@@ -38,12 +41,13 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
) {
$consumer_key = isset($params['consumer_key']) ? $params['consumer_key'] : 'anonymous';
$consumer_secret = isset($params['consumer_secret']) ? $params['consumer_secret'] : 'anonymous';
- $this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
- $this->oauth_token = new OAuthToken($params['token'], $params['token_secret']);
- $this->sig_method = new OAuthSignatureMethod_HMAC_SHA1();
+ $this->id = 'google::' . $params['token'];
+ $this->consumer = new \OAuthConsumer($consumer_key, $consumer_secret);
+ $this->oauth_token = new \OAuthToken($params['token'], $params['token_secret']);
+ $this->sig_method = new \OAuthSignatureMethod_HMAC_SHA1();
$this->entries = array();
} else {
- throw new Exception('Creating OC_Filestorage_Google storage failed');
+ throw new \Exception('Creating \OC\Files\Storage\Google storage failed');
}
}
@@ -68,7 +72,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
$tempStr .= '&' . urlencode($key) . '=' . urlencode($value);
}
$uri = preg_replace('/&/', '?', $tempStr, 1);
- $request = OAuthRequest::from_consumer_and_token($this->consumer,
+ $request = \OAuthRequest::from_consumer_and_token($this->consumer,
$this->oauth_token,
$httpMethod,
$uri,
@@ -110,7 +114,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
}
if ($isDownload) {
- $tmpFile = OC_Helper::tmpFile();
+ $tmpFile = \OC_Helper::tmpFile();
$handle = fopen($tmpFile, 'w');
curl_setopt($curl, CURLOPT_FILE, $handle);
}
@@ -139,7 +143,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
private function getFeed($feedUri, $httpMethod, $postData = null) {
$result = $this->sendRequest($feedUri, $httpMethod, $postData);
if ($result) {
- $dom = new DOMDocument();
+ $dom = new \DOMDocument();
$dom->loadXML($result);
return $dom;
}
@@ -194,6 +198,9 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
}
}
+ public function getId(){
+ return $this->id;
+ }
public function mkdir($path) {
$collection = dirname($path);
@@ -266,7 +273,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
$this->entries[$name] = $entry;
}
}
- OC_FakeDirStream::$dirs['google'.$path] = $files;
+ \OC\Files\Stream\Dir::register('google'.$path, $files);
return opendir('fakedir://google'.$path);
}
@@ -287,7 +294,6 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
//$stat['atime'] = strtotime($entry->getElementsByTagNameNS('http://schemas.google.com/g/2005',
// 'lastViewed')->item(0)->nodeValue);
$stat['mtime'] = strtotime($entry->getElementsByTagName('updated')->item(0)->nodeValue);
- $stat['ctime'] = strtotime($entry->getElementsByTagName('published')->item(0)->nodeValue);
}
}
if (isset($stat)) {
@@ -443,8 +449,8 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
} else {
$ext = '';
}
- $tmpFile = OC_Helper::tmpFile($ext);
- OC_CloseStreamWrapper::$callBacks[$tmpFile] = array($this, 'writeBack');
+ $tmpFile = \OC_Helper::tmpFile($ext);
+ \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
file_put_contents($tmpFile, $source);
@@ -482,7 +488,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
}
if (isset($uploadUri) && $handle = fopen($path, 'r')) {
$uploadUri .= '?convert=false';
- $mimetype = OC_Helper::getMimeType($path);
+ $mimetype = \OC_Helper::getMimeType($path);
$size = filesize($path);
$headers = array('X-Upload-Content-Type: ' => $mimetype, 'X-Upload-Content-Length: ' => $size);
$postData = '<?xml version="1.0" encoding="UTF-8"?>';
@@ -590,4 +596,4 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
}
-} \ No newline at end of file
+}
diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php
index 071a9cd5f95..96778b0b2e1 100644
--- a/apps/files_external/lib/smb.php
+++ b/apps/files_external/lib/smb.php
@@ -6,9 +6,11 @@
* See the COPYING-README file.
*/
+namespace OC\Files\Storage;
+
require_once 'smb4php/smb.php';
-class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
+class SMB extends \OC\Files\Storage\StreamWrapper{
private $password;
private $user;
private $host;
@@ -30,14 +32,13 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
if ( ! $this->share || $this->share[0]!='/') {
$this->share='/'.$this->share;
}
- if (substr($this->share, -1, 1)=='/') {
- $this->share=substr($this->share, 0, -1);
+ if(substr($this->share, -1, 1)=='/') {
+ $this->share = substr($this->share,0,-1);
}
+ }
- //create the root folder if necesary
- if ( ! $this->is_dir('')) {
- $this->mkdir('');
- }
+ public function getId(){
+ return 'smb::' . $this->user . '@' . $this->host . '/' . $this->share . '/' . $this->root;
}
public function constructUrl($path) {
@@ -65,11 +66,13 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
/**
* check if a file or folder has been updated since $time
+ * @param string $path
* @param int $time
* @return bool
*/
- public function hasUpdated($path, $time) {
- if ( ! $path and $this->root=='/') {
+ public function hasUpdated($path,$time) {
+ $this->init();
+ if(!$path and $this->root=='/') {
// mtime doesn't work for shares, but giving the nature of the backend,
// doing a full update is still just fast enough
return true;
diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php
index a386e333995..7c3ddcf8a2c 100644
--- a/apps/files_external/lib/streamwrapper.php
+++ b/apps/files_external/lib/streamwrapper.php
@@ -6,16 +6,33 @@
* See the COPYING-README file.
*/
+namespace OC\Files\Storage;
+
+abstract class StreamWrapper extends \OC\Files\Storage\Common{
+ private $ready = false;
+
+ protected function init(){
+ if($this->ready){
+ return;
+ }
+ $this->ready = true;
+
+ //create the root folder if necesary
+ if(!$this->is_dir('')) {
+ $this->mkdir('');
+ }
+ }
-abstract class OC_FileStorage_StreamWrapper extends OC_Filestorage_Common{
abstract public function constructUrl($path);
public function mkdir($path) {
+ $this->init();
return mkdir($this->constructUrl($path));
}
public function rmdir($path) {
- if ($this->file_exists($path)) {
+ $this->init();
+ if($this->file_exists($path)) {
$succes = rmdir($this->constructUrl($path));
clearstatcache();
return $succes;
@@ -25,10 +42,12 @@ abstract class OC_FileStorage_StreamWrapper extends OC_Filestorage_Common{
}
public function opendir($path) {
+ $this->init();
return opendir($this->constructUrl($path));
}
public function filetype($path) {
+ $this->init();
return filetype($this->constructUrl($path));
}
@@ -41,46 +60,54 @@ abstract class OC_FileStorage_StreamWrapper extends OC_Filestorage_Common{
}
public function file_exists($path) {
+ $this->init();
return file_exists($this->constructUrl($path));
}
public function unlink($path) {
+ $this->init();
$succes = unlink($this->constructUrl($path));
clearstatcache();
return $succes;
}
- public function fopen($path, $mode) {
- return fopen($this->constructUrl($path), $mode);
+ public function fopen($path,$mode) {
+ $this->init();
+ return fopen($this->constructUrl($path),$mode);
}
public function free_space($path) {
return 0;
}
- public function touch($path, $mtime = null) {
- if (is_null($mtime)) {
- $fh = $this->fopen($path, 'a');
- fwrite($fh, '');
+ public function touch($path,$mtime=null) {
+ $this->init();
+ if(is_null($mtime)) {
+ $fh = $this->fopen($path,'a');
+ fwrite($fh,'');
fclose($fh);
} else {
return false;//not supported
}
}
- public function getFile($path, $target) {
- return copy($this->constructUrl($path), $target);
+ public function getFile($path,$target) {
+ $this->init();
+ return copy($this->constructUrl($path),$target);
}
- public function uploadFile($path, $target) {
- return copy($path, $this->constructUrl($target));
+ public function uploadFile($path,$target) {
+ $this->init();
+ return copy($path,$this->constructUrl($target));
}
- public function rename($path1, $path2) {
- return rename($this->constructUrl($path1), $this->constructUrl($path2));
+ public function rename($path1,$path2) {
+ $this->init();
+ return rename($this->constructUrl($path1),$this->constructUrl($path2));
}
public function stat($path) {
+ $this->init();
return stat($this->constructUrl($path));
}
diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php
index a071dfdbb03..cbf2007052b 100644
--- a/apps/files_external/lib/swift.php
+++ b/apps/files_external/lib/swift.php
@@ -6,24 +6,28 @@
* See the COPYING-README file.
*/
+namespace OC\Files\Storage;
+
require_once 'php-cloudfiles/cloudfiles.php';
-class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
+class SWIFT extends \OC\Files\Storage\Common{
+ private $id;
private $host;
private $root;
private $user;
private $token;
private $secure;
+ private $ready = false;
/**
- * @var CF_Authentication auth
+ * @var \CF_Authentication auth
*/
private $auth;
/**
- * @var CF_Connection conn
+ * @var \CF_Connection conn
*/
private $conn;
/**
- * @var CF_Container rootContainer
+ * @var \CF_Container rootContainer
*/
private $rootContainer;
@@ -35,18 +39,18 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
/**
* translate directory path to container name
- * @param string path
+ * @param string $path
* @return string
*/
private function getContainerName($path) {
- $path=trim(trim($this->root, '/')."/".$path, '/.');
+ $path=trim(trim($this->root, '/') . "/".$path, '/.');
return str_replace('/', '\\', $path);
}
/**
* get container by path
- * @param string path
- * @return CF_Container
+ * @param string $path
+ * @return \CF_Container
*/
private function getContainer($path) {
if ($path=='' or $path=='/') {
@@ -59,15 +63,15 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
$container=$this->conn->get_container($this->getContainerName($path));
$this->containers[$path]=$container;
return $container;
- } catch(NoSuchContainerException $e) {
+ } catch(\NoSuchContainerException $e) {
return null;
}
}
/**
* create container
- * @param string path
- * @return CF_Container
+ * @param string $path
+ * @return \CF_Container
*/
private function createContainer($path) {
if ($path=='' or $path=='/' or $path=='.') {
@@ -89,8 +93,8 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
/**
* get object by path
- * @param string path
- * @return CF_Object
+ * @param string $path
+ * @return \CF_Object
*/
private function getObject($path) {
if (isset($this->objects[$path])) {
@@ -107,7 +111,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
$obj=$container->get_object(basename($path));
$this->objects[$path]=$obj;
return $obj;
- } catch(NoSuchObjectException $e) {
+ } catch(\NoSuchObjectException $e) {
return null;
}
}
@@ -132,8 +136,8 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
/**
* create object
- * @param string path
- * @return CF_Object
+ * @param string $path
+ * @return \CF_Object
*/
private function createObject($path) {
$container=$this->getContainer(dirname($path));
@@ -154,7 +158,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
/**
* check if container for path exists
- * @param string path
+ * @param string $path
* @return bool
*/
private function containerExists($path) {
@@ -163,15 +167,15 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
/**
* get the list of emulated sub containers
- * @param CF_Container container
+ * @param \CF_Container $container
* @return array
*/
private function getSubContainers($container) {
- $tmpFile=OCP\Files::tmpFile();
+ $tmpFile=\OCP\Files::tmpFile();
$obj=$this->getSubContainerFile($container);
try {
$obj->save_to_filename($tmpFile);
- } catch(Exception $e) {
+ } catch(\Exception $e) {
return array();
}
$obj->save_to_filename($tmpFile);
@@ -185,15 +189,15 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
/**
* add an emulated sub container
- * @param CF_Container container
- * @param string name
+ * @param \CF_Container $container
+ * @param string $name
* @return bool
*/
private function addSubContainer($container, $name) {
if ( ! $name) {
return false;
}
- $tmpFile=OCP\Files::tmpFile();
+ $tmpFile=\OCP\Files::tmpFile();
$obj=$this->getSubContainerFile($container);
try {
$obj->save_to_filename($tmpFile);
@@ -201,16 +205,15 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
foreach ($containers as &$sub) {
$sub=trim($sub);
}
- if (array_search($name, $containers)!==false) {
+ if(array_search($name, $containers) !== false) {
unlink($tmpFile);
return false;
} else {
$fh=fopen($tmpFile, 'a');
- fwrite($fh, $name."\n");
+ fwrite($fh,$name . "\n");
}
- } catch(Exception $e) {
- $containers=array();
- file_put_contents($tmpFile, $name."\n");
+ } catch(\Exception $e) {
+ file_put_contents($tmpFile, $name . "\n");
}
$obj->load_from_filename($tmpFile);
@@ -220,20 +223,20 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
/**
* remove an emulated sub container
- * @param CF_Container container
- * @param string name
+ * @param \CF_Container $container
+ * @param string $name
* @return bool
*/
private function removeSubContainer($container, $name) {
if ( ! $name) {
return false;
}
- $tmpFile=OCP\Files::tmpFile();
+ $tmpFile=\OCP\Files::tmpFile();
$obj=$this->getSubContainerFile($container);
try {
$obj->save_to_filename($tmpFile);
$containers=file($tmpFile);
- } catch (Exception $e) {
+ } catch (\Exception $e) {
return false;
}
foreach ($containers as &$sub) {
@@ -255,8 +258,8 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
/**
* ensure a subcontainer file exists and return it's object
- * @param CF_Container container
- * @return CF_Object
+ * @param \CF_Container $container
+ * @return \CF_Object
*/
private function getSubContainerFile($container) {
try {
@@ -283,10 +286,19 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
if ( ! $this->root || $this->root[0]!='/') {
$this->root='/'.$this->root;
}
- $this->auth = new CF_Authentication($this->user, $this->token, null, $this->host);
+
+ }
+
+ private function init(){
+ if($this->ready){
+ return;
+ }
+ $this->ready = true;
+
+ $this->auth = new \CF_Authentication($this->user, $this->token, null, $this->host);
$this->auth->authenticate();
- $this->conn = new CF_Connection($this->auth);
+ $this->conn = new \CF_Connection($this->auth);
if ( ! $this->containerExists('/')) {
$this->rootContainer=$this->createContainer('/');
@@ -295,8 +307,13 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
}
}
+ public function getId(){
+ return $this->id;
+ }
+
public function mkdir($path) {
+ $this->init();
if ($this->containerExists($path)) {
return false;
} else {
@@ -306,7 +323,8 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
}
public function rmdir($path) {
- if ( ! $this->containerExists($path)) {
+ $this->init();
+ if (!$this->containerExists($path)) {
return false;
} else {
$this->emptyContainer($path);
@@ -343,6 +361,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
}
public function opendir($path) {
+ $this->init();
$container=$this->getContainer($path);
$files=$this->getObjects($container);
$i=array_search(self::SUBCONTAINER_FILE, $files);
@@ -352,11 +371,12 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
$subContainers=$this->getSubContainers($container);
$files=array_merge($files, $subContainers);
$id=$this->getContainerName($path);
- OC_FakeDirStream::$dirs[$id]=$files;
+ \OC\Files\Stream\Dir::register($id, $files);
return opendir('fakedir://'.$id);
}
public function filetype($path) {
+ $this->init();
if ($this->containerExists($path)) {
return 'dir';
} else {
@@ -373,6 +393,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
}
public function file_exists($path) {
+ $this->init();
if ($this->is_dir($path)) {
return true;
} else {
@@ -381,6 +402,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
}
public function file_get_contents($path) {
+ $this->init();
$obj=$this->getObject($path);
if (is_null($obj)) {
return false;
@@ -389,6 +411,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
}
public function file_put_contents($path, $content) {
+ $this->init();
$obj=$this->getObject($path);
if (is_null($obj)) {
$container=$this->getContainer(dirname($path));
@@ -402,6 +425,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
}
public function unlink($path) {
+ $this->init();
if ($this->containerExists($path)) {
return $this->rmdir($path);
}
@@ -415,6 +439,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
}
public function fopen($path, $mode) {
+ $this->init();
switch($mode) {
case 'r':
case 'rb':
@@ -440,7 +465,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
case 'c':
case 'c+':
$tmpFile=$this->getTmpFile($path);
- OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack');
+ \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
self::$tempFiles[$tmpFile]=$path;
return fopen('close://'.$tmpFile, $mode);
}
@@ -458,6 +483,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
}
public function touch($path, $mtime=null) {
+ $this->init();
$obj=$this->getObject($path);
if (is_null($obj)) {
return false;
@@ -472,6 +498,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
}
public function rename($path1, $path2) {
+ $this->init();
$sourceContainer=$this->getContainer(dirname($path1));
$targetContainer=$this->getContainer(dirname($path2));
$result=$sourceContainer->move_object_to(basename($path1), $targetContainer, basename($path2));
@@ -484,6 +511,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
}
public function copy($path1, $path2) {
+ $this->init();
$sourceContainer=$this->getContainer(dirname($path1));
$targetContainer=$this->getContainer(dirname($path2));
$result=$sourceContainer->copy_object_to(basename($path1), $targetContainer, basename($path2));
@@ -495,6 +523,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
}
public function stat($path) {
+ $this->init();
$container=$this->getContainer($path);
if ( ! is_null($container)) {
return array(
@@ -523,17 +552,19 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
}
private function getTmpFile($path) {
+ $this->init();
$obj=$this->getObject($path);
if ( ! is_null($obj)) {
- $tmpFile=OCP\Files::tmpFile();
+ $tmpFile=\OCP\Files::tmpFile();
$obj->save_to_filename($tmpFile);
return $tmpFile;
} else {
- return OCP\Files::tmpFile();
+ return \OCP\Files::tmpFile();
}
}
private function fromTmpFile($tmpFile, $path) {
+ $this->init();
$obj=$this->getObject($path);
if (is_null($obj)) {
$obj=$this->createObject($path);
@@ -544,7 +575,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
/**
* remove custom mtime metadata
- * @param CF_Object obj
+ * @param \CF_Object $obj
*/
private function resetMTime($obj) {
if (isset($obj->metadata['Mtime'])) {
diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php
index 920aefc12de..2a953ac63f4 100644
--- a/apps/files_external/lib/webdav.php
+++ b/apps/files_external/lib/webdav.php
@@ -6,14 +6,17 @@
* See the COPYING-README file.
*/
-class OC_FileStorage_DAV extends OC_Filestorage_Common{
+namespace OC\Files\Storage;
+
+class DAV extends \OC\Files\Storage\Common{
private $password;
private $user;
private $host;
private $secure;
private $root;
+ private $ready;
/**
- * @var Sabre_DAV_Client
+ * @var \Sabre_DAV_Client
*/
private $client;
@@ -43,6 +46,13 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
if (substr($this->root, -1, 1)!='/') {
$this->root.='/';
}
+ }
+
+ private function init(){
+ if($this->ready){
+ return;
+ }
+ $this->ready = true;
$settings = array(
'baseUri' => $this->createBaseUri(),
@@ -50,7 +60,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
'password' => $this->password,
);
- $this->client = new Sabre_DAV_Client($settings);
+ $this->client = new \Sabre_DAV_Client($settings);
$caview = \OCP\Files::getStorage('files_external');
if ($caview) {
@@ -63,6 +73,10 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
$this->mkdir('');
}
+ public function getId(){
+ return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root;
+ }
+
private function createBaseUri() {
$baseUri='http';
if ($this->secure) {
@@ -73,40 +87,45 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
}
public function mkdir($path) {
+ $this->init();
$path=$this->cleanPath($path);
return $this->simpleResponse('MKCOL', $path, null, 201);
}
public function rmdir($path) {
+ $this->init();
$path=$this->cleanPath($path);
return $this->simpleResponse('DELETE', $path, null, 204);
}
public function opendir($path) {
+ $this->init();
$path=$this->cleanPath($path);
try {
$response=$this->client->propfind($path, array(), 1);
$id=md5('webdav'.$this->root.$path);
- OC_FakeDirStream::$dirs[$id]=array();
+ $content = array();
$files=array_keys($response);
array_shift($files);//the first entry is the current directory
foreach ($files as $file) {
$file = urldecode(basename($file));
- OC_FakeDirStream::$dirs[$id][]=$file;
+ $content[]=$file;
}
+ \OC\Files\Stream\Dir::register($id, $content);
return opendir('fakedir://'.$id);
- } catch(Exception $e) {
+ } catch(\Exception $e) {
return false;
}
}
public function filetype($path) {
+ $this->init();
$path=$this->cleanPath($path);
try {
$response=$this->client->propfind($path, array('{DAV:}resourcetype'));
$responseType=$response["{DAV:}resourcetype"]->resourceType;
return (count($responseType)>0 and $responseType[0]=="{DAV:}collection")?'dir':'file';
- } catch(Exception $e) {
+ } catch(\Exception $e) {
error_log($e->getMessage());
\OCP\Util::writeLog("webdav client", \OCP\Util::sanitizeHTML($e->getMessage()), \OCP\Util::ERROR);
return false;
@@ -122,20 +141,23 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
}
public function file_exists($path) {
+ $this->init();
$path=$this->cleanPath($path);
try {
$this->client->propfind($path, array('{DAV:}resourcetype'));
return true;//no 404 exception
- } catch(Exception $e) {
+ } catch(\Exception $e) {
return false;
}
}
public function unlink($path) {
- return $this->simpleResponse('DELETE', $path, null, 204);
+ $this->init();
+ return $this->simpleResponse('DELETE', $path, null ,204);
}
- public function fopen($path, $mode) {
+ public function fopen($path,$mode) {
+ $this->init();
$path=$this->cleanPath($path);
switch($mode) {
case 'r':
@@ -172,9 +194,9 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
} else {
$ext='';
}
- $tmpFile=OCP\Files::tmpFile($ext);
- OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack');
- if ($this->file_exists($path)) {
+ $tmpFile = \OCP\Files::tmpFile($ext);
+ \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
+ if($this->file_exists($path)) {
$this->getFile($path, $tmpFile);
}
self::$tempFiles[$tmpFile]=$path;
@@ -190,6 +212,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
}
public function free_space($path) {
+ $this->init();
$path=$this->cleanPath($path);
try {
$response=$this->client->propfind($path, array('{DAV:}quota-available-bytes'));
@@ -198,12 +221,13 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
} else {
return 0;
}
- } catch(Exception $e) {
+ } catch(\Exception $e) {
return 0;
}
}
public function touch($path, $mtime=null) {
+ $this->init();
if (is_null($mtime)) {
$mtime=time();
}
@@ -211,12 +235,14 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
$this->client->proppatch($path, array('{DAV:}lastmodified' => $mtime));
}
- public function getFile($path, $target) {
- $source=$this->fopen($path, 'r');
- file_put_contents($target, $source);
+ public function getFile($path,$target) {
+ $this->init();
+ $source=$this->fopen($path,'r');
+ file_put_contents($target,$source);
}
- public function uploadFile($path, $target) {
+ public function uploadFile($path,$target) {
+ $this->init();
$source=fopen($path, 'r');
$curl = curl_init();
@@ -230,47 +256,46 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
curl_close ($curl);
}
- public function rename($path1, $path2) {
+ public function rename($path1,$path2) {
+ $this->init();
$path1=$this->cleanPath($path1);
$path2=$this->root.$this->cleanPath($path2);
try {
$this->client->request('MOVE', $path1, null, array('Destination'=>$path2));
return true;
- } catch(Exception $e) {
- echo $e;
- echo 'fail';
+ } catch(\Exception $e) {
return false;
}
}
- public function copy($path1, $path2) {
+ public function copy($path1,$path2) {
+ $this->init();
$path1=$this->cleanPath($path1);
$path2=$this->root.$this->cleanPath($path2);
try {
$this->client->request('COPY', $path1, null, array('Destination'=>$path2));
return true;
- } catch(Exception $e) {
- echo $e;
- echo 'fail';
+ } catch(\Exception $e) {
return false;
}
}
public function stat($path) {
+ $this->init();
$path=$this->cleanPath($path);
try {
$response=$this->client->propfind($path, array('{DAV:}getlastmodified', '{DAV:}getcontentlength'));
return array(
'mtime'=>strtotime($response['{DAV:}getlastmodified']),
'size'=>(int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0,
- 'ctime'=>-1,
);
- } catch(Exception $e) {
+ } catch(\Exception $e) {
return array();
}
}
public function getMimeType($path) {
+ $this->init();
$path=$this->cleanPath($path);
try {
$response=$this->client->propfind($path, array('{DAV:}getcontenttype', '{DAV:}resourcetype'));
@@ -283,7 +308,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
} else {
return false;
}
- } catch(Exception $e) {
+ } catch(\Exception $e) {
return false;
}
}
@@ -296,12 +321,12 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
}
}
- private function simpleResponse($method, $path, $body, $expected) {
+ private function simpleResponse($method,$path,$body,$expected) {
$path=$this->cleanPath($path);
try {
$response=$this->client->request($method, $path, $body);
return $response['statusCode']==$expected;
- } catch(Exception $e) {
+ } catch(\Exception $e) {
return false;
}
}
diff --git a/apps/files_external/personal.php b/apps/files_external/personal.php
index 4215b28787e..268d1880232 100755
--- a/apps/files_external/personal.php
+++ b/apps/files_external/personal.php
@@ -24,7 +24,7 @@ OCP\Util::addScript('files_external', 'settings');
OCP\Util::addStyle('files_external', 'settings');
$backends = OC_Mount_Config::getBackends();
// Remove local storage
-unset($backends['OC_Filestorage_Local']);
+unset($backends['\OC\Files\Storage\Local']);
$tmpl = new OCP\Template('files_external', 'settings');
$tmpl->assign('isAdminPage', false, false);
$tmpl->assign('mounts', OC_Mount_Config::getPersonalMountPoints());
diff --git a/apps/files_external/tests/amazons3.php b/apps/files_external/tests/amazons3.php
index 39f96fe8e55..6b3a942b5ba 100644
--- a/apps/files_external/tests/amazons3.php
+++ b/apps/files_external/tests/amazons3.php
@@ -20,7 +20,9 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
-class Test_Filestorage_AmazonS3 extends Test_FileStorage {
+namespace Test\Files\Storage;
+
+class AmazonS3 extends Storage {
private $config;
private $id;
@@ -32,12 +34,12 @@ class Test_Filestorage_AmazonS3 extends Test_FileStorage {
$this->markTestSkipped('AmazonS3 backend not configured');
}
$this->config['amazons3']['bucket'] = $id; // Make sure we have a new empty bucket to work in
- $this->instance = new OC_Filestorage_AmazonS3($this->config['amazons3']);
+ $this->instance = new \OC\Files\Storage\AmazonS3($this->config['amazons3']);
}
public function tearDown() {
if ($this->instance) {
- $s3 = new AmazonS3(array('key' => $this->config['amazons3']['key'],
+ $s3 = new \AmazonS3(array('key' => $this->config['amazons3']['key'],
'secret' => $this->config['amazons3']['secret']));
if ($s3->delete_all_objects($this->id)) {
$s3->delete_bucket($this->id);
diff --git a/apps/files_external/tests/config.php b/apps/files_external/tests/config.php
index ff16b1c1d8a..65127175ad7 100644
--- a/apps/files_external/tests/config.php
+++ b/apps/files_external/tests/config.php
@@ -8,7 +8,7 @@ return array(
'root'=>'/test',
),
'webdav'=>array(
- 'run'=>false,
+ 'run'=>true,
'host'=>'localhost',
'user'=>'test',
'password'=>'test',
@@ -30,7 +30,7 @@ return array(
'root'=>'/',
),
'smb'=>array(
- 'run'=>false,
+ 'run'=>true,
'user'=>'test',
'password'=>'test',
'host'=>'localhost',
diff --git a/apps/files_external/tests/dropbox.php b/apps/files_external/tests/dropbox.php
index 304cb3ca38c..e4e598b06b0 100644
--- a/apps/files_external/tests/dropbox.php
+++ b/apps/files_external/tests/dropbox.php
@@ -6,7 +6,9 @@
* See the COPYING-README file.
*/
-class Test_Filestorage_Dropbox extends Test_FileStorage {
+namespace Test\Files\Storage;
+
+class Dropbox extends Storage {
private $config;
public function setUp() {
@@ -16,7 +18,7 @@ class Test_Filestorage_Dropbox extends Test_FileStorage {
$this->markTestSkipped('Dropbox backend not configured');
}
$this->config['dropbox']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
- $this->instance = new OC_Filestorage_Dropbox($this->config['dropbox']);
+ $this->instance = new \OC\Files\Storage\Dropbox($this->config['dropbox']);
}
public function tearDown() {
diff --git a/apps/files_external/tests/ftp.php b/apps/files_external/tests/ftp.php
index 91e4589ed18..923b5e39681 100644
--- a/apps/files_external/tests/ftp.php
+++ b/apps/files_external/tests/ftp.php
@@ -6,7 +6,9 @@
* See the COPYING-README file.
*/
-class Test_Filestorage_FTP extends Test_FileStorage {
+namespace Test\Files\Storage;
+
+class FTP extends Storage {
private $config;
public function setUp() {
@@ -16,12 +18,12 @@ class Test_Filestorage_FTP extends Test_FileStorage {
$this->markTestSkipped('FTP backend not configured');
}
$this->config['ftp']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
- $this->instance = new OC_Filestorage_FTP($this->config['ftp']);
+ $this->instance = new \OC\Files\Storage\FTP($this->config['ftp']);
}
public function tearDown() {
if ($this->instance) {
- OCP\Files::rmdirr($this->instance->constructUrl(''));
+ \OCP\Files::rmdirr($this->instance->constructUrl(''));
}
}
diff --git a/apps/files_external/tests/google.php b/apps/files_external/tests/google.php
index 379bf992ff5..f344163a8b9 100644
--- a/apps/files_external/tests/google.php
+++ b/apps/files_external/tests/google.php
@@ -20,8 +20,9 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
-class Test_Filestorage_Google extends Test_FileStorage {
+namespace Test\Files\Storage;
+class Google extends Storage {
private $config;
public function setUp() {
@@ -31,7 +32,7 @@ class Test_Filestorage_Google extends Test_FileStorage {
$this->markTestSkipped('Google backend not configured');
}
$this->config['google']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
- $this->instance = new OC_Filestorage_Google($this->config['google']);
+ $this->instance = new \OC\Files\Storage\Google($this->config['google']);
}
public function tearDown() {
diff --git a/apps/files_external/tests/smb.php b/apps/files_external/tests/smb.php
index 2d6268ef269..be3ea5a8308 100644
--- a/apps/files_external/tests/smb.php
+++ b/apps/files_external/tests/smb.php
@@ -6,7 +6,10 @@
* See the COPYING-README file.
*/
-class Test_Filestorage_SMB extends Test_FileStorage {
+namespace Test\Files\Storage;
+
+class SMB extends Storage {
+
private $config;
public function setUp() {
@@ -16,12 +19,12 @@ class Test_Filestorage_SMB extends Test_FileStorage {
$this->markTestSkipped('Samba backend not configured');
}
$this->config['smb']['root'] .= $id; //make sure we have an new empty folder to work in
- $this->instance = new OC_Filestorage_SMB($this->config['smb']);
+ $this->instance = new \OC\Files\Storage\SMB($this->config['smb']);
}
public function tearDown() {
if ($this->instance) {
- OCP\Files::rmdirr($this->instance->constructUrl(''));
+ \OCP\Files::rmdirr($this->instance->constructUrl(''));
}
}
}
diff --git a/apps/files_external/tests/swift.php b/apps/files_external/tests/swift.php
index 8b25db50996..5c782840246 100644
--- a/apps/files_external/tests/swift.php
+++ b/apps/files_external/tests/swift.php
@@ -6,7 +6,9 @@
* See the COPYING-README file.
*/
-class Test_Filestorage_SWIFT extends Test_FileStorage {
+namespace Test\Files\Storage;
+
+class SWIFT extends Storage {
private $config;
public function setUp() {
@@ -16,7 +18,7 @@ class Test_Filestorage_SWIFT extends Test_FileStorage {
$this->markTestSkipped('OpenStack SWIFT backend not configured');
}
$this->config['swift']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
- $this->instance = new OC_Filestorage_SWIFT($this->config['swift']);
+ $this->instance = new \OC\Files\Storage\SWIFT($this->config['swift']);
}
diff --git a/apps/files_external/tests/webdav.php b/apps/files_external/tests/webdav.php
index dd938a0c93a..1702898045e 100644
--- a/apps/files_external/tests/webdav.php
+++ b/apps/files_external/tests/webdav.php
@@ -6,7 +6,10 @@
* See the COPYING-README file.
*/
-class Test_Filestorage_DAV extends Test_FileStorage {
+namespace Test\Files\Storage;
+
+class DAV extends Storage {
+
private $config;
public function setUp() {
@@ -16,7 +19,7 @@ class Test_Filestorage_DAV extends Test_FileStorage {
$this->markTestSkipped('WebDAV backend not configured');
}
$this->config['webdav']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
- $this->instance = new OC_Filestorage_DAV($this->config['webdav']);
+ $this->instance = new \OC\Files\Storage\DAV($this->config['webdav']);
}
public function tearDown() {