Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
  • Loading branch information
lenidot committed Jul 7, 2011
1 parent 9b565e6 commit 606b8ef
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 74 deletions.
4 changes: 2 additions & 2 deletions content/zindus/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
* Contributor(s): Leni Mayo
*
* ***** END LICENSE BLOCK *****/
// $Id: const.js,v 1.322 2011-07-04 23:35:34 cvsuser Exp $
// $Id: const.js,v 1.324 2011-07-07 11:10:05 cvsuser Exp $

const APP_NAME="zindus";
const APP_VERSION_NUMBER="0.8.35.20110705.094127"; // this line generated by build.sh
const APP_VERSION_NUMBER="0.8.35.20110707.212001"; // this line generated by build.sh
const APP_VERSION_DATA_CONSISTENT_WITH="0.8.34.20110704.175247"; // remove the data files (forcing a slow sync) if data was
// generated by a software version older than this

Expand Down
16 changes: 15 additions & 1 deletion content/zindus/filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* Contributor(s): Leni Mayo
*
* ***** END LICENSE BLOCK *****/
// $Id: filesystem.js,v 1.29 2011-05-01 02:21:51 cvsuser Exp $
// $Id: filesystem.js,v 1.30 2011-07-07 11:10:05 cvsuser Exp $

var Filesystem = {
m_charset : "UTF-8",
Expand Down Expand Up @@ -165,6 +165,20 @@ var Filesystem = {
cis.close();
}
},
readBinaryFile : function(nsifile) {
let fstream = Cc['@mozilla.org/network/file-input-stream;1'].createInstance(Ci.nsIFileInputStream);
let bstream = Cc['@mozilla.org/binaryinputstream;1'].createInstance(Ci.nsIBinaryInputStream);

fstream.init(nsifile, 1, 0, false);
bstream.setInputStream(fstream);

let ret = bstream.readByteArray(fstream.available());

bstream.close();
fstream.close();

return ret;
},
// the remove* methods...
removeZfc : function(filename) {
let directory = Filesystem.nsIFileForDirectory(Filesystem.eDirectory.DATA);
Expand Down
115 changes: 48 additions & 67 deletions content/zindus/syncfsm.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* Contributor(s): Leni Mayo
*
* ***** END LICENSE BLOCK *****/
// $Id: syncfsm.js,v 1.304 2011-07-04 23:35:34 cvsuser Exp $
// $Id: syncfsm.js,v 1.305 2011-07-07 11:10:05 cvsuser Exp $

includejs("fsm.js");
includejs("zmsoapdocument.js");
Expand Down Expand Up @@ -232,17 +232,7 @@ SyncFsmGdAuth.prototype.initialiseFsm = function()
{
SyncFsmGd.prototype.initialiseFsm.call(this);

if (false && AppInfo.app_name() == AppInfo.eApp.firefox)
{
// TODO - this code is/was toying with the idea that "test connection" in firefox should also get the google groups..
//
this.fsm.m_transitions['stAuthCheck']['evNext'] = 'stGetAllGroups';
this.fsm.m_transitions['stGetAllGroups'] = { evCancel: 'final', evNext: 'final', evHttpRequest: 'stHttpRequest' };
this.fsm.m_a_entry['stGetAllGroups'] = this.entryActionGetAllGroups;
this.fsm.m_a_exit['stGetAllGroups'] = this.exitActionGetAllGroups;
}
else
this.fsm.m_transitions['stAuthCheck']['evNext'] = 'final';
this.fsm.m_transitions['stAuthCheck']['evNext'] = 'final';
}

SyncFsmLd.prototype.initialiseFsm = function()
Expand Down Expand Up @@ -8428,10 +8418,9 @@ SyncFsm.prototype.entryActionUpdateGdPhoto = function(state, event, continuation

if (!is_noop) {
nsifile = SyncFsmGd.gd_photo_nsifile_for(tb_properties["PhotoName"]);
this.debug("entryActionUpdateGdPhoto: before calling getTypeFromFile: nsifile.path: " + nsifile.path); // TODO REMOVE ME

let mimeSvc = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
let content_type = mimeSvc.getTypeFromFile(nsifile);
let content_type = SyncFsmGd.gd_content_type_from_file(nsifile);

headers = newObject("Content-Type", content_type,
"X-HTTP-Method-Override", "PUT",
"If-Match", "*");
Expand Down Expand Up @@ -11095,15 +11084,6 @@ SyncFsmGd.prototype.entryActionGetPhotoGd = function(state, event, continuation)
if (this.state.m_gd_progress_count < this.state.a_gd_photo_to_get.length) {
let uri = gdAdjustHttpHttps(this.state.a_gd_contact[this.state.a_gd_photo_to_get[this.state.m_gd_progress_count]].photo.uri);

if (false) // for testing issue #288
{
let id = this.state.a_gd_photo_to_get[this.state.m_gd_progress_count];
if (id == "c:89d8544889ecd6f") {
uri = uri + "XXXX"; // TODO
this.debug("mangled uri: " + uri);
}
}

function on_xhr(http) {
http.m_xhr.overrideMimeType('text/plain; charset=x-user-defined');
http.m_xhr.send(http.httpBody());
Expand Down Expand Up @@ -11150,7 +11130,7 @@ SyncFsmGd.prototype.exitActionGetPhotoGd = function(state, event)
if (zfi.isPresent(FeedItem.ATTR_GDME))
zfi.del(FeedItem.ATTR_GDME);

let ext = SyncFsmGd.gd_photo_extension(this.state.m_http.m_xhr);
let ext = SyncFsmGd.gd_file_ext_from_http(this.state.m_http.m_xhr);
let filename = filename_from_retrieved_photo(contact, ext);
let re = SyncFsmGd.gd_photo_filename_re_full(this.account().username);

Expand All @@ -11170,17 +11150,6 @@ SyncFsmGd.prototype.exitActionGetPhotoGd = function(state, event)

this.debug("exitActionGetPhotoGd: photo for id=" + contact.meta.id +
" stored as filename: " + filename + " bytes: " + this.state.m_http.response('text').length);

{
// TODO REMOVE ME when finished debugging #296
//
let nsifile = SyncFsmGd.gd_photo_nsifile_for(filename);
this.debug("exitActionGetPhotoGd: confirming that getTypeFromFile works: nsifile.path: " + nsifile.path);

let mimeSvc = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
let content_type = mimeSvc.getTypeFromFile(nsifile);
this.debug("exitActionGetPhotoGd: content_type: " + content_type);
}
}
else {
zfi.set(FeedItem.ATTR_GDME, contact.photo.etag);
Expand Down Expand Up @@ -11230,50 +11199,62 @@ SyncFsmGd.gd_photo_nsifile_for = function(filename)
return nsifile;
}

SyncFsmGd.gd_photo_extension = function(arg)
SyncFsmGd.gd_file_ext_from_http = function(xhr)
{
let ret = "";
let msg = "";

if (arg instanceof XMLHttpRequest) {
let xhr = arg;
let mimeSvc = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
let uri = xhr.channel.URI;
zinAssert(xhr instanceof XMLHttpRequest);

if (uri instanceof Components.interfaces.nsIURL)
ret = uri.fileExtension;
let mimeSvc = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
let uri = xhr.channel.URI;

try {
let contentType = xhr.getResponseHeader('Content-Type');
if (uri instanceof Components.interfaces.nsIURL)
ret = uri.fileExtension;

if (contentType == "image/jpg") {
// Google Contacts API may occasionally respond with Content-Type: image/jpg which isn't a valid image media type:
// http://www.iana.org/assignments/media-types/image/index.html
// mozilla's nsIMIMEService doesn't know about 'image/jpg', so it's special-cased here:
//
ret = "jpg";
}
else
ret = mimeSvc.getPrimaryExtension(contentType, ret);
try {
let contentType = xhr.getResponseHeader('Content-Type');

msg += " http Content-Type: " + contentType;
} catch (e) {}
if (contentType == "image/jpg") {
// Google Contacts API sometimes responds with Content-Type: image/jpg which isn't a valid image media type:
// http://www.iana.org/assignments/media-types/image/index.html
// bug filed: http://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=2649
//
ret = "jpg";
}
else
ret = mimeSvc.getPrimaryExtension(contentType, ret);
} catch (e) {
zinAssertAndLog(false, "google served a wierd content type: getAllResponseHeaders: " + xhr.getAllResponseHeaders());
}
else {
zinAssert(arg instanceof Ci.nsIFile);

let nsifile = arg;
let uri = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService).newFileURI(nsifile);
if (ret == "jpe")
ret = "jpg";

zinAssertAndLog(uri instanceof Ci.nsIURL, function() { return nsifile.path; } );
logger().debug("SyncFsmGd.gd_file_ext_from_http: returns: " + ret);

ret = uri.fileExtension;
}
return ret;
}

if (ret == "jpe")
ret = "jpg";
SyncFsmGd.gd_content_type_from_file = function(nsifile)
{
let ret;
let msg = " uses: ";

zinAssert(nsifile instanceof Ci.nsIFile);

let mimeSvc = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);

try {
ret = mimeSvc.getTypeFromFile(nsifile);
msg += "nsIMIMEService";
} catch(ex) {
let sniffer = Cc["@mozilla.org/network/content-sniffer;1"].getService(Ci.nsIContentSniffer);
let aData = Filesystem.readBinaryFile(nsifile);
ret = sniffer.getMIMETypeFromContent(null, aData, aData.length);
msg += "nsIContentSniffer";
}

logger().debug("SyncFsmGd.gd_photo_extension: returns: " + ret + msg);
logger().debug("SyncFsmGd.gd_content_type_from_file: file: " + nsifile.path + msg + " returns: " + ret);

return ret;
}
Expand Down
9 changes: 7 additions & 2 deletions content/zindus/testharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* Contributor(s): Leni Mayo
*
* ***** END LICENSE BLOCK *****/
// $Id: testharness.js,v 1.134 2011-07-03 21:53:42 cvsuser Exp $
// $Id: testharness.js,v 1.135 2011-07-07 11:10:05 cvsuser Exp $

function TestHarness()
{
Expand Down Expand Up @@ -1765,9 +1765,14 @@ TestHarness.prototype.testContactGoogleIssue296 = function()

logger().debug("testContactGoogleIssue296: a_filename: " + aToString(a_filename));

let content_sniffer = Cc["@mozilla.org/network/content-sniffer;1"].getService(Ci.nsIContentSniffer);

for (filename in a_filename) {
let nsifile = SyncFsmGd.gd_photo_nsifile_for(filename);
let content_type;
let aData = Filesystem.readBinaryFile(nsifile);
let content_type = content_sniffer.getMIMETypeFromContent(null, aData, aData.length);

logger().debug("testContactGoogleIssue296: content_sniffer: " + content_type + " filename: " + filename);

logger().debug("testContactGoogleIssue296: before calling getTypeFromFile: nsifile.path: " + nsifile.path);

Expand Down
4 changes: 2 additions & 2 deletions install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<em:id>{ad7d8a66-253b-11dc-977c-000c29a3126e}</em:id>

<em:version>0.8.35</em:version> <!-- version populated by build script -->
<em:version>0.8.35.20110707.212001</em:version> <!-- version populated by build script -->

<em:targetApplication>
<!-- Thunderbird -->
Expand Down Expand Up @@ -75,7 +75,7 @@
<em:hidden>false</em:hidden>
<em:iconURL>chrome://zindus/skin/zindus32x32.gif</em:iconURL>
<em:updateKey>MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCyC+XK8GT8SJpfhxXZu7MM+ALv/OmcRfP3m2m6DzWrB121ToA3zEfUOfD568gDuKExpptuomgNyYRUB32yCQfmHryMS4fXXuG49JGlQq7kMNXW+aSp7IE5Q6DExVhLZ0jOSXk+alWbTWLFpXNLuI0n72T291Otmq0YEyrlqx3UbwIDAQAB</em:updateKey>
<em:updateURL>http://www.zindus.com/download/xpi-update-rdf.php?item_id=%ITEM_ID%&amp;item_version=%ITEM_VERSION%&amp;item_status=%ITEM_STATUS%&amp;app_id=%APP_ID%&amp;app_os=%APP_OS%&amp;app_abi=%APP_ABI%&amp;reltype=prod-zindus</em:updateURL>
<em:updateURL>http://www.zindus.com/download/xpi-update-rdf.php?item_id=%ITEM_ID%&amp;item_version=%ITEM_VERSION%&amp;item_status=%ITEM_STATUS%&amp;app_id=%APP_ID%&amp;app_os=%APP_OS%&amp;app_abi=%APP_ABI%&amp;reltype=testing</em:updateURL>

</rdf:Description>

Expand Down

0 comments on commit 606b8ef

Please sign in to comment.