KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > zirc > threads > KickUserThread


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

22 /**
23  * <p>Title: KickUserThread</p>
24  * <p>Description: thread du kick</p>
25  * <p>Copyright: Copyright (c) 2004</p>
26  * <p>Company: CoolBytes(Stephane Claret, Andre Aymon, Alban Zumofen) coolbytes@hotmail.com</p>
27  * @version 1.0
28  */

29
30
31 public class KickUserThread extends PseudoThread
32 {
33   private IRCconnexion IRCchan ;
34   private String JavaDoc channel ;
35   private String JavaDoc nick ;
36
37   public KickUserThread(IRCconnexion _IRCchan, String JavaDoc _chan, String JavaDoc _nick)
38   {
39     super() ;
40     IRCchan=_IRCchan;
41     channel=_chan;
42     nick=_nick;
43   }
44
45   public void go()
46   {
47     ArrayList JavaDoc Frm = IRCchan.getAllChatFrames() ;
48     DefaultListModel JavaDoc lm ;
49     int ind = -1 ;
50
51     for (int i = 0 ; i < Frm.size() ; i++)
52     {
53       if (((ChatFrame)(Frm.get(i))).getChan().equals(channel))
54       {
55         ChatFrame chatFrame = ((ChatFrame)(Frm.get(i))) ;
56         lm = chatFrame.getListModel() ;
57
58         //trouver l'ancien rang
59
ind = Arrays.binarySearch(lm.toArray(), new ChanUser(nick, ChanUser.OP)) ;
60         if (ind < 0)
61         {
62           ind = Arrays.binarySearch(lm.toArray(), new ChanUser(nick, ChanUser.HALFOP)) ;
63         }
64         if (ind < 0)
65         {
66           ind = Arrays.binarySearch(lm.toArray(), new ChanUser(nick, ChanUser.VOICE)) ;
67         }
68         if (ind < 0)
69         {
70           ind = Arrays.binarySearch(lm.toArray(), new ChanUser(nick, ChanUser.NORM)) ;
71         }
72
73         if (ind >= 0)
74         {
75           lm.removeElementAt(ind) ;
76         }
77       }
78     }
79
80
81   }
82 }
83
Popular Tags