Added field mapping UI
git-svn-id: svn://10.0.0.236/trunk@57772 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -24,3 +24,8 @@ importDialog.js
|
||||
importDialog.xul
|
||||
importProgress.js
|
||||
importProgress.xul
|
||||
fieldMapExport.xul
|
||||
fieldMapExport.js
|
||||
fieldMapImport.xul
|
||||
fieldMapImport.js
|
||||
|
||||
|
||||
160
mozilla/mailnews/import/resources/content/fieldMapExport.js
Normal file
160
mozilla/mailnews/import/resources/content/fieldMapExport.js
Normal file
@@ -0,0 +1,160 @@
|
||||
/* -*- 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 importService = 0;
|
||||
var fieldMap = null;
|
||||
|
||||
function OnLoadFieldMapExport()
|
||||
{
|
||||
// top.bundle = srGetStrBundle("chrome://messenger/locale/importMsgs.properties");
|
||||
top.importService = Components.classes["component://mozilla/import/import-service"].createInstance();
|
||||
top.importService = top.importService.QueryInterface(Components.interfaces.nsIImportService);
|
||||
|
||||
// We need a field map object...
|
||||
// assume we have one passed in? or just make one?
|
||||
if (window.arguments && window.arguments[0])
|
||||
top.fieldMap = window.arguments[0].fieldMap;
|
||||
if (!top.fieldMap) {
|
||||
top.fieldMap = top.importService.CreateNewFieldMap();
|
||||
top.fieldMap.DefaultFieldMap( top.fieldMap.numMozFields);
|
||||
}
|
||||
|
||||
doSetOKCancel( FieldExportOKButton, 0);
|
||||
|
||||
ListFields();
|
||||
}
|
||||
|
||||
function SetDivText(id, text)
|
||||
{
|
||||
var div = document.getElementById(id);
|
||||
|
||||
if ( div )
|
||||
{
|
||||
if ( div.childNodes.length == 0 )
|
||||
{
|
||||
var textNode = document.createTextNode(text);
|
||||
div.appendChild(textNode);
|
||||
}
|
||||
else if ( div.childNodes.length == 1 )
|
||||
div.childNodes[0].nodeValue = text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function FieldExportOKButton()
|
||||
{
|
||||
// hmmm... can we re-build the map from the tree values?
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function FieldSelectionChanged()
|
||||
{
|
||||
var tree = document.getElementById('fieldList');
|
||||
if ( tree && tree.selectedItems && (tree.selectedItems.length == 1) )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
function ExportSelectionChanged()
|
||||
{
|
||||
var tree = document.getElementById('exportList');
|
||||
if ( tree && tree.selectedItems && (tree.selectedItems.length == 1) )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ListFields() {
|
||||
if (top.fieldMap == null)
|
||||
return;
|
||||
|
||||
// we should fill in the field list with the data from the field map?
|
||||
var body = document.getElementById("fieldBody");
|
||||
var count = top.fieldMap.numMozFields;
|
||||
for (i = 0; i < count; i++) {
|
||||
AddFieldToList( body, top.fieldMap.GetFieldDescription( i), i);
|
||||
}
|
||||
|
||||
body = document.getElementById("exportBody");
|
||||
count = top.fieldMap.mapSize;
|
||||
var index;
|
||||
for (i = 0; i < count; i++) {
|
||||
index = top.fieldMap.GetFieldMap( i);
|
||||
AddFieldToList( body, top.fieldMap.GetFieldDescription( index), index);
|
||||
}
|
||||
}
|
||||
|
||||
function AddFieldToList(body, name, index)
|
||||
{
|
||||
|
||||
var item = document.createElement('treeitem');
|
||||
var row = document.createElement('treerow');
|
||||
var cell = document.createElement('treecell');
|
||||
cell.setAttribute('value', name);
|
||||
item.setAttribute('field-index', index);
|
||||
|
||||
row.appendChild(cell);
|
||||
item.appendChild(row);
|
||||
body.appendChild(item);
|
||||
}
|
||||
|
||||
function DeleteExportItems()
|
||||
{
|
||||
var tree = document.getElementById('exportList');
|
||||
if ( tree && tree.selectedItems && (tree.selectedItems.length > 0) ) {
|
||||
var body = document.getElementById("exportBody");
|
||||
if (body) {
|
||||
while (tree.selectedItems.length) {
|
||||
body.removeChild( tree.selectedItems[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function OnAddExport()
|
||||
{
|
||||
var tree = document.getElementById('fieldList');
|
||||
if ( tree && tree.selectedItems && (tree.selectedItems.length > 0) ) {
|
||||
var body = document.getElementById("exportBody");
|
||||
if (body) {
|
||||
var name;
|
||||
var fIndex;
|
||||
for (var index = 0; index < tree.selectedItems.length; index++) {
|
||||
name = tree.selectedItems[index].firstChild.firstChild.getAttribute( 'value');
|
||||
fIndex = tree.selectedItems[index].getAttribute( 'field-index');
|
||||
AddFieldToList( body, name, fIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function OnAddAllExport()
|
||||
{
|
||||
var body = document.getElementById("exportBody");
|
||||
var count = top.fieldMap.numMozFields;
|
||||
for (var i = 0; i < count; i++) {
|
||||
AddFieldToList( body, top.fieldMap.GetFieldDescription( i), i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
110
mozilla/mailnews/import/resources/content/fieldMapExport.xul
Normal file
110
mozilla/mailnews/import/resources/content/fieldMapExport.xul
Normal file
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
The contents of this file are subject to the Netscape 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/NPL/
|
||||
|
||||
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 Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://messenger/skin/" type="text/css"?>
|
||||
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://messenger/locale/fieldMapExport.dtd">
|
||||
|
||||
|
||||
<window xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&fieldMapExport.title;"
|
||||
class="dialog"
|
||||
style="padding:0px"
|
||||
onload="OnLoadFieldMapExport()"
|
||||
align="vertical">
|
||||
|
||||
<html:script src="chrome://global/content/strres.js"/>
|
||||
<html:script src="chrome://messenger/content/fieldMapExport.js"/>
|
||||
<!--html:script language="JavaScript" src="resource:/res/samples/DumpDOM.js"/-->
|
||||
|
||||
<keyset id="keyset"/>
|
||||
|
||||
<box align="horizontal">
|
||||
|
||||
<spring style="width:3em"/>
|
||||
|
||||
<!-- field list -->
|
||||
<box align="vertical">
|
||||
<spring style="height:1em"/>
|
||||
<html:div id="fieldLabel">Ye old fields</html:div>
|
||||
<spring style="height:.5em"/>
|
||||
|
||||
<box align="vertical" style="border: 1px inset white">
|
||||
<html:div style="width:10em; height:200px" flex="1">
|
||||
<tree id="fieldList" style="width:100%; height:100%" onselect="FieldSelectionChanged()">
|
||||
<treecol style="width:100%"/>
|
||||
<treechildren id="fieldBody"/>
|
||||
</tree>
|
||||
</html:div>
|
||||
</box>
|
||||
|
||||
<spring style="height:1.5em"/>
|
||||
|
||||
</box>
|
||||
|
||||
<spring style="width: 1em"/>
|
||||
|
||||
<box align="vertical" style="height:270px">
|
||||
<spring flex="50%"/>
|
||||
<titledbutton class="dialog push" onclick="OnAddExport()" value="&fieldMapExport.add;"/>
|
||||
<titledbutton class="dialog push" onclick="OnAddAllExport()" value="&fieldMapExport.addAll;"/>
|
||||
<spring flex="50%"/>
|
||||
</box>
|
||||
|
||||
<spring style="width:1em"/>
|
||||
|
||||
<!-- export list -->
|
||||
<box align="vertical">
|
||||
<spring style="height:1em"/>
|
||||
<html:div id="exportLabel">Export fields</html:div>
|
||||
<spring style="height:.5em"/>
|
||||
|
||||
<box align="vertical" style="border: 1px inset white">
|
||||
<html:div style="width:10em; height:200px" flex="1">
|
||||
<tree id="exportList" style="width:100%; height:100%"
|
||||
onselect="ExportSelectionChanged()"
|
||||
onkeyup="if (event.keyCode == 8) return( DeleteExportItems());"
|
||||
ondragover="return DragOverTree(event);"
|
||||
ondraggesture="return BeginDrag( event, true);"
|
||||
ondragdrop="return DropOnTree( event);">
|
||||
<treecol style="width:100%"/>
|
||||
<treechildren id="exportBody"/>
|
||||
</tree>
|
||||
</html:div>
|
||||
</box>
|
||||
|
||||
<spring style="height:1.5em"/>
|
||||
|
||||
</box>
|
||||
|
||||
<spring style="width:3em"/>
|
||||
|
||||
</box>
|
||||
|
||||
<!-- OK & Cancel buttons -->
|
||||
<box id="okCancelButtons"/>
|
||||
|
||||
</window>
|
||||
443
mozilla/mailnews/import/resources/content/fieldMapImport.js
Normal file
443
mozilla/mailnews/import/resources/content/fieldMapImport.js
Normal file
@@ -0,0 +1,443 @@
|
||||
var importService = 0;
|
||||
var fieldMap = null;
|
||||
var transferType = null;
|
||||
var recordNum = 0;
|
||||
var amAtEnd = false;
|
||||
var addInterface = null;
|
||||
var dialogResult = null;
|
||||
|
||||
function OnLoadFieldMapImport()
|
||||
{
|
||||
// top.bundle = srGetStrBundle("chrome://messenger/locale/importMsgs.properties");
|
||||
top.importService = Components.classes["component://mozilla/import/import-service"].createInstance();
|
||||
top.importService = top.importService.QueryInterface(Components.interfaces.nsIImportService);
|
||||
top.transferType = "text/plain";
|
||||
top.recordNum = 0;
|
||||
|
||||
// We need a field map object...
|
||||
// assume we have one passed in? or just make one?
|
||||
if (window.arguments && window.arguments[0]) {
|
||||
top.fieldMap = window.arguments[0].fieldMap;
|
||||
top.addInterface = window.arguments[0].addInterface;
|
||||
top.dialogResult = window.arguments[0].result;
|
||||
}
|
||||
if (top.fieldMap == null) {
|
||||
top.fieldMap = top.importService.CreateNewFieldMap();
|
||||
top.fieldMap.DefaultFieldMap( top.fieldMap.numMozFields);
|
||||
}
|
||||
|
||||
doSetOKCancel( FieldImportOKButton, 0);
|
||||
|
||||
ListFields();
|
||||
OnNextRecord();
|
||||
}
|
||||
|
||||
function SetDivText(id, text)
|
||||
{
|
||||
var div = document.getElementById(id);
|
||||
|
||||
if ( div )
|
||||
{
|
||||
if ( div.childNodes.length == 0 )
|
||||
{
|
||||
var textNode = document.createTextNode(text);
|
||||
div.appendChild(textNode);
|
||||
}
|
||||
else if ( div.childNodes.length == 1 )
|
||||
div.childNodes[0].nodeValue = text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function FieldSelectionChanged()
|
||||
{
|
||||
var tree = document.getElementById('fieldList');
|
||||
if ( tree && tree.selectedItems && (tree.selectedItems.length == 1) )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function IndexInMap( index)
|
||||
{
|
||||
var count = top.fieldMap.mapSize;
|
||||
var i;
|
||||
for (i = 0; i < count; i++) {
|
||||
if (top.fieldMap.GetFieldMap( i) == index)
|
||||
return( true);
|
||||
}
|
||||
|
||||
return( false);
|
||||
}
|
||||
|
||||
function ListFields() {
|
||||
if (top.fieldMap == null)
|
||||
return;
|
||||
|
||||
body = document.getElementById("fieldBody");
|
||||
count = top.fieldMap.mapSize;
|
||||
var index;
|
||||
var i;
|
||||
for (i = 0; i < count; i++) {
|
||||
index = top.fieldMap.GetFieldMap( i);
|
||||
AddFieldToList( body, top.fieldMap.GetFieldDescription( index), index, top.fieldMap.GetFieldActive( i));
|
||||
}
|
||||
|
||||
count = top.fieldMap.numMozFields;
|
||||
for (i = 0; i < count; i++) {
|
||||
if (!IndexInMap( i))
|
||||
AddFieldToList( body, top.fieldMap.GetFieldDescription( i), i, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function CheckClick( item)
|
||||
{
|
||||
if (item.getAttribute( 'isChecked') == "true") {
|
||||
item.setAttribute( 'isChecked', "false");
|
||||
item.firstChild.removeAttribute( 'checked');
|
||||
}
|
||||
else {
|
||||
item.setAttribute( 'isChecked', "true");
|
||||
item.firstChild.setAttribute( 'checked', "true");
|
||||
}
|
||||
|
||||
return( true);
|
||||
}
|
||||
|
||||
|
||||
function CreateField( name, index, on)
|
||||
{
|
||||
var item = document.createElement('treeitem');
|
||||
var row = document.createElement('treerow');
|
||||
var cell = document.createElement('treecell');
|
||||
cell.setAttribute('value', name);
|
||||
item.setAttribute('field-index', index);
|
||||
|
||||
var cCell = document.createElement( 'treecell');
|
||||
var cBox = document.createElement( 'html:input');
|
||||
cBox.setAttribute( 'type', "checkbox");
|
||||
if (on == true)
|
||||
cBox.setAttribute( 'checked', "true");
|
||||
cBox.setAttribute( 'onclick', "return BoxClick();");
|
||||
|
||||
cCell.appendChild( cBox);
|
||||
cCell.setAttribute( 'onclick', "return CheckClick( event.target);");
|
||||
cCell.setAttribute( 'isChecked', on);
|
||||
|
||||
row.appendChild( cCell);
|
||||
|
||||
|
||||
row.appendChild(cell);
|
||||
item.appendChild(row);
|
||||
|
||||
return( item);
|
||||
}
|
||||
|
||||
function AddFieldToList(body, name, index, on)
|
||||
{
|
||||
var item = CreateField( name, index, on);
|
||||
body.appendChild(item);
|
||||
}
|
||||
|
||||
function BeginDrag( event)
|
||||
{
|
||||
var tree = document.getElementById("fieldList");
|
||||
if ( event.target == tree )
|
||||
return( true); // continue propagating the event
|
||||
|
||||
if (!tree)
|
||||
return( false);
|
||||
|
||||
var dragService = Components.classes["component://netscape/widget/dragservice"].getService();
|
||||
if ( dragService ) dragService = dragService.QueryInterface(Components.interfaces.nsIDragService);
|
||||
if ( !dragService ) return(false);
|
||||
|
||||
var trans = Components.classes["component://netscape/widget/transferable"].createInstance();
|
||||
if ( trans ) trans = trans.QueryInterface(Components.interfaces.nsITransferable);
|
||||
if ( !trans ) return(false);
|
||||
|
||||
var genData = Components.classes["component://netscape/supports-string"].createInstance();
|
||||
if ( genData ) genData = genData.QueryInterface(Components.interfaces.nsISupportsString);
|
||||
if (!genData) return(false);
|
||||
|
||||
trans.addDataFlavor( top.transferType);
|
||||
|
||||
// the index is on the <treeitem> which is two levels above the <treecell> which is
|
||||
// the target of the event.
|
||||
var index = event.target.parentNode.parentNode.getAttribute("field-index");
|
||||
var indexStr = ("" + index);
|
||||
genData.data = indexStr;
|
||||
|
||||
trans.setTransferData ( top.transferType, genData, indexStr.length);
|
||||
|
||||
var transArray = Components.classes["component://netscape/supports-array"].createInstance();
|
||||
if ( transArray ) transArray = transArray.QueryInterface(Components.interfaces.nsISupportsArray);
|
||||
if ( !transArray ) return(false);
|
||||
|
||||
// put it into the transferable as an |nsISupports|
|
||||
var genTrans = trans.QueryInterface(Components.interfaces.nsISupports);
|
||||
transArray.AppendElement(genTrans);
|
||||
|
||||
var nsIDragService = Components.interfaces.nsIDragService;
|
||||
dragService.invokeDragSession ( transArray, null, nsIDragService.DRAGDROP_ACTION_MOVE);
|
||||
|
||||
return( false); // don't propagate the event if a drag has begun
|
||||
}
|
||||
|
||||
function FindRowFromIndex( body, index)
|
||||
{
|
||||
for (var i = 0; i < body.childNodes.length; i++) {
|
||||
if (body.childNodes[i].getAttribute( 'field-index') == index)
|
||||
return( i);
|
||||
}
|
||||
|
||||
return( -1);
|
||||
}
|
||||
|
||||
function FindRowFromItem( body, item)
|
||||
{
|
||||
for (var i = 0; i < body.childNodes.length; i++) {
|
||||
if (body.childNodes[i] == item)
|
||||
return( i);
|
||||
}
|
||||
|
||||
return( -1);
|
||||
}
|
||||
|
||||
function DropOnTree( event)
|
||||
{
|
||||
|
||||
var treeRoot = document.getElementById("fieldList");
|
||||
if (!treeRoot) return(false);
|
||||
|
||||
// target is the <treecell>, and the <treeitem> is two levels above
|
||||
var treeItem = event.target.parentNode.parentNode;
|
||||
if (!treeItem) return(false);
|
||||
|
||||
// get drop hint attributes
|
||||
var dropBefore = treeItem.getAttribute("dd-droplocation");
|
||||
var dropOn = treeItem.getAttribute("dd-dropon");
|
||||
|
||||
// calculate drop action
|
||||
var dropAction;
|
||||
if (dropBefore == "true") dropAction = "before";
|
||||
else if (dropOn == "true") dropAction = "on";
|
||||
else dropAction = "after";
|
||||
|
||||
dump( "DropAction: " + dropAction + "\n");
|
||||
|
||||
// calculate parent container node
|
||||
/* bookmarks.js uses this, not sure what it's for???
|
||||
var containerItem = treeItem;
|
||||
if (dropAction != "on")
|
||||
containerItem = treeItem.parentNode.parentNode;
|
||||
*/
|
||||
|
||||
var dragService = Components.classes["component://netscape/widget/dragservice"].getService();
|
||||
if ( dragService ) dragService = dragService.QueryInterface(Components.interfaces.nsIDragService);
|
||||
if ( !dragService ) return(false);
|
||||
|
||||
var dragSession = dragService.getCurrentSession();
|
||||
if ( !dragSession ) return(false);
|
||||
|
||||
var trans = Components.classes["component://netscape/widget/transferable"].createInstance();
|
||||
if ( trans ) trans = trans.QueryInterface(Components.interfaces.nsITransferable);
|
||||
if ( !trans ) return(false);
|
||||
trans.addDataFlavor( top.transferType);
|
||||
|
||||
var body = document.getElementById( "fieldBody");
|
||||
if (!body)
|
||||
return( false);
|
||||
|
||||
for ( var i = 0; i < dragSession.numDropItems; ++i )
|
||||
{
|
||||
dragSession.getData ( trans, i );
|
||||
var dataObj = new Object();
|
||||
var bestFlavor = new Object();
|
||||
var len = new Object();
|
||||
try {
|
||||
trans.getAnyTransferData( bestFlavor, dataObj, len);
|
||||
if ( dataObj ) {
|
||||
dataObj = dataObj.value.QueryInterface(Components.interfaces.nsISupportsString);
|
||||
}
|
||||
if ( !dataObj ) {
|
||||
continue;
|
||||
}
|
||||
var fIndex = parseInt( dataObj.data);
|
||||
|
||||
// so now what, move the given row to the new position!
|
||||
// find the source row index
|
||||
var srcRow = FindRowFromIndex( body, fIndex);
|
||||
if (srcRow < 0) {
|
||||
dump( "*** Error finding source row\n");
|
||||
continue;
|
||||
}
|
||||
var dstRow = FindRowFromItem( body, treeItem);
|
||||
if (dstRow < 0) {
|
||||
dump( "*** Error finding destination row\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
// always do before unless we can't
|
||||
if (dropAction == "on" || dropAction == "after") {
|
||||
dstRow++;
|
||||
if (dstRow >= body.childNodes.length) {
|
||||
if (srcRow == (body.childNodes.length - 1))
|
||||
continue;
|
||||
dstRow = -1;
|
||||
}
|
||||
}
|
||||
|
||||
var name;
|
||||
var on;
|
||||
|
||||
if (dstRow < 0) {
|
||||
// remove the row and append it to the end!
|
||||
var dstItem = body.childNodes[srcRow];
|
||||
body.removeChild( dstItem);
|
||||
body.appendChild( dstItem);
|
||||
|
||||
}
|
||||
else {
|
||||
if (dstRow == srcRow)
|
||||
continue;
|
||||
|
||||
// insert the row before dstRow
|
||||
var dstItem = body.childNodes[srcRow];
|
||||
// name = dstItem.firstChild.firstChild.getAttribute( 'value');
|
||||
// on = dstItem.getAttribute( 'isChecked');
|
||||
body.removeChild( dstItem);
|
||||
if (srcRow < dstRow)
|
||||
dstRow--;
|
||||
// dstItem = CreateField( name, fIndex, on);
|
||||
body.insertBefore( dstItem, body.childNodes[dstRow]);
|
||||
}
|
||||
|
||||
}
|
||||
catch( ex) {
|
||||
}
|
||||
}
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
function DragOverTree( event)
|
||||
{
|
||||
var validFlavor = false;
|
||||
var dragSession = null;
|
||||
var retVal = true;
|
||||
|
||||
var dragService = Components.classes["component://netscape/widget/dragservice"].getService();
|
||||
if ( dragService ) dragService = dragService.QueryInterface(Components.interfaces.nsIDragService);
|
||||
if ( !dragService ) return(false);
|
||||
|
||||
dragSession = dragService.getCurrentSession();
|
||||
if ( !dragSession ) return(false);
|
||||
|
||||
if ( dragSession.isDataFlavorSupported( top.transferType) ) validFlavor = true;
|
||||
|
||||
if (event.target == document.getElementById( "fieldBody")) return( false);
|
||||
|
||||
// touch the attribute on the rowgroup to trigger the repaint with the drop feedback.
|
||||
if ( validFlavor )
|
||||
{
|
||||
//XXX this is really slow and likes to refresh N times per second.
|
||||
var rowGroup = event.target.parentNode.parentNode;
|
||||
rowGroup.setAttribute ( "dd-triggerrepaint", 0 );
|
||||
dragSession.canDrop = true;
|
||||
// necessary??
|
||||
retVal = false; // do not propagate message
|
||||
}
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
function ShowSampleData( data)
|
||||
{
|
||||
var body = document.getElementById( "dataBody");
|
||||
var max = body.childNodes.length - 1;
|
||||
while (max >= 0) {
|
||||
body.removeChild( body.childNodes[max]);
|
||||
max--;
|
||||
}
|
||||
|
||||
// split up the string into individual str's for the tree nodes
|
||||
var fields = data.split( "\n");
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
var item = document.createElement('treeitem');
|
||||
var row = document.createElement('treerow');
|
||||
var cell = document.createElement('treecell');
|
||||
cell.setAttribute('value', fields[i]);
|
||||
row.appendChild(cell);
|
||||
item.appendChild(row);
|
||||
body.appendChild(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function FetchSampleData()
|
||||
{
|
||||
if (!top.addInterface)
|
||||
return( false);
|
||||
|
||||
var num = top.recordNum - 1;
|
||||
if (num < 0)
|
||||
num = 0;
|
||||
var data = top.addInterface.GetData( "sampleData-"+num);
|
||||
var result = false;
|
||||
if (data != null) {
|
||||
data = data.QueryInterface( Components.interfaces.nsISupportsWString);
|
||||
if (data != null) {
|
||||
ShowSampleData( data.data);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return( result);
|
||||
}
|
||||
|
||||
function OnPreviousRecord()
|
||||
{
|
||||
if (top.recordNum <= 1)
|
||||
return;
|
||||
top.recordNum--;
|
||||
top.amAtEnd = false;
|
||||
if (FetchSampleData()) {
|
||||
SetDivText( "recordNumber", ("" + top.recordNum));
|
||||
}
|
||||
}
|
||||
|
||||
function OnNextRecord()
|
||||
{
|
||||
if (top.amAtEnd)
|
||||
return;
|
||||
top.recordNum++;
|
||||
if (!FetchSampleData()) {
|
||||
top.amAtEnd = true;
|
||||
top.recordNum--;
|
||||
}
|
||||
else
|
||||
SetDivText( "recordNumber", ("" + top.recordNum));
|
||||
}
|
||||
|
||||
function FieldImportOKButton()
|
||||
{
|
||||
var body = document.getElementById( "fieldBody");
|
||||
var max = body.childNodes.length;
|
||||
var fIndex;
|
||||
var on;
|
||||
for (var i = 0; i < max; i++) {
|
||||
fIndex = body.childNodes[i].getAttribute( 'field-index');
|
||||
on = body.childNodes[i].firstChild.firstChild.getAttribute( 'isChecked');
|
||||
top.fieldMap.SetFieldMap( i, fIndex);
|
||||
if (on == "true")
|
||||
top.fieldMap.SetFieldActive( i, true);
|
||||
else
|
||||
top.fieldMap.SetFieldActive( i, false);
|
||||
}
|
||||
|
||||
top.dialogResult.ok = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
116
mozilla/mailnews/import/resources/content/fieldMapImport.xul
Normal file
116
mozilla/mailnews/import/resources/content/fieldMapImport.xul
Normal file
@@ -0,0 +1,116 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
The contents of this file are subject to the Netscape 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/NPL/
|
||||
|
||||
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 Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://messenger/skin/" type="text/css"?>
|
||||
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://messenger/locale/fieldMapImport.dtd">
|
||||
|
||||
|
||||
<window xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&fieldMapImport.title;"
|
||||
class="dialog"
|
||||
style="padding:0px"
|
||||
onload="OnLoadFieldMapImport()"
|
||||
align="vertical">
|
||||
|
||||
<html:script src="chrome://global/content/strres.js"/>
|
||||
<html:script src="chrome://messenger/content/fieldMapImport.js"/>
|
||||
<!-- <html:script language="JavaScript" src="resource:/res/samples/DumpDOM.js"/> -->
|
||||
|
||||
<keyset id="keyset"/>
|
||||
|
||||
<box align="horizontal">
|
||||
|
||||
<spring style="width:3em"/>
|
||||
|
||||
<!-- field list -->
|
||||
<box align="vertical">
|
||||
<spring style="height:1em"/>
|
||||
<html:div id="fieldLabel">&fieldMapImport.fieldListTitle;</html:div>
|
||||
<spring style="height:.5em"/>
|
||||
|
||||
<box align="vertical" style="border: 1px inset white">
|
||||
<html:div style="width:12em; height:200px" flex="1">
|
||||
<tree id="fieldList" style="width:100%; height:100%"
|
||||
onselect="FieldSelectionChanged()"
|
||||
ondragover="return DragOverTree(event);"
|
||||
ondraggesture="return BeginDrag( event);"
|
||||
ondragdrop="return DropOnTree( event);">
|
||||
<treecol style="width:20%"/>
|
||||
<treecol style="width:80%"/>
|
||||
<treechildren id="fieldBody"/>
|
||||
</tree>
|
||||
</html:div>
|
||||
</box>
|
||||
|
||||
<spring style="height:1.5em"/>
|
||||
|
||||
</box>
|
||||
|
||||
<spring style="width: 1em"/>
|
||||
|
||||
<box align="vertical">
|
||||
<spring style="height:1em"/>
|
||||
<html:div id="fieldLabel">&fieldMapImport.dataTitle;</html:div>
|
||||
<spring style="height:.5em"/>
|
||||
|
||||
<box align="vertical" style="border: 1px inset white">
|
||||
<html:div style="width:20em; height:200px" flex="1">
|
||||
<tree id="dataList" style="width:100%; height:100%">
|
||||
<treecol style="width:100%"/>
|
||||
<treechildren id="dataBody"/>
|
||||
</tree>
|
||||
</html:div>
|
||||
</box>
|
||||
|
||||
<spring style="height:1.5em"/>
|
||||
|
||||
</box>
|
||||
|
||||
<spring style="width:3em"/>
|
||||
|
||||
</box>
|
||||
|
||||
<spring style="height: 1em"/>
|
||||
|
||||
<box align="horizontal">
|
||||
<spring flex="50%"/>
|
||||
<titledbutton class="dialog push" id="previous" onclick="OnPreviousRecord()" value="&fieldMapImport.previous;"/>
|
||||
<spring style="width: 2em"/>
|
||||
<html:div>&fieldMapImport.recordNumber;</html:div>
|
||||
<spring style="width: 1em"/>
|
||||
<html:div id="recordNumber">0</html:div>
|
||||
<spring style="width: 2em"/>
|
||||
<titledbutton class="dialog push" id="next" onclick="OnNextRecord()" value="&fieldMapImport.next;"/>
|
||||
<spring flex="50%"/>
|
||||
</box>
|
||||
|
||||
<spring style="height: 3em"/>
|
||||
|
||||
<!-- OK & Cancel buttons -->
|
||||
<box id="okCancelButtons"/>
|
||||
|
||||
</window>
|
||||
@@ -2,466 +2,29 @@
|
||||
<body>
|
||||
|
||||
<script language="javascript">
|
||||
var intervalState = null;
|
||||
var importMailInterface = null;
|
||||
var importAddressInterface = null;
|
||||
var importSuccess = false;
|
||||
|
||||
function LoadImportService() {
|
||||
var module = Components.classes["component://mozilla/import/import-service"].createInstance();
|
||||
module = module.QueryInterface(Components.interfaces.nsIImportService);
|
||||
return( module);
|
||||
}
|
||||
|
||||
function ListModules( service, filter) {
|
||||
if (service == null)
|
||||
return;
|
||||
var count = service.GetModuleCount( filter);
|
||||
for (i = 0; i < count; i++) {
|
||||
dump( "\tModule available: " + service.GetModuleName( filter, i) + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
function ListUpgradeModules( service) {
|
||||
if (service == null)
|
||||
return;
|
||||
var count = service.GetModuleCount( "");
|
||||
var module;
|
||||
for (i = 0; i < count; i++) {
|
||||
module = service.GetModule( "", i);
|
||||
if ( module.supportsUpgrade) {
|
||||
dump( "\tUpgrade Module available: " + service.GetModuleName( "", i) + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ContinueMailImport() {
|
||||
clear = true;
|
||||
if (importMailInterface) {
|
||||
if (!importMailInterface.ContinueImport()) {
|
||||
importSuccess = false;
|
||||
dump( "Import mail failed, ContinueImport returned false\n");
|
||||
}
|
||||
else if (importMailInterface.GetProgress() < 100) {
|
||||
clear = false;
|
||||
dump( ".");
|
||||
}
|
||||
else {
|
||||
importSuccess = true;
|
||||
dump( "Mail import successful\n");
|
||||
}
|
||||
}
|
||||
if (clear == true) {
|
||||
dump( "Mail import finished\n");
|
||||
clearInterval( intervalState);
|
||||
intervalState = null;
|
||||
importMailInterface = null;
|
||||
}
|
||||
}
|
||||
|
||||
function ContinueAddressImport() {
|
||||
clear = true;
|
||||
if (importAddressInterface) {
|
||||
if (!importAddressInterface.ContinueImport()) {
|
||||
importSuccess = false;
|
||||
dump( "Import address failed, ContinueImport returned false\n");
|
||||
}
|
||||
else if (importAddressInterface.GetProgress() < 100) {
|
||||
clear = false;
|
||||
dump( ".");
|
||||
}
|
||||
else {
|
||||
importSuccess = true;
|
||||
dump( "Address import successful\n");
|
||||
}
|
||||
}
|
||||
if (clear == true) {
|
||||
dump( "Address import finished\n");
|
||||
clearInterval( intervalState);
|
||||
intervalState = null;
|
||||
importAddressInterface = null;
|
||||
}
|
||||
}
|
||||
|
||||
function ImportMail( module) {
|
||||
if (importMailInterface || intervalState) {
|
||||
dump( "Already importing something, wait till this one is done!\n");
|
||||
return( false);
|
||||
}
|
||||
|
||||
importSuccess = false;
|
||||
|
||||
var mailInterface = module.GetImportInterface( "mail");
|
||||
mailInterface = mailInterface.QueryInterface( Components.interfaces.nsIImportGeneric);
|
||||
|
||||
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) {
|
||||
var filePicker = Components.classes["component://netscape/filespecwithui"].createInstance();
|
||||
if (filePicker != null) {
|
||||
filePicker = filePicker.QueryInterface( Components.interfaces.nsIFileSpecWithUI);
|
||||
if (filePicker != null) {
|
||||
try {
|
||||
filePicker.chooseDirectory( "Select mail directory");
|
||||
mailInterface.SetLocation( filePicker.QueryInterface( Components.interfaces.nsIFileSpec));
|
||||
} catch( ex) {
|
||||
dump( "file picker failed to pick a directory\n");
|
||||
// don't show an error when we return!
|
||||
return( true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dump( "QueryInterface failed on the file picker\n");
|
||||
return( false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dump( "Unable to obtain file picker class\n");
|
||||
return( false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dump( "Unable to find mail to import\n");
|
||||
return( false);
|
||||
}
|
||||
}
|
||||
|
||||
if (mailInterface.WantsProgress()) {
|
||||
dump( "Beginning import with progress\n");
|
||||
if (mailInterface.BeginImport( null, null)) {
|
||||
dump( "Importing ");
|
||||
importMailInterface = mailInterface;
|
||||
intervalState = setInterval( "ContinueMailImport()", 100);
|
||||
|
||||
dump( "\nWaiting for import to finish.....\n");
|
||||
return( true);
|
||||
}
|
||||
else {
|
||||
dump( "BeginImport returned failure\n");
|
||||
return( false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (mailInterface.BeginImport( null, null)) {
|
||||
dump( "BeginImport successful without progress\n");
|
||||
return( true);
|
||||
}
|
||||
else {
|
||||
dump( "BeginImport FAILED without progress\n");
|
||||
return( false);
|
||||
}
|
||||
}
|
||||
|
||||
function toImport(importType)
|
||||
{
|
||||
/*
|
||||
window.openDialog("chrome:/messenger/content/fieldMapImport.xul",
|
||||
"fieldMapImportDialog",
|
||||
"chrome,modal");
|
||||
*/
|
||||
window.openDialog("chrome:/messenger/content/importDialog.xul",
|
||||
"",
|
||||
"chrome,modal",
|
||||
{importType:importType});
|
||||
|
||||
}
|
||||
|
||||
function ImportAddresses( module) {
|
||||
if (importAddressInterface || intervalState) {
|
||||
dump( "Already importing something, wait till this one is done!\n");
|
||||
return( false);
|
||||
}
|
||||
|
||||
importSuccess = false;
|
||||
|
||||
var addInterface = module.GetImportInterface( "addressbook");
|
||||
if (addInterface == null) {
|
||||
dump( "Unable to obtain address book interface\n");
|
||||
return( false);
|
||||
}
|
||||
|
||||
addInterface = addInterface.QueryInterface( Components.interfaces.nsIImportGeneric);
|
||||
if (addInterface == null) {
|
||||
dump( "Unable to obtain address book generic import interface\n");
|
||||
return( false);
|
||||
}
|
||||
|
||||
|
||||
var loc = addInterface.GetStatus( "autoFind");
|
||||
if (loc == false) {
|
||||
loc = addInterface.GetData( "addressLocation");
|
||||
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!
|
||||
dump( "Unable to locate address book for importing\n");
|
||||
return( false);
|
||||
}
|
||||
|
||||
var filePicker = Components.classes["component://netscape/filespecwithui"].createInstance();
|
||||
if (filePicker != null) {
|
||||
filePicker = filePicker.QueryInterface( Components.interfaces.nsIFileSpecWithUI);
|
||||
if (filePicker == null) {
|
||||
dump( "Error getting file picker interface\n");
|
||||
return( false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dump( "Error getting file picker component\n");
|
||||
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.chooseDirectory( "Select address book directory");
|
||||
file = filePicker.QueryInterface( Components.interfaces.nsIFileSpec);
|
||||
} catch( ex) {
|
||||
file = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// ask for file
|
||||
try {
|
||||
filePicker.chooseInputFile( "Select address book file", filePicker.eAllFiles, null, null);
|
||||
file = filePicker.QueryInterface( Components.interfaces.nsIFileSpec);
|
||||
} catch( ex) {
|
||||
file = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (file == null) {
|
||||
dump( "They didn't pick a file or dir!\n");
|
||||
return( true);
|
||||
}
|
||||
|
||||
addInterface.SetData( "addressLocation", file);
|
||||
}
|
||||
|
||||
var map = addInterface.GetData( "fieldMap");
|
||||
if (map != null) {
|
||||
// FIXME: Show modal UI to handle the field map!
|
||||
}
|
||||
|
||||
if (addInterface.WantsProgress()) {
|
||||
dump( "Beginning address import with progress\n");
|
||||
if (addInterface.BeginImport( null, null)) {
|
||||
dump( "Importing ");
|
||||
importAddressInterface = addInterface;
|
||||
intervalState = setInterval( "ContinueAddressImport()", 100);
|
||||
|
||||
dump( "\nWaiting for address import to finish.....\n");
|
||||
return( true);
|
||||
}
|
||||
else {
|
||||
dump( "BeginImport address returned failure\n");
|
||||
return( false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (addInterface.BeginImport( null, null)) {
|
||||
dump( "BeginImport address successful without progress\n");
|
||||
return( true);
|
||||
}
|
||||
else {
|
||||
dump( "BeginImport address FAILED without progress\n");
|
||||
return( false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ImportSettings( module, newAccount) {
|
||||
var setIntf = module.GetImportInterface( "settings");
|
||||
if (setIntf != null)
|
||||
setIntf = setIntf.QueryInterface( Components.interfaces.nsIImportSettings);
|
||||
if (setIntf == null) {
|
||||
dump( "Unable to obtain settings interface.\n");
|
||||
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["component://netscape/filespecwithui"].createInstance();
|
||||
if (filePicker != null) {
|
||||
filePicker = filePicker.QueryInterface( Components.interfaces.nsIFileSpecWithUI);
|
||||
if (filePicker != null) {
|
||||
// filePicker.create( window.top, "Select settings file", filePicker.modeLoad);
|
||||
try {
|
||||
filePicker.chooseInputFile( "Select settings file", filePicker.eAllFiles, null, null);
|
||||
setIntf.SetLocation( filePicker.QueryInterface( Components.interfaces.nsIFileSpec));
|
||||
} catch( ex) {
|
||||
dump( "file picker failed to pick a file\n");
|
||||
// don't show an error when we return!
|
||||
return( true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dump( "QueryInterface failed on the file picker\n");
|
||||
return( false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dump( "Unable to obtain file picker class\n");
|
||||
return( false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Settings are not specified in a file and were not found,
|
||||
// this means they cannot be imported.
|
||||
dump( "Unable to find settings to import\n");
|
||||
return( false);
|
||||
}
|
||||
}
|
||||
|
||||
// interesting, we need to return the account that new
|
||||
// mail should be imported into?
|
||||
// that's really only useful for "Upgrade"
|
||||
return( setIntf.Import( newAccount));
|
||||
}
|
||||
|
||||
|
||||
function importOEMail() {
|
||||
|
||||
dump( "Loading outlook express component\n");
|
||||
var module = Components.classes["component://mozilla/import/import-oe"].createInstance();
|
||||
module = module.QueryInterface(Components.interfaces.nsIImportModule);
|
||||
|
||||
dump( "Loaded outlook express import module\n");
|
||||
|
||||
ImportMail( module);
|
||||
}
|
||||
|
||||
function eudoraMail() {
|
||||
dump( "Loading eudora component\n");
|
||||
var module = Components.classes["component://mozilla/import/import-eudora"].createInstance();
|
||||
module = module.QueryInterface(Components.interfaces.nsIImportModule);
|
||||
|
||||
dump( "Loaded eudora import module\n");
|
||||
|
||||
ImportMail( module);
|
||||
}
|
||||
|
||||
|
||||
function importOEAddress() {
|
||||
|
||||
dump( "Loading outlook express component\n");
|
||||
var module = Components.classes["component://mozilla/import/import-oe"].createInstance();
|
||||
module = module.QueryInterface(Components.interfaces.nsIImportModule);
|
||||
|
||||
ImportAddresses( module);
|
||||
}
|
||||
|
||||
function eudoraAddress() {
|
||||
|
||||
dump( "Loading eudora component\n");
|
||||
var module = Components.classes["component://mozilla/import/import-eudora"].createInstance();
|
||||
module = module.QueryInterface(Components.interfaces.nsIImportModule);
|
||||
|
||||
dump( "Loaded eudora import module\n");
|
||||
|
||||
ImportAddresses( module);
|
||||
}
|
||||
|
||||
function importTextAddress() {
|
||||
dump( "Loading text import component\n");
|
||||
var module = Components.classes["component://mozilla/import/import-text"].createInstance();
|
||||
module = module.QueryInterface( Components.interfaces.nsIImportModule);
|
||||
dump( "Loaded text import module\n");
|
||||
|
||||
ImportAddresses( module);
|
||||
}
|
||||
|
||||
function importOESettings() {
|
||||
dump( "Loading outlook express component\n");
|
||||
var module = Components.classes["component://mozilla/import/import-oe"].createInstance();
|
||||
module = module.QueryInterface(Components.interfaces.nsIImportModule);
|
||||
|
||||
dump( "Loaded outlook express import module\n");
|
||||
|
||||
ImportSettings( module);
|
||||
}
|
||||
|
||||
function eudoraSettings() {
|
||||
dump( "Loading eudora component\n");
|
||||
var module = Components.classes["component://mozilla/import/import-eudora"].createInstance();
|
||||
module = module.QueryInterface(Components.interfaces.nsIImportModule);
|
||||
|
||||
dump( "Loaded eudora import module\n");
|
||||
|
||||
ImportSettings( module);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function GetModule( service, index, filter) {
|
||||
var module = service.GetModule( filter, index);
|
||||
return( module);
|
||||
}
|
||||
|
||||
function testLists() {
|
||||
var service = LoadImportService();
|
||||
dump( "Mail modules:\n");
|
||||
ListModules( service, "mail");
|
||||
|
||||
dump( "Addressbook modules:\n");
|
||||
ListModules( service, "addressbook");
|
||||
|
||||
dump( "Settings modules:\n");
|
||||
ListModules( service, "settings");
|
||||
|
||||
dump( "Upgrade modules:\n");
|
||||
ListUpgradeModules( service);
|
||||
|
||||
service = null;
|
||||
}
|
||||
|
||||
function trySettings( index) {
|
||||
var service = LoadImportService();
|
||||
if (service == null) {
|
||||
dump( "Unable to get import service\n");
|
||||
return( false);
|
||||
}
|
||||
var module = GetModule( service, index, "settings");
|
||||
if (module == null) {
|
||||
dump( "Unable to obtain settings module #" + index + "\n");
|
||||
return( false);
|
||||
}
|
||||
|
||||
if (ImportSettings( module) == true) {
|
||||
dump( "Import Settings success\n");
|
||||
return( true);
|
||||
}
|
||||
else {
|
||||
dump( "Import Settings failed\n");
|
||||
return( false);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<p>
|
||||
<form name="form">
|
||||
<input type="button" value="Import Outlook Express Mail" onclick="importOEMail();"><br>
|
||||
<input type="button" value="Import Outlook Express Address Book" onclick="importOEAddress();"><br>
|
||||
<input type="button" value="Import Outlook Express Settings" onclick="importOESettings();"><br>
|
||||
<input type="button" value="Import Eudora Mail" onclick="eudoraMail();"><br>
|
||||
<input type="button" value="Import Eudora Address" onclick="eudoraAddress();"><br>
|
||||
<input type="button" value="Import Eudora Settings" onclick="eudoraSettings();"><br>
|
||||
<input type="button" value="Test Listings" onclick="testLists();"><br>
|
||||
<input type="button" value="Import Settings from module #2" onclick="trySettings( 2);"><br>
|
||||
<input type="button" value="Import Text Address Book" onclick="importTextAddress();"><br>
|
||||
<input type="button" value="Import Address Books" onclick="toImport( 'addressbook');"><br>
|
||||
<input type="button" value="Import Mail" onclick="toImport( 'mail');"><br>
|
||||
<input type="button" value="Import Settings" onclick="toImport( 'settings');"><br>
|
||||
<form>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -1,3 +1,25 @@
|
||||
/* -*- 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 = 0;
|
||||
var bundle = 0;
|
||||
var importService = 0;
|
||||
@@ -99,14 +121,15 @@ function ImportDialogOKButton()
|
||||
return( true);
|
||||
}
|
||||
else {
|
||||
var meterText = top.bundle.GetStringFromName( 'MailProgressMeterText') + " " + name;
|
||||
// show the progress window...
|
||||
top.window.openDialog(
|
||||
"chrome://messenger/content/importProgress.xul",
|
||||
"",
|
||||
"chrome,modal",
|
||||
{windowTitle:"My Progress Window Title",
|
||||
progressTitle: "Importing some crap",
|
||||
progressStatus: "Now importing specific crap",
|
||||
{windowTitle: top.bundle.GetStringFromName( 'MailProgressTitle'),
|
||||
progressTitle: meterText,
|
||||
progressStatus: "",
|
||||
progressInfo: top.progressInfo});
|
||||
|
||||
dump( "*** Returned from progress window\n");
|
||||
@@ -140,14 +163,15 @@ function ImportDialogOKButton()
|
||||
return( true);
|
||||
}
|
||||
else {
|
||||
var meterText = top.bundle.GetStringFromName( 'AddrProgressMeterText') + " " + name;
|
||||
// show the progress window...
|
||||
top.window.openDialog(
|
||||
"chrome://messenger/content/importProgress.xul",
|
||||
"",
|
||||
"chrome,modal",
|
||||
{windowTitle:"My Address Window Title",
|
||||
progressTitle: "Importing some address",
|
||||
progressStatus: "Now importing specific crap",
|
||||
{windowTitle: top.bundle.GetStringFromName( 'AddrProgressTitle'),
|
||||
progressTitle: meterText,
|
||||
progressStatus: "",
|
||||
progressInfo: top.progressInfo});
|
||||
|
||||
return( true);
|
||||
@@ -299,17 +323,20 @@ function ShowMailComplete( good)
|
||||
|
||||
function ShowAddressComplete( good)
|
||||
{
|
||||
var str;
|
||||
var str = null;
|
||||
if (good == true) {
|
||||
str = top.bundle.GetStringFromName( 'ImportAddressSuccess');
|
||||
str += "\nsuccess: " + top.successStr.data + "\nerror:" + top.errorStr.data;
|
||||
}
|
||||
else {
|
||||
str = top.bundle.GetStringFromName( 'ImportAddressFailed');
|
||||
str += "\nerror: " + top.errorStr.data;
|
||||
if ((top.errorStr.data != null) && (top.errorStr.data.length > 0)) {
|
||||
str = top.bundle.GetStringFromName( 'ImportAddressFailed');
|
||||
str += "\nerror: " + top.errorStr.data;
|
||||
}
|
||||
}
|
||||
|
||||
alert( str);
|
||||
if (str != null)
|
||||
alert( str);
|
||||
}
|
||||
|
||||
|
||||
@@ -533,7 +560,20 @@ function ImportAddress( module, success, error) {
|
||||
|
||||
var map = addInterface.GetData( "fieldMap");
|
||||
if (map != null) {
|
||||
// FIXME: Show modal UI to handle the field map!
|
||||
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",
|
||||
{fieldMap: map,
|
||||
addInterface: addInterface,
|
||||
result: result});
|
||||
}
|
||||
if (result.ok == false)
|
||||
return( false);
|
||||
}
|
||||
|
||||
if (addInterface.WantsProgress()) {
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
/* -*- 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 progressMeter = 0;
|
||||
var progressInfo = null;
|
||||
@@ -18,10 +39,10 @@ function OnLoadProgressDialog()
|
||||
top.window.title = window.arguments[0].windowTitle;
|
||||
|
||||
if ( window.arguments[0].progressTitle )
|
||||
SetDivText( 'ProgressTitle', window.arguments[0].progressTitle );
|
||||
SetDivText( 'progressTitle', window.arguments[0].progressTitle );
|
||||
|
||||
if ( window.arguments[0].progressStatus )
|
||||
SetDivText( 'ProgressStatus', window.arguments[0].progressStatus );
|
||||
SetDivText( 'progressStatus', window.arguments[0].progressStatus );
|
||||
|
||||
top.progressInfo = window.arguments[0].progressInfo;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ Rights Reserved.
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
class="dialog"
|
||||
style="padding:0px"
|
||||
style="padding:0px; width:20em;"
|
||||
onload="OnLoadProgressDialog()"
|
||||
align="vertical">
|
||||
|
||||
@@ -41,7 +41,7 @@ Rights Reserved.
|
||||
|
||||
<keyset id="keyset"/>
|
||||
|
||||
<box align="vertical" flex="100%">
|
||||
<box align="vertical">
|
||||
|
||||
<html:div id="progressTitle">Title</html:div>
|
||||
|
||||
|
||||
@@ -24,11 +24,15 @@ DEPTH=..\..\..\..
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install::
|
||||
$(MAKE_INSTALL) import-test.html $(DIST)\bin\res\samples
|
||||
$(MAKE_INSTALL) importDialog.js $(DIST)\bin\chrome\messenger\content\default
|
||||
$(MAKE_INSTALL) importDialog.xul $(DIST)\bin\chrome\messenger\content\default
|
||||
$(MAKE_INSTALL) importProgress.xul $(DIST)\bin\chrome\messenger\content\default
|
||||
$(MAKE_INSTALL) importProgress.js $(DIST)\bin\chrome\messenger\content\default
|
||||
$(MAKE_INSTALL) import-test.html $(DIST)\bin\res\samples
|
||||
$(MAKE_INSTALL) importDialog.js $(DIST)\bin\chrome\messenger\content\default
|
||||
$(MAKE_INSTALL) importDialog.xul $(DIST)\bin\chrome\messenger\content\default
|
||||
$(MAKE_INSTALL) importProgress.xul $(DIST)\bin\chrome\messenger\content\default
|
||||
$(MAKE_INSTALL) importProgress.js $(DIST)\bin\chrome\messenger\content\default
|
||||
$(MAKE_INSTALL) fieldMapExport.xul $(DIST)\bin\chrome\messenger\content\default
|
||||
$(MAKE_INSTALL) fieldMapExport.js $(DIST)\bin\chrome\messenger\content\default
|
||||
$(MAKE_INSTALL) fieldMapImport.xul $(DIST)\bin\chrome\messenger\content\default
|
||||
$(MAKE_INSTALL) fieldMapImport.js $(DIST)\bin\chrome\messenger\content\default
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\res\samples\import-test.html
|
||||
@@ -36,6 +40,10 @@ clobber::
|
||||
rm -f $(DIST)\bin\chrome\messenger\content\default\importDialog.xul
|
||||
rm -f $(DIST)\bin\chrome\messenger\content\default\importProgress.js
|
||||
rm -f $(DIST)\bin\chrome\messenger\content\default\importProgress.xul
|
||||
rm -f $(DIST)\bin\chrome\messenger\content\default\fieldMapExport.js
|
||||
rm -f $(DIST)\bin\chrome\messenger\content\default\fieldMapExport.xul
|
||||
rm -f $(DIST)\bin\chrome\messenger\content\default\fieldMapImport.js
|
||||
rm -f $(DIST)\bin\chrome\messenger\content\default\fieldMapImport.xul
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,3 +21,6 @@
|
||||
#
|
||||
|
||||
importMsgs.properties
|
||||
fieldMapExport.dtd
|
||||
fieldMapImport.dtd
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<!--
|
||||
The contents of this file are subject to the Netscape 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/NPL/
|
||||
|
||||
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 Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
-->
|
||||
|
||||
<!ENTITY fieldMapExport.title "Export Address Book">
|
||||
<!ENTITY fieldMapExport.add "Add Field ->">
|
||||
<!ENTITY fieldMapExport.addAll "Add All ->">
|
||||
<!ENTITY fieldList.label "Address Fields">
|
||||
@@ -0,0 +1,27 @@
|
||||
<!--
|
||||
The contents of this file are subject to the Netscape 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/NPL/
|
||||
|
||||
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 Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
-->
|
||||
|
||||
<!ENTITY fieldMapImport.title "Import Address Book">
|
||||
<!ENTITY fieldMapImport.recordNumber "Record:">
|
||||
<!ENTITY fieldMapImport.next "Next">
|
||||
<!ENTITY fieldMapImport.previous "Previous">
|
||||
<!ENTITY fieldMapImport.fieldListTitle "Address Book fields:">
|
||||
<!ENTITY fieldMapImport.dataTitle "Record to import:">
|
||||
|
||||
@@ -288,3 +288,9 @@ ImportAddressBadModule=Unable to load address book import module
|
||||
ImportAddressNotFound=Unable to find any address books to import. Check to make sure the selected application or format is correctly installed on this machine.
|
||||
ImportAddressFailed=An error occurred importing addresses from
|
||||
ImportAddressSuccess=Addresses were successfully imported from
|
||||
|
||||
#Progress strings
|
||||
MailProgressTitle=Importing Mail
|
||||
MailProgressMeterText=Converting mailboxes from
|
||||
AddrProgressTitle=Importing Address Books
|
||||
AddrProgressMeterText=Converting address books from
|
||||
|
||||
@@ -25,7 +25,12 @@ include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install::
|
||||
$(MAKE_INSTALL) importMsgs.properties $(DIST)\bin\chrome\messenger\locale\en-US
|
||||
$(MAKE_INSTALL) fieldMapExport.dtd $(DIST)\bin\chrome\messenger\locale\en-US
|
||||
$(MAKE_INSTALL) fieldMapImport.dtd $(DIST)\bin\chrome\messenger\locale\en-US
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)bin\chrome\messenger\locale\en-US\importMsgs.properties
|
||||
rm -f $(DIST)bin\chrome\messenger\locale\en-US\fieldMapExport.dtd
|
||||
rm -f $(DIST)bin\chrome\messenger\locale\en-US\fieldMapImport.dtd
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user