Revision 3952,
1.6 KB
checked in by alexandrecorreia, 14 years ago
(diff) |
Ticket #1710 - Adicao do codigo fonte java do componente jmessenger(jabberit_messenger)
|
-
Property svn:executable set to
*
|
Line | |
---|
1 | package nu.fw.jeti.jabber.elements; |
---|
2 | |
---|
3 | /** |
---|
4 | * @author E.S. de Boer |
---|
5 | */ |
---|
6 | |
---|
7 | public class PresenceBuilder extends PacketBuilder |
---|
8 | { |
---|
9 | public String showAsString; |
---|
10 | public int show; |
---|
11 | public String status; |
---|
12 | public String priorityAsString; |
---|
13 | public int priority; |
---|
14 | public String type; |
---|
15 | |
---|
16 | public PresenceBuilder() |
---|
17 | { |
---|
18 | reset(); |
---|
19 | } |
---|
20 | |
---|
21 | public void reset() |
---|
22 | { |
---|
23 | super.reset(); |
---|
24 | show = Integer.MAX_VALUE; |
---|
25 | showAsString = null; |
---|
26 | status=null; |
---|
27 | priorityAsString=null; |
---|
28 | priority = 0; |
---|
29 | } |
---|
30 | |
---|
31 | public Packet build() throws InstantiationException |
---|
32 | { |
---|
33 | //if(priority < -128 || priority >127) throw new InstantiationException("priority out of bounds (-128, 127"); |
---|
34 | if(priority==0) |
---|
35 | { |
---|
36 | try{ |
---|
37 | priority =Integer.parseInt(priorityAsString); |
---|
38 | }catch (NumberFormatException e){priority=0;} |
---|
39 | } |
---|
40 | if(type==null) type = "available"; |
---|
41 | else |
---|
42 | { |
---|
43 | if(!(type.equals("unavailable") || |
---|
44 | type.equals("subscribe")|| |
---|
45 | type.equals("subscribed")|| |
---|
46 | type.equals("unsubscribe")|| |
---|
47 | type.equals("unsubscribed")|| |
---|
48 | type.equals("probe")|| |
---|
49 | type.equals("error"))) |
---|
50 | type ="available"; |
---|
51 | } |
---|
52 | if(type.equals("unavailable")) show = Presence.UNAVAILABLE; |
---|
53 | else if(show == Integer.MAX_VALUE) |
---|
54 | { |
---|
55 | if("away".equals(showAsString)) show = Presence.AWAY; |
---|
56 | else if("dnd".equals(showAsString)) show = Presence.DND; |
---|
57 | else if("xa".equals(showAsString)) show = Presence.XA; |
---|
58 | else if("chat".equals(showAsString)) show = Presence.FREE_FOR_CHAT; |
---|
59 | else |
---|
60 | { |
---|
61 | if (type.equals("available")) show = Presence.AVAILABLE; |
---|
62 | else show = Presence.UNAVAILABLE; |
---|
63 | } |
---|
64 | } |
---|
65 | return new Presence(this); |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | /* |
---|
70 | * Overrides for emacs |
---|
71 | * Local variables: |
---|
72 | * tab-width: 4 |
---|
73 | * End: |
---|
74 | */ |
---|
Note: See
TracBrowser
for help on using the repository browser.