From 7e1a678f9b7692cc7f14167d8aabf3e18806a2ae Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 12 Aug 2006 03:54:13 +0000 Subject: [PATCH] Addresses #136, Detect mime type and character set of local files when importing Use new MIME type detection tricks when linking and importing files -- now for charset detection... --- .../content/scholar/xpcom/data_access.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/xpcom/data_access.js b/chrome/chromeFiles/content/scholar/xpcom/data_access.js index 1edce663b1..3a2037dc13 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/data_access.js +++ b/chrome/chromeFiles/content/scholar/xpcom/data_access.js @@ -1950,7 +1950,7 @@ Scholar.Attachments = new function(){ newFile.initWithFile(destDir); newFile.append(title); - var mimeType = _getMIMETypeFromFile(newFile); + var mimeType = Scholar.File.getMIMETypeFromFile(newFile); var charsetID = _getCharsetIDFromFile(newFile); _addToDB(newFile, null, null, this.LINK_MODE_IMPORTED_FILE, mimeType, charsetID, sourceItemID, itemID); @@ -1961,7 +1961,7 @@ Scholar.Attachments = new function(){ function linkFromFile(file, sourceItemID){ var title = file.leafName; - var mimeType = _getMIMETypeFromFile(file); + var mimeType = Scholar.File.getMIMETypeFromFile(file); var charsetID = _getCharsetIDFromFile(file); return _addToDB(file, null, title, this.LINK_MODE_LINKED_FILE, mimeType, charsetID, sourceItemID); } @@ -2050,15 +2050,6 @@ Scholar.Attachments = new function(){ } - // TODO: currently only uses file extension - function _getMIMETypeFromFile(file){ - var ms = Components - .classes['@mozilla.org/uriloader/external-helper-app-service;1'] - .getService(Components.interfaces.nsIMIMEService); - return ms.getTypeFromFile(file); - } - - function _getCharsetIDFromFile(file){ // TODO: Not yet implemented return null;