Commit f3fe4668 authored by Olivier Paroz's avatar Olivier Paroz
Browse files

Introducing 3D images support (media type)

So that people with 3D images can at least see a 2D picture
Full 3D support is possible via an app
parent 6c989256
...@@ -81,6 +81,7 @@ return array( ...@@ -81,6 +81,7 @@ return array(
'impress' => array('text/impress', null), 'impress' => array('text/impress', null),
'jpeg' => array('image/jpeg', null), 'jpeg' => array('image/jpeg', null),
'jpg' => array('image/jpeg', null), 'jpg' => array('image/jpeg', null),
'jps' => array('image/jpeg', null),
'js' => array('application/javascript', 'text/plain'), 'js' => array('application/javascript', 'text/plain'),
'json' => array('application/json', 'text/plain'), 'json' => array('application/json', 'text/plain'),
'k25' => array('image/x-dcraw', null), 'k25' => array('image/x-dcraw', null),
...@@ -103,6 +104,7 @@ return array( ...@@ -103,6 +104,7 @@ return array(
'mp4' => array('video/mp4', null), 'mp4' => array('video/mp4', null),
'mpeg' => array('video/mpeg', null), 'mpeg' => array('video/mpeg', null),
'mpg' => array('video/mpeg', null), 'mpg' => array('video/mpeg', null),
'mpo' => array('image/jpeg', null),
'msi' => array('application/x-msi', null), 'msi' => array('application/x-msi', null),
'nef' => array('image/x-dcraw', null), 'nef' => array('image/x-dcraw', null),
'numbers' => array('application/x-iwork-numbers-sffnumbers', null), 'numbers' => array('application/x-iwork-numbers-sffnumbers', null),
......
...@@ -17,7 +17,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { ...@@ -17,7 +17,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
public function getName() { public function getName() {
return 'Repair mime types'; return 'Repair mime types';
} }
private static function existsStmt() { private static function existsStmt() {
return \OC_DB::prepare(' return \OC_DB::prepare('
SELECT count(`mimetype`) SELECT count(`mimetype`)
...@@ -51,14 +51,14 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { ...@@ -51,14 +51,14 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
) WHERE `mimetype` = ? ) WHERE `mimetype` = ?
'); ');
} }
private static function deleteStmt() { private static function deleteStmt() {
return \OC_DB::prepare(' return \OC_DB::prepare('
DELETE FROM `*PREFIX*mimetypes` DELETE FROM `*PREFIX*mimetypes`
WHERE `id` = ? WHERE `id` = ?
'); ');
} }
private static function updateByNameStmt() { private static function updateByNameStmt() {
return \OC_DB::prepare(' return \OC_DB::prepare('
UPDATE `*PREFIX*filecache` UPDATE `*PREFIX*filecache`
...@@ -69,7 +69,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { ...@@ -69,7 +69,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
) WHERE `name` ILIKE ? ) WHERE `name` ILIKE ?
'); ');
} }
private function repairMimetypes($wrongMimetypes) { private function repairMimetypes($wrongMimetypes) {
foreach ($wrongMimetypes as $wrong => $correct) { foreach ($wrongMimetypes as $wrong => $correct) {
// do we need to remove a wrong mimetype? // do we need to remove a wrong mimetype?
...@@ -81,8 +81,8 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { ...@@ -81,8 +81,8 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
$result = \OC_DB::executeAudited(self::existsStmt(), array($correct)); $result = \OC_DB::executeAudited(self::existsStmt(), array($correct));
$exists = $result->fetchOne(); $exists = $result->fetchOne();
if ( ! is_null($correct) ) { if (!is_null($correct)) {
if ( ! $exists ) { if (!$exists) {
// insert mimetype // insert mimetype
\OC_DB::executeAudited(self::insertStmt(), array($correct)); \OC_DB::executeAudited(self::insertStmt(), array($correct));
} }
...@@ -90,27 +90,27 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { ...@@ -90,27 +90,27 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
// change wrong mimetype to correct mimetype in filecache // change wrong mimetype to correct mimetype in filecache
\OC_DB::executeAudited(self::updateWrongStmt(), array($correct, $wrongId)); \OC_DB::executeAudited(self::updateWrongStmt(), array($correct, $wrongId));
} }
// delete wrong mimetype // delete wrong mimetype
\OC_DB::executeAudited(self::deleteStmt(), array($wrongId)); \OC_DB::executeAudited(self::deleteStmt(), array($wrongId));
} }
} }
} }
private function updateMimetypes($updatedMimetypes) { private function updateMimetypes($updatedMimetypes) {
foreach ($updatedMimetypes as $extension => $mimetype ) { foreach ($updatedMimetypes as $extension => $mimetype) {
$result = \OC_DB::executeAudited(self::existsStmt(), array($mimetype)); $result = \OC_DB::executeAudited(self::existsStmt(), array($mimetype));
$exists = $result->fetchOne(); $exists = $result->fetchOne();
if ( ! $exists ) { if (!$exists) {
// insert mimetype // insert mimetype
\OC_DB::executeAudited(self::insertStmt(), array($mimetype)); \OC_DB::executeAudited(self::insertStmt(), array($mimetype));
} }
// change mimetype for files with x extension // change mimetype for files with x extension
\OC_DB::executeAudited(self::updateByNameStmt(), array($mimetype, '%.'.$extension)); \OC_DB::executeAudited(self::updateByNameStmt(), array($mimetype, '%.' . $extension));
} }
} }
...@@ -132,9 +132,9 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { ...@@ -132,9 +132,9 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
// separate doc from docx etc // separate doc from docx etc
self::updateMimetypes($updatedMimetypes); self::updateMimetypes($updatedMimetypes);
} }
private function fixApkMimeType() { private function fixApkMimeType() {
$updatedMimetypes = array( $updatedMimetypes = array(
'apk' => 'application/vnd.android.package-archive', 'apk' => 'application/vnd.android.package-archive',
...@@ -142,7 +142,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { ...@@ -142,7 +142,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
self::updateMimetypes($updatedMimetypes); self::updateMimetypes($updatedMimetypes);
} }
private function fixFontsMimeTypes() { private function fixFontsMimeTypes() {
// update wrong mimetypes // update wrong mimetypes
$wrongMimetypes = array( $wrongMimetypes = array(
...@@ -152,7 +152,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { ...@@ -152,7 +152,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
); );
self::repairMimetypes($wrongMimetypes); self::repairMimetypes($wrongMimetypes);
$updatedMimetypes = array( $updatedMimetypes = array(
'ttf' => 'application/font-sfnt', 'ttf' => 'application/font-sfnt',
'otf' => 'application/font-sfnt', 'otf' => 'application/font-sfnt',
...@@ -161,7 +161,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { ...@@ -161,7 +161,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
self::updateMimetypes($updatedMimetypes); self::updateMimetypes($updatedMimetypes);
} }
private function fixPostscriptMimeType() { private function fixPostscriptMimeType() {
$updatedMimetypes = array( $updatedMimetypes = array(
'eps' => 'application/postscript', 'eps' => 'application/postscript',
...@@ -195,6 +195,15 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { ...@@ -195,6 +195,15 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
self::updateMimetypes($updatedMimetypes); self::updateMimetypes($updatedMimetypes);
} }
private function introduce3dImagesMimeType() {
$updatedMimetypes = array(
'jps' => 'image/jpeg',
'mpo' => 'image/jpeg',
);
self::updateMimetypes($updatedMimetypes);
}
/** /**
* Fix mime types * Fix mime types
*/ */
...@@ -202,15 +211,15 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { ...@@ -202,15 +211,15 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
if ($this->fixOfficeMimeTypes()) { if ($this->fixOfficeMimeTypes()) {
$this->emit('\OC\Repair', 'info', array('Fixed office mime types')); $this->emit('\OC\Repair', 'info', array('Fixed office mime types'));
} }
if ($this->fixApkMimeType()) { if ($this->fixApkMimeType()) {
$this->emit('\OC\Repair', 'info', array('Fixed APK mime type')); $this->emit('\OC\Repair', 'info', array('Fixed APK mime type'));
} }
if ($this->fixFontsMimeTypes()) { if ($this->fixFontsMimeTypes()) {
$this->emit('\OC\Repair', 'info', array('Fixed fonts mime types')); $this->emit('\OC\Repair', 'info', array('Fixed fonts mime types'));
} }
if ($this->fixPostscriptMimeType()) { if ($this->fixPostscriptMimeType()) {
$this->emit('\OC\Repair', 'info', array('Fixed Postscript mime types')); $this->emit('\OC\Repair', 'info', array('Fixed Postscript mime types'));
} }
...@@ -218,5 +227,9 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { ...@@ -218,5 +227,9 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
if ($this->introduceRawMimeType()) { if ($this->introduceRawMimeType()) {
$this->emit('\OC\Repair', 'info', array('Fixed Raw mime types')); $this->emit('\OC\Repair', 'info', array('Fixed Raw mime types'));
} }
if ($this->introduce3dImagesMimeType()) {
$this->emit('\OC\Repair', 'info', array('Fixed 3D images mime types'));
}
} }
} }
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment