New module for session-based roaming like in Netscape Communicator 4.x.

r=Pete Zha <pete.zha@sun.com>
sr=darin (backend), jag (UI code)
a=tor
Tracking of bugs, regressions: Bug 228629
This commit is contained in:
mozilla.BenB%bucksch.org 2004-05-24 16:55:07 +00:00
Родитель 1c36c46f0f
Коммит f91b94bfac
48 изменённых файлов: 6793 добавлений и 12 удалений

Просмотреть файл

@ -0,0 +1,47 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# 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
# Ben Bucksch <http://www.bucksch.org> of
# Beonex <http://www.beonex.com>.
# Portions created by the Initial Developer are Copyright (C) 2003-2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH=../..
topsrcdir=@top_srcdir@
srcdir=@srcdir@
VPATH=@srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS=src
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,43 @@
This implements 4.x-like roaming.
To make the implementation vastly more simple, it has been decided that no
syncing during the session happens. The design will not allow that either
(at most sync in certain intervalls). A full-blown dynamic implementation
that immediately update the server when a data change occured requires the
cooperation of the data providers (bookmarks, prefs etc.) and is thus a huge
change that I will leave to somebody else to implement independant of this
roaming support here. alecf made such proposals a longer time ago on
n.p.m.prefs, they sounded very interesting, but unfortunately, nobody
implemented them so far.
When the users selected a profile, we will check, if it's a roaming profile
and where the data lies. If necessary, we will contact the server and
download the data as files. We will overwrite local profile files with
the downloaded ones. Then, the profile works as if it were fully local.
When the user then logs out (shuts down Mozilla or switches to another
profile), we upload the local files, overwriting those on the server.
Following Conrad Carlen's advise, I do not hook up using nsIProfileChangeStatus,
but in nsProfile directly. That just calls |nsISessionRoaming|.
Its implementation uses various protocol handlers like |mozSRoamingCopy| to
do the upload/download. These in turn may use generic protocol handlers like
the netwerk HTTP protocol to do that.
Also following Conrad's advise, I do not store the roaming prefs in the prefs
system (prefs.js etc.), because that it not yet initialized when I need the
data (of course - prefs.js, user.js etc. might get changed by us), but in
the Mozilla application registry. For the structure, see the comment at
the top of prefs/top.js.
Overview of implementation:
- transfer.js (the Transfer class and support classes) contains the
non-GUI logic to transfer files and track the progress and success.
- progressDialog.* shows the progress to the user (and also works as interface
to the C++ code)
- conflictCheck.js is the "controller", controls the overall execution flow.
It determines what has to be done (which files to transfer when etc.),
including the conflict resolution logic, and kicks off the transfers.
There is a long comment at the top describing the implementation.
- conflictResolution.* is a dialog to ask the user when we don't know which
version of a file to use.

Просмотреть файл

@ -0,0 +1,36 @@
sroaming.jar:
content/sroaming/contents.rdf (resources/content/contents.rdf)
content/sroaming/transfer/transfer.js (resources/content/transfer/transfer.js)
content/sroaming/transfer/utility.js (resources/content/transfer/utility.js)
content/sroaming/transfer/progressDialog.xul (resources/content/transfer/progressDialog.xul)
content/sroaming/transfer/progressDialog.js (resources/content/transfer/progressDialog.js)
content/sroaming/transfer/conflictResolve.xul (resources/content/transfer/conflictResolve.xul)
content/sroaming/transfer/conflictResolve.js (resources/content/transfer/conflictResolve.js)
content/sroaming/transfer/conflictCheck.js (resources/content/transfer/conflictCheck.js)
content/sroaming/prefs/all.js (resources/content/prefs/all.js)
content/sroaming/prefs/top.xul (resources/content/prefs/top.xul)
content/sroaming/prefs/top.js (resources/content/prefs/top.js)
content/sroaming/prefs/files.xul (resources/content/prefs/files.xul)
content/sroaming/prefs/files.js (resources/content/prefs/files.js)
content/sroaming/prefs/prefsOverlay.xul (resources/content/prefs/prefsOverlay.xul)
content/sroaming/prefs/firefox.xul (resources/content/prefs/firefox.xul)
content/sroaming/prefs/firefox.js (resources/content/prefs/firefox.js)
locale/en-US/sroaming/contents.rdf (resources/locale/en-US/contents.rdf)
locale/en-US/sroaming/transfer.properties (resources/locale/en-US/transfer.properties)
locale/en-US/sroaming/progressDialog.dtd (resources/locale/en-US/progressDialog.dtd)
locale/en-US/sroaming/conflictResolve.dtd (resources/locale/en-US/conflictResolve.dtd)
locale/en-US/sroaming/filedescr.properties (resources/locale/en-US/filedescr.properties)
locale/en-US/sroaming/prefs.dtd (resources/locale/en-US/prefs.dtd)
locale/en-US/sroaming/prefs.properties (resources/locale/en-US/prefs.properties)
skin/modern/sroaming/contents.rdf (resources/skin/modern/contents.rdf)
skin/modern/sroaming/progressDialog.css (resources/skin/modern/progressDialog.css)
skin/modern/sroaming/pending-small.gif (resources/skin/modern/pending-small.gif)
skin/modern/sroaming/busy-small.gif (resources/skin/modern/busy-small.gif)
skin/modern/sroaming/done-small.gif (resources/skin/modern/done-small.gif)
skin/modern/sroaming/failed-small.gif (resources/skin/modern/failed-small.gif)
skin/classic/sroaming/contents.rdf (resources/skin/classic/contents.rdf)
skin/classic/sroaming/progressDialog.css (resources/skin/classic/progressDialog.css)
skin/classic/sroaming/pending-small.gif (resources/skin/classic/pending-small.gif)
skin/classic/sroaming/busy-small.gif (resources/skin/classic/busy-small.gif)
skin/classic/sroaming/done-small.gif (resources/skin/classic/done-small.gif)
skin/classic/sroaming/failed-small.gif (resources/skin/classic/failed-small.gif)

Просмотреть файл

@ -0,0 +1,58 @@
todo:
- firefox: doesn't start up after the roaming dialog closed - bug 209880
don't care (for now):
- conflict
- some files failed, see XXX - update: eh, where was that?
- world gone
- problem: ddump, xpcom not defined after files done and dialog closed
solution: close dialog only when done with processing.
workaround: gTimeout
- problem: cancel by user in progress dialog: xpconnect errors
solution: prevent dialog closure (even if cancel pressed) until we're done.
- listing progressmeter doesn't work
- If one file is missing on both server and client and we didn't upload, but
there is no conflict, we still show one. That's due to that commented-out
check in compareFiles(). Mind the warning there and fix it.
- no preselection in conflict dialog
- not using statusText for FTP errors (reason 'file not readable' in this case)
Enhance
- better error dialog
- protocols
- HTTPS
- LDAP (already done by Sun?)
- IMAP
- password encrypt?
- no upload at switch profile
roaming urls
<ftp://user@ftp-server//path/to/dir/>
<http://user@http-server/path/to/dir/>
Mind the number of slashes.
Servers used: wu-FTPd and Apache with mod_roaming.
Feedback
- why do I need to implement nsIDocShellTreeItem for a http xml file *download*?
- onStopRequest (e.g. Request: http://ben:pgpben@http.server.bucksch.org/roaming/ben/listing.xml, StatusCode: NS_OK, HTTPResponse 200) called *before* the file finished. ftp and http: onStopRequest *before* onStatus(SENDING_TO), but only for the first file
clipboard
undefined.message=Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIURI.password]
undefined.result=2147500037
undefined.name=NS_ERROR_FAILURE
undefined.filename=chrome://sroaming/content/transfer/transfer.js
undefined.lineNumber=225
undefined.columnNumber=4294967295
WARNING: NS_ENSURE_TRUE(!aQualifiedName.IsEmpty()) failed, file ../../../../mozilla/content/base/src/nsNodeInfoManager.cpp, line 287
[4]
onStatus:
Request: ftp://...
StatusCode: NET_STATUS_SENDING_TO
StatusArg: ftp.server.bucksch.org
request to change listing.xml from done (NS_OK) to busy (NET_STATUS_SENDING_TO)
SetProgressStatus(1): listing.xml, busy, NET_STATUS_SENDING_TO
Setting listing.xml from done to busy

Просмотреть файл

@ -0,0 +1,72 @@
<?xml version="1.0"?>
<!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- 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 Roaming code.
-
- The Initial Developer of the Original Code is
- Ben Bucksch <http://www.bucksch.org> of
- Beonex <http://www.beonex.com>
- Portions created by the Initial Developer are Copyright (C) 2002-2004
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<!-- list all the packages being supplied by this jar -->
<RDF:Seq about="urn:mozilla:package:root">
<RDF:li resource="urn:mozilla:package:sroaming"/>
</RDF:Seq>
<!-- package information -->
<RDF:Description about="urn:mozilla:package:sroaming"
chrome:name="sroaming"
chrome:displayName="Roaming"
chrome:description="Session-Roaming up-/downloads selected profile files to/from a server during application shutdown/start, to faciliate working on different computers (but not at the same time)"
chrome:author="Ben Bucksch, Beonex"
chrome:authorURL="http://www.beonex.com"
chrome:localeVersion="0.9.4"
chrome:skinVersion="1.0"
chrome:extension="true"
chrome:settingsURL="chrome://sroaming/content/prefs/firefox.xul"
>
</RDF:Description>
<!-- overlay information -->
<RDF:Seq about="urn:mozilla:overlays">
<RDF:li resource="chrome://communicator/content/pref/preftree.xul"/>
</RDF:Seq>
<!-- Communicator Overlays -->
<RDF:Seq about="chrome://communicator/content/pref/preftree.xul">
<RDF:li>chrome://sroaming/content/prefs/prefsOverlay.xul</RDF:li>
</RDF:Seq>
</RDF:RDF>

Просмотреть файл

