0
|
1 package nabble.view.web.template;
|
|
2
|
|
3 import java.util.List;
|
|
4 import java.util.ArrayList;
|
|
5 import java.util.Map;
|
|
6 import nabble.model.Node;
|
|
7 import nabble.model.Subscription;
|
|
8 import nabble.model.User;
|
|
9 import nabble.naml.compiler.Command;
|
|
10 import nabble.naml.compiler.CommandSpec;
|
|
11 import nabble.naml.compiler.Interpreter;
|
|
12 import nabble.naml.compiler.IPrintWriter;
|
|
13 import nabble.naml.compiler.Namespace;
|
|
14 import nabble.naml.compiler.ScopedInterpreter;
|
|
15
|
|
16
|
|
17 @Namespace (
|
|
18 name = "instant_mail",
|
|
19 global = true
|
|
20 )
|
|
21 public final class InstantMailNamespace {
|
|
22 private final Node node;
|
|
23 private final Map<User,Subscription> subscriptionMap;
|
|
24
|
|
25 public InstantMailNamespace(Node node,Map<User,Subscription> subscriptionMap) {
|
|
26 this.node = node;
|
|
27 this.subscriptionMap = subscriptionMap;
|
|
28 }
|
|
29
|
|
30 public static final CommandSpec new_node = CommandSpec.DO;
|
|
31
|
|
32 @Command public void new_node(IPrintWriter out,ScopedInterpreter<NodeNamespace> interp) {
|
|
33 NodeNamespace nodeNs = new NodeNamespace(node);
|
|
34 out.print( interp.getArg(nodeNs,"do") );
|
|
35 }
|
|
36
|
|
37 public static final CommandSpec remove_from_instant_mail = CommandSpec.NO_OUTPUT()
|
|
38 .dotParameter("user")
|
|
39 .build()
|
|
40 ;
|
|
41
|
|
42 @Command public void remove_from_instant_mail(IPrintWriter out,Interpreter interp) {
|
|
43 UserNamespace ns = interp.getArgAsNamespace(UserNamespace.class,"user");
|
|
44 subscriptionMap.remove(ns.user());
|
|
45 }
|
|
46
|
|
47 public static final CommandSpec subscription_list = CommandSpec.DO;
|
|
48
|
|
49 @Command public void subscription_list(IPrintWriter out,ScopedInterpreter<SubscriptionNamespace.SubscriptionList> interp) {
|
|
50 List<Subscription> list = new ArrayList<Subscription>(subscriptionMap.values());
|
|
51 out.print( interp.getArg(new SubscriptionNamespace.SubscriptionList(list),"do") );
|
|
52 }
|
|
53
|
|
54 }
|