зеркало из https://github.com/mozilla/pjs.git
fix #54491 (subscribe is a big fat pig)
fix #56971 (correct spelling mistake: suppress not supress) fix #60244 (subscribe retains only last server subscribe changes) fix #60242 (subscribe typedown should select first match in list) fix #39156 (fix how I determine the delimiter in subscribe.js) fix #59231 (make insecure imap login work if password has a \ in it) fix #53654 (subscribe downloaded bytes don't start at zero) fix #39393 (stop button in subscribe) fix #60506 (switching servers doesn't clear text area in subscribe)
This commit is contained in:
Родитель
ab28a8e66c
Коммит
5a514dcacc
|
@ -118,7 +118,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsMessage)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgViewNavigationService,Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgServiceProviderService, Init);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSubscribeDataSource, Init);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSubscribableServer);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSubscribableServer, Init);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgPrintEngine, Init)
|
||||
|
||||
// The list of components we register
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
interface nsIFolder;
|
||||
|
||||
[scriptable, uuid(1c5ef9f0-d1c0-11d2-94CA-006097222B83)] /* XXX regenerate */
|
||||
[scriptable, uuid(d4ff86da-1dd1-11b2-a6f6-9fcd348bcc34)]
|
||||
interface nsIFolderListener : nsISupports {
|
||||
|
||||
void OnItemAdded(in nsISupports parentItem,
|
||||
|
|
|
@ -22,33 +22,60 @@
|
|||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISupportsArray.idl"
|
||||
|
||||
interface nsIMsgWindow;
|
||||
interface nsIMsgIncomingServer;
|
||||
interface nsIRDFResource;
|
||||
interface nsIRDFNode;
|
||||
|
||||
[scriptable, uuid(61a08c3a-1dd2-11b2-b64f-c4b2de1cf129)]
|
||||
interface nsISubscribeDataSource : nsISupports {
|
||||
readonly attribute boolean hasObservers;
|
||||
void NotifyObservers(in nsIRDFResource subject, in nsIRDFResource property, in nsIRDFNode object, in boolean isAssert, in boolean isChange);
|
||||
};
|
||||
|
||||
[scriptable, uuid(f337b84a-1dd1-11b2-97c7-fb8b2e3f2280)]
|
||||
interface nsISubscribeListener : nsISupports {
|
||||
void OnStopPopulating();
|
||||
void OnDonePopulating();
|
||||
};
|
||||
|
||||
[scriptable, uuid(6f9d2e82-1dd2-11b2-bbed-bbea41ca33a7)]
|
||||
interface nsISubscribableServer : nsISupports {
|
||||
void setIncomingServer(in nsIMsgIncomingServer server);
|
||||
void setDelimiter(in char delimiter);
|
||||
void populateSubscribeDatasource(in nsIMsgWindow aMsgWindow, in boolean forceToServer);
|
||||
void populateSubscribeDatasourceWithUri(in nsIMsgWindow aMsgWindow, in boolean forceToServer, in string uri);
|
||||
attribute nsISubscribeListener subscribeListener;
|
||||
void startPopulatingSubscribeDS();
|
||||
void stopPopulatingSubscribeDS();
|
||||
void findAndAddParentToSubscribeDS(in string uri, in string serverUri, in string aName, in nsIRDFResource aChildResource);
|
||||
void setPropertiesInSubscribeDS(in string uri, in wstring aName, in nsIRDFResource aResource, in boolean subscribed, in boolean changeIfExists);
|
||||
void addToSubscribeDS(in string aName, in boolean addAsSubscribed, in boolean changeIfExists);
|
||||
void setAsSubscribedInSubscribeDS(in string aURI);
|
||||
void updateSubscribedInSubscribeDS();
|
||||
|
||||
attribute char delimiter;
|
||||
|
||||
void startPopulating(in nsIMsgWindow aMsgWindow, in boolean forceToServer);
|
||||
void startPopulatingWithUri(in nsIMsgWindow aMsgWindow, in boolean forceToServer, in string uri);
|
||||
void stopPopulating(in nsIMsgWindow aMsgWindow);
|
||||
|
||||
// return true if state changed, false otherwise
|
||||
boolean setState(in string path, in boolean state);
|
||||
|
||||
void subscribeCleanup();
|
||||
|
||||
void subscribe(in wstring name);
|
||||
void unsubscribe(in wstring name);
|
||||
|
||||
void commitSubscribeChanges();
|
||||
|
||||
// other stuff
|
||||
void setIncomingServer(in nsIMsgIncomingServer server);
|
||||
void addTo(in string aName, in boolean addAsSubscribed, in boolean changeIfExists);
|
||||
void setAsSubscribed(in string path);
|
||||
void updateSubscribed();
|
||||
void setShowFullName(in boolean showFullName);
|
||||
void subscribeCleanup();
|
||||
|
||||
// if path is null, use the root
|
||||
boolean hasChildren(in string path);
|
||||
// if path is null, use the root
|
||||
boolean isSubscribed(in string path);
|
||||
// if path is null, use the root
|
||||
wstring getLeafName(in string path);
|
||||
// if path is null, use the root
|
||||
void getChildren(in string path, in nsISupportsArray array);
|
||||
// if path is null, use the root
|
||||
void getFirstChildURI(in string path, out string result);
|
||||
};
|
||||
|
||||
|
|
|
@ -349,50 +349,38 @@ function Subscribe(windowTitle, preselectedMsgFolder)
|
|||
okCallback:SubscribeOKCallback});
|
||||
}
|
||||
|
||||
function SubscribeOKCallback(serverURI, changeTable)
|
||||
function SubscribeOKCallback(changeTable)
|
||||
{
|
||||
//dump("in SubscribeOKCallback(" + serverURI +")\n");
|
||||
//dump("change table = " + changeTable + "\n");
|
||||
|
||||
var folder = GetMsgFolderFromUri(serverURI);
|
||||
var server = folder.server;
|
||||
var subscribableServer =
|
||||
server.QueryInterface(Components.interfaces.nsISubscribableServer);
|
||||
for (var serverURI in changeTable) {
|
||||
//dump("serverURI = " + serverURI + "\n");
|
||||
var folder = GetMsgFolderFromUri(serverURI);
|
||||
var server = folder.server;
|
||||
var subscribableServer =
|
||||
server.QueryInterface(Components.interfaces.nsISubscribableServer);
|
||||
|
||||
for (var name in changeTable[serverURI]) {
|
||||
//dump("name = " + name + "\n");
|
||||
//dump("(" + serverURI + "," + name + ") = " + changeTable[serverURI][name] + "\n");
|
||||
if (changeTable[serverURI][name] == true) {
|
||||
//dump("from js, subscribe to " + name +" on " + serverURI + "\n");
|
||||
subscribableServer.subscribe(name);
|
||||
}
|
||||
else if (changeTable[serverURI][name] == false) {
|
||||
//dump("from js, unsubscribe to " + name +" on " + serverURI + "\n");
|
||||
subscribableServer.unsubscribe(name);
|
||||
}
|
||||
else {
|
||||
//dump("no change to " + name + " on " + serverURI +"\n");
|
||||
}
|
||||
}
|
||||
|
||||
for (var name in changeTable) {
|
||||
//dump(name + " = " + changeTable[name] + "\n");
|
||||
if (changeTable[name] == true) {
|
||||
//dump("from js, subscribe to " + name +"\n");
|
||||
subscribableServer.subscribe(name);
|
||||
}
|
||||
else if (changeTable[name] == false) {
|
||||
//dump("from js, unsubscribe to " + name +"\n");
|
||||
subscribableServer.unsubscribe(name);
|
||||
}
|
||||
else {
|
||||
//dump("no change to " + name + "\n");
|
||||
}
|
||||
}
|
||||
try {
|
||||
var imapServer =
|
||||
server.QueryInterface(Components.interfaces.nsIImapIncomingServer);
|
||||
if (imapServer)
|
||||
imapServer.reDiscoverAllFolders();
|
||||
}
|
||||
catch (ex) {
|
||||
//dump("*** not an imap server\n");
|
||||
}
|
||||
var nntpServer;
|
||||
try {
|
||||
nntpServer =
|
||||
server.QueryInterface(Components.interfaces.nsINntpIncomingServer);
|
||||
// write out the subscribe changes
|
||||
if (nntpServer)
|
||||
nntpServer.writeNewsrcFile();
|
||||
}
|
||||
catch (ex) {
|
||||
//dump("*** not a news server\n");
|
||||
try {
|
||||
var subscribableServer = server.QueryInterface(Components.interfaces.nsISubscribableServer);
|
||||
subscribableServer.commitSubscribeChanges();
|
||||
}
|
||||
catch (ex) {
|
||||
dump(ex + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,33 +3,25 @@ var okCallback = null;
|
|||
var gChangeTable = {};
|
||||
var gServerURI = null;
|
||||
var gSubscribableServer = null;
|
||||
var RDF = null;
|
||||
var gSubscribeDS = null;
|
||||
var gStatusBar = null;
|
||||
var gNameField = null;
|
||||
var gFolderDelimiter = ".";
|
||||
var gStatusFeedback = new nsMsgStatusFeedback;
|
||||
|
||||
// the rdf service
|
||||
var RDF = '@mozilla.org/rdf/rdf-service;1'
|
||||
RDF = Components.classes[RDF].getService();
|
||||
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
|
||||
var subscribeDS = RDF.GetDataSource("rdf:subscribe");
|
||||
|
||||
// used for caching the tree children (in typedown)
|
||||
var lastTreeChildrenValue = null;
|
||||
var lastTreeChildren = null;
|
||||
|
||||
|
||||
function SetUpRDF()
|
||||
{
|
||||
if (!RDF) {
|
||||
RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService();
|
||||
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
|
||||
}
|
||||
|
||||
if (!gSubscribeDS) {
|
||||
gSubscribeDS = RDF.GetDataSource("rdf:subscribe");
|
||||
}
|
||||
}
|
||||
|
||||
function Stop()
|
||||
{
|
||||
dump("xxx todo implement stop.\n");
|
||||
//dump("Stop()\n")
|
||||
gSubscribableServer.stopPopulating(msgWindow);
|
||||
}
|
||||
|
||||
var Bundle = srGetStrBundle("chrome://messenger/locale/subscribe.properties");
|
||||
|
@ -39,9 +31,9 @@ function SetServerTypeSpecificTextValues()
|
|||
if (!gServerURI) return;
|
||||
|
||||
var serverType = GetMsgFolderFromUri(gServerURI).server.type;
|
||||
//dump("serverType="+serverType+"\n");
|
||||
|
||||
/* set the server specific ui elements */
|
||||
//set the server specific ui elements
|
||||
|
||||
var element = document.getElementById("foldertextlabel");
|
||||
var stringName = "foldertextfor-" + serverType;
|
||||
var stringval = Bundle.GetStringFromName(stringName);
|
||||
|
@ -52,15 +44,14 @@ function SetServerTypeSpecificTextValues()
|
|||
element = document.getElementById("foldersheaderlabel");
|
||||
element.setAttribute('value',stringval);
|
||||
|
||||
// xxx todo, fix this hack
|
||||
// qi the server to get a nsISubscribable server
|
||||
// and ask it for the delimiter
|
||||
if (serverType == "nntp") {
|
||||
gFolderDelimiter = ".";
|
||||
}
|
||||
else {
|
||||
gFolderDelimiter = "/";
|
||||
}
|
||||
//set the delimiter
|
||||
try {
|
||||
gFolderDelimiter = gSubscribableServer.delimiter;
|
||||
}
|
||||
catch (ex) {
|
||||
//dump(ex + "\n");
|
||||
gFolderDelimiter = ".";
|
||||
}
|
||||
}
|
||||
|
||||
function onServerClick(event)
|
||||
|
@ -69,8 +60,9 @@ function onServerClick(event)
|
|||
gServerURI = item.id;
|
||||
//dump("gServerURI="+gServerURI+"\n");
|
||||
|
||||
SetServerTypeSpecificTextValues();
|
||||
SetUpTree(false);
|
||||
|
||||
SetServerTypeSpecificTextValues();
|
||||
}
|
||||
|
||||
function SetUpServerMenu()
|
||||
|
@ -88,28 +80,29 @@ function SetUpServerMenu()
|
|||
serverMenu.selectedItem = menuitems[0];
|
||||
}
|
||||
catch (ex) {
|
||||
dump("failed to set the selected server: " + ex + "\n");
|
||||
//dump("failed to set the selected server: " + ex + "\n");
|
||||
}
|
||||
|
||||
SetServerTypeSpecificTextValues();
|
||||
}
|
||||
|
||||
var MySubscribeListener = {
|
||||
OnStopPopulating: function() {
|
||||
// only re-root the tree, if it is null.
|
||||
// otherwise, we are in here because we are populating
|
||||
// a part of the tree
|
||||
|
||||
var refValue = gSubscribeTree.getAttribute('ref');
|
||||
//dump("ref = " + refValue + refValue.length + "\n");
|
||||
if (refValue == "null") {
|
||||
dump("root subscribe tree at: "+ gServerURI +"\n");
|
||||
gSubscribeTree.setAttribute('ref',gServerURI);
|
||||
}
|
||||
|
||||
OnDonePopulating: function() {
|
||||
gStatusFeedback.ShowProgress(100);
|
||||
gStatusFeedback.ShowStatusString(Bundle.GetStringFromName("doneString"));
|
||||
gStatusBar.setAttribute("mode","normal");
|
||||
|
||||
// only re-root the tree, if it is null.
|
||||
// otherwise, we are in here because we are populating
|
||||
// a part of the tree
|
||||
|
||||
var refValue = gSubscribeTree.getAttribute('ref');
|
||||
//dump("ref = " + refValue + refValue.length + "\n");
|
||||
if (refValue == "null") {
|
||||
//dump("root subscribe tree at: "+ gServerURI +"\n");
|
||||
gSubscribeTree.database.AddDataSource(subscribeDS);
|
||||
gSubscribeTree.setAttribute('ref',gServerURI);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -121,29 +114,31 @@ function SetUpTree(forceToServer)
|
|||
lastTreeChildrenValue = null;
|
||||
lastTreeChildren = null;
|
||||
|
||||
SetUpRDF();
|
||||
|
||||
gStatusBar = document.getElementById('statusbar-icon');
|
||||
gSubscribeTree.setAttribute('ref',null);
|
||||
|
||||
if (!gServerURI) return;
|
||||
|
||||
|
||||
var folder = GetMsgFolderFromUri(gServerURI);
|
||||
var server = folder.server;
|
||||
|
||||
try {
|
||||
gSubscribableServer = server.QueryInterface(Components.interfaces.nsISubscribableServer);
|
||||
gSubscribeTree.setAttribute('ref',null);
|
||||
|
||||
// clear out the text field when switching server
|
||||
gNameField.setAttribute('value',"");
|
||||
|
||||
gSubscribeTree.database.RemoveDataSource(subscribeDS);
|
||||
gSubscribableServer.subscribeListener = MySubscribeListener;
|
||||
|
||||
gStatusFeedback.ShowProgress(0);
|
||||
gStatusFeedback.ShowStatusString(Bundle.GetStringFromName("pleaseWaitString"));
|
||||
gStatusBar.setAttribute("mode","undetermined");
|
||||
|
||||
gSubscribableServer.populateSubscribeDatasource(msgWindow, forceToServer);
|
||||
gSubscribableServer.startPopulating(msgWindow, forceToServer);
|
||||
}
|
||||
catch (ex) {
|
||||
dump("failed to populate subscribe ds: " + ex + "\n");
|
||||
//dump("failed to populate subscribe ds: " + ex + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,7 +179,7 @@ function SubscribeOnLoad()
|
|||
gServerURI = folder.server.serverURI;
|
||||
}
|
||||
catch (ex) {
|
||||
dump("not a subscribable server\n");
|
||||
//dump("not a subscribable server\n");
|
||||
gSubscribableServer = null;
|
||||
gServerURI = null;
|
||||
}
|
||||
|
@ -192,7 +187,7 @@ function SubscribeOnLoad()
|
|||
|
||||
if (!gServerURI) {
|
||||
//dump("subscribe: no uri\n");
|
||||
dump("xxx todo: use the default news server. right now, I'm just using the first server\n");
|
||||
//dump("xxx todo: use the default news server. right now, I'm just using the first server\n");
|
||||
var serverMenu = document.getElementById("serverMenu");
|
||||
var menuitems = serverMenu.getElementsByTagName("menuitem");
|
||||
|
||||
|
@ -200,25 +195,26 @@ function SubscribeOnLoad()
|
|||
gServerURI = menuitems[1].id;
|
||||
}
|
||||
else {
|
||||
dump("xxx todo none of your servers are subscribable\n");
|
||||
dump("xxx todo fix this by disabling subscribe if no subscribable server or, add a CREATE SERVER button, like in 4.x\n");
|
||||
//dump("xxx todo none of your servers are subscribable\n");
|
||||
//dump("xxx todo fix this by disabling subscribe if no subscribable server or, add a CREATE SERVER button, like in 4.x\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SetUpServerMenu();
|
||||
|
||||
SetUpTree(false);
|
||||
|
||||
|
||||
gNameField.focus();
|
||||
gNameField.focus();
|
||||
}
|
||||
|
||||
function subscribeOK()
|
||||
{
|
||||
//dump("in subscribeOK()\n")
|
||||
if (top.okCallback) {
|
||||
top.okCallback(top.gServerURI,top.gChangeTable);
|
||||
top.okCallback(top.gChangeTable);
|
||||
}
|
||||
Stop();
|
||||
if (gSubscribableServer) {
|
||||
gSubscribableServer.subscribeCleanup();
|
||||
}
|
||||
|
@ -235,63 +231,46 @@ function subscribeCancel()
|
|||
return true;
|
||||
}
|
||||
|
||||
function SetState(uri,name,state,stateStr)
|
||||
function SetState(name,state)
|
||||
{
|
||||
//dump("SetState(" + uri +"," + name + "," + state + "," + stateStr + ")\n");
|
||||
if (!uri || !stateStr) return;
|
||||
//dump("SetState(" + name + "," + state + ")\n");
|
||||
|
||||
try {
|
||||
// xxx should we move this code into nsSubscribableServer.cpp?
|
||||
var src = RDF.GetResource(uri, true);
|
||||
var prop = RDF.GetResource("http://home.netscape.com/NC-rdf#Subscribed", true);
|
||||
var oldLiteral = gSubscribeDS.GetTarget(src, prop, true);
|
||||
//dump("oldLiteral="+oldLiteral+"\n");
|
||||
var changed = gSubscribableServer.setState(name, state);
|
||||
if (changed) {
|
||||
StateChanged(name,state);
|
||||
}
|
||||
}
|
||||
|
||||
oldValue = oldLiteral.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
||||
//dump("oldLiteral.Value="+oldValue+"\n");
|
||||
if (oldValue != stateStr) {
|
||||
var newLiteral = RDF.GetLiteral(stateStr);
|
||||
gSubscribeDS.Change(src, prop, oldLiteral, newLiteral);
|
||||
StateChanged(name,state);
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
dump("failed: " + ex + "\n");
|
||||
}
|
||||
function changeTableRecord(server, name, state) {
|
||||
this.server = server;
|
||||
this.name = name;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
function StateChanged(name,state)
|
||||
{
|
||||
//dump("StateChanged(" + name + "," + state + ")\n");
|
||||
//dump("start val=" +gChangeTable[name] + "\n");
|
||||
|
||||
if (gChangeTable[name] == undefined) {
|
||||
//dump(name+" not in table yet\n");
|
||||
gChangeTable[name] = state;
|
||||
if (gChangeTable[gServerURI] == undefined) {
|
||||
gChangeTable[gServerURI] = {};
|
||||
gChangeTable[gServerURI][name] = state;
|
||||
}
|
||||
else {
|
||||
var oldValue = gChangeTable[name];
|
||||
//dump(name+" already in table\n");
|
||||
if (oldValue != state) {
|
||||
gChangeTable[name] = undefined;
|
||||
}
|
||||
if (gChangeTable[gServerURI][name] == undefined) {
|
||||
gChangeTable[gServerURI][name] = state;
|
||||
}
|
||||
else {
|
||||
var oldValue = gChangeTable[gServerURI,name];
|
||||
if (oldValue != state) {
|
||||
gChangeTable[gServerURI][name] = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//dump("end val=" +gChangeTable[name] + "\n");
|
||||
}
|
||||
|
||||
function SetSubscribeState(state)
|
||||
{
|
||||
//dump("SetSubscribedState()\n");
|
||||
|
||||
var stateStr;
|
||||
if (state) {
|
||||
stateStr = 'true';
|
||||
}
|
||||
else {
|
||||
stateStr = 'false';
|
||||
}
|
||||
|
||||
try {
|
||||
//dump("subscribe button clicked\n");
|
||||
|
||||
|
@ -302,36 +281,28 @@ function SetSubscribeState(state)
|
|||
//dump(uri + "\n");
|
||||
name = group.getAttribute('name');
|
||||
//dump(name + "\n");
|
||||
SetState(uri,name,state,stateStr);
|
||||
SetState(name,state);
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
dump("SetSubscribedState failed: " + ex + "\n");
|
||||
//dump("SetSubscribedState failed: " + ex + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
function ReverseStateFromNode(node)
|
||||
{
|
||||
var stateStr;
|
||||
var state;
|
||||
|
||||
if (node.getAttribute('Subscribed') == "true") {
|
||||
stateStr = "false";
|
||||
state = false;
|
||||
}
|
||||
else {
|
||||
stateStr = "true";
|
||||
state = true;
|
||||
}
|
||||
|
||||
var uri = node.getAttribute('id');
|
||||
var name = node.getAttribute('name');
|
||||
SetState(uri, name, state, stateStr);
|
||||
}
|
||||
|
||||
function ReverseState(uri)
|
||||
{
|
||||
//dump("ReverseState("+uri+")\n");
|
||||
SetState(name, state);
|
||||
}
|
||||
|
||||
function SubscribeOnClick(event)
|
||||
|
@ -348,13 +319,13 @@ function SubscribeOnClick(event)
|
|||
if(open == "true") {
|
||||
var uri = treeitem.getAttribute("id");
|
||||
|
||||
dump("do twisty for " + uri + "\n");
|
||||
//dump("do twisty for " + uri + "\n");
|
||||
|
||||
gStatusFeedback.ShowProgress(0);
|
||||
gStatusFeedback.ShowStatusString(Bundle.GetStringFromName("pleaseWaitString"));
|
||||
gStatusBar.setAttribute("mode","undetermined");
|
||||
|
||||
gSubscribableServer.populateSubscribeDatasourceWithUri(msgWindow, true /* force to server */, uri);
|
||||
gSubscribableServer.startPopulatingWithUri(msgWindow, true /* force to server */, uri);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -366,7 +337,7 @@ function SubscribeOnClick(event)
|
|||
}
|
||||
}
|
||||
|
||||
function RefreshList()
|
||||
function Refresh()
|
||||
{
|
||||
// force it to talk to the server
|
||||
SetUpTree(true);
|
||||
|
@ -442,13 +413,60 @@ function selectNodeByName( aMatchString )
|
|||
lastLow = i;
|
||||
}
|
||||
else {
|
||||
gSubscribeTree.selectItem( currItem );
|
||||
gSubscribeTree.ensureElementIsVisible( currItem );
|
||||
return;
|
||||
SelectFirstMatch(lastLow, i, node.childNodes, aMatchString);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function SelectFirstMatch(startNode, endNode, nodes, matchStr)
|
||||
{
|
||||
// this code is to make sure we select the alphabetically first match
|
||||
// not just any match (see bug #60242)
|
||||
|
||||
// find the match, using a binary search.
|
||||
|
||||
var lastMatch = nodes[endNode];
|
||||
var totalItems = endNode - startNode;
|
||||
if (totalItems == 0) {
|
||||
gSubscribeTree.selectItem( lastMatch );
|
||||
gSubscribeTree.ensureElementIsVisible( lastMatch );
|
||||
return;
|
||||
}
|
||||
|
||||
var lastLow = startNode;
|
||||
var lastHigh = endNode;
|
||||
while (true) {
|
||||
var i = Math.floor((lastHigh + lastLow) / 2);
|
||||
//dump(i+","+lastLow+","+lastHigh+"\n");
|
||||
var currItem = nodes[i];
|
||||
var currValue = (currItem.getAttribute("name")).substring(0,matchStr.length);
|
||||
//dump(currValue+" vs "+matchStr+"\n");
|
||||
if (currValue > matchStr) {
|
||||
gSubscribeTree.selectItem( lastMatch );
|
||||
gSubscribeTree.ensureElementIsVisible( lastMatch );
|
||||
return;
|
||||
}
|
||||
else if (currValue < matchStr) {
|
||||
if (lastLow == i) {
|
||||
gSubscribeTree.selectItem( lastMatch );
|
||||
gSubscribeTree.ensureElementIsVisible( lastMatch );
|
||||
return;
|
||||
}
|
||||
lastLow = i;
|
||||
}
|
||||
else {
|
||||
lastMatch = currItem;
|
||||
if (lastHigh == i) {
|
||||
gSubscribeTree.selectItem( lastMatch );
|
||||
gSubscribeTree.ensureElementIsVisible( lastMatch );
|
||||
return;
|
||||
}
|
||||
lastHigh = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getTreechildren( aTreeNode )
|
||||
{
|
||||
if( aTreeNode.childNodes )
|
||||
|
|
|
@ -86,7 +86,7 @@ Rights Reserved.
|
|||
<row flex="1">
|
||||
<tree class="inset" flex="1"
|
||||
id="subscribetree"
|
||||
datasources="rdf:subscribe"
|
||||
datasources="rdf:null"
|
||||
onclick="SubscribeOnClick(event);">
|
||||
<template>
|
||||
<rule>
|
||||
|
@ -121,7 +121,8 @@ Rights Reserved.
|
|||
<box orient="vertical">
|
||||
<button id="subscribe" class="dialog" value="&subscribeButton.label;" oncommand="SetSubscribeState(true)"/>
|
||||
<button id="unsubscribe" class="dialog" value="&unsubscribeButton.label;" oncommand="SetSubscribeState(false)"/>
|
||||
<button id="refresh" class="dialog" value="&refreshButton.label;" oncommand="RefreshList()"/>
|
||||
<button id="refresh" class="dialog" value="&refreshButton.label;" oncommand="Refresh()"/>
|
||||
<button id="stop" class="dialog" value="&stopButton.label;" oncommand="Stop()"/>
|
||||
<spring flex="1"/>
|
||||
</box>
|
||||
</row>
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -24,11 +24,36 @@
|
|||
#ifndef nsSubscribableServer_h__
|
||||
#define nsSubscribableServer_h__
|
||||
|
||||
#include "nsISubscribableServer.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIRDFResource.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsISubscribableServer.h"
|
||||
#include "nsIMsgIncomingServer.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsSubscribeDataSource.h"
|
||||
#include "nsIRDFResource.h"
|
||||
|
||||
typedef struct _subscribeTreeNode {
|
||||
char *name;
|
||||
PRBool isSubscribed;
|
||||
struct _subscribeTreeNode *prevSibling;
|
||||
struct _subscribeTreeNode *nextSibling;
|
||||
struct _subscribeTreeNode *firstChild;
|
||||
struct _subscribeTreeNode *lastChild;
|
||||
struct _subscribeTreeNode *parent;
|
||||
struct _subscribeTreeNode *cachedChild;
|
||||
#ifdef HAVE_SUBSCRIBE_DESCRIPTION
|
||||
PRUnichar *description;
|
||||
#endif
|
||||
#ifdef HAVE_SUBSCRIBE_MESSAGES
|
||||
PRUint32 messages;
|
||||
#endif
|
||||
#ifdef HAVE_SUBSCRIBE_ISSUBSCRIBABLE
|
||||
PRBool isSubscribable;
|
||||
#endif
|
||||
} SubscribeTreeNode;
|
||||
|
||||
#if defined(DEBUG_sspitzer) || defined(DEBUG_seth)
|
||||
#define DEBUG_SUBSCRIBE 1
|
||||
#endif
|
||||
|
||||
class nsSubscribableServer : public nsISubscribableServer
|
||||
{
|
||||
|
@ -36,23 +61,38 @@ class nsSubscribableServer : public nsISubscribableServer
|
|||
nsSubscribableServer();
|
||||
virtual ~nsSubscribableServer();
|
||||
|
||||
nsresult Init();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISUBSCRIBABLESERVER
|
||||
|
||||
private:
|
||||
nsresult ConvertNameToUnichar(const char *inStr, PRUnichar **outStr);
|
||||
nsCOMPtr <nsISubscribeListener> mSubscribeListener;
|
||||
nsCOMPtr <nsIRDFDataSource> mSubscribeDatasource;
|
||||
nsCOMPtr <nsIRDFService> mRDFService;
|
||||
nsCOMPtr <nsIRDFResource> kNC_Name;
|
||||
nsCOMPtr <nsIRDFResource> kNC_LeafName;
|
||||
nsCOMPtr <nsIRDFResource> kNC_Child;
|
||||
nsCOMPtr <nsIRDFResource> kNC_Subscribed;
|
||||
nsCOMPtr <nsIRDFLiteral> kTrueLiteral;
|
||||
nsCOMPtr <nsIRDFLiteral> kFalseLiteral;
|
||||
nsCOMPtr <nsIMsgIncomingServer> mIncomingServer;
|
||||
nsCOMPtr <nsISubscribeDataSource> mSubscribeDS;
|
||||
char mDelimiter;
|
||||
PRBool mShowFullName;
|
||||
PRBool mStopped;
|
||||
|
||||
nsCOMPtr <nsIRDFResource> kNC_Child;
|
||||
nsCOMPtr <nsIRDFResource> kNC_Subscribed;
|
||||
nsCOMPtr <nsIRDFLiteral> kTrueLiteral;
|
||||
nsCOMPtr <nsIRDFLiteral> kFalseLiteral;
|
||||
|
||||
nsCOMPtr <nsIRDFService> mRDFService;
|
||||
|
||||
SubscribeTreeNode *mTreeRoot;
|
||||
nsresult FreeSubtree(SubscribeTreeNode *node);
|
||||
nsresult CreateNode(SubscribeTreeNode *parent, const char *name, SubscribeTreeNode **result);
|
||||
nsresult AddChildNode(SubscribeTreeNode *parent, const char *name, SubscribeTreeNode **child);
|
||||
nsresult FindAndCreateNode(const char *path, SubscribeTreeNode **result);
|
||||
nsresult NotifyAssert(SubscribeTreeNode *subjectNode, nsIRDFResource *property, SubscribeTreeNode *objectNode);
|
||||
nsresult NotifyChange(SubscribeTreeNode *subjectNode, nsIRDFResource *property, PRBool value);
|
||||
nsresult Notify(nsIRDFResource *subject, nsIRDFResource *property, nsIRDFNode *object, PRBool isAssert, PRBool isChange);
|
||||
void BuildURIFromNode(SubscribeTreeNode *node, nsCString &uri);
|
||||
nsresult EnsureSubscribeDS();
|
||||
nsresult EnsureRDFService();
|
||||
};
|
||||
|
||||
#endif // nsSubscribableServer_h__
|
||||
|
|
|
@ -26,10 +26,25 @@
|
|||
#include "nsIRDFService.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "rdf.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIMsgFolder.h"
|
||||
#include "nsIMsgIncomingServer.h"
|
||||
|
||||
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
// this is used for notification of observers using nsVoidArray
|
||||
typedef struct _nsSubscribeNotification {
|
||||
nsIRDFDataSource *datasource;
|
||||
nsIRDFResource *subject;
|
||||
nsIRDFResource *property;
|
||||
nsIRDFNode *object;
|
||||
} nsSubscribeNotification;
|
||||
|
||||
nsSubscribeDataSource::nsSubscribeDataSource()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
@ -37,21 +52,675 @@ nsSubscribeDataSource::nsSubscribeDataSource()
|
|||
|
||||
nsSubscribeDataSource::~nsSubscribeDataSource()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsSubscribeDataSource);
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsSubscribeDataSource);
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE1(nsSubscribeDataSource, nsIRDFDataSource)
|
||||
NS_IMPL_QUERY_INTERFACE2(nsSubscribeDataSource, nsIRDFDataSource, nsISubscribeDataSource)
|
||||
|
||||
nsresult
|
||||
nsSubscribeDataSource::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
mInner = do_CreateInstance(kRDFInMemoryDataSourceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
nsresult rv;
|
||||
|
||||
mRDFService = do_GetService(kRDFServiceCID, &rv);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv) && mRDFService, "failed to get rdf service");
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (!mRDFService) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = mRDFService->GetResource(NC_NAMESPACE_URI "child",getter_AddRefs(kNC_Child));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = mRDFService->GetResource(NC_NAMESPACE_URI "Name",getter_AddRefs(kNC_Name));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = mRDFService->GetResource(NC_NAMESPACE_URI "LeafName",getter_AddRefs(kNC_LeafName));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = mRDFService->GetResource(NC_NAMESPACE_URI "Subscribed",getter_AddRefs(kNC_Subscribed));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = mRDFService->GetLiteral(NS_ConvertASCIItoUCS2("true").GetUnicode(),getter_AddRefs(kTrueLiteral));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = mRDFService->GetLiteral(NS_ConvertASCIItoUCS2("false").GetUnicode(),getter_AddRefs(kFalseLiteral));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::GetURI(char * *aURI)
|
||||
{
|
||||
if ((*aURI = nsXPIDLCString::Copy("rdf:subscribe")) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::GetSource(nsIRDFResource *property, nsIRDFNode *target, PRBool tv, nsIRDFResource **source)
|
||||
{
|
||||
NS_PRECONDITION(property != nsnull, "null ptr");
|
||||
if (! property)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(target != nsnull, "null ptr");
|
||||
if (! target)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(source != nsnull, "null ptr");
|
||||
if (! source)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*source = nsnull;
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::GetTarget(nsIRDFResource *source,
|
||||
nsIRDFResource *property,
|
||||
PRBool tv,
|
||||
nsIRDFNode **target /* out */)
|
||||
{
|
||||
nsresult rv = NS_RDF_NO_VALUE;
|
||||
|
||||
NS_PRECONDITION(source != nsnull, "null ptr");
|
||||
if (! source)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(property != nsnull, "null ptr");
|
||||
if (! property)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(target != nsnull, "null ptr");
|
||||
if (! target)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*target = nsnull;
|
||||
|
||||
// we only have positive assertions in the subscribe data source.
|
||||
if (! tv) return NS_RDF_NO_VALUE;
|
||||
|
||||
nsCOMPtr<nsISubscribableServer> server;
|
||||
nsXPIDLCString relativePath;
|
||||
|
||||
rv = GetServerAndRelativePathFromResource(source, getter_AddRefs(server), getter_Copies(relativePath));
|
||||
if (NS_FAILED(rv) || !server) {
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
if (property == kNC_Name.get()) {
|
||||
nsCOMPtr<nsIRDFLiteral> name;
|
||||
rv = mRDFService->GetLiteral(NS_ConvertASCIItoUCS2((const char *)relativePath).GetUnicode(), getter_AddRefs(name));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (!name) rv = NS_RDF_NO_VALUE;
|
||||
if (rv == NS_RDF_NO_VALUE) return(rv);
|
||||
return name->QueryInterface(NS_GET_IID(nsIRDFNode), (void**) target);
|
||||
}
|
||||
else if (property == kNC_Child.get()) {
|
||||
nsXPIDLCString childUri;
|
||||
rv = server->GetFirstChildURI(relativePath, getter_Copies(childUri));
|
||||
if (NS_FAILED(rv)) return NS_RDF_NO_VALUE;
|
||||
if (!(const char *)childUri) return NS_RDF_NO_VALUE;
|
||||
|
||||
nsCOMPtr <nsIRDFResource> childResource;
|
||||
rv = mRDFService->GetResource((const char *)childUri, getter_AddRefs(childResource));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
return childResource->QueryInterface(NS_GET_IID(nsIRDFNode), (void**) target);
|
||||
}
|
||||
else if (property == kNC_Subscribed.get()) {
|
||||
PRBool isSubscribed;
|
||||
rv = server->IsSubscribed(relativePath, &isSubscribed);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (isSubscribed) {
|
||||
*target = kTrueLiteral;
|
||||
NS_IF_ADDREF(*target);
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
*target = kFalseLiteral;
|
||||
NS_IF_ADDREF(*target);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else if (property == kNC_LeafName.get()) {
|
||||
nsXPIDLString leafNameStr;
|
||||
rv = server->GetLeafName(relativePath, getter_Copies(leafNameStr));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> leafName;
|
||||
rv = mRDFService->GetLiteral(leafNameStr, getter_AddRefs(leafName));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (!leafName) rv = NS_RDF_NO_VALUE;
|
||||
if (rv == NS_RDF_NO_VALUE) return(rv);
|
||||
return leafName->QueryInterface(NS_GET_IID(nsIRDFNode), (void**) target);
|
||||
}
|
||||
else {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
return(NS_RDF_NO_VALUE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSubscribeDataSource::GetChildren(nsISubscribableServer *server, const char *relativePath, nsISimpleEnumerator** aResult)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_ASSERTION(server && aResult, "no server or result");
|
||||
if (!server || !aResult) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> children;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(children));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (!children) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = server->GetChildren(relativePath, children);
|
||||
// GetChildren() can fail if there are no children
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsISimpleEnumerator* result = new nsArrayEnumerator(children);
|
||||
if (!result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(result);
|
||||
*aResult = result;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::GetTargets(nsIRDFResource *source,
|
||||
nsIRDFResource *property,
|
||||
PRBool tv,
|
||||
nsISimpleEnumerator **targets /* out */)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_PRECONDITION(source != nsnull, "null ptr");
|
||||
if (! source)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(property != nsnull, "null ptr");
|
||||
if (! property)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(targets != nsnull, "null ptr");
|
||||
if (! targets)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*targets = nsnull;
|
||||
|
||||
// we only have positive assertions in the file system data source.
|
||||
if (!tv) return NS_RDF_NO_VALUE;
|
||||
|
||||
nsCOMPtr<nsISubscribableServer> server;
|
||||
nsXPIDLCString relativePath;
|
||||
|
||||
rv = GetServerAndRelativePathFromResource(source, getter_AddRefs(server), getter_Copies(relativePath));
|
||||
if (NS_FAILED(rv) || !server) {
|
||||
return NS_NewEmptyEnumerator(targets);
|
||||
}
|
||||
|
||||
if (property == kNC_Child.get()) {
|
||||
rv = GetChildren(server, relativePath, targets);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_NewEmptyEnumerator(targets);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
else if (property == kNC_LeafName.get()) {
|
||||
nsXPIDLString leafNameStr;
|
||||
rv = server->GetLeafName(relativePath, getter_Copies(leafNameStr));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> leafName;
|
||||
rv = mRDFService->GetLiteral(leafNameStr, getter_AddRefs(leafName));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsISimpleEnumerator* result = new nsSingletonEnumerator(leafName);
|
||||
if (!result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(result);
|
||||
*targets = result;
|
||||
return NS_OK;
|
||||
}
|
||||
else if (property == kNC_Subscribed.get()) {
|
||||
PRBool isSubscribed;
|
||||
rv = server->IsSubscribed(relativePath, &isSubscribed);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsISimpleEnumerator* result = nsnull;
|
||||
if (isSubscribed) {
|
||||
result = new nsSingletonEnumerator(kTrueLiteral);
|
||||
}
|
||||
else {
|
||||
result = new nsSingletonEnumerator(kFalseLiteral);
|
||||
}
|
||||
if (!result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(result);
|
||||
*targets = result;
|
||||
return NS_OK;
|
||||
}
|
||||
else if (property == kNC_Name.get()) {
|
||||
nsCOMPtr<nsIRDFLiteral> name;
|
||||
rv = mRDFService->GetLiteral(NS_ConvertASCIItoUCS2((const char *)relativePath).GetUnicode(), getter_AddRefs(name));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsISimpleEnumerator* result = new nsSingletonEnumerator(name);
|
||||
if (!result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(result);
|
||||
*targets = result;
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
return NS_NewEmptyEnumerator(targets);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::Assert(nsIRDFResource *source,
|
||||
nsIRDFResource *property,
|
||||
nsIRDFNode *target,
|
||||
PRBool tv)
|
||||
{
|
||||
return NS_RDF_ASSERTION_REJECTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::Unassert(nsIRDFResource *source,
|
||||
nsIRDFResource *property,
|
||||
nsIRDFNode *target)
|
||||
{
|
||||
return NS_RDF_ASSERTION_REJECTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::Change(nsIRDFResource* aSource,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFNode* aOldTarget,
|
||||
nsIRDFNode* aNewTarget)
|
||||
{
|
||||
return NS_RDF_ASSERTION_REJECTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::Move(nsIRDFResource* aOldSource,
|
||||
nsIRDFResource* aNewSource,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFNode* aTarget)
|
||||
{
|
||||
return NS_RDF_ASSERTION_REJECTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSubscribeDataSource::GetServerAndRelativePathFromResource(nsIRDFResource *source, nsISubscribableServer **server, char **relativePath)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
const char *sourceURI = nsnull;
|
||||
rv = source->GetValueConst(&sourceURI);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(source, &rv));
|
||||
// we expect this to fail sometimes, so don't assert
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!folder) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIMsgIncomingServer> incomingServer;
|
||||
rv = folder->GetServer(getter_AddRefs(incomingServer));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (!incomingServer) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = incomingServer->QueryInterface(NS_GET_IID(nsISubscribableServer), (void**)server);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (!*server) return NS_ERROR_FAILURE;
|
||||
|
||||
nsXPIDLCString serverURI;
|
||||
rv = incomingServer->GetServerURI(getter_Copies(serverURI));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
PRUint32 serverURILen = nsCRT::strlen((const char *)serverURI);
|
||||
if (serverURILen == nsCRT::strlen(sourceURI)) {
|
||||
*relativePath = nsnull;
|
||||
}
|
||||
else {
|
||||
*relativePath = nsCRT::strdup(sourceURI + serverURILen + 1);
|
||||
NS_ASSERTION(*relativePath,"no relative path");
|
||||
if (!*relativePath) return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::HasAssertion(nsIRDFResource *source,
|
||||
nsIRDFResource *property,
|
||||
nsIRDFNode *target,
|
||||
PRBool tv,
|
||||
PRBool *hasAssertion /* out */)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_PRECONDITION(source != nsnull, "null ptr");
|
||||
if (! source)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(property != nsnull, "null ptr");
|
||||
if (! property)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(target != nsnull, "null ptr");
|
||||
if (! target)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(hasAssertion != nsnull, "null ptr");
|
||||
if (! hasAssertion)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// we only have positive assertions in the file system data source.
|
||||
*hasAssertion = PR_FALSE;
|
||||
|
||||
if (!tv) return NS_OK;
|
||||
|
||||
nsCOMPtr<nsISubscribableServer> server;
|
||||
nsXPIDLCString relativePath;
|
||||
|
||||
rv = GetServerAndRelativePathFromResource(source, getter_AddRefs(server), getter_Copies(relativePath));
|
||||
if (NS_FAILED(rv) || !server) {
|
||||
*hasAssertion = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (property == kNC_Child.get()) {
|
||||
// not everything has children
|
||||
rv = server->HasChildren((const char *)relativePath, hasAssertion);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
else if (property == kNC_Name.get()) {
|
||||
// everything has a name
|
||||
*hasAssertion = PR_TRUE;
|
||||
}
|
||||
else if (property == kNC_LeafName.get()) {
|
||||
// everything has a leaf name
|
||||
*hasAssertion = PR_TRUE;
|
||||
}
|
||||
else if (property == kNC_Subscribed.get()) {
|
||||
// everything is subscribed or not
|
||||
*hasAssertion = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::HasArcOut(nsIRDFResource *source, nsIRDFResource *aArc, PRBool *result)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsISubscribableServer> server;
|
||||
nsXPIDLCString relativePath;
|
||||
|
||||
rv = GetServerAndRelativePathFromResource(source, getter_AddRefs(server), getter_Copies(relativePath));
|
||||
if (NS_FAILED(rv) || !server) {
|
||||
*result = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aArc == kNC_Child.get()) {
|
||||
PRBool hasChildren = PR_FALSE;
|
||||
rv = server->HasChildren((const char *)relativePath, &hasChildren);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
*result = hasChildren;
|
||||
return NS_OK;
|
||||
}
|
||||
else if ((aArc == kNC_Subscribed.get()) ||
|
||||
(aArc == kNC_LeafName.get()) ||
|
||||
(aArc == kNC_Name.get())) {
|
||||
*result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*result = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::ArcLabelsIn(nsIRDFNode *node,
|
||||
nsISimpleEnumerator ** labels /* out */)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::ArcLabelsOut(nsIRDFResource *source,
|
||||
nsISimpleEnumerator **labels /* out */)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_PRECONDITION(source != nsnull, "null ptr");
|
||||
if (! source)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(labels != nsnull, "null ptr");
|
||||
if (! labels)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsISubscribableServer> server;
|
||||
nsXPIDLCString relativePath;
|
||||
|
||||
rv = GetServerAndRelativePathFromResource(source, getter_AddRefs(server), getter_Copies(relativePath));
|
||||
if (NS_FAILED(rv) || !server) {
|
||||
return NS_NewEmptyEnumerator(labels);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsArray> array;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(array));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
array->AppendElement(kNC_Subscribed);
|
||||
array->AppendElement(kNC_Name);
|
||||
array->AppendElement(kNC_LeafName);
|
||||
|
||||
PRBool hasChildren = PR_FALSE;
|
||||
rv = server->HasChildren((const char *)relativePath, &hasChildren);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (hasChildren) {
|
||||
array->AppendElement(kNC_Child);
|
||||
}
|
||||
|
||||
nsISimpleEnumerator* result = new nsArrayEnumerator(array);
|
||||
if (! result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(result);
|
||||
*labels = result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::GetAllResources(nsISimpleEnumerator** aCursor)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("sorry!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::AddObserver(nsIRDFObserver *n)
|
||||
{
|
||||
NS_PRECONDITION(n != nsnull, "null ptr");
|
||||
if (! n)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (! mObservers)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(mObservers));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
mObservers->AppendElement(n);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::RemoveObserver(nsIRDFObserver *n)
|
||||
{
|
||||
NS_PRECONDITION(n != nsnull, "null ptr");
|
||||
if (! n)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (! mObservers)
|
||||
return NS_OK;
|
||||
|
||||
mObservers->RemoveElement(n);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::GetHasObservers(PRBool *hasObservers)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_ASSERTION(hasObservers, "null ptr");
|
||||
if (!hasObservers) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (!mObservers) {
|
||||
*hasObservers = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRUint32 count = 0;
|
||||
rv = mObservers->Count(&count);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
*hasObservers = (count > 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::GetAllCmds(nsIRDFResource* source,
|
||||
nsISimpleEnumerator/*<nsIRDFResource>*/** commands)
|
||||
{
|
||||
return(NS_NewEmptyEnumerator(commands));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aSources,
|
||||
nsIRDFResource* aCommand,
|
||||
nsISupportsArray/*<nsIRDFResource>*/* aArguments,
|
||||
PRBool* aResult)
|
||||
{
|
||||
return(NS_ERROR_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
|
||||
nsIRDFResource* aCommand,
|
||||
nsISupportsArray/*<nsIRDFResource>*/* aArguments)
|
||||
{
|
||||
return(NS_ERROR_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::GetSources(nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, nsISimpleEnumerator **_retval)
|
||||
{
|
||||
NS_ASSERTION(PR_FALSE, "Not implemented");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::GetAllCommands(nsIRDFResource *aSource, nsIEnumerator **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribeDataSource::NotifyObservers(nsIRDFResource *subject,
|
||||
nsIRDFResource *property,
|
||||
nsIRDFNode *object,
|
||||
PRBool assert, PRBool change)
|
||||
{
|
||||
NS_ASSERTION(!(change && assert),
|
||||
"Can't change and assert at the same time!\n");
|
||||
|
||||
if(mObservers)
|
||||
{
|
||||
nsSubscribeNotification note = { this, subject, property, object };
|
||||
if(change)
|
||||
mObservers->EnumerateForwards(changeEnumFunc, ¬e);
|
||||
else if (assert)
|
||||
mObservers->EnumerateForwards(assertEnumFunc, ¬e);
|
||||
else
|
||||
mObservers->EnumerateForwards(unassertEnumFunc, ¬e);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsSubscribeDataSource::changeEnumFunc(nsISupports *aElement, void *aData)
|
||||
{
|
||||
nsSubscribeNotification* note = (nsSubscribeNotification*)aData;
|
||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||
|
||||
observer->OnChange(note->datasource,
|
||||
note->subject,
|
||||
note->property,
|
||||
nsnull, note->object);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsSubscribeDataSource::assertEnumFunc(nsISupports *aElement, void *aData)
|
||||
{
|
||||
nsSubscribeNotification* note = (nsSubscribeNotification*)aData;
|
||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||
|
||||
observer->OnAssert(note->datasource,
|
||||
note->subject,
|
||||
note->property,
|
||||
note->object);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsSubscribeDataSource::unassertEnumFunc(nsISupports *aElement, void *aData)
|
||||
{
|
||||
nsSubscribeNotification* note = (nsSubscribeNotification*)aData;
|
||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||
|
||||
observer->OnUnassert(note->datasource,
|
||||
note->subject,
|
||||
note->property,
|
||||
note->object);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -24,13 +24,17 @@
|
|||
#ifndef nsSubscribeDataSource_h__
|
||||
#define nsSubscribeDataSource_h__
|
||||
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFResource.h"
|
||||
#include "nsIRDFLiteral.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISubscribableServer.h"
|
||||
|
||||
/**
|
||||
* The subscribe data source.
|
||||
*/
|
||||
class nsSubscribeDataSource : public nsIRDFDataSource
|
||||
class nsSubscribeDataSource : public nsIRDFDataSource, public nsISubscribeDataSource
|
||||
{
|
||||
|
||||
public:
|
||||
|
@ -40,10 +44,26 @@ public:
|
|||
nsresult Init();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_FORWARD_NSIRDFDATASOURCE(mInner->)
|
||||
NS_DECL_NSIRDFDATASOURCE
|
||||
NS_DECL_NSISUBSCRIBEDATASOURCE
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIRDFDataSource> mInner;
|
||||
nsCOMPtr <nsIRDFResource> kNC_Child;
|
||||
nsCOMPtr <nsIRDFResource> kNC_Name;
|
||||
nsCOMPtr <nsIRDFResource> kNC_LeafName;
|
||||
nsCOMPtr <nsIRDFResource> kNC_Subscribed;
|
||||
nsCOMPtr <nsIRDFLiteral> kTrueLiteral;
|
||||
nsCOMPtr <nsIRDFLiteral> kFalseLiteral;
|
||||
|
||||
nsCOMPtr <nsIRDFService> mRDFService;
|
||||
nsCOMPtr <nsISupportsArray> mObservers;
|
||||
|
||||
nsresult GetChildren(nsISubscribableServer *server, const char *relativePath, nsISimpleEnumerator** aResult);
|
||||
nsresult GetServerAndRelativePathFromResource(nsIRDFResource *source, nsISubscribableServer **server, char **relativePath);
|
||||
|
||||
static PRBool assertEnumFunc(nsISupports *aElement, void *aData);
|
||||
static PRBool unassertEnumFunc(nsISupports *aElement, void *aData);
|
||||
static PRBool changeEnumFunc(nsISupports *aElement, void *aData);
|
||||
};
|
||||
|
||||
#endif /* nsSubscribedDataSource_h__ */
|
||||
|
|
|
@ -50,7 +50,7 @@ nsMsgProtocol::nsMsgProtocol(nsIURI * aURL)
|
|||
|
||||
m_tempMsgFileSpec = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory);
|
||||
m_tempMsgFileSpec += "tempMessage.eml";
|
||||
mSupressListenerNotifications = PR_FALSE;
|
||||
mSuppressListenerNotifications = PR_FALSE;
|
||||
InitFromURI(aURL);
|
||||
}
|
||||
|
||||
|
@ -168,10 +168,10 @@ nsresult nsMsgProtocol::CloseSocket()
|
|||
* Returns a positive number for success, 0 for failure (not all the bytes were written to the
|
||||
* stream, etc). We need to make another pass through this file to install an error system (mscott)
|
||||
*
|
||||
* No logging is done in the base implementation, so aSupressLogging is ignored.
|
||||
* No logging is done in the base implementation, so aSuppressLogging is ignored.
|
||||
*/
|
||||
|
||||
PRInt32 nsMsgProtocol::SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSupressLogging)
|
||||
PRInt32 nsMsgProtocol::SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSuppressLogging)
|
||||
{
|
||||
PRUint32 writeCount = 0;
|
||||
PRInt32 status = 0;
|
||||
|
@ -208,7 +208,7 @@ NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIChannel * aChannel, nsISupports *
|
|||
// if we are set up as a channel, we should notify our channel listener that we are starting...
|
||||
// so pass in ourself as the channel and not the underlying socket or file channel the protocol
|
||||
// happens to be using
|
||||
if (!mSupressListenerNotifications && m_channelListener)
|
||||
if (!mSuppressListenerNotifications && m_channelListener)
|
||||
{
|
||||
if (!m_channelContext)
|
||||
m_channelContext = do_QueryInterface(ctxt);
|
||||
|
@ -226,7 +226,7 @@ NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports *c
|
|||
// if we are set up as a channel, we should notify our channel listener that we are starting...
|
||||
// so pass in ourself as the channel and not the underlying socket or file channel the protocol
|
||||
// happens to be using
|
||||
if (!mSupressListenerNotifications && m_channelListener)
|
||||
if (!mSuppressListenerNotifications && m_channelListener)
|
||||
rv = m_channelListener->OnStopRequest(this, m_channelContext, aStatus, aMsg);
|
||||
|
||||
nsCOMPtr <nsIMsgMailNewsUrl> msgUrl = do_QueryInterface(ctxt, &rv);
|
||||
|
|
|
@ -93,8 +93,8 @@ protected:
|
|||
// It also informs the transport layer that this data is now available for transmission.
|
||||
// Returns a positive number for success, 0 for failure (not all the bytes were written to the
|
||||
// stream, etc).
|
||||
// aSupressLogging is a hint that sensitive data is being sent and should not be logged
|
||||
virtual PRInt32 SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSupressLogging = PR_FALSE);
|
||||
// aSuppressLogging is a hint that sensitive data is being sent and should not be logged
|
||||
virtual PRInt32 SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSuppressLogging = PR_FALSE);
|
||||
|
||||
virtual nsresult PostMessage(nsIURI* url, nsIFileSpec * fileSpec);
|
||||
|
||||
|
@ -128,9 +128,9 @@ protected:
|
|||
// for a mailnews url.
|
||||
nsresult GetPromptDialogFromUrl(nsIMsgMailNewsUrl * aMsgUrl, nsIPrompt ** aPromptDialog);
|
||||
|
||||
// if a url isn't going to result in any content then we want to supress calls to
|
||||
// if a url isn't going to result in any content then we want to suppress calls to
|
||||
// OnStartRequest, OnDataAvailable and OnStopRequest
|
||||
PRBool mSupressListenerNotifications;
|
||||
PRBool mSuppressListenerNotifications;
|
||||
};
|
||||
|
||||
#endif /* nsMsgProtocol_h__ */
|
||||
|
|
|
@ -1115,11 +1115,11 @@ PRInt32 nsSmtpProtocol::SendRecipientResponse()
|
|||
}
|
||||
|
||||
|
||||
PRInt32 nsSmtpProtocol::SendData(nsIURI *url, const char *dataBuffer, PRBool aSupressLogging)
|
||||
PRInt32 nsSmtpProtocol::SendData(nsIURI *url, const char *dataBuffer, PRBool aSuppressLogging)
|
||||
{
|
||||
if (!url || !dataBuffer) return -1;
|
||||
|
||||
if (!aSupressLogging) {
|
||||
if (!aSuppressLogging) {
|
||||
PR_LOG(SMTPLogModule, PR_LOG_ALWAYS, ("SMTP Send: %s", dataBuffer));
|
||||
} else {
|
||||
PR_LOG(SMTPLogModule, PR_LOG_ALWAYS, ("Logging suppressed for this command (it probably contained authentication information)"));
|
||||
|
|
|
@ -112,7 +112,7 @@ public:
|
|||
virtual ~nsSmtpProtocol();
|
||||
|
||||
virtual nsresult LoadUrl(nsIURI * aURL, nsISupports * aConsumer = nsnull);
|
||||
virtual PRInt32 SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSupressLogging = PR_FALSE);
|
||||
virtual PRInt32 SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSuppressLogging = PR_FALSE);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// we suppport the nsIStreamListener interface
|
||||
|
|
|
@ -216,6 +216,6 @@ interface nsIImapService : nsISupports
|
|||
in nsIUrlListener aUrlListener);
|
||||
|
||||
|
||||
void buildSubscribeDatasource(in nsIImapIncomingServer aServer, in nsIMsgWindow aMsgWindow);
|
||||
void buildSubscribeDatasourceWithPath(in nsIImapIncomingServer aServer, in nsIMsgWindow aMsgWindow, in string folderPath);
|
||||
void getListOfFoldersOnServer(in nsIImapIncomingServer aServer, in nsIMsgWindow aMsgWindow);
|
||||
void getListOfFoldersWithPath(in nsIImapIncomingServer aServer, in nsIMsgWindow aMsgWindow, in string folderPath);
|
||||
};
|
||||
|
|
|
@ -105,6 +105,9 @@ nsImapIncomingServer::nsImapIncomingServer()
|
|||
|
||||
nsImapIncomingServer::~nsImapIncomingServer()
|
||||
{
|
||||
nsresult rv = ClearInner();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "ClearInner failed");
|
||||
|
||||
CloseCachedConnections();
|
||||
}
|
||||
|
||||
|
@ -902,7 +905,7 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath,
|
|||
if (!folderPath || !*folderPath) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (mDoingSubscribeDialog) {
|
||||
rv = AddToSubscribeDS(folderPath, mDoingLsub /* add as subscribed */, mDoingLsub /* change if exists */);
|
||||
rv = AddTo(folderPath, mDoingLsub /* add as subscribed */, mDoingLsub /* change if exists */);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -2131,60 +2134,109 @@ NS_IMETHODIMP nsImapIncomingServer::OnLogonRedirectionReply(const PRUnichar *pHo
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsImapIncomingServer::SetDelimiterFromHierarchyDelimiter()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIImapService> imapService = do_GetService(kImapServiceCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (!imapService) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIFolder> rootFolder;
|
||||
rv = GetRootFolder(getter_AddRefs(rootFolder));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIMsgImapMailFolder> rootMsgFolder = do_QueryInterface(rootFolder, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (!rootMsgFolder) return NS_ERROR_FAILURE;
|
||||
|
||||
PRUnichar delimiter = '/';
|
||||
rv = rootMsgFolder->GetHierarchyDelimiter(&delimiter);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
#ifdef DEBUG_seth
|
||||
printf("setting delimiter to %c\n",char(delimiter));
|
||||
#endif
|
||||
if (delimiter == kOnlineHierarchySeparatorUnknown) {
|
||||
delimiter = '/';
|
||||
#ifdef DEBUG_seth
|
||||
printf("..no, override delimiter to %c\n",char(delimiter));
|
||||
#endif
|
||||
}
|
||||
|
||||
rv = SetDelimiter(char(delimiter));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::PopulateSubscribeDatasourceWithUri(nsIMsgWindow *aMsgWindow, PRBool aForceToServer /*ignored*/, const char *uri)
|
||||
nsImapIncomingServer::StartPopulatingWithUri(nsIMsgWindow *aMsgWindow, PRBool aForceToServer /*ignored*/, const char *uri)
|
||||
{
|
||||
nsresult rv;
|
||||
#ifdef DEBUG_sspitzer
|
||||
printf("in PopulateSubscribeDatasourceWithUri(%s)\n",uri);
|
||||
printf("in StartPopulatingWithUri(%s)\n",uri);
|
||||
#endif
|
||||
mDoingSubscribeDialog = PR_TRUE;
|
||||
|
||||
// xxx todo can we do: rv = mInner->StartPopulatingSubscribeDS(); ?
|
||||
rv = StartPopulatingSubscribeDS();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mInner->StartPopulatingWithUri(aMsgWindow, aForceToServer, uri);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = SetDelimiterFromHierarchyDelimiter();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = SetShowFullName(PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsXPIDLCString serverUri;
|
||||
rv = GetServerURI(getter_Copies(serverUri));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIImapService> imapService = do_GetService(kImapServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (!imapService) return NS_ERROR_FAILURE;
|
||||
|
||||
nsXPIDLCString serverUri;
|
||||
rv = GetServerURI(getter_Copies(serverUri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
/*
|
||||
if uri = imap://user@host/foo/bar, the serverUri is imap://user@host
|
||||
to get path from uri, skip over imap://user@host + 1 (for the /)
|
||||
*/
|
||||
const char *path = uri + nsCRT::strlen((const char *)serverUri) + 1;
|
||||
|
||||
/*
|
||||
if uri = imap://user@host/foo/bar, the serverUri is imap://user@host
|
||||
to get path from uri, skip over imap://user@host + 1 (for the /)
|
||||
*/
|
||||
const char *path = uri + nsCRT::strlen((const char *)serverUri) + 1;
|
||||
#ifdef DEBUG_seth
|
||||
printf("path = %s\n",path);
|
||||
#endif
|
||||
|
||||
rv = imapService->BuildSubscribeDatasourceWithPath(this, aMsgWindow, path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = imapService->GetListOfFoldersWithPath(this, aMsgWindow, path);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::PopulateSubscribeDatasource(nsIMsgWindow *aMsgWindow, PRBool aForceToServer /*ignored*/)
|
||||
nsImapIncomingServer::StartPopulating(nsIMsgWindow *aMsgWindow, PRBool aForceToServer /*ignored*/)
|
||||
{
|
||||
nsresult rv;
|
||||
#ifdef DEBUG_sspitzer
|
||||
printf("in PopulateSubscribeDatasource()\n");
|
||||
printf("in StartPopulating()\n");
|
||||
#endif
|
||||
mDoingSubscribeDialog = PR_TRUE;
|
||||
|
||||
rv = StartPopulatingSubscribeDS();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mInner->StartPopulating(aMsgWindow, aForceToServer);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = SetDelimiterFromHierarchyDelimiter();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = SetShowFullName(PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIImapService> imapService = do_GetService(kImapServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (!imapService) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = imapService->BuildSubscribeDatasource(this, aMsgWindow);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = imapService->GetListOfFoldersOnServer(this, aMsgWindow);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2200,6 +2252,9 @@ nsImapIncomingServer::OnStopRunningUrl(nsIURI *url, nsresult exitCode)
|
|||
{
|
||||
nsresult rv = exitCode;
|
||||
|
||||
// xxx todo get msgWindow from url
|
||||
nsCOMPtr<nsIMsgWindow> msgWindow;
|
||||
|
||||
nsCOMPtr<nsIImapUrl> imapUrl = do_QueryInterface(url);
|
||||
if (imapUrl) {
|
||||
nsImapAction imapAction = nsIImapUrl::nsImapTest;
|
||||
|
@ -2207,10 +2262,11 @@ nsImapIncomingServer::OnStopRunningUrl(nsIURI *url, nsresult exitCode)
|
|||
switch (imapAction) {
|
||||
case nsIImapUrl::nsImapDiscoverAllAndSubscribedBoxesUrl:
|
||||
case nsIImapUrl::nsImapDiscoverChildrenUrl:
|
||||
rv = UpdateSubscribedInSubscribeDS();
|
||||
rv = UpdateSubscribed();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mDoingSubscribeDialog = PR_FALSE;
|
||||
rv = StopPopulatingSubscribeDS();
|
||||
rv = StopPopulating(msgWindow);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
break;
|
||||
case nsIImapUrl::nsImapDiscoverAllBoxesUrl:
|
||||
DiscoveryDone();
|
||||
|
@ -2226,37 +2282,45 @@ nsImapIncomingServer::OnStopRunningUrl(nsIURI *url, nsresult exitCode)
|
|||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::SetIncomingServer(nsIMsgIncomingServer *aServer)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->SetIncomingServer(aServer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::SetShowFullName(PRBool showFullName)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->SetShowFullName(showFullName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::GetDelimiter(char *aDelimiter)
|
||||
{
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->GetDelimiter(aDelimiter);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::SetDelimiter(char aDelimiter)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->SetDelimiter(aDelimiter);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::SetAsSubscribedInSubscribeDS(const char *aURI)
|
||||
nsImapIncomingServer::SetAsSubscribed(const char *path)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
return mInner->SetAsSubscribedInSubscribeDS(aURI);
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->SetAsSubscribed(path);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::UpdateSubscribedInSubscribeDS()
|
||||
nsImapIncomingServer::UpdateSubscribed()
|
||||
{
|
||||
#ifdef DEBUG_sspitzer
|
||||
printf("for imap, do this when we populate\n");
|
||||
|
@ -2265,32 +2329,15 @@ nsImapIncomingServer::UpdateSubscribedInSubscribeDS()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::AddToSubscribeDS(const char *aName, PRBool addAsSubscribed,PRBool changeIfExists)
|
||||
nsImapIncomingServer::AddTo(const char *aName, PRBool addAsSubscribed,PRBool changeIfExists)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
return mInner->AddToSubscribeDS(aName, addAsSubscribed, changeIfExists);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::SetPropertiesInSubscribeDS(const char *uri, const PRUnichar *aName, nsIRDFResource *aResource, PRBool subscribed, PRBool changeIfExists)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
return mInner->SetPropertiesInSubscribeDS(uri,aName,aResource,subscribed,changeIfExists);
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->AddTo(aName, addAsSubscribed, changeIfExists);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::FindAndAddParentToSubscribeDS(const char *uri, const char *serverUri, const char *aName, nsIRDFResource *aChildResource)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
return mInner->FindAndAddParentToSubscribeDS(uri,serverUri,aName,aChildResource);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::StopPopulatingSubscribeDS()
|
||||
nsImapIncomingServer::StopPopulating(nsIMsgWindow *aMsgWindow)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -2299,14 +2346,17 @@ nsImapIncomingServer::StopPopulatingSubscribeDS()
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
if (!listener) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = listener->OnStopPopulating();
|
||||
rv = listener->OnDonePopulating();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
rv = mInner->StopPopulatingSubscribeDS();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mInner->StopPopulating(aMsgWindow);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
//xxx todo when do I set this to null?
|
||||
//rv = ClearInner();
|
||||
//NS_ENSURE_SUCCESS(rv,rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2315,50 +2365,24 @@ NS_IMETHODIMP
|
|||
nsImapIncomingServer::SubscribeCleanup()
|
||||
{
|
||||
nsresult rv;
|
||||
if (mInner) {
|
||||
rv = mInner->SetSubscribeListener(nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mInner = nsnull;
|
||||
}
|
||||
rv = ClearInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::StartPopulatingSubscribeDS()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = SetIncomingServer(this);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetDelimiter('/'); // is this aways the case? need to talk to jefft
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetShowFullName(PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mInner->StartPopulatingSubscribeDS();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::SetSubscribeListener(nsISubscribeListener *aListener)
|
||||
{
|
||||
nsresult rv;
|
||||
mInner = do_CreateInstance(kSubscribableServerCID,&rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->SetSubscribeListener(aListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::GetSubscribeListener(nsISubscribeListener **aListener)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->GetSubscribeListener(aListener);
|
||||
}
|
||||
|
||||
|
@ -2436,3 +2460,92 @@ nsImapIncomingServer::ReDiscoverAllFolders()
|
|||
nsresult rv = PerformExpand(nsnull);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::SetState(const char *path, PRBool state, PRBool *stateChanged)
|
||||
{
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->SetState(path, state, stateChanged);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::HasChildren(const char *path, PRBool *aHasChildren)
|
||||
{
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->HasChildren(path, aHasChildren);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::IsSubscribed(const char *path, PRBool *aIsSubscribed)
|
||||
{
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->IsSubscribed(path, aIsSubscribed);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::GetLeafName(const char *path, PRUnichar **aLeafName)
|
||||
{
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->GetLeafName(path, aLeafName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::GetFirstChildURI(const char * path, char **aResult)
|
||||
{
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->GetFirstChildURI(path, aResult);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::GetChildren(const char *path, nsISupportsArray *array)
|
||||
{
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->GetChildren(path, array);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsImapIncomingServer::EnsureInner()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mInner) return NS_OK;
|
||||
|
||||
mInner = do_CreateInstance(kSubscribableServerCID,&rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = SetIncomingServer(this);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsImapIncomingServer::ClearInner()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mInner) {
|
||||
rv = mInner->SetSubscribeListener(nsnull);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = mInner->SetIncomingServer(nsnull);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
mInner = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::CommitSubscribeChanges()
|
||||
{
|
||||
return ReDiscoverAllFolders();
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ protected:
|
|||
|
||||
nsresult GetStringBundle();
|
||||
private:
|
||||
nsresult SetDelimiterFromHierarchyDelimiter();
|
||||
nsresult SubscribeToFolder(const PRUnichar *aName, PRBool subscribe);
|
||||
nsresult CreateImapConnection (nsIEventQueue* aEventQueue,
|
||||
nsIImapUrl* aImapUrl,
|
||||
|
@ -98,7 +99,10 @@ private:
|
|||
PRBool mDoingSubscribeDialog;
|
||||
PRBool mDoingLsub;
|
||||
nsresult AddFolderToSubscribeDialog(const char *parentUri, const char *uri,const char *folderName);
|
||||
|
||||
nsCOMPtr <nsISubscribableServer> mInner;
|
||||
nsresult EnsureInner();
|
||||
nsresult ClearInner();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1295,7 +1295,7 @@ NS_IMETHODIMP nsImapProtocol::GetRunningImapURL(nsIImapUrl **aImapUrl)
|
|||
* stream, etc). We need to make another pass through this file to install an error system (mscott)
|
||||
*/
|
||||
|
||||
nsresult nsImapProtocol::SendData(const char * dataBuffer, PRBool aSupressLogging)
|
||||
nsresult nsImapProtocol::SendData(const char * dataBuffer, PRBool aSuppressLogging)
|
||||
{
|
||||
PRUint32 writeCount = 0;
|
||||
nsresult rv = NS_ERROR_NULL_POINTER;
|
||||
|
@ -1305,7 +1305,7 @@ nsresult nsImapProtocol::SendData(const char * dataBuffer, PRBool aSupressLoggin
|
|||
if (dataBuffer && m_outputStream)
|
||||
{
|
||||
m_currentCommand = dataBuffer;
|
||||
if (!aSupressLogging)
|
||||
if (!aSuppressLogging)
|
||||
Log("SendData", nsnull, dataBuffer);
|
||||
else
|
||||
Log("SendData", nsnull, "Logging suppressed for this command (it probably contained authentication information)");
|
||||
|
@ -4325,13 +4325,19 @@ void nsImapProtocol::InsecureLogin(const char *userName, const char *password)
|
|||
// if the password contains a \, login will fail
|
||||
// turn foo\bar into foo\\bar
|
||||
nsCString correctedPassword;
|
||||
correctedPassword = password;
|
||||
correctedPassword.ReplaceSubstring("\\","\\\\");
|
||||
if (password) {
|
||||
PRUint32 i = 0;
|
||||
for (i=0;i<nsCRT::strlen(password);i++) {
|
||||
if (password[i] == '\\') {
|
||||
correctedPassword += '\\';
|
||||
}
|
||||
correctedPassword += password[i];
|
||||
}
|
||||
}
|
||||
command.Append((const char *)correctedPassword);
|
||||
|
||||
command.Append("\""CRLF);
|
||||
|
||||
nsresult rv = SendData(command.GetBuffer(), PR_TRUE /* supress logging */);
|
||||
nsresult rv = SendData(command.GetBuffer(), PR_TRUE /* suppress logging */);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
ParseIMAPandCheckForNewMail();
|
||||
|
@ -4418,7 +4424,7 @@ void nsImapProtocol::AuthLogin(const char *userName, const char *password, eIMAP
|
|||
{
|
||||
PR_snprintf(m_dataOutputBuf, OUTPUT_BUFFER_SIZE, "%s" CRLF, base64Str);
|
||||
PR_Free(base64Str);
|
||||
rv = SendData(m_dataOutputBuf, PR_TRUE /* supress logging */);
|
||||
rv = SendData(m_dataOutputBuf, PR_TRUE /* suppress logging */);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
ParseIMAPandCheckForNewMail(currentCommand);
|
||||
if (GetServerStateParser().LastCommandSuccessful())
|
||||
|
@ -4445,7 +4451,7 @@ void nsImapProtocol::AuthLogin(const char *userName, const char *password, eIMAP
|
|||
{
|
||||
PR_snprintf(m_dataOutputBuf, OUTPUT_BUFFER_SIZE, "%s" CRLF, base64Str);
|
||||
PR_Free(base64Str);
|
||||
rv = SendData(m_dataOutputBuf, PR_TRUE /* supress logging */);
|
||||
rv = SendData(m_dataOutputBuf, PR_TRUE /* suppress logging */);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
ParseIMAPandCheckForNewMail(currentCommand);
|
||||
}
|
||||
|
@ -4454,7 +4460,7 @@ void nsImapProtocol::AuthLogin(const char *userName, const char *password, eIMAP
|
|||
base64Str = PL_Base64Encode((char*)password, PL_strlen(password), nsnull);
|
||||
PR_snprintf(m_dataOutputBuf, OUTPUT_BUFFER_SIZE, "%s" CRLF, base64Str);
|
||||
PR_FREEIF(base64Str);
|
||||
rv = SendData(m_dataOutputBuf, PR_TRUE /* supress logging */);
|
||||
rv = SendData(m_dataOutputBuf, PR_TRUE /* suppress logging */);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
ParseIMAPandCheckForNewMail(currentCommand);
|
||||
if (GetServerStateParser().LastCommandSuccessful())
|
||||
|
|
|
@ -416,10 +416,10 @@ private:
|
|||
|
||||
// SendData not only writes the NULL terminated data in dataBuffer to our output stream
|
||||
// but it also informs the consumer that the data has been written to the stream.
|
||||
// aSupressLogging --> set to true if you wish to supress logging for this particular command.
|
||||
// aSuppressLogging --> set to true if you wish to suppress logging for this particular command.
|
||||
// this is useful for making sure we don't log authenication information like the user's password (which was
|
||||
// encoded anyway), but still we shouldn't add that information to the log.
|
||||
nsresult SendData(const char * dataBuffer, PRBool aSupressLogging = PR_FALSE);
|
||||
nsresult SendData(const char * dataBuffer, PRBool aSuppressLogging = PR_FALSE);
|
||||
|
||||
// state ported over from 4.5
|
||||
PRBool m_pseudoInterrupted;
|
||||
|
|
|
@ -2976,12 +2976,12 @@ nsImapService::GetDefaultCopiesAndFoldersPrefsToServer(PRBool *aDefaultCopiesAnd
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapService::BuildSubscribeDatasourceWithPath(nsIImapIncomingServer *aServer, nsIMsgWindow *aMsgWindow, const char *folderPath)
|
||||
nsImapService::GetListOfFoldersWithPath(nsIImapIncomingServer *aServer, nsIMsgWindow *aMsgWindow, const char *folderPath)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
#ifdef DEBUG_sspitzer
|
||||
printf("BuildSubscribeDatasourceWithPath(%s)\n",folderPath);
|
||||
printf("GetListOfFoldersWithPath(%s)\n",folderPath);
|
||||
#endif
|
||||
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(aServer);
|
||||
if (!server) return NS_ERROR_FAILURE;
|
||||
|
@ -3013,7 +3013,7 @@ nsImapService::BuildSubscribeDatasourceWithPath(nsIImapIncomingServer *aServer,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapService::BuildSubscribeDatasource(nsIImapIncomingServer *aServer, nsIMsgWindow *aMsgWindow)
|
||||
nsImapService::GetListOfFoldersOnServer(nsIImapIncomingServer *aServer, nsIMsgWindow *aMsgWindow)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
|
|
@ -707,7 +707,7 @@ nsresult nsPop3Protocol::LoadUrl(nsIURI* aURL, nsISupports * /* aConsumer */)
|
|||
{
|
||||
uidl += 5;
|
||||
m_pop3ConData->only_uidl = PL_strdup(uidl);
|
||||
mSupressListenerNotifications = PR_TRUE; // supress on start and on stop because this url won't have any content to display
|
||||
mSuppressListenerNotifications = PR_TRUE; // suppress on start and on stop because this url won't have any content to display
|
||||
}
|
||||
|
||||
// m_pop3ConData->next_state = POP3_READ_PASSWORD;
|
||||
|
@ -848,11 +848,11 @@ nsPop3Protocol::Error(PRInt32 err_code)
|
|||
return -1;
|
||||
}
|
||||
|
||||
PRInt32 nsPop3Protocol::SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSupressLogging)
|
||||
PRInt32 nsPop3Protocol::SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSuppressLogging)
|
||||
{
|
||||
PRInt32 result = nsMsgProtocol::SendData(aURL, dataBuffer);
|
||||
|
||||
if (!aSupressLogging) {
|
||||
if (!aSuppressLogging) {
|
||||
PR_LOG(POP3LOGMODULE, PR_LOG_ALWAYS, ("SEND: %s", dataBuffer));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -286,7 +286,7 @@ private:
|
|||
virtual nsresult ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream,
|
||||
PRUint32 sourceOffset, PRUint32 length);
|
||||
virtual nsresult CloseSocket();
|
||||
virtual PRInt32 SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSupressLogging = PR_FALSE);
|
||||
virtual PRInt32 SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSuppressLogging = PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIURI> m_url;
|
||||
nsCOMPtr<nsIPop3Sink> m_nsIPop3Sink;
|
||||
|
|
|
@ -73,6 +73,6 @@ interface nsINntpIncomingServer : nsISupports {
|
|||
void subscribeToNewsgroup(in string name);
|
||||
|
||||
/* used for the subscribe dialog */
|
||||
void addNewsgroupToSubscribeDS(in string name);
|
||||
void addNewsgroupToList(in string name);
|
||||
|
||||
};
|
||||
|
|
|
@ -42,7 +42,7 @@ interface nsINntpService : nsISupports {
|
|||
|
||||
nsIURI cancelMessages (in string hostname, in string newsgroupname, in nsISupportsArray messages, in nsISupports aConsumer, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow);
|
||||
|
||||
void buildSubscribeDatasource(in nsINntpIncomingServer nntpServer, in nsIMsgWindow aMsgWindow);
|
||||
void getListOfGroupsOnServer(in nsINntpIncomingServer nntpServer, in nsIMsgWindow aMsgWindow);
|
||||
|
||||
void updateCounts(in nsINntpIncomingServer nntpServer, in nsIMsgWindow aMsgWindow);
|
||||
};
|
||||
|
|
|
@ -1210,9 +1210,9 @@ nsresult nsNNTPProtocol::ParseURL(nsIURI * aURL, PRBool * bValP, char ** aGroup,
|
|||
* stream, etc). We need to make another pass through this file to install an error system (mscott)
|
||||
*/
|
||||
|
||||
PRInt32 nsNNTPProtocol::SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSupressLogging)
|
||||
PRInt32 nsNNTPProtocol::SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSuppressLogging)
|
||||
{
|
||||
if (!aSupressLogging) {
|
||||
if (!aSuppressLogging) {
|
||||
NNTP_LOG_WRITE(dataBuffer);
|
||||
}
|
||||
else {
|
||||
|
@ -2841,7 +2841,7 @@ PRInt32 nsNNTPProtocol::ProcessNewsgroups(nsIInputStream * inputStream, PRUint32
|
|||
#else
|
||||
NS_ASSERTION(m_nntpServer, "no nntp incoming server");
|
||||
if (m_nntpServer) {
|
||||
rv = m_nntpServer->AddNewsgroupToSubscribeDS(line);
|
||||
rv = m_nntpServer->AddNewsgroupToList(line);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to add to subscribe ds");
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
@ -2865,6 +2865,7 @@ PRInt32 nsNNTPProtocol::BeginReadNewsList()
|
|||
{
|
||||
m_readNewsListCount = 0;
|
||||
m_nextState = NNTP_READ_LIST;
|
||||
mBytesReceived = 0;
|
||||
PRInt32 status = 0;
|
||||
#ifdef UNREADY_CODE
|
||||
NET_Progress(ce->window_id, XP_GetString(XP_PROGRESS_RECEIVE_NEWSGROUP));
|
||||
|
@ -2974,7 +2975,8 @@ PRInt32 nsNNTPProtocol::ReadNewsList(nsIInputStream * inputStream, PRUint32 leng
|
|||
NS_ASSERTION(m_nntpServer, "no nntp incoming server");
|
||||
if (m_nntpServer) {
|
||||
m_readNewsListCount++;
|
||||
rv = m_nntpServer->AddNewsgroupToSubscribeDS(line);
|
||||
rv = m_nntpServer->AddNewsgroupToList(line);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to add to subscribe ds");
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
@ -4422,7 +4424,7 @@ PRInt32 nsNNTPProtocol::ListXActiveResponse(nsIInputStream * inputStream, PRUint
|
|||
#else
|
||||
NS_ASSERTION(m_nntpServer, "no nntp incoming server");
|
||||
if (m_nntpServer) {
|
||||
rv = m_nntpServer->AddNewsgroupToSubscribeDS(line);
|
||||
rv = m_nntpServer->AddNewsgroupToList(line);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to add to subscribe ds");
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
|
|
@ -179,7 +179,7 @@ private:
|
|||
|
||||
// we have our own implementation of SendData which writes to the nntp log
|
||||
// and then calls the base class to transmit the data
|
||||
PRInt32 SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSupressLogging = PR_FALSE);
|
||||
PRInt32 SendData(nsIURI * aURL, const char * dataBuffer, PRBool aSuppressLogging = PR_FALSE);
|
||||
|
||||
nsresult CleanupAfterRunningUrl();
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsINntpService.h"
|
||||
#include "nsINNTPProtocol.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsMsgNewsCID.h"
|
||||
#include "nsNNTPProtocol.h"
|
||||
#include "nsIDirectoryService.h"
|
||||
|
@ -44,6 +43,8 @@
|
|||
#define PREF_MAIL_NEWSRC_ROOT "mail.newsrc_root"
|
||||
#define HOSTINFO_FILE_NAME "hostinfo.dat"
|
||||
|
||||
#define NEWS_DELIMITER '.'
|
||||
|
||||
#define HOSTINFO_COUNT_MAX 200 /* number of groups to process at a time when reading the list from the hostinfo.dat file */
|
||||
#define HOSTINFO_TIMEOUT 5 /* uSec to wait until doing more */
|
||||
|
||||
|
@ -63,7 +64,6 @@
|
|||
#define HOSTINFO_FILE_BUFFER_SIZE 1024
|
||||
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kNntpServiceCID, NS_NNTPSERVICE_CID);
|
||||
static NS_DEFINE_CID(kSubscribableServerCID, NS_SUBSCRIBABLESERVER_CID);
|
||||
|
||||
|
@ -100,20 +100,23 @@ nsNntpIncomingServer::~nsNntpIncomingServer()
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
if (mGroupsEnumerator) {
|
||||
delete mGroupsEnumerator;
|
||||
mGroupsEnumerator = nsnull;
|
||||
}
|
||||
|
||||
if (mUpdateTimer) {
|
||||
mUpdateTimer->Cancel();
|
||||
mUpdateTimer = nsnull;
|
||||
if (mGroupsEnumerator) {
|
||||
delete mGroupsEnumerator;
|
||||
mGroupsEnumerator = nsnull;
|
||||
}
|
||||
if (mNewsrcSaveTimer)
|
||||
{
|
||||
mNewsrcSaveTimer->Cancel();
|
||||
mNewsrcSaveTimer = nsnull;
|
||||
}
|
||||
|
||||
if (mUpdateTimer) {
|
||||
mUpdateTimer->Cancel();
|
||||
mUpdateTimer = nsnull;
|
||||
}
|
||||
|
||||
if (mNewsrcSaveTimer) {
|
||||
mNewsrcSaveTimer->Cancel();
|
||||
mNewsrcSaveTimer = nsnull;
|
||||
}
|
||||
|
||||
rv = ClearInner();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "ClearInner failed");
|
||||
|
||||
rv = CloseCachedConnections();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "CloseCachedConnections failed");
|
||||
|
@ -691,10 +694,10 @@ NS_IMETHODIMP
|
|||
nsNntpIncomingServer::OnStopRunningUrl(nsIURI *url, nsresult exitCode)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = UpdateSubscribedInSubscribeDS();
|
||||
rv = UpdateSubscribed();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = StopPopulatingSubscribeDS();
|
||||
rv = StopPopulating(mMsgWindow);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -851,26 +854,25 @@ nsNntpIncomingServer::LoadHostInfoFile()
|
|||
}
|
||||
|
||||
hostinfoStream.close();
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("LoadHostInfoFile()\n");
|
||||
#endif
|
||||
|
||||
mHostInfoLoaded = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNntpIncomingServer::PopulateSubscribeDatasourceFromHostInfo()
|
||||
nsNntpIncomingServer::StartPopulatingFromHostInfo()
|
||||
{
|
||||
nsresult rv;
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("PopulateSubscribeDatasourceFromHostInfo()\n");
|
||||
printf("StartPopulatingFromHostInfo()\n");
|
||||
#endif
|
||||
|
||||
mGroupsOnServerCount = mGroupsOnServer.Count();
|
||||
nsCString currentGroup;
|
||||
|
||||
while (mGroupsOnServerIndex < mGroupsOnServerCount) {
|
||||
mGroupsOnServer.CStringAt(mGroupsOnServerIndex, currentGroup);
|
||||
rv = AddToSubscribeDS((const char *)currentGroup, PR_FALSE, PR_TRUE);
|
||||
rv = AddTo((const char *)currentGroup, PR_FALSE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("%d = %s\n",mGroupsOnServerIndex,(const char *)currentGroup);
|
||||
|
@ -918,10 +920,10 @@ nsNntpIncomingServer::PopulateSubscribeDatasourceFromHostInfo()
|
|||
#ifdef DEBUG_NEWS
|
||||
printf("we are done\n");
|
||||
#endif
|
||||
rv = UpdateSubscribedInSubscribeDS();
|
||||
rv = UpdateSubscribed();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = StopPopulatingSubscribeDS();
|
||||
rv = StopPopulating(mMsgWindow);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
@ -933,19 +935,24 @@ nsNntpIncomingServer::Notify(nsITimer *timer)
|
|||
{
|
||||
NS_ASSERTION(timer == mUpdateTimer.get(), "Hey, this ain't my timer!");
|
||||
mUpdateTimer = nsnull; // release my hold
|
||||
PopulateSubscribeDatasourceFromHostInfo();
|
||||
StartPopulatingFromHostInfo();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::PopulateSubscribeDatasourceWithUri(nsIMsgWindow *aMsgWindow, PRBool aForceToServer, const char *uri)
|
||||
nsNntpIncomingServer::StartPopulatingWithUri(nsIMsgWindow *aMsgWindow, PRBool aForceToServer, const char *uri)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("PopulateSubscribeDatasourceWithUri(%s)\n",uri);
|
||||
#ifdef DEBUG_seth
|
||||
printf("StartPopulatingWithUri(%s)\n",uri);
|
||||
#endif
|
||||
|
||||
rv = StopPopulatingSubscribeDS();
|
||||
rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mInner->StartPopulatingWithUri(aMsgWindow, aForceToServer, uri);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = StopPopulating(mMsgWindow);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -954,22 +961,26 @@ nsNntpIncomingServer::PopulateSubscribeDatasourceWithUri(nsIMsgWindow *aMsgWindo
|
|||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::SubscribeCleanup()
|
||||
{
|
||||
nsresult rv;
|
||||
if (mInner) {
|
||||
rv = mInner->SetSubscribeListener(nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mInner = nsnull;
|
||||
}
|
||||
nsresult rv = NS_OK;
|
||||
rv = ClearInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::PopulateSubscribeDatasource(nsIMsgWindow *aMsgWindow, PRBool aForceToServer)
|
||||
nsNntpIncomingServer::StartPopulating(nsIMsgWindow *aMsgWindow, PRBool aForceToServer)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
rv = StartPopulatingSubscribeDS();
|
||||
rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mInner->StartPopulating(aMsgWindow, aForceToServer);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = SetDelimiter(NEWS_DELIMITER);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetShowFullName(PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsINntpService> nntpService = do_GetService(kNntpServiceCID, &rv);
|
||||
|
@ -991,7 +1002,7 @@ nsNntpIncomingServer::PopulateSubscribeDatasource(nsIMsgWindow *aMsgWindow, PRBo
|
|||
mGroupsOnServerCount = mGroupsOnServer.Count();
|
||||
mMsgWindow = aMsgWindow;
|
||||
|
||||
rv = PopulateSubscribeDatasourceFromHostInfo();
|
||||
rv = StartPopulatingFromHostInfo();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
|
@ -1001,7 +1012,7 @@ nsNntpIncomingServer::PopulateSubscribeDatasource(nsIMsgWindow *aMsgWindow, PRBo
|
|||
mHostInfoLoaded = PR_TRUE;
|
||||
mGroupsOnServer.Clear();
|
||||
|
||||
rv = nntpService->BuildSubscribeDatasource(this, aMsgWindow);
|
||||
rv = nntpService->GetListOfGroupsOnServer(this, aMsgWindow);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
@ -1009,14 +1020,14 @@ nsNntpIncomingServer::PopulateSubscribeDatasource(nsIMsgWindow *aMsgWindow, PRBo
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::AddNewsgroupToSubscribeDS(const char *aName)
|
||||
nsNntpIncomingServer::AddNewsgroupToList(const char *aName)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// since this comes from the server, append it to the list
|
||||
mGroupsOnServer.AppendCString(nsCAutoString(aName));
|
||||
|
||||
rv = AddToSubscribeDS(aName, PR_FALSE, PR_TRUE);
|
||||
rv = AddTo(aName, PR_FALSE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1024,156 +1035,148 @@ nsNntpIncomingServer::AddNewsgroupToSubscribeDS(const char *aName)
|
|||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::SetIncomingServer(nsIMsgIncomingServer *aServer)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->SetIncomingServer(aServer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::SetShowFullName(PRBool showFullName)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->SetShowFullName(showFullName);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNntpIncomingServer::ClearInner()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mInner) {
|
||||
rv = mInner->SetSubscribeListener(nsnull);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = mInner->SetIncomingServer(nsnull);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
mInner = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNntpIncomingServer::EnsureInner()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mInner) return NS_OK;
|
||||
|
||||
mInner = do_CreateInstance(kSubscribableServerCID,&rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = SetIncomingServer(this);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::GetDelimiter(char *aDelimiter)
|
||||
{
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->GetDelimiter(aDelimiter);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::SetDelimiter(char aDelimiter)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->SetDelimiter(aDelimiter);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::SetAsSubscribedInSubscribeDS(const char *aURI)
|
||||
nsNntpIncomingServer::SetAsSubscribed(const char *path)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
return mInner->SetAsSubscribedInSubscribeDS(aURI);
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->SetAsSubscribed(path);
|
||||
}
|
||||
|
||||
PRBool
|
||||
setAsSubscribedFunction(nsCString &aElement, void *aData)
|
||||
{
|
||||
nsresult rv;
|
||||
nsNntpIncomingServer *server;
|
||||
server = (nsNntpIncomingServer *)aData;
|
||||
|
||||
nsXPIDLCString serverURI;
|
||||
|
||||
nsCOMPtr<nsIFolder> rootFolder;
|
||||
rv = server->GetRootFolder(getter_AddRefs(rootFolder));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!rootFolder) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = rootFolder->GetURI(getter_Copies(serverURI));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCAutoString uriStr;
|
||||
uriStr = (const char*)serverURI;
|
||||
uriStr += '/';
|
||||
uriStr += (const char *)aElement;
|
||||
|
||||
rv = server->SetAsSubscribedInSubscribeDS((const char *)uriStr);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"SetAsSubscribedInSubscribeDS failed");
|
||||
nsresult rv = NS_OK;
|
||||
nsNntpIncomingServer *server;
|
||||
server = (nsNntpIncomingServer *)aData;
|
||||
NS_ASSERTION(server, "no server");
|
||||
if (!server) {
|
||||
// todo is this correct?
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
rv = server->SetAsSubscribed((const char *)aElement);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"SetAsSubscribed failed");
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::UpdateSubscribedInSubscribeDS()
|
||||
nsNntpIncomingServer::UpdateSubscribed()
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
mSubscribedNewsgroups.EnumerateForwards((nsCStringArrayEnumFunc)setAsSubscribedFunction, (void *)this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::AddToSubscribeDS(const char *aName, PRBool addAsSubscribed, PRBool changeIfExists)
|
||||
nsNntpIncomingServer::AddTo(const char *aName, PRBool addAsSubscribed, PRBool changeIfExists)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
return mInner->AddToSubscribeDS(aName,addAsSubscribed,changeIfExists);
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->AddTo(aName,addAsSubscribed,changeIfExists);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::SetPropertiesInSubscribeDS(const char *uri, const PRUnichar *aName, nsIRDFResource *aResource, PRBool subscribed, PRBool changeIfExists)
|
||||
nsNntpIncomingServer::StopPopulating(nsIMsgWindow *aMsgWindow)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
return mInner->SetPropertiesInSubscribeDS(uri,aName,aResource,subscribed,changeIfExists);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::FindAndAddParentToSubscribeDS(const char *uri, const char *serverUri, const char *aName, nsIRDFResource *aChildResource)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
return mInner->FindAndAddParentToSubscribeDS(uri,serverUri,aName,aChildResource);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::StopPopulatingSubscribeDS()
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsISubscribeListener> listener;
|
||||
rv = GetSubscribeListener(getter_AddRefs(listener));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (!listener) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = listener->OnStopPopulating();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = listener->OnDonePopulating();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
rv = mInner->StopPopulatingSubscribeDS();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mInner->StopPopulating(aMsgWindow);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
//xxx todo when do I set this to null?
|
||||
//mInner = nsnull;
|
||||
//rv = ClearInner();
|
||||
//NS_ENSURE_SUCCESS(rv,rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::StartPopulatingSubscribeDS()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = SetIncomingServer(this);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetDelimiter('.');
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetShowFullName(PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mInner->StartPopulatingSubscribeDS();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::SetSubscribeListener(nsISubscribeListener *aListener)
|
||||
{
|
||||
nsresult rv;
|
||||
mInner = do_CreateInstance(kSubscribableServerCID,&rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->SetSubscribeListener(aListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::GetSubscribeListener(nsISubscribeListener **aListener)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->GetSubscribeListener(aListener);
|
||||
}
|
||||
|
||||
|
@ -1277,3 +1280,61 @@ nsNntpIncomingServer::RemoveNewsgroup(const char *name)
|
|||
mSubscribedNewsgroups.RemoveCString(nsCAutoString(name));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::SetState(const char *path, PRBool state, PRBool *stateChanged)
|
||||
{
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->SetState(path, state, stateChanged);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::HasChildren(const char *path, PRBool *aHasChildren)
|
||||
{
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->HasChildren(path, aHasChildren);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::IsSubscribed(const char *path, PRBool *aIsSubscribed)
|
||||
{
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->IsSubscribed(path, aIsSubscribed);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::GetLeafName(const char *path, PRUnichar **aLeafName)
|
||||
{
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->GetLeafName(path, aLeafName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::GetFirstChildURI(const char * path, char **aResult)
|
||||
{
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->GetFirstChildURI(path, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::GetChildren(const char *path, nsISupportsArray *array)
|
||||
{
|
||||
nsresult rv = EnsureInner();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return mInner->GetChildren(path, array);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::CommitSubscribeChanges()
|
||||
{
|
||||
nsresult rv;
|
||||
rv = SetNewsrcHasChanged(PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
return WriteNewsrcFile();
|
||||
}
|
||||
|
|
|
@ -81,8 +81,8 @@ protected:
|
|||
nsCOMPtr<nsISupportsArray> m_connectionCache;
|
||||
NS_IMETHOD GetServerRequiresPasswordForBiff(PRBool *_retval);
|
||||
nsByteArray mHostInfoInputStream;
|
||||
nsresult SetupNewsrcSaveTimer();
|
||||
static void OnNewsrcSaveTimer(nsITimer *timer, void *voidIncomingServer);
|
||||
nsresult SetupNewsrcSaveTimer();
|
||||
static void OnNewsrcSaveTimer(nsITimer *timer, void *voidIncomingServer);
|
||||
|
||||
private:
|
||||
PRInt32 mGroupsOnServerIndex;
|
||||
|
@ -93,13 +93,12 @@ private:
|
|||
PRBool mHasSeenBeginGroups;
|
||||
nsresult WriteHostInfoFile();
|
||||
nsresult LoadHostInfoFile();
|
||||
nsresult PopulateSubscribeDatasourceFromHostInfo();
|
||||
nsresult StartPopulatingFromHostInfo();
|
||||
|
||||
PRBool mNewsrcHasChanged;
|
||||
nsAdapterEnumerator *mGroupsEnumerator;
|
||||
PRBool mHostInfoLoaded;
|
||||
PRBool mHostInfoHasChanged;
|
||||
nsCOMPtr <nsISubscribableServer> mInner;
|
||||
nsCOMPtr <nsIFileSpec> mHostInfoFile;
|
||||
|
||||
PRUint32 mLastGroupDate;
|
||||
|
@ -108,9 +107,13 @@ private:
|
|||
PRBool mPushAuth;
|
||||
PRInt32 mVersion;
|
||||
|
||||
nsCOMPtr<nsITimer> mNewsrcSaveTimer;
|
||||
nsCOMPtr<nsITimer> mNewsrcSaveTimer;
|
||||
nsCOMPtr <nsITimer> mUpdateTimer;
|
||||
nsCOMPtr <nsIMsgWindow> mMsgWindow;
|
||||
|
||||
nsCOMPtr <nsISubscribableServer> mInner;
|
||||
nsresult EnsureInner();
|
||||
nsresult ClearInner();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1421,11 +1421,11 @@ nsNntpService::UpdateCounts(nsINntpIncomingServer *aNntpServer, nsIMsgWindow *aM
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpService::BuildSubscribeDatasource(nsINntpIncomingServer *aNntpServer, nsIMsgWindow *aMsgWindow)
|
||||
nsNntpService::GetListOfGroupsOnServer(nsINntpIncomingServer *aNntpServer, nsIMsgWindow *aMsgWindow)
|
||||
{
|
||||
nsresult rv;
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("in BuildSubscribeDatasource()\n");
|
||||
printf("in GetListOfGroupsOnServer()\n");
|
||||
#endif
|
||||
if (!aNntpServer) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче