summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib
diff options
context:
space:
mode:
authorRobin McCorkell <rmccorkell@owncloud.com>2015-08-18 22:49:29 +0100
committerRobin McCorkell <rmccorkell@owncloud.com>2015-08-19 15:26:38 +0100
commitd577aad4ac876c1ed29f7b81199f607da581239b (patch)
tree55bca408402528a7fff2e4d5a0acb5aa7e4ee534 /apps/files_external/lib
parent5fd36d017ecdbce61dcf1c67ae04c8c0be81a4bf (diff)
downloadnextcloud-server-d577aad4ac876c1ed29f7b81199f607da581239b.tar.gz
nextcloud-server-d577aad4ac876c1ed29f7b81199f607da581239b.zip
Use OCP classes as much as possible in files_external
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r--apps/files_external/lib/amazons3.php8
-rw-r--r--apps/files_external/lib/api.php2
-rw-r--r--apps/files_external/lib/config.php25
-rw-r--r--apps/files_external/lib/dropbox.php4
-rw-r--r--apps/files_external/lib/google.php6
-rw-r--r--apps/files_external/lib/swift.php6
6 files changed, 26 insertions, 25 deletions
diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php
index b956a607eba..fd98d26f834 100644
--- a/apps/files_external/lib/amazons3.php
+++ b/apps/files_external/lib/amazons3.php
@@ -372,7 +372,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
switch ($mode) {
case 'r':
case 'rb':
- $tmpFile = \OC_Helper::tmpFile();
+ $tmpFile = \OCP\Files::tmpFile();
self::$tmpFiles[$tmpFile] = $path;
try {
@@ -404,7 +404,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
} else {
$ext = '';
}
- $tmpFile = \OC_Helper::tmpFile($ext);
+ $tmpFile = \OCP\Files::tmpFile($ext);
\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
@@ -464,7 +464,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
]);
$this->testTimeout();
} else {
- $mimeType = \OC_Helper::getMimetypeDetector()->detectPath($path);
+ $mimeType = \OC::$server->getMimeTypeDetector()->detectPath($path);
$this->getConnection()->putObject([
'Bucket' => $this->bucket,
'Key' => $this->cleanKey($path),
@@ -629,7 +629,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
'Bucket' => $this->bucket,
'Key' => $this->cleanKey(self::$tmpFiles[$tmpFile]),
'SourceFile' => $tmpFile,
- 'ContentType' => \OC_Helper::getMimeType($tmpFile),
+ 'ContentType' => \OC::$server->getMimeTypeDetector()->detect($tmpFile),
'ContentLength' => filesize($tmpFile)
));
$this->testTimeout();
diff --git a/apps/files_external/lib/api.php b/apps/files_external/lib/api.php
index b9435e33105..015c15c41ff 100644
--- a/apps/files_external/lib/api.php
+++ b/apps/files_external/lib/api.php
@@ -71,7 +71,7 @@ class Api {
*/
public static function getUserMounts($params) {
$entries = array();
- $user = \OC_User::getUser();
+ $user = \OC::$server->getUserSession()->getUser()->getUID();
$mounts = \OC_Mount_Config::getAbsoluteMountPoints($user);
foreach($mounts as $mountPoint => $mount) {
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 91c33ef10a5..7a0fd94e42e 100644
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -86,10 +86,9 @@ class OC_Mount_Config {
self::addStorageIdToConfig($data['user']);
$user = \OC::$server->getUserManager()->get($data['user']);
if (!$user) {
- \OCP\Util::writeLog(
- 'files_external',
+ \OC::$server->getLogger()->warning(
'Cannot init external mount points for non-existant user "' . $data['user'] . '".',
- \OCP\Util::WARN
+ ['app' => 'files_external']
);
return;
}
@@ -275,10 +274,11 @@ class OC_Mount_Config {
*/
public static function readData($user = null) {
if (isset($user)) {
- $jsonFile = OC_User::getHome($user) . '/mount.json';
+ $jsonFile = \OC::$server->getUserManager()->get($user)->getHome() . '/mount.json';
} else {
- $datadir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data/');
- $jsonFile = \OC_Config::getValue('mount_file', $datadir . '/mount.json');
+ $config = \OC::$server->getConfig();
+ $datadir = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/');
+ $jsonFile = $config->getSystemValue('mount_file', $datadir . '/mount.json');
}
if (is_file($jsonFile)) {
$mountPoints = json_decode(file_get_contents($jsonFile), true);
@@ -297,10 +297,11 @@ class OC_Mount_Config {
*/
public static function writeData($user, $data) {
if (isset($user)) {
- $file = OC_User::getHome($user) . '/mount.json';
+ $file = \OC::$server->getUserManager()->get($user)->getHome() . '/mount.json';
} else {
- $datadir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data/');
- $file = \OC_Config::getValue('mount_file', $datadir . '/mount.json');
+ $config = \OC::$server->getConfig();
+ $datadir = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/');
+ $file = $config->getSystemValue('mount_file', $datadir . '/mount.json');
}
foreach ($data as &$applicables) {
@@ -324,7 +325,7 @@ class OC_Mount_Config {
* @return string
*/
public static function dependencyMessage($backends) {
- $l = new \OC_L10N('files_external');
+ $l = \OC::$server->getL10N('files_external');
$message = '';
$dependencyGroups = [];
@@ -351,12 +352,12 @@ class OC_Mount_Config {
/**
* Returns a dependency missing message
*
- * @param OC_L10N $l
+ * @param \OCP\IL10N $l
* @param string $module
* @param string $backend
* @return string
*/
- private static function getSingleDependencyMessage(OC_L10N $l, $module, $backend) {
+ private static function getSingleDependencyMessage(\OCP\IL10N $l, $module, $backend) {
switch (strtolower($module)) {
case 'curl':
return $l->t('<b>Note:</b> The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it.', $backend);
diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php
index 2d1aea1afc8..4ab14d4f3e0 100644
--- a/apps/files_external/lib/dropbox.php
+++ b/apps/files_external/lib/dropbox.php
@@ -244,7 +244,7 @@ class Dropbox extends \OC\Files\Storage\Common {
switch ($mode) {
case 'r':
case 'rb':
- $tmpFile = \OC_Helper::tmpFile();
+ $tmpFile = \OCP\Files::tmpFile();
try {
$data = $this->dropbox->getFile($path);
file_put_contents($tmpFile, $data);
@@ -270,7 +270,7 @@ class Dropbox extends \OC\Files\Storage\Common {
} else {
$ext = '';
}
- $tmpFile = \OC_Helper::tmpFile($ext);
+ $tmpFile = \OCP\Files::tmpFile($ext);
\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php
index 2ca550dfe7c..e29b1036244 100644
--- a/apps/files_external/lib/google.php
+++ b/apps/files_external/lib/google.php
@@ -429,7 +429,7 @@ class Google extends \OC\Files\Storage\Common {
$request = new \Google_Http_Request($downloadUrl, 'GET', null, null);
$httpRequest = $this->client->getAuth()->authenticatedRequest($request);
if ($httpRequest->getResponseHttpCode() == 200) {
- $tmpFile = \OC_Helper::tmpFile($ext);
+ $tmpFile = \OCP\Files::tmpFile($ext);
$data = $httpRequest->getResponseBody();
file_put_contents($tmpFile, $data);
return fopen($tmpFile, $mode);
@@ -449,7 +449,7 @@ class Google extends \OC\Files\Storage\Common {
case 'x+':
case 'c':
case 'c+':
- $tmpFile = \OC_Helper::tmpFile($ext);
+ $tmpFile = \OCP\Files::tmpFile($ext);
\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'rb');
@@ -466,7 +466,7 @@ class Google extends \OC\Files\Storage\Common {
$parentFolder = $this->getDriveFile(dirname($path));
if ($parentFolder) {
// TODO Research resumable upload
- $mimetype = \OC_Helper::getMimeType($tmpFile);
+ $mimetype = \OC::$server->getMimeTypeDetector()->detect($tmpFile);
$data = file_get_contents($tmpFile);
$params = array(
'data' => $data,
diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php
index d8107e58fed..6f93f3c84cd 100644
--- a/apps/files_external/lib/swift.php
+++ b/apps/files_external/lib/swift.php
@@ -310,7 +310,7 @@ class Swift extends \OC\Files\Storage\Common {
switch ($mode) {
case 'r':
case 'rb':
- $tmpFile = \OC_Helper::tmpFile();
+ $tmpFile = \OCP\Files::tmpFile();
self::$tmpFiles[$tmpFile] = $path;
try {
$object = $this->getContainer()->getObject($path);
@@ -348,7 +348,7 @@ class Swift extends \OC\Files\Storage\Common {
} else {
$ext = '';
}
- $tmpFile = \OC_Helper::tmpFile($ext);
+ $tmpFile = \OCP\Files::tmpFile($ext);
\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
@@ -387,7 +387,7 @@ class Swift extends \OC\Files\Storage\Common {
$object->saveMetadata($metadata);
return true;
} else {
- $mimeType = \OC_Helper::getMimetypeDetector()->detectPath($path);
+ $mimeType = \OC::$server->getMimeTypeDetector()->detectPath($path);
$customHeaders = array('content-type' => $mimeType);
$metadataHeaders = DataObject::stockHeaders($metadata);
$allHeaders = $customHeaders + $metadataHeaders;