@ -15,9 +15,9 @@
* The Original Code is Mozilla Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2003
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
@ -395,11 +395,8 @@ RoamingPrefs.prototype =
{
try
{
var bundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService()
.QueryInterface(Components.interfaces.nsIStringBundleService)
.createBundle("chrome://sroaming/locale/prefs.properties");
var dialogTitle = bundle.GetStringFromName("RoamingErrorTitle");
var bundle = document.getElementById("bundle_roaming_prefs");
var dialogTitle = bundle.getString("RoamingErrorTitle");
var text = dialogTitle + "\n";
if (val)
text += bundle.formatStringFromName(prop, [val], 1);

Просмотреть файл

@ -0,0 +1,195 @@
/*-*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* See all.js */
var _elementIDs = []; // no prefs (nsIPrefBranch) needed, see above
var addedHandler = false; // see top.js
function Load()
{
parent.initPanel('chrome://sroaming/content/prefs/files.xul');
FileLabels();
SetFiles();
// dataManager.pageData doesn't work, because it needs to work on both panes
if (!parent.roaming)
parent.roaming = new RoamingPrefs();
DataToUI();
if (parent != null && "firefox" in parent)
{
if (!parent.firefox.filesLoad)
parent.firefox.filesLoad = Load;
if (!parent.firefox.filesUnload)
parent.firefox.filesUnload = Unload;
}
if (!addedHandler)
{
addedHandler = true;
parent.hPrefWindow.registerOKCallbackFunc(function()
{
UIToData();
parent.roaming.okClicked();
});
}
}
// Logic
// some files have a non-static name. set these filenames here.
function SetFiles()
{
var prefs = Components.classes["@mozilla.org/preferences;1"]
.getService(Components.interfaces.nsIPrefBranch);
try
{
SetFile("filePassword", prefs.getCharPref("signon.SignonFileName"));
SetFile("fileWallet", prefs.getCharPref("wallet.SchemaValueFileName"));
} catch (e) {}
// disable the nodes which are still invalid
var children = E("filesList").childNodes;
for (var i = 0; i < children.length; i++)
{
var checkbox = children[i];
if (!("getAttribute" in checkbox) ||
checkbox.getAttribute("type") != "checkbox")
continue;
if (checkbox.getAttribute("filename") == "")
checkbox.disabled = true;
}
}
function SetFile(elementID, filename)
{
var listitem = document.getElementById(elementID);
listitem.setAttribute("filename", filename);
}
// UI
// write data to widgets
function DataToUI()
{
var data = parent.roaming;
var filesList = E("filesList");
EnableTree(data.Enabled, filesList);
// first, disable all by default
var children = filesList.childNodes;
for (var i = 0, l = children.length; i < l; i++)
{
var checkbox = children[i];
if (!("getAttribute" in checkbox) ||
checkbox.getAttribute("type") != "checkbox")
// Somebody adds unwanted nodes as children to listbox :-(
continue;
checkbox.checked = false;
}
// then check for each file in the list, if it's in the checkboxes.
// enabled it, if so, otherwise create and enable it (for files added by
// the user).
for (i = 0, l = data.Files.length; i < l; i++)
{
var file = data.Files[i];
var found = false;
for (var i2 = 0, l2 = children.length; i2 < l2; i2++)
{
var checkbox = children[i2];
if ("getAttribute" in checkbox
&& checkbox.getAttribute("type") == "checkbox"
// Somebody adds unwanted nodes as children to listbox :-(
&& checkbox.getAttribute("filename") == file)
{
checkbox.checked = true;
found = true;
}
}
if (!found)
{
var li = document.createElement("listitem");
if (li)
{
li.setAttribute("type", "checkbox");
li.setAttribute("id", file);
li.setAttribute("filename", file);
li.setAttribute("label", file);
li.setAttribute("checked", "true");
filesList.appendChild(li);
}
}
}
}
// write widget content to data
function UIToData()
{
var data = parent.roaming;
data.Files = new Array(); // clear list
var children = E("filesList").childNodes;
for (var i = 0; i < children.length; i++)
{
var checkbox = children.item(i);
if (checkbox.checked)
data.Files.push(checkbox.getAttribute("filename"));
}
data.changed = true; // excessive
}
/* read human-readable names for profile files from filedescr.properties
and use them as labels */
function FileLabels()
{
var children = E("filesList").childNodes;
for (var i = 0; i < children.length; i++)
{
var checkbox = children[i];
if (!("getAttribute" in checkbox) ||
checkbox.getAttribute("type") != "checkbox")
continue;
checkbox.setAttribute("label",
GetFileDescription(checkbox.getAttribute("filename"),
checkbox.getAttribute("id")));
}
}

Просмотреть файл

@ -0,0 +1,157 @@
<?xml version="1.0"?>
<!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- 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 Roaming code.
-
- The Initial Developer of the Original Code is
- Ben Bucksch <http://www.bucksch.org> of
- Beonex <http://www.beonex.com>
- Portions created by the Initial Developer are Copyright (C) 2002-2004
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://sroaming/locale/prefs.dtd" >
<page id="winPref"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="Load();"
onunload="Unload();"
headertitle="&sroamingFiles-header.label;">
<script type="application/x-javascript"
src="chrome://sroaming/content/transfer/utility.js"/>
<script type="application/x-javascript"
src="chrome://sroaming/content/prefs/all.js"/>
<script type="application/x-javascript"
src="chrome://sroaming/content/prefs/files.js"/>
<description>&descrFiles.label;</description>
<stringbundle id="bundle_roaming_prefs" src="chrome://sroaming/locale/prefs.properties"/>
<stringbundle id="bundle_roaming_filedescr" src="chrome://sroaming/locale/filedescr.properties"/>
<vbox id="roamingSettings" flex="1">
<groupbox id="files" flex="1">
<caption label="&files.label;" />
<vbox flex="1">
<!--
Defaults are set in the default pref "roaming.default.files", displayed
names in filedescr.properties.
If you want to hide something from the normal user, don't mark it hidden,
but comment it out. Otherwise it will not show up as expected, if the user
added it manually (in prefs.js).
-->
<listbox id="filesList" flex="1">
<listitem type="checkbox"
id="bookmarks"
filename="bookmarks.html"
label="" />
<listitem type="checkbox"
id="addressbook"
filename="abook.mab"
label="" />
<listitem type="checkbox"
id="ab-history"
filename="history.mab"
label="" />
<listitem type="checkbox"
id="cookies"
filename="cookies.txt"
label="" />
<listitem type="checkbox"
id="cookperm"
filename="cookperm.txt"
label="" />
<listitem type="checkbox"
id="history"
filename="history.dat"
label="" />
<listitem type="checkbox"
id="passwords"
filename=""
label="" />
<listitem type="checkbox"
id="wallet"
filename=""
label="" />
<listitem type="checkbox"
id="helperapps"
filename="mimeTypes.rdf"
label="" />
<listitem type="checkbox"
id="sidebar"
filename="panels.rdf"
label="" />
<listitem type="checkbox"
id="localstorerdf"
filename="localstore.rdf"
label="" />
<listitem type="checkbox"
id="userstuff"
filename="user.js"
morefilenames="user.js,chrome/userChrome.css,chrome/userContent.css
- doesn't work, duh"
label="" />
<listitem type="checkbox"
id="mailViews"
filename="mailViews.dat"
label="" />
<!--
<listitem type="checkbox"
id="filters"
filename="mailserver/rules.dat and mailserver/msgFilterRules.dat
- crap"
label="" />
<listitem type="checkbox"
id="newsrc"
filename="newsserver/*.rc - dito"
label="" />
-->
<listitem type="checkbox"
id="emailcerts"
filename="cert7.db"
label="" />
<listitem type="checkbox"
id="cryptokeys"
filename="key3.db"
label="" />
<listitem type="checkbox"
id="secmod"
filename="secmod.db"
label="" />
</listbox>
</vbox>
</groupbox>
</vbox>
</page>

Просмотреть файл

@ -0,0 +1,82 @@
/*-*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ben Goodger
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// For compatibility with Communicator prefs window
//var hPrefWindow = new nsPrefWindow();
function nsPrefWindow()
{
this.okHandlers = new Array();
this.cancelHandlers = new Array();
}
nsPrefWindow.prototype =
{
onOK : function()
{
for(var i = 0; i < hPrefWindow.okHandlers.length; i++)
try
{
hPrefWindow.okHandlers[i]();
} catch (e) {}
},
onCancel : function()
{
for(var i = 0; i < hPrefWindow.cancelHandlers.length; i++)
try
{
hPrefWindow.cancelHandlers[i]();
} catch (e) {}
},
registerOKCallbackFunc : function(aFunction)
{
this.okHandlers.push(aFunction);
},
registerCancelCallbackFunc : function(aFunction)
{
this.cancelHandlers.push(aFunction);
}
};
// dummy
function initPanel(aPrefTag)
{
}

Просмотреть файл

@ -0,0 +1,89 @@
<?xml version="1.0"?>
<!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- 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 Roaming code.
-
- The Initial Developer of the Original Code is
- Ben Bucksch <http://www.bucksch.org> of
- Beonex <http://www.beonex.com>
- Portions created by the Initial Developer are Copyright (C) 2002-2004
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://communicator/skin/"
type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/profile/profile.css"
type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://sroaming/locale/prefs.dtd">
<dialog
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="roamingPrefsFirefox"
class="color-dialog non-resizable"
title="&sroaming-header.label;"
orient="vertical"
style="width: 41em; height: 41em;"
onload=""
ondialogaccept="return hPrefWindow.onOK();"
ondialogcancel="return hPrefWindow.onCancel();"
>
<script type="application/x-javascript"
src="chrome://sroaming/content/prefs/firefox.js"/>
<script type="application/x-javascript">
var hPrefWindow = new nsPrefWindow();
var firefox = new Object();
</script>
<tabbox flex="1">
<tabs>
<tab label="&sroamingTop-header.label;"
oncommand="firefox.filesUnload(); firefox.topLoad();" />
<tab label="&sroamingTop-header.label;"
oncommand="firefox.topUnload(); firefox.filesLoad();" />
</tabs>
<tabpanels flex="1">
<tabpanel flex="1">
<iframe id="top"
src="chrome://sroaming/content/prefs/top.xul"
flex="1" />
</tabpanel>
<tabpanel flex="1">
<iframe id="files"
src="chrome://sroaming/content/prefs/files.xul"
flex="1" />
</tabpanel>
</tabpanels>
</tabbox>
</dialog>

Просмотреть файл

@ -0,0 +1,64 @@
<?xml version="1.0"?>
<!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- 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 Roaming code.
-
- The Initial Developer of the Original Code is
- Ben Bucksch <http://www.bucksch.org> of
- Beonex <http://www.beonex.com>
- Portions created by the Initial Developer are Copyright (C) 2002-2004
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<!DOCTYPE overlay SYSTEM "chrome://sroaming/locale/prefs.dtd">
<overlay id="ovPrefs"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<treechildren id="panelChildren">
<treeitem container="true" id="sroamingItem">
<treerow>
<treecell class="treecell-indent"
url="chrome://sroaming/content/prefs/top.xul"
label="&sroaming-header.label;" />
</treerow>
<treechildren id="sroamingChildren">
<treeitem id="sroamingFiles">
<treerow>
<treecell class="treecell-indent"
url="chrome://sroaming/content/prefs/files.xul"
label="&sroamingFiles-header.label;" />
</treerow>
</treeitem>
</treechildren>
</treeitem>
</treechildren>
</overlay>

Просмотреть файл

@ -0,0 +1,149 @@
/*-*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* See all.js */
var _elementIDs = []; // no prefs (nsIPrefBranch) needed, see above
var addedHandler = false; /* Communicator's broken prefwindow
makes onload/onunload trigger every time the user
switches a pane (i.e. several times for the same pane).
This does not happen with the tabs in Firefox, and while
trying to make it work with both at once, I was almost
going insane. This onload/onunload/okHandler stuff here is
extremely fragile. This version happens to work, I don't
know why, but I can't see it anymore, after fighting
with it for maybe 2 days in Communicatior and slmost
another day in Firefox, only on this
onload/onunload/okHandler crap. */
function Load()
{
parent.initPanel('chrome://sroaming/content/prefs/top.xul');
// dataManager.pageData doesn't work, because it needs to work on both panes
if (!parent.roaming)
parent.roaming = new RoamingPrefs();
DataToUI();
if (parent != null && "firefox" in parent)
{
if (!parent.firefox.topLoad)
parent.firefox.topLoad = Load;
if (!parent.firefox.topUnload)
parent.firefox.topUnload = Unload;
}
if (!addedHandler)
{
addedHandler = true;
parent.hPrefWindow.registerOKCallbackFunc(function()
{
UIToData();
parent.roaming.okClicked();
});
}
}
// UI
// write data to widgets
function DataToUI()
{
var data = parent.roaming;
E("enabled").checked = data.Enabled;
E("methodSelect").value = data.Method;
E("streamURL").value = data.Stream.BaseURL;
E("streamUsername").value = data.Stream.Username;
E("streamPassword").value = data.Stream.Password;
E("streamSavePW").checked = data.Stream.SavePW;
E("copyDir").value = data.Copy.RemoteDir;
SwitchDeck(data.Method, E("methodSettingsDeck"));
EnableTree(data.Enabled, E("method"));
E("streamPassword").disabled = !data.Stream.SavePW || !data.Enabled;
}
// write widget content to data
function UIToData()
{
var data = parent.roaming;
data.Enabled = E("enabled").checked;
data.Method = E("methodSelect").value;
data.Stream.BaseURL = E("streamURL").value;
data.Stream.Username = E("streamUsername").value;
data.Stream.Password = E("streamPassword").value;
data.Stream.SavePW = E("streamSavePW").checked;
data.Copy.RemoteDir = E("copyDir").value;
data.changed = true; // excessive
}
// updates UI (esp. en/disabling of widgets) to match new user input
function SwitchChanged()
{
UIToData();
DataToUI();
}
// Displays a general warning about roaming
function ActivationWarning()
{
try
{
/* The pref here is intended not to exist (code logic falling back to
false) when the user first activates roaming,
then to be set, so that the user doesn't see the dialog twice.
It being a pref also leaves admins the choice of supressing it,
e.g. when they set up appropriate backups on behalf of the user on
the server or client in a large installation. */
var prefBranch = Components.classes["@mozilla.org/preferences;1"]
.getService(Components.interfaces.nsIPrefBranch);
try
{
showWarning = prefBranch.getBoolPref("roaming.showInitialWarning");
if (!showWarning)
return;
} catch(e) {}
var bundle = document.getElementById("bundle_roaming_prefs");
GetPromptService().alert(window, GetString("Alert"),
bundle.getString("ActivationWarning"));
prefBranch.setBoolPref("roaming.showInitialWarning", false);
} catch(e) {}
}

Просмотреть файл

@ -0,0 +1,146 @@
<?xml version="1.0"?>
<!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- 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 Roaming code.
-
- The Initial Developer of the Original Code is
- Ben Bucksch <http://www.bucksch.org> of
- Beonex <http://www.beonex.com>
- Portions created by the Initial Developer are Copyright (C) 2002-2004
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://sroaming/locale/prefs.dtd" >
<page id="winPref"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="Load();"
onunload="Unload();"
headertitle="&sroaming-header.label;">
<script type="application/x-javascript"
src="chrome://sroaming/content/transfer/utility.js"/>
<script type="application/x-javascript"
src="chrome://sroaming/content/prefs/all.js"/>
<script type="application/x-javascript"
src="chrome://sroaming/content/prefs/top.js"/>
<description>&descr.label;</description>
<stringbundle id="bundle_roaming_prefs" src="chrome://sroaming/locale/prefs.properties"/>
<stringbundle id="bundle_roaming_filedescr" src="chrome://sroaming/locale/filedescr.properties"/>
<checkbox id="enabled"
aoncommand="EnableTree(this.checked, E('roamingSettings'));
parent.roaming.enabled = this.checked;"
oncommand="ActivationWarning(); SwitchChanged();"
class="indent"
label="&enabled.label;"
accesskey="&enabled.accesskey;"
/>
<groupbox id="method">
<caption label="&method.label;" />
<vbox>
<menulist id="methodSelect"
oncommand="SwitchChanged();"
>
<menupopup>
<menuitem
value="0"
label="&methodStream.label;"
/>
<menuitem
value="1"
label="&methodCopy.label;"
/>
</menupopup>
</menulist>
</vbox>
<deck id="methodSettingsDeck">
<vbox id="streamSettings">
<grid flex="1">
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row>
<hbox align="center">
<label control="streamURL"
value="&streamURL.label;"
accesskey="&streamURL.accesskey;"
/>
</hbox>
<textbox id="streamURL" />
</row>
<row>
<hbox align="center">
<label control="streamUsername"
value="&streamUsername.label;"
accesskey="&streamUsername.accesskey;"
/>
</hbox>
<textbox id="streamUsername" />
</row>
<row>
<hbox />
<checkbox id="streamSavePW"
oncommand="SwitchChanged();"
label="&streamSavePW.label;"
accesskey="&streamSavePW.accesskey;"
/>
</row>
<row>
<hbox align="center">
<label control="streamPassword"
value="&streamPassword.label;"
accesskey="&streamPassword.accesskey;"
/>
</hbox>
<textbox type="password" id="streamPassword" />
</row>
</rows>
</grid>
</vbox>
<vbox id="copySettings">
<label control="copyDir"
value="&copyDir.label;"
accesskey="&copyDir.accesskey;"
/>
<textbox id="copyDir" />
</vbox>
</deck>
</groupbox>
</page>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,190 @@
/*-*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* ManyOne <http://www.manyone.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Code for the conflictResolve.xul dialog, which lets the user select
which of 2 conflicting versions of the same file to keep. */
var params = window.arguments[0].QueryInterface(
Components.interfaces.nsIDialogParamBlock);
var gIsDownload = true; // otherwise upload
var gCount = 0; // number of files
function Startup()
{
centerWindowOnScreen();
LoadElements();
ClearParam();
window.sizeToContent();
}
function AddItem(fileid, filename, server, local)
{
/*
<rows id="filerows">
<row>
<description><html:b>&filedescr.label;</html:b></description>
<description><html:b>&server.label;</html:b></description>
<description><html:b>&local.label;</html:b></description>
</row>
<radiogroup value="2"
style="display: -moz-grid-line;
-moz-box-orient: horizontal;"
flex="1"> <!-- acts as <column> -->
<description>file description</description>
<radio label="last modified server, size server" value="1"/>
<radio label="last modified local, size local" value="2"/>
</radiogroup>
<rows>
*/
var radiogroup = document.createElement("radiogroup");
radiogroup.setAttribute("id", fileid);
radiogroup.setAttribute("value", gIsDownload ? "2" : "1");
var cell;
cell = document.createElement("description");
cell.appendChild(document.createTextNode(GetFileDescription(filename)));
radiogroup.appendChild(cell);
cell = document.createElement("radio");
cell.setAttribute("value", "1");
if (server)
cell.setAttribute("label", server);
radiogroup.appendChild(cell);
cell = document.createElement("radio");
cell.setAttribute("value", "2");
if (local)
cell.setAttribute("label", local);
radiogroup.appendChild(cell);
var rows = document.getElementById("filerows");
rows.appendChild(radiogroup);
// WORKAROUND needs to be here, due to bug 209594
radiogroup.setAttribute("style",
"display: -moz-grid-line; -moz-box-orient: horizontal;");
}
function FileLabel(lastModified, size)
{
if (!lastModified || lastModified == "" || !size || size == "")
return GetString("NonExistant");
//return GetString("FileStatsUnknown");
var dateString = new Date(Number(lastModified)).toLocaleString();
return GetString("FileStats")
.replace(/%date%/, dateString)
.replace(/%size%/, size);
}
function LoadElements()
{
//For definition of meaning of params, see mozSRoaming.cpp::ConflictResolveUI
// download
var direction = params.GetInt(0);
//ddump("Passing in: Int 0 (direction) is " + direction);
if (direction != 1 && direction != 2)
dumpError("Bad direction param");
gIsDownload = direction == 1;
// count
gCount = params.GetInt(1);
//ddump("Passing in: Int 1 (count) is " + gCount);
if (gCount < 1)
dumpError("Bad count param");
// filenames
for (var i = 0; i < gCount; i++)
{
var value = params.GetString(i + 1);
//ddump("Passing in: String " + (i + 1) + " is " + value);
var values = value.split(",");
if (values.length != 1 && values.length != 5)
dumpError("Bad file param");
if (values.length == 5)
{
var server = FileLabel(values[1], values[2]);
var local = FileLabel(values[3], values[4]);
AddItem("file" + i, values[0], server, local);
}
else
AddItem("file" + i, values[0]);
}
var descr_deck = document.getElementById("intro");
descr_deck.setAttribute("selectedIndex", gIsDownload ? 0 : 1);
}
/* Because the param block has a different meaning on open and close, there
is a risk of misinterpreting the input as output. Thus, clear it to avoid
that. (0 values are intentionally not defined as legal.) */
function ClearParam()
{
params.SetInt(0, 0);
params.SetInt(1, 0);
}
function onOK()
{
//ddump("onOK()");
params.SetInt(0, 3); // OK
for (var i = 0; i < gCount; i++)
{
var radiogroup = document.getElementById("file" + i);
var choice = Number(radiogroup.value);
if (choice != 1 && choice != 2)
{
dumpError("Bad radiogroup value: -" + radiogroup.value +
"- -" + choice + "-");
onCancel();
}
params.SetInt(i + 1, choice);
//ddump("Passing back: Int " + (i + 1) + " is " + choice);
}
return true;
}
function onCancel()
{
//ddump("onCancel()");
params.SetInt(0, 4); // Cancel
return true;
}

Просмотреть файл

@ -0,0 +1,112 @@
<?xml version="1.0"?>
<!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- 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 Roaming code.
-
- The Initial Developer of the Original Code is
- Ben Bucksch <http://www.bucksch.org> of
- Beonex <http://www.beonex.com>
- Portions created by the Initial Developer are Copyright (C) 2002-2004
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://communicator/skin/"
type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/profile/profile.css"
type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://sroaming/locale/conflictResolve.dtd">
<dialog
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
id="conflictResolve"
class="color-dialog"
title="&windowtitle.label;"
orient="vertical"
style="width: 60em;"
onload="Startup();"
ondialogaccept="return onOK();"
ondialogcancel="return onCancel();"
>
<script type="application/x-javascript"
src="chrome://sroaming/content/transfer/conflictResolve.js"/>
<script type="application/x-javascript"
src="chrome://sroaming/content/transfer/utility.js"/>
<keyset id="dialogKeys"/>
<dialogheader class="header-large"
id="header"
title="&windowtitle.label;"
description="&subheader.label;"/>
<separator orient="vertical"/>
<stringbundle id="bundle_roaming_transfer" src="chrome://sroaming/locale/transfer.properties"/>
<stringbundle id="bundle_roaming_filedescr" src="chrome://sroaming/locale/filedescr.properties"/>
<deck id="intro">
<description style="width: 17em; border: 1px solid transparent;" flex="1">
&intro-download.label;
</description>
<description style="width: 17em; border: 1px solid transparent;" flex="1">
&intro-upload.label;
</description>
</deck>
<separator orient="vertical"/>
<!-- files with radios will be added here -->
<vbox valign="center">
<grid>
<columns>
<column flex="1"/>
<column flex="1"/>
<column flex="1"/>
</columns>
<rows id="filerows">
<row>
<description><html:b>&filedescr.label;</html:b></description>
<description><html:b>&server.label;</html:b></description>
<description><html:b>&local.label;</html:b></description>
</row>
</rows>
</grid>
</vbox>
<separator orient="vertical"/>
</dialog>

Просмотреть файл

@ -0,0 +1,409 @@
/*-*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Netscape Editor team
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Displays the progress of the down/upload of profile files to an
HTTP/FTP server.
It also initiates the actual transfer, using transfer.js,
see mozSRoamingStream.cpp for the reasons.
The Set*() part of this file needs a serious shakeout.
*/
var gTransfer; // main |Transfer| object, for the main files to be tranferred
var gDialog = new Object(); // references to widgets
var gFinished = false; // all files finished (done or failed)
var gTransferFailed = false; // any file failed
var gResults = ""; /* stores the transfer result messages (in human language)
to be later displayed to the user on his request. */
var gTimerID;
var gTimeout = 1000;
var gAllowEnterKey = false;
function Startup()
{
//ddump("In sroaming/transfer/progressDialog::Startup()");
gDialog.FileList = document.getElementById("FileList");
gDialog.StatusMessage = document.getElementById("StatusMessage");
gDialog.ListingProgress = document.getElementById("ListingProgress");
gDialog.Close = document.documentElement.getButton("cancel");
try
{
GetParams(); // dialog params -> gTransfer
checkAndTransfer(gTransfer, null); // half-blocking
}
catch (e)
{
/* All kinds of exceptions should end up here, esp. from init, meaning
this is the main last backstop for unexpected or fatal errors,
esp. those not related to a certain file. */
GlobalError(ErrorMessageForException(e));
return;
}
window.title = GetString("TransferProgressCaption");
var directionString = gTransfer.download
? GetString("TransferFromSite")
: GetString("TransferToSite");
document.getElementById("TransferToFromSite").value =
directionString.replace(/%site%/, gTransfer.sitename);
// Show transfering destination URL
document.getElementById("TransferUrl").value = gTransfer.remoteDir;
// Add the files to the UI as quickly as possible
gDialog.FileList.setAttribute("rows", gTransfer.files.length);
for (var i = 0; i < gTransfer.files.length; i++)
SetProgressStatus(i);
window.sizeToContent();
}
/*
Reads in the params we got from the calling function. Creates gTransfer.
*/
function GetParams()
{
var params = window.arguments[0].QueryInterface(
Components.interfaces.nsIDialogParamBlock);
/* For definition of meaning of params, see
mozSRoamingStream.cpp::DownUpLoad() */
// download
var direction = params.GetInt(0);
//ddump("Passing in: Int 0 (direction) is " + direction);
if (direction != 1 && direction != 2)
throw "Error: Bad direction param";
var download = direction == 1;
// serial/parallel
var serial_param = params.GetInt(1);
//ddump("Passing in: Int 1 (serial) is " + serial_param);
if (serial_param != 1 && serial_param != 2)
throw "Error: Bad serial param";
var serial = serial_param == 1;
serial = true;
// files count
var count = params.GetInt(2);
//ddump("Passing in: Int 2 (files count) is " + count);
if (count == 0)
throw GetString("NoFilesSelected");
if (count < 0)
throw "Error: Bad count param";
// save pw
var savepw_param = params.GetInt(3);
//ddump("Passing in: Int 3 (save pw) is " + savepw_param);
var savepw = false;
if (savepw_param == 1)
savepw = true;
// profile dir
var profileDir = params.GetString(1);
//ddump("Passing in: String 1 (profile dir) is " + profileDir);
if (profileDir == null || profileDir == "")
throw "Error: Bad profile dir param";
// remote dir
var remoteDir = params.GetString(2);
//ddump("Passing in: String 2 (remote dir) is " + remoteDir);
if (remoteDir == null || remoteDir == "")
throw "Error: Bad remote dir param";
// password
var password = params.GetString(3);
//ddump("Passing in: String 3 (password) is " + password);
// ignore errors
// filenames
var files = new Array();
for (var i = 0; i < count; i++)
{
var filename = params.GetString(i + 4); // filenames start at item 4
//ddumpCont("Passing in: String " + (i + 4));
//ddump(" (file " + i + ") is " + filename);
if (filename == null || filename == "")
throw "Error: Bad filename";
files[i] = new Object();
files[i].filename = filename;
files[i].mimetype = undefined;
files[i].size = undefined;
}
gTransfer = new Transfer(download, serial,
profileDir, remoteDir,
password, savepw,
files,
undefined, SetProgressStatus);
}
function PassBackParams()
{
//ddump("PassBackParam()");
var params = window.arguments[0].QueryInterface(
Components.interfaces.nsIDialogParamBlock);
if (gTransfer)
{
params.SetInt(0, gTransfer.getSaveLogin());
//ddump(" int0: " + gTransfer.getSaveLogin());
if (gTransfer.getSaveLogin() == 1)
{
params.SetString(0, gTransfer.getUsername());
params.SetString(1, gTransfer.getPassword());
//ddump(" string0: " + gTransfer.getUsername());
//ddump(" string1: " + gTransfer.getPassword());
}
}
else /* e.g. if we didn't get good prefs and couldn't create a transfer
in the first place */
{
params.SetInt(0, 0);
params.SetString(0, "");
params.SetString(1, "");
}
//ddump(" done");
}
/* Add filename to list of files to transfer
or set status for file already in the list.
@param filenr integer index of file in gTransfer
@return boolean if file was in the list
*/
function SetProgressStatus(filenr)
{
//ddumpCont("SetProgressStatus(" + filenr + "): ");
if (!gTransfer || !gTransfer.files[filenr])
{
dumpError("no such file");
return false;
}
var file = gTransfer.files[filenr];
var filename = file.filename;
var status = file.status;
//ddump(filename + ", " + status + ", " + NameForStatusCode(file.statusCode));
if (status == "busy")
SetStatusMessage(GetString("Transfering"));
// update file listbox
// if we already have this file's item, just set attribute for status icon
found = false;
var listitems = document.getElementsByTagName("listitem");
for (var i = 0, l = listitems.length; i < l; i++)
{
var li = listitems[i];
if (li.getAttribute("filename") == filename)
{
if (li.getAttribute("progress") != status)
{
var oldstat = li.getAttribute("progress");
//ddump(" Setting "+filename+" from "+oldstat+" to "+status);
li.setAttribute("progress", status);
}
found = true;
}
}
// otherwise, add the item
if (!found)
{
var listitem = document.createElement("listitem");
listitem.setAttribute("class", "listitem-iconic progressitem");
// The progress attribute triggers CSS to show icon for each status state
listitem.setAttribute("progress", status);
listitem.setAttribute("filename", filename); // bookkeeping
listitem.setAttribute("label", GetFileDescription(filename));
gDialog.FileList.appendChild(listitem);
}
// CheckDone(false); -- already called from conflictCheck.js
return found;
}
function SetProgressFinishedAll()
{
SetStatusMessage(GetString(gTransferFailed
? "UnknownTransferError"
: "TransferCompleted"));
for (var i = 0, l = gTransfer.files.length; i < l; i++)
addFileStatus(gTransfer.files[i]);
if (gTransferFailed)
{
/* Show "Troubleshooting" button to help solving problems
and legend for successful / failed icons */
document.getElementById("failureBox").hidden = false;
window.sizeToContent();
}
gDialog.Close.setAttribute("label", GetString("Close"));
// Now allow "Enter/Return" key to close the dialog
gDialog.Close.setAttribute("default","true");
gAllowEnterKey = true;
}
/*
checks, if all fines finished (failed or success) and change dialog, if so
@param close bool If all files finished successfully, also close dialog
*/
function CheckDone(close)
{
//ddump("CheckDone()");
for (var i = 0; i < gTransfer.files.length; i++)
{
var file = gTransfer.files[i];
//ddumpCont(" Checking " + i + ", " + file.filename + ", ");
//ddump(file.status);
if (file.status == "failed")
gTransferFailed = true;
else if (file.status != "done")
return;
}
//ddump(" Yes, we're done");
gFinished = true;
// Finish progress messages, settings buttons etc.
SetProgressFinishedAll();
if (!close || gTransferFailed)
return;
//ddump(" Closing");
if (gTimeout > 0)
// Leave window open a minimum amount of time
gTimerID = setTimeout(CloseDialog, gTimeout);
else
CloseDialog();
}
// Close stuff
function onClose()
{
CleanUpDialog();
return true;
}
// called, if the user presses Cancel in the conflict resolve dialog
function onCancel()
{
CloseDialog();
}
function onEnterKey()
{
if (gAllowEnterKey)
return CloseDialog();
return false;
}
function CloseDialog()
{
CleanUpDialog();
try {
window.close();
} catch (e) {}
}
function CleanUpDialog()
{
if (gTimerID)
{
clearTimeout(gTimerID);
gTimerID = null;
}
if (!gFinished && gTransfer)
{
gTransfer.cancel();
}
PassBackParams();
}
// UI stuff
// Sets the text in the prominent center of the dialog
function SetStatusMessage(message)
{
if (!message)
message = "";
if (!gTransferFailed)
gDialog.StatusMessage.value = message;
}
// For fatal errors like unexpected exceptions. Bail and go home.
function GlobalError(message)
{
GetPromptService().alert(window, GetString("FatalError"),
message);
CloseDialog();
}
/*
Records the transfer result of a file, to be alter displayed to the user
on request.
@param file TransferFile
*/
function addFileStatus(file)
{
gResults += GetFileDescription(file.filename)
+ ": " + ErrorMessageForFile(file) + "\n";
}
// replace with nicer dialog
function showErrors()
{
GetPromptService().alert(window, GetString("TransferErrorsTitle"),
gResults);
}
// set to on, if a listing.xml file is being transferred (and off afterwards)
function SetListingTransfer(on)
{
gDialog.ListingProgress.setAttribute("hidden", on ? "false" : "true");
//gDialog.ListingProgress.setAttribute("value", on ? "1" : "0");
SetStatusMessage(on ? GetString("TransferingListing") : null);
}

Просмотреть файл

@ -0,0 +1,105 @@
<?xml version="1.0"?>
<!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- 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 Roaming code.
-
- The Initial Developer of the Original Code is
- Ben Bucksch <http://www.bucksch.org> of
- Beonex <http://www.beonex.com>
- Portions created by the Initial Developer are Copyright (C) 2002-2004
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/profile/profile.css"
type="text/css"?>
<?xml-stylesheet href="chrome://sroaming/skin/progressDialog.css"
type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://sroaming/locale/progressDialog.dtd">
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&defaultTitle;"
buttons="cancel"
onload="Startup();"
ondialogaccept="return onEnterKey();"
ondialogcancel="return onClose();"
>
<script type="application/x-javascript"
src="chrome://global/content/dialogOverlay.js" />
<script type="application/x-javascript"
src="chrome://sroaming/content/transfer/progressDialog.js" />
<script type="application/x-javascript"
src="chrome://sroaming/content/transfer/conflictCheck.js" />
<script type="application/x-javascript"
src="chrome://sroaming/content/transfer/transfer.js" />
<script type="application/x-javascript"
src="chrome://sroaming/content/transfer/utility.js" />
<spacer id="location" offsetY="50" persist="offsetX offsetY"/>
<stringbundle id="bundle_roaming_transfer" src="chrome://sroaming/locale/transfer.properties"/>
<stringbundle id="bundle_roaming_filedescr" src="chrome://sroaming/locale/filedescr.properties"/>
<groupbox>
<caption><label id="TransferToFromSite"/></caption>
<hbox>
<label value="&siteUrl.label;"/>
<label class="indent bold" id="TransferUrl" style="max-width:30em" />
</hbox>
</groupbox>
<groupbox>
<caption><label value="&fileList.label;"/></caption>
<vbox align="center" style="max-width:30em">
<hbox>
<progressmeter id="ListingProgress"
mode="undetermined" value="0"
hidden="true" />
<text id="StatusMessage" class="bold" value="&status.label;" />
</hbox>
</vbox>
<spacer class="bigspacer"/>
<listbox id="FileList" rows="1" flex="1" />
<hbox align="center" id="failureBox" hidden="true">
<image class="progressitem" progress="done"/>
<label value="&succeeded.label;"/>
<spacer class="bigspacer"/>
<image class="progressitem" progress="failed"/>
<label value="&failed.label;"/>
<button label="&troubleshooting.label;"
accesskey="&troubleshooting.accessKey;"
oncommand="showErrors();" />
</hbox>
</groupbox>
</dialog>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,515 @@
/*-*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Netscape Editor team, esp. Charles Manske <cmanske@netscape.com>
* ManyOne <http://www.manyone.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Provides some global functions useful for implementing the backend or UI
of the file transfer.
*/
////////////////////////////////////////////////////////////////////////////
// UI
////////////////////////////////////////////////////////////////////////////
var gStringBundle;
// Get string from standard string bundle (transfer.properties)
function GetString(name)
{
if (!gStringBundle)
gStringBundle = document.getElementById("bundle_roaming_transfer");
try {
return gStringBundle.getString(name);
} catch (e) {
return null;
}
}
function GetStringWithFile(stringname, filename)
{
return GetString(stringname).replace(/%file%/, filename);
}
// See also GetFileDescription() below
function GetPromptService()
{
// no caching, not worth it
// throw errors into caller
return Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
}
////////////////////////////////////////////////////////////////////////////
// Error handling (UI)
////////////////////////////////////////////////////////////////////////////
// These functions return a string for display to the user.
/* Accepts either
- XPCOM exceptions (with nsresult codes in e.result)
- our own errors (e.prop is the name of the error in our string bundle)
- objects convertable to string, will be shown to user verbatim.
(Only for unexpected errors, because not localized.)
*/
function ErrorMessageForException(e)
{
if (!e)
return "null";
else if (e.result)
return ErrorMessageForStatusCode(e.result);
else if (e.prop)
return GetString(e.prop);
else
return e.toString();
}
/* Translates the result of a file transfer into a String for display
to the user.
@param aFile Object from transfer.files[]
@return String
*/
function ErrorMessageForFile(aFile)
{
if (aFile.statusCode == kStatusHTTP)
return GetStringWithFile(aFile.status == "done"
? "HTTPResponseSucceeded"
: "HTTPResponseFailed",
aFile.filename)
.replace(/%responsecode%/, aFile.httpResponse)
.replace(/%responsetext%/, aFile.statusText);
else if (aFile.statusCode == kErrorFailure && aFile.statusText) // FTP
return GetStringWithFile("StatusTextOnly", aFile.filename)
.replace(/%statustext%/, aFile.statusText);
else
return ErrorMessageForStatusCode(aFile.statusCode, aFile.filename);
}
/* Translates an XPCOM result code into a String for display to the user.
@param aStatusCode int XPCOM result code
@param aFilename String relative filename
@return String
*/
function ErrorMessageForStatusCode(aStatusCode, aFilename)
{
var statusMessage = null;
switch (aStatusCode)
{
case 0:
statusMessage = GetStringWithFile("NSOK", aFilename);
break;
case kFileNotFound:
gFileNotFound = true;
statusMessage = GetStringWithFile("FileNotFound", aFilename);
break;
case kNetReset:
// We get this when subdir doesn't exist AND
// if aFilename used is same as an existing subdir
var dir = (gTransferData.filename == aFilename) ? gTransferData.docDir
: gTransferData.otherDir;
if (dir)
{
// This is the ambiguous case when we can't tell,
// if subdir or filename is bad
statusMessage = GetString("SubdirDoesNotExist").replace(/%dir%/, dir);
statusMessage = statusMessage.replace(/%file%/, aFilename);
// Remove directory from saved prefs
// XXX Note that if subdir is good,
// but filename = next level subdirectory name,
// we really shouldn't remove subdirectory,
// but it's impossible to differentiate this case!
RemoveTransferSubdirectoryFromPrefs(gTransferData, dir);
}
else
statusMessage = GetStringWithFile("FilenameIsSubdir", aFilename);
break;
case kErrorMalformedURI:
statusMessage = GetString("MalformedURI");
break;
case kNotConnected:
case kConnectionRefused:
case kNetTimeout:
case kUnknownHost:
case kPortAccessNotAllowed:
case kUnknownProxyHost:
statusMessage = GetString("ServerNotAvailable");
break;
case kOffline:
statusMessage = GetString("Offline");
break;
case kDiskFull:
case kNoDeviceSpace:
statusMessage = GetStringWithFile("DiskFull", aFilename);
break;
case kNameTooLong:
statusMessage = GetStringWithFile("NameTooLong", aFilename);
break;
case kAccessDenied:
statusMessage = GetStringWithFile("AccessDenied", aFilename);
break;
case kStatusFTPCWD:
statusMessage = GetStringWithFile("FTPCWD", aFilename);
break;
case kErrorAbort:
statusMessage = GetStringWithFile("Abort");
break;
case kUnknownType:
default:
statusMessage = GetStringWithFile("UnknownTransferError", aFilename)
+ " " + NameForStatusCode(aStatusCode);
break;
}
return statusMessage
}
////////////////////////////////////////////////////////////////////////////
// Error handling (general)
////////////////////////////////////////////////////////////////////////////
// Internal, backend, debugging stuff
/*
This is bad. We should have this in a central place, but I don't know
(nor could find) one where this is available. Note that I do use
|Components.results| in the end, but it doesn't have all the errors I need.
*/
// Transfer error codes
// These are translated from C++ error code strings like this:
// kFileNotFound = "NS_FILE_NOT_FOUND",
const kNS_OK = 0;
const kMyBase = 0x80780000; // Generic module, only valid within our module
const kNetBase = 2152398848; // 0x804B0000
const kFilesBase = 2152857600; // 0x80520000
const kUnknownType = kFilesBase + 04; // nsError.h
const kDiskFull = kFilesBase + 10; // nsError.h
const kNoDeviceSpace = kFilesBase + 16; // nsError.h
const kNameTooLong = kFilesBase + 17; // nsError.h
const kFileNotFound = kFilesBase + 18; // nsError.h, 0x80520012
const kAccessDenied = kFilesBase + 21; // nsError.h
const kNetReset = kNetBase + 20;
const kErrorMalformedURI = kNetBase + 10; // netCore.h
const kNotConnected = kNetBase + 12; // netCore.h
const kConnectionRefused = kNetBase + 13;
const kNetTimeout = kNetBase + 14;
const kInProgress = kNetBase + 15; // netCore.h
const kOffline = kNetBase + 16; // netCore.h; 0x804b0010
const kUnknownHost = kNetBase + 30; // nsNetErr; was "no connection or timeout"
const kUnknownProxyHost = kNetBase + 42; // nsNetError.h
const kPortAccessNotAllowed = kNetBase + 19; // netCore.h
const kErrorDocumentNotCached = kNetBase + 70; // nsNetError.h
const kErrorBindingFailed = kNetBase + 1; // netCore.h
const kErrorBindingAborted = kNetBase + 2; // netCore.h
const kErrorBindingRedirected = kNetBase + 3; // netCore.h
const kErrorBindingRetargeted = kNetBase + 4; // netCore.h
const kStatusBeginFTPTransaction = kNetBase + 27; // ftpCore.h
const kStatusEndFTPTransaction = kNetBase + 28; // ftpCore.h
const kStatusFTPLogin = kNetBase + 21; // ftpCore.h
const kStatusFTPCWD = kNetBase + 22; // ftpCore.h
const kStatusFTPPassive = kNetBase + 23; // ftpCore.h
const kStatusFTPPWD = kNetBase + 24; // ftpCore.h
const kErrorNoInterface = 0x80004002; // nsError.h
const kErrorNotImplemented = 0x80004001; // nsError.h
const kErrorAbort = 0x80004004; // nsError.h
const kErrorFailure = 0x80004005; // nsError.h
const kErrorUnexpected = 0x8000ffff; // nsError.h
const kErrorInvalidValue = 0x80070057; // nsError.h
const kErrorNotAvailable = 0x80040111; // nsError.h
const kErrorNotInited = 0xC1F30001; // nsError.h
const kErrorAlreadyInited = 0xC1F30002; // nsError.h
const kErrorFTPAuthNeeded = 0x4B001B; // XXX not sure what exactly this is or
// where it comes from (grep doesn't find it in dec or hex notation), but
// that's what I get when the credentials are not accepted by the FTP server
const kErrorFTPAuthFailed = 0x4B001C; // dito
const kStatusHTTP = kMyBase + 0;
/* See Transfer.onStatus().
*_Status are the number we get from nsIProgressEventSink, the others
are what we use internally in the rest of the code. */
const kStatusResolvingHost = kMyBase + 5;
const kStatusConnectedTo = kMyBase + 6;
const kStatusSendingTo = kMyBase + 7;
const kStatusReceivingFrom = kMyBase + 8;
const kStatusConnectingTo = kMyBase + 9;
const kStatusWaitingFor = kMyBase + 10;
const kStatusReadFrom = kMyBase + 11;
const kStatusWroteTo = kMyBase + 12;
const kStatusResolvingHost_Status = kNetBase + 3;// nsISocketTransport.idl
const kStatusConnectedTo_Status = kNetBase + 4; // nsISocketTransport.idl
const kStatusSendingTo_Status = kNetBase + 5; // nsISocketTransport.idl
const kStatusReceivingFrom_Status = kNetBase + 6; // nsISocketTransport.idl
const kStatusConnectingTo_Status = kNetBase + 7; // nsISocketTransport.idl
const kStatusWaitingFor_Status = kNetBase + 10; // nsISocketTransport.idl
const kStatusReadFrom_Status = kNetBase + 8; // nsIFileTransportService.idl
const kStatusWroteTo_Status = kNetBase + 9; // nsIFileTransportService.idl
// Translates an XPCOM result code into a String similar to the C++ constant.
function NameForStatusCode(aStatusCode)
{
switch (aStatusCode)
{
case 0:
return "NS_OK";
case kStatusReadFrom:
return "NET_STATUS_READ_FROM";
case kStatusWroteTo:
return "NET_STATUS_WROTE_TO";
case kStatusReceivingFrom:
return "NET_STATUS_RECEIVING_FROM";
case kStatusSendingTo:
return "NET_STATUS_SENDING_TO";
case kStatusWaitingFor:
return "NET_STATUS_WAITING_FOR";
case kStatusResolvingHost:
return "NET_STATUS_RESOLVING_HOST";
case kStatusConnectedTo:
return "NET_STATUS_CONNECTED_TO";
case kStatusConnectingTo:
return "NET_STATUS_CONNECTING_TO";
case kStatusHTTP:
return "See HTTP response";
case kErrorBindingFailed:
return "BINDING_FAILED";
case kErrorBindingAborted:
return "BINDING_ABORTED";
case kErrorBindingRedirected:
return "BINDING_REDIRECTED";
case kErrorBindingRetargeted:
return "BINDING_RETARGETED";
case kErrorMalformedURI:
return "MALFORMED_URI";
case kNetBase + 11: // netCore.h
return "ALREADY_CONNECTED";
case kNotConnected:
return "NOT_CONNECTED";
case kConnectionRefused:
return "CONNECTION_REFUSED";
case kNetTimeout:
return "NET_TIMEOUT";
case kInProgress:
return "IN_PROGRESS";
case kOffline:
return "OFFLINE";
case kNetBase + 17: // netCore.h
return "NO_CONTENT";
case kNetBase + 18: // netCore.h
return "UNKNOWN_PROTOCOL";
case kPortAccessNotAllowed:
return "PORT_ACCESS_NOT_ALLOWED";
case kNetReset:
return "NET_RESET";
case kStatusFTPLogin:
return "FTP_LOGIN";
case kStatusFTPCWD:
return "FTP_CWD";
case kStatusFTPPassive:
return "FTP_PASV";
case kStatusFTPPWD:
return "FTP_PWD";
case kUnknownHost:
return "UNKNOWN_HOST or NO_CONNECTION_OR_TIMEOUT";
case kUnknownProxyHost:
return "UNKNOWN_PROXY_HOST";
case kErrorFTPAuthNeeded:
return "FTP auth needed (?)";
case kErrorFTPAuthFailed:
return "FTP auth failed (?)";
case kStatusBeginFTPTransaction:
return "NET_STATUS_BEGIN_FTP_TRANSACTION";
case kStatusEndFTPTransaction:
return "NET_STATUS_END_FTP_TRANSACTION";
case kNetBase + 61:
return "NET_CACHE_KEY_NOT_FOUND";
case kNetBase + 62:
return "NET_CACHE_DATA_IS_STREAM";
case kNetBase + 63:
return "NET_CACHE_DATA_IS_NOT_STREAM";
case kNetBase + 64:
return "NET_CACHE_WAIT_FOR_VALIDATION"; // XXX error or status?
case kNetBase + 65:
return "NET_CACHE_ENTRY_DOOMED";
case kNetBase + 66:
return "NET_CACHE_READ_ACCESS_DENIED";
case kNetBase + 67:
return "NET_CACHE_WRITE_ACCESS_DENIED";
case kNetBase + 68:
return "NET_CACHE_IN_USE";
case kErrorDocumentNotCached:
return "NET_DOCUMENT_NOT_CACHED";//XXX error or status? seems to be error
case kFilesBase + 1: // nsError.h
return "UNRECOGNIZED_PATH";
case kFilesBase + 2: // nsError.h
return "UNRESOLABLE SYMLINK";
case kFilesBase + 4: // nsError.h
return "UNKNOWN_TYPE";
case kFilesBase + 5: // nsError.h
return "DESTINATION_NOT_DIR";
case kFilesBase + 6: // nsError.h
return "TARGET_DOES_NOT_EXIST";
case kFilesBase + 8: // nsError.h
return "ALREADY_EXISTS";
case kFilesBase + 9: // nsError.h
return "INVALID_PATH";
case kDiskFull:
return "DISK_FULL";
case kFilesBase + 11: // nsError.h
return "FILE_CORRUPTED (justice department, too)";
case kFilesBase + 12: // nsError.h
return "NOT_DIRECTORY";
case kFilesBase + 13: // nsError.h
return "IS_DIRECTORY";
case kFilesBase + 14: // nsError.h
return "IS_LOCKED";
case kFilesBase + 15: // nsError.h
return "TOO_BIG";
case kNoDeviceSpace:
return "NO_DEVICE_SPACE";
case kNameTooLong:
return "NAME_TOO_LONG";
case kFileNotFound:
return "FILE_NOT_FOUND";
case kFilesBase + 19: // nsError.h
return "READ_ONLY";
case kFilesBase + 20: // nsError.h
return "DIR_NOT_EMPTY";
case kAccessDenied:
return "ACCESS_DENIED";
default:
for (a in Components.results)
if (Components.results[a] == aStatusCode)
return a;
return String(aStatusCode);
}
}
////////////////////////////////////////////////////////////////////////////
// Debugging (backend and UI)
////////////////////////////////////////////////////////////////////////////
// Turn this on to get debug output.
const debugOutput = true;
function ddump(text)
{
if (debugOutput)
dump(text + "\n");
}
function ddumpCont(text)
{
if (debugOutput)
dump(text);
}
function dumpObject(obj, name, maxDepth, curDepth)
{
if (!debugOutput)
return;
if (curDepth == undefined)
curDepth = 0;
if (maxDepth != undefined && curDepth > maxDepth)
return;
var i = 0;
for (prop in obj)
{
i++;
if (typeof(obj[prop]) == "object")
{
if (obj[prop] && obj[prop].length != undefined)
ddump(name + "." + prop + "=[probably array, length "
+ obj[prop].length + "]");
else
ddump(name + "." + prop + "=[" + typeof(obj[prop]) + "]");
dumpObject(obj[prop], name + "." + prop, maxDepth, curDepth+1);
}
else if (typeof(obj[prop]) == "function")
ddump(name + "." + prop + "=[function]");
else
ddump(name + "." + prop + "=" + obj[prop]);
}
if (!i)
ddump(name + " is empty");
}
function dumpError(text)
{
dump(text + "\n");
}
///////////////////////////////////////////////////////////////////////
// Profile-related stuff
// Only makes sense for roaming
///////////////////////////////////////////////////////////////////////
/* Returns a human-readable name for a profile file, e.g.
"abook.mab" -> "Personal Addressbook"
Will look for a stringbundle match
- for filename
- if failing that, for id
- if failing that, use the raw id
- if failing that, use the raw filename
@param filename string
@param id in case the filename is changing for a certain profile file
(e.g. in the case of password files), optionally pass an ID
for the file here, as used in filedescr.properties.
May be null.
@return string Description for file
*/
var gStringBundleFiledescr;
function GetFileDescription(filename, id)
{
if (!gStringBundleFiledescr)
gStringBundleFiledescr =
document.getElementById("bundle_roaming_filedescr");
try {
return gStringBundleFiledescr.getString(filename);
} catch (e) {
try {
return gStringBundleFiledescr.getString(id);
} catch (e2) {
if (id)
return id;
return filename;
}
}
}

Просмотреть файл

@ -0,0 +1,48 @@
<!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- 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 Roaming code.
-
- The Initial Developer of the Original Code is
- Ben Bucksch <http://www.bucksch.org> of
- Beonex <http://www.beonex.com>
- Portions created by the Initial Developer are Copyright (C) 2002-2004
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<!ENTITY windowtitle.label "Roaming files conflicts">
<!ENTITY subheader.label "Select which version of your profile files to keep">
<!ENTITY intro-download.label "Download: Several files in your local user profile have been changed since the corresponding files on the server have been last uploaded. This suggests that the files on the server are not up-to-date. Which version of the files do you want to keep?">
<!ENTITY intro-upload.label "Upload: Several files have been changed both on the server and in your local user profile since the files have been last downloaded. Which version of the files do you want to keep?">
<!ENTITY filedescr.label "File">
<!ENTITY server.label "Server">
<!ENTITY local.label "Local profile">

Просмотреть файл

@ -0,0 +1,59 @@
<?xml version="1.0"?>
<!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- 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 Roaming code.
-
- The Initial Developer of the Original Code is
- Ben Bucksch <http://www.bucksch.org> of
- Beonex <http://www.beonex.com>
- Portions created by the Initial Developer are Copyright (C) 2002-2004
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<!-- list all the skins being supplied by this package -->
<RDF:Seq about="urn:mozilla:locale:root">
<RDF:li resource="urn:mozilla:locale:en-US"/>
</RDF:Seq>
<!-- locale information -->
<RDF:Description about="urn:mozilla:locale:en-US">
<chrome:packages>
<RDF:Seq about="urn:mozilla:locale:en-US:packages">
<RDF:li resource="urn:mozilla:locale:en-US:sroaming"/>
</RDF:Seq>
</chrome:packages>
</RDF:Description>
<RDF:Description about="urn:mozilla:locale:en-US:sroaming"
chrome:localeVersion="0.9.4"/>
</RDF:RDF>

Просмотреть файл

@ -14,9 +14,9 @@
# The Original Code is Mozilla Roaming code.
#
# The Initial Developer of the Original Code is
# Ben Bucksch <http://www.bucksch.org> of
# Beonex <http://www.beonex.com>
# Portions created by the Initial Developer are Copyright (C) 2002
# Ben Bucksch <http://www.bucksch.org> of
# Beonex <http://www.beonex.com>
# Portions created by the Initial Developer are Copyright (C) 2002-2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):

Просмотреть файл

@ -0,0 +1,67 @@
<!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- 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 Roaming code.
-
- The Initial Developer of the Original Code is
- Ben Bucksch <http://www.bucksch.org> of
- Beonex <http://www.beonex.com>
- Portions created by the Initial Developer are Copyright (C) 2002-2004
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<!ENTITY sroaming-header.label "Roaming User">
<!ENTITY sroamingTop-header.label "Server"> <!-- for Firefox -->
<!ENTITY sroamingFiles-header.label "Item Selection">
<!ENTITY descr.label "Roaming Access allows you to retrieve and store your user profile information from/on a Roaming Access server. Your profile information will then be retrieved from the server on startup and transferred to it on shutdown.">
<!ENTITY descrFiles.label "If Roaming Access is enabled (in the Roaming User pane), the following parts of your profile will be transferred to and from the Roaming Access server.">
<!ENTITY enabled.label "Enable remote profile storage">
<!ENTITY enabled.accesskey "e">
<!ENTITY method.label "Server Information">
<!ENTITY methodSelect.label "Transfer Method">
<!ENTITY methodSelect.accesskey "m">
<!ENTITY files.label "Item Selection">
<!ENTITY filesDescr.label "User profile items selected below will be transferred to/from the server.">
<!ENTITY filesList.accesskey "i">
<!ENTITY methodCopy.label "File copy">
<!ENTITY methodStream.label "HTTP / FTP">
<!ENTITY streamURL.label "Base URL">
<!ENTITY streamURL.accesskey "u">
<!ENTITY streamUsername.label "Username">
<!ENTITY streamUsername.accesskey "Username">
<!ENTITY streamSavePW.label "Save password">
<!ENTITY streamSavePW.accesskey "s">
<!ENTITY streamPassword.label "Password">
<!ENTITY streamPassword.accesskey "p">
<!ENTITY copyDir.label "Copy to/from directory">
<!ENTITY copyDir.accesskey "d">

Просмотреть файл

@ -9,4 +9,4 @@ RoamingErrorTitle=Roaming settings error
ErrorRegRead=Reading from registry failed
ErrorRegWrite=Writing roaming settings to registry failed
ActivationWarning=Please be warned that the roaming implementation is still new and experimental. It may accidently overwrite your roaming profile files (both on the server and locally) with a bad or empty version. Please make regular backups of your profile to prevent possible data loss. See the release notes or ask your administrator for where you can find the files. This warning won't be shown anymore for this profile.
ActivationWarning=Be warned that the roaming implementation is still new and experimental. It may accidently overwrite your roaming profile files (both on the server and locally) with a bad or empty version. Please make regular backups of your profile to prevent possible data loss. See the release notes or ask your administrator for where you can find the files. Please report any dataloss bugs you find. This warning won't be shown anymore for this profile.

Просмотреть файл

@ -0,0 +1,49 @@
<!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- 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 Roaming code.
-
- The Initial Developer of the Original Code is
- Ben Bucksch <http://www.bucksch.org> of
- Beonex <http://www.beonex.com>
- Portions created by the Initial Developer are Copyright (C) 2002-2004
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<!ENTITY defaultTitle "Roaming Transfer">
<!ENTITY siteUrl.label "Site URL:">
<!ENTITY status.label "">
<!ENTITY fileList.label "Transfering Status">
<!ENTITY statusHeader.label "Status">
<!ENTITY filenameHeader.label "Filename">
<!ENTITY succeeded.label "Succeeded">
<!ENTITY failed.label "Failed">
<!ENTITY troubleshooting.label "Troubleshooting">
<!ENTITY troubleshooting.accessKey "T">

Просмотреть файл

@ -0,0 +1,47 @@
#transfer.js
Alert=Alert
PasswordTitle=Password for file transfer
# LOCALIZATION NOTE Don't translate %realm%, %username% or similar. Same for the whole file.
EnterPasswordForUserAt=Enter password for user %username% at %realm%
SavePassword=Save password
# Transfering error strings:
NSOK=%file% succeeded
FileNotFound="%file%" not found.
SubdirDoesNotExist=The subdirectory "%dir%" doesn't exist on this site or the filename "%file%" is already in use by another subdirectory.
FilenameIsSubdir=The filename "%file%" is already in use by another subdirectory.
ServerNotAvailable=The server is not available. Check your connection and try again later.
Offline=You are currently offline. Click the icon near the lower-right corner of any window to go online.
DiskFull=There is not enough disk space available to save the file "%file%".
NameTooLong=The filename or subdirectory name is too long.
AccessDenied=You do not have permission to transfer to this location.
Abort=Transfer has been cancelled
UnknownTransferStatus=Transfer status:
UnknownTransferError=Transfer error with file "%file%":
NotFinished=The transfer of file "%file%" didn't finish
HTTPResponseFailed="%file%" failed, HTTP server said "%responsecode%: %responsetext%"
HTTPResponseSucceeded="%file%" succeeded, HTTP server said "%responsecode%: %responsetext%"
StatusTextOnly="%file%" failed with error %statustext%
FTPCWD=File or directory of "%file%" cannot be found.
# also getting the above error in case the file is e.g. not readable, so don't say: Did you use the right base URL in preferences?
MalformedURI=The Base URL is malformed.
NoFilesSelected=You did not select any files to be transfered.
NoUsername=No username given.
# End-Transfering error strings
#ProgressDialog.js
TransferProgressCaption=Roaming transfer: %title%
TransferToSite=Transfering to site: %site%
TransferFromSite=Transfering from site: %site%
Close=Close
TransferFailed=Transfer failed
TransferCompleted=Transfer completed successfully
Transfering=Transfering...
TransferingListing=Transfering listing file
TransferErrorsTitle=Transfer Errors
FatalError=Fatal error while trying to transfer files
#Conflict resolve
FileStats=%date%, %size% Bytes
FileStatsUnknown=Unknown
NonExistant=Non-existant

Двоичные данные
extensions/sroaming/resources/skin/classic/busy-small.gif Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 597 B

Просмотреть файл

@ -0,0 +1,59 @@
<?xml version="1.0"?>
<!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- 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 Roaming code.
-
- The Initial Developer of the Original Code is
- Ben Bucksch <http://www.bucksch.org> of
- Beonex <http://www.beonex.com>
- Portions created by the Initial Developer are Copyright (C) 2002-2004
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<!-- List all the skins being supplied by this theme -->
<RDF:Seq about="urn:mozilla:skin:root">
<RDF:li resource="urn:mozilla:skin:classic/1.0" />
</RDF:Seq>
<!-- Classic Information -->
<RDF:Description about="urn:mozilla:skin:classic/1.0">
<chrome:packages>
<RDF:Seq about="urn:mozilla:skin:classic/1.0:packages">
<RDF:li resource="urn:mozilla:skin:classic/1.0:sroaming"/>
</RDF:Seq>
</chrome:packages>
</RDF:Description>
<RDF:Description about="urn:mozilla:skin:classic/1.0:sroaming"
chrome:skinVersion="1.0"/>
</RDF:RDF>

Двоичные данные
extensions/sroaming/resources/skin/classic/done-small.gif Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 109 B

Двоичные данные
extensions/sroaming/resources/skin/classic/failed-small.gif Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 155 B

Двоичные данные
extensions/sroaming/resources/skin/classic/pending-small.gif Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 62 B

Просмотреть файл

@ -0,0 +1,51 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* ::::: Progress Dialog ::::: */
.progressitem[progress="pending"] {
list-style-image: url("chrome://sroaming/skin/pending-small.gif");
}
.progressitem[progress="busy"] {
list-style-image: url("chrome://sroaming/skin/busy-small.gif");
}
.progressitem[progress="done"] {
list-style-image: url("chrome://sroaming/skin/done-small.gif");
}
.progressitem[progress="failed"] {
list-style-image: url("chrome://sroaming/skin/failed-small.gif");
}

Двоичные данные
extensions/sroaming/resources/skin/modern/busy-small.gif Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 597 B

Просмотреть файл

@ -0,0 +1,59 @@
<?xml version="1.0"?>
<!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- 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 Roaming code.
-
- The Initial Developer of the Original Code is
- Ben Bucksch <http://www.bucksch.org> of
- Beonex <http://www.beonex.com>
- Portions created by the Initial Developer are Copyright (C) 2002-2004
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<!-- List all the skins being supplied by this theme -->
<RDF:Seq about="urn:mozilla:skin:root">
<RDF:li resource="urn:mozilla:skin:modern/1.0" />
</RDF:Seq>
<!-- Modern Information -->
<RDF:Description about="urn:mozilla:skin:modern/1.0">
<chrome:packages>
<RDF:Seq about="urn:mozilla:skin:modern/1.0:packages">
<RDF:li resource="urn:mozilla:skin:modern/1.0:sroaming"/>
</RDF:Seq>
</chrome:packages>
</RDF:Description>
<RDF:Description about="urn:mozilla:skin:modern/1.0:sroaming"
chrome:skinVersion="1.0"/>
</RDF:RDF>

Двоичные данные
extensions/sroaming/resources/skin/modern/done-small.gif Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 109 B

Двоичные данные
extensions/sroaming/resources/skin/modern/failed-small.gif Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 155 B

Двоичные данные
extensions/sroaming/resources/skin/modern/pending-small.gif Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 62 B

Просмотреть файл

@ -0,0 +1,51 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* ::::: Progress Dialog ::::: */
.progressitem[progress="pending"] {
list-style-image: url("chrome://sroaming/skin/pending-small.gif");
}
.progressitem[progress="busy"] {
list-style-image: url("chrome://sroaming/skin/busy-small.gif");
}
.progressitem[progress="done"] {
list-style-image: url("chrome://sroaming/skin/done-small.gif");
}
.progressitem[progress="failed"] {
list-style-image: url("chrome://sroaming/skin/failed-small.gif");
}

Просмотреть файл

@ -0,0 +1,240 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "Copy.h"
#include "nsIComponentManager.h"
#include "nsILocalFile.h"
#include "nsXPIDLString.h"
#define kRegTreeCopy (NS_LITERAL_STRING("Copy"))
#define kRegKeyRemote (NS_LITERAL_STRING("RemoteDir"))
// Internal helper functions unrelated to class
/* @param fileSubPath works for subpaths or just filenames?
doesn't really matter for us. */
static nsresult CopyFile(nsCOMPtr<nsIFile> fromDir,
nsCOMPtr<nsIFile> toDir,
nsAString& fileSubPath)
{
nsresult rv;
nsCOMPtr<nsIFile> fromFile;
rv = fromDir->Clone(getter_AddRefs(fromFile));
NS_ENSURE_SUCCESS(rv, rv);
rv = fromFile->Append(fileSubPath);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> toFileOld;
rv = toDir->Clone(getter_AddRefs(toFileOld));
NS_ENSURE_SUCCESS(rv, rv);
rv = toFileOld->Append(fileSubPath);
NS_ENSURE_SUCCESS(rv, rv);
PRBool exists;
rv = fromFile->Exists(&exists);
NS_ENSURE_SUCCESS(rv, rv);
if (exists)
{
rv = toFileOld->Remove(PR_FALSE);
rv = fromFile->CopyTo(toDir, fileSubPath);
}
else
{
rv = NS_ERROR_FILE_NOT_FOUND;
}
return rv;
}
static void AppendElementsToStrArray(nsCStringArray& target, nsCStringArray& source)
{
for (PRInt32 i = source.Count() - 1; i >= 0; i--)
target.AppendCString(*source.CStringAt(i));
}
/*
* nsSRoamingProtocol implementation
*/
nsresult Copy::Init(Core* aController)
{
nsresult rv;
mController = aController;
if (!mController)
return NS_ERROR_INVALID_ARG;
// Get prefs
nsCOMPtr<nsIRegistry> registry;
rv = mController->GetRegistry(registry);
NS_ENSURE_SUCCESS(rv, rv);
nsRegistryKey regkey;
rv = mController->GetRegistryTree(regkey);
NS_ENSURE_SUCCESS(rv, rv);
rv = registry->GetKey(regkey,
kRegTreeCopy.get(),
&regkey);
NS_ENSURE_SUCCESS(rv, rv);
nsXPIDLString remoteDirPref;
rv = registry->GetString(regkey, kRegKeyRemote.get(),
getter_Copies(remoteDirPref));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILocalFile> lf;
rv = NS_NewLocalFile(remoteDirPref, PR_FALSE,
getter_AddRefs(lf));
NS_ENSURE_SUCCESS(rv, rv);
mRemoteDir = lf;
rv = mController->GetProfileDir(getter_AddRefs(mProfileDir));
NS_ENSURE_SUCCESS(rv, rv);
if (!mProfileDir)
return NS_ERROR_FILE_NOT_FOUND;
return NS_OK;
}
nsresult Copy::Download()
{
return DownUpLoad(PR_TRUE);
}
nsresult Copy::Upload()
{
return DownUpLoad(PR_FALSE);
}
nsresult Copy::DownUpLoad(PRBool download)
{
nsresult rv = NS_OK;
const nsCStringArray* files = mController->GetFilesToRoam();
// Check for conflicts
nsCStringArray conflicts(10);
nsCStringArray copyfiles(10);
PRInt32 i;
for (i = files->Count() - 1; i >= 0; i--)
{
nsCString& file = *files->CStringAt(i);
NS_ConvertASCIItoUTF16 fileL(file);
nsCOMPtr<nsIFile> profileFile;
rv = mProfileDir->Clone(getter_AddRefs(profileFile));
NS_ENSURE_SUCCESS(rv, rv);
rv = profileFile->Append(fileL);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> remoteFile;
rv = mRemoteDir->Clone(getter_AddRefs(remoteFile));
NS_ENSURE_SUCCESS(rv, rv);
rv = remoteFile->Append(fileL);
NS_ENSURE_SUCCESS(rv, rv);
// avoid conflicts for missing files
PRBool remoteExists = PR_TRUE;
PRBool profileExists = PR_TRUE;
remoteFile->Exists(&remoteExists);
profileFile->Exists(&profileExists);
if (download)
{
if (!remoteExists)
continue;
if (!profileExists) {
copyfiles.AppendCString(file);
continue;
/* actually, this code is not needed given how the last modified
code below works, but for readability and just in case... */
}
}
else
{
if (!profileExists)
continue;
if (!remoteExists) {
copyfiles.AppendCString(file);
continue;
}
}
PRInt64 profileTime = 0;
PRInt64 remoteTime = 0;
profileFile->GetLastModifiedTime(&profileTime);
remoteFile->GetLastModifiedTime(&remoteTime);
// do we have a conflict?
if (download
? profileTime > remoteTime
: profileTime < remoteTime )
conflicts.AppendCString(file);
else
copyfiles.AppendCString(file);
}
// Ask user about conflicts
nsCStringArray copyfiles_conflicts(10);
rv = mController->ConflictResolveUI(download, conflicts,
&copyfiles_conflicts);
NS_ENSURE_SUCCESS(rv, rv);
AppendElementsToStrArray(copyfiles, copyfiles_conflicts);
// Copy
for (i = copyfiles.Count() - 1; i >= 0; i--)
{
const nsCString& file = *copyfiles.CStringAt(i);
NS_ConvertASCIItoUTF16 fileL(file);
if (download)
rv = CopyFile(mRemoteDir, mProfileDir, fileL);
else
rv = CopyFile(mProfileDir, mRemoteDir, fileL);
}
return rv;
}

Просмотреть файл

@ -0,0 +1,71 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Copies files from/to another place on the local filesystem */
/* This is a very primitive implementation of a roaming method,
mostly intended for testing purposes. Some users might find it useful
nevertheless, e.g. to
- test, if roaming works at all for them
- store their most important profile data apart from the cache
- store profile data on a slow network file server mounted on the
local filesystem
*/
#ifndef _COPY_H_
#define _COPY_H_
#include "Protocol.h"
class Copy: public Protocol
{
public:
nsresult Init(Core* controller);
nsresult Download();
nsresult Upload();
protected:
// Data
nsCOMPtr<nsIFile> mRemoteDir;
nsCOMPtr<nsIFile> mProfileDir;
protected:
nsresult DownUpLoad(PRBool download); // upload, if !download
};
#endif

Просмотреть файл

@ -0,0 +1,397 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "Core.h"
#include "nsIComponentManager.h"
#include "nsIRegistry.h"
#include "nsIProfile.h"
#include "nsDirectoryServiceUtils.h"
#include "nsAppDirectoryServiceDefs.h"
#include "Copy.h"
#include "Stream.h"
#include "nsILocalFile.h"
#include "nsIObserverService.h"
// UI
#include "nsIDialogParamBlock.h"
#include "nsIDOMWindow.h"
#include "nsIWindowWatcher.h"
#include "plstr.h"
#define kRegTreeProfile (NS_LITERAL_STRING("Profiles"))
#define kRegTreeRoaming (NS_LITERAL_STRING("Roaming"))
#define kRegKeyEnabled (NS_LITERAL_CSTRING("Enabled"))
#define kRegKeyMethod (NS_LITERAL_STRING("Method"))
#define kRegKeyFiles (NS_LITERAL_STRING("Files"))
#define kRegValMethodStream (NS_LITERAL_STRING("stream"))
#define kRegValMethodCopy (NS_LITERAL_STRING("copy"))
#define kConflDlg "chrome://sroaming/content/transfer/conflictResolve.xul"
NS_IMPL_ISUPPORTS1(Core,
nsISessionRoaming)
Core::Core()
: mFiles(10), mIsRoaming(PR_FALSE), mMethod(0), mRegistry(0)
{
}
/*
* mozISRoaming implementation
*/
NS_IMETHODIMP
Core::BeginSession()
{
nsresult rv = ReadRoamingPrefs();
NS_ENSURE_SUCCESS(rv, rv);
if (!mIsRoaming)
return NS_OK;
Protocol* proto = CreateMethodHandler();
if (!proto)
return NS_ERROR_ABORT;
rv = proto->Init(this);
if (NS_FAILED(rv))
{
delete proto;
return rv;
}
rv = proto->Download();
if (NS_FAILED(rv))
{
delete proto;
return rv;
}
delete proto;
return NS_OK;
}
NS_IMETHODIMP
Core::EndSession()
{
nsresult rv = ReadRoamingPrefs();
NS_ENSURE_SUCCESS(rv, rv);
if (!mIsRoaming)
return NS_OK;
Protocol* proto = CreateMethodHandler();
if (!proto)
return NS_ERROR_ABORT;
rv = proto->Init(this);
if (NS_FAILED(rv))
{
delete proto;
return rv;
}
RestoreNet();
rv = proto->Upload();
if (NS_FAILED(rv))
{
delete proto;
return rv;
}
CloseNet();
delete proto;
return NS_OK;
}
NS_IMETHODIMP
Core::IsRoaming(PRBool *_retval)
{
ReadRoamingPrefs();
*_retval = IsRoaming();
return NS_OK;
}
/*
* Public functions
*/
nsresult Core::GetProfileDir(nsIFile** result)
{
return NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, result);
}
nsresult
Core::ConflictResolveUI(PRBool download, const nsCStringArray& files,
nsCStringArray* result)
{
if (files.Count() < 1)
return NS_OK;
/* nsIDialogParamBlock is a method to pass ints and strings
to and from XUL dialogs.
To dialog (upon open)
Int array
Item 0: 1 = download, 2 = upload
Item 1: Number of files (n below)
String array
Item 1..(n): Either filename or comma-separated (no spaces) string:
- filename
- last modified (unix time) server
- size (bytes) server
- last modified (unix time) local
- size (bytes) local
e.g. "bookmarks.html,100024563,325,100024535,245" or
"bookmarks.html"
From dialog (upon close)
Int array
Item 0: 3 = OK, 4 = Cancel
Item 1..(n): if OK:
1 = Use server version, 2 = Use local version.
For each file. Indices are the same as To/String
*/
nsresult rv;
nsCOMPtr<nsIDialogParamBlock> ioParamBlock
(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1", &rv));
NS_ENSURE_SUCCESS(rv, rv);
// download/upload
ioParamBlock->SetInt(0, download ? 1 : 2);
// filenames
ioParamBlock->SetInt(1, files.Count());
PRInt32 i;
for (i = files.Count() - 1; i >= 0; i--)
{
NS_ConvertASCIItoUTF16 filename(*files.CStringAt(i));
ioParamBlock->SetString(i + 1, filename.get());
}
nsCOMPtr<nsIWindowWatcher> windowWatcher
(do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMWindow> window;
rv = windowWatcher->OpenWindow(nsnull,
kConflDlg,
nsnull,
"centerscreen,chrome,modal,titlebar",
ioParamBlock,
getter_AddRefs(window));
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 value = 0;
ioParamBlock->GetInt(0, &value);
if (value != 3 && value != 4)
return NS_ERROR_INVALID_ARG;
if (value == 4) // cancel
{
return NS_ERROR_ABORT;
}
/* I am assuming that the sequence of iteration here is the same as in the
last |for| statement. If that is not true, the indices gotten from
param block will not match the array and we will interpret the result
wrongly. */
for (i = files.Count() - 1; i >= 0; i--)
{
ioParamBlock->GetInt(i + 1, &value);
if (value != 1 && value != 2)
return NS_ERROR_INVALID_ARG;
if (download
? value == 1
: value == 2)
result->AppendCString(*files.CStringAt(i));
}
//*result = files;
return NS_OK;
}
nsresult Core::GetRegistry(nsCOMPtr<nsIRegistry>& result)
{
if (mRegistry)
{
result = mRegistry;
return NS_OK;
}
nsresult rv;
nsCOMPtr<nsIRegistry> registry(do_CreateInstance(NS_REGISTRY_CONTRACTID,
&rv));
NS_ENSURE_SUCCESS(rv, rv);
rv = registry->OpenWellKnownRegistry(nsIRegistry::ApplicationRegistry);
NS_ENSURE_SUCCESS(rv, rv);
mRegistry = registry;
result = registry;
return NS_OK;
}
nsresult Core::GetRegistryTree(nsRegistryKey& result)
{
nsRegistryKey regkey = 0;
nsresult rv;
nsCOMPtr<nsIProfile> profMan(do_GetService(NS_PROFILE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsXPIDLString profile;
rv = profMan->GetCurrentProfile(getter_Copies(profile));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIRegistry> registry;
rv = GetRegistry(registry);
NS_ENSURE_SUCCESS(rv, rv);
rv = registry->GetKey(nsIRegistry::Common,
kRegTreeProfile.get(),
&regkey);
NS_ENSURE_SUCCESS(rv, rv);
rv = registry->GetKey(regkey,
profile.get(),
&regkey);
NS_ENSURE_SUCCESS(rv, rv);
rv = registry->GetKey(regkey,
kRegTreeRoaming.get(),
&regkey);
NS_ENSURE_SUCCESS(rv, rv);
result = regkey;
return NS_OK;
}
/*
* Internal functions
*/
nsresult Core::ReadRoamingPrefs()
{
nsCOMPtr<nsIRegistry> registry;
nsresult rv = GetRegistry(registry);
NS_ENSURE_SUCCESS(rv, rv);
nsRegistryKey regkey;
rv = GetRegistryTree(regkey);
if (NS_FAILED(rv)) // expected, if roaming not set up for this profile
mIsRoaming = PR_FALSE;
else
{
PRInt32 enabled;
rv = registry->GetInt(regkey, kRegKeyEnabled.get(),
&enabled);
if (NS_FAILED(rv))
{
mIsRoaming = PR_FALSE;
return rv;
}
mIsRoaming = (enabled != 0);
}
if (!mIsRoaming)
return NS_OK;
// Method
nsXPIDLString proto;
rv = registry->GetString(regkey, kRegKeyMethod.get(),
getter_Copies(proto));
NS_ENSURE_SUCCESS(rv, rv);
if (proto == kRegValMethodStream)
mMethod = 1;
else if (proto == kRegValMethodCopy)
mMethod = 2;
// Files
nsXPIDLString files_reg;
rv = registry->GetString(regkey, kRegKeyFiles.get(),
getter_Copies(files_reg));
NS_ENSURE_SUCCESS(rv, rv);
NS_ConvertUTF16toUTF8 files_pref(files_reg);
mFiles.Clear();
mFiles.ParseString(files_pref.get(), ",");
return NS_OK;
}
Protocol* Core::CreateMethodHandler()
{
if (mMethod == 1)
return new Stream;
else if (mMethod == 2)
return new Copy;
return 0;
}
/* A workaround for the fact that the network library is shut down during
profile shutdown (for dynamic profile changing), *before* the
app is told to write down profile changes and thus before we try to upload,
so our upload will fail.
So, I just power netlib up again and then power it down again by sending
the corresponding profile change notification. Might not be the
best solution, but has small impact on existing code and WFM. */
nsresult Core::RestoreCloseNet(PRBool restore)
{
const char* topic = restore ? "profile-change-net-restore"
: "profile-change-net-teardown";
nsresult rv;
nsCOMPtr<nsIObserverService> observerService
(do_GetService("@mozilla.org/observer-service;1", &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupports> subject(do_GetService(NS_PROFILE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
rv = observerService->NotifyObservers(subject, topic,
NS_LITERAL_STRING("switch").get());
return rv;
}

Просмотреть файл

@ -0,0 +1,139 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Central object for session roaming. Controls program sequence and provides
common functions. */
#ifndef _Core_H_
#define _Core_H_
#include "nsISessionRoaming.h"
#include "nsCOMPtr.h"
#include "nsISupports.h"
#include "nsIRegistry.h"
#include "nsIURI.h"
#include "nsString.h"
#include "nsVoidArray.h"
#define NS_SESSIONROAMING_CID \
{ /* {ab62465c-494c-446e-b671-930bb98a7bc4} */ \
0xab62465c, \
0x494c, \
0x446e, \
{ 0xb6, 0x71, 0x93, 0x0b, 0xb9, 0x8a, 0x7b, 0xc4 } \
}
#define NS_SESSIONROAMING_CONTRACTID \
"@mozilla.org/profile/session-roaming;1"
class Protocol;
class Core: public nsISessionRoaming
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISESSIONROAMING
Core();
// Is a roaming profile (if not, then nothing to do)
inline PRBool IsRoaming() { return mIsRoaming; };
// Which profile files should be stored on the server
// @return pointer to the internal nsDeque object. Do not free it.
inline const nsCStringArray* GetFilesToRoam() { return &mFiles; };
// Local profile directory
nsresult GetProfileDir(nsIFile** result);
// Method used to store remote files
// 0=unknown, 1=HTTP, 2=Copy
inline PRInt32 GetMethod() { return mMethod; };
/* If we'd normally overwrite a newer file. Ask user, which file to keep.
* @param download direction: true = download, false = upload
* @param files conflicting files
* @param result Files for which conflicts should be ignored.
* This is a subset of the files param and those should
* be uploaded / downloaded. The rest of files in the
* files param should *not* be uploaded / downloaded.
* Wants an array passed in, items will be added to that.
* @return NS_ERROR_ABORT, if the user clicked Cancel.
*/
nsresult ConflictResolveUI(PRBool download, const nsCStringArray& files,
nsCStringArray* result);
nsresult GetRegistry(nsCOMPtr<nsIRegistry>& result);
nsresult GetRegistryTree(nsRegistryKey& result);
/* At the time we attempt to upload, the network lib has already been
shut down. So, temporarily restore it and then close it down again.
Of course, this is a hack, until we (me, ccarlen, darin) have found a
better solution and it has been tested thoroughly for regressions.
This problem currently doesn't appear during download (at startup).
@param restore if true, then restore, otherwise close
@param topic the notification topic.
either "profile-change-net-restore"
or "profile-change-net-teardown"
*/
inline nsresult RestoreNet() { return RestoreCloseNet(PR_TRUE); };
inline nsresult CloseNet() { return RestoreCloseNet(PR_FALSE); };
protected:
// Data (see getters above)
PRBool mIsRoaming;
PRInt32 mMethod;
nsCStringArray mFiles;
// Cache
nsCOMPtr<nsIRegistry> mRegistry;
// Reads liprefs: is roaming profile?, files, server info etc.
nsresult ReadRoamingPrefs();
// Factory method for a new method handler that can handle this method
// We'll use a new object for down-/upload respectively
// @return new object. you have to free it with delete.
Protocol* CreateMethodHandler();
nsresult RestoreCloseNet(PRBool restore);
};
#endif

Просмотреть файл

@ -0,0 +1,70 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# 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
# Ben Bucksch <http://www.bucksch.org> of
# Beonex <http://www.beonex.com>.
# Portions created by the Initial Developer are Copyright (C) 2003-2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH=../../..
topsrcdir=@top_srcdir@
srcdir=@srcdir@
VPATH=@srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE=sroaming
LIBRARY_NAME=sroaming
IS_COMPONENT = 1
REQUIRES = xpcom \
xpcom_obsolete \
reglib \
string \
profile \
necko \
dom \
windowwatcher \
$(NULL)
CPPSRCS= \
Core.cpp \
Copy.cpp \
Stream.cpp \
Module.cpp \
$(NULL)
EXTRA_DSO_LDOPTS += \
$(MOZ_COMPONENT_LIBS) \
$(MOZ_XPCOM_OBSOLETE_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIGenericFactory.h"
#include "Core.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(Core)
static const nsModuleComponentInfo components[] =
{
{ "Session Roaming",
NS_SESSIONROAMING_CID,
NS_SESSIONROAMING_CONTRACTID,
CoreConstructor },
};
NS_IMPL_NSGETMODULE(Module, components)

Просмотреть файл

@ -0,0 +1,73 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Interface for session roaming protocol handlers */
/* These protocol handlers download/upload the profile files
from/to the server,
probably using generic protocol implementations in netwerk. */
// I love it when the license is longer than the content.</irony>
#ifndef _PROTOCOL_H_
#define _PROTOCOL_H_
#include "Core.h"
class Protocol
{
public:
Protocol() {};
virtual ~Protocol() {};
/**
* If the class reads any prefs,
* it must happen here
*/
virtual nsresult Init(Core*) = 0;
// copy files from server to local profile
virtual nsresult Download() = 0;
// copy files from local profile to server
virtual nsresult Upload() = 0;
protected:
// Data
Core* mController;
};
#endif

Просмотреть файл

@ -0,0 +1,299 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "Stream.h"
#include "nsIComponentManager.h"
#include "nsILocalFile.h"
#include "nsXPIDLString.h"
#include "nsIIOService.h"
#include "nsNetUtil.h"
// UI
#include "nsIDialogParamBlock.h"
#include "nsIDOMWindow.h"
#include "nsIWindowWatcher.h"
#include "plstr.h"
// IID and CIDs of all the services needed
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#define kRegTreeStream (NS_LITERAL_STRING("Stream"))
#define kRegKeyURL (NS_LITERAL_STRING("BaseURL"))
#define kRegKeyUsername (NS_LITERAL_STRING("Username"))
#define kRegKeyPassword (NS_LITERAL_STRING("Password"))
#define kRegKeySavePassword (NS_LITERAL_CSTRING("SavePassword"))
#define kXferDlg "chrome://sroaming/content/transfer/progressDialog.xul"
// Internal helper functions unrelated to class
static void AppendElements(nsCStringArray& target, nsCStringArray& source)
{
for (PRInt32 i = source.Count() - 1; i >= 0; i--)
target.AppendCString(*source.CStringAt(i));
}
/*
* nsSRoamingMethod implementation
*/
nsresult Stream::Init(Core* aController)
{
nsresult rv;
mController = aController;
NS_ASSERTION(mController, "mController is null");
// Get prefs
nsCOMPtr<nsIRegistry> registry;
rv = mController->GetRegistry(registry);
NS_ENSURE_SUCCESS(rv, rv);
nsRegistryKey regkey;
rv = mController->GetRegistryTree(regkey);
NS_ENSURE_SUCCESS(rv, rv);
rv = registry->GetKey(regkey,
kRegTreeStream.get(),
&regkey);
NS_ENSURE_SUCCESS(rv, rv);
mRegkeyStream = regkey;
nsXPIDLString remoteUrlPref;
rv = registry->GetString(regkey, kRegKeyURL.get(),
getter_Copies(remoteUrlPref));
NS_ENSURE_SUCCESS(rv, rv);
mRemoteBaseUrl = NS_ConvertUTF16toUTF8(remoteUrlPref);
/* For easier mass-personalisation via scripts in corporate setups and
for easier instructed setup by normal users,
we allow the username to be separate from the URL. */
nsXPIDLString usernamePref;
rv = registry->GetString(regkey, kRegKeyUsername.get(),
getter_Copies(usernamePref));
if (NS_SUCCEEDED(rv) && !usernamePref.IsEmpty() )
/* failure is non-fatal, because username might be in the URL, and
even if it isn't, the transfer will pull up a prompt. */
{
nsCOMPtr<nsIIOService> ioserv = do_GetService(kIOServiceCID, &rv);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), mRemoteBaseUrl);
if (NS_SUCCEEDED(rv))
{
rv = uri->SetUsername(NS_ConvertUTF16toUTF8(usernamePref));
if (NS_SUCCEEDED(rv))
{
// Yikes. Did I mention that I hate that C/wide string crap?
nsXPIDLCString spec;
uri->GetSpec(spec);
mRemoteBaseUrl = spec;
mRemoteBaseUrl.ReplaceSubstring(NS_LITERAL_CSTRING("$USERID"),
NS_ConvertUTF16toUTF8(usernamePref));
}
}
}
}
// we need a / at the end (base URL), fix up, if user error
if (mRemoteBaseUrl.Last() != (PRUnichar) '/')
mRemoteBaseUrl += (PRUnichar) '/';
nsXPIDLString passwordPref;
rv = registry->GetString(regkey, kRegKeyPassword.get(),
getter_Copies(passwordPref));
/* failure is non-fatal, because if there's no password, the
transfer will pull up a prompt. */
mPassword = passwordPref;
PRInt32 savepw = 0;
rv = registry->GetInt(regkey, kRegKeySavePassword.get(),
&savepw);
mSavePassword = savepw == 0 ? PR_FALSE : PR_TRUE;
nsCOMPtr<nsIFile> profiledir;
rv = mController->GetProfileDir(getter_AddRefs(profiledir));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIIOService> ioserv = do_GetService(kIOServiceCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_NewFileURI(getter_AddRefs(mProfileDir), profiledir);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
nsresult Stream::Download()
{
return DownUpLoad(PR_TRUE);
}
nsresult Stream::Upload()
{
return DownUpLoad(PR_FALSE);
}
nsresult Stream::DownUpLoad(PRBool download)
{
nsresult rv = NS_OK;
if (!mController)
return NS_ERROR_UNEXPECTED;
/* Design
I'd really like to
- open a few channels (one per file) here in this function,
- attach |nsIProgressEventSink|s to each and
- let a Progress dialog track/reflect the progress sinks.
That way, I would have a generic dialog for the UI somewhere
and the logic (transfer) here in this file, where it belongs.
Unfortunately, this doesn't work. I have to
block this function until the transfer is done, but have the transfer
itself and the progress UI working. darin says, I will get threading
issues then. He suggested to initiate the transfer from the dialog
(because that dialog uses another event quene) and let the dialog
close itself when the transfer is done. Here in this function, I can
block until the dialog is dismissed.
(At least, that's what I understood from darin.)
That's what I do, and it seems to work. It's still a poor design.
Actually, it's really crap. It destroys my whole design with the
pluggable "method"s (like stream, copy etc.). Basically everything
contacting remote servers (i.e. needing a progress dialog) now has to
either mess around in sroamingTransfer.js or duplicate a certain
portion of code.
*/
nsCOMPtr<nsIWindowWatcher> windowWatcher
(do_GetService("@mozilla.org/embedcomp/window-watcher;1", &rv));
NS_ENSURE_SUCCESS(rv, rv);
/* nsIDialogParamBlock is a method to pass ints and strings
to and from XUL dialogs.
To dialog (upon open)
Int array
Item 0: 1 = download, 2 = upload
Item 1: 1 = serial (transfer one file after the other),
2 = parallel (start all file transfers at once)
Item 2: Number of files (n below)
Item 3: Save password (should pw be stored by default when asked?)
1 = true
0 = false
String array
Item 0: unused
Item 1: URL of profile dir
Item 2: URL of remote dir
Item 3: Password
Item 4..(n+3): filenames
From dialog (upon close)
Int array
Item 0: 0 = do nothing
1 = Save Password (user checked the box in the prompt)
2 = Set SavePassword pref to false, ignore PW/Usern. retval
String array
Item 0: Saved username (as entered in the prompt)
Item 1: Saved password (as entered in the prompt)
*/
nsCOMPtr<nsIDialogParamBlock> ioParamBlock
(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1", &rv));
NS_ENSURE_SUCCESS(rv, rv);
// download/upload
ioParamBlock->SetInt(0, download ? 1 : 2);
ioParamBlock->SetInt(1, 2);
const nsCStringArray* files = mController->GetFilesToRoam();
ioParamBlock->SetInt(2, files->Count());
ioParamBlock->SetInt(3, mSavePassword ? 1 : 0);
nsXPIDLCString profile;
mProfileDir->GetSpec(profile);
ioParamBlock->SetString(1, NS_ConvertUTF8toUTF16(profile).get());
ioParamBlock->SetString(2, NS_ConvertUTF8toUTF16(mRemoteBaseUrl).get());
ioParamBlock->SetString(3, mSavePassword
? mPassword.get()
: NS_LITERAL_STRING("").get());
// filenames
for (PRInt32 i = files->Count() - 1; i >= 0; i--)
{
NS_ConvertASCIItoUTF16 filename(*files->CStringAt(i));
ioParamBlock->SetString(i + 4, filename.get());
// filenames start at item 4
}
nsCOMPtr<nsIDOMWindow> window;
rv = windowWatcher->OpenWindow(nsnull,
kXferDlg,
nsnull,
"centerscreen,chrome,modal,titlebar",
ioParamBlock,
getter_AddRefs(window));
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 savepw = 0;
ioParamBlock->GetInt(0, &savepw);
if (savepw == 1)
{
nsXPIDLString password, username;
ioParamBlock->GetString(0, getter_Copies(username));
ioParamBlock->GetString(1, getter_Copies(password));
mPassword = password;
nsCOMPtr<nsIRegistry> registry;
rv = mController->GetRegistry(registry);
rv = registry->SetInt(mRegkeyStream, kRegKeySavePassword.get(), 1);
rv = registry->SetString(mRegkeyStream, kRegKeyUsername.get(),
username.get());
rv = registry->SetString(mRegkeyStream, kRegKeyPassword.get(),
mPassword.get());
// failure is not fatal. then it's not saved *shrug*. ;-)
}
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,80 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Roaming code.
*
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org> of
* Beonex <http://www.beonex.com>
* Portions created by the Initial Developer are Copyright (C) 2002-2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Uploads/downloads files using HTTP or FTP */
/* This implementation uses Necko to transfer files to/from the server.
It should be able to support any protocol which has an nsIUploadChannel
implementation in Necko, after some tweaks (errors msgs and workarounds)
to the JS part (resources/content/transfer/transfer.js, utility.js and
transfer.properties). Currently, HTTP and FTP are supported.
*/
#ifndef _STREAM_H_
#define _STREAM_H_
#include "Protocol.h"
class Stream: public Protocol
{
public:
nsresult Init(Core* controller);
nsresult Download();
nsresult Upload();
nsresult DownUpLoad(PRBool download);
protected:
// Data
/**
* Directory on server, where profile files are.
* This is already with the concrete username.
*/
nsCString mRemoteBaseUrl;
nsString mPassword;
/**
* If we have to ask for a password, this is
* the default for the "save password" checkbox
*/
PRBool mSavePassword;
nsCOMPtr<nsIURI> mProfileDir;
nsRegistryKey mRegkeyStream;
protected:
};
#endif