summaryrefslogtreecommitdiffstats
path: root/kjsembed/docs/examples/dcop/rss.js
blob: f42e7915fea203e000e38e01c346edcbf02b173a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env kjscmd

function newArticles( articles )
{

	var box = new TQVBox(main);
	var count = articles.call("count()");
	var label = new TQLabel(box);
	var list = new TDEListBox(box);


	label.text = count + " articles for " + articles.call("title()");
	for( var idx = 0; idx < count; ++idx)
	{
		var article = articles.call("article(int)", idx);
		list.insertItem( article.call( "title()" ));
	}
	box.show();
	return true;
}

var main = new TQHBox(this)
var dcop = new DCOPInterface(this, "news");
dcop.publish("void newArticles(DCOPRef)");

var client = new DCOPClient(this);
var feeds = client.call( "rssservice", "RSSService", "list()" );

for( var idx = 0; idx < feeds.length; ++idx)
{
	var doc = client.call( "rssservice", "RSSService", "add(TQString)", feeds[idx] );
	client.connectDCOPSignal("rssservice", doc.obj(), "documentUpdated(DCOPRef)",
			"news","newArticles(DCOPRef)");
	doc.call("refresh()");
}
main.show();

application.exec();