KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > zirc > msg > MSGprivMsg


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

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

26
27
28 public class MSGprivMsg extends AbstractMessage
29 {
30   private String JavaDoc user ;
31   private String JavaDoc destination ;
32
33   public MSGprivMsg(IRCconnexion _IRCchan, Object JavaDoc _user, Object JavaDoc _chan, String JavaDoc _total)
34   {
35     super(_IRCchan, _total) ;
36
37     destination = (String JavaDoc)(_chan) ;
38
39     //parser le sender
40
user = (String JavaDoc)(_user) ;
41     int ind = user.indexOf("!") ;
42     if (ind > 0)
43     {
44       user = user.substring(1, ind) ;
45     }
46
47   }
48
49   public void reagit()
50   {
51     //
52
//fenetre cible dans lequel le message sera affiché
53
//
54
if (destination.startsWith("#"))
55     {
56       ChatFrame cht = ircChan.GetFenetreDuChan(destination) ;
57       if (cht != null)
58       {
59         this.frm = cht ;
60       }
61     }
62     else
63     {
64       //c'est un message privé
65
String JavaDoc correspondant ;
66
67       //si c'est pour nous
68
if (ircChan.GetUser_nickName().equalsIgnoreCase(destination))
69       {
70         correspondant = user ;
71       }
72       else
73       {
74         correspondant = destination ;
75       }
76
77       PrivateFrame prm = ircChan.GetFenetreDuPrive(correspondant) ;
78       if (prm == null)
79       {
80         prm = ircChan.createPrivateFrame(correspondant) ;
81       }
82
83       //a present que la fenetre est déterminée...
84
frm = prm ;
85     }
86
87   }
88
89 //parser le message
90
public String JavaDoc parseMessagePourAffichage(String JavaDoc _txtAffiche)
91   {
92     String JavaDoc ret = "" ;
93     int ind ;
94
95     //extraire l'utilisateur (:Ecurbx!~poosstoom@Recycled-irc-A7BE083.w82-125.abo.wanadoo.fr)
96
ret = "&#60;" + user + "&#62; " ;
97
98     //le message
99
ind = _txtAffiche.indexOf(":", 2) ;
100     if (ind > 0)
101     {
102       ret += _txtAffiche.substring(ind + 1) ;
103     }
104
105     return ret ;
106   }
107 }
108
Popular Tags