KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > zirc > msg > MSGkick


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: MSGkick</p>
22  * <p>Description: </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
29 public class MSGkick extends AbstractMessage
30 {
31   private String JavaDoc tokens[] = new String JavaDoc[5] ;
32   private IRCconnexion IRCchan ;
33
34   public MSGkick(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
//si c nous
48
if (tokens[3].substring(0, tokens[3].length()).equals(IRCchan.GetUser_nickName()))
49     {
50       ChatFrame frm = IRCchan.GetFenetreDuChan(tokens[2]) ;
51       frm.destroyForKick() ;
52     }
53
54     else
55     {
56       if ((tokens[2].startsWith("#")))
57       {
58         ChatFrame cht = _IRCchan.GetFenetreDuChan(tokens[2]) ;
59         if (cht != null)
60         {
61           this.frm = cht ;
62         }
63       }
64     }
65
66   }
67
68   protected void setColor(StringBuffer JavaDoc _htmlMsg)
69   {
70     _htmlMsg.insert(0, "<font color=" + vectColors[4] + ">") ;
71     _htmlMsg.append("</font>") ;
72   }
73
74   //parser le message
75
public String JavaDoc parseMessagePourAffichage(String JavaDoc _txtAffiche)
76   {
77     //
78
//ATTENTION : deux types de message:
79
//
80
//:zumzum!~azuu@CB243DF0.CEE497DF.CA7F87DF.IP KICK #zuzutest azuu :pignoufle
81
//:zumzum!~azuu@CB243DF0.CEE497DF.CA7F87DF.IP KICK #zuzutest azuu :zumzum
82

83     String JavaDoc initiateur ;
84     int ind = tokens[0].indexOf("!") ;
85
86     if (ind > -1)
87     {
88       //message type 1
89
initiateur = tokens[0].substring(1, ind) ;
90     }
91     else
92     {
93       initiateur = tokens[0].substring(1) ;
94     }
95
96     //si c nous on formate le message differemment
97
if (tokens[3].substring(0, tokens[3].length()).equals(IRCchan.GetUser_nickName()))
98     {
99       return "* " + initiateur + " vous a kicke " + tokens[4] ;
100     }
101     else
102     {
103       IRCchan.ajouteTache(new KickUserThread(IRCchan, tokens[2], tokens[3])) ;
104       return "* " + initiateur + " a kicke " + tokens[3] + " " + tokens[4] ;
105     }
106   }
107
108   protected boolean informeUser()
109   {
110     return false ;
111   }
112
113 }
114
Popular Tags