зеркало из https://github.com/mozilla/gecko-dev.git
more changes for the new subscribe dialog. not turned on yet.
This commit is contained in:
Родитель
e065b12714
Коммит
872492417a
|
@ -3,38 +3,19 @@ var gCurrentServer = null;
|
||||||
var okCallback = null;
|
var okCallback = null;
|
||||||
var gChangeTable = {};
|
var gChangeTable = {};
|
||||||
var gServerURI = null;
|
var gServerURI = null;
|
||||||
|
var RDF = null;
|
||||||
|
var SubscribeDS = null;
|
||||||
|
var gCurrentServerURI = null;
|
||||||
|
|
||||||
function AddItem(children,cells)
|
function SetUpTree()
|
||||||
{
|
{
|
||||||
var kids = document.getElementById(children);
|
var nntpService = Components.classes['component://netscape/messenger/nntpservice'].getService(Components.interfaces.nsINntpService);
|
||||||
var item = document.createElement("treeitem");
|
nntpService = nntpService.QueryInterface(Components.interfaces.nsINntpService);
|
||||||
var row = document.createElement("treerow");
|
nntpService.buildSubscribeDatasource(gCurrentServer);
|
||||||
|
|
||||||
for(var i = 0; i < cells.length; i++) {
|
gCurrentServerURI = "news://" + gCurrentServer.hostName;
|
||||||
var cell = document.createElement("treecell");
|
dump("root subscribe tree at: "+gCurrentServerURI+"\n");
|
||||||
cell.setAttribute("value", cells[i])
|
gSubscribeTree.setAttribute('ref',gCurrentServerURI);
|
||||||
cell.setAttribute("id", cells[0] + "#" + i)
|
|
||||||
row.appendChild(cell);
|
|
||||||
}
|
|
||||||
|
|
||||||
item.appendChild(row);
|
|
||||||
item.setAttribute("id",cells[0]);
|
|
||||||
kids.appendChild(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
var SubscribeDialogListener = {
|
|
||||||
AddItem: function(name, subscribed, count) {
|
|
||||||
dump(name + "," + subscribed + "," + count + "\n");
|
|
||||||
AddItem("folders",[name,subscribed,count]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function SetUpTree(server)
|
|
||||||
{
|
|
||||||
dump("SetUpTree("+ server.hostname + ")\n");
|
|
||||||
|
|
||||||
var master = server.QueryInterface(Components.interfaces.nsISubscribeDialogMaster);
|
|
||||||
master.populateSubscribeDialog(SubscribeDialogListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function SubscribeOnLoad()
|
function SubscribeOnLoad()
|
||||||
|
@ -42,7 +23,6 @@ function SubscribeOnLoad()
|
||||||
dump("SubscribeOnLoad()\n");
|
dump("SubscribeOnLoad()\n");
|
||||||
|
|
||||||
gSubscribeTree = document.getElementById('subscribetree');
|
gSubscribeTree = document.getElementById('subscribetree');
|
||||||
gCurrentServer = document.getElementById('currentserver');
|
|
||||||
|
|
||||||
doSetOKCancel(subscribeOK,subscribeCancel);
|
doSetOKCancel(subscribeOK,subscribeCancel);
|
||||||
|
|
||||||
|
@ -57,33 +37,17 @@ function SubscribeOnLoad()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pre select the folderPicker, based on what they selected in the folder pane
|
|
||||||
if (window.arguments[0].preselectedURI) {
|
if (window.arguments[0].preselectedURI) {
|
||||||
gServerURI = window.arguments[0].preselectedURI;
|
gServerURI = window.arguments[0].preselectedURI;
|
||||||
var folder = GetMsgFolderFromUri(window.arguments[0].preselectedURI);
|
folder = GetMsgFolderFromUri(window.arguments[0].preselectedURI);
|
||||||
var server = folder.server;
|
gCurrentServer = folder.server;
|
||||||
|
|
||||||
gCurrentServer.value = server.hostName; // use gServer.prettyName?
|
SetUpTree();
|
||||||
|
|
||||||
SetUpTree(server);
|
RDF = Components.classes["component://netscape/rdf/rdf-service"].getService();
|
||||||
|
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
|
||||||
|
|
||||||
dump("for each child of " + server.hostName + " set subscribed to true in the datasource\n");
|
SubscribeDS = RDF.GetDataSource("rdf:subscribe");
|
||||||
|
|
||||||
var folders = folder.GetSubFolders();
|
|
||||||
|
|
||||||
if (folders) {
|
|
||||||
try {
|
|
||||||
while (true) {
|
|
||||||
var i = folders.currentItem();
|
|
||||||
var f = i.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
||||||
SetState(f.name, null, 'true');
|
|
||||||
folders.next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ex) {
|
|
||||||
dump("no more subfolders\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,18 +66,20 @@ function subscribeCancel()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetState(uri, element, state)
|
function SetState(uri, state)
|
||||||
{
|
{
|
||||||
var subCell = element;
|
dump("SetState(" + uri +"," + state + ")\n");
|
||||||
dump("SetState: " + uri + "," + element + "," + state + "\n");
|
if (!uri || !state) return;
|
||||||
|
|
||||||
if (!subCell) {
|
try {
|
||||||
subCell = document.getElementById(uri + "#1");
|
var src = RDF.GetResource(uri, true);
|
||||||
dump("subCell =" + subCell + "\n");
|
var prop = RDF.GetResource("http://home.netscape.com/NC-rdf#Subscribed", true);
|
||||||
|
var oldLiteral = SubscribeDS.GetTarget(src, prop, true);
|
||||||
|
var newLiteral = RDF.GetLiteral(state);
|
||||||
|
SubscribeDS.Change(src, prop, oldLiteral, newLiteral);
|
||||||
}
|
}
|
||||||
|
catch (ex) {
|
||||||
if (subCell) {
|
dump("failed: " + ex + "\n");
|
||||||
subCell.setAttribute("value",state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +101,9 @@ function StateChanged(uri,state)
|
||||||
|
|
||||||
function SetSubscribeState(state)
|
function SetSubscribeState(state)
|
||||||
{
|
{
|
||||||
|
dump("SetSubscribedState()\n");
|
||||||
|
|
||||||
|
try {
|
||||||
dump("subscribe button clicked\n");
|
dump("subscribe button clicked\n");
|
||||||
|
|
||||||
var groupList = gSubscribeTree.selectedItems;
|
var groupList = gSubscribeTree.selectedItems;
|
||||||
|
@ -142,13 +111,14 @@ function SetSubscribeState(state)
|
||||||
group = groupList[i];
|
group = groupList[i];
|
||||||
uri = group.getAttribute('id');
|
uri = group.getAttribute('id');
|
||||||
dump(uri + "\n");
|
dump(uri + "\n");
|
||||||
|
SetState(uri, state);
|
||||||
var cells = group.getElementsByAttribute("id",uri + "#1");
|
|
||||||
dump("cell=" + cells[0] + "\n");
|
|
||||||
SetState(uri, cells[0], state);
|
|
||||||
StateChanged(uri,state);
|
StateChanged(uri,state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (ex) {
|
||||||
|
dump("SetSubscribedState failed: " + ex + "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function SubscribeOnClick(event)
|
function SubscribeOnClick(event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,7 @@ Rights Reserved.
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
xmlns:NC="http://home.netscape.com/NC-rdf#"
|
xmlns:NC="http://home.netscape.com/NC-rdf#"
|
||||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
align="vertical"
|
orient="vertical"
|
||||||
class="dialog"
|
class="dialog"
|
||||||
height="300"
|
height="300"
|
||||||
width="600"
|
width="600"
|
||||||
|
@ -43,26 +43,60 @@ Rights Reserved.
|
||||||
|
|
||||||
<keyset id="keyset"/>
|
<keyset id="keyset"/>
|
||||||
|
|
||||||
<box align="horizontal" flex="100%">
|
<box orient="horizontal" flex="100%">
|
||||||
<box align="vertical" flex="100%">
|
<box orient="vertical" flex="100%">
|
||||||
<box align="horizontal" flex="100%">
|
<box orient="horizontal" flex="100%">
|
||||||
<html:div>&server.label;</html:div>
|
<text class="label" value="&server.label;" for="currentserver"/>
|
||||||
<titledbutton id="currentserver" value="..."/>
|
<menulist id="currentserver" value="...">
|
||||||
|
<menupopup>
|
||||||
|
<menuitem value="news.mozilla.org" uri="news://news.mozilla.org" />
|
||||||
|
<menuitem value="news.fresmeat.net" uri="news://news.freshmeant.net" />
|
||||||
|
<menuitem value="news.mcom.com" uri="news://news.mcom.com" />
|
||||||
|
<!--
|
||||||
|
<menupopup datasources="rdf:msgaccountmanager" ref="msgaccounts:/">
|
||||||
|
<template>
|
||||||
|
<rule>
|
||||||
|
<menuitem value="..."/>
|
||||||
|
</rule>
|
||||||
|
</template>
|
||||||
|
-->
|
||||||
|
</menupopup>
|
||||||
|
</menulist>
|
||||||
</box>
|
</box>
|
||||||
<box align="horizontal" flex="100%">
|
<box orient="horizontal" flex="100%">
|
||||||
<html:div>&folders.label;</html:div>
|
<text class="label" value="&folders.label;" for="name"/>
|
||||||
<html:input tabindex="0" type="text" id="name"
|
<textfield id="name"/>
|
||||||
style="width:100%"/>
|
|
||||||
</box>
|
</box>
|
||||||
</box>
|
</box>
|
||||||
</box>
|
</box>
|
||||||
<box align="horizontal" flex="100%">
|
<box orient="horizontal" flex="100%">
|
||||||
<box align="vertical" flex="100%">
|
<box orient="vertical" flex="100%">
|
||||||
|
|
||||||
<tree style="width:100px;" flex="100%"
|
<tree style="width:100px;" flex="100%"
|
||||||
class="inset"
|
class="inset"
|
||||||
id="subscribetree"
|
id="subscribetree"
|
||||||
|
datasources="rdf:subscribe"
|
||||||
onclick="SubscribeOnClick(event);">
|
onclick="SubscribeOnClick(event);">
|
||||||
|
<template>
|
||||||
|
<rule>
|
||||||
|
<treechildren>
|
||||||
|
<treeitem uri="...">
|
||||||
|
<treerow>
|
||||||
|
<treecell value="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||||
|
<treecell value="rdf:http://home.netscape.com/NC-rdf#Subscribed"/>
|
||||||
|
<treecell value="rdf:http://home.netscape.com/NC-rdf#Count"/>
|
||||||
|
</treerow>
|
||||||
|
</treeitem>
|
||||||
|
</treechildren>
|
||||||
|
</rule>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<treecolgroup id="theSubscribeColumns">
|
||||||
|
<treecol width="8*" id="NameColumn" rdf:resource="http://home.netscape.com/NC-rdf#Name"/>
|
||||||
|
<treecol width="1*" id="SubscribedColumn" rdf:resource="http://home.netscape.com/NC-rdf#Subscribed"/>
|
||||||
|
<treecol width="1*" id="CountColumn" rdf:resource="http://home.netscape.com/NC-rdf#Count"/>
|
||||||
|
</treecolgroup>
|
||||||
|
|
||||||
<treehead>
|
<treehead>
|
||||||
<treerow id="headRow">
|
<treerow id="headRow">
|
||||||
<treecell value="&foldersHeader.label;" />
|
<treecell value="&foldersHeader.label;" />
|
||||||
|
@ -70,13 +104,10 @@ Rights Reserved.
|
||||||
<treecell value="&messagesHeader.label;"/>
|
<treecell value="&messagesHeader.label;"/>
|
||||||
</treerow>
|
</treerow>
|
||||||
</treehead>
|
</treehead>
|
||||||
<treechildren>
|
|
||||||
<treeitem id="folders"/>
|
|
||||||
</treechildren>
|
|
||||||
</tree>
|
</tree>
|
||||||
|
|
||||||
</box>
|
</box>
|
||||||
<box align="vertical" flex="20%">
|
<box orient="vertical" flex="20%">
|
||||||
<spring flex="100%"/>
|
<spring flex="100%"/>
|
||||||
<titledbutton id="subscribe" class="push" value="&subscribeButton.label;" onclick="SetSubscribeState('true')"/>
|
<titledbutton id="subscribe" class="push" value="&subscribeButton.label;" onclick="SetSubscribeState('true')"/>
|
||||||
<titledbutton id="unsubscribe" class="push" value="&unsubscribeButton.label;" onclick="SetSubscribeState('false')"/>
|
<titledbutton id="unsubscribe" class="push" value="&unsubscribeButton.label;" onclick="SetSubscribeState('false')"/>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче