KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > zirc > msg > MSGmode


1 package zirc.msg ;
2
3 import zirc.base.* ;
4 import zirc.gui.* ;
5 import zirc.threads.* ;
6
7 //zIrc, irc client.
8
// Copyright (C) 2004 CoolBytes(Stephane claret, Andre Aymon, Alban Zumofen) coolbytes@hotmail.com
9
//
10
// This program is free software; you can redistribute it and/or
11
// modify it under the terms of the GNU General Public License
12
// as published by the Free Software Foundation; either version 2
13
// of the License, or (at your option) any later version.
14
//
15
// This program is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU General Public License for more details.
19

20 /**
21  * <p>Title: MSGmode</p>
22  * <p>Description: traite le message MODE</p>
23  * <p>Copyright: Copyright (c) 2004</p>
24  * <p>Company: CoolBytes(Stephane Claret, Andre Aymon, Alban Zumofen) coolbytes@hotmail.com</p>
25  * @version 1.0
26  */

27
28 public class MSGmode extends AbstractMessage
29 {
30
31   private String JavaDoc tokens[] = new String JavaDoc[5] ;
32   private IRCconnexion IRCchan ;
33
34   public MSGmode(IRCconnexion _IRCchan, Object JavaDoc _tk1, Object JavaDoc _tk2, Object JavaDoc _tk3, Object JavaDoc _tk4, Object JavaDoc _tk5)
35   {
36     super(_IRCchan, _tk1 + " " + _tk2 + " " + _tk3 + " " + _tk4 + " " + _tk5) ;
37     IRCchan = _IRCchan ;
38     tokens[0] = (String JavaDoc)(_tk1) ;
39     tokens[1] = (String JavaDoc)(_tk2) ;
40     tokens[2] = (String JavaDoc)(_tk3) ;
41     tokens[3] = (String JavaDoc)(_tk4) ;
42     tokens[4] = (String JavaDoc)(_tk5) ;
43
44     //
45
//fenetre cible dans lequel le message sera affiché
46
//
47
if (tokens[2].startsWith("#"))
48     {
49       ChatFrame cht = _IRCchan.GetFenetreDuChan(tokens[2]) ;
50       if (cht != null)
51       {
52         this.frm = cht ;
53       }
54     }
55   }
56
57   protected void setColor(StringBuffer JavaDoc _htmlMsg)
58   {
59     _htmlMsg.insert(0, "<font color=" + vectColors[1] + ">") ;
60     _htmlMsg.append("</font>") ;
61   }
62
63   //parser le message
64
public String JavaDoc parseMessagePourAffichage(String JavaDoc _txtAffiche)
65   {
66     //
67
//ATTENTION : deux types de message:
68
//
69
//:Aphrodite!services@olympe.epiknet.org MODE #chan +ao
70
//:zuzutest!lol2-a35d5@F7B40898.62F969ED.26210312.IP MODE #zuzutest -o azuu
71
//:zuzu MODE zuzu :+x
72
///MODE #zuzutest +o azuu//user
73
//MODE #zuzutest2 +p //chan
74

75     try
76     {
77       tokens[4].length() ;
78     }
79     catch (NullPointerException JavaDoc ex)
80     {
81       tokens[4] = "" ;
82     }
83     finally
84     {
85       String JavaDoc initiateur ;
86       int ind = tokens[0].indexOf("!") ;
87
88       if (ind > -1)
89       {
90         //message type 1
91
initiateur = tokens[0].substring(1, ind) ;
92       }
93       else
94       {
95         initiateur = tokens[0].substring(1) ;
96       }
97
98       if (tokens[4].length() == 0)
99       {
100         return "* " + initiateur + " met le mode: " + tokens[3] + " " + tokens[2] ;
101       }
102       else
103       {
104         IRCchan.sendCommand("NAMES "+tokens[2]);
105         return "* " + initiateur + " met le mode: " + tokens[3] + " " + tokens[4] ;
106       }
107     }
108   }
109
110   protected boolean informeUser()
111   {
112     return false ;
113   }
114
115 }
116
Popular Tags