Skip to content

Commit

Permalink
Merge pull request #18440 from owncloud/ext-backends.customjs
Browse files Browse the repository at this point in the history
Migrate custom JS external storage backends to new registration API [part 2]
  • Loading branch information
MorrisJobke committed Aug 25, 2015
2 parents 2f86be9 + 88a7823 commit 494c1d7
Show file tree
Hide file tree
Showing 16 changed files with 529 additions and 308 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
OCP\JSON::callCheck();
$l = \OC::$server->getL10N('files_external');

// FIXME: currently hard-coded to Dropbox OAuth
if (isset($_POST['app_key']) && isset($_POST['app_secret'])) {
$oauth = new Dropbox_OAuth_Curl((string)$_POST['app_key'], (string)$_POST['app_secret']);
if (isset($_POST['step'])) {
Expand All @@ -47,7 +48,7 @@
'request_token_secret' => $token['token_secret'])));
} catch (Exception $exception) {
OCP\JSON::error(array('data' => array('message' =>
$l->t('Fetching request tokens failed. Verify that your Dropbox app key and secret are correct.'))
$l->t('Fetching request tokens failed. Verify that your app key and secret are correct.'))
));
}
break;
Expand All @@ -60,13 +61,13 @@
'access_token_secret' => $token['token_secret']));
} catch (Exception $exception) {
OCP\JSON::error(array('data' => array('message' =>
$l->t('Fetching access tokens failed. Verify that your Dropbox app key and secret are correct.'))
$l->t('Fetching access tokens failed. Verify that your app key and secret are correct.'))
));
}
}
break;
}
}
} else {
OCP\JSON::error(array('data' => array('message' => $l->t('Please provide a valid Dropbox app key and secret.'))));
OCP\JSON::error(array('data' => array('message' => $l->t('Please provide a valid app key and secret.'))));
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
OCP\JSON::callCheck();
$l = \OC::$server->getL10N('files_external');

// FIXME: currently hard-coded to Google Drive
if (isset($_POST['client_id']) && isset($_POST['client_secret']) && isset($_POST['redirect'])) {
$client = new Google_Client();
$client->setClientId((string)$_POST['client_id']);
Expand Down
55 changes: 0 additions & 55 deletions apps/files_external/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,61 +70,6 @@
OCP\Util::connectHook('OC_Filesystem', 'post_initMountPoints', '\OC_Mount_Config', 'initMountPointsHook');
OCP\Util::connectHook('OC_User', 'post_login', 'OC\Files\Storage\SMB_OC', 'login');

OC_Mount_Config::registerBackend('\OC\Files\Storage\AmazonS3', [
'backend' => (string)$l->t('Amazon S3'),
'priority' => 100,
'configuration' => [
'key' => (string)$l->t('Key'),
'secret' => '*'.$l->t('Secret'),
'bucket' => (string)$l->t('Bucket'),
],
'has_dependencies' => true,
]);

OC_Mount_Config::registerBackend('\OC\Files\Storage\AmazonS3', [
'backend' => (string)$l->t('Amazon S3 and compliant'),
'priority' => 100,
'configuration' => [
'key' => (string)$l->t('Access Key'),
'secret' => '*'.$l->t('Secret Key'),
'bucket' => (string)$l->t('Bucket'),
'hostname' => '&'.$l->t('Hostname'),
'port' => '&'.$l->t('Port'),
'region' => '&'.$l->t('Region'),
'use_ssl' => '!'.$l->t('Enable SSL'),
'use_path_style' => '!'.$l->t('Enable Path Style')
],
'has_dependencies' => true,
]);

OC_Mount_Config::registerBackend('\OC\Files\Storage\Dropbox', [
'backend' => 'Dropbox',
'priority' => 100,
'configuration' => [
'configured' => '#configured',
'app_key' => (string)$l->t('App key'),
'app_secret' => '*'.$l->t('App secret'),
'token' => '#token',
'token_secret' => '#token_secret'
],
'custom' => 'dropbox',
'has_dependencies' => true,
]);

OC_Mount_Config::registerBackend('\OC\Files\Storage\Google', [
'backend' => 'Google Drive',
'priority' => 100,
'configuration' => [
'configured' => '#configured',
'client_id' => (string)$l->t('Client ID'),
'client_secret' => '*'.$l->t('Client secret'),
'token' => '#token',
],
'custom' => 'google',
'has_dependencies' => true,
]);


OC_Mount_Config::registerBackend('\OC\Files\Storage\Swift', [
'backend' => (string)$l->t('OpenStack Object Storage'),
'priority' => 100,
Expand Down
12 changes: 12 additions & 0 deletions apps/files_external/appinfo/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ protected function loadBackends() {
$container->query('OCA\Files_External\Lib\Backend\DAV'),
$container->query('OCA\Files_External\Lib\Backend\OwnCloud'),
$container->query('OCA\Files_External\Lib\Backend\SFTP'),
$container->query('OCA\Files_External\Lib\Backend\AmazonS3'),
$container->query('OCA\Files_External\Lib\Backend\Dropbox'),
$container->query('OCA\Files_External\Lib\Backend\Google'),
]);

if (!\OC_Util::runningOnWindows()) {
Expand All @@ -91,6 +94,15 @@ protected function loadAuthMechanisms() {
// AuthMechanism::SCHEME_PASSWORD mechanisms
$container->query('OCA\Files_External\Lib\Auth\Password\Password'),
$container->query('OCA\Files_External\Lib\Auth\Password\SessionCredentials'),

// AuthMechanism::SCHEME_OAUTH1 mechanisms
$container->query('OCA\Files_External\Lib\Auth\OAuth1\OAuth1'),

// AuthMechanism::SCHEME_OAUTH2 mechanisms
$container->query('OCA\Files_External\Lib\Auth\OAuth2\OAuth2'),

// Specialized mechanisms
$container->query('OCA\Files_External\Lib\Auth\AmazonS3\AccessKey'),
]);
}

Expand Down
8 changes: 4 additions & 4 deletions apps/files_external/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
)
);

$this->create('files_external_dropbox', 'ajax/dropbox.php')
->actionInclude('files_external/ajax/dropbox.php');
$this->create('files_external_google', 'ajax/google.php')
->actionInclude('files_external/ajax/google.php');
$this->create('files_external_oauth1', 'ajax/oauth1.php')
->actionInclude('files_external/ajax/oauth1.php');
$this->create('files_external_oauth2', 'ajax/oauth2.php')
->actionInclude('files_external/ajax/oauth2.php');


$this->create('files_external_list_applicable', '/applicable')
Expand Down
111 changes: 0 additions & 111 deletions apps/files_external/js/dropbox.js

This file was deleted.

131 changes: 0 additions & 131 deletions apps/files_external/js/google.js

This file was deleted.

Loading

0 comments on commit 494c1d7

Please sign in to comment.