PK Ak6chrome/PK Bk6D*ɏ^^chrome/memotoothunderbird.jarPK y3content/PK GX(32((content/bmsyncNetworkService.js// this code was written by Torisugari var gBookmarksSynchronizerUploadService= { _channel:null, _callback:null, _data:"", _scheme:"", _errorData:"", start:function(aStr,aURI,aType,aCallback) { if( !aStr || !aURI) return false; this._callback=aCallback; this._scheme=aURI.scheme; const ioService = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); const stringStream=Components.classes["@mozilla.org/io/string-input-stream;1"] .createInstance(Components.interfaces.nsIStringInputStream); this._channel = ioService.newChannelFromURI( aURI ) .QueryInterface(Components.interfaces.nsIUploadChannel); try{ stringStream.setData(aStr, -1); this._channel.setUploadStream(stringStream,aType,-1); this._channel.asyncOpen(this, null); this._callback("send",status); this._data=aStr; return true; }catch(e){window.alert("__netwerk__\n\n"+"e");} return false; }, cancel:function() { if(this._channel) this._channel.cancel(0x804b0002); }, onDataAvailable: function (channel, ctxt, input, sourceOffset, count){ const sis = Components.classes["@mozilla.org/scriptableinputstream;1"] .createInstance(Components.interfaces.nsIScriptableInputStream); sis.init(input); this._errorData +=sis.read(count); }, onStartRequest: function (channel, ctxt){}, onStopRequest: function (channel, ctxt, status) { if(this._scheme != "ftp") { var res=0; try{ res = channel.QueryInterface(Components.interfaces.nsIHttpChannel) .responseStatus; }catch(e){} if(res==200||res==201 || res==204) status=0; /* 200:OK 201:Created 204:No Content This is an uploading channel, no need to "GET" the file contents. */ if(this._errorData || res==401) status=res; if(this._errorData && res==200) alert(this._errorData); } if(this._callback) this._callback("done",status); } }; var gBookmarksSynchronizerDownloadService= { _channel:null, _scheme:"", _callback:null, _startTime:0, _endTime:0, streamLoader:null, data:null, length:null, start:function(aURI,aCallback) { if( !aURI ) return false; this._callback=aCallback; this._scheme=aURI.scheme; try{ var ioService = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); this.streamLoader=Components.classes["@mozilla.org/network/stream-loader;1"] .createInstance(Components.interfaces.nsIStreamLoader); this._channel = ioService.newChannelFromURI( aURI ); if(aURI.scheme=="http" || aURI.scheme=="https") this._channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE; this.streamLoader.init(this._channel, this , null); this._startTime=(new Date()).getTime(); }catch(e){ alert(e); return false;} return true; }, cancel:function() { if(this._channel) this._channel.cancel(0x804b0002); }, onStreamComplete :function ( loader , ctxt , status , resultLength , result ) { this.data=""; this._endTime=(new Date()).getTime(); if(status==0) { this.length=resultLength; if(typeof(result)=="string") this.data=result; else { while(result.length > (256*192) ) { this.data += String.fromCharCode.apply(this,result.splice(0,256*192)); } this.data += String.fromCharCode.apply(this,result); } } if(this._scheme != "ftp") { var res=0; try{ res = this._channel.QueryInterface(Components.interfaces.nsIHttpChannel) .responseStatus; }catch(e){} if(res==401) status=res; } if(this._callback) this._callback("done",status); }, get time(){ return this._endTime-this._startTime; } }; PK 3P`content/contents.rdf chrome://memotoothunderbird/content/memotoothunderbirdOverlay.xul chrome://memotoothunderbird/content/memotoothunderbirdOverlayAddressBook.xul PK S3bW#W#content/functions.js/* * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as defined in RFC 1321. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet * Distributed under the BSD License * See http://pajhome.org.uk/crypt/md5 for more info. */ /* * Configurable variables. You may need to tweak these to be compatible with * the server-side, but the defaults work in most cases. */ var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ /* * These are the functions you'll usually want to call * They take string arguments and return either hex or base-64 encoded strings */ function hex_md5(s){ if (s.length=="32" || s.length=="0") return s; else return binl2hex(core_md5(str2binl(s), s.length * chrsz));} /* * Calculate the MD5 of an array of little-endian words, and a bit length */ function core_md5(x, len) { /* append padding */ x[len >> 5] |= 0x80 << ((len) % 32); x[(((len + 64) >>> 9) << 4) + 14] = len; var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; for(var i = 0; i < x.length; i += 16) { var olda = a; var oldb = b; var oldc = c; var oldd = d; a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); c = md5_ff(c, d, a, b, x[i+10], 17, -42063); b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); a = safe_add(a, olda); b = safe_add(b, oldb); c = safe_add(c, oldc); d = safe_add(d, oldd); } return Array(a, b, c, d); } /* * These functions implement the four basic operations the algorithm uses. */ function md5_cmn(q, a, b, x, s, t) { return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); } function md5_ff(a, b, c, d, x, s, t) { return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); } function md5_gg(a, b, c, d, x, s, t) { return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); } function md5_hh(a, b, c, d, x, s, t) { return md5_cmn(b ^ c ^ d, a, b, x, s, t); } function md5_ii(a, b, c, d, x, s, t) { return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); } /* * Calculate the HMAC-MD5, of a key and some data */ function core_hmac_md5(key, data) { var bkey = str2binl(key); if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz); var ipad = Array(16), opad = Array(16); for(var i = 0; i < 16; i++) { ipad[i] = bkey[i] ^ 0x36363636; opad[i] = bkey[i] ^ 0x5C5C5C5C; } var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz); return core_md5(opad.concat(hash), 512 + 128); } /* * Add integers, wrapping at 2^32. This uses 16-bit operations internally * to work around bugs in some JS interpreters. */ function safe_add(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } /* * Bitwise rotate a 32-bit number to the left. */ function bit_rol(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); } /* * Convert a string to an array of little-endian words * If chrsz is ASCII, characters >255 have their hi-byte silently ignored. */ function str2binl(str) { var bin = Array(); var mask = (1 << chrsz) - 1; for(var i = 0; i < str.length * chrsz; i += chrsz) bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); return bin; } /* * Convert an array of little-endian words to a hex string. */ function binl2hex(binarray) { var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; var str = ""; for(var i = 0; i < binarray.length * 4; i++) { str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); } return str; } function winopen(page,largeur,hauteur,chrome) { var top = (screen.height-hauteur)/2; var left = (screen.width-largeur)/2; if (top>40) { top = top-40; } if (chrome==1) window.open(""+page,"_blank","chrome,resizable,modal,width="+largeur+",height="+hauteur+",top="+top+",left="+left); else { var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance(); messenger = messenger.QueryInterface(Components.interfaces.nsIMessenger); messenger.launchExternalURL(page); } } function URLEncode(plaintext) { // The Javascript escape and unescape functions do not correspond // with what browsers actually do... var SAFECHARS = "0123456789" + // Numeric "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic "abcdefghijklmnopqrstuvwxyz" + "-_.!~*'()"; // RFC2396 Mark characters var HEX = "0123456789ABCDEF"; var encoded = ""; for (var i = 0; i < plaintext.length; i++ ) { var ch = plaintext.charAt(i); if (ch == " ") { encoded += "+"; // x-www-urlencoded, rather than %20 } else if (SAFECHARS.indexOf(ch) != -1) { encoded += ch; } else { var charCode = ch.charCodeAt(0); if (charCode > 255) { alert( "Unicode Character '" + ch + "' cannot be encoded using standard URL encoding.\n" + "(URL encoding only supports 8-bit characters.)\n" + "A space (+) will be substituted." ); encoded += "+"; } else { encoded += "%"; encoded += HEX.charAt((charCode >> 4) & 0xF); encoded += HEX.charAt(charCode & 0xF); } } } // for return encoded; }PK qsa3g*f[[content/importDialog.js/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 1999 Netscape Communications Corporation. All * Rights Reserved. * * Contributor(s): */ var importType = null; var gImportMsgsBundle; var importService = 0; var successStr = null; var errorStr = null; var inputStr = null ; var progressInfo = null; var selectedModuleName = null; var selLocIsHome = false ; var addInterface = null ; function OnLoadImportDialog() { gImportMsgsBundle = document.getElementById("bundle_importMsgs"); importService = Components.classes["@mozilla.org/import/import-service;1"].getService(); importService = top.importService.QueryInterface(Components.interfaces.nsIImportService); progressInfo = { }; progressInfo.progressWindow = null; progressInfo.importInterface = null; progressInfo.mainWindow = window; progressInfo.intervalState = 0; progressInfo.importSuccess = false; progressInfo.importType = null; progressInfo.localFolderExists = false; // look in arguments[0] for parameters if (window.arguments && window.arguments.length >= 1 && "importType" in window.arguments[0] && window.arguments[0].importType) { // keep parameters in global for later importType = window.arguments[0].importType; progressInfo.importType = top.importType; } else { importType = "addressbook"; progressInfo.importType = "addressbook"; } // MemotooThunderbird: DEBUT importType = "addressbook"; progressInfo.importType = "addressbook"; // MemotooThunderbird: FIN SetUpImportType(); // MemotooThunderbird: DEBUT next(); next(); // MemotooThunderbird: FIN // on startup, set the focus to the control element // for accessibility reasons. // if we used the wizardOverlay, we would get this for free. // see bug #101874 document.getElementById("importFields").focus(); } function SetUpImportType() { // set dialog title var typeRadioGroup = document.getElementById("importFields"); switch (importType) { case "mail": typeRadioGroup.selectedItem = document.getElementById("mailRadio"); break; case "addressbook": typeRadioGroup.selectedItem = document.getElementById("addressbookRadio"); break; case "settings": typeRadioGroup.selectedItem = document.getElementById("settingsRadio"); break; } ListModules(); } function SetDivText(id, text) { var div = document.getElementById(id); if (div) { if (!div.childNodes.length) { var textNode = document.createTextNode(text); div.appendChild(textNode); } else if ( div.childNodes.length == 1 ) { div.childNodes[0].nodeValue = text; } } } function CheckIfLocalFolderExists() { var acctMgr = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager); if (acctMgr) { try { if (acctMgr.localFoldersServer) progressInfo.localFolderExists = true; } catch (ex) { progressInfo.localFolderExists = false; } } } function GetStringBundle(aURL) { var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService(); stringBundleService = stringBundleService.QueryInterface(Components.interfaces.nsIStringBundleService); var stringBundle = stringBundleService.createBundle(aURL); if (stringBundle) return stringBundle.QueryInterface(Components.interfaces.nsIStringBundle); } function ImportDialogOKButton() { var listbox = document.getElementById('moduleList'); var deck = document.getElementById("stateDeck"); var header = document.getElementById("header"); var progressMeterEl = document.getElementById("progressMeter"); var progressStatusEl = document.getElementById("progressStatus"); var progressTitleEl = document.getElementById("progressTitle"); // better not mess around with navigation at this point var nextButton = document.getElementById("forward"); nextButton.setAttribute("disabled", "true"); var backButton = document.getElementById("back"); backButton.setAttribute("disabled", "true"); if ( listbox && listbox.selectedItems && (listbox.selectedItems.length == 1) ) { var importTypeRadioGroup = document.getElementById("importFields"); importType = importTypeRadioGroup.selectedItem.getAttribute("value"); var index = listbox.selectedItems[0].getAttribute('list-index'); var module = importService.GetModule(importType, index); var name = importService.GetModuleName(importType, index); selectedModuleName = name; if (module) { // Fix for Bug 57839 & 85219 // We use localFoldersServer(in nsIMsgAccountManager) to check if Local Folder exists. // We need to check localFoldersServer before importing "mail" or "settings". // Reason: We will create an account with an incoming server of type "none" after // importing "mail", so the localFoldersServer is valid even though the Local Folder // is not created. if (importType == "mail" || importType == "settings") CheckIfLocalFolderExists(); var meterText = ""; switch(importType) { case "mail": top.successStr = Components.classes["@mozilla.org/supports-string;1"].createInstance(); if (top.successStr) { top.successStr = top.successStr.QueryInterface( Components.interfaces.nsISupportsString); } top.errorStr = Components.classes["@mozilla.org/supports-string;1"].createInstance(); if (top.errorStr) top.errorStr = top.errorStr.QueryInterface( Components.interfaces.nsISupportsString); if (ImportMail( module, top.successStr, top.errorStr) == true) { // We think it was a success, either, we need to // wait for the import to finish // or we are done! if (top.progressInfo.importInterface == null) { ShowImportResults(true, 'Mail'); return( true); } else { meterText = gImportMsgsBundle.getFormattedString('MailProgressMeterText', [ name ]); header.setAttribute("description", meterText); progressStatusEl.setAttribute("label", ""); progressTitleEl.setAttribute("label", meterText); deck.setAttribute("selectedIndex", "2"); progressInfo.progressWindow = top.window; progressInfo.intervalState = setInterval("ContinueImportCallback()", 100); return( true); } } else { ShowImportResults(false, 'Mail'); // enable back and next buttons so that users can retry or pick other import options. nextButton.removeAttribute("disabled"); backButton.removeAttribute("disabled"); return( false); } break; case "addressbook": top.successStr = Components.classes["@mozilla.org/supports-string;1"].createInstance(); if (top.successStr) top.successStr = top.successStr.QueryInterface( Components.interfaces.nsISupportsString); top.errorStr = Components.classes["@mozilla.org/supports-string;1"].createInstance(); if (top.errorStr) top.errorStr = top.errorStr.QueryInterface( Components.interfaces.nsISupportsString); top.inputStr = Components.classes["@mozilla.org/supports-string;1"].createInstance(); if (top.inputStr) top.inputStr = top.inputStr.QueryInterface( Components.interfaces.nsISupportsString); if (ImportAddress( module, top.successStr, top.errorStr) == true) { // We think it was a success, either, we need to // wait for the import to finish // or we are done! if (top.progressInfo.importInterface == null) { ShowImportResults(true, 'Address'); return( true); } else { meterText = gImportMsgsBundle.getFormattedString('AddrProgressMeterText', [ name ]); header.setAttribute("description", meterText); progressStatusEl.setAttribute("label", ""); progressTitleEl.setAttribute("label", meterText); deck.setAttribute("selectedIndex", "2"); progressInfo.progressWindow = top.window; progressInfo.intervalState = setInterval("ContinueImportCallback()", 100); return( true); } } else { ShowImportResults(false, 'Address'); // re-enable the next button, as we are here // because the user cancelled when picking an addressbook file to import. // enable next, so they can try again nextButton.removeAttribute("disabled"); // also enable back button so that users can pick other import options. backButton.removeAttribute("disabled"); return( false); } break; case "settings": var error = new Object(); error.value = null; var newAccount = new Object(); if (!ImportSettings( module, newAccount, error)) { if (error.value) ShowImportResultsRaw(gImportMsgsBundle.getString('ImportSettingsFailed'), null, false); // the user canceled the operation, shoud we dismiss // this dialog or not? return false; } else ShowImportResultsRaw(gImportMsgsBundle.getFormattedString('ImportSettingsSuccess', [ name ]), null, true); break; } } } return true; } function SetStatusText( val) { var progressStatus = document.getElementById("progressStatus"); progressStatus.setAttribute( "label", val); } function SetProgress( val) { var progressMeter = document.getElementById("progressMeter"); progressMeter.setAttribute( "value", val); } function ContinueImportCallback() { progressInfo.mainWindow.ContinueImport( top.progressInfo); } function ImportSelectionChanged() { var listbox = document.getElementById('moduleList'); if ( listbox && listbox.selectedItems && (listbox.selectedItems.length == 1) ) { var index = listbox.selectedItems[0].getAttribute('list-index'); SetDivText('description', top.importService.GetModuleDescription(top.importType, index)); } } function CompareImportModuleName(a, b) { if (a.name > b.name) return 1; if (a.name < b.name) return -1; return 0; } function ListModules() { if (top.importService == null) return; var body = document.getElementById( "moduleList"); var max = body.childNodes.length - 1; while (max >= 0) { body.removeChild( body.childNodes[max]); max--; } var count = top.importService.GetModuleCount(top.importType); var i; var moduleArray = new Array(count); for (i = 0; i < count; i++) { moduleArray[i] = {name:top.importService.GetModuleName(top.importType, i), index:i }; } // sort the array of modules by name, so that they'll show up in the right order moduleArray.sort(CompareImportModuleName); for (i = 0; i < count; i++) { AddModuleToList(moduleArray[i].name, moduleArray[i].index); } } function AddModuleToList(moduleName, index) { var body = document.getElementById("moduleList"); var item = document.createElement('listitem'); item.setAttribute('label', moduleName); item.setAttribute('list-index', index); body.appendChild(item); } function ContinueImport( info) { var isMail = info.importType == 'mail' ? true : false; var clear = true; var deck; var pcnt; if (info.importInterface) { if (!info.importInterface.ContinueImport()) { info.importSuccess = false; clearInterval( info.intervalState); if (info.progressWindow != null) { deck = document.getElementById("stateDeck"); deck.setAttribute("selectedIndex", "3"); info.progressWindow = null; } ShowImportResults(false, isMail ? 'Mail' : 'Address'); } else if ((pcnt = info.importInterface.GetProgress()) < 100) { clear = false; if (info.progressWindow != null) { if (pcnt < 5) pcnt = 5; SetProgress( pcnt); if (isMail) { var mailName = info.importInterface.GetData( "currentMailbox"); if (mailName) { mailName = mailName.QueryInterface( Components.interfaces.nsISupportsString); if (mailName) SetStatusText( mailName.data); } } } } else { dump("*** WARNING! sometimes this shows results too early. \n"); dump(" something screwy here. this used to work fine.\n"); clearInterval( info.intervalState); info.importSuccess = true; if (info.progressWindow) { deck = document.getElementById("stateDeck"); deck.setAttribute("selectedIndex", "3"); info.progressWindow = null; } ShowImportResults(true, isMail ? 'Mail' : 'Address'); } } if (clear) { info.intervalState = null; info.importInterface = null; } } function ShowResults(doesWantProgress, result) { if (result) { if (doesWantProgress) { var deck = document.getElementById("stateDeck"); var header = document.getElementById("header"); var progressStatusEl = document.getElementById("progressStatus"); var progressTitleEl = document.getElementById("progressTitle"); var meterText = gImportMsgsBundle.getFormattedString('AddrProgressMeterText', [ name ]); header.setAttribute("description", meterText); progressStatusEl.setAttribute("label", ""); progressTitleEl.setAttribute("label", meterText); deck.setAttribute("selectedIndex", "2"); progressInfo.progressWindow = top.window; progressInfo.intervalState = setInterval("ContinueImportCallback()", 100); } else { ShowImportResults(true, 'Address'); } } else { ShowImportResults(false, 'Address'); } return true ; } function ShowImportResults(good, module) { // The callers seem to set 'good' to true even if there's something // in the error log. So we should only make it a success case if // error log/str is empty. var modSuccess = 'Import' + module + 'Success'; var modFailed = 'Import' + module + 'Failed'; var results, title; if (good && !errorStr.data) { title = gImportMsgsBundle.getFormattedString(modSuccess, [ selectedModuleName ? selectedModuleName : '' ]); results = successStr.data; } else if (errorStr.data) { title = gImportMsgsBundle.getFormattedString(modFailed, [ selectedModuleName ? selectedModuleName : '' ]); results = errorStr.data; } if (results && title) ShowImportResultsRaw(title, results, good); } function ShowImportResultsRaw(title, results, good) { SetDivText("status", title); var header = document.getElementById("header"); header.setAttribute("description", title); dump("*** results = " + results + "\n"); attachStrings("results", results); var deck = document.getElementById("stateDeck"); deck.setAttribute("selectedIndex", "3"); var nextButton = document.getElementById("forward"); nextButton.label = nextButton.getAttribute("finishedval"); nextButton.removeAttribute("disabled"); var cancelButton = document.getElementById("cancel"); cancelButton.setAttribute("disabled", "true"); var backButton = document.getElementById("back"); backButton.setAttribute("disabled", "true"); // If the Local Folder is not existed, create it after successfully // import "mail" and "settings" var checkLocalFolder = (top.progressInfo.importType == 'mail' || top.progressInfo.importType == 'settings') ? true : false; if (good && checkLocalFolder && !top.progressInfo.localFolderExists) { var messengerMigrator = Components.classes["@mozilla.org/messenger/migrator;1"].getService(Components.interfaces.nsIMessengerMigrator); if (messengerMigrator) messengerMigrator.createLocalMailAccount(false); } } function attachStrings(aNode, aString) { var attachNode = document.getElementById(aNode); if (!aString) { attachNode.parentNode.setAttribute("hidden", "true"); return; } var strings = aString.split("\n"); for (var i = 0; i < strings.length; i++) { if (strings[i]) { var currNode = document.createTextNode(strings[i]); attachNode.appendChild(currNode); var br = document.createElementNS("http://www.w3.org/1999/xhtml", 'br'); attachNode.appendChild( br); } } } function ShowAddressComplete( good) { var str = null; if (good == true) { if ((top.selectedModuleName != null) && (top.selectedModuleName.length > 0)) str = gImportMsgsBundle.getFormattedString('ImportAddressSuccess', [ top.selectedModuleName ]); else str = gImportMsgsBundle.getFormattedString('ImportAddressSuccess', [ "" ]); str += "\n"; str += "\n" + top.successStr.data; } else { if ((top.errorStr.data != null) && (top.errorStr.data.length > 0)) { if ((top.selectedModuleName != null) && (top.selectedModuleName.length > 0)) str = gImportMsgsBundle.getFormattedString('ImportAddressFailed', [ top.selectedModuleName ]); else str = gImportMsgsBundle.getFormattedString('ImportAddressFailed', [ "" ]); str += "\n" + top.errorStr.data; } } if (str != null) alert( str); } function CreateNewFileSpecFromPath( inPath) { var file = Components.classes["@mozilla.org/filespec;1"].createInstance(); if (file != null) { file = file.QueryInterface( Components.interfaces.nsIFileSpec); if (file != null) { file.nativePath = inPath; } } return( file); } /* Import Settings from a specific module, returns false if it failed and true if successful. A "local mail" account is returned in newAccount. This is only useful in upgrading - import the settings first, then import mail into the account returned from ImportSettings, then import address books. An error string is returned as error.value */ function ImportSettings( module, newAccount, error) { var setIntf = module.GetImportInterface( "settings"); if (setIntf != null) setIntf = setIntf.QueryInterface( Components.interfaces.nsIImportSettings); if (setIntf == null) { error.value = gImportMsgsBundle.getString('ImportSettingsBadModule'); return( false); } // determine if we can auto find the settings or if we need to ask the user var location = new Object(); var description = new Object(); var result = setIntf.AutoLocate( description, location); if (result == false) { // In this case, we couldn't not find the settings if (location.value != null) { // Settings were not found, however, they are specified // in a file, so ask the user for the settings file. var filePicker = Components.classes["@mozilla.org/filepicker;1"].createInstance(); if (filePicker != null) { filePicker = filePicker.QueryInterface( Components.interfaces.nsIFilePicker); if (filePicker != null) { var file = null; try { filePicker.init( top.window, gImportMsgsBundle.getString('ImportSelectSettings'), Components.interfaces.nsIFilePicker.modeOpen); filePicker.appendFilters( Components.interfaces.nsIFilePicker.filterAll); filePicker.show(); if (filePicker.file && (filePicker.file.path.length > 0)) file = CreateNewFileSpecFromPath( filePicker.file.path); else file = null; } catch(ex) { file = null; error.value = null; return( false); } if (file != null) { setIntf.SetLocation( file); } else { error.value = null; return( false); } } else { error.value = gImportMsgsBundle.getString('ImportSettingsNotFound'); return( false); } } else { error.value = gImportMsgsBundle.getString('ImportSettingsNotFound'); return( false); } } else { error.value = gImportMsgsBundle.getString('ImportSettingsNotFound'); return( false); } } // interesting, we need to return the account that new // mail should be imported into? // that's really only useful for "Upgrade" result = setIntf.Import( newAccount); if (result == false) { error.value = gImportMsgsBundle.getString('ImportSettingsFailed'); } return( result); } function CreateNewFileSpec( inFile) { var file = Components.classes["@mozilla.org/filespec;1"].createInstance(); if (file != null) { file = file.QueryInterface( Components.interfaces.nsIFileSpec); if (file != null) { file.fromFileSpec( inFile); } } return( file); } function ImportMail( module, success, error) { if (top.progressInfo.importInterface || top.progressInfo.intervalState) { error.data = gImportMsgsBundle.getString('ImportAlreadyInProgress'); return( false); } top.progressInfo.importSuccess = false; var mailInterface = module.GetImportInterface( "mail"); if (mailInterface != null) mailInterface = mailInterface.QueryInterface( Components.interfaces.nsIImportGeneric); if (mailInterface == null) { error.data = gImportMsgsBundle.getString('ImportMailBadModule'); return( false); } var loc = mailInterface.GetData( "mailLocation"); if (loc == null) { // No location found, check to see if we can ask the user. if (mailInterface.GetStatus( "canUserSetLocation") != 0) { if (selectedModuleName == gImportMsgsBundle.getString('Comm4xImportName')) { var errorValue = true; //open the profile dialog. var comm4xprofile = Components.classes["@mozilla.org/comm4xProfile;1"].createInstance(); if(comm4xprofile != null) { comm4xprofile = comm4xprofile.QueryInterface( Components.interfaces.nsIComm4xProfile); if(comm4xprofile != null) { var length = {value:0}; var profileList = comm4xprofile.getProfileList(length); if (profileList) { var selected = {value:0}; if (length.value == 1) { errorValue = false; } else { var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); if (promptService) { var clickedOk = false; clickedOk = promptService.select(window, gImportMsgsBundle.getString('profileTitle'), gImportMsgsBundle.getString('profileText'), length.value, profileList, selected); if (clickedOk) { errorValue = false; } else { // users cancel the pick list dialog so just return and // don't set error string so that current dialog can stay. return( false); } } // promptService } if (!errorValue) { var profileDir = comm4xprofile.getMailDir(profileList[selected.value]); var localfile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); localfile.initWithPath(profileDir); mailInterface.SetData( "mailLocation", localfile); } } // profileList } // comm4xprofile } // comm4xprofile if (errorValue) { error.data = gImportMsgsBundle.getString('ImportMailNotFound'); return(false); } } else { var filePicker = Components.classes["@mozilla.org/filepicker;1"].createInstance(); if (filePicker != null) { filePicker = filePicker.QueryInterface( Components.interfaces.nsIFilePicker); if (filePicker != null) { try { filePicker.init( top.window, gImportMsgsBundle.getString('ImportSelectMailDir'), Components.interfaces.nsIFilePicker.modeGetFolder); filePicker.appendFilters( Components.interfaces.nsIFilePicker.filterAll); filePicker.show(); if (filePicker.file && (filePicker.file.path.length > 0)) mailInterface.SetData( "mailLocation", filePicker.file); else return( false); } catch( ex) { // don't show an error when we return! return( false); } } else { error.data = gImportMsgsBundle.getString('ImportMailNotFound'); return( false); } } else { error.data = gImportMsgsBundle.getString('ImportMailNotFound'); return( false); } } } else { error.data = gImportMsgsBundle.getString('ImportMailNotFound'); return( false); } } if (mailInterface.WantsProgress()) { if (mailInterface.BeginImport( success, error, false)) { top.progressInfo.importInterface = mailInterface; // top.intervalState = setInterval( "ContinueImport()", 100); return true; } else return false; } else return mailInterface.BeginImport( success, error, false) ? true : false; } // The address import! A little more complicated than the mail import // due to field maps... function ImportAddress( module, success, error) { if (top.progressInfo.importInterface || top.progressInfo.intervalState) { error.data = gImportMsgsBundle.getString('ImportAlreadyInProgress'); return( false); } top.progressInfo.importSuccess = false; addInterface = module.GetImportInterface( "addressbook"); if (addInterface != null) addInterface = addInterface.QueryInterface( Components.interfaces.nsIImportGeneric); if (addInterface == null) { error.data = gImportMsgsBundle.getString('ImportAddressBadModule'); return( false); } var path ; // MemotooThunderbird: DEBUT /* var loc = addInterface.GetStatus( "autoFind"); if (loc == false) { loc = addInterface.GetData( "addressLocation"); if (loc != null) { loc = loc.QueryInterface( Components.interfaces.nsIFileSpec); if (loc != null) { if (!loc.exists) loc = null; } } } if (loc == null) { // Couldn't find the address book, see if we can // as the user for the location or not? if (addInterface.GetStatus( "canUserSetLocation") == 0) { // an autofind address book that could not be found! error.data = gImportMsgsBundle.getString('ImportAddressNotFound'); return( false); } var filePicker = Components.classes["@mozilla.org/filepicker;1"].createInstance(); if (filePicker != null) { filePicker = filePicker.QueryInterface( Components.interfaces.nsIFilePicker); if (filePicker == null) { error.data = gImportMsgsBundle.getString('ImportAddressNotFound'); return( false); } } else { error.data = gImportMsgsBundle.getString('ImportAddressNotFound'); return( false); } // The address book location was not found. // Determine if we need to ask for a directory // or a single file. var file = null; if (addInterface.GetStatus( "supportsMultiple") != 0) { // ask for dir try { filePicker.init( top.window, gImportMsgsBundle.getString('ImportSelectAddrDir'), Components.interfaces.nsIFilePicker.modeGetFolder); filePicker.appendFilters( Components.interfaces.nsIFilePicker.filterAll); filePicker.show(); if (filePicker.file && (filePicker.file.path.length > 0)) file = filePicker.file; else file = null; } catch( ex) { file = null; } } else { // ask for file try { filePicker.init( top.window, gImportMsgsBundle.getString('ImportSelectAddrFile'), Components.interfaces.nsIFilePicker.modeOpen); if (selectedModuleName == gImportMsgsBundle.getString('Comm4xImportName')) filePicker.appendFilter(gImportMsgsBundle.getString('Comm4xFiles'),"*.na2"); else { var addressbookBundle = GetStringBundle("chrome://messenger/locale/addressbook/addressBook.properties"); filePicker.appendFilter(addressbookBundle.GetStringFromName('LDIFFiles'), "*.ldi; *.ldif"); filePicker.appendFilter(addressbookBundle.GetStringFromName('CSVFiles'), "*.csv"); filePicker.appendFilter(addressbookBundle.GetStringFromName('TABFiles'), "*.tab; *.txt"); filePicker.appendFilters(Components.interfaces.nsIFilePicker.filterAll); } if (filePicker.show() == Components.interfaces.nsIFilePicker.returnCancel) return false; if (filePicker.file && (filePicker.file.path.length > 0)) file = filePicker.file; else file = null; } catch( ex) { dump("ImportAddress(): failure when picking a file to import: " + ex + "\n"); file = null; } } path = filePicker.file.leafName; if (file == null) { return( false); } addInterface.SetData("addressLocation", file); } */ var fichierTmp = Components.classes["@mozilla.org/file/directory_service;1"] .getService(Components.interfaces.nsIProperties) .get("TmpD", Components.interfaces.nsIFile); fichierTmp.append("memotoo-contacts.ldif"); //alert("->"+fichierTmp.path); if (! fichierTmp.exists()) { alert("Erreur lors de l'importation fichier temporaire introuvable -> Contactez le webmaster de Memotoo.com"); } addInterface.SetData("addressLocation", fichierTmp); // MemotooThunderbird: FIN // no need to use the fieldmap for 4.x import since we are using separate dialog if (selectedModuleName == gImportMsgsBundle.getString('Comm4xImportName')) { var deck = document.getElementById("stateDeck"); deck.setAttribute("selectedIndex", "4"); var isHomeRadioGroup = document.getElementById("homeorwork"); isHomeRadioGroup.selectedItem = document.getElementById("workRadio"); var forwardButton = document.getElementById("forward"); forwardButton.removeAttribute("disabled"); var warning = document.getElementById("warning"); var textStr = " " + path ; warning.setAttribute ('value', textStr) ; return false; } var map = addInterface.GetData( "fieldMap"); if (map != null) { map = map.QueryInterface( Components.interfaces.nsIImportFieldMap); if (map != null) { var result = new Object(); result.ok = false; top.window.openDialog( "chrome://messenger/content/fieldMapImport.xul", "", "chrome,modal,titlebar", {fieldMap: map, addInterface: addInterface, result: result}); } if (result.ok == false) return( false); } if (addInterface.WantsProgress()) { if (addInterface.BeginImport( success, error, selLocIsHome)) { top.progressInfo.importInterface = addInterface; // top.intervalState = setInterval( "ContinueImport()", 100); return( true); } else { return( false); } } else { if (addInterface.BeginImport( success, error, selLocIsHome)) { return( true); } else { return( false); } } } function SwitchType( newType) { top.importType = newType; top.progressInfo.importType = newType; SetUpImportType(); SetDivText('description', ""); } function next() { var deck = document.getElementById("stateDeck"); var index = deck.getAttribute("selectedIndex"); switch (index) { case "0": var backButton = document.getElementById("back"); backButton.removeAttribute("disabled"); var radioGroup = document.getElementById("importFields"); SwitchType(radioGroup.value); deck.setAttribute("selectedIndex", "1"); SelectFirstItem(); enableAdvance(); break; case "1": ImportDialogOKButton(); break; case "3": close(); break; case "4" : var isHomeRadioGroup = document.getElementById("homeorwork"); if (isHomeRadioGroup.selectedItem.getAttribute("value") == "Home") selLocIsHome = true ; ExportComm4x() ; break ; } } function ExportComm4x() { var result ; if (addInterface.WantsProgress()) { result = addInterface.BeginImport( successStr, errorStr, selLocIsHome) ; top.progressInfo.importInterface = addInterface; ShowResults(true, result) ; } else { result = addInterface.BeginImport( successStr, errorStr, selLocIsHome) ; ShowResults(false, result) ; } return true ; } function SelectFirstItem() { var listbox = document.getElementById("moduleList"); // MemotooThunderbird: DEBUT //listbox.selectedIndex = 0; listbox.selectedIndex = 3; // MemotooThunderbird: FIN ImportSelectionChanged(); } function enableAdvance() { var listbox = document.getElementById("moduleList"); var nextButton = document.getElementById("forward"); if (listbox.selectedItems.length) nextButton.removeAttribute("disabled"); else nextButton.setAttribute("disabled", "true"); } function back() { var deck = document.getElementById("stateDeck"); if (deck.getAttribute("selectedIndex") == "1") { var backButton = document.getElementById("back"); backButton.setAttribute("disabled", "true"); var nextButton = document.getElementById("forward"); nextButton.label = nextButton.getAttribute("nextval"); nextButton.removeAttribute("disabled"); deck.setAttribute("selectedIndex", "0"); } } PK M43c+[content/importDialog.xul %brandDTD; %importDTD; ]> PK y3y!!0content/memotoothunderbirdOverlayAddressBook.xul