Skip to content

Commit

Permalink
Bug 966434 - Refactor tps for fxaccounts and old sync authentication …
Browse files Browse the repository at this point in the history
…support. r=jgriffin
  • Loading branch information
whimboo committed Mar 14, 2014
1 parent a459101 commit d29c742
Show file tree
Hide file tree
Showing 29 changed files with 476 additions and 598 deletions.
1 change: 0 additions & 1 deletion services/sync/modules/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,6 @@ Sync11Service.prototype = {
&& (username || password || passphrase)) {
Svc.Obs.notify("weave:service:setup-complete");
}

this._log.info("Logging in user " + this.identity.username);
this._updateCachedURLs();

Expand Down
2 changes: 1 addition & 1 deletion services/sync/tests/tps/mozmill_sanity.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

Components.utils.import('resource://tps/sync.jsm');
Components.utils.import('resource://tps/mozmill/sync.jsm');

var setupModule = function(module) {
controller = mozmill.getBrowserController();
Expand Down
3 changes: 2 additions & 1 deletion services/sync/tps/extensions/tps/chrome.manifest
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
resource tps modules/
resource tps resource/

component {4e5bd3f0-41d3-11df-9879-0800200c9a66} components/tps-cmdline.js
contract @mozilla.org/commandlinehandler/general-startup;1?type=tps {4e5bd3f0-41d3-11df-9879-0800200c9a66}
category command-line-handler m-tps @mozilla.org/commandlinehandler/general-startup;1?type=tps
27 changes: 10 additions & 17 deletions services/sync/tps/extensions/tps/components/tps-cmdline.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

function TPSCmdLineHandler() {}
TPSCmdLineHandler.prototype =
{

TPSCmdLineHandler.prototype = {
classDescription: "TPSCmdLineHandler",
classID : TPS_CMDLINE_CLSID,
contractID : TPS_CMDLINE_CONTRACTID,
Expand All @@ -49,7 +49,7 @@ TPSCmdLineHandler.prototype =
return;
let phase = cmdLine.handleFlagWithParam("tpsphase", false);
if (phase == null)
throw("must specify --tpsphase with --tps");
throw Error("must specify --tpsphase with --tps");
let logfile = cmdLine.handleFlagWithParam("tpslogfile", false);
if (logfile == null)
logfile = "";
Expand Down Expand Up @@ -79,10 +79,8 @@ TPSCmdLineHandler.prototype =
};


var TPSCmdLineFactory =
{
createInstance : function(outer, iid)
{
var TPSCmdLineFactory = {
createInstance : function(outer, iid) {
if (outer != null) {
throw Components.results.NS_ERROR_NO_AGGREGATION;
}
Expand All @@ -92,10 +90,8 @@ var TPSCmdLineFactory =
};


var TPSCmdLineModule =
{
registerSelf : function(compMgr, fileSpec, location, type)
{
var TPSCmdLineModule = {
registerSelf : function(compMgr, fileSpec, location, type) {
compMgr = compMgr.QueryInterface(nsIComponentRegistrar);

compMgr.registerFactoryLocation(TPS_CMDLINE_CLSID,
Expand All @@ -114,8 +110,7 @@ var TPSCmdLineModule =
TPS_CMDLINE_CONTRACTID, true, true);
},

unregisterSelf : function(compMgr, fileSpec, location)
{
unregisterSelf : function(compMgr, fileSpec, location) {
compMgr = compMgr.QueryInterface(nsIComponentRegistrar);

compMgr.unregisterFactoryLocation(TPS_CMDLINE_CLSID, fileSpec);
Expand All @@ -126,8 +121,7 @@ var TPSCmdLineModule =
"m-tps", true);
},

getClassObject : function(compMgr, cid, iid)
{
getClassObject : function(compMgr, cid, iid) {
if (cid.equals(TPS_CMDLINE_CLSID)) {
return TPSCmdLineFactory;
}
Expand All @@ -139,8 +133,7 @@ var TPSCmdLineModule =
throw Components.results.NS_ERROR_NO_INTERFACE;
},

canUnload : function(compMgr)
{
canUnload : function(compMgr) {
return true;
}
};
Expand Down
9 changes: 5 additions & 4 deletions services/sync/tps/extensions/tps/install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>tps@mozilla.org</em:id>
<em:version>0.2</em:version>
<em:version>0.5</em:version>

<em:targetApplication>
<!-- Firefox -->
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>3.5.0</em:minVersion>
<em:maxVersion>12.0.*</em:maxVersion>
<em:minVersion>24.0.*</em:minVersion>
<em:maxVersion>31.0.*</em:maxVersion>
</Description>
</em:targetApplication>

<!-- front-end metadata -->
<em:name>TPS</em:name>
<em:description>Sync test extension</em:description>
<em:creator>Jonathan Griffin</em:creator>
<em:homepageURL>http://www.mozilla.org/</em:homepageURL>
<em:contributor>Henrik Skupin</em:contributor>
<em:homepageURL>https://developer.mozilla.org/en-US/docs/TPS</em:homepageURL>
</Description>
</RDF>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ this.EXPORTED_SYMBOLS = [
"FxAccountsHelper",
];

const { utils: Cu } = Components;
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;

Cu.import("resource://gre/modules/FxAccountsClient.jsm");
Cu.import("resource://services-common/async.js");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@

var EXPORTED_SYMBOLS = ["Logger"];

const CC = Components.classes;
const CI = Components.interfaces;
const CU = Components.utils;
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;

var Logger =
{
var Logger = {
_foStream: null,
_converter: null,
_potentialError: null,
Expand All @@ -25,35 +22,35 @@ var Logger =
return;
}

let prefs = CC["@mozilla.org/preferences-service;1"]
.getService(CI.nsIPrefBranch);
let prefs = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefBranch);
if (path) {
prefs.setCharPref("tps.logfile", path);
}
else {
path = prefs.getCharPref("tps.logfile");
}

this._file = CC["@mozilla.org/file/local;1"]
.createInstance(CI.nsILocalFile);
this._file = Cc["@mozilla.org/file/local;1"]
.createInstance(Ci.nsILocalFile);
this._file.initWithPath(path);
var exists = this._file.exists();

// Make a file output stream and converter to handle it.
this._foStream = CC["@mozilla.org/network/file-output-stream;1"]
.createInstance(CI.nsIFileOutputStream);
this._foStream = Cc["@mozilla.org/network/file-output-stream;1"]
.createInstance(Ci.nsIFileOutputStream);
// If the file already exists, append it, otherwise create it.
var fileflags = exists ? 0x02 | 0x08 | 0x10 : 0x02 | 0x08 | 0x20;

this._foStream.init(this._file, fileflags, 0666, 0);
this._converter = CC["@mozilla.org/intl/converter-output-stream;1"]
.createInstance(CI.nsIConverterOutputStream);
this._converter = Cc["@mozilla.org/intl/converter-output-stream;1"]
.createInstance(Ci.nsIConverterOutputStream);
this._converter.init(this._foStream, "UTF-8", 0, 0);
},

write: function (data) {
if (this._converter == null) {
CU.reportError(
Cu.reportError(
"TPS Logger.write called with _converter == null!");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ Cu.import("resource://services-sync/addonutils.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://tps/logger.jsm");

const ADDONSGETURL = 'http://127.0.0.1:4567/';
const ADDONSGETURL = "http://127.0.0.1:4567/";
const STATE_ENABLED = 1;
const STATE_DISABLED = 2;

function GetFileAsText(file)
{
function GetFileAsText(file) {
let channel = Services.io.newChannel(file, null, null);
let inputStream = channel.open();
if (channel instanceof Ci.nsIHttpChannel &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@
var EXPORTED_SYMBOLS = ["PlacesItem", "Bookmark", "Separator", "Livemark",
"BookmarkFolder", "DumpBookmarks"];

const CC = Components.classes;
const CI = Components.interfaces;
const CU = Components.utils;
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;

CU.import("resource://tps/logger.jsm");
CU.import("resource://gre/modules/Services.jsm");
CU.import("resource://gre/modules/PlacesUtils.jsm");
CU.import("resource://gre/modules/BookmarkJSONUtils.jsm");
CU.import("resource://gre/modules/Task.jsm");
CU.import("resource://services-common/async.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/PlacesUtils.jsm");
Cu.import("resource://gre/modules/BookmarkJSONUtils.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://services-common/async.js");

Cu.import("resource://tps/logger.jsm");

var DumpBookmarks = function TPS_Bookmarks__DumpBookmarks() {
let writer = {
Expand Down Expand Up @@ -223,7 +222,7 @@ PlacesItem.prototype = {
for (let i = 1; i < folder_parts.length; i++) {
let subfolder_id = this.GetPlacesNodeId(
folder_id,
CI.nsINavHistoryResultNode.RESULT_TYPE_FOLDER,
Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER,
folder_parts[i]);
if (subfolder_id == -1) {
return -1;
Expand Down Expand Up @@ -253,7 +252,7 @@ PlacesItem.prototype = {
for (let i = 1; i < folder_parts.length; i++) {
let subfolder_id = this.GetPlacesNodeId(
folder_id,
CI.nsINavHistoryResultNode.RESULT_TYPE_FOLDER,
Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER,
folder_parts[i]);
if (subfolder_id == -1) {
folder_id = PlacesUtils.bookmarks.createFolder(folder_id,
Expand Down Expand Up @@ -703,7 +702,7 @@ BookmarkFolder.prototype = {
}
this.props.item_id = this.GetPlacesNodeId(
this.props.folder_id,
CI.nsINavHistoryResultNode.RESULT_TYPE_FOLDER,
Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER,
this.props.folder);
if (!this.CheckDescription(this.props.description))
return -1;
Expand Down Expand Up @@ -814,7 +813,7 @@ Livemark.prototype = {
}
this.props.item_id = this.GetPlacesNodeId(
this.props.folder_id,
CI.nsINavHistoryResultNode.RESULT_TYPE_FOLDER,
Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER,
this.props.livemark);
if (!PlacesUtils.annotations
.itemHasAnnotation(this.props.item_id, PlacesUtils.LMANNO_FEEDURI)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@

var EXPORTED_SYMBOLS = ["FormData"];

const CC = Components.classes;
const CI = Components.interfaces;
const CU = Components.utils;
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;

CU.import("resource://tps/logger.jsm");
Cu.import("resource://tps/logger.jsm");

let formService = CC["@mozilla.org/satchel/form-history;1"]
.getService(CI.nsIFormHistory2);
let formService = Cc["@mozilla.org/satchel/form-history;1"]
.getService(Ci.nsIFormHistory2);

/**
* FormDB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@

var EXPORTED_SYMBOLS = ["HistoryEntry", "DumpHistory"];

const CC = Components.classes;
const CI = Components.interfaces;
const CU = Components.utils;
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;

CU.import("resource://gre/modules/Services.jsm");
CU.import("resource://gre/modules/PlacesUtils.jsm");
CU.import("resource://tps/logger.jsm");
CU.import("resource://services-common/async.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/PlacesUtils.jsm");
Cu.import("resource://tps/logger.jsm");
Cu.import("resource://services-common/async.js");

var DumpHistory = function TPS_History__DumpHistory() {
let writer = {
Expand Down Expand Up @@ -55,7 +53,7 @@ var HistoryEntry = {
* Returns the DBConnection object for the history service.
*/
get _db() {
return PlacesUtils.history.QueryInterface(CI.nsPIPlacesDatabase).DBConnection;
return PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection;
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@

var EXPORTED_SYMBOLS = ["Password", "DumpPasswords"];

const CC = Components.classes;
const CI = Components.interfaces;
const CU = Components.utils;
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;

CU.import("resource://gre/modules/Services.jsm");
CU.import("resource://tps/logger.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://tps/logger.jsm");

let nsLoginInfo = new Components.Constructor(
"@mozilla.org/login-manager/loginInfo;1",
CI.nsILoginInfo,
Ci.nsILoginInfo,
"init");

var DumpPasswords = function TPS__Passwords__DumpPasswords() {
Expand Down Expand Up @@ -87,7 +85,7 @@ Password.prototype = {
this.props.usernameField,
this.props.passwordField);
Services.logins.addLogin(login);
login.QueryInterface(CI.nsILoginMetaInfo);
login.QueryInterface(Ci.nsILoginMetaInfo);
return login.guid;
},

Expand All @@ -109,7 +107,7 @@ Password.prototype = {
logins[i].password == this.props.password &&
logins[i].usernameField == this.props.usernameField &&
logins[i].passwordField == this.props.passwordField) {
logins[i].QueryInterface(CI.nsILoginMetaInfo);
logins[i].QueryInterface(Ci.nsILoginMetaInfo);
return logins[i].guid;
}
}
Expand Down
Loading

0 comments on commit d29c742

Please sign in to comment.