This commit is contained in:
sspitzer%netscape.com 2000-03-28 04:03:25 +00:00
Родитель 4054cc5f8f
Коммит c3c8228dc7
4 изменённых файлов: 128 добавлений и 45 удалений

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

@ -0,0 +1,30 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Seth Spitzer <sspitzer@netscape.com>
*/
#include "nsISupports.idl"
[scriptable, uuid(5022d2b6-1dd2-11b2-917b-e88201dcfc0d)]
interface nsISubscribeDialogListener: nsISupports {
void AddItem(in wstring name, in boolean subscribed, in long count);
};

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

@ -0,0 +1,31 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Seth Spitzer <sspitzer@netscape.com>
*/
#include "nsISupports.idl"
interface nsISubscribeDialogListener;
[scriptable, uuid(75d31250-1dd2-11b2-906c-e1de3ecf633f)]
interface nsISubscribeDialogMaster: nsISupports {
void populateSubscribeDialog(in nsISubscribeDialogListener listener);
};

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

@ -1,15 +1,46 @@
var gSubscribeTree = null;
var gCurrentServer = null;
var okCallback = null;
var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService(Components.interfaces.nsIRDFService);
var datasource = rdf.GetDataSource('rdf:newshostinfo');
var gChangeTable = {};
var gServerURI = null;
function AddItem(children,cells)
{
var kids = document.getElementById(children);
var item = document.createElement("treeitem");
var row = document.createElement("treerow");
for(var i = 0; i < cells.length; i++) {
var cell = document.createElement("treecell");
cell.setAttribute("value", cells[i])
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()
{
dump("SubscribeOnLoad()\n");
gSubscribeTree = document.getElementById('subscribetree');
gCurrentServer = document.getElementById('currentserver');
@ -32,10 +63,11 @@ function SubscribeOnLoad()
var folder = GetMsgFolderFromUri(window.arguments[0].preselectedURI);
var server = folder.server;
gSubscribeTree.setAttribute('ref','urn:' + server.hostName);
gCurrentServer.value = server.hostName; // use gServer.prettyName?
dump("for each child of news://" + server.hostName + " set subscribed to true in the datasource\n");
SetUpTree(server);
dump("for each child of " + server.hostName + " set subscribed to true in the datasource\n");
var folders = folder.GetSubFolders();
@ -44,11 +76,7 @@ function SubscribeOnLoad()
while (true) {
var i = folders.currentItem();
var f = i.QueryInterface(Components.interfaces.nsIMsgFolder);
dump(f.URI+ "\n");
dump(f.name + "\n");
dump('urn:' + f.name + "\n");
SetState('urn:' + f.name, 'true');
SetState(f.name, null, 'true');
folders.next();
}
}
@ -74,31 +102,24 @@ function subscribeCancel()
return true;
}
function SetState(uri, state)
function SetState(uri, element, state)
{
var group = rdf.GetResource(uri);
dump(group + "\n");
var subCell = element;
dump("SetState: " + uri + "," + element + "," + state + "\n");
if (!subCell) {
subCell = document.getElementById(uri + "#1");
dump("subCell =" + subCell + "\n");
}
var prop = rdf.GetResource("http://home.netscape.com/NC-rdf#subscribed", true);
var target = datasource.GetTarget(group, prop, true);
dump(target + "\n");
if (target) {
var targetValue = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
//dump(targetValue + "\n");
if (targetValue) {
targetValue = targetValue.Value;
dump(targetValue + "\n");
if (targetValue) {
var newLiteral = rdf.GetLiteral(state);
var newTarget = newLiteral.QueryInterface(Components.interfaces.nsIRDFNode);
datasource.Change(group,prop,target,newTarget);
}
}
if (subCell) {
subCell.setAttribute("value",state);
}
}
function StateChanged(uri,state)
{
dump("StateChanged(" + uri + "," + state + ")\n");
if (!gChangeTable[uri]) {
gChangeTable[uri] = 0;
}
@ -121,7 +142,10 @@ function SetSubscribeState(state)
group = groupList[i];
uri = group.getAttribute('id');
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);
}
}
@ -131,3 +155,8 @@ function SubscribeOnClick(event)
dump("subscribe tree clicked\n");
dump(event.target.parentNode.parentNode.getAttribute("id") + "\n");
}
function RefreshList()
{
dump("refresh list\n");
}

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

@ -33,6 +33,8 @@ Rights Reserved.
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
align="vertical"
class="dialog"
height="300"
width="600"
onload="SubscribeOnLoad()"
style="padding:10px">
@ -48,7 +50,7 @@ Rights Reserved.
<titledbutton id="currentserver" value="..."/>
</box>
<box align="horizontal" flex="100%">
<html:div>&newsgroup.label;</html:div>
<html:div>&folders.label;</html:div>
<html:input tabindex="0" type="text" id="name"
style="width:100%"/>
</box>
@ -60,27 +62,17 @@ Rights Reserved.
<tree style="width:100px;" flex="100%"
class="inset"
id="subscribetree"
datasources="rdf:newshostinfo"
onclick="SubscribeOnClick(event);">
<template>
<rule>
<treechildren>
<treeitem uri="...">
<treerow>
<treecell indent="true" value="rdf:http://home.netscape.com/NC-rdf#Name"/>
<treecell indent="true" value="rdf:http://home.netscape.com/NC-rdf#subscribed"/>
</treerow>
</treeitem>
</treechildren>
</rule>
</template>
<treehead>
<treerow id="headRow">
<treecell value="&newsgroupHeader.label;"/>
<treecell value="&foldersHeader.label;"/>
<treecell value="&subscribedHeader.label;"/>
<treecell value="&messagesHeader.label;"/>
</treerow>
</treehead>
<treechildren>
<treeitem id="folders"/>
</treechildren>
</tree>
</box>
@ -88,6 +80,7 @@ Rights Reserved.
<spring flex="100%"/>
<titledbutton id="subscribe" class="push" value="&subscribeButton.label;" onclick="SetSubscribeState('true')"/>
<titledbutton id="unsubscribe" class="push" value="&unsubscribeButton.label;" onclick="SetSubscribeState('false')"/>
<titledbutton id="refresh" class="push" value="&refreshButton.label;" onclick="RefreshList()"/>
<spring flex="100%"/>
</box>
</box>