pax_global_header00006660000000000000000000000064115510367770014526gustar00rootroot0000000000000052 comment=82109757015570e34a5b364dd02e0d2fb95831f5 libirclib-java-1.10/000077500000000000000000000000001155103677700143215ustar00rootroot00000000000000libirclib-java-1.10/CHANGELOG000077500000000000000000000535301155103677700155440ustar00rootroot00000000000000Changelog of IRClib (IRC client library): IRClib 1.10 (03.11.2006): * Changed: org.schwering.irc.lib.ssl.*. The new package is the new residence of the SSL IRC classes. org.schwering.irc.lib.SSLIRCConnection and org.schwering.irc.lib.SSLDefaultTrustManager are deprecated. * Added: The interface IRCConstants contains the reply codes, error codes and mIRC color codes now. The interface is implemented by IRCUtil (thus, accessing the constants via IRCUtil still works) and by IRCEventListener (for less typing work). * Changed: The mIRC color code fields in the IRCUtil class (like actionIndicator etc.) are deprecated. The new values are final and written in upper case with underscores (e.g. ACTION_INDICATOR). * Changed: IRCEventListeners are fired from-last-to-first. * Changed: There's only one release which contains the three licenses: GNU LGPL, Eclipse Public License, Apache Software License. IRClib 1.04-epl (31.03.2006): * Changed: Wrong documentation of onReply() and onError() Events: Your own nickname is the first word in the _value_, not in the msg. * Changed: Correct code formatting. * Changed: IRCConnection.send() and IRCConnection.close prints an exception if one is thrown when transmitting a line to the server. IRClib 1.04-bsd (23.09.2005): * Added: IRClib is now additionally released under the Apache License 2.0. IRClib 1.04 (03.10.2004): * Added: IRCConnection.setEncoding sets the socket's character encoding. Thanks to Daniel Wunsch. * Added: IRCConnection.getColors, IRCConnection.getPong, IRCConnection.getEncoding and IRCConnection.getTimeout which all belong to one set-method. * Changed: The IRCUser.toString method now returns simply the nickname. That makes it possible to add the IRCUser objects to JLists etc. without a wrapper. * Fixed: The onDisconnect method could be invoked twice, if IRCConnection.doQuit and IRCConnection.close were invoked immediately after another. IRClib 1.03 (08.10.2003): * Fixed: The onMode(String channel, IRCUser user, IRCModeParser modes) had a wrong IRCModeParser argument. Sorry. IRClib 1.02 (07.10.2003): * Changed: Improved code-documentation for javadoc. * Fixed: The nick-update in the IRCConnection class wasn't case-insenstive. However, that's just a theoretical bug; I have *never* seen a server that changes nicks' case. * Fixed: IRClib crashed when the server sent empty lines (""). Stupid servers :-). Thanks to Demian Rootring . IRClib 1.01 (03.10.2003): * Changed: Better performance for multiple listeners. * Changed: IRClib leaved out the PASS command of the registration if the password was null, empty or whitespace. Now you can force IRClib to send the PASS command by setting whitespace (like " ") as password. That might be useful on some servers, because RFC1459 says that *always* a PASS command must be send. However, the most IRC servers send a not-enough-parameters reply when you send a PASS command without a password. * Fixed: If a reply was received before the first PING? PONG!, the onRegistered event was fired. So far so good, but it was fired after the onReply event; now it's first the onRegistered and then onReply. * Fixed: When a too long or special-char-containing nickname was set before the registration is completed and accepted, the nickname is updated in the IRCConnection. Caused bad errors, because IRClib didn't know that the nickname was changed by the server sometimes. IRClib 1.00 (24.09.2003): * Changed: Release-number. After 2^8 days of development, 1.00 is there. Today the EU Parliament approved the amended version of the directive about software patents. IRClib 0.91 (23.09.2003): * Added: IRCConnection.close method which closes the connection *brutally* and *not* with the proper IRC command QUIT. This was the private method disconnect until now. This method should be used if the server doesn't react on QUIT commands anymore. Please check the javadocs. * Removed: IRCConnection.setDebug and all debug-functions. * Changed: Improved code-documentation for javadoc. * Fixed: The IRCParser compared two ints (the current index and the possible beginning of the trailing) when it wasn't necessary. * Fixed: The IRCConnection.isConnected method returned true even if the connection was closed from one side. IRClib 0.90 (11.09.2003): * Changed: The version policy: There's only one code of the IRClib. This code runs under all Java versions since J2SE 1.2 and requires JSSE. JSSE is no more required since J2SE 1.4. Some of this code is deprecated since 1.4, but that doesn't matter. * Changed: The TrustManager and X509TrustManager interfaces are now in package com.sun.net.ssl. The methods of the X509TrustManager also have changed. See the javadocs and/or tutorial. * Fixed: SSLIRCConnection threw AlgorithmNotFoundException in old Java versions. * Fixed: The javadocs look much nicer if you use older versions of javadoc now (because of much uglier HTML in them, that's paradox). IRClib 0.84 (03.09.2003): * Added: IRCConnection.getUsername method returns the username. * Added: IRCConnection.getPassword method returns the server-password. * Removed: IRCConnection.updateNick has no sense anymore since the library notices a nickchange before being registered itself. Read below. * Changed: Rewrote all numeric replies and error replies in the IRCUtil class. Now they are named same as in RFC1459 (with the ERR_ or RPL_) and they are documentated (copied documentation from RFC1459 in most cases). * Changed: The IRCParser recognizes "moor " as trailing in a string like that: "nick moor ". Before, the IRCParser just returned the substring from the last index to the ending of the line as trailing which is an empty string in such a case. * Changed: You do not need to invoke IRCConnection.updateNick to update the nickname before being registered when you receive an nickname error reply. * Changed: IRCEventListener.onConnect is now known as IRCEventListener.onRegistered because the new name better describes the event. * Changed: IRCEventListener.onDisconnect is now known as IRCEventListener.onDisconnected because the new name makes it clear that it's our connection which is broken. * Changed: IRCConnection.getPort returns 0 instead of -1 if there's no connection. * Changed: Every IRClib version will consist of one Java 1.4 release and one Java 1.3 + JSSE release. IRClib 0.83 (26.08.2003): * Changed: All classes except SSLIRCConnection and SSLDefaultTrustManager are Java 1.3 compliant. To convert the SSLIRCConnection and SSLDefaultTrustManager classes into Java 1.3, you must download the JSSE (Java Secure Socket Extensions) library, change some imports and change the SSLDefaultTrustManager's methods. There'll be a small text about how to do that at http://moepii.sf.net. * Changed: IRCConnection.setNick is now known as IRCConnection updateNick because this method is not used as normal set-methods. Its purpose is very special; read the javadoc for it. * Changed: Improved code-documentation for javadoc. * Changed: Improved dirty code in IRCUtil.isChan method. * Changed: SSLIRCConnection.removeTrustManager returns true if one was removed. * Changed: Protected debugging method IRCConnection.print now invokes printStackTrace if the transmitted object is an Exception. * Changed: Before the calls of the debugging method print, it's checked wether debugging is enabled or disabled, which is faster (the only exception is in SSLIRCConnection.connect; this method calls the method print and it's checked wether debugging is on or off). * Changed: Some pieces of dirty code. * Fixed: Bug in IRCConnection.portRangeToArray: If the IRCConnection was instantiated with the portrange constructor and not with the portarray constructor, only one port was tried to connect. * Fixed: When getting disconnected the IRCConnection instance does not try to send a second quit. IRClib 0.82 (17.08.2003): * Added: The IRCConnection.addIRCEventListener(IRCEventListener listener) and IRCConnection.removeIRCEventListener(IRCEventListener listener) methods. * Removed: The IRCConnection.setEventListener(IRCEventListener listener). Added a add- and remove-method instead. * Changed: As you can see at the above points, IRClib now supports multiple listeners. * Changed: IRCEventListener now extends the java.util.EventListener interface. * Changed: The methods IRCEventListener.onOther and IRCEventAdapter.onOther are now known as IRCEventListener.unknown and IRCEventAdapter.unknown. * Changed: The library is now distributed under the terms of the GNU LGPL! IRClib 0.81 (08.08.2003): * Changed: The IRCParser and IRCModeParser use IRCUtil.split instead of a StringTokenizer object to parse the parameters. That makes them faster. * Changed: The SSLIRCConnection might be a microlittlebit faster. * Fixed: The mIRC color code for reversed colors is now parsed out, too. * Fixed: The IRCConnection.connect and SSLIRCConnection.connect methods possibly did not close sockets. * Fixed: Removed a useless imports in classes IRCModeParser and IRCUser. IRClib 0.80 (01.08.2003): * Added: Support for SSL connections! * Added: The SSLIRCConnection class which extends IRCConnection and uses secure sockets. * Added: The SSLDefaultTrustManager class which truts the X509 key which is used by all public IRC networks which support SSL I know. * Changed: Turned arount the arguments of the IRCEventListener.onNotice and IRCEventAdapter.onNotice methods: now first argument String target, IRCUser user, String msg. * Changed: The IRCConnection extends now Thread so that all methods provided by Thread can be used directly. * Changed: Some pieces of dirty code. IRClib 0.71 (23.07.2003): * Added: Constructors of IRCConnection: IRCConnection(String host, int[] ports, String pass, String nick, String username, String realname) and IRCConnection(String host, int portMin, int portMax, String pass, String nick, String username, String realname). * Added: The argument username which replaces the stupid eMail in the whole library. * Removed: All other constructors. * Removed The eMail from the whole library. Instead added the username. * Removed: The IRCUtil.getRandomString method which wasn't needed anymore because of the constructors are removed. * Changed: With the new constructor, not only a portrange can be tested, but also a number of ports like 256, 1024, 2048, 6667, 6668, 6669. * Fixed: Now the IRCConnection also connects to the last port of the portrange. IRClib 0.70 (20.07.2003): * Added: The IRCUser class which stores the nickname, username and hostname of users. * Added: The IRCParser.getUser method which returns an IRCUser object. This method is used by the IRCConnection from now on to transmit the data about the active user to the listener. * Added: The IRCConnection.isDaemon method which returns true if the thread is a daemon thread. * Changed: The whole listening! Instead of the nickname, and sometimes additionally the username and host, an IRCUser object is given as argument to the events. Thus, the listener has always all available information about the active user. * Changed: The IRCParser.getUser method, which returned the username of the user is now known as IRCParser.getUsername, because of the new IRCParser.getUser. * Fixed: Removed an unwanted System.out.println from the IRCConnection. IRClib 0.63 (06.07.2003): * Added: IRCConnection.setDaemon sets the the thread as either daemon or user thread. As a user thread, a reference to a IRCConnection object prevents the JVM from exiting. NOTE: Until now, the thread was a daemon thread; by default it's a user thread now! Therefore, you probably must use setDaemon(true) in existing code. Otherwise, the JVM wouldn't exit when you want it to do. * Added: IRCParser.getServername which is totally equal to IRCParser.getNick. Thus this method makes no sense, but it's there because there's also a part in the prefix which is the same as the nickname. * Removed: The IRCParser.finalize method. * Changed: No exceptions are printed out if debugging is disabled. * Changed: IRCParser.indexOf and IRCParser.lastIndexOf do not try and catch Exceptions anymore, because the index cannot be out of bounds, because it's checked with an if. * Changed: Now compiled under Java 1.4.2. * Fixed: The IRCParser's methods which work with the prefix (getNick, getUser, getHost and new getServername) are now completely in compliance with RFC1492: A line's prefix can look like this now: | [ '!' ] [ '@' ] And every method returns its part. getUser and getHost return null if their parts are set and getNick and getServername are totally equal. If no prefix is specified in the line, all of the methods return null. * Fixed: The method IRCParser.getParametersTo didn't work. * Fixed: IRCParser behaved crazy when jumping over spaces. IRClib 0.62 (10.06.2003): * Added: IRCConnection.toString which contains some information about the instance. * Added: IRCModeParser.toString which contains some information about the instance. * Added: IRCParser.toString which contains some information about the instance. * Changed: Revised whole code of IRClib. Thus also optimized some small parts. * Changed: IRCModeParser.parse is now declared 'private' instead of 'public'. * Fixed: The IRCParser ignores now spaces between prefix and command and between command and middle as the RFC says. * Fixed: The IRCParser doesn't throw an exception when parsing a line without any parameters. IRClib 0.61 (06.06.2003): * Changed: IRCEventListener.onMessage is now known as IRCEventListener.onPrivmsg. * Changed: IRCConnection.doMsg is now known as IRCConnection.doPrivmsg. * Changed: Optimized IRCUtil.getRandomString's speed. * Fixed: The onConnect event wasn't fired sometimes. Now the IRCConnection.register method is invoked before the IRCConnection.startGetThread method. Therefore the registration is completed always before incoming lines are treated. IRClib 0.60 (03.06.2003): * Added: IRCConnection.setTimeout method which sets the timeout of the socket. Default is 15 minutes. * Removed: All constructors which had an IRCActionListener (now IRCEventListener) object as argument. * Removed: The deprecated IRCParser.getLeading method which was replaced with IRCParser.getMiddle. * Changed: The IRCConnection does not connect automatically when it's instantiated! You must invoke IRCConnection.connect first!! * Changed: IRCActionAdapter is now known as IRCEventAdapter. I'm sorry, but I think event is the better word. * Changed: IRCActionListener is now known as IRCEventListener. I'm sorry, but I think event is the better word. * Changed: IRCConnection.addIRCActionListener is now known as IRCConnection.setEventListener. Its argument changed into IRCEventListener, of course. I'm sorry, but the old name didn't really describe what happend. * Changed: The IRCUtil.parseColor is faster because the BOLD, UNDERLINE, ACTION and COLOREND characters are parsed in the same loop as the COLORSTART and its parameters. * Changed: IRCConnection implements Runnable now instead of extending Thread. * Fixed: Early events are now always fired because connecting must be done by invoking IRCConnection.connect; it's no more done automatically. * Fixed: IRCConnection.connect tries now all ports. If all ports (from portMin to portMax) fail, the IOException is thrown. IRClib 0.52 (31.05.2003): * Changed: The method IRCParser.getLeading is deprecated, use IRCParser.getMiddle now. I wanted to be in compliance with the RFC's names for the parts of a message. * Changed: Improved IRCParser's code-documentation for javadoc. IRClib 0.51 (26.05.2003): * Added: The IRCParser.getParameterCount method which returns the count of parameters (the trailing is one parameters independent from the amount of words in the trailing). * Added: IRCConnection.setDebug to enable or disable console-output of incoming and outgoing messages. * Changed: IRCParser's code to get leading and trailing looks a little bit different now. * Changed: The getParam* methods of IRCParser are now named getParameter*. * Fixed: The onKick and onPart message argument is now "" if there isn't a message. * Fixed: Some mistakes in documentation. IRClib 0.50 (21.05.2003): * Added: New IRCParser has now more than double speed. * Added: An onError event to IRClib for ERROR commands. * Added: Constructors of IRCConnection: IRCConnection(IRCActionListener listener, String sHost, int iPortMin, int iPortMax, String sNick), IRCConnection(IRCActionListener listener, String sHost, int iPortMin, int iPortMax, String sPass, String sNick), IRCConnection(IRCActionListener listener, String sHost, int iPortMin, int iPortMax, String sPass, String sNick, String sRealname, String sMail), IRCConnection(String sHost, int iPortMin, int iPortMax, String sPass, String sNick). See IRClib's javadoc. * Removed: Constructors of IRCConnection: IRCConnection(String sHost), IRCConnection(String sHost, int iPortMin, int iPortMax), IRCConnection(String sHost, int iPortMin, int iPortMax, String sPass). See IRClib's javadoc. * Removed: Method IRCConnection.setParamArgType. * Removed: Method IRCParser.getParam(). * Removed: Method / event IRCActionListener.onOther(String prefix, String command, String[] param). * Changed: Changed onReply and onError numeric-reply-argument to type int. * Changed: By default, mIRC color code is disabled in IRCConnection. * Changed: Revised all javadoc comments in IRClib's code. * Changed: Normton has revised the IRCUtil.parseColors method for more speed (thanks to him). * Changed: IRClib's constructor should now have the IRCActionListener as first argument; otherwise you might miss the first one or two lines. * Changed: Improved code-documentation for javadoc. * Changed: Renamed IRCParser.getParamsTill into IRCParser.getParamsTo (hate prepositions, is it right now?). IRClib 0.43 (13.05.2003): * Fixed: Changed many 'private'-modifiers which were not in compliance with Java 1.4.1_02 into 'protected'. IRClib 0.42 (09.05.2003): * Changed: Some 'abstract' and some 'protected' declarations. IRClib 0.41 (29.04.2003): * Added: An onConnect() event to IRClib which is fired when the first PING is received. * Changed: The start of the listening Thread in the IRCConnection a bit; has no influence to the user. * Fixed: Noticed that indpendent isn't spelled independant. :-) IRClib 0.40 (12.04.2003): * Changed: Extended documentation. * Changed: Got some new icons and logos; thanks to Carsten Wiesbaum alias Radi Skull . IRClib 0.31 (22.03.2003): * Changed: The way how the colorcodes are parsed by the IRCParser-class much faster. * Fixed: Bug in IRClib for networks which ignore case. * Fixed: Missing classes in manifest-file. IRClib 0.30 (14.03.2003): * Fixed: Some String-calculations like many indexOf-methods got faster because of less stupid use. * Fixed: The client now can handle all types of channel names described in RFC 2812: They may begin with #, &, !, +. * Fixed: Strange exception when joining a channel with an active key. IRClib 0.20 (04.03.2003): * Added: mIRC ColorCode chars are now available in class Util in ASCII code. * Fixed: Really many bugs in IRCConnection. * Fixed: Bugs in IRCModeParser. * Fixed: ColorCodes are now removed successfully. * Fixed: The nickname of the mode-changing user was null if the server changed the mode. * Fixed: The mIRC ColorCode character for ending of all formatting (ASCII decimal int: 15) is now parsed, too. * Fixed: Now eMail address is required by class IRCConnection, so that proper authing is possible. IRClib 0.11 (06.02.2003): * Dunno what I changed... probably almost everything. IRClib 0.10 (05.02.2003): * First running release. IRClib 0.00 (12.01.2003): * Started development of IRClib. IRClib 0.00 (22.09.2002): * Began writing some code which was so stupid that it never had a chance to do what I wanted. libirclib-java-1.10/COPYING_AL000077500000000000000000000264461155103677700157470ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. libirclib-java-1.10/COPYING_EPL000077500000000000000000000260051155103677700160620ustar00rootroot00000000000000*Eclipse Public License - v 1.0* THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. *1. DEFINITIONS* "Contribution" means: a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and b) in the case of each subsequent Contributor: i) changes to the Program, and ii) additions to the Program; where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. "Contributor" means any person or entity that distributes the Program. "Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. "Program" means the Contributions distributed in accordance with this Agreement. "Recipient" means anyone who receives the Program under this Agreement, including all Contributors. *2. GRANT OF RIGHTS* a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. *3. REQUIREMENTS* A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: a) it complies with the terms and conditions of this Agreement; and b) its license agreement: i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. When the Program is made available in source code form: a) it must be made available under this Agreement; and b) a copy of this Agreement must be included with each copy of the Program. Contributors may not remove or alter any copyright notices contained within the Program. Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. *4. COMMERCIAL DISTRIBUTION* Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. *5. NO WARRANTY* EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. *6. DISCLAIMER OF LIABILITY* EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. *7. GENERAL* If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. libirclib-java-1.10/COPYING_LGPL000077500000000000000000000604151155103677700162030ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONSlibirclib-java-1.10/README000077500000000000000000000015731155103677700152120ustar00rootroot00000000000000IRClib is client library for Internet Relay Chat (IRC) licensed under the * GNU Lesser General Public License (see COPYING_LGPL), * Apache License, Version 2.0 (see COPYING_AL) and * Eclipse Public License (see COPYING_EPL). IRClib requires Java Runtime Environment 1.2 or later. It requires JSSE (Java Secure Socket Extensions) until J2RE 1.3; J2RE 1.4 already includes JSSE and hence doesn't require JSSE. You can download JSSE from http://java.sun.com/products/jsse/index-103.html. Content: * irclib.jar IRClib java byte code * src/ IRClib java source code * javadoc/ IRClib javadoc documentation Check the project's homepage: http://moepii.sourceforge.net My name is Christoph Schwering. You can mail to schwering@gmail.com or visit http://www.schwering.org. Please see the file COPYING_* for copyright affairs and the file CHANGELOG for the changelog. libirclib-java-1.10/javadoc/000077500000000000000000000000001155103677700157305ustar00rootroot00000000000000libirclib-java-1.10/javadoc/.svn/000077500000000000000000000000001155103677700166145ustar00rootroot00000000000000libirclib-java-1.10/javadoc/.svn/README.txt000066400000000000000000000001661155103677700203150ustar00rootroot00000000000000This is a Subversion working copy administrative directory. Visit http://subversion.tigris.org/ for more information. libirclib-java-1.10/javadoc/.svn/dir-wcprops000066400000000000000000000001221155103677700210030ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 41 /svnroot/moepii/!svn/ver/31/trunk/javadoc END libirclib-java-1.10/javadoc/.svn/empty-file000066400000000000000000000000001155103677700206000ustar00rootroot00000000000000libirclib-java-1.10/javadoc/.svn/entries000066400000000000000000000073761155103677700202250ustar00rootroot00000000000000 libirclib-java-1.10/javadoc/.svn/format000066400000000000000000000000021155103677700200170ustar00rootroot000000000000004 libirclib-java-1.10/javadoc/.svn/text-base/000077500000000000000000000000001155103677700205105ustar00rootroot00000000000000libirclib-java-1.10/javadoc/.svn/text-base/allclasses-frame.html.svn-base000066400000000000000000000047501155103677700263370ustar00rootroot00000000000000 All Classes All Classes
IRCConnection
IRCConstants
IRCEventAdapter
IRCEventListener
IRCModeParser
IRCParser
IRCUser
IRCUtil
SSLDefaultTrustManager
SSLDefaultTrustManager
SSLIRCConnection
SSLIRCConnection
SSLNotSupportedException
SSLTrustManager
libirclib-java-1.10/javadoc/.svn/text-base/allclasses-noframe.html.svn-base000066400000000000000000000043201155103677700266650ustar00rootroot00000000000000 All Classes All Classes
IRCConnection
IRCConstants
IRCEventAdapter
IRCEventListener
IRCModeParser
IRCParser
IRCUser
IRCUtil
SSLDefaultTrustManager
SSLDefaultTrustManager
SSLIRCConnection
SSLIRCConnection
SSLNotSupportedException
SSLTrustManager
libirclib-java-1.10/javadoc/.svn/text-base/constant-values.html.svn-base000066400000000000000000001700001155103677700262370ustar00rootroot00000000000000 Constant Field Values

Constant Field Values


Contents
org.schwering.*

org.schwering.irc.lib.IRCConstants
public static final char ACTION_INDICATOR 1
public static final char BOLD_INDICATOR 31
public static final char COLOR_END_INDICATOR 15
public static final char COLOR_INDICATOR 3
public static final char COLOR_REVERSE_INDICATOR 22
public static final int ERR_ALREADYREGISTRED 462
public static final int ERR_BADCHANMASK 476
public static final int ERR_BADCHANNELKEY 475
public static final int ERR_BANNEDFROMCHAN 474
public static final int ERR_CANNOTSENDTOCHAN 404
public static final int ERR_CANTKILLSERVER 483
public static final int ERR_CHANNELISFULL 471
public static final int ERR_CHANOPRIVSNEEDED 482
public static final int ERR_ERRONEUSNICKNAME 432
public static final int ERR_FILEERROR 424
public static final int ERR_INVITEONLYCHAN 473
public static final int ERR_KEYSET 467
public static final int ERR_NEEDMOREPARAMS 461
public static final int ERR_NICKCOLLISION 436
public static final int ERR_NICKNAMEINUSE 433
public static final int ERR_NOADMININFO 423
public static final int ERR_NOLOGIN 444
public static final int ERR_NOMOTD 422
public static final int ERR_NONICKNAMEGIVEN 431
public static final int ERR_NOOPERHOST 491
public static final int ERR_NOORIGIN 409
public static final int ERR_NOPERMFORHOST 463
public static final int ERR_NOPRIVILEGES 481
public static final int ERR_NORECIPIENT 411
public static final int ERR_NOSERVICEHOST 492
public static final int ERR_NOSUCHCHANNEL 403
public static final int ERR_NOSUCHNICK 401
public static final int ERR_NOSUCHSERVER 402
public static final int ERR_NOTEXTTOSEND 412
public static final int ERR_NOTONCHANNEL 442
public static final int ERR_NOTOPLEVEL 413
public static final int ERR_NOTREGISTERED 451
public static final int ERR_PASSWDMISMATCH 464
public static final int ERR_SUMMONDISABLED 445
public static final int ERR_TOOMANYCHANNELS 405
public static final int ERR_TOOMANYTARGETS 407
public static final int ERR_UMODEUNKNOWNFLAG 501
public static final int ERR_UNKNOWNCOMMAND 421
public static final int ERR_UNKNOWNMODE 472
public static final int ERR_USERNOTINCHANNEL 441
public static final int ERR_USERONCHANNEL 443
public static final int ERR_USERSDISABLED 446
public static final int ERR_USERSDONTMATCH 502
public static final int ERR_WASNOSUCHNICK 406
public static final int ERR_WILDTOPLEVEL 414
public static final int ERR_YOUREBANNEDCREEP 465
public static final int ERR_YOUWILLBEBANNED 466
public static final int RPL_ADMINEMAIL 259
public static final int RPL_ADMINLOC1 257
public static final int RPL_ADMINLOC2 258
public static final int RPL_ADMINME 256
public static final int RPL_AUTHNAME 333
public static final int RPL_AWAY 301
public static final int RPL_BANLIST 367
public static final int RPL_CHANNELMODEIS 324
public static final int RPL_CLOSEEND 363
public static final int RPL_CLOSING 362
public static final int RPL_CREATED 3
public static final int RPL_ENDOFBANLIST 368
public static final int RPL_ENDOFINFO 374
public static final int RPL_ENDOFLINKS 365
public static final int RPL_ENDOFMOTD 376
public static final int RPL_ENDOFNAMES 366
public static final int RPL_ENDOFSERVICES 232
public static final int RPL_ENDOFSTATS 219
public static final int RPL_ENDOFUSERS 394
public static final int RPL_ENDOFWHO 315
public static final int RPL_ENDOFWHOIS 318
public static final int RPL_ENDOFWHOWAS 369
public static final int RPL_INFO 371
public static final int RPL_INFOSTART 373
public static final int RPL_INVITING 341
public static final int RPL_ISON 303
public static final int RPL_ISUPPORT 5
public static final int RPL_KILLDONE 361
public static final int RPL_LINKS 364
public static final int RPL_LIST 322
public static final int RPL_LISTEND 323
public static final int RPL_LISTSTART 321
public static final int RPL_LUSERCHANNELS 254
public static final int RPL_LUSERCLIENT 251
public static final int RPL_LUSERME 255
public static final int RPL_LUSEROP 252
public static final int RPL_LUSERUNKNOWN 253
public static final int RPL_MOTD 372
public static final int RPL_MOTDSTART 375
public static final int RPL_MYINFO 4
public static final int RPL_MYPORTIS 384
public static final int RPL_NAMREPLY 353
public static final int RPL_NONE 300
public static final int RPL_NOTOPIC 331
public static final int RPL_NOUSERS 395
public static final int RPL_NOWAWAY 306
public static final int RPL_REHASHING 382
public static final int RPL_SERVICE 233
public static final int RPL_SERVICEINFO 231
public static final int RPL_SERVLIST 234
public static final int RPL_SERVLISTEND 235
public static final int RPL_STATSCLINE 213
public static final int RPL_STATSCOMMANDS 212
public static final int RPL_STATSHLINE 244
public static final int RPL_STATSILINE 215
public static final int RPL_STATSKLINE 216
public static final int RPL_STATSLINKINFO 211
public static final int RPL_STATSLLINE 241
public static final int RPL_STATSNLINE 214
public static final int RPL_STATSOLINE 243
public static final int RPL_STATSQLINE 217
public static final int RPL_STATSUPTIME 242
public static final int RPL_STATSYLINE 218
public static final int RPL_SUMMONING 342
public static final int RPL_TIME 391
public static final int RPL_TOPIC 332
public static final int RPL_TOPICINFO 333
public static final int RPL_TRACECLASS 209
public static final int RPL_TRACECONNECTING 201
public static final int RPL_TRACEHANDSHAKE 202
public static final int RPL_TRACELINK 200
public static final int RPL_TRACELOG 261
public static final int RPL_TRACENEWTYPE 208
public static final int RPL_TRACEOPERATOR 204
public static final int RPL_TRACESERVER 206
public static final int RPL_TRACEUNKNOWN 203
public static final int RPL_TRACEUSER 205
public static final int RPL_UMODEIS 221
public static final int RPL_UNAWAY 305
public static final int RPL_USERHOST 302
public static final int RPL_USERS 393
public static final int RPL_USERSSTART 392
public static final int RPL_VERSION 351
public static final int RPL_WELCOME 1
public static final int RPL_WHOISCHANNELS 319
public static final int RPL_WHOISCHANOP 316
public static final int RPL_WHOISIDLE 317
public static final int RPL_WHOISOPERATOR 313
public static final int RPL_WHOISSERVER 312
public static final int RPL_WHOISUSER 311
public static final int RPL_WHOREPLY 352
public static final int RPL_WHOWASUSER 314
public static final int RPL_YOUREOPER 381
public static final int RPL_YOURHOST 2
public static final char UNDERLINE_INDICATOR 2



libirclib-java-1.10/javadoc/.svn/text-base/deprecated-list.html.svn-base000066400000000000000000000171351155103677700261730ustar00rootroot00000000000000 Deprecated List

Deprecated API

Deprecated Classes
org.schwering.irc.lib.SSLDefaultTrustManager
          This class has been replaced with org.schwering.irc.lib.ssl.SSLDefaultTrustManager. 
org.schwering.irc.lib.SSLIRCConnection
          This class has been replaced with org.schwering.irc.lib.ssl.SSLDefaultTrustManager. 
 

Deprecated Fields
org.schwering.irc.lib.IRCUtil.actionIndicator
          Moved to IRCConstants. 
org.schwering.irc.lib.IRCUtil.boldIndicator
          Moved to IRCConstants. 
org.schwering.irc.lib.IRCUtil.colorEndIndicator
          Moved to IRCConstants. 
org.schwering.irc.lib.IRCUtil.colorIndicator
          Moved to IRCConstants. 
org.schwering.irc.lib.IRCUtil.colorReverseIndicator
          Moved to IRCConstants. 
org.schwering.irc.lib.IRCUtil.underlinedIndicator
          Moved to IRCConstants. 
 



libirclib-java-1.10/javadoc/.svn/text-base/help-doc.html.svn-base000066400000000000000000000212451155103677700246120ustar00rootroot00000000000000 API Help

How This API Document Is Organized

This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

Overview

The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

Package

Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

  • Interfaces (italic)
  • Classes
  • Exceptions
  • Errors

Class/Interface

Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

  • Class inheritance diagram
  • Direct Subclasses
  • All Known Subinterfaces
  • All Known Implementing Classes
  • Class/interface declaration
  • Class/interface description

  • Nested Class Summary
  • Field Summary
  • Constructor Summary
  • Method Summary

  • Field Detail
  • Constructor Detail
  • Method Detail
Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

Use

Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.

Tree (Class Hierarchy)

There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
  • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
  • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.

Deprecated API

The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

Index

The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

Prev/Next

These links take you to the next or previous class, interface, package, or related page.

Frames/No Frames

These links show and hide the HTML frames. All pages are available with or without frames.

Serialized Form

Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

This help file applies to API documentation generated using the standard doclet.



libirclib-java-1.10/javadoc/.svn/text-base/index.html.svn-base000066400000000000000000000016001155103677700242170ustar00rootroot00000000000000 Generated Documentation (Untitled) <H2> Frame Alert</H2> <P> This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. <BR> Link to<A HREF="overview-summary.html">Non-frame version.</A> libirclib-java-1.10/javadoc/.svn/text-base/overview-frame.html.svn-base000066400000000000000000000021061155103677700260500ustar00rootroot00000000000000 Overview
All Classes

Packages
org.schwering.irc.lib
org.schwering.irc.lib.ssl

  libirclib-java-1.10/javadoc/.svn/text-base/overview-summary.html.svn-base000066400000000000000000000126171155103677700264630ustar00rootroot00000000000000 Overview


Packages
org.schwering.irc.lib IRClib is a library for the client-side of IRC (Internet Relay Chat) connections.
org.schwering.irc.lib.ssl Provides support for secure IRC connections.

 



libirclib-java-1.10/javadoc/.svn/text-base/overview-tree.html.svn-base000066400000000000000000000211621155103677700257200ustar00rootroot00000000000000 Class Hierarchy

Hierarchy For All Packages

Package Hierarchies:
org.schwering.irc.lib, org.schwering.irc.lib.ssl

Class Hierarchy

Interface Hierarchy



libirclib-java-1.10/javadoc/.svn/text-base/package-list.svn-base000066400000000000000000000000601155103677700245100ustar00rootroot00000000000000org.schwering.irc.lib org.schwering.irc.lib.ssl libirclib-java-1.10/javadoc/.svn/text-base/packages.html.svn-base000066400000000000000000000012311155103677700246660ustar00rootroot00000000000000


The front page has been relocated.Please see:
          Frame version
          Non-frame version.
libirclib-java-1.10/javadoc/.svn/text-base/serialized-form.html.svn-base000066400000000000000000000131521155103677700262110ustar00rootroot00000000000000 Serialized Form

Serialized Form


Package org.schwering.irc.lib.ssl

Class org.schwering.irc.lib.ssl.SSLNotSupportedException extends java.lang.RuntimeException implements Serializable

serialVersionUID: -5108810948951810903l



libirclib-java-1.10/javadoc/.svn/text-base/stylesheet.css.svn-base000066400000000000000000000022621155103677700251320ustar00rootroot00000000000000/* Javadoc style sheet */ /* Define colors, fonts and other style attributes here to override the defaults */ /* Page background color */ body { background-color: #FFFFFF } /* Headings */ h1 { font-size: 145% } /* Table colors */ .TableHeadingColor { background: #CCCCFF } /* Dark mauve */ .TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ .TableRowColor { background: #FFFFFF } /* White */ /* Font used in left-hand frame lists */ .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif } .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } /* Navigation bar fonts and colors */ .NavBarCell1 { background-color:#EEEEFF;} /* Light mauve */ .NavBarCell1Rev { background-color:#00008B;} /* Dark Blue */ .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} libirclib-java-1.10/javadoc/.svn/wcprops/000077500000000000000000000000001155103677700203115ustar00rootroot00000000000000libirclib-java-1.10/javadoc/.svn/wcprops/allclasses-frame.html.svn-work000066400000000000000000000001501155103677700261760ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 63 /svnroot/moepii/!svn/ver/35/trunk/javadoc/allclasses-frame.html END libirclib-java-1.10/javadoc/.svn/wcprops/allclasses-noframe.html.svn-work000066400000000000000000000001521155103677700265350ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 65 /svnroot/moepii/!svn/ver/35/trunk/javadoc/allclasses-noframe.html END libirclib-java-1.10/javadoc/.svn/wcprops/constant-values.html.svn-work000066400000000000000000000001471155103677700261140ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 62 /svnroot/moepii/!svn/ver/35/trunk/javadoc/constant-values.html END libirclib-java-1.10/javadoc/.svn/wcprops/deprecated-list.html.svn-work000066400000000000000000000001471155103677700260370ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 62 /svnroot/moepii/!svn/ver/35/trunk/javadoc/deprecated-list.html END libirclib-java-1.10/javadoc/.svn/wcprops/help-doc.html.svn-work000066400000000000000000000001401155103677700244520ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 55 /svnroot/moepii/!svn/ver/35/trunk/javadoc/help-doc.html END libirclib-java-1.10/javadoc/.svn/wcprops/index.html.svn-work000066400000000000000000000001351155103677700240720ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 52 /svnroot/moepii/!svn/ver/35/trunk/javadoc/index.html END libirclib-java-1.10/javadoc/.svn/wcprops/overview-frame.html.svn-work000066400000000000000000000001461155103677700257230ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 61 /svnroot/moepii/!svn/ver/35/trunk/javadoc/overview-frame.html END libirclib-java-1.10/javadoc/.svn/wcprops/overview-summary.html.svn-work000066400000000000000000000001501155103677700263210ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 63 /svnroot/moepii/!svn/ver/35/trunk/javadoc/overview-summary.html END libirclib-java-1.10/javadoc/.svn/wcprops/overview-tree.html.svn-work000066400000000000000000000001451155103677700255670ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 60 /svnroot/moepii/!svn/ver/35/trunk/javadoc/overview-tree.html END libirclib-java-1.10/javadoc/.svn/wcprops/package-list.svn-work000066400000000000000000000001371155103677700243660ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 54 /svnroot/moepii/!svn/ver/22/trunk/javadoc/package-list END libirclib-java-1.10/javadoc/.svn/wcprops/packages.html.svn-work000066400000000000000000000001401155103677700245350ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 55 /svnroot/moepii/!svn/ver/35/trunk/javadoc/packages.html END libirclib-java-1.10/javadoc/.svn/wcprops/serialized-form.html.svn-work000066400000000000000000000001471155103677700260620ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 62 /svnroot/moepii/!svn/ver/35/trunk/javadoc/serialized-form.html END libirclib-java-1.10/javadoc/.svn/wcprops/stylesheet.css.svn-work000066400000000000000000000001401155103677700247740ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 55 /svnroot/moepii/!svn/ver/3/trunk/javadoc/stylesheet.css END libirclib-java-1.10/src/000077500000000000000000000000001155103677700151105ustar00rootroot00000000000000libirclib-java-1.10/src/.svn/000077500000000000000000000000001155103677700157745ustar00rootroot00000000000000libirclib-java-1.10/src/.svn/README.txt000066400000000000000000000001661155103677700174750ustar00rootroot00000000000000This is a Subversion working copy administrative directory. Visit http://subversion.tigris.org/ for more information. libirclib-java-1.10/src/.svn/dir-wcprops000066400000000000000000000001161155103677700201660ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 37 /svnroot/moepii/!svn/ver/33/trunk/src END libirclib-java-1.10/src/.svn/empty-file000066400000000000000000000000001155103677700177600ustar00rootroot00000000000000libirclib-java-1.10/src/.svn/entries000066400000000000000000000007021155103677700173670ustar00rootroot00000000000000 libirclib-java-1.10/src/.svn/format000066400000000000000000000000021155103677700171770ustar00rootroot000000000000004 libirclib-java-1.10/src/org/000077500000000000000000000000001155103677700156775ustar00rootroot00000000000000libirclib-java-1.10/src/org/.svn/000077500000000000000000000000001155103677700165635ustar00rootroot00000000000000libirclib-java-1.10/src/org/.svn/README.txt000066400000000000000000000001661155103677700202640ustar00rootroot00000000000000This is a Subversion working copy administrative directory. Visit http://subversion.tigris.org/ for more information. libirclib-java-1.10/src/org/.svn/dir-wcprops000066400000000000000000000001221155103677700207520ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 41 /svnroot/moepii/!svn/ver/33/trunk/src/org END libirclib-java-1.10/src/org/.svn/empty-file000066400000000000000000000000001155103677700205470ustar00rootroot00000000000000libirclib-java-1.10/src/org/.svn/entries000066400000000000000000000007141155103677700201610ustar00rootroot00000000000000 libirclib-java-1.10/src/org/.svn/format000066400000000000000000000000021155103677700177660ustar00rootroot000000000000004 libirclib-java-1.10/src/org/schwering/000077500000000000000000000000001155103677700176705ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/.svn/000077500000000000000000000000001155103677700205545ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/.svn/README.txt000066400000000000000000000001661155103677700222550ustar00rootroot00000000000000This is a Subversion working copy administrative directory. Visit http://subversion.tigris.org/ for more information. libirclib-java-1.10/src/org/schwering/.svn/dir-wcprops000066400000000000000000000001341155103677700227460ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 51 /svnroot/moepii/!svn/ver/33/trunk/src/org/schwering END libirclib-java-1.10/src/org/schwering/.svn/empty-file000066400000000000000000000000001155103677700225400ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/.svn/entries000066400000000000000000000007201155103677700221470ustar00rootroot00000000000000 libirclib-java-1.10/src/org/schwering/.svn/format000066400000000000000000000000021155103677700217570ustar00rootroot000000000000004 libirclib-java-1.10/src/org/schwering/irc/000077500000000000000000000000001155103677700204455ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/.svn/000077500000000000000000000000001155103677700213315ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/.svn/README.txt000066400000000000000000000001661155103677700230320ustar00rootroot00000000000000This is a Subversion working copy administrative directory. Visit http://subversion.tigris.org/ for more information. libirclib-java-1.10/src/org/schwering/irc/.svn/dir-wcprops000066400000000000000000000001401155103677700235200ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 55 /svnroot/moepii/!svn/ver/33/trunk/src/org/schwering/irc END libirclib-java-1.10/src/org/schwering/irc/.svn/empty-file000066400000000000000000000000001155103677700233150ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/.svn/entries000066400000000000000000000007241155103677700227300ustar00rootroot00000000000000 libirclib-java-1.10/src/org/schwering/irc/.svn/format000066400000000000000000000000021155103677700225340ustar00rootroot000000000000004 libirclib-java-1.10/src/org/schwering/irc/lib/000077500000000000000000000000001155103677700212135ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/.svn/000077500000000000000000000000001155103677700220775ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/.svn/README.txt000066400000000000000000000001661155103677700236000ustar00rootroot00000000000000This is a Subversion working copy administrative directory. Visit http://subversion.tigris.org/ for more information. libirclib-java-1.10/src/org/schwering/irc/lib/.svn/dir-wcprops000066400000000000000000000001441155103677700242720ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 59 /svnroot/moepii/!svn/ver/33/trunk/src/org/schwering/irc/lib END libirclib-java-1.10/src/org/schwering/irc/lib/.svn/empty-file000066400000000000000000000000001155103677700240630ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/.svn/entries000066400000000000000000000060421155103677700234750ustar00rootroot00000000000000 libirclib-java-1.10/src/org/schwering/irc/lib/.svn/format000066400000000000000000000000021155103677700233020ustar00rootroot000000000000004 libirclib-java-1.10/src/org/schwering/irc/lib/.svn/text-base/000077500000000000000000000000001155103677700237735ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/.svn/text-base/IRCConnection.java.svn-base000066400000000000000000001047151155103677700310200ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class IRCConnection * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.Socket; import java.net.SocketException; /** * Creates a new connection to an IRC server. It's the main class of the * IRClib, the point everything starts. *

* The following sample code tries to establish an IRC connection to an * IRC server: *

*


 * /* 
 *  * The following code of a class which imports org.schwering.irc.lib.*
 *  * prepares an IRC connection and then tries to establish the connection.
 *  * The server is "irc.somenetwork.com", the default portrange (6667 and 
 *  * 6669) is set, no password is used (null). The nickname is "Foo" and 
 *  * the realname is "Mr. Foobar". The username "foobar".
 *  * Because of setDaemon(true), the JVM exits even if this thread is 
 *  * running.
 *  * An instance of the class MyListener which must implement 
 *  * IRCActionListener is added as only event-listener for the connection. 
 *  * The connection is told to parse out mIRC color codes and to enable
 *  * automatic PING? PONG! replies.
 *  */
 * IRCConnection conn = new IRCConnection(
 *                            "irc.somenetwork.com", 
 *                            6667, 
 *                            6669, 
 *                            null, 
 *                            "Foo", 
 *                            "Mr. Foobar", 
 *                            "foo@bar.com" 
 *                          ); 
 * 
 * conn.addIRCEventListener(new MyListener()); 
 * conn.setDaemon(true);
 * conn.setColors(false); 
 * conn.setPong(true); 
 * 
 * try {
 *   conn.connect(); // Try to connect!!! Don't forget this!!!
 * } catch (IOException ioexc) {
 *   ioexc.printStackTrace(); 
 * }
 * 

*

* The serverpassword isn't needed in most cases. You can give * null or "" instead as done in this example. * @author Christoph Schwering <schwering@gmail.com> * @version 3.05 * @see IRCEventListener * @see IRCParser * @see IRCUtil * @see SSLIRCConnection */ public class IRCConnection extends Thread { /** * This Socket is a connection to the IRC server. */ private Socket socket; /** * This is like a UNIX-runlevel. Its value indicates the level of the * IRCConnection object. 0 means that the object * has not yet been connected, 1 means that it's connected but * not registered, 2 means that it's connected and registered * but still waiting to receive the nickname the first time, 3 * means that it's connected and registered, and -1 means that * it was connected but is disconnected. * Therefore the defaultvalue is 0. */ protected byte level = 0; /** * The host of the IRC server. */ protected String host; /** * The int[] contains all ports to which we are going to try to * connect. This can be a portrange from port 6667 to 6669, for example. */ protected int[] ports; /** * The BufferedReader receives Strings from the IRC server. */ private volatile BufferedReader in; /** * The PrintWriter sends Strings to the IRC server. */ private PrintWriter out; /** * The String contains the name of the character encoding used * to talk to the server. This can be ISO-8859-1 or UTF-8 for example. The * default is ISO-8859-1. */ protected String encoding = "ISO-8859-1"; /** * This array contains IRCEventListener objects. */ private IRCEventListener[] listeners = new IRCEventListener[0]; /** * This int is the connection's timeout in milliseconds. It's * used in the Socket.setSoTimeout method. The default is * 1000 * 60 * 15 millis which are 15 minutes. */ private int timeout = 1000 * 60 * 15; /** * This boolean stands for enabled (true) or * disabled (false) ColorCodes.
Default is enabled * (false). */ private boolean colorsEnabled = false; /** * This boolean stands for enabled or disabled automatic PING? * PONG! support.
It means, that if the server asks with PING for the * ping, the PONG is automatically sent. Default is automatic PONG enabled * (true). */ private boolean pongAutomatic = true; /** * The password, which is needed to get access to the IRC server. */ private String pass; /** * The user's nickname, which is indispensably to connect. */ private String nick; /** * The user's realname, which is indispensably to connect. */ private String realname; /** * The user's username, which is indispensable to connect. */ private String username; // ------------------------------ /** * Creates a new IRC connection.
* The difference to the other constructor is, that it transmits the ports in * an int[]. Thus, also ports like 1024, 2048, 6667 and * 6669 can be selected.

* The constructor prepares a new IRC connection which can be really started * by invoking the connect method. Before invoking it, you should * set the IRCEventListener and other settings.
* Note that you do not need to set a password to connect to the large public * IRC networks like QuakeNet, EFNet etc. To use no password in your IRC * connection, use "" or null for the password * argument in the constructor. * @param host The hostname of the server we want to connect to. * @param ports The portrange to which we want to connect. * @param pass The password of the IRC server. If your server isn't * secured by a password (that's normal), use * null or "". * @param nick The nickname for the connection. Is used to register the * connection. * @param username The username. Is used to register the connection. * @param realname The realname. Is used to register the connection. * @throws IllegalArgumentException If the host or * ports is null or * ports' length is * 0. * @see #connect() */ public IRCConnection(String host, int[] ports, String pass, String nick, String username, String realname) { if (host == null || ports == null || ports.length == 0) throw new IllegalArgumentException("Host and ports may not be null."); this.host = host; this.ports = ports; this.pass = (pass != null && pass.length() == 0) ? null : pass; this.nick = nick; this.username = username; this.realname = realname; } // ------------------------------ /** * Creates a new IRC connection.
* The difference to the other constructor is, that it transmits the ports as * two ints. Thus, only a portrange from port x to * port y like from port 6667 to 6669 can be selected.
*
* The constructor prepares a new IRC connection which can be really started * by invoking the connect method. Before invoking it, you should * set the IRCEventListener and other settings.
* Note that you do not need to set a password to connect to the large public * IRC networks like QuakeNet, EFNet etc. To use no password in your IRC * connection, use "" or null for the password * argument in the constructor. * @param host The hostname of the server we want to connect to. * @param portMin The beginning of the port range we are going to connect * to. * @param portMax The ending of the port range we are going to connect to. * @param pass The password of the IRC server. If your server isn't * secured by a password (that's normal), use * null or "". * @param nick The nickname for the connection. Is used to register the * connection. * @param username The username. Is used to register the connection. * @param realname The realname. Is used to register the connection. * @throws IllegalArgumentException If the host is * null. * @see #connect() */ public IRCConnection(String host, int portMin, int portMax, String pass, String nick, String username, String realname) { this(host, portRangeToArray(portMin, portMax), pass, nick, username, realname); } // ------------------------------ /** * Converts a portrange which starts with a given int and ends * with a given int into an array which contains all * ints from the beginning to the ending (including beginning * and ending).
* If portMin > portMax, the portrange is turned arount * automatically. * @param portMin The beginning port of the portrange. * @param portMax The ending port of the portrange. */ private static int[] portRangeToArray(int portMin, int portMax) { if (portMin > portMax) { int tmp = portMin; portMin = portMax; portMax = tmp; } int[] ports = new int[portMax - portMin + 1]; for (int i = 0; i < ports.length; i++) ports[i] = portMin + i; return ports; } // ------------------------------ /** * Establish a connection to the server.
* This method must be invoked to start a connection; the constructor doesn't * do that!
* It tries all set ports until one is open. If all ports fail it throws an * IOException.
* You can invoke connect only one time. * @throws IOException If an I/O error occurs. * @throws SocketException If the connect method was already * invoked. * @see #isConnected() * @see #doQuit() * @see #doQuit(String) * @see #close() */ public void connect() throws IOException { if (level != 0) // otherwise disconnected or connect throw new SocketException("Socket closed or already open ("+ level +")"); IOException exception = null; Socket s = null; for (int i = 0; i < ports.length && s == null; i++) { try { s = new Socket(host, ports[i]); exception = null; } catch (IOException exc) { if (s != null) s.close(); s = null; exception = exc; } } if (exception != null) throw exception; // connection wasn't successful at any port prepare(s); } // ------------------------------ /** * Invoked by the connect method, this method prepares the * connection.
* It initializes the class-vars for the inputstream and the outputstream of * the socket, starts the registration of at the IRC server by calling * register() and starts the receiving of lines from the server * by starting the thread with the start method.

* This method must be protected, because it is used by extending classes, * which override the connect method. * @param s The socket which is used for the connection. * @throws IOException If an I/O error occurs. * @see #connect() * @see #run() */ protected void prepare(Socket s) throws IOException { if (s == null) throw new SocketException("Socket s is null, not connected"); socket = s; level = 1; s.setSoTimeout(timeout); in = new BufferedReader(new InputStreamReader(s.getInputStream(), encoding)); out = new PrintWriter(new OutputStreamWriter(s.getOutputStream(), encoding)); start(); register(); } // ------------------------------ /** * Registers the connection with the IRC server.
* In fact, it sends a password (if set, else nothing), the nickname and the * user, the realname and the host which we're connecting to.
* The action synchronizes code> so that no important messages * (like the first PING) come in before this registration is finished.
* The USER command's format is:
* <username> <localhost> <irchost> <realname> * */ private void register() { if (pass != null) send("PASS "+ pass); send("NICK "+ nick); send("USER "+ username +" "+ socket.getLocalAddress() +" "+ host +" :"+ realname); } // ------------------------------ /** * The Thread is started by the connect method. * It's task is to receive strings from the IRC server and hand them over * to the get method. */ public void run() { try { String line; while (!isInterrupted()) { line = in.readLine(); if (line != null) get(line); else close(); } } catch (IOException exc) { close(); } } // ------------------------------ /** * Sends a String to the server. * You should use this method only, if you must do it. For most purposes, * there are do* methods (like doJoin). A carriage * return line feed (\r\n) is appended automatically. * @param line The line which should be send to the server without the * trailing carriage return line feed (\r\n). */ public void send(String line) { try { out.write(line +"\r\n"); out.flush(); if (level == 1) { // not registered IRCParser p = new IRCParser(line); if (p.getCommand().equalsIgnoreCase("NICK")) nick = p.getParameter(1).trim(); } } catch (Exception exc) { exc.printStackTrace(); } } // ------------------------------ /** * Just parses a String given as the only argument with the help of the * IRCParser class. Then it controls the command and fires events * through the IRCEventListener.
* @param line The line which is sent from the server. */ private synchronized void get(String line) { IRCParser p; try { p = new IRCParser(line, colorsEnabled); } catch (Exception exc) { return; } String command = p.getCommand(); int reply; // 3-digit reply will be parsed in the later if-condition if (command.equalsIgnoreCase("PRIVMSG")) { // MESSAGE IRCUser user = p.getUser(); String middle = p.getMiddle(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onPrivmsg(middle, user, trailing); } else if (command.equalsIgnoreCase("MODE")) { // MODE String chan = p.getParameter(1); if (IRCUtil.isChan(chan)) { IRCUser user = p.getUser(); String param2 = p.getParameter(2); String paramsFrom3 = p.getParametersFrom(3); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onMode(chan, user, new IRCModeParser(param2, paramsFrom3)); } else { IRCUser user = p.getUser(); String paramsFrom2 = p.getParametersFrom(2); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onMode(user, chan, paramsFrom2); } } else if (command.equalsIgnoreCase("PING")) { // PING String ping = p.getTrailing(); // no int cause sometimes it's text if (pongAutomatic) doPong(ping); else for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onPing(ping); if (level == 1) { // not registered level = 2; // first PING received -> connection for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onRegistered(); } } else if (command.equalsIgnoreCase("JOIN")) { // JOIN IRCUser user = p.getUser(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onJoin(trailing, user); } else if (command.equalsIgnoreCase("NICK")) { // NICK IRCUser user = p.getUser(); String changingNick = p.getNick(); String newNick = p.getTrailing(); if (changingNick.equalsIgnoreCase(nick)) nick = newNick; for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onNick(user, newNick); } else if (command.equalsIgnoreCase("QUIT")) { // QUIT IRCUser user = p.getUser(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onQuit(user, trailing); } else if (command.equalsIgnoreCase("PART")) { // PART IRCUser user = p.getUser(); String chan = p.getParameter(1); String msg = p.getParameterCount() > 1 ? p.getTrailing() : ""; // not logic: "PART :#zentrum" is without msg, "PART #zentrum :cjo all" // is with msg. so we cannot use getMiddle and getTrailing :-/ for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onPart(chan, user, msg); } else if (command.equalsIgnoreCase("NOTICE")) { // NOTICE IRCUser user = p.getUser(); String middle = p.getMiddle(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onNotice(middle, user, trailing); } else if ((reply = IRCUtil.parseInt(command)) >= 1 && reply < 400) { // RPL String potNick = p.getParameter(1); if ((level == 1 || level == 2) && nick.length() > potNick.length() && nick.substring(0, potNick.length()).equalsIgnoreCase(potNick)) { nick = potNick; if (level == 2) level = 3; } if (level == 1) { // not registered level = 2; // if first PING wasn't received, we're for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onRegistered(); // connected now for sure } String middle = p.getMiddle(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onReply(reply, middle, trailing); } else if (reply >= 400 && reply < 600) { // ERROR String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onError(reply, trailing); } else if (command.equalsIgnoreCase("KICK")) { // KICK IRCUser user = p.getUser(); String param1 = p.getParameter(1); String param2 = p.getParameter(2); String msg = (p.getParameterCount() > 2) ? p.getTrailing() : ""; for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onKick(param1, user, param2, msg); } else if (command.equalsIgnoreCase("INVITE")) { // INVITE IRCUser user = p.getUser(); String middle = p.getMiddle(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onInvite(trailing, user, middle); } else if (command.equalsIgnoreCase("TOPIC")) { // TOPIC IRCUser user = p.getUser(); String middle = p.getMiddle(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onTopic(middle, user, trailing); } else if (command.equalsIgnoreCase("ERROR")) { // ERROR String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onError(trailing); } else { // OTHER String prefix = p.getPrefix(); String middle = p.getMiddle(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].unknown(prefix, command, middle, trailing); } } // ------------------------------ /** * Close down the connection brutally.
* It does *NOT* send the proper IRC command QUIT. You should * always use the doQuit methods or send("QUIT") * instead of this method.
* You should use this method to close down the connection only when the IRC * server doesn't react to the QUIT command. * @see #connect() * @see #doQuit * @see #doQuit(String) */ public synchronized void close() { try { if (!isInterrupted()) interrupt(); } catch (Exception exc) { exc.printStackTrace(); } try { if (socket != null) socket.close(); } catch (Exception exc) { exc.printStackTrace(); } try { if (out != null) out.close(); } catch (Exception exc) { exc.printStackTrace(); } try { if (in != null) in.close(); } catch (Exception exc) { exc.printStackTrace(); } if (this.level != -1) { this.level = -1; for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onDisconnected(); } socket = null; in = null; out = null; listeners = new IRCEventListener[0]; } // ------------------------------ /** * Adds a new {@link org.schwering.irc.lib.IRCEventListener} which listens * for actions coming from the IRC server. * @param l An instance of the * {@link org.schwering.irc.lib.IRCEventListener} interface. * @throws IllegalArgumentException If listener is * null. */ public synchronized void addIRCEventListener(IRCEventListener l) { if (l == null) throw new IllegalArgumentException("Listener is null."); int len = listeners.length; IRCEventListener[] oldListeners = listeners; listeners = new IRCEventListener[len + 1]; System.arraycopy(oldListeners, 0, listeners, 0, len); listeners[len] = l; } // ------------------------------ /** * Removes the first occurence of the given * {@link org.schwering.irc.lib.IRCEventListener} from the listener-vector. * @param l An instance of the * {@link org.schwering.irc.lib.IRCEventListener} interface. * @return true if the listener was successfully removed; * false if it was not found. */ public synchronized boolean removeIRCEventListener(IRCEventListener l) { if (l == null) return false; int index = -1; for (int i = 0; i < listeners.length; i++) if (listeners[i].equals(l)) { index = i; break; } if (index == -1) return false; listeners[index] = null; int len = listeners.length - 1; IRCEventListener[] newListeners = new IRCEventListener[len]; for (int i = 0, j = 0; i < len; j++) if (listeners[j] != null) newListeners[i++] = listeners[j]; listeners = newListeners; return true; } // ------------------------------ /** * Enables or disables the mIRC colorcodes. * @param colors true to enable, false to disable * colors. */ public void setColors(boolean colors) { colorsEnabled = colors; } // ------------------------------ /** * Enables or disables the automatic PING? PONG! support. * @param pong true to enable automatic PONG * reply, false makes the class fire * onPing events. */ public void setPong(boolean pong) { pongAutomatic = pong; } // ------------------------------ /** * Changes the character encoding used to talk to the server. * This can be ISO-8859-1 or UTF-8 for example. * This property must be set before a call to the connect() * method. * @param encoding */ public void setEncoding(String encoding) { this.encoding = encoding; } // ------------------------------ /** * Sets the connection's timeout in milliseconds.
* The default is 1000 * 60 15 millis which are 15 minutes. */ public void setTimeout(int millis) { if (socket != null) try { socket.setSoTimeout(millis); } catch (IOException exc) { exc.printStackTrace(); } timeout = millis; } // ------------------------------ /** * Tells whether there's a connection to the IRC network or not.
* If connect wasn't called yet, it returns false. * @return The status of the connection; true if it's connected. * @see #connect() * @see #doQuit() * @see #doQuit(String) * @see #close() */ public boolean isConnected() { return level >= 1; } // ------------------------------ /** * Returns the nickname of this instance. * @return The nickname. */ public String getNick() { return nick; } // ------------------------------ /** * Returns the realname of this instance. * @return The realname. */ public String getRealname() { return realname; } // ------------------------------ /** * Returns the username of this instance. * @return The username. */ public String getUsername() { return username; } // ------------------------------ /** * Returns the server of this instance. * @return The server's hostname. */ public String getHost() { return host; } // ------------------------------ /** * Returns the password of this instance. If no password is set, * null is returned. * @return The password. If no password is set, null is * returned. */ public String getPassword() { return pass; } // ------------------------------ /** * Returns all ports to which the IRCConnection is going to try * or has tried to connect to. * @return The ports in an int[] array. */ public int[] getPorts() { return ports; } // ------------------------------ /** * Returns the port to which the IRCConnection connected, or * 0 if the connection failed or wasn't tried yet. * @return The port to which the IRCConnection, or * 0 if the connection failed or wasn't tried yet. */ public int getPort() { return (socket != null) ? socket.getPort() : 0; } // ------------------------------ /** * Indicates whether colors are stripped out or not. * @return true if colors are disabled. */ public boolean getColors() { return colorsEnabled; } // ------------------------------ /** * Indicates whether automatic PING? PONG! is enabled or not. * @return true if PING? PONG! is done automatically. */ public boolean getPong() { return pongAutomatic; } // ------------------------------ /** * Returns the encoding of the socket. * @return The socket's encoding. */ public String getEncoding() { return encoding; } // ------------------------------ /** * Returns the timeout of the socket.
* If an error occurs, which is never the case, -1 is returned. * @return The timeout. */ public int getTimeout() { if (socket != null) try { return socket.getSoTimeout(); } catch (IOException exc) { exc.printStackTrace(); return -1; } else return timeout; } // ------------------------------ /** * Generates a String with some information about the instance of * IRCConnection. * Its format is: * classname[host,portMin,portMax,username,nick,realname,pass,connected] * . * @return A String with information about the instance. */ public String toString() { return getClass().getName() +"["+ host +","+ getPort() +","+ username +","+ nick +","+ realname +","+ pass +","+ isConnected() +"]"; } // ------------------------------ /** * Removes away message. */ public void doAway() { send("AWAY"); } // ------------------------------ /** * Sets away message. * @param msg The away message. */ public void doAway(String msg) { send("AWAY :"+ msg); } // ------------------------------ /** * Invites a user to a channel. * @param nick The nickname of the user who should be invited. * @param chan The channel the user should be invited to. */ public void doInvite(String nick, String chan) { send("INVITE "+ nick +" "+ chan); } // ------------------------------ /** * Checks if one or more nicks are used on the server. * @param nick The nickname of the user we search for. */ public void doIson(String nick) { send("ISON "+ nick); } // ------------------------------ /** * Joins a channel without a key. * @param chan The channel which is to join. */ public void doJoin(String chan) { send("JOIN "+ chan); } // ------------------------------ /** * Joins a channel with a key. * @param chan The channel which is to join. * @param key The key of the channel. */ public void doJoin(String chan, String key) { send("JOIN "+ chan +" "+ key); } // ------------------------------ /** * Kicks a user from a channel. * @param chan The channel somebody should be kicked from. * @param nick The nickname of the user who should be kicked. */ public void doKick(String chan, String nick) { send("KICK "+ chan +" "+ nick); } // ------------------------------ /** * Kicks a user from a channel with a comment. * @param chan The channel somebody should be kicked from. * @param nick The nickname of the user who should be kicked. * @param msg The optional kickmessage. */ public void doKick(String chan, String nick, String msg) { send("KICK "+ chan +" "+ nick +" :"+ msg); } // ------------------------------ /** * Lists all channels with their topic and status. */ public void doList() { send("LIST"); } // ------------------------------ /** * Lists channel(s) with their topic and status. * @param chan The channel the LIST refers to. */ public void doList(String chan) { send("LIST "+ chan); } // ------------------------------ /** * Lists all visible users. */ public void doNames() { send("NAMES"); } // ------------------------------ /** * Lists all visible users of (a) channel(s). * @param chan The channel the NAMES command is refering to. */ public void doNames(String chan) { send("NAMES "+ chan); } // ------------------------------ /** * Sends a message to a person or a channel. * @param target The nickname or channel the message should be sent to. * @param msg The message which should be transmitted. */ public void doPrivmsg(String target, String msg) { send("PRIVMSG "+ target +" :"+ msg); } // ------------------------------ /** * Requests a Reply 324 for the modes of a given channel. * @param chan The channel the MODE request is refering to. */ public void doMode(String chan) { send("MODE "+ chan); } // ------------------------------ /** * Sends a mode to the server.
* The first argument is a nickname (user-mode) or a channel (channel-mode). * String mode must contain the operators (+/-), the modes * (o/v/i/k/l/p/s/w) and the possibly values (nicks/banmask/limit/key). * @param target The nickname or channel of the user whose modes will be * changed. * @param mode The new modes. */ public void doMode(String target, String mode) { send("MODE "+ target +" "+ mode); } // ------------------------------ /** * Changes the nickname. * @param nick The new nickname. */ public void doNick(String nick) { send("NICK "+ nick); } // ------------------------------ /** * Notices a message to a person or a channel. * @param target The nickname or channel (group) the message should be * sent to. * @param msg The message which should be transmitted. */ public void doNotice(String target, String msg) { send("NOTICE "+ target +" :"+ msg); } // ------------------------------ /** * Parts from a given channel. * @param chan The channel you want to part from. */ public void doPart(String chan) { send("PART "+ chan); } // ------------------------------ /** * Parts from a given channel with a given parg-msg. * @param chan The channel you want to part from. * @param msg The optional partmessage. */ public void doPart(String chan, String msg) { send("PART "+ chan +" :"+ msg); } // ------------------------------ /** * Quits from the IRC server with a quit-msg. * @param ping The ping which was received in onPing. It's a * String, because sometimes on some networks * the server-hostname (for example splatterworld.quakenet.org) is * given as parameter which would throw an Exception if we * gave the ping as long. */ public void doPong(String ping) { send("PONG :"+ ping); } // ------------------------------ /** * Quits from the IRC server. * Calls the disconnect-method which does the work actually. * @see #isConnected() * @see #connect() * @see #doQuit(String) * @see #close() */ public void doQuit() { send("QUIT"); } // ------------------------------ /** * Quits from the IRC server with a quit-msg. * Calls the disconnect-method which does the work actually. * @param msg The optional quitmessage. * @see #isConnected() * @see #connect() * @see #doQuit() * @see #close() */ public void doQuit(String msg) { send("QUIT :"+ msg); } // ------------------------------ /** * Requests the topic of a chan. The topic is given in a numeric reply. * @param chan The channel which topic should be requested. */ public void doTopic(String chan) { send("TOPIC "+ chan); } // ------------------------------ /** * Changes the topic of a chan. * @param chan The channel which topic is changed. * @param topic The new topic. */ public void doTopic(String chan, String topic) { send("TOPIC "+ chan +" :"+ topic); } // ------------------------------ /** * Requests information about users matching the given criteric, * for example a channel they are on. * @param criteric The criterics of the WHO query. */ public void doWho(String criteric) { send("WHO "+ criteric); } // ------------------------------ /** * Requires information about an existing user. * @param nick The nickname of the user the query is refering to. */ public void doWhois(String nick) { send("WHOIS "+ nick); } // ------------------------------ /** * Requires host-information about a user, who is not connected anymore. * @param nick The nickname of the user the query is refering to. */ public void doWhowas(String nick) { send("WHOWAS "+ nick); } // ------------------------------ /** * Requires host-information about up to 5 users which must be listed and * divided by spaces. * @param nick The nickname of the user the query is refering to. */ public void doUserhost(String nick) { send("USERHOST "+ nick); } } libirclib-java-1.10/src/org/schwering/irc/lib/.svn/text-base/IRCConstants.java.svn-base000066400000000000000000001404131155103677700306700ustar00rootroot00000000000000package org.schwering.irc.lib; /** * Contains constants: reply codes, error codes and mIRC color codes. * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 1.00 * @see IRCEventListener#onError(int, String) * @see IRCEventListener#onReply(int, String, String) */ public interface IRCConstants { /** * Usually the first replies when you're connected. */ public static final int RPL_WELCOME = 001; /** * Usually the first replies when you're connected. */ public static final int RPL_YOURHOST = 002; /** * Usually the first replies when you're connected. */ public static final int RPL_CREATED = 003; /** * Usually the first replies when you're connected. */ public static final int RPL_MYINFO = 004; /** * Usually the first replies when you're connected. */ public static final int RPL_ISUPPORT = 005; /** * Used to indicate the nickname parameter supplied to * a command is currently unused. */ public static final int ERR_NOSUCHNICK = 401; /** * Format: "<server name> No such server".
* Used to indicate the server name given currently * doesn't exist. */ public static final int ERR_NOSUCHSERVER = 402; /** * Format: "<channel name> No such channel".
* Used to indicate the given channel name is invalid. */ public static final int ERR_NOSUCHCHANNEL = 403; /** * Format: "<channel name> Cannot send to channel".
* Sent to a user who is either (a) not on a channel * which is mode +n or (b) not a chanop (or mode +v) on * a channel which has mode +m set and is trying to send * a PRIVMSG message to that channel. */ public static final int ERR_CANNOTSENDTOCHAN = 404; /** * Format: "<channel name> You have joined too many * channels".
* Sent to a user when they have joined the maximum * number of allowed channels and they try to join * another channel. */ public static final int ERR_TOOMANYCHANNELS = 405; /** * Format: "<nickname> There was no such nickname".
* Returned by WHOWAS to indicate there is no history * information for that nickname. */ public static final int ERR_WASNOSUCHNICK = 406; /** * Format: "<target> Duplicate recipients. No message delivered".
* Returned to a client which is attempting to send a PRIVMSG/NOTICE using * the user@host destination format and for a user@host which has several * occurrences. */ public static final int ERR_TOOMANYTARGETS = 407; /** * Format: "No origin specified".
* PING or PONG message missing the originator parameter * which is required since these commands must work * without valid prefixes. */ public static final int ERR_NOORIGIN = 409; /** * Format: "No recipient given (<command>)". */ public static final int ERR_NORECIPIENT = 411; /** * Format: "No text to send".
* 412 - 414 are returned by PRIVMSG to indicate that * the message wasn't delivered for some reason. * ERR_NOTOPLEVEL and ERR_WILDTOPLEVEL are errors that * are returned when an invalid use of * "PRIVMSG $<server>" or "PRIVMSG #<host>" is attempted. */ public static final int ERR_NOTEXTTOSEND = 412; /** * Format: "<mask> No toplevel domain specified".
* 412 - 414 are returned by PRIVMSG to indicate that * the message wasn't delivered for some reason. * ERR_NOTOPLEVEL and ERR_WILDTOPLEVEL are errors that * are returned when an invalid use of * "PRIVMSG $<server>" or "PRIVMSG #<host>" is attempted. */ public static final int ERR_NOTOPLEVEL = 413; /** * Format: "<mask> Wildcard in toplevel domain".
* 412 - 414 are returned by PRIVMSG to indicate that * the message wasn't delivered for some reason. * ERR_NOTOPLEVEL and ERR_WILDTOPLEVEL are errors that * are returned when an invalid use of * "PRIVMSG $<server>" or "PRIVMSG #<host>" is attempted. */ public static final int ERR_WILDTOPLEVEL = 414; /** * Format: "<command> Unknown command".
* Returned to a registered client to indicate that the * command sent is unknown by the server. */ public static final int ERR_UNKNOWNCOMMAND = 421; /** * Format: "MOTD File is missing".
* Server's MOTD file could not be opened by the server. */ public static final int ERR_NOMOTD = 422; /** * Format: "<server> No administrative info available".
* Returned by a server in response to an ADMIN message * when there is an error in finding the appropriate * information. */ public static final int ERR_NOADMININFO = 423; /** * Format: "File error doing <file op> on <file>".
* Generic error message used to report a failed file * operation during the processing of a message. */ public static final int ERR_FILEERROR = 424; /** * Format: "No nickname given".
* Returned when a nickname parameter expected for a * command and isn't found. */ public static final int ERR_NONICKNAMEGIVEN = 431; /** * Format: "<nick> Erroneus nickname".
* Returned after receiving a NICK message which contains * characters which do not fall in the defined set. See * section x.x.x for details on valid nicknames. */ public static final int ERR_ERRONEUSNICKNAME = 432; /** * Format: "<nick> Nickname is already in use".
* Returned when a NICK message is processed that results * in an attempt to change to a currently existing * nickname. */ public static final int ERR_NICKNAMEINUSE = 433; /** * Format: "<nick> Nickname collision KILL".
* Returned by a server to a client when it detects a * nickname collision (registered of a NICK that * already exists by another server). */ public static final int ERR_NICKCOLLISION = 436; /** * Format: "<nick> <channel> They aren't on that channel".
* Returned by the server to indicate that the target * user of the command is not on the given channel. */ public static final int ERR_USERNOTINCHANNEL = 441; /** * Format: "<channel> You're not on that channel".
* Returned by the server whenever a client tries to * perform a channel effecting command for which the * client isn't a member. */ public static final int ERR_NOTONCHANNEL = 442; /** * Format: "<user> <channel> is already on channel".
* Returned when a client tries to invite a user to a * channel they are already on. */ public static final int ERR_USERONCHANNEL = 443; /** * Format: "<user> User not logged in".
* Returned by the summon after a SUMMON command for a * user was unable to be performed since they were not * logged in. */ public static final int ERR_NOLOGIN = 444; /** * Format: "SUMMON has been disabled".
* Returned as a response to the SUMMON command. Must be * returned by any server which does not implement it. */ public static final int ERR_SUMMONDISABLED = 445; /** * Format: "USERS has been disabled".
* Returned as a response to the USERS command. Must be * returned by any server which does not implement it. */ public static final int ERR_USERSDISABLED = 446; /** * Format: "You have not registered".
* Returned by the server to indicate that the client * must be registered before the server will allow it * to be parsed in detail. */ public static final int ERR_NOTREGISTERED = 451; /** * Format: "<command> Not enough parameters".
* Returned by the server by numerous commands to * indicate to the client that it didn't supply enough * parameters. */ public static final int ERR_NEEDMOREPARAMS = 461; /** * Format: "You may not reregister".
* Returned by the server to any link which tries to * change part of the registered details (such as * password or user details from second USER message). */ public static final int ERR_ALREADYREGISTRED = 462; /** * Format: "Your host isn't among the privileged".
* Returned to a client which attempts to register with * a server which does not been setup to allow * connections from the host the attempted connection * is tried. */ public static final int ERR_NOPERMFORHOST = 463; /** * Format: "Password incorrect".
* Returned to indicate a failed attempt at registering * a connection for which a password was required and * was either not given or incorrect. */ public static final int ERR_PASSWDMISMATCH = 464; /** * Format: "You are banned from this server".
* Returned after an attempt to connect and register * yourself with a server which has been setup to * explicitly deny connections to you. */ public static final int ERR_YOUREBANNEDCREEP = 465; /** * Format: "<channel> Channel key already set". */ public static final int ERR_KEYSET = 467; /** * Format: "<channel> Cannot join channel (+l)". */ public static final int ERR_CHANNELISFULL = 471; /** * Format: "<char> is unknown mode char to me". */ public static final int ERR_UNKNOWNMODE = 472; /** * Format: "<channel> Cannot join channel (+i)". */ public static final int ERR_INVITEONLYCHAN = 473; /** * Format: "<channel> Cannot join channel (+b)". */ public static final int ERR_BANNEDFROMCHAN = 474; /** * Format: "<channel> Cannot join channel (+k)". */ public static final int ERR_BADCHANNELKEY = 475; /** * Format: "Permission Denied- You're not an IRC operator". * Any command requiring operator privileges to operate * must return this error to indicate the attempt was * unsuccessful. */ public static final int ERR_NOPRIVILEGES = 481; /** * Format: "<channel> You're not channel operator".
* Any command requiring 'chanop' privileges (such as * MODE messages) must return this error if the client * making the attempt is not a chanop on the specified * channel. */ public static final int ERR_CHANOPRIVSNEEDED = 482; /** * Format: "You cant kill a server!".
* Any attempts to use the KILL command on a server * are to be refused and this error returned directly * to the client. */ public static final int ERR_CANTKILLSERVER = 483; /** * Format: "No O-lines for your host".
* If a client sends an OPER message and the server has * not been configured to allow connections from the * client's host as an operator, this error must be * returned. */ public static final int ERR_NOOPERHOST = 491; /** * Format: "Unknown MODE flag".
* Returned by the server to indicate that a MODE * message was sent with a nickname parameter and that * the a mode flag sent was not recognized. */ public static final int ERR_UMODEUNKNOWNFLAG = 501; /** * Format: "Cant change mode for other users".
* Error sent to any user trying to view or change the * user mode for a user other than themselves. */ public static final int ERR_USERSDONTMATCH = 502; /** * Dummy reply number. Not used. */ public static final int RPL_NONE = 300; /** * Format: "[<reply>{<space><reply>}]".
* Reply format used by USERHOST to list replies to * the query list. The reply string is composed as * follows:
* <reply> ::= <nick>['*'] '=' <'+'|'-'><hostname> *
* The '*' indicates whether the client has registered * as an Operator. The '-' or '+' characters represent * whether the client has set an AWAY message or not * respectively. */ public static final int RPL_USERHOST = 302; /** * Format: "[<nick> {<space><nick>}]".
* Reply format used by ISON to list replies to the * query list. */ public static final int RPL_ISON = 303; /** * Format: "<nick> <away message>". */ public static final int RPL_AWAY = 301; /** * Format: "You are no longer marked as being away". */ public static final int RPL_UNAWAY = 305; /** * Format: "You have been marked as being away".
* These replies are used with the AWAY command (if * allowed). RPL_AWAY is sent to any client sending a * PRIVMSG to a client which is away. RPL_AWAY is only * sent by the server to which the client is connected. * Replies RPL_UNAWAY and RPL_NOWAWAY are sent when the * client removes and sets an AWAY message. */ public static final int RPL_NOWAWAY = 306; /** * Format: "<nick> <user> <host> * :<real name>". *
* Replies 311 - 313, 317 - 319 are all replies * generated in response to a WHOIS message. Given that * there are enough parameters present, the answering * server must either formulate a reply out of the above * numerics (if the query nick is found) or return an * error reply. The '*' in RPL_WHOISUSER is there as * the literal character and not as a wild card. For * each reply set, only RPL_WHOISCHANNELS may appear * more than once (for long lists of channel names). * The '@' and '+' characters next to the channel name * indicate whether a client is a channel operator or * has been granted permission to speak on a moderated * channel. The RPL_ENDOFWHOIS reply is used to mark * the end of processing a WHOIS message. */ public static final int RPL_WHOISUSER = 311; /** * Format: "<nick> <server> <server info>".
* Replies 311 - 313, 317 - 319 are all replies * generated in response to a WHOIS message. Given that * there are enough parameters present, the answering * server must either formulate a reply out of the above * numerics (if the query nick is found) or return an * error reply. The '*' in RPL_WHOISUSER is there as * the literal character and not as a wild card. For * each reply set, only RPL_WHOISCHANNELS may appear * more than once (for long lists of channel names). * The '@' and '+' characters next to the channel name * indicate whether a client is a channel operator or * has been granted permission to speak on a moderated * channel. The RPL_ENDOFWHOIS reply is used to mark * the end of processing a WHOIS message. */ public static final int RPL_WHOISSERVER = 312; /** * Format: "<nick> is an IRC operator".
* Replies 311 - 313, 317 - 319 are all replies * generated in response to a WHOIS message. Given that * there are enough parameters present, the answering * server must either formulate a reply out of the above * numerics (if the query nick is found) or return an * error reply. The '*' in RPL_WHOISUSER is there as * the literal character and not as a wild card. For * each reply set, only RPL_WHOISCHANNELS may appear * more than once (for long lists of channel names). * The '@' and '+' characters next to the channel name * indicate whether a client is a channel operator or * has been granted permission to speak on a moderated * channel. The RPL_ENDOFWHOIS reply is used to mark * the end of processing a WHOIS message. */ public static final int RPL_WHOISOPERATOR = 313; /** * Format: "<nick> <integer> seconds idle".
* Replies 311 - 313, 317 - 319 are all replies * generated in response to a WHOIS message. Given that * there are enough parameters present, the answering * server must either formulate a reply out of the above * numerics (if the query nick is found) or return an * error reply. The '*' in RPL_WHOISUSER is there as * the literal character and not as a wild card. For * each reply set, only RPL_WHOISCHANNELS may appear * more than once (for long lists of channel names). * The '@' and '+' characters next to the channel name * indicate whether a client is a channel operator or * has been granted permission to speak on a moderated * channel. The RPL_ENDOFWHOIS reply is used to mark * the end of processing a WHOIS message. */ public static final int RPL_WHOISIDLE = 317; /** * Format: "<nick> End of /WHOIS list".
* Replies 311 - 313, 317 - 319 are all replies * generated in response to a WHOIS message. Given that * there are enough parameters present, the answering * server must either formulate a reply out of the above * numerics (if the query nick is found) or return an * error reply. The '*' in RPL_WHOISUSER is there as * the literal character and not as a wild card. For * each reply set, only RPL_WHOISCHANNELS may appear * more than once (for long lists of channel names). * The '@' and '+' characters next to the channel name * indicate whether a client is a channel operator or * has been granted permission to speak on a moderated * channel. The RPL_ENDOFWHOIS reply is used to mark * the end of processing a WHOIS message. */ public static final int RPL_ENDOFWHOIS = 318; /** * Format: "<nick> {[@|+]<channel><space>}".
* Replies 311 - 313, 317 - 319 are all replies * generated in response to a WHOIS message. Given that * there are enough parameters present, the answering * server must either formulate a reply out of the above * numerics (if the query nick is found) or return an * error reply. The '*' in RPL_WHOISUSER is there as * the literal character and not as a wild card. For * each reply set, only RPL_WHOISCHANNELS may appear * more than once (for long lists of channel names). * The '@' and '+' characters next to the channel name * indicate whether a client is a channel operator or * has been granted permission to speak on a moderated * channel. The RPL_ENDOFWHOIS reply is used to mark * the end of processing a WHOIS message. */ public static final int RPL_WHOISCHANNELS = 319; /** * Format: "<nick> <user> <host> * <real name>". */ public static final int RPL_WHOWASUSER = 314; /** * Format: "<nick> End of WHOWAS".
* When replying to a WHOWAS message, a server must use * the replies RPL_WHOWASUSER, RPL_WHOISSERVER or * ERR_WASNOSUCHNICK for each nickname in the presented * list. At the end of all reply batches, there must * be RPL_ENDOFWHOWAS (even if there was only one reply * and it was an error). */ public static final int RPL_ENDOFWHOWAS = 369; /** * Format: "Channel Users Name".
* Replies RPL_LISTSTART, RPL_LIST, RPL_LISTEND mark * the start, actual replies with data and end of the * server's response to a LIST command. If there are * no channels available to return, only the start * and end reply must be sent. */ public static final int RPL_LISTSTART = 321; /** * Format: "<channel> <# visible> <topic>".
* Replies RPL_LISTSTART, RPL_LIST, RPL_LISTEND mark * the start, actual replies with data and end of the * server's response to a LIST command. If there are * no channels available to return, only the start * and end reply must be sent. */ public static final int RPL_LIST = 322; /** * Format: "End of /LIST".
* Replies RPL_LISTSTART, RPL_LIST, RPL_LISTEND mark * the start, actual replies with data and end of the * server's response to a LIST command. If there are * no channels available to return, only the start * and end reply must be sent. */ public static final int RPL_LISTEND = 323; /** * Format: "<channel> <mode> <mode params>".
*/ public static final int RPL_CHANNELMODEIS = 324; /** * Format: "<nick> <authname> is authed as"
* This is part of /WHOIS on many servers which provide bots to authenticate. */ public static final int RPL_AUTHNAME = 333; /** * Format: "<channel> No topic is set".
* When sending a TOPIC message to determine the * channel topic, one of two replies is sent. If * the topic is set, RPL_TOPIC is sent back else * public static final int RPL_NOTOPIC. */ public static final int RPL_NOTOPIC = 331; /** * Format: "<channel> <topic>".
* When sending a TOPIC message to determine the * channel topic, one of two replies is sent. If * the topic is set, RPL_TOPIC is sent back else * public static final int RPL_NOTOPIC. */ public static final int RPL_TOPIC = 332; /** * Format: "<channel> <nick-who-set-topic> <seconds>". * The seconds are not milliseconds; just multiply it with 1000 and then * format a date with it. */ public static final int RPL_TOPICINFO = 333; /** * Format: "<channel> <nick>".
* Returned by the server to indicate that the * attempted INVITE message was successful and is * being passed onto the end client. */ public static final int RPL_INVITING = 341; /** * Format: "<user> Summoning user to IRC".
* Returned by a server answering a SUMMON message to * indicate that it is summoning that user. */ public static final int RPL_SUMMONING = 342; /** * Format: "<version>.<debuglevel> <server> * <comments>".
* Reply by the server showing its version details. * The <version> is the version of the software being * used (including any patchlevel revisions) and the * <debuglevel> is used to indicate if the server is * running in "debug mode".
* The "comments" field may contain any comments about * the version or further version details. */ public static final int RPL_VERSION = 351; /** * Format: "<channel> <user> <host> <server> * <nick> <H|G>[*][@|+] <hopcount> <real name>".
* The RPL_WHOREPLY and RPL_ENDOFWHO pair are used * to answer a WHO message. The RPL_WHOREPLY is only * sent if there is an appropriate match to the WHO * query. If there is a list of parameters supplied * with a WHO message, a RPL_ENDOFWHO must be sent * after processing each list item with <name> being * the item. */ public static final int RPL_WHOREPLY = 352; /** * Format: "<name> End of /WHO list".
* The RPL_WHOREPLY and RPL_ENDOFWHO pair are used * to answer a WHO message. The RPL_WHOREPLY is only * sent if there is an appropriate match to the WHO * query. If there is a list of parameters supplied * with a WHO message, a RPL_ENDOFWHO must be sent * after processing each list item with <name> being * the item. */ public static final int RPL_ENDOFWHO = 315; /** * Format: "<channel> [[@|+]<nick> [[@|+]<nick> * [...]]]".
* To reply to a NAMES message, a reply pair consisting * of RPL_NAMREPLY and RPL_ENDOFNAMES is sent by the * server back to the client. If there is no channel * found as in the query, then only RPL_ENDOFNAMES is * returned. The exception to this is when a NAMES * message is sent with no parameters and all visible * channels and contents are sent back in a series of * RPL_NAMEREPLY messages with a RPL_ENDOFNAMES to mark * the end. */ public static final int RPL_NAMREPLY = 353; /** * Format: "<channel> End of /NAMES list".
* To reply to a NAMES message, a reply pair consisting * of RPL_NAMREPLY and RPL_ENDOFNAMES is sent by the * server back to the client. If there is no channel * found as in the query, then only RPL_ENDOFNAMES is * returned. The exception to this is when a NAMES * message is sent with no parameters and all visible * channels and contents are sent back in a series of * RPL_NAMEREPLY messages with a RPL_ENDOFNAMES to mark * the end. */ public static final int RPL_ENDOFNAMES = 366; /** * Format: "<mask> <server> <hopcount> <server info>". *
* In replying to the LINKS message, a server must send * replies back using the RPL_LINKS numeric and mark the * end of the list using an RPL_ENDOFLINKS reply. */ public static final int RPL_LINKS = 364; /** * Format: "<mask> End of /LINKS list".
* In replying to the LINKS message, a server must send * replies back using the RPL_LINKS numeric and mark the * end of the list using an RPL_ENDOFLINKS reply. */ public static final int RPL_ENDOFLINKS = 365; /** * Format: "<channel> <banid>".
* When listing the active 'bans' for a given channel, * a server is required to send the list back using the * RPL_BANLIST and RPL_ENDOFBANLIST messages. A separate * RPL_BANLIST is sent for each active banid. After the * banids have been listed (or if none present) a * RPL_ENDOFBANLIST must be sent. */ public static final int RPL_BANLIST = 367; /** * Format: "<channel> End of channel ban list".
* When listing the active 'bans' for a given channel, * a server is required to send the list back using the * RPL_BANLIST and RPL_ENDOFBANLIST messages. A separate * RPL_BANLIST is sent for each active banid. After the * banids have been listed (or if none present) a * RPL_ENDOFBANLIST must be sent. */ public static final int RPL_ENDOFBANLIST = 368; /** * Format: "<string>".
* A server responding to an INFO message is required to * send all its 'info' in a series of RPL_INFO messages * with a RPL_ENDOFINFO reply to indicate the end of the * replies. */ public static final int RPL_INFO = 371; /** * Format: "End of /INFO list".
* A server responding to an INFO message is required to * send all its 'info' in a series of RPL_INFO messages * with a RPL_ENDOFINFO reply to indicate the end of the * replies. */ public static final int RPL_ENDOFINFO = 374; /** * Format: "- <server> Message of the day - ".
* When responding to the MOTD message and the MOTD file * is found, the file is displayed line by line, with * each line no longer than 80 characters, using * RPL_MOTD format replies. These should be surrounded * by a RPL_MOTDSTART (before the RPL_MOTDs) and an * RPL_ENDOFMOTD (after). */ public static final int RPL_MOTDSTART = 375; /** * Format: "- <text>".
* When responding to the MOTD message and the MOTD file * is found, the file is displayed line by line, with * each line no longer than 80 characters, using * RPL_MOTD format replies. These should be surrounded * by a RPL_MOTDSTART (before the RPL_MOTDs) and an * RPL_ENDOFMOTD (after). */ public static final int RPL_MOTD = 372; /** * Format: "End of /MOTD command".
* When responding to the MOTD message and the MOTD file * is found, the file is displayed line by line, with * each line no longer than 80 characters, using * RPL_MOTD format replies. These should be surrounded * by a RPL_MOTDSTART (before the RPL_MOTDs) and an * RPL_ENDOFMOTD (after). */ public static final int RPL_ENDOFMOTD = 376; /** * Format: "You are now an IRC operator".
* RPL_YOUREOPER is sent back to a client which has * just successfully issued an OPER message and gained * operator status. */ public static final int RPL_YOUREOPER = 381; /** * Format: "<config file> Rehashing".
* If the REHASH option is used and an operator sends * a REHASH message, an RPL_REHASHING is sent back to * the operator. */ public static final int RPL_REHASHING = 382; /** * Format: "<server> <string showing server's local time>".
* When replying to the TIME message, a server must send * the reply using the RPL_TIME format above. The string * showing the time need only contain the correct day and * time there. There is no further requirement for the * time string. */ public static final int RPL_TIME = 391; /** * Format: "UserID Terminal Host".
* If the USERS message is handled by a server, the * replies RPL_USERSTART, RPL_USERS, RPL_ENDOFUSERS and * RPL_NOUSERS are used. RPL_USERSSTART must be sent * first, following by either a sequence of RPL_USERS * or a single RPL_NOUSER. Following this is * RPL_ENDOFUSERS. */ public static final int RPL_USERSSTART = 392; /** * Format: "%-8s %-9s %-8s".
* If the USERS message is handled by a server, the * replies RPL_USERSTART, RPL_USERS, RPL_ENDOFUSERS and * RPL_NOUSERS are used. RPL_USERSSTART must be sent * first, following by either a sequence of RPL_USERS * or a single RPL_NOUSER. Following this is * RPL_ENDOFUSERS. */ public static final int RPL_USERS = 393; /** * Format: "End of users".
* If the USERS message is handled by a server, the * replies RPL_USERSTART, RPL_USERS, RPL_ENDOFUSERS and * RPL_NOUSERS are used. RPL_USERSSTART must be sent * first, following by either a sequence of RPL_USERS * or a single RPL_NOUSER. Following this is * RPL_ENDOFUSERS. */ public static final int RPL_ENDOFUSERS = 394; /** * Format: "Nobody logged in".
* If the USERS message is handled by a server, the * replies RPL_USERSTART, RPL_USERS, RPL_ENDOFUSERS and * RPL_NOUSERS are used. RPL_USERSSTART must be sent * first, following by either a sequence of RPL_USERS * or a single RPL_NOUSER. Following this is * RPL_ENDOFUSERS. */ public static final int RPL_NOUSERS = 395; /** * Format: "Link <version & debug level> <destination> * <next server>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACELINK = 200; /** * Format: "Try. <class> <server>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACECONNECTING = 201; /** * Format: "H.S. <class> <server>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACEHANDSHAKE = 202; /** * Format: "???? <class> [<client IP address in dot form>]".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACEUNKNOWN = 203; /** * Format: "Oper <class> <nick>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACEOPERATOR = 204; /** * Format: "User <class> <nick>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACEUSER = 205; /** * Format: "Serv <class> <int>S <int>C <server> * <nick!user|*!*>@<host|server>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACESERVER = 206; /** * Format: "<newtype> 0 <client name>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACENEWTYPE = 208; /** * Format: "File <logfile> <debug level>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACELOG = 261; /** * Format: "<linkname> <sendq> <sent messages> * <sent bytes> <received messages> * <received bytes> <time open>". */ public static final int RPL_STATSLINKINFO = 211; /** * Format: "<command> <count>". */ public static final int RPL_STATSCOMMANDS = 212; /** * Format: "C <host> * <name> <port> <class>". */ public static final int RPL_STATSCLINE = 213; /** * Format: "N <host> * <name> <port> <class>". */ public static final int RPL_STATSNLINE = 214; /** * Format: "I <host> * <host> <port> <class>". */ public static final int RPL_STATSILINE = 215; /** * Format: "K <host> * <username> <port> <class>". */ public static final int RPL_STATSKLINE = 216; /** * Format: "Y <class> <ping frequency> <connect * frequency> <max sendq>". */ public static final int RPL_STATSYLINE = 218; /** * Format: "<stats letter> End of /STATS report". */ public static final int RPL_ENDOFSTATS = 219; /** * Format: "L <hostmask> * <servername> <maxdepth>". */ public static final int RPL_STATSLLINE = 241; /** * Format: "Server Up %d days %d:%02d:%02d". */ public static final int RPL_STATSUPTIME = 242; /** * Format: "O <hostmask> * <name>" */ public static final int RPL_STATSOLINE = 243; /** * Format: "H <hostmask> * <servername>". */ public static final int RPL_STATSHLINE = 244; /** * Format: "<user mode string>".
* To answer a query about a client's own mode, * RPL_UMODEIS is sent back. */ public static final int RPL_UMODEIS = 221; /** * Format: "There are <integer> users and <integer> * invisible on <integer> servers".
* In processing an LUSERS message, the server * sends a set of replies from RPL_LUSERCLIENT, * RPL_LUSEROP, RPL_USERUNKNOWN, * RPL_LUSERCHANNELS and RPL_LUSERME. When * replying, a server must send back * RPL_LUSERCLIENT and RPL_LUSERME. The other * replies are only sent back if a non-zero count * is found for them. */ public static final int RPL_LUSERCLIENT = 251; /** * Format: "<integer> operator(s) online".
* In processing an LUSERS message, the server * sends a set of replies from RPL_LUSERCLIENT, * RPL_LUSEROP, RPL_USERUNKNOWN, * RPL_LUSERCHANNELS and RPL_LUSERME. When * replying, a server must send back * RPL_LUSERCLIENT and RPL_LUSERME. The other * replies are only sent back if a non-zero count * is found for them. */ public static final int RPL_LUSEROP = 252; /** * Format: "<integer> unknown connection(s)".
* In processing an LUSERS message, the server * sends a set of replies from RPL_LUSERCLIENT, * RPL_LUSEROP, RPL_USERUNKNOWN, * RPL_LUSERCHANNELS and RPL_LUSERME. When * replying, a server must send back * RPL_LUSERCLIENT and RPL_LUSERME. The other * replies are only sent back if a non-zero count * is found for them. */ public static final int RPL_LUSERUNKNOWN = 253; /** * Format: "<integer> channels formed".
* In processing an LUSERS message, the server * sends a set of replies from RPL_LUSERCLIENT, * RPL_LUSEROP, RPL_USERUNKNOWN, * RPL_LUSERCHANNELS and RPL_LUSERME. When * replying, a server must send back * RPL_LUSERCLIENT and RPL_LUSERME. The other * replies are only sent back if a non-zero count * is found for them. */ public static final int RPL_LUSERCHANNELS = 254; /** * Format: "I have <integer> clients and <integer> * servers".
* In processing an LUSERS message, the server * sends a set of replies from RPL_LUSERCLIENT, * RPL_LUSEROP, RPL_USERUNKNOWN, * RPL_LUSERCHANNELS and RPL_LUSERME. When * replying, a server must send back * RPL_LUSERCLIENT and RPL_LUSERME. The other * replies are only sent back if a non-zero count * is found for them. */ public static final int RPL_LUSERME = 255; /** * Format: "<server> Administrative info".
* When replying to an ADMIN message, a server * is expected to use replies RLP_ADMINME * through to RPL_ADMINEMAIL and provide a text * message with each. For RPL_ADMINLOC1 a * description of what city, state and country * the server is in is expected, followed by * details of the university and department * (RPL_ADMINLOC2) and finally the administrative * contact for the server (an email address here * is required) in RPL_ADMINEMAIL. */ public static final int RPL_ADMINME = 256; /** * Format: "<admin info>".
* When replying to an ADMIN message, a server * is expected to use replies RLP_ADMINME * through to RPL_ADMINEMAIL and provide a text * message with each. For RPL_ADMINLOC1 a * description of what city, state and country * the server is in is expected, followed by * details of the university and department * (RPL_ADMINLOC2) and finally the administrative * contact for the server (an email address here * is required) in RPL_ADMINEMAIL. */ public static final int RPL_ADMINLOC1 = 257; /** * Format: "<admin info>".
* When replying to an ADMIN message, a server * is expected to use replies RLP_ADMINME * through to RPL_ADMINEMAIL and provide a text * message with each. For RPL_ADMINLOC1 a * description of what city, state and country * the server is in is expected, followed by * details of the university and department * (RPL_ADMINLOC2) and finally the administrative * contact for the server (an email address here * is required) in RPL_ADMINEMAIL. */ public static final int RPL_ADMINLOC2 = 258; /** * Format: "<admin info>".
* When replying to an ADMIN message, a server * is expected to use replies RLP_ADMINME * through to RPL_ADMINEMAIL and provide a text * message with each. For RPL_ADMINLOC1 a * description of what city, state and country * the server is in is expected, followed by * details of the university and department * (RPL_ADMINLOC2) and finally the administrative * contact for the server (an email address here * is required) in RPL_ADMINEMAIL. */ public static final int RPL_ADMINEMAIL = 259; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_TRACECLASS = 209; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_STATSQLINE = 217; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_SERVICEINFO = 231; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_ENDOFSERVICES = 232; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_SERVICE = 233; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_SERVLIST = 234; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_SERVLISTEND = 235; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_WHOISCHANOP = 316; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_KILLDONE = 361; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_CLOSING = 362; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_CLOSEEND = 363; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_INFOSTART = 373; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_MYPORTIS = 384; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int ERR_YOUWILLBEBANNED = 466; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int ERR_BADCHANMASK = 476; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int ERR_NOSERVICEHOST = 492; /** * This is part of the mIRC code and shows that a color-code starts / ends. * Here it is as the ASCII decimal int 3. */ public static final char COLOR_INDICATOR = 3; // ASCII code /** * This is part of the mIRC code and shows that bold starts / ends. * Here it is as the ASCII decimal int 32. */ public static final char BOLD_INDICATOR = 31; // ASCII code /** * This is part of the mIRC code and shows that bold starts / ends. * Here it is as the ASCII decimal int 2. */ public static final char UNDERLINE_INDICATOR = 2; // ASCII code /** * This is part of the mIRC code and shows that bold, underline and colors * end. * Here it is as the ASCII decimal int 15. */ public static final char COLOR_END_INDICATOR = 15; // ASCII code /** * This is part of the mIRC code and indicates that the client's colors are * reversed (background -> foreground and foreground -> background). * Here it is as the ASCII decimal int 1. */ public static final char COLOR_REVERSE_INDICATOR = 22; // ASCII code /** * This is part of the mIRC code and shows that a PRIVMSG is an ACTION * (/me). * Here it is as the ASCII decimal int 22. */ public static final char ACTION_INDICATOR = 1; // ASCII code } libirclib-java-1.10/src/org/schwering/irc/lib/.svn/text-base/IRCEventAdapter.java.svn-base000066400000000000000000000225671155103677700313070ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class IRCEventAdapter * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; /** * Adapts the events of the IRCEventListener interface. *

* Supported events: *

    *
  • Connect
  • *
  • Disconnect
  • *
  • Error
  • *
  • Invite
  • *
  • Join
  • *
  • Kick
  • *
  • Private Message
  • *
  • Mode (Chan)
  • *
  • Mode (User)
  • *
  • Nick
  • *
  • Notice
  • *
  • Numeric Reply
  • *
  • Numeric Error
  • *
  • Part
  • *
  • Ping
  • *
  • Quit
  • *
  • Topic
  • *
*

* For other, unkown events there's the unknown-method. * @author Christoph Schwering <schwering@gmail.com> * @version 1.63 * @see IRCEventListener */ public class IRCEventAdapter implements IRCEventListener { /** * The default and only constructor does nothing. */ public IRCEventAdapter() { // nothing } // ------------------------------ /** * Fired when the own connection is successfully established. * This is the case when the first PING? is received.
* This happens between the connection is opened with a socket and the * connection is registered: The client sends his information to the server * (nickname, username). The server says hello to you by sending you * some NOTICEs. And if your nickname is invalid or in use or * anything else is wrong with your nickname, it asks you for a new one. */ public void onRegistered() { // nothing } // ------------------------------ /** * Fired when the own connection is broken. */ public void onDisconnected() { // nothing } // ------------------------------ /** * Fired when an ERROR command is received. * @param msg The message of the error. */ public void onError(String msg) { // nothing } // ------------------------------ /** * Fired when a numeric error is received. * The server often sends numeric errors (wrong nickname etc.). * The msg's format is different for every reply. All replies' * formats are described in the {@link org.schwering.irc.lib.IRCUtil}. * @param num The identifier (usually a 3-digit number). * @param msg The message of the error. */ public void onError(int num, String msg) { // nothing } // ------------------------------ /** * Fired when somebody is invited to a channel. * @param chan The channel the user is invited to. * @param user The user who invites another. Contains nick, username and host. * @param passiveNick The nickname of the user who is invited by another user * (passive). */ public void onInvite(String chan, IRCUser user, String passiveNick) { // nothing } // ------------------------------ /** * Fired when somebody joins a channel. * @param chan The channel the person joins. * @param user The user who joins. Contains nick, username and host. */ public void onJoin(String chan, IRCUser user) { // nothing } // ------------------------------ /** * Fired when somebody is kicked from a channel. * @param chan The channel somebody is kicked from. * @param user The user who kicks another user from a channel. * Contains nick, username and host. * @param passiveNick The nickname of the user who is kicked from a channel * (passive). * @param msg The message the active user has set. This is "" if * no message was set. */ public void onKick(String chan, IRCUser user, String passiveNick, String msg) { // nothing } // ------------------------------ /** * Fired when an operator changes the modes of a channel. * For example, he can set somebody as an operator, too, or take him the * oper-status. * Also keys, moderated and other channelmodes are fired here. * @param chan The channel in which the modes are changed. * @param user The user who changes the modes. * Contains nick, username and host. * @param modeParser The IRCModeParser object which contains the * parsed information about the modes which are changed. */ public void onMode(String chan, IRCUser user, IRCModeParser modeParser) { // nothing } // ------------------------------ /** * Fired when somebody changes somebody's usermodes. * Note that this event is not fired when a channel-mode is set, for example * when someone sets another user as operator or the mode moderated. * @param user The user who changes the modes of another user or himself. * Contains nick, username and host. * @param passiveNick The nickname of the person whose modes are changed by * another user or himself. * @param mode The changed modes which are set. */ public void onMode(IRCUser user, String passiveNick, String mode) { // nothing } // ------------------------------ /** * Fired when somebody changes his nickname successfully. * @param user The user who changes his nickname. * Contains nick, username and host. * @param newNick The new nickname of the user who changes his nickname. */ public void onNick(IRCUser user, String newNick) { // nothing } // ------------------------------ /** * Fired when somebody sends a NOTICE to a user or a group. * @param target The channel or nickname the user sent a NOTICE * to. * @param user The user who notices another person or a group. * Contains nick, username and host. * @param msg The message. */ public void onNotice(String target, IRCUser user, String msg) { // nothing } // ------------------------------ /** * Fired when somebody parts from a channel. * @param chan The channel somebody parts from. * @param user The user who parts from a channel. * Contains nick, username and host. * @param msg The part-message which is optionally. * If it's empty, msg is "". */ public void onPart(String chan, IRCUser user, String msg) { // nothing } // ------------------------------ /** * Fired when a PING comes in. * The IRC server tests in different periods if the client is still there by * sending PING <ping>. The client must response PONG <ping>. * @param ping The ping which is received from the server. */ public void onPing(String ping) { // nothing } // ------------------------------ /** * Fired when a user sends a PRIVMSG to a user or to a * group. * @param target The channel or nickname the user sent a PRIVMSG * to. * @param user The user who sent the PRIVMSG. * Contains nick, username and host. * @param msg The message the user transmits. */ public void onPrivmsg(String target, IRCUser user, String msg) { // nothing } // ------------------------------ /** * Fired when somebody quits from the network. * @param user The user who quits. Contains nick, username and host. * @param msg The optional message. "" if no message is set by * the user. */ public void onQuit(IRCUser user, String msg) { // nothing } // ------------------------------ /** * Fired when a numeric reply is received. * For example, WHOIS queries are answered by the server with * numeric replies. * The msg's format is different for every reply. All replies' * formats are described in the {@link org.schwering.irc.lib.IRCUtil}. * The first word in the value is always your own nickname! * @param num The numeric reply. * @param value The first part of the message. * @param msg The main part of the message. */ public void onReply(int num, String value, String msg) { // nothing } // ------------------------------ /** * Fired when the topic is changed by operators. * Note that the topic is given as a numeric reply fired in * onReply when you join a channel. * @param chan The channel where the topic is changed. * @param user The user who changes the topic. * Contains nick, username and host. * @param topic The new topic. */ public void onTopic(String chan, IRCUser user, String topic) { // nothing } // ------------------------------ /** * This event is fired when the incoming line can not be identified as a known * event. * @param prefix The prefix of the incoming line. * @param command The command of the incoming line. * @param middle The part until the colon (:). * @param trailing The part behind the colon (:). */ public void unknown(String prefix, String command, String middle, String trailing) { // nothing } } libirclib-java-1.10/src/org/schwering/irc/lib/.svn/text-base/IRCEventListener.java.svn-base000066400000000000000000000223101155103677700314760ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class IRCEventListener * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; import java.util.EventListener; /** * Used as listener for incoming events like messages. *

* The IRCEventListener is used by the * IRCConnection.addEventListener(IRCEventListener) method to add * a listener which listens to the connection for incoming IRC events like * PRIVMSGs or numeric replies. *

* Supported events: *

    *
  • Connect
  • *
  • Disconnect
  • *
  • Error
  • *
  • Invite
  • *
  • Join
  • *
  • Kick
  • *
  • Private Message
  • *
  • Mode (Chan)
  • *
  • Mode (User)
  • *
  • Nick
  • *
  • Notice
  • *
  • Numeric Reply
  • *
  • Numeric Error
  • *
  • Part
  • *
  • Ping
  • *
  • Quit
  • *
  • Topic
  • *
*

* For other, unkown events there's the unknown-method. * @author Christoph Schwering <schwering@gmail.com> * @version 1.64 * @see IRCEventAdapter * @see IRCConnection */ public interface IRCEventListener extends EventListener, IRCConstants { /** * Fired when the own connection is successfully established. * This is the case when the first PING? is received.
* This happens between the connection is opened with a socket and the * connection is registered: The client sends his information to the server * (nickname, username). The server says hello to you by sending you * some NOTICEs. And if your nickname is invalid or in use or * anything else is wrong with your nickname, it asks you for a new one. */ public void onRegistered(); // ------------------------------ /** * Fired when the own connection is broken. */ public void onDisconnected(); // ------------------------------ /** * Fired when an ERROR command is received. * @param msg The message of the error. */ public void onError(String msg); // ------------------------------ /** * Fired when a numeric error is received. * The server often sends numeric errors (wrong nickname etc.). * The msg's format is different for every reply. All replies' * formats are described in the {@link org.schwering.irc.lib.IRCUtil}. * @param num The identifier (usually a 3-digit number). * @param msg The message of the error. */ public void onError(int num, String msg); // ------------------------------ /** * Fired when somebody is invited to a channel. * @param chan The channel the user is invited to. * @param user The user who invites another. Contains nick, username and host. * @param passiveNick The nickname of the user who is invited by another user * (passive). */ public void onInvite(String chan, IRCUser user, String passiveNick); // ------------------------------ /** * Fired when somebody joins a channel. * @param chan The channel the person joins. * @param user The user who joins. Contains nick, username and host. */ public void onJoin(String chan, IRCUser user); // ------------------------------ /** * Fired when somebody is kicked from a channel. * @param chan The channel somebody is kicked from. * @param user The user who kicks another user from a channel. * Contains nick, username and host. * @param passiveNick The nickname of the user who is kicked from a channel * (passive). * @param msg The message the active user has set. This is "" if * no message was set. */ public void onKick(String chan, IRCUser user, String passiveNick, String msg); // ------------------------------ /** * Fired when an operator changes the modes of a channel. * For example, he can set somebody as an operator, too, or take him the * oper-status. * Also keys, moderated and other channelmodes are fired here. * @param chan The channel in which the modes are changed. * @param user The user who changes the modes. * Contains nick, username and host. * @param modeParser The IRCModeParser object which contains the * parsed information about the modes which are changed. */ public void onMode(String chan, IRCUser user, IRCModeParser modeParser); // ------------------------------ /** * Fired when somebody changes somebody's usermodes. * Note that this event is not fired when a channel-mode is set, for example * when someone sets another user as operator or the mode moderated. * @param user The user who changes the modes of another user or himself. * Contains nick, username and host. * @param passiveNick The nickname of the person whose modes are changed by * another user or himself. * @param mode The changed modes which are set. */ public void onMode(IRCUser user, String passiveNick, String mode); // ------------------------------ /** * Fired when somebody changes his nickname successfully. * @param user The user who changes his nickname. * Contains nick, username and host. * @param newNick The new nickname of the user who changes his nickname. */ public void onNick(IRCUser user, String newNick); // ------------------------------ /** * Fired when somebody sends a NOTICE to a user or a group. * @param target The channel or nickname the user sent a NOTICE * to. * @param user The user who notices another person or a group. * Contains nick, username and host. * @param msg The message. */ public void onNotice(String target, IRCUser user, String msg); // ------------------------------ /** * Fired when somebody parts from a channel. * @param chan The channel somebody parts from. * @param user The user who parts from a channel. * Contains nick, username and host. * @param msg The part-message which is optionally. * If it's empty, msg is "". */ public void onPart(String chan, IRCUser user, String msg); // ------------------------------ /** * Fired when a PING comes in. * The IRC server tests in different periods if the client is still there by * sending PING <ping>. The client must response PONG <ping>. * @param ping The ping which is received from the server. */ public void onPing(String ping); // ------------------------------ /** * Fired when a user sends a PRIVMSG to a user or to a * group. * @param target The channel or nickname the user sent a PRIVMSG * to. * @param user The user who sent the PRIVMSG. * Contains nick, username and host. * @param msg The message the user transmits. */ public void onPrivmsg(String target, IRCUser user, String msg); // ------------------------------ /** * Fired when somebody quits from the network. * @param user The user who quits. Contains nick, username and host. * @param msg The optional message. "" if no message is set by * the user. */ public void onQuit(IRCUser user, String msg); // ------------------------------ /** * Fired when a numeric reply is received. * For example, WHOIS queries are answered by the server with * numeric replies. * The msg's format is different for every reply. All replies' * formats are described in the {@link org.schwering.irc.lib.IRCUtil}. * The first word in the value is always your own nickname! * @param num The numeric reply. * @param value The first part of the message. * @param msg The main part of the message. */ public void onReply(int num, String value, String msg); // ------------------------------ /** * Fired when the topic is changed by operators. * Note that the topic is given as a numeric reply fired in * onReply when you join a channel. * @param chan The channel where the topic is changed. * @param user The user who changes the topic. * Contains nick, username and host. * @param topic The new topic. */ public void onTopic(String chan, IRCUser user, String topic); // ------------------------------ /** * This event is fired when the incoming line can not be identified as a known * event. * @param prefix The prefix of the incoming line. * @param command The command of the incoming line. * @param middle The part until the colon (:). * @param trailing The part behind the colon (:). */ public void unknown(String prefix, String command, String middle, String trailing); } libirclib-java-1.10/src/org/schwering/irc/lib/.svn/text-base/IRCModeParser.java.svn-base000066400000000000000000000200021155103677700307440ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class IRCModeParser * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; /** * Parses channel-modes. *

* An instance of this class is an argument of the {@link * org.schwering.irc.lib.IRCEventListener#onMode(String chan, IRCUser user, * IRCModeParser modeParser)}. * It's intended to help the programmer to work with the modes. *

* Channelmodes are: *

    *
  • +/- o nick
  • *
  • +/- v nick
  • *
  • +/- b banmask
  • *
  • +/- l limit
  • *
  • +/- k key
  • *
  • +/- p
  • *
  • +/- s
  • *
  • +/- i
  • *
  • +/- t
  • *
  • +/- n
  • *
  • +/- m
  • *
*

* These are all channel-modes defined in RFC1459. Nevertheless, most * networks provide more channel-modes. This class can handle all modes; it's * not restricted to the rights defined in RFC1459. * @author Christoph Schwering <schwering@gmail.com> * @version 1.22 * @see IRCEventListener */ public class IRCModeParser { /** * Represents the operators, modes and nicks as they were sent from the IRC * server. */ private String line; /** * Contains pluses (+) and minuses (-) which show * if the mode is taken or given. */ private char[] operatorsArr; /** * This array contains the modes that are set with the operator of the * operatorsArr-array. * */ private char[] modesArr; /** * Represents the parsed nicks, hostnames, limits or keys in an array of * Strings. */ private String[] argsArr; // ------------------------------ /** * Analyzes the modes and parses them into the parts operators (+ * or -), modes (one character) and optional arguments (one * word or number). * @param line The modes and the arguments; nothing more. */ public IRCModeParser(String line) { line = line.trim(); this.line = line; int index = line.indexOf(' '); if (index >= 2) { // with arguments String modes = line.substring(0, index); String args = line.substring(index + 1); parse(modes, args); // call real constructor. } else if (line.length() >= 2) { // no arguments String modes = line; String args = ""; parse(modes, args); } else { // nothing argsArr = new String[0]; operatorsArr = new char[0]; modesArr = new char[0]; } } // ------------------------------ /** * Analyzes the modes and parses them into the parts operators (+ * or -), modes (one character) and optional arguments (one * word or number). * @param modes The modes (for example +oo+m-v). * @param args The modes' arguments (for example Heinz Hans * Thomas). */ public IRCModeParser(String modes, String args) { line = modes +" "+ args; parse(modes, args); } // ------------------------------ /** * Parses the modes into two char-arrays and one * String-array.
* The first one contains the operator of the mode (+ or *
-) and the second one the mode (w, * i, s, o or any other mode). * The String[] contains the nicknames. * @param modes The modes (for example +oo+m-v). * @param args The modes' arguments (for example Heinz Hans * Thomas). */ private void parse(String modes, String args) { String[] argsTmp = IRCUtil.split(args, ' '); int modesLen = modes.length(); int modesCount = getModesCount(modes); char c; char operator = '+'; // any value cause it must be initialized operatorsArr = new char[modesCount]; modesArr = new char[modesCount]; argsArr = new String[modesCount]; // parse and fill the arrays for (int i = 0, j = 0, n = 0; i < modesLen; i++) { c = modes.charAt(i); if (c == '+' || c == '-') { operator = c; } else { // add the operator (which was found earlier in the loop) operatorsArr[n] = operator; modesArr[n] = c; // add the mode if ((c == 'o' || c == 'v' || c == 'b' || c == 'k') // come with arg || (c == 'l' && operator == '+')) { // key comes with arg if '+' argsArr[n] = (j < argsTmp.length) ? argsTmp[j++] : ""; } else { argsArr[n] = ""; // null if mode has no argument (for example m, p, s) } n++; // increase n, not i. n is used to fill the arrays } } } // ------------------------------ /** * Returns the amount of modes in the string. This is done by counting all * chars which are not + or -. * @param modes The modes which are to analyze. * @return The count of modes without operators. */ private int getModesCount(String modes) { int count = 0; for (int i = 0, c, len = modes.length(); i < len; i++) if ((c = modes.charAt(i)) != '+' && c != '-') count++; return count; } // ------------------------------ /** * Returns count of modes. * @return The count of modes. * @see #getOperatorAt(int) * @see #getModeAt(int) * @see #getArgAt(int) */ public int getCount() { return operatorsArr.length; } // ------------------------------ /** * Returns the operator (+ or -) of a given index. * @param i The index of the operator you want to get. The index starts * with 1 and not with 0. * @return The operator at the given index (+ or -). * @see #getCount() * @see #getModeAt(int) * @see #getArgAt(int) */ public char getOperatorAt(int i) { return operatorsArr[i - 1]; } // ------------------------------ /** * Returns the mode (for example o, v, * m, i) of a given index. * @param i The index of the mode you want to get. The index starts with * 1 and not with 0. * @return The mode of the given index (for example o, * v, m, i) * @see #getCount() * @see #getOperatorAt(int) * @see #getArgAt(int) */ public char getModeAt(int i) { return modesArr[i - 1]; } // ------------------------------ /** * Returns the nick of a given index. * @param i The index of the argument you want to get. The index starts with * 1 and not with 0. * @return The argument you requested. It's "" if there's no * argument at this index (for example +m for moderated * has never an argument). * @see #getCount() * @see #getOperatorAt(int) * @see #getModeAt(int) */ public String getArgAt(int i) { return argsArr[i - 1]; } // ------------------------------ /** * Returns the line as it was sent from the IRC server. * The line contains the the operators, the modes and the nicknames, but not * the channel or the nickname who executed the MODE command! * @return The line which was set as argument when the parser was initialized. */ public String getLine() { return line; } // ------------------------------ /** * Generates a String with some information about the instance of * IRCModeParser. * Its format is: classname[line]. * @return A String with information about the instance. */ public String toString() { return getClass().getName() +"["+ getLine() +"]"; } } libirclib-java-1.10/src/org/schwering/irc/lib/.svn/text-base/IRCParser.java.svn-base000066400000000000000000000433511155103677700301530ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class IRCParser * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; /** * Parses a line sent from the IRC server. *

* Note: Probably this class is unimportant for you. It's used by the * IRCConnection to parse incoming lines. Nevertheless I declared * it as public because you might want to use it to parse IRC * command-shortcuts like MSG instead of PRIVMSG in * your client.
* The following text goes on with the description of the class and what it * does. *

* According with RFC1459 it divides the line into a prefix, a command and * its parameters. *

* The prefix is only given if a line starts with a : (colon) * and is used to indicate from where the line is send. *

* The next word in the line (if no prefix exists it is the first, else the * second word) is the command. * The command is eiter a valid IRC command or a three-digit number which * represents a numeric reply or a numeric error. *

* The parameters are divided into a middle and a trailing part. * In the middle part one word means one parameter while the trailing part is * just one parameter independent from the amount of words in it. * If there is a " :" (space+colon) in the line, this point * means the beginning of the trailing. * If there is no such space+colon, the trailing is just the last word. * All words behind the space+colon mean just one parameter. * If there is only one parameter given (the parameter is the first, the last * and the only one), the parameter is available as trailing (with * getTrailing), not as middle! *

* One line may have up to 15 parameters. Therefore up to 14 are middle and * one is the trailing. *

* The line may have up to 510 characters plus the CR-LF (carriage return - * line feed) which trails the incoming line. *

* The following extract of the RFC1459 shows the message format in BNF: *

* <message>  ::= * [':' <prefix> <SPACE> ] <command> <params> * <crlf>
* <prefix>   ::= * <servername> | <nick> * [ '!' <username> ] [ '@' <host> ] *
* <command>  ::= * <letter> { <letter> } | <number> <number> * <number>
* <SPACE>    ::= * ' ' { ' ' }
* <params>   ::= * <SPACE> [ ':' <trailing> | <middle> <params> ]
* <middle>   ::= * <Any *non-empty* sequence of octets not including SPACE or NUL or CR or * LF, the first of which may not be ':'>
* <trailing> ::= * <Any, possibly *empty*, sequence of octets not including NUL or CR or * LF>
* <crlf>     ::= * CR LF
*
* @author Christoph Schwering <schwering@gmail.com> * @version 3.22 * @see IRCConnection */ public class IRCParser { /** * The StringBuffer contains the line which was analyzed. */ private StringBuffer buf; /** * The length of the line. */ private int len; /** * The prefix, which is parsed out in the constructor. */ private String prefix; /** * The command, which is parsed out in the constructor. */ private String command; /** * The middle, which is parsed out in the constructor. */ private String middle; /** * The trailing, which is parsed out in the constructor. The trailing is the * part behind the colon (:) or the last parameter. */ private String trailing; /** * The parameters' array. It's not initialized in the constructor because of * rare access. The methods which use and need this parameter-array * (getParametersCount, getParameter, getParameterFrom etc.) initialize this * array by calling initParameters, if the array isn't initialized yet. */ private String[] parameters; // ------------------------------ /** * Parses the line after erasing all mIRC color codes. * This constructor is a shorthand for IRCParser(line, false). * @param line The line which will be parsed. */ public IRCParser(String line) { this(line, false); } // ------------------------------ /** * The main constructor. * Parses prefix, command, middle and trailing. * @param line The line which will be parsed. * @param colorsEnabled If false, mIRC color codes are parsed out * by using IRCUtil.parseColors method. */ public IRCParser(String line, boolean colorsEnabled) { int index = 0; int trail; buf = new StringBuffer(line); if (!colorsEnabled) buf = IRCUtil.parseColors(buf); len = buf.length(); // prefix if (buf.charAt(0) == ':') { prefix = buf.substring(1, (index = indexOf(' ', index))); index++; } while (buf.charAt(index) == ' ') index++; // command command = buf.substring(index, ((index = indexOf(' ', index)) != -1) ? index : (index = len)); while (index < len && buf.charAt(index) == ' ') index++; index--; // middle & trailing if ((trail = indexOf(" :", index)) != -1) trailing = buf.substring(trail + 2, len); else if ((trail = lastIndexOf(' ')) != -1 && trail >= index) trailing = buf.substring(trail + 1, len); middle = (index < trail) ? buf.substring(index + 1, trail) : ""; // save this.prefix = (prefix != null) ? prefix : ""; this.command = (command != null) ? command : ""; this.middle = (middle != null) ? middle : ""; this.trailing = (trailing != null) ? trailing : ""; } // ------------------------------ /** * Searches for a char in the StringBuffer buf from a given index * and returns its index. * @param c The char to search. * @param i The index the method will start searching at. * @return The index of the searched char. */ private int indexOf(int c, int i) { while (i < len) if (buf.charAt(i++) == c) return --i; return -1; } // ------------------------------ /** * Searches for a string in the StringBuffer buf from a given * index and returns its beginning index. * @param str The string to search. * @param i The index the method will start searching at. * @return The index of the searched string. */ private int indexOf(String str, int i) { int sublen = str.length(); int index = -1; int j; for ( ; i < len; i++) for (index = i, j = 0; i < len && j < sublen; i++, j++) if (buf.charAt(i) != str.charAt(j)) break; else if (j + 1 == sublen) return index; return -1; } // ------------------------------ /** * Searches for a given char in the StringBuffer buf.
* It starts at the end.
* Note: The method expects a character which is not c before * it can return an index. Thus in a string like "nick moor   *   " with four trailing spaces * lastIndexOf(' ') does not return the the index of the last * space. It first waits for characters which are not a space (r, o, o, m) and * then returns the index of the next space: the space between * nick and moor. By this, also in lines with * trailing whitespace the trailing-part is correctly recognized. * @param c The char to search. * @return The last index of the searched char. */ private int lastIndexOf(int c) { int i = len; boolean ok = false; while (i > 0) if (buf.charAt(--i) != c) ok = true; else if (ok) return i; return -1; } // ------------------------------ /** * Initializes the parameters[]. * This method is called by getParam, getParamFrom * and getParamTo, if the parameters[] aren't * initialized yet.
* The method splits the middle into all words using and appends * the trailing as last parameter. It uses the IRCUtil.split * method. */ private void initParameters() { parameters = IRCUtil.split(middle, ' ', trailing); } // ------------------------------ /** * Returns the line's prefix. A prefix is the part which contains information * about the sender of the line. If no prefix is set, "" is * returned; but in fact there's always a prefix. * @return The line's prefix. */ public String getPrefix() { return prefix; } // ------------------------------ /** * Returns the line's command. * @return The line's command. */ public String getCommand() { return command; } // ------------------------------ /** * Returns the line's middle. * @return The line's middle. */ public String getMiddle() { return middle; } // ------------------------------ /** * Returns the line's trailing. * @return The line's trailing. */ public String getTrailing() { return trailing; } // ------------------------------ /** * Returns the unparsed line. It looks exacttly as the server sent it, but * if colors are disabled and therefore already parsed out by * IRCUtil.parseColors, the colors are not included in here. * @return The line. */ public String getLine() { return buf.toString(); } // ------------------------------ /** * Returns the line's parameters which consists of the middle and the * trailing. * @return The line's parameters. */ public String getParameters() { return middle + ((middle.length() != 0 && trailing.length() != 0) ? " " : "") + trailing; } // ------------------------------ /** * Returns the nickname of the person who sent the line * or the servername of the server which sent the line.
* It is found in the prefix which always looks like that:
* * <servername> | <nick> * [ '!' <username> ] [ '@' <host> ] *

* If no prefix is given in the whole line, null is returned. *

* Note: This method is totally equal to getServername! *
* Note: There is also the method getUser which returns * an IRCUser object which holds the nickname, username and host. * By the way, the getUser uses the getNick, * getUsername and getHost methods to create this * object. * @return The nickname or the servername of the line. If no prefix is given, * null is returned. * @see #getServername() * @see #getUsername() * @see #getHost() * @see #getUser() */ public String getNick() { int i = prefix.indexOf('!'); if (i != -1 || (i = prefix.indexOf('@')) != -1) return prefix.substring(0, i); return (prefix.length() != 0) ? prefix : null; } // ------------------------------ /** * Returns the servername of the server which sent the line * or the nickname of the person who sent the line.
* It is found in the prefix which always looks like that:
* * <servername> | <nick> * [ '!' <username> ] [ '@' <host> ] *

* If no prefix is given in the whole line, null is returned. *

* Note: This method is totally equal to getNick! *
* Note: There is also the method getUser which returns * an IRCUser object which holds the nickname, username and host. * By the way, the getUser uses the getNick, * getUsername and getHost methods to create this * object. * @return The servername or the nickname of the line. If no prefix is given, * null is returned. * @see #getNick() * @see #getUser() */ public String getServername() { return getNick(); } // ------------------------------ /** * Returns the username of the person who sent the line.
* It is found in the prefix which always looks like that:
* * <servername> | <nick> * [ '!' <username> ] [ '@' <host> ] *

* If the username is not specified, this method returns null. *
* Note: There is also the method getUser which returns * an IRCUser object which holds the nickname, username and host. * By the way, the getUser uses the getNick, * getUsername and getHost methods to create this * object. * @return The username of the line; null if it's not given. * @see #getNick() * @see #getHost() * @see #getUser() */ public String getUsername() { int i = prefix.indexOf('!') + 1; if (i != 0) { int j = prefix.indexOf('@', i); return prefix.substring(i, (j != -1) ? j : prefix.length()); } return null; } // ------------------------------ /** * Returns the host of the person who sent the line.
* It is found in the prefix which always looks like that:
* * <servername> | <nick> * [ '!' <username> ] [ '@' <host> ] *

* If the host is not specified, this method returns null. *
* Note: There is also the method getUser which returns * an IRCUser object which holds the nickname, username and host. * By the way, the getUser uses the getNick, * getUsername and getHost methods to create this * object. * @return The host of the line; null if it's not given. * @see #getNick() * @see #getUsername() * @see #getUser() */ public String getHost() { int i = prefix.indexOf('@') + 1; if (i != 0) return prefix.substring(i, prefix.length()); return null; } // ------------------------------ /** * Returns a new IRCUser object. * This method is equal to new IRCUser(IRCParser.getNick(), * IRCParser.getUsername(), IRCParser.getHost()). See those methods to * learn which value they return if they are not set. * @return A new IRCUser object with exactly those values which * are returned by the getNick, getUsername * and getHost methods. * @see #getNick() * @see #getUsername() * @see #getHost() */ public IRCUser getUser() { return new IRCUser(getNick(), getUsername(), getHost()); } // ------------------------------ /** * Gets count of parameters. * If parameters isn't initialized yet, it calls * initParameters to do that. * @return The number of parameters. */ public int getParameterCount() { if (parameters == null) initParameters(); return parameters.length; } // ------------------------------ /** * Get one parameter of the line. * If parameters isn't initialized yet, it calls * initParameters to do that. * @param i The index of the parameter you want to get. The index starts with * 1 and not with 0. * @return The ith parameter. If i is out of bounds, * "" is returned. */ public String getParameter(int i) { if (parameters == null) initParameters(); --i; if (i >= 0 && i < parameters.length) return parameters[i]; else return ""; } // ------------------------------ /** * Grabs the line's parameters from the ith to the last * parameter (including the ith). * If parameters isn't initialized yet, it calls * initParameters to do that. * @param i The index of the first parameter you want to get. * @return All parameters behind another beginning at the ith. * If i is out of bounds, "" is returned. */ public String getParametersFrom(int i) { if (parameters == null) initParameters(); StringBuffer params = new StringBuffer(); for (i--; i < parameters.length; i++) params.append(parameters[i] +" "); return params.toString(); } // ------------------------------ /** * Grabs the line's parameters from the first to the ith * parameters (including the ith). * If parameters isn't initialized yet, it calls * initParameters to do that. * @param i The index of the last parameter you want to get. * @return All parameters beginning at the first and ending at the * ith. If i is out of bounds, * "" is returned. */ public String getParametersTo(int i) { if (parameters == null) initParameters(); StringBuffer params = new StringBuffer(); int max = (i < parameters.length) ? i : parameters.length; for (i = 0; i < max; i++) params.append(parameters[i] +" "); return params.toString(); } // ------------------------------ /** * Generates a String with some information about the instance of * IRCParser.
* Its format is: classname[prefix,command,middle,trailing]. * @return A String with information about the instance. */ public String toString() { return getClass().getName() +"["+ prefix +","+ command +","+ middle +","+ trailing +"]"; } } libirclib-java-1.10/src/org/schwering/irc/lib/.svn/text-base/IRCUser.java.svn-base000066400000000000000000000063771155103677700276440ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class IRCUser * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; /** * Holds variables for the nick, username and host of a user. *

* It's used to pack these information in one object. * @author Christoph Schwering <schwering@gmail.com> * @version 1.02 * @see IRCEventListener * @see IRCParser */ public class IRCUser { /** * The user's nickname. */ private String nick; /** * The user's username. */ private String username; /** * The user's host. */ private String host; // ------------------------------ /** * Creates a new IRCUser object. * @param nick The user's nickname. * @param username The user's username. * @param host The user's host. */ public IRCUser(String nick, String username, String host) { this.nick = nick; this.username = username; this.host = host; } // ------------------------------ /** * Returns the nickname of the person who sent the line * or the servername of the server which sent the line.
* If no nickname is given, null is returned. *

* Note: This method is totally equal to getServername! * @return The nickname or the servername of the line. If no nick is given, * null is returned. * @see #getServername() * @see #getUsername() * @see #getHost() */ public String getNick() { return nick; } // ------------------------------ /** * Returns the servername of the server which sent the line or the nickname of * the person who sent the line.
* If no nickname is given, null is returned. *

* Note: This method is totally equal to getNick! * @return The servername or the nickname of the line. If no server is given, * null is returned. * @see #getNick() */ public String getServername() { return getNick(); } // ------------------------------ /** * Returns the username of the person who sent the line.
* If the username is not specified, this method returns null. * @return The username of the line; null if it's not given. * @see #getNick() * @see #getHost() */ public String getUsername() { return username; } // ------------------------------ /** * Returns the host of the person who sent the line.
* If the host is not specified, this method returns null. * @return The host of the line; null if it's not given. * @see #getNick() * @see #getUsername() */ public String getHost() { return host; } // ------------------------------ /** * Returns the nickname. * @return The nickname. */ public String toString() { return getNick(); } } libirclib-java-1.10/src/org/schwering/irc/lib/.svn/text-base/IRCUtil.java.svn-base000066400000000000000000000200771155103677700276340ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class IRCUtil * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; import java.util.Vector; /** * Contains some utilities like numeric error and reply numbers. *

* The most description of the numeric errors and numeric replies are copied * from RFC1459. * @author Christoph Schwering <schwering@gmail.com> * @author Normton <normton@latinmail.com> * @version 2.03 * @see IRCConnection * @see IRCEventListener#onError(int, String) * @see IRCEventListener#onReply(int, String, String) */ public class IRCUtil implements IRCConstants { /** * This is part of the mIRC code and shows that a color-code starts / ends. * Here it is as the ASCII decimal int 3. * @deprecated Moved to IRCConstants. */ public static char colorIndicator = 3; // ASCII code /** * This is part of the mIRC code and shows that bold starts / ends. * Here it is as the ASCII decimal int 32. * @deprecated Moved to IRCConstants. */ public static char boldIndicator = 31; // ASCII code /** * This is part of the mIRC code and shows that bold starts / ends. * Here it is as the ASCII decimal int 2. * @deprecated Moved to IRCConstants. */ public static char underlinedIndicator = 2; // ASCII code /** * This is part of the mIRC code and shows that bold, underline and colors * end. * Here it is as the ASCII decimal int 15. * @deprecated Moved to IRCConstants. */ public static char colorEndIndicator = 15; // ASCII code /** * This is part of the mIRC code and indicates that the client's colors are * reversed (background -> foreground and foreground -> background). * Here it is as the ASCII decimal int 1. * @deprecated Moved to IRCConstants. */ public static char colorReverseIndicator = 22; // ASCII code /** * This is part of the mIRC code and shows that a PRIVMSG is an ACTION * (/me). * Here it is as the ASCII decimal int 22. * @deprecated Moved to IRCConstants. */ public static char actionIndicator = 1; // ASCII code // ------------------------------ /** * This is an empty constructor, it does nothing. Nobody may instantiate this * class. */ private IRCUtil() { // nothing } // ------------------------------ /** * According to RFC2812 the channel's name may and must start with one of the * following characters. *

    *
  • ! == 33 (ASCII)
  • *
  • # == 35
  • *
  • & == 38
  • *
  • + == 43
  • *
. * @param str The name to check if it's a channel. * @return true if the argument starts with one of the characters * mentioned above. */ public static boolean isChan(String str) { int c; return (str.length() >= 2) && ((c = str.charAt(0)) == 35 || c == 38 || c == 33 || c == 43); } // ------------------------------ /** * Parses a String to an int via * Integer.parseInt but avoids the * NumberFormatException. * @param str The String to parse. * @return The parsed new int. -1 if * NumberFormatException was thrown. */ public static int parseInt(String str) { try { return Integer.parseInt(str); } catch (NumberFormatException exc) { return -1; } } // ------------------------------ /** * Erases the mIRC colorcodes from a String. * The documentation of the evil color codes is available on * http://www.mirc.co.uk/help/color.txt. * This method links to the parseColors(StringBuffer) method. * @param str The line which should be parsed. * @return A line cleaned from any mIRC colorcodes. * @see #parseColors(StringBuffer) */ public static String parseColors(String str) { return parseColors(new StringBuffer(str)).toString(); } // ------------------------------ /** * Erases the mIRC colorcodes from a String. * The documentation of the evil color codes is available on * http://www.mirc.co.uk/help/color.txt. * @param buf The line which should be parsed. * @return A line as StringBuffer object which is cleaned from * any mIRC colorcodes. * @see #parseColors(String) */ public static StringBuffer parseColors(StringBuffer buf) { int len = buf.length(); for (int i = 0, j = 0, c; i < len; i++, j = i) { c = buf.charAt(i); try { // COLORS Beginning // (format: [][[,[]] if (c == COLOR_INDICATOR) { c = buf.charAt(++j); if ('0' <= c && c <= '9') { // first int c = buf.charAt(++j); if ('0' <= c && c <= '9') c = buf.charAt(++j); // second int } if (c == ',') c = buf.charAt(++j); // comma if ('0' <= c && c <= '9') { // first int c = buf.charAt(++j); if ('0' <= c && c <= '9') c = buf.charAt(++j); // second int } // ACTION / BOLD / UNDERLINE / COLOR END // (format: / etc.) } else if (c == ACTION_INDICATOR || c == BOLD_INDICATOR || c == UNDERLINE_INDICATOR || c == COLOR_END_INDICATOR || c == COLOR_REVERSE_INDICATOR) { j++; } } catch(StringIndexOutOfBoundsException exc) { // we got the end of the string with a call to charAt(++iIndexEnd) // nothing } if (j > i) { buf = buf.delete(i, j); // remove the cars len -= (j - i); i -= (j - i); } } return buf; } // ------------------------------ /** * Splits a string into substrings. * @param str The string which is to split. * @param delim The delimiter character, for example a space ' '. * @param trailing The ending which is added as a substring though it wasn't * in the str. This parameter is just for the * IRCParser class which uses this method to * split the middle part into the parameters. * But as last parameter always the trailing is * added. This is done here because it's the fastest way to * do it here.
* If the end is null or * "", nothing is appended. * @return An array with all substrings. * @see #split(String, int) */ public static String[] split(String str, int delim, String trailing) { Vector items = new Vector(15); int last = 0; int index = 0; int len = str.length(); while (index < len) { if (str.charAt(index) == delim) { items.add(str.substring(last, index)); last = index + 1; } index++; } if (last != len) items.add(str.substring(last)); if (trailing != null && trailing.length() != 0) items.add(trailing); String[] result = new String[items.size()]; items.copyInto(result); return result; } // ------------------------------ /** * Splits a string into substrings. This method is totally equal to * split(str, delim, null). * @param str The string which is to split. * @param delim The delimiter character, for example a space ' '. * @return An array with all substrings. * @see #split(String, int, String) */ public static String[] split(String str, int delim) { return split(str, delim, null); } } libirclib-java-1.10/src/org/schwering/irc/lib/.svn/text-base/SSLDefaultTrustManager.java.svn-base000066400000000000000000000061511155103677700326610ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class SSLDefaultTrustManager * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; import com.sun.net.ssl.X509TrustManager; import java.security.cert.X509Certificate; /** * The default TrustManager of the * SSLIRCConnection. *

* Note that this class is deprecated. The SSL supporting classes moved * to org.schwering.irc.lib.ssl since IRClib 1.10. *

* It automatically accepts the X509 certificate. *

* In many cases you should change the SSLIRCConnection's * TrustManager. For examle if you write an IRC client for human * users, you may want to ask the user whether he accepts the server's * certificate or not. You could do this by a new class which extends the * SSLDefaultTrustManager class and overrides the * checkServerTrusted method and asks the user whether he wants to * accept the certification or not. * @deprecated This class has been replaced with * org.schwering.irc.lib.ssl.SSLDefaultTrustManager. * @author Christoph Schwering <schwering@gmail.com> * @version 1.13 * @see SSLIRCConnection * @see com.sun.net.ssl.TrustManager */ public class SSLDefaultTrustManager implements X509TrustManager { /** * The X509Certificates which are accepted. */ protected X509Certificate[] accepted = new X509Certificate[0]; // ------------------------------ /** * Creates a new instance of the SSLDefaultTrustManager class. */ public SSLDefaultTrustManager() { // nothing } // ------------------------------ /** * Does nothing. This method would check whether we (the server) trust the * client. But we are the client and not the server.
* It's final so that nobody can override it; it would make no sense. * @param chain The peer certificate chain. * @return Always false. */ public final boolean isClientTrusted(X509Certificate chain[]) { return false; } // ------------------------------ /** * Invoked when the client should check whether he trusts the server or not. * This method trusts the server. But this method can be overriden and then * ask the user whether he truts the client or not. * @param chain The peer certificate chain. * @return Always true. */ public boolean isServerTrusted(X509Certificate chain[]) { accepted = chain; return true; } // ------------------------------ /** * Returns the accepted certificates. They are set in the * checkServerTrusted method. * @return A non-null (possibly empty) array of acceptable CA issuer * certificates. */ public X509Certificate[] getAcceptedIssuers() { return accepted; } } libirclib-java-1.10/src/org/schwering/irc/lib/.svn/text-base/SSLIRCConnection.java.svn-base000066400000000000000000000335101155103677700313740ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class SSLIRCConnection * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; import com.sun.net.ssl.SSLContext; import com.sun.net.ssl.TrustManager; import com.sun.net.ssl.internal.ssl.Provider; import java.io.IOException; import java.io.StringWriter; import java.io.PrintWriter; import java.net.SocketException; import java.security.Security; import java.util.Vector; import javax.net.ssl.SSLException; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; /** * The SSL extension of the IRCConnection class. *

* Note that this class is deprecated. The SSL supporting classes moved * to org.schwering.irc.lib.ssl since IRClib 1.10. *

* The IRC server you want to connect to must accept SSL connections. * Otherwise you cannot connect to it with an instance of * SSLIRCConnection. IRC servers which accept SSL connections are * really very rare, because SSL means a high load for the server. *

* The following sample code tries to establish an IRC connection to an * IRC server which must support SSL. Differences to the code which * demonstrates the use of of the {@link org.schwering.irc.lib.IRCConnection} * class are printed in bold font: *

*


 * /* 
 *  * The following code of a class which imports org.schwering.irc.lib.*
 *  * prepares an SSL IRC connection and then tries to establish the 
 *  * connection. The server is "irc.somenetwork.com", the ports are 
 *  * the default SSL port (443) and the port used on most SSL IRC servers
 *  * (994). No password is used (null). The nickname is "Foo" and 
 *  * the realname is "Mr. Foobar". The username "foobar".
 *  * Because of setDaemon(true), the JVM exits even if this thread is 
 *  * running.
 *  * By setting an instance of SSLDefaultTrustManager as TrustManager
 *  * (which is also done implicitely by the SSLIRCConnection class if no
 *  * TrustManager is set until the connect method is invoked), the
 *  * X509Certificate is accepted automatically. Of course, you can write
 *  * your own TrustManager. For example, you could write a class which
 *  * extends SSLDefaultTrustManager and overrides its checkServerTrusted
 *  * method. In the new checkServerTrusted method, you could ask the user
 *  * to accept or reject the certificate.
 *  * An instance of the class MyListener which must implement 
 *  * IRCActionListener is set as event-listener for the connection. 
 *  * The connection is told to parse out mIRC color codes and to enable
 *  * automatic PING? PONG! replies.
 *  */
 * SSLIRCConnection conn = new SSLIRCConnection(
 *                               "irc.somenetwork.com", 
 *                               new int[] { 443, 994 },  
 *                               null, 
 *                               "Foo", 
 *                               "Mr. Foobar", 
 *                               "foo@bar.com" 
 *                             ); 
 * 
 * conn.addIRCEventListener(new MyListener()); 
 * conn.addTrustManager(new SSLDefaultTrustManager());
 * conn.setDaemon(true);
 * conn.setColors(false); 
 * conn.setPong(true); 
 *   
 * try {
 *   conn.connect(); // Try to connect!!! Don't forget this!!!
 * } catch (IOException ioexc) {
 *   ioexc.printStackTrace(); 
 * }
 * 

*

* The serverpassword isn't needed in most cases. You can give * null or "" instead as done in this example. *

* TrustManagers can be added and removed until the * connect method is invoked. If no TrustManagers are * set until then, an {@link org.schwering.irc.lib.SSLDefaultTrustManager} is * set automatically. It accepts all X509 certificates. * @deprecated This class has been replaced with * org.schwering.irc.lib.ssl.SSLDefaultTrustManager. * @author Christoph Schwering <schwering@gmail.com> * @version 1.33 * @see IRCConnection * @see SSLDefaultTrustManager * @see com.sun.net.ssl.TrustManager */ public class SSLIRCConnection extends IRCConnection { /** * The list of TrustManagers. TrustManagers can be * added with the addTrustManager method and removed with the * removeTrustManager method. If no TrustManager * is included, the getTrustManagers method sets an instance of * SSLDefaultTrustManager as only TrustManager. */ private Vector trustManagers = new Vector(1); // ------------------------------ /** * Creates a new IRC connection with secure sockets (SSL).
* The difference to the other constructor is, that it transmits the ports in * an int[]. Thus, also ports like 994, 6000 and 6697 can be * selected.

* The constructor prepares a new IRC connection with secure sockets which * can be really started by invoking the connect method. Before * invoking it, you should set the IRCEventListener, optionally * the TrustManager, if you don't want to use the * SSLDefaultTrustManager which accepts the X509 certificate * automatically, and other settings.
* Note that you do not need to set a password to connect to the large public * IRC networks like QuakeNet, EFNet etc. To use no password in your IRC * connection, use "" or null for the password * argument in the constructor. * @param host The hostname of the server we want to connect to. * @param ports The portrange to which we want to connect. * @param pass The password of the IRC server. If your server isn't * secured by a password (that's normal), use * null or "". * @param nick The nickname for the connection. Is used to register the * connection. * @param username The username. Is used to register the connection. * @param realname The realname. Is used to register the connection. * @throws IllegalArgumentException If the host or * ports is null or * ports' length is * 0. * @see #connect() */ public SSLIRCConnection(String host, int[] ports, String pass, String nick, String username, String realname) { super(host, ports, pass, nick, username, realname); } // ------------------------------ /** * Creates a new IRC connection with secure sockets (SSL).
* The difference to the other constructor is, that it transmits the ports as * two ints. Thus, only a portrange from port x to * port y like from port 6000 to 6010 can be selected.
*
* The constructor prepares a new IRC connection with secure sockets which * can be really started by invoking the connect method. Before * invoking it, you should set the IRCEventListener, optionally * the TrustManager, if you don't want to use the * SSLDefaultTrustManager which accepts the X509 certificate * automatically, and other settings.
* Note that you do not need to set a password to connect to the large public * IRC networks like QuakeNet, EFNet etc. To use no password in your IRC * connection, use "" or null for the password * argument in the constructor. * @param host The hostname of the server we want to connect to. * @param portMin The beginning of the port range we are going to connect * to. * @param portMax The ending of the port range we are going to connect to. * @param pass The password of the IRC server. If your server isn't * secured by a password (that's normal), use * null or "". * @param nick The nickname for the connection. Is used to register the * connection. * @param username The username. Is used to register the connection. * @param realname The realname. Is used to register the connection. * @throws IllegalArgumentException If the host is * null. * @see #connect() */ public SSLIRCConnection(String host, int portMin, int portMax, String pass, String nick, String username, String realname) { super(host, portMin, portMax, pass, nick, username, realname); } // ------------------------------ /** * Establish a connection to the server.
* This method must be invoked to start a connection; the constructor doesn't * do that!
* It tries all set ports until one is open. If all ports fail it throws an * IOException. If anything SSL related fails (for example * conflicts with the algorithms or during the handshaking), a * SSLException is thrown.
* You can invoke connect only one time. * @throws IOException If an I/O error occurs. * @throws SSLException If anything with the secure sockets fails. * @throws SocketException If the connect method was already * invoked. * @see #isConnected() * @see #doQuit() * @see #doQuit(String) * @see #close() */ public void connect() throws IOException { if (level != 0) // otherwise disconnected or connect throw new SocketException("Socket closed or already open ("+ level +")"); IOException exception = null; SSLSocketFactory sf = null; SSLSocket s = null; for (int i = 0; i < ports.length && s == null; i++) { try { if (sf == null) sf = getSocketFactory(); s = (SSLSocket)sf.createSocket(host, ports[i]); s.startHandshake(); exception = null; } catch (IOException exc) { if (s != null) s.close(); s = null; exception = exc; } } if (exception != null) throw exception; // connection wasn't successful at any port prepare(s); } // ------------------------------ /** * Creates a new SSLSocketFactory on whose base a new * SSLSocket can be created. This method is used by the * connect method. If a NoSuchAlgorithmException, * KeyManagementException, or any other exception is thrown, * it's catched a SSLException is thrown. This * SSLException contains all information about the exception * which was really thrown.

* If there are now TrustManagers set at the moment, an instance * of SSLDefultTrustManager is set automatically. * @throws SSLException If any exception is thrown. It contains all the thrown * exception's information. * @return A new SSLSocketFactory on which base a new * SSLSocket can be created. */ private SSLSocketFactory getSocketFactory() throws SSLException { if (trustManagers.size() == 0) addTrustManager(new SSLDefaultTrustManager()); try { Security.addProvider(new Provider()); SSLContext context = SSLContext.getInstance("SSL"); context.init(null, getTrustManagers(), null); SSLSocketFactory socketFactory = context.getSocketFactory(); return socketFactory; } catch (Exception exc) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); exc.printStackTrace(pw); pw.close(); throw new SSLException("Exception while preparing "+ "the SSLSocket:\n---\n"+ sw.toString() + "---"); } } // ------------------------------ /** * Adds a new TrustManager.
* Please remind that we're talking here about * com.sun.net.ssl.TrustManagers of the JSSE API and not the * javax.net.ssl.TrustManagers of the Java 1.4 API! * @param trustManager The TrustManager object which is to add. * @see #removeTrustManager(TrustManager) * @see #getTrustManagers() */ public void addTrustManager(TrustManager trustManager) { trustManagers.add(trustManager); } // ------------------------------ /** * Removes one TrustManager.
* Please remind that we're talking here about * com.sun.net.ssl.TrustManagers of the JSSE API and not the * javax.net.ssl.TrustManagers of the Java 1.4 API! * @param trustManager The TrustManager object which is to * remove. * @return true if a TrustManager was removed. * @see #addTrustManager(TrustManager) * @see #getTrustManagers() */ public boolean removeTrustManager(TrustManager trustManager) { return trustManagers.remove(trustManager); } // ------------------------------ /** * Returns the set TrustManagers. The default * TrustManager is an instance of * SSLDefaultTrustManager, which is set when you invoke the * connect method without having set another * TrustManager.
* Please remind that we're talking here about * com.sun.net.ssl.TrustManagers of the JSSE API and not the * javax.net.ssl.TrustManagers of the Java 1.4 API! * @return The set TrustManagers. * @see #addTrustManager(TrustManager) * @see #removeTrustManager(TrustManager) */ public TrustManager[] getTrustManagers() { TrustManager[] tm = new TrustManager[trustManagers.size()]; trustManagers.copyInto(tm); return tm; } } libirclib-java-1.10/src/org/schwering/irc/lib/.svn/text-base/package.html.svn-base000066400000000000000000000023211155103677700277670ustar00rootroot00000000000000 IRClib is a library for the client-side of IRC (Internet Relay Chat) connections.

IRClib is RFC1459 and RFC2812 compliant. It's licensed under the GNU Lesser General Public License, the Apache License 2.0 and the Eclipse Public License so that you can use and modify it for your purposes for free.

By instantiating the {@link org.schwering.irc.lib.IRCConnection} class you can establish a new connection to an IRC server. The {@link org.schwering.irc.lib.IRCEventListener} informs your class about lines coming from the server which are parsed by the {@link org.schwering.irc.lib.IRCParser}. The {@link org.schwering.irc.lib.IRCModeParser} is especially made for channel-modes.
To create a secure connection with SSL, instantiate the {@link org.schwering.irc.lib.ssl.SSLIRCConnection}.

This project's home page is available at http://moepii.sourceforge.net.

If you're using IRClib, write a mail to me so that I can put you on the using-IRClib-list! @version 1.10 @author Christoph Schwering <schwering@gmail.com> libirclib-java-1.10/src/org/schwering/irc/lib/.svn/wcprops/000077500000000000000000000000001155103677700235745ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/.svn/wcprops/IRCConnection.java.svn-work000066400000000000000000000001671155103677700306650ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 78 /svnroot/moepii/!svn/ver/33/trunk/src/org/schwering/irc/lib/IRCConnection.java END libirclib-java-1.10/src/org/schwering/irc/lib/.svn/wcprops/IRCConstants.java.svn-work000066400000000000000000000001661155103677700305410ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 77 /svnroot/moepii/!svn/ver/25/trunk/src/org/schwering/irc/lib/IRCConstants.java END libirclib-java-1.10/src/org/schwering/irc/lib/.svn/wcprops/IRCEventAdapter.java.svn-work000066400000000000000000000001711155103677700311430ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 80 /svnroot/moepii/!svn/ver/24/trunk/src/org/schwering/irc/lib/IRCEventAdapter.java END libirclib-java-1.10/src/org/schwering/irc/lib/.svn/wcprops/IRCEventListener.java.svn-work000066400000000000000000000001721155103677700313510ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 81 /svnroot/moepii/!svn/ver/24/trunk/src/org/schwering/irc/lib/IRCEventListener.java END libirclib-java-1.10/src/org/schwering/irc/lib/.svn/wcprops/IRCModeParser.java.svn-work000066400000000000000000000001671155103677700306270ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 78 /svnroot/moepii/!svn/ver/24/trunk/src/org/schwering/irc/lib/IRCModeParser.java END libirclib-java-1.10/src/org/schwering/irc/lib/.svn/wcprops/IRCParser.java.svn-work000066400000000000000000000001631155103677700300160ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 74 /svnroot/moepii/!svn/ver/24/trunk/src/org/schwering/irc/lib/IRCParser.java END libirclib-java-1.10/src/org/schwering/irc/lib/.svn/wcprops/IRCUser.java.svn-work000066400000000000000000000001611155103677700274760ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 72 /svnroot/moepii/!svn/ver/24/trunk/src/org/schwering/irc/lib/IRCUser.java END libirclib-java-1.10/src/org/schwering/irc/lib/.svn/wcprops/IRCUtil.java.svn-work000066400000000000000000000001611155103677700274750ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 72 /svnroot/moepii/!svn/ver/24/trunk/src/org/schwering/irc/lib/IRCUtil.java END libirclib-java-1.10/src/org/schwering/irc/lib/.svn/wcprops/SSLDefaultTrustManager.java.svn-work000066400000000000000000000002001155103677700325170ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 87 /svnroot/moepii/!svn/ver/25/trunk/src/org/schwering/irc/lib/SSLDefaultTrustManager.java END libirclib-java-1.10/src/org/schwering/irc/lib/.svn/wcprops/SSLIRCConnection.java.svn-work000066400000000000000000000001721155103677700312430ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 81 /svnroot/moepii/!svn/ver/25/trunk/src/org/schwering/irc/lib/SSLIRCConnection.java END libirclib-java-1.10/src/org/schwering/irc/lib/.svn/wcprops/package.html.svn-work000066400000000000000000000001611155103677700276400ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 72 /svnroot/moepii/!svn/ver/27/trunk/src/org/schwering/irc/lib/package.html END libirclib-java-1.10/src/org/schwering/irc/lib/IRCConnection.java000066400000000000000000001047151155103677700245230ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class IRCConnection * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.Socket; import java.net.SocketException; /** * Creates a new connection to an IRC server. It's the main class of the * IRClib, the point everything starts. *

* The following sample code tries to establish an IRC connection to an * IRC server: *

*


 * /* 
 *  * The following code of a class which imports org.schwering.irc.lib.*
 *  * prepares an IRC connection and then tries to establish the connection.
 *  * The server is "irc.somenetwork.com", the default portrange (6667 and 
 *  * 6669) is set, no password is used (null). The nickname is "Foo" and 
 *  * the realname is "Mr. Foobar". The username "foobar".
 *  * Because of setDaemon(true), the JVM exits even if this thread is 
 *  * running.
 *  * An instance of the class MyListener which must implement 
 *  * IRCActionListener is added as only event-listener for the connection. 
 *  * The connection is told to parse out mIRC color codes and to enable
 *  * automatic PING? PONG! replies.
 *  */
 * IRCConnection conn = new IRCConnection(
 *                            "irc.somenetwork.com", 
 *                            6667, 
 *                            6669, 
 *                            null, 
 *                            "Foo", 
 *                            "Mr. Foobar", 
 *                            "foo@bar.com" 
 *                          ); 
 * 
 * conn.addIRCEventListener(new MyListener()); 
 * conn.setDaemon(true);
 * conn.setColors(false); 
 * conn.setPong(true); 
 * 
 * try {
 *   conn.connect(); // Try to connect!!! Don't forget this!!!
 * } catch (IOException ioexc) {
 *   ioexc.printStackTrace(); 
 * }
 * 

*

* The serverpassword isn't needed in most cases. You can give * null or "" instead as done in this example. * @author Christoph Schwering <schwering@gmail.com> * @version 3.05 * @see IRCEventListener * @see IRCParser * @see IRCUtil * @see SSLIRCConnection */ public class IRCConnection extends Thread { /** * This Socket is a connection to the IRC server. */ private Socket socket; /** * This is like a UNIX-runlevel. Its value indicates the level of the * IRCConnection object. 0 means that the object * has not yet been connected, 1 means that it's connected but * not registered, 2 means that it's connected and registered * but still waiting to receive the nickname the first time, 3 * means that it's connected and registered, and -1 means that * it was connected but is disconnected. * Therefore the defaultvalue is 0. */ protected byte level = 0; /** * The host of the IRC server. */ protected String host; /** * The int[] contains all ports to which we are going to try to * connect. This can be a portrange from port 6667 to 6669, for example. */ protected int[] ports; /** * The BufferedReader receives Strings from the IRC server. */ private volatile BufferedReader in; /** * The PrintWriter sends Strings to the IRC server. */ private PrintWriter out; /** * The String contains the name of the character encoding used * to talk to the server. This can be ISO-8859-1 or UTF-8 for example. The * default is ISO-8859-1. */ protected String encoding = "ISO-8859-1"; /** * This array contains IRCEventListener objects. */ private IRCEventListener[] listeners = new IRCEventListener[0]; /** * This int is the connection's timeout in milliseconds. It's * used in the Socket.setSoTimeout method. The default is * 1000 * 60 * 15 millis which are 15 minutes. */ private int timeout = 1000 * 60 * 15; /** * This boolean stands for enabled (true) or * disabled (false) ColorCodes.
Default is enabled * (false). */ private boolean colorsEnabled = false; /** * This boolean stands for enabled or disabled automatic PING? * PONG! support.
It means, that if the server asks with PING for the * ping, the PONG is automatically sent. Default is automatic PONG enabled * (true). */ private boolean pongAutomatic = true; /** * The password, which is needed to get access to the IRC server. */ private String pass; /** * The user's nickname, which is indispensably to connect. */ private String nick; /** * The user's realname, which is indispensably to connect. */ private String realname; /** * The user's username, which is indispensable to connect. */ private String username; // ------------------------------ /** * Creates a new IRC connection.
* The difference to the other constructor is, that it transmits the ports in * an int[]. Thus, also ports like 1024, 2048, 6667 and * 6669 can be selected.

* The constructor prepares a new IRC connection which can be really started * by invoking the connect method. Before invoking it, you should * set the IRCEventListener and other settings.
* Note that you do not need to set a password to connect to the large public * IRC networks like QuakeNet, EFNet etc. To use no password in your IRC * connection, use "" or null for the password * argument in the constructor. * @param host The hostname of the server we want to connect to. * @param ports The portrange to which we want to connect. * @param pass The password of the IRC server. If your server isn't * secured by a password (that's normal), use * null or "". * @param nick The nickname for the connection. Is used to register the * connection. * @param username The username. Is used to register the connection. * @param realname The realname. Is used to register the connection. * @throws IllegalArgumentException If the host or * ports is null or * ports' length is * 0. * @see #connect() */ public IRCConnection(String host, int[] ports, String pass, String nick, String username, String realname) { if (host == null || ports == null || ports.length == 0) throw new IllegalArgumentException("Host and ports may not be null."); this.host = host; this.ports = ports; this.pass = (pass != null && pass.length() == 0) ? null : pass; this.nick = nick; this.username = username; this.realname = realname; } // ------------------------------ /** * Creates a new IRC connection.
* The difference to the other constructor is, that it transmits the ports as * two ints. Thus, only a portrange from port x to * port y like from port 6667 to 6669 can be selected.
*
* The constructor prepares a new IRC connection which can be really started * by invoking the connect method. Before invoking it, you should * set the IRCEventListener and other settings.
* Note that you do not need to set a password to connect to the large public * IRC networks like QuakeNet, EFNet etc. To use no password in your IRC * connection, use "" or null for the password * argument in the constructor. * @param host The hostname of the server we want to connect to. * @param portMin The beginning of the port range we are going to connect * to. * @param portMax The ending of the port range we are going to connect to. * @param pass The password of the IRC server. If your server isn't * secured by a password (that's normal), use * null or "". * @param nick The nickname for the connection. Is used to register the * connection. * @param username The username. Is used to register the connection. * @param realname The realname. Is used to register the connection. * @throws IllegalArgumentException If the host is * null. * @see #connect() */ public IRCConnection(String host, int portMin, int portMax, String pass, String nick, String username, String realname) { this(host, portRangeToArray(portMin, portMax), pass, nick, username, realname); } // ------------------------------ /** * Converts a portrange which starts with a given int and ends * with a given int into an array which contains all * ints from the beginning to the ending (including beginning * and ending).
* If portMin > portMax, the portrange is turned arount * automatically. * @param portMin The beginning port of the portrange. * @param portMax The ending port of the portrange. */ private static int[] portRangeToArray(int portMin, int portMax) { if (portMin > portMax) { int tmp = portMin; portMin = portMax; portMax = tmp; } int[] ports = new int[portMax - portMin + 1]; for (int i = 0; i < ports.length; i++) ports[i] = portMin + i; return ports; } // ------------------------------ /** * Establish a connection to the server.
* This method must be invoked to start a connection; the constructor doesn't * do that!
* It tries all set ports until one is open. If all ports fail it throws an * IOException.
* You can invoke connect only one time. * @throws IOException If an I/O error occurs. * @throws SocketException If the connect method was already * invoked. * @see #isConnected() * @see #doQuit() * @see #doQuit(String) * @see #close() */ public void connect() throws IOException { if (level != 0) // otherwise disconnected or connect throw new SocketException("Socket closed or already open ("+ level +")"); IOException exception = null; Socket s = null; for (int i = 0; i < ports.length && s == null; i++) { try { s = new Socket(host, ports[i]); exception = null; } catch (IOException exc) { if (s != null) s.close(); s = null; exception = exc; } } if (exception != null) throw exception; // connection wasn't successful at any port prepare(s); } // ------------------------------ /** * Invoked by the connect method, this method prepares the * connection.
* It initializes the class-vars for the inputstream and the outputstream of * the socket, starts the registration of at the IRC server by calling * register() and starts the receiving of lines from the server * by starting the thread with the start method.

* This method must be protected, because it is used by extending classes, * which override the connect method. * @param s The socket which is used for the connection. * @throws IOException If an I/O error occurs. * @see #connect() * @see #run() */ protected void prepare(Socket s) throws IOException { if (s == null) throw new SocketException("Socket s is null, not connected"); socket = s; level = 1; s.setSoTimeout(timeout); in = new BufferedReader(new InputStreamReader(s.getInputStream(), encoding)); out = new PrintWriter(new OutputStreamWriter(s.getOutputStream(), encoding)); start(); register(); } // ------------------------------ /** * Registers the connection with the IRC server.
* In fact, it sends a password (if set, else nothing), the nickname and the * user, the realname and the host which we're connecting to.
* The action synchronizes code> so that no important messages * (like the first PING) come in before this registration is finished.
* The USER command's format is:
* <username> <localhost> <irchost> <realname> * */ private void register() { if (pass != null) send("PASS "+ pass); send("NICK "+ nick); send("USER "+ username +" "+ socket.getLocalAddress() +" "+ host +" :"+ realname); } // ------------------------------ /** * The Thread is started by the connect method. * It's task is to receive strings from the IRC server and hand them over * to the get method. */ public void run() { try { String line; while (!isInterrupted()) { line = in.readLine(); if (line != null) get(line); else close(); } } catch (IOException exc) { close(); } } // ------------------------------ /** * Sends a String to the server. * You should use this method only, if you must do it. For most purposes, * there are do* methods (like doJoin). A carriage * return line feed (\r\n) is appended automatically. * @param line The line which should be send to the server without the * trailing carriage return line feed (\r\n). */ public void send(String line) { try { out.write(line +"\r\n"); out.flush(); if (level == 1) { // not registered IRCParser p = new IRCParser(line); if (p.getCommand().equalsIgnoreCase("NICK")) nick = p.getParameter(1).trim(); } } catch (Exception exc) { exc.printStackTrace(); } } // ------------------------------ /** * Just parses a String given as the only argument with the help of the * IRCParser class. Then it controls the command and fires events * through the IRCEventListener.
* @param line The line which is sent from the server. */ private synchronized void get(String line) { IRCParser p; try { p = new IRCParser(line, colorsEnabled); } catch (Exception exc) { return; } String command = p.getCommand(); int reply; // 3-digit reply will be parsed in the later if-condition if (command.equalsIgnoreCase("PRIVMSG")) { // MESSAGE IRCUser user = p.getUser(); String middle = p.getMiddle(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onPrivmsg(middle, user, trailing); } else if (command.equalsIgnoreCase("MODE")) { // MODE String chan = p.getParameter(1); if (IRCUtil.isChan(chan)) { IRCUser user = p.getUser(); String param2 = p.getParameter(2); String paramsFrom3 = p.getParametersFrom(3); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onMode(chan, user, new IRCModeParser(param2, paramsFrom3)); } else { IRCUser user = p.getUser(); String paramsFrom2 = p.getParametersFrom(2); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onMode(user, chan, paramsFrom2); } } else if (command.equalsIgnoreCase("PING")) { // PING String ping = p.getTrailing(); // no int cause sometimes it's text if (pongAutomatic) doPong(ping); else for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onPing(ping); if (level == 1) { // not registered level = 2; // first PING received -> connection for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onRegistered(); } } else if (command.equalsIgnoreCase("JOIN")) { // JOIN IRCUser user = p.getUser(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onJoin(trailing, user); } else if (command.equalsIgnoreCase("NICK")) { // NICK IRCUser user = p.getUser(); String changingNick = p.getNick(); String newNick = p.getTrailing(); if (changingNick.equalsIgnoreCase(nick)) nick = newNick; for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onNick(user, newNick); } else if (command.equalsIgnoreCase("QUIT")) { // QUIT IRCUser user = p.getUser(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onQuit(user, trailing); } else if (command.equalsIgnoreCase("PART")) { // PART IRCUser user = p.getUser(); String chan = p.getParameter(1); String msg = p.getParameterCount() > 1 ? p.getTrailing() : ""; // not logic: "PART :#zentrum" is without msg, "PART #zentrum :cjo all" // is with msg. so we cannot use getMiddle and getTrailing :-/ for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onPart(chan, user, msg); } else if (command.equalsIgnoreCase("NOTICE")) { // NOTICE IRCUser user = p.getUser(); String middle = p.getMiddle(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onNotice(middle, user, trailing); } else if ((reply = IRCUtil.parseInt(command)) >= 1 && reply < 400) { // RPL String potNick = p.getParameter(1); if ((level == 1 || level == 2) && nick.length() > potNick.length() && nick.substring(0, potNick.length()).equalsIgnoreCase(potNick)) { nick = potNick; if (level == 2) level = 3; } if (level == 1) { // not registered level = 2; // if first PING wasn't received, we're for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onRegistered(); // connected now for sure } String middle = p.getMiddle(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onReply(reply, middle, trailing); } else if (reply >= 400 && reply < 600) { // ERROR String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onError(reply, trailing); } else if (command.equalsIgnoreCase("KICK")) { // KICK IRCUser user = p.getUser(); String param1 = p.getParameter(1); String param2 = p.getParameter(2); String msg = (p.getParameterCount() > 2) ? p.getTrailing() : ""; for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onKick(param1, user, param2, msg); } else if (command.equalsIgnoreCase("INVITE")) { // INVITE IRCUser user = p.getUser(); String middle = p.getMiddle(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onInvite(trailing, user, middle); } else if (command.equalsIgnoreCase("TOPIC")) { // TOPIC IRCUser user = p.getUser(); String middle = p.getMiddle(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onTopic(middle, user, trailing); } else if (command.equalsIgnoreCase("ERROR")) { // ERROR String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onError(trailing); } else { // OTHER String prefix = p.getPrefix(); String middle = p.getMiddle(); String trailing = p.getTrailing(); for (int i = listeners.length - 1; i >= 0; i--) listeners[i].unknown(prefix, command, middle, trailing); } } // ------------------------------ /** * Close down the connection brutally.
* It does *NOT* send the proper IRC command QUIT. You should * always use the doQuit methods or send("QUIT") * instead of this method.
* You should use this method to close down the connection only when the IRC * server doesn't react to the QUIT command. * @see #connect() * @see #doQuit * @see #doQuit(String) */ public synchronized void close() { try { if (!isInterrupted()) interrupt(); } catch (Exception exc) { exc.printStackTrace(); } try { if (socket != null) socket.close(); } catch (Exception exc) { exc.printStackTrace(); } try { if (out != null) out.close(); } catch (Exception exc) { exc.printStackTrace(); } try { if (in != null) in.close(); } catch (Exception exc) { exc.printStackTrace(); } if (this.level != -1) { this.level = -1; for (int i = listeners.length - 1; i >= 0; i--) listeners[i].onDisconnected(); } socket = null; in = null; out = null; listeners = new IRCEventListener[0]; } // ------------------------------ /** * Adds a new {@link org.schwering.irc.lib.IRCEventListener} which listens * for actions coming from the IRC server. * @param l An instance of the * {@link org.schwering.irc.lib.IRCEventListener} interface. * @throws IllegalArgumentException If listener is * null. */ public synchronized void addIRCEventListener(IRCEventListener l) { if (l == null) throw new IllegalArgumentException("Listener is null."); int len = listeners.length; IRCEventListener[] oldListeners = listeners; listeners = new IRCEventListener[len + 1]; System.arraycopy(oldListeners, 0, listeners, 0, len); listeners[len] = l; } // ------------------------------ /** * Removes the first occurence of the given * {@link org.schwering.irc.lib.IRCEventListener} from the listener-vector. * @param l An instance of the * {@link org.schwering.irc.lib.IRCEventListener} interface. * @return true if the listener was successfully removed; * false if it was not found. */ public synchronized boolean removeIRCEventListener(IRCEventListener l) { if (l == null) return false; int index = -1; for (int i = 0; i < listeners.length; i++) if (listeners[i].equals(l)) { index = i; break; } if (index == -1) return false; listeners[index] = null; int len = listeners.length - 1; IRCEventListener[] newListeners = new IRCEventListener[len]; for (int i = 0, j = 0; i < len; j++) if (listeners[j] != null) newListeners[i++] = listeners[j]; listeners = newListeners; return true; } // ------------------------------ /** * Enables or disables the mIRC colorcodes. * @param colors true to enable, false to disable * colors. */ public void setColors(boolean colors) { colorsEnabled = colors; } // ------------------------------ /** * Enables or disables the automatic PING? PONG! support. * @param pong true to enable automatic PONG * reply, false makes the class fire * onPing events. */ public void setPong(boolean pong) { pongAutomatic = pong; } // ------------------------------ /** * Changes the character encoding used to talk to the server. * This can be ISO-8859-1 or UTF-8 for example. * This property must be set before a call to the connect() * method. * @param encoding */ public void setEncoding(String encoding) { this.encoding = encoding; } // ------------------------------ /** * Sets the connection's timeout in milliseconds.
* The default is 1000 * 60 15 millis which are 15 minutes. */ public void setTimeout(int millis) { if (socket != null) try { socket.setSoTimeout(millis); } catch (IOException exc) { exc.printStackTrace(); } timeout = millis; } // ------------------------------ /** * Tells whether there's a connection to the IRC network or not.
* If connect wasn't called yet, it returns false. * @return The status of the connection; true if it's connected. * @see #connect() * @see #doQuit() * @see #doQuit(String) * @see #close() */ public boolean isConnected() { return level >= 1; } // ------------------------------ /** * Returns the nickname of this instance. * @return The nickname. */ public String getNick() { return nick; } // ------------------------------ /** * Returns the realname of this instance. * @return The realname. */ public String getRealname() { return realname; } // ------------------------------ /** * Returns the username of this instance. * @return The username. */ public String getUsername() { return username; } // ------------------------------ /** * Returns the server of this instance. * @return The server's hostname. */ public String getHost() { return host; } // ------------------------------ /** * Returns the password of this instance. If no password is set, * null is returned. * @return The password. If no password is set, null is * returned. */ public String getPassword() { return pass; } // ------------------------------ /** * Returns all ports to which the IRCConnection is going to try * or has tried to connect to. * @return The ports in an int[] array. */ public int[] getPorts() { return ports; } // ------------------------------ /** * Returns the port to which the IRCConnection connected, or * 0 if the connection failed or wasn't tried yet. * @return The port to which the IRCConnection, or * 0 if the connection failed or wasn't tried yet. */ public int getPort() { return (socket != null) ? socket.getPort() : 0; } // ------------------------------ /** * Indicates whether colors are stripped out or not. * @return true if colors are disabled. */ public boolean getColors() { return colorsEnabled; } // ------------------------------ /** * Indicates whether automatic PING? PONG! is enabled or not. * @return true if PING? PONG! is done automatically. */ public boolean getPong() { return pongAutomatic; } // ------------------------------ /** * Returns the encoding of the socket. * @return The socket's encoding. */ public String getEncoding() { return encoding; } // ------------------------------ /** * Returns the timeout of the socket.
* If an error occurs, which is never the case, -1 is returned. * @return The timeout. */ public int getTimeout() { if (socket != null) try { return socket.getSoTimeout(); } catch (IOException exc) { exc.printStackTrace(); return -1; } else return timeout; } // ------------------------------ /** * Generates a String with some information about the instance of * IRCConnection. * Its format is: * classname[host,portMin,portMax,username,nick,realname,pass,connected] * . * @return A String with information about the instance. */ public String toString() { return getClass().getName() +"["+ host +","+ getPort() +","+ username +","+ nick +","+ realname +","+ pass +","+ isConnected() +"]"; } // ------------------------------ /** * Removes away message. */ public void doAway() { send("AWAY"); } // ------------------------------ /** * Sets away message. * @param msg The away message. */ public void doAway(String msg) { send("AWAY :"+ msg); } // ------------------------------ /** * Invites a user to a channel. * @param nick The nickname of the user who should be invited. * @param chan The channel the user should be invited to. */ public void doInvite(String nick, String chan) { send("INVITE "+ nick +" "+ chan); } // ------------------------------ /** * Checks if one or more nicks are used on the server. * @param nick The nickname of the user we search for. */ public void doIson(String nick) { send("ISON "+ nick); } // ------------------------------ /** * Joins a channel without a key. * @param chan The channel which is to join. */ public void doJoin(String chan) { send("JOIN "+ chan); } // ------------------------------ /** * Joins a channel with a key. * @param chan The channel which is to join. * @param key The key of the channel. */ public void doJoin(String chan, String key) { send("JOIN "+ chan +" "+ key); } // ------------------------------ /** * Kicks a user from a channel. * @param chan The channel somebody should be kicked from. * @param nick The nickname of the user who should be kicked. */ public void doKick(String chan, String nick) { send("KICK "+ chan +" "+ nick); } // ------------------------------ /** * Kicks a user from a channel with a comment. * @param chan The channel somebody should be kicked from. * @param nick The nickname of the user who should be kicked. * @param msg The optional kickmessage. */ public void doKick(String chan, String nick, String msg) { send("KICK "+ chan +" "+ nick +" :"+ msg); } // ------------------------------ /** * Lists all channels with their topic and status. */ public void doList() { send("LIST"); } // ------------------------------ /** * Lists channel(s) with their topic and status. * @param chan The channel the LIST refers to. */ public void doList(String chan) { send("LIST "+ chan); } // ------------------------------ /** * Lists all visible users. */ public void doNames() { send("NAMES"); } // ------------------------------ /** * Lists all visible users of (a) channel(s). * @param chan The channel the NAMES command is refering to. */ public void doNames(String chan) { send("NAMES "+ chan); } // ------------------------------ /** * Sends a message to a person or a channel. * @param target The nickname or channel the message should be sent to. * @param msg The message which should be transmitted. */ public void doPrivmsg(String target, String msg) { send("PRIVMSG "+ target +" :"+ msg); } // ------------------------------ /** * Requests a Reply 324 for the modes of a given channel. * @param chan The channel the MODE request is refering to. */ public void doMode(String chan) { send("MODE "+ chan); } // ------------------------------ /** * Sends a mode to the server.
* The first argument is a nickname (user-mode) or a channel (channel-mode). * String mode must contain the operators (+/-), the modes * (o/v/i/k/l/p/s/w) and the possibly values (nicks/banmask/limit/key). * @param target The nickname or channel of the user whose modes will be * changed. * @param mode The new modes. */ public void doMode(String target, String mode) { send("MODE "+ target +" "+ mode); } // ------------------------------ /** * Changes the nickname. * @param nick The new nickname. */ public void doNick(String nick) { send("NICK "+ nick); } // ------------------------------ /** * Notices a message to a person or a channel. * @param target The nickname or channel (group) the message should be * sent to. * @param msg The message which should be transmitted. */ public void doNotice(String target, String msg) { send("NOTICE "+ target +" :"+ msg); } // ------------------------------ /** * Parts from a given channel. * @param chan The channel you want to part from. */ public void doPart(String chan) { send("PART "+ chan); } // ------------------------------ /** * Parts from a given channel with a given parg-msg. * @param chan The channel you want to part from. * @param msg The optional partmessage. */ public void doPart(String chan, String msg) { send("PART "+ chan +" :"+ msg); } // ------------------------------ /** * Quits from the IRC server with a quit-msg. * @param ping The ping which was received in onPing. It's a * String, because sometimes on some networks * the server-hostname (for example splatterworld.quakenet.org) is * given as parameter which would throw an Exception if we * gave the ping as long. */ public void doPong(String ping) { send("PONG :"+ ping); } // ------------------------------ /** * Quits from the IRC server. * Calls the disconnect-method which does the work actually. * @see #isConnected() * @see #connect() * @see #doQuit(String) * @see #close() */ public void doQuit() { send("QUIT"); } // ------------------------------ /** * Quits from the IRC server with a quit-msg. * Calls the disconnect-method which does the work actually. * @param msg The optional quitmessage. * @see #isConnected() * @see #connect() * @see #doQuit() * @see #close() */ public void doQuit(String msg) { send("QUIT :"+ msg); } // ------------------------------ /** * Requests the topic of a chan. The topic is given in a numeric reply. * @param chan The channel which topic should be requested. */ public void doTopic(String chan) { send("TOPIC "+ chan); } // ------------------------------ /** * Changes the topic of a chan. * @param chan The channel which topic is changed. * @param topic The new topic. */ public void doTopic(String chan, String topic) { send("TOPIC "+ chan +" :"+ topic); } // ------------------------------ /** * Requests information about users matching the given criteric, * for example a channel they are on. * @param criteric The criterics of the WHO query. */ public void doWho(String criteric) { send("WHO "+ criteric); } // ------------------------------ /** * Requires information about an existing user. * @param nick The nickname of the user the query is refering to. */ public void doWhois(String nick) { send("WHOIS "+ nick); } // ------------------------------ /** * Requires host-information about a user, who is not connected anymore. * @param nick The nickname of the user the query is refering to. */ public void doWhowas(String nick) { send("WHOWAS "+ nick); } // ------------------------------ /** * Requires host-information about up to 5 users which must be listed and * divided by spaces. * @param nick The nickname of the user the query is refering to. */ public void doUserhost(String nick) { send("USERHOST "+ nick); } } libirclib-java-1.10/src/org/schwering/irc/lib/IRCConstants.java000066400000000000000000001404131155103677700243730ustar00rootroot00000000000000package org.schwering.irc.lib; /** * Contains constants: reply codes, error codes and mIRC color codes. * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 1.00 * @see IRCEventListener#onError(int, String) * @see IRCEventListener#onReply(int, String, String) */ public interface IRCConstants { /** * Usually the first replies when you're connected. */ public static final int RPL_WELCOME = 001; /** * Usually the first replies when you're connected. */ public static final int RPL_YOURHOST = 002; /** * Usually the first replies when you're connected. */ public static final int RPL_CREATED = 003; /** * Usually the first replies when you're connected. */ public static final int RPL_MYINFO = 004; /** * Usually the first replies when you're connected. */ public static final int RPL_ISUPPORT = 005; /** * Used to indicate the nickname parameter supplied to * a command is currently unused. */ public static final int ERR_NOSUCHNICK = 401; /** * Format: "<server name> No such server".
* Used to indicate the server name given currently * doesn't exist. */ public static final int ERR_NOSUCHSERVER = 402; /** * Format: "<channel name> No such channel".
* Used to indicate the given channel name is invalid. */ public static final int ERR_NOSUCHCHANNEL = 403; /** * Format: "<channel name> Cannot send to channel".
* Sent to a user who is either (a) not on a channel * which is mode +n or (b) not a chanop (or mode +v) on * a channel which has mode +m set and is trying to send * a PRIVMSG message to that channel. */ public static final int ERR_CANNOTSENDTOCHAN = 404; /** * Format: "<channel name> You have joined too many * channels".
* Sent to a user when they have joined the maximum * number of allowed channels and they try to join * another channel. */ public static final int ERR_TOOMANYCHANNELS = 405; /** * Format: "<nickname> There was no such nickname".
* Returned by WHOWAS to indicate there is no history * information for that nickname. */ public static final int ERR_WASNOSUCHNICK = 406; /** * Format: "<target> Duplicate recipients. No message delivered".
* Returned to a client which is attempting to send a PRIVMSG/NOTICE using * the user@host destination format and for a user@host which has several * occurrences. */ public static final int ERR_TOOMANYTARGETS = 407; /** * Format: "No origin specified".
* PING or PONG message missing the originator parameter * which is required since these commands must work * without valid prefixes. */ public static final int ERR_NOORIGIN = 409; /** * Format: "No recipient given (<command>)". */ public static final int ERR_NORECIPIENT = 411; /** * Format: "No text to send".
* 412 - 414 are returned by PRIVMSG to indicate that * the message wasn't delivered for some reason. * ERR_NOTOPLEVEL and ERR_WILDTOPLEVEL are errors that * are returned when an invalid use of * "PRIVMSG $<server>" or "PRIVMSG #<host>" is attempted. */ public static final int ERR_NOTEXTTOSEND = 412; /** * Format: "<mask> No toplevel domain specified".
* 412 - 414 are returned by PRIVMSG to indicate that * the message wasn't delivered for some reason. * ERR_NOTOPLEVEL and ERR_WILDTOPLEVEL are errors that * are returned when an invalid use of * "PRIVMSG $<server>" or "PRIVMSG #<host>" is attempted. */ public static final int ERR_NOTOPLEVEL = 413; /** * Format: "<mask> Wildcard in toplevel domain".
* 412 - 414 are returned by PRIVMSG to indicate that * the message wasn't delivered for some reason. * ERR_NOTOPLEVEL and ERR_WILDTOPLEVEL are errors that * are returned when an invalid use of * "PRIVMSG $<server>" or "PRIVMSG #<host>" is attempted. */ public static final int ERR_WILDTOPLEVEL = 414; /** * Format: "<command> Unknown command".
* Returned to a registered client to indicate that the * command sent is unknown by the server. */ public static final int ERR_UNKNOWNCOMMAND = 421; /** * Format: "MOTD File is missing".
* Server's MOTD file could not be opened by the server. */ public static final int ERR_NOMOTD = 422; /** * Format: "<server> No administrative info available".
* Returned by a server in response to an ADMIN message * when there is an error in finding the appropriate * information. */ public static final int ERR_NOADMININFO = 423; /** * Format: "File error doing <file op> on <file>".
* Generic error message used to report a failed file * operation during the processing of a message. */ public static final int ERR_FILEERROR = 424; /** * Format: "No nickname given".
* Returned when a nickname parameter expected for a * command and isn't found. */ public static final int ERR_NONICKNAMEGIVEN = 431; /** * Format: "<nick> Erroneus nickname".
* Returned after receiving a NICK message which contains * characters which do not fall in the defined set. See * section x.x.x for details on valid nicknames. */ public static final int ERR_ERRONEUSNICKNAME = 432; /** * Format: "<nick> Nickname is already in use".
* Returned when a NICK message is processed that results * in an attempt to change to a currently existing * nickname. */ public static final int ERR_NICKNAMEINUSE = 433; /** * Format: "<nick> Nickname collision KILL".
* Returned by a server to a client when it detects a * nickname collision (registered of a NICK that * already exists by another server). */ public static final int ERR_NICKCOLLISION = 436; /** * Format: "<nick> <channel> They aren't on that channel".
* Returned by the server to indicate that the target * user of the command is not on the given channel. */ public static final int ERR_USERNOTINCHANNEL = 441; /** * Format: "<channel> You're not on that channel".
* Returned by the server whenever a client tries to * perform a channel effecting command for which the * client isn't a member. */ public static final int ERR_NOTONCHANNEL = 442; /** * Format: "<user> <channel> is already on channel".
* Returned when a client tries to invite a user to a * channel they are already on. */ public static final int ERR_USERONCHANNEL = 443; /** * Format: "<user> User not logged in".
* Returned by the summon after a SUMMON command for a * user was unable to be performed since they were not * logged in. */ public static final int ERR_NOLOGIN = 444; /** * Format: "SUMMON has been disabled".
* Returned as a response to the SUMMON command. Must be * returned by any server which does not implement it. */ public static final int ERR_SUMMONDISABLED = 445; /** * Format: "USERS has been disabled".
* Returned as a response to the USERS command. Must be * returned by any server which does not implement it. */ public static final int ERR_USERSDISABLED = 446; /** * Format: "You have not registered".
* Returned by the server to indicate that the client * must be registered before the server will allow it * to be parsed in detail. */ public static final int ERR_NOTREGISTERED = 451; /** * Format: "<command> Not enough parameters".
* Returned by the server by numerous commands to * indicate to the client that it didn't supply enough * parameters. */ public static final int ERR_NEEDMOREPARAMS = 461; /** * Format: "You may not reregister".
* Returned by the server to any link which tries to * change part of the registered details (such as * password or user details from second USER message). */ public static final int ERR_ALREADYREGISTRED = 462; /** * Format: "Your host isn't among the privileged".
* Returned to a client which attempts to register with * a server which does not been setup to allow * connections from the host the attempted connection * is tried. */ public static final int ERR_NOPERMFORHOST = 463; /** * Format: "Password incorrect".
* Returned to indicate a failed attempt at registering * a connection for which a password was required and * was either not given or incorrect. */ public static final int ERR_PASSWDMISMATCH = 464; /** * Format: "You are banned from this server".
* Returned after an attempt to connect and register * yourself with a server which has been setup to * explicitly deny connections to you. */ public static final int ERR_YOUREBANNEDCREEP = 465; /** * Format: "<channel> Channel key already set". */ public static final int ERR_KEYSET = 467; /** * Format: "<channel> Cannot join channel (+l)". */ public static final int ERR_CHANNELISFULL = 471; /** * Format: "<char> is unknown mode char to me". */ public static final int ERR_UNKNOWNMODE = 472; /** * Format: "<channel> Cannot join channel (+i)". */ public static final int ERR_INVITEONLYCHAN = 473; /** * Format: "<channel> Cannot join channel (+b)". */ public static final int ERR_BANNEDFROMCHAN = 474; /** * Format: "<channel> Cannot join channel (+k)". */ public static final int ERR_BADCHANNELKEY = 475; /** * Format: "Permission Denied- You're not an IRC operator". * Any command requiring operator privileges to operate * must return this error to indicate the attempt was * unsuccessful. */ public static final int ERR_NOPRIVILEGES = 481; /** * Format: "<channel> You're not channel operator".
* Any command requiring 'chanop' privileges (such as * MODE messages) must return this error if the client * making the attempt is not a chanop on the specified * channel. */ public static final int ERR_CHANOPRIVSNEEDED = 482; /** * Format: "You cant kill a server!".
* Any attempts to use the KILL command on a server * are to be refused and this error returned directly * to the client. */ public static final int ERR_CANTKILLSERVER = 483; /** * Format: "No O-lines for your host".
* If a client sends an OPER message and the server has * not been configured to allow connections from the * client's host as an operator, this error must be * returned. */ public static final int ERR_NOOPERHOST = 491; /** * Format: "Unknown MODE flag".
* Returned by the server to indicate that a MODE * message was sent with a nickname parameter and that * the a mode flag sent was not recognized. */ public static final int ERR_UMODEUNKNOWNFLAG = 501; /** * Format: "Cant change mode for other users".
* Error sent to any user trying to view or change the * user mode for a user other than themselves. */ public static final int ERR_USERSDONTMATCH = 502; /** * Dummy reply number. Not used. */ public static final int RPL_NONE = 300; /** * Format: "[<reply>{<space><reply>}]".
* Reply format used by USERHOST to list replies to * the query list. The reply string is composed as * follows:
* <reply> ::= <nick>['*'] '=' <'+'|'-'><hostname> *
* The '*' indicates whether the client has registered * as an Operator. The '-' or '+' characters represent * whether the client has set an AWAY message or not * respectively. */ public static final int RPL_USERHOST = 302; /** * Format: "[<nick> {<space><nick>}]".
* Reply format used by ISON to list replies to the * query list. */ public static final int RPL_ISON = 303; /** * Format: "<nick> <away message>". */ public static final int RPL_AWAY = 301; /** * Format: "You are no longer marked as being away". */ public static final int RPL_UNAWAY = 305; /** * Format: "You have been marked as being away".
* These replies are used with the AWAY command (if * allowed). RPL_AWAY is sent to any client sending a * PRIVMSG to a client which is away. RPL_AWAY is only * sent by the server to which the client is connected. * Replies RPL_UNAWAY and RPL_NOWAWAY are sent when the * client removes and sets an AWAY message. */ public static final int RPL_NOWAWAY = 306; /** * Format: "<nick> <user> <host> * :<real name>". *
* Replies 311 - 313, 317 - 319 are all replies * generated in response to a WHOIS message. Given that * there are enough parameters present, the answering * server must either formulate a reply out of the above * numerics (if the query nick is found) or return an * error reply. The '*' in RPL_WHOISUSER is there as * the literal character and not as a wild card. For * each reply set, only RPL_WHOISCHANNELS may appear * more than once (for long lists of channel names). * The '@' and '+' characters next to the channel name * indicate whether a client is a channel operator or * has been granted permission to speak on a moderated * channel. The RPL_ENDOFWHOIS reply is used to mark * the end of processing a WHOIS message. */ public static final int RPL_WHOISUSER = 311; /** * Format: "<nick> <server> <server info>".
* Replies 311 - 313, 317 - 319 are all replies * generated in response to a WHOIS message. Given that * there are enough parameters present, the answering * server must either formulate a reply out of the above * numerics (if the query nick is found) or return an * error reply. The '*' in RPL_WHOISUSER is there as * the literal character and not as a wild card. For * each reply set, only RPL_WHOISCHANNELS may appear * more than once (for long lists of channel names). * The '@' and '+' characters next to the channel name * indicate whether a client is a channel operator or * has been granted permission to speak on a moderated * channel. The RPL_ENDOFWHOIS reply is used to mark * the end of processing a WHOIS message. */ public static final int RPL_WHOISSERVER = 312; /** * Format: "<nick> is an IRC operator".
* Replies 311 - 313, 317 - 319 are all replies * generated in response to a WHOIS message. Given that * there are enough parameters present, the answering * server must either formulate a reply out of the above * numerics (if the query nick is found) or return an * error reply. The '*' in RPL_WHOISUSER is there as * the literal character and not as a wild card. For * each reply set, only RPL_WHOISCHANNELS may appear * more than once (for long lists of channel names). * The '@' and '+' characters next to the channel name * indicate whether a client is a channel operator or * has been granted permission to speak on a moderated * channel. The RPL_ENDOFWHOIS reply is used to mark * the end of processing a WHOIS message. */ public static final int RPL_WHOISOPERATOR = 313; /** * Format: "<nick> <integer> seconds idle".
* Replies 311 - 313, 317 - 319 are all replies * generated in response to a WHOIS message. Given that * there are enough parameters present, the answering * server must either formulate a reply out of the above * numerics (if the query nick is found) or return an * error reply. The '*' in RPL_WHOISUSER is there as * the literal character and not as a wild card. For * each reply set, only RPL_WHOISCHANNELS may appear * more than once (for long lists of channel names). * The '@' and '+' characters next to the channel name * indicate whether a client is a channel operator or * has been granted permission to speak on a moderated * channel. The RPL_ENDOFWHOIS reply is used to mark * the end of processing a WHOIS message. */ public static final int RPL_WHOISIDLE = 317; /** * Format: "<nick> End of /WHOIS list".
* Replies 311 - 313, 317 - 319 are all replies * generated in response to a WHOIS message. Given that * there are enough parameters present, the answering * server must either formulate a reply out of the above * numerics (if the query nick is found) or return an * error reply. The '*' in RPL_WHOISUSER is there as * the literal character and not as a wild card. For * each reply set, only RPL_WHOISCHANNELS may appear * more than once (for long lists of channel names). * The '@' and '+' characters next to the channel name * indicate whether a client is a channel operator or * has been granted permission to speak on a moderated * channel. The RPL_ENDOFWHOIS reply is used to mark * the end of processing a WHOIS message. */ public static final int RPL_ENDOFWHOIS = 318; /** * Format: "<nick> {[@|+]<channel><space>}".
* Replies 311 - 313, 317 - 319 are all replies * generated in response to a WHOIS message. Given that * there are enough parameters present, the answering * server must either formulate a reply out of the above * numerics (if the query nick is found) or return an * error reply. The '*' in RPL_WHOISUSER is there as * the literal character and not as a wild card. For * each reply set, only RPL_WHOISCHANNELS may appear * more than once (for long lists of channel names). * The '@' and '+' characters next to the channel name * indicate whether a client is a channel operator or * has been granted permission to speak on a moderated * channel. The RPL_ENDOFWHOIS reply is used to mark * the end of processing a WHOIS message. */ public static final int RPL_WHOISCHANNELS = 319; /** * Format: "<nick> <user> <host> * <real name>". */ public static final int RPL_WHOWASUSER = 314; /** * Format: "<nick> End of WHOWAS".
* When replying to a WHOWAS message, a server must use * the replies RPL_WHOWASUSER, RPL_WHOISSERVER or * ERR_WASNOSUCHNICK for each nickname in the presented * list. At the end of all reply batches, there must * be RPL_ENDOFWHOWAS (even if there was only one reply * and it was an error). */ public static final int RPL_ENDOFWHOWAS = 369; /** * Format: "Channel Users Name".
* Replies RPL_LISTSTART, RPL_LIST, RPL_LISTEND mark * the start, actual replies with data and end of the * server's response to a LIST command. If there are * no channels available to return, only the start * and end reply must be sent. */ public static final int RPL_LISTSTART = 321; /** * Format: "<channel> <# visible> <topic>".
* Replies RPL_LISTSTART, RPL_LIST, RPL_LISTEND mark * the start, actual replies with data and end of the * server's response to a LIST command. If there are * no channels available to return, only the start * and end reply must be sent. */ public static final int RPL_LIST = 322; /** * Format: "End of /LIST".
* Replies RPL_LISTSTART, RPL_LIST, RPL_LISTEND mark * the start, actual replies with data and end of the * server's response to a LIST command. If there are * no channels available to return, only the start * and end reply must be sent. */ public static final int RPL_LISTEND = 323; /** * Format: "<channel> <mode> <mode params>".
*/ public static final int RPL_CHANNELMODEIS = 324; /** * Format: "<nick> <authname> is authed as"
* This is part of /WHOIS on many servers which provide bots to authenticate. */ public static final int RPL_AUTHNAME = 333; /** * Format: "<channel> No topic is set".
* When sending a TOPIC message to determine the * channel topic, one of two replies is sent. If * the topic is set, RPL_TOPIC is sent back else * public static final int RPL_NOTOPIC. */ public static final int RPL_NOTOPIC = 331; /** * Format: "<channel> <topic>".
* When sending a TOPIC message to determine the * channel topic, one of two replies is sent. If * the topic is set, RPL_TOPIC is sent back else * public static final int RPL_NOTOPIC. */ public static final int RPL_TOPIC = 332; /** * Format: "<channel> <nick-who-set-topic> <seconds>". * The seconds are not milliseconds; just multiply it with 1000 and then * format a date with it. */ public static final int RPL_TOPICINFO = 333; /** * Format: "<channel> <nick>".
* Returned by the server to indicate that the * attempted INVITE message was successful and is * being passed onto the end client. */ public static final int RPL_INVITING = 341; /** * Format: "<user> Summoning user to IRC".
* Returned by a server answering a SUMMON message to * indicate that it is summoning that user. */ public static final int RPL_SUMMONING = 342; /** * Format: "<version>.<debuglevel> <server> * <comments>".
* Reply by the server showing its version details. * The <version> is the version of the software being * used (including any patchlevel revisions) and the * <debuglevel> is used to indicate if the server is * running in "debug mode".
* The "comments" field may contain any comments about * the version or further version details. */ public static final int RPL_VERSION = 351; /** * Format: "<channel> <user> <host> <server> * <nick> <H|G>[*][@|+] <hopcount> <real name>".
* The RPL_WHOREPLY and RPL_ENDOFWHO pair are used * to answer a WHO message. The RPL_WHOREPLY is only * sent if there is an appropriate match to the WHO * query. If there is a list of parameters supplied * with a WHO message, a RPL_ENDOFWHO must be sent * after processing each list item with <name> being * the item. */ public static final int RPL_WHOREPLY = 352; /** * Format: "<name> End of /WHO list".
* The RPL_WHOREPLY and RPL_ENDOFWHO pair are used * to answer a WHO message. The RPL_WHOREPLY is only * sent if there is an appropriate match to the WHO * query. If there is a list of parameters supplied * with a WHO message, a RPL_ENDOFWHO must be sent * after processing each list item with <name> being * the item. */ public static final int RPL_ENDOFWHO = 315; /** * Format: "<channel> [[@|+]<nick> [[@|+]<nick> * [...]]]".
* To reply to a NAMES message, a reply pair consisting * of RPL_NAMREPLY and RPL_ENDOFNAMES is sent by the * server back to the client. If there is no channel * found as in the query, then only RPL_ENDOFNAMES is * returned. The exception to this is when a NAMES * message is sent with no parameters and all visible * channels and contents are sent back in a series of * RPL_NAMEREPLY messages with a RPL_ENDOFNAMES to mark * the end. */ public static final int RPL_NAMREPLY = 353; /** * Format: "<channel> End of /NAMES list".
* To reply to a NAMES message, a reply pair consisting * of RPL_NAMREPLY and RPL_ENDOFNAMES is sent by the * server back to the client. If there is no channel * found as in the query, then only RPL_ENDOFNAMES is * returned. The exception to this is when a NAMES * message is sent with no parameters and all visible * channels and contents are sent back in a series of * RPL_NAMEREPLY messages with a RPL_ENDOFNAMES to mark * the end. */ public static final int RPL_ENDOFNAMES = 366; /** * Format: "<mask> <server> <hopcount> <server info>". *
* In replying to the LINKS message, a server must send * replies back using the RPL_LINKS numeric and mark the * end of the list using an RPL_ENDOFLINKS reply. */ public static final int RPL_LINKS = 364; /** * Format: "<mask> End of /LINKS list".
* In replying to the LINKS message, a server must send * replies back using the RPL_LINKS numeric and mark the * end of the list using an RPL_ENDOFLINKS reply. */ public static final int RPL_ENDOFLINKS = 365; /** * Format: "<channel> <banid>".
* When listing the active 'bans' for a given channel, * a server is required to send the list back using the * RPL_BANLIST and RPL_ENDOFBANLIST messages. A separate * RPL_BANLIST is sent for each active banid. After the * banids have been listed (or if none present) a * RPL_ENDOFBANLIST must be sent. */ public static final int RPL_BANLIST = 367; /** * Format: "<channel> End of channel ban list".
* When listing the active 'bans' for a given channel, * a server is required to send the list back using the * RPL_BANLIST and RPL_ENDOFBANLIST messages. A separate * RPL_BANLIST is sent for each active banid. After the * banids have been listed (or if none present) a * RPL_ENDOFBANLIST must be sent. */ public static final int RPL_ENDOFBANLIST = 368; /** * Format: "<string>".
* A server responding to an INFO message is required to * send all its 'info' in a series of RPL_INFO messages * with a RPL_ENDOFINFO reply to indicate the end of the * replies. */ public static final int RPL_INFO = 371; /** * Format: "End of /INFO list".
* A server responding to an INFO message is required to * send all its 'info' in a series of RPL_INFO messages * with a RPL_ENDOFINFO reply to indicate the end of the * replies. */ public static final int RPL_ENDOFINFO = 374; /** * Format: "- <server> Message of the day - ".
* When responding to the MOTD message and the MOTD file * is found, the file is displayed line by line, with * each line no longer than 80 characters, using * RPL_MOTD format replies. These should be surrounded * by a RPL_MOTDSTART (before the RPL_MOTDs) and an * RPL_ENDOFMOTD (after). */ public static final int RPL_MOTDSTART = 375; /** * Format: "- <text>".
* When responding to the MOTD message and the MOTD file * is found, the file is displayed line by line, with * each line no longer than 80 characters, using * RPL_MOTD format replies. These should be surrounded * by a RPL_MOTDSTART (before the RPL_MOTDs) and an * RPL_ENDOFMOTD (after). */ public static final int RPL_MOTD = 372; /** * Format: "End of /MOTD command".
* When responding to the MOTD message and the MOTD file * is found, the file is displayed line by line, with * each line no longer than 80 characters, using * RPL_MOTD format replies. These should be surrounded * by a RPL_MOTDSTART (before the RPL_MOTDs) and an * RPL_ENDOFMOTD (after). */ public static final int RPL_ENDOFMOTD = 376; /** * Format: "You are now an IRC operator".
* RPL_YOUREOPER is sent back to a client which has * just successfully issued an OPER message and gained * operator status. */ public static final int RPL_YOUREOPER = 381; /** * Format: "<config file> Rehashing".
* If the REHASH option is used and an operator sends * a REHASH message, an RPL_REHASHING is sent back to * the operator. */ public static final int RPL_REHASHING = 382; /** * Format: "<server> <string showing server's local time>".
* When replying to the TIME message, a server must send * the reply using the RPL_TIME format above. The string * showing the time need only contain the correct day and * time there. There is no further requirement for the * time string. */ public static final int RPL_TIME = 391; /** * Format: "UserID Terminal Host".
* If the USERS message is handled by a server, the * replies RPL_USERSTART, RPL_USERS, RPL_ENDOFUSERS and * RPL_NOUSERS are used. RPL_USERSSTART must be sent * first, following by either a sequence of RPL_USERS * or a single RPL_NOUSER. Following this is * RPL_ENDOFUSERS. */ public static final int RPL_USERSSTART = 392; /** * Format: "%-8s %-9s %-8s".
* If the USERS message is handled by a server, the * replies RPL_USERSTART, RPL_USERS, RPL_ENDOFUSERS and * RPL_NOUSERS are used. RPL_USERSSTART must be sent * first, following by either a sequence of RPL_USERS * or a single RPL_NOUSER. Following this is * RPL_ENDOFUSERS. */ public static final int RPL_USERS = 393; /** * Format: "End of users".
* If the USERS message is handled by a server, the * replies RPL_USERSTART, RPL_USERS, RPL_ENDOFUSERS and * RPL_NOUSERS are used. RPL_USERSSTART must be sent * first, following by either a sequence of RPL_USERS * or a single RPL_NOUSER. Following this is * RPL_ENDOFUSERS. */ public static final int RPL_ENDOFUSERS = 394; /** * Format: "Nobody logged in".
* If the USERS message is handled by a server, the * replies RPL_USERSTART, RPL_USERS, RPL_ENDOFUSERS and * RPL_NOUSERS are used. RPL_USERSSTART must be sent * first, following by either a sequence of RPL_USERS * or a single RPL_NOUSER. Following this is * RPL_ENDOFUSERS. */ public static final int RPL_NOUSERS = 395; /** * Format: "Link <version & debug level> <destination> * <next server>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACELINK = 200; /** * Format: "Try. <class> <server>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACECONNECTING = 201; /** * Format: "H.S. <class> <server>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACEHANDSHAKE = 202; /** * Format: "???? <class> [<client IP address in dot form>]".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACEUNKNOWN = 203; /** * Format: "Oper <class> <nick>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACEOPERATOR = 204; /** * Format: "User <class> <nick>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACEUSER = 205; /** * Format: "Serv <class> <int>S <int>C <server> * <nick!user|*!*>@<host|server>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACESERVER = 206; /** * Format: "<newtype> 0 <client name>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACENEWTYPE = 208; /** * Format: "File <logfile> <debug level>".
* The RPL_TRACE* are all returned by the server in * response to the TRACE message. How many are * returned is dependent on the the TRACE message and * whether it was sent by an operator or not. There * is no predefined order for which occurs first. * Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and * RPL_TRACEHANDSHAKE are all used for connections * which have not been fully established and are either * unknown, still attempting to connect or in the * process of completing the 'server handshake'. * RPL_TRACELINK is sent by any server which handles * a TRACE message and has to pass it on to another * server. The list of RPL_TRACELINKs sent in * response to a TRACE command traversing the IRC * network should reflect the actual connectivity of * the servers themselves along that path. * RPL_TRACENEWTYPE is to be used for any connection * which does not fit in the other categories but is * being displayed anyway. */ public static final int RPL_TRACELOG = 261; /** * Format: "<linkname> <sendq> <sent messages> * <sent bytes> <received messages> * <received bytes> <time open>". */ public static final int RPL_STATSLINKINFO = 211; /** * Format: "<command> <count>". */ public static final int RPL_STATSCOMMANDS = 212; /** * Format: "C <host> * <name> <port> <class>". */ public static final int RPL_STATSCLINE = 213; /** * Format: "N <host> * <name> <port> <class>". */ public static final int RPL_STATSNLINE = 214; /** * Format: "I <host> * <host> <port> <class>". */ public static final int RPL_STATSILINE = 215; /** * Format: "K <host> * <username> <port> <class>". */ public static final int RPL_STATSKLINE = 216; /** * Format: "Y <class> <ping frequency> <connect * frequency> <max sendq>". */ public static final int RPL_STATSYLINE = 218; /** * Format: "<stats letter> End of /STATS report". */ public static final int RPL_ENDOFSTATS = 219; /** * Format: "L <hostmask> * <servername> <maxdepth>". */ public static final int RPL_STATSLLINE = 241; /** * Format: "Server Up %d days %d:%02d:%02d". */ public static final int RPL_STATSUPTIME = 242; /** * Format: "O <hostmask> * <name>" */ public static final int RPL_STATSOLINE = 243; /** * Format: "H <hostmask> * <servername>". */ public static final int RPL_STATSHLINE = 244; /** * Format: "<user mode string>".
* To answer a query about a client's own mode, * RPL_UMODEIS is sent back. */ public static final int RPL_UMODEIS = 221; /** * Format: "There are <integer> users and <integer> * invisible on <integer> servers".
* In processing an LUSERS message, the server * sends a set of replies from RPL_LUSERCLIENT, * RPL_LUSEROP, RPL_USERUNKNOWN, * RPL_LUSERCHANNELS and RPL_LUSERME. When * replying, a server must send back * RPL_LUSERCLIENT and RPL_LUSERME. The other * replies are only sent back if a non-zero count * is found for them. */ public static final int RPL_LUSERCLIENT = 251; /** * Format: "<integer> operator(s) online".
* In processing an LUSERS message, the server * sends a set of replies from RPL_LUSERCLIENT, * RPL_LUSEROP, RPL_USERUNKNOWN, * RPL_LUSERCHANNELS and RPL_LUSERME. When * replying, a server must send back * RPL_LUSERCLIENT and RPL_LUSERME. The other * replies are only sent back if a non-zero count * is found for them. */ public static final int RPL_LUSEROP = 252; /** * Format: "<integer> unknown connection(s)".
* In processing an LUSERS message, the server * sends a set of replies from RPL_LUSERCLIENT, * RPL_LUSEROP, RPL_USERUNKNOWN, * RPL_LUSERCHANNELS and RPL_LUSERME. When * replying, a server must send back * RPL_LUSERCLIENT and RPL_LUSERME. The other * replies are only sent back if a non-zero count * is found for them. */ public static final int RPL_LUSERUNKNOWN = 253; /** * Format: "<integer> channels formed".
* In processing an LUSERS message, the server * sends a set of replies from RPL_LUSERCLIENT, * RPL_LUSEROP, RPL_USERUNKNOWN, * RPL_LUSERCHANNELS and RPL_LUSERME. When * replying, a server must send back * RPL_LUSERCLIENT and RPL_LUSERME. The other * replies are only sent back if a non-zero count * is found for them. */ public static final int RPL_LUSERCHANNELS = 254; /** * Format: "I have <integer> clients and <integer> * servers".
* In processing an LUSERS message, the server * sends a set of replies from RPL_LUSERCLIENT, * RPL_LUSEROP, RPL_USERUNKNOWN, * RPL_LUSERCHANNELS and RPL_LUSERME. When * replying, a server must send back * RPL_LUSERCLIENT and RPL_LUSERME. The other * replies are only sent back if a non-zero count * is found for them. */ public static final int RPL_LUSERME = 255; /** * Format: "<server> Administrative info".
* When replying to an ADMIN message, a server * is expected to use replies RLP_ADMINME * through to RPL_ADMINEMAIL and provide a text * message with each. For RPL_ADMINLOC1 a * description of what city, state and country * the server is in is expected, followed by * details of the university and department * (RPL_ADMINLOC2) and finally the administrative * contact for the server (an email address here * is required) in RPL_ADMINEMAIL. */ public static final int RPL_ADMINME = 256; /** * Format: "<admin info>".
* When replying to an ADMIN message, a server * is expected to use replies RLP_ADMINME * through to RPL_ADMINEMAIL and provide a text * message with each. For RPL_ADMINLOC1 a * description of what city, state and country * the server is in is expected, followed by * details of the university and department * (RPL_ADMINLOC2) and finally the administrative * contact for the server (an email address here * is required) in RPL_ADMINEMAIL. */ public static final int RPL_ADMINLOC1 = 257; /** * Format: "<admin info>".
* When replying to an ADMIN message, a server * is expected to use replies RLP_ADMINME * through to RPL_ADMINEMAIL and provide a text * message with each. For RPL_ADMINLOC1 a * description of what city, state and country * the server is in is expected, followed by * details of the university and department * (RPL_ADMINLOC2) and finally the administrative * contact for the server (an email address here * is required) in RPL_ADMINEMAIL. */ public static final int RPL_ADMINLOC2 = 258; /** * Format: "<admin info>".
* When replying to an ADMIN message, a server * is expected to use replies RLP_ADMINME * through to RPL_ADMINEMAIL and provide a text * message with each. For RPL_ADMINLOC1 a * description of what city, state and country * the server is in is expected, followed by * details of the university and department * (RPL_ADMINLOC2) and finally the administrative * contact for the server (an email address here * is required) in RPL_ADMINEMAIL. */ public static final int RPL_ADMINEMAIL = 259; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_TRACECLASS = 209; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_STATSQLINE = 217; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_SERVICEINFO = 231; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_ENDOFSERVICES = 232; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_SERVICE = 233; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_SERVLIST = 234; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_SERVLISTEND = 235; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_WHOISCHANOP = 316; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_KILLDONE = 361; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_CLOSING = 362; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_CLOSEEND = 363; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_INFOSTART = 373; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int RPL_MYPORTIS = 384; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int ERR_YOUWILLBEBANNED = 466; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int ERR_BADCHANMASK = 476; /** * This numeric is no longer in use, reserved for future planned use or * anything else. */ public static final int ERR_NOSERVICEHOST = 492; /** * This is part of the mIRC code and shows that a color-code starts / ends. * Here it is as the ASCII decimal int 3. */ public static final char COLOR_INDICATOR = 3; // ASCII code /** * This is part of the mIRC code and shows that bold starts / ends. * Here it is as the ASCII decimal int 32. */ public static final char BOLD_INDICATOR = 31; // ASCII code /** * This is part of the mIRC code and shows that bold starts / ends. * Here it is as the ASCII decimal int 2. */ public static final char UNDERLINE_INDICATOR = 2; // ASCII code /** * This is part of the mIRC code and shows that bold, underline and colors * end. * Here it is as the ASCII decimal int 15. */ public static final char COLOR_END_INDICATOR = 15; // ASCII code /** * This is part of the mIRC code and indicates that the client's colors are * reversed (background -> foreground and foreground -> background). * Here it is as the ASCII decimal int 1. */ public static final char COLOR_REVERSE_INDICATOR = 22; // ASCII code /** * This is part of the mIRC code and shows that a PRIVMSG is an ACTION * (/me). * Here it is as the ASCII decimal int 22. */ public static final char ACTION_INDICATOR = 1; // ASCII code } libirclib-java-1.10/src/org/schwering/irc/lib/IRCEventAdapter.java000066400000000000000000000225671155103677700250120ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class IRCEventAdapter * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; /** * Adapts the events of the IRCEventListener interface. *

* Supported events: *

    *
  • Connect
  • *
  • Disconnect
  • *
  • Error
  • *
  • Invite
  • *
  • Join
  • *
  • Kick
  • *
  • Private Message
  • *
  • Mode (Chan)
  • *
  • Mode (User)
  • *
  • Nick
  • *
  • Notice
  • *
  • Numeric Reply
  • *
  • Numeric Error
  • *
  • Part
  • *
  • Ping
  • *
  • Quit
  • *
  • Topic
  • *
*

* For other, unkown events there's the unknown-method. * @author Christoph Schwering <schwering@gmail.com> * @version 1.63 * @see IRCEventListener */ public class IRCEventAdapter implements IRCEventListener { /** * The default and only constructor does nothing. */ public IRCEventAdapter() { // nothing } // ------------------------------ /** * Fired when the own connection is successfully established. * This is the case when the first PING? is received.
* This happens between the connection is opened with a socket and the * connection is registered: The client sends his information to the server * (nickname, username). The server says hello to you by sending you * some NOTICEs. And if your nickname is invalid or in use or * anything else is wrong with your nickname, it asks you for a new one. */ public void onRegistered() { // nothing } // ------------------------------ /** * Fired when the own connection is broken. */ public void onDisconnected() { // nothing } // ------------------------------ /** * Fired when an ERROR command is received. * @param msg The message of the error. */ public void onError(String msg) { // nothing } // ------------------------------ /** * Fired when a numeric error is received. * The server often sends numeric errors (wrong nickname etc.). * The msg's format is different for every reply. All replies' * formats are described in the {@link org.schwering.irc.lib.IRCUtil}. * @param num The identifier (usually a 3-digit number). * @param msg The message of the error. */ public void onError(int num, String msg) { // nothing } // ------------------------------ /** * Fired when somebody is invited to a channel. * @param chan The channel the user is invited to. * @param user The user who invites another. Contains nick, username and host. * @param passiveNick The nickname of the user who is invited by another user * (passive). */ public void onInvite(String chan, IRCUser user, String passiveNick) { // nothing } // ------------------------------ /** * Fired when somebody joins a channel. * @param chan The channel the person joins. * @param user The user who joins. Contains nick, username and host. */ public void onJoin(String chan, IRCUser user) { // nothing } // ------------------------------ /** * Fired when somebody is kicked from a channel. * @param chan The channel somebody is kicked from. * @param user The user who kicks another user from a channel. * Contains nick, username and host. * @param passiveNick The nickname of the user who is kicked from a channel * (passive). * @param msg The message the active user has set. This is "" if * no message was set. */ public void onKick(String chan, IRCUser user, String passiveNick, String msg) { // nothing } // ------------------------------ /** * Fired when an operator changes the modes of a channel. * For example, he can set somebody as an operator, too, or take him the * oper-status. * Also keys, moderated and other channelmodes are fired here. * @param chan The channel in which the modes are changed. * @param user The user who changes the modes. * Contains nick, username and host. * @param modeParser The IRCModeParser object which contains the * parsed information about the modes which are changed. */ public void onMode(String chan, IRCUser user, IRCModeParser modeParser) { // nothing } // ------------------------------ /** * Fired when somebody changes somebody's usermodes. * Note that this event is not fired when a channel-mode is set, for example * when someone sets another user as operator or the mode moderated. * @param user The user who changes the modes of another user or himself. * Contains nick, username and host. * @param passiveNick The nickname of the person whose modes are changed by * another user or himself. * @param mode The changed modes which are set. */ public void onMode(IRCUser user, String passiveNick, String mode) { // nothing } // ------------------------------ /** * Fired when somebody changes his nickname successfully. * @param user The user who changes his nickname. * Contains nick, username and host. * @param newNick The new nickname of the user who changes his nickname. */ public void onNick(IRCUser user, String newNick) { // nothing } // ------------------------------ /** * Fired when somebody sends a NOTICE to a user or a group. * @param target The channel or nickname the user sent a NOTICE * to. * @param user The user who notices another person or a group. * Contains nick, username and host. * @param msg The message. */ public void onNotice(String target, IRCUser user, String msg) { // nothing } // ------------------------------ /** * Fired when somebody parts from a channel. * @param chan The channel somebody parts from. * @param user The user who parts from a channel. * Contains nick, username and host. * @param msg The part-message which is optionally. * If it's empty, msg is "". */ public void onPart(String chan, IRCUser user, String msg) { // nothing } // ------------------------------ /** * Fired when a PING comes in. * The IRC server tests in different periods if the client is still there by * sending PING <ping>. The client must response PONG <ping>. * @param ping The ping which is received from the server. */ public void onPing(String ping) { // nothing } // ------------------------------ /** * Fired when a user sends a PRIVMSG to a user or to a * group. * @param target The channel or nickname the user sent a PRIVMSG * to. * @param user The user who sent the PRIVMSG. * Contains nick, username and host. * @param msg The message the user transmits. */ public void onPrivmsg(String target, IRCUser user, String msg) { // nothing } // ------------------------------ /** * Fired when somebody quits from the network. * @param user The user who quits. Contains nick, username and host. * @param msg The optional message. "" if no message is set by * the user. */ public void onQuit(IRCUser user, String msg) { // nothing } // ------------------------------ /** * Fired when a numeric reply is received. * For example, WHOIS queries are answered by the server with * numeric replies. * The msg's format is different for every reply. All replies' * formats are described in the {@link org.schwering.irc.lib.IRCUtil}. * The first word in the value is always your own nickname! * @param num The numeric reply. * @param value The first part of the message. * @param msg The main part of the message. */ public void onReply(int num, String value, String msg) { // nothing } // ------------------------------ /** * Fired when the topic is changed by operators. * Note that the topic is given as a numeric reply fired in * onReply when you join a channel. * @param chan The channel where the topic is changed. * @param user The user who changes the topic. * Contains nick, username and host. * @param topic The new topic. */ public void onTopic(String chan, IRCUser user, String topic) { // nothing } // ------------------------------ /** * This event is fired when the incoming line can not be identified as a known * event. * @param prefix The prefix of the incoming line. * @param command The command of the incoming line. * @param middle The part until the colon (:). * @param trailing The part behind the colon (:). */ public void unknown(String prefix, String command, String middle, String trailing) { // nothing } } libirclib-java-1.10/src/org/schwering/irc/lib/IRCEventListener.java000066400000000000000000000223101155103677700252010ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class IRCEventListener * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; import java.util.EventListener; /** * Used as listener for incoming events like messages. *

* The IRCEventListener is used by the * IRCConnection.addEventListener(IRCEventListener) method to add * a listener which listens to the connection for incoming IRC events like * PRIVMSGs or numeric replies. *

* Supported events: *

    *
  • Connect
  • *
  • Disconnect
  • *
  • Error
  • *
  • Invite
  • *
  • Join
  • *
  • Kick
  • *
  • Private Message
  • *
  • Mode (Chan)
  • *
  • Mode (User)
  • *
  • Nick
  • *
  • Notice
  • *
  • Numeric Reply
  • *
  • Numeric Error
  • *
  • Part
  • *
  • Ping
  • *
  • Quit
  • *
  • Topic
  • *
*

* For other, unkown events there's the unknown-method. * @author Christoph Schwering <schwering@gmail.com> * @version 1.64 * @see IRCEventAdapter * @see IRCConnection */ public interface IRCEventListener extends EventListener, IRCConstants { /** * Fired when the own connection is successfully established. * This is the case when the first PING? is received.
* This happens between the connection is opened with a socket and the * connection is registered: The client sends his information to the server * (nickname, username). The server says hello to you by sending you * some NOTICEs. And if your nickname is invalid or in use or * anything else is wrong with your nickname, it asks you for a new one. */ public void onRegistered(); // ------------------------------ /** * Fired when the own connection is broken. */ public void onDisconnected(); // ------------------------------ /** * Fired when an ERROR command is received. * @param msg The message of the error. */ public void onError(String msg); // ------------------------------ /** * Fired when a numeric error is received. * The server often sends numeric errors (wrong nickname etc.). * The msg's format is different for every reply. All replies' * formats are described in the {@link org.schwering.irc.lib.IRCUtil}. * @param num The identifier (usually a 3-digit number). * @param msg The message of the error. */ public void onError(int num, String msg); // ------------------------------ /** * Fired when somebody is invited to a channel. * @param chan The channel the user is invited to. * @param user The user who invites another. Contains nick, username and host. * @param passiveNick The nickname of the user who is invited by another user * (passive). */ public void onInvite(String chan, IRCUser user, String passiveNick); // ------------------------------ /** * Fired when somebody joins a channel. * @param chan The channel the person joins. * @param user The user who joins. Contains nick, username and host. */ public void onJoin(String chan, IRCUser user); // ------------------------------ /** * Fired when somebody is kicked from a channel. * @param chan The channel somebody is kicked from. * @param user The user who kicks another user from a channel. * Contains nick, username and host. * @param passiveNick The nickname of the user who is kicked from a channel * (passive). * @param msg The message the active user has set. This is "" if * no message was set. */ public void onKick(String chan, IRCUser user, String passiveNick, String msg); // ------------------------------ /** * Fired when an operator changes the modes of a channel. * For example, he can set somebody as an operator, too, or take him the * oper-status. * Also keys, moderated and other channelmodes are fired here. * @param chan The channel in which the modes are changed. * @param user The user who changes the modes. * Contains nick, username and host. * @param modeParser The IRCModeParser object which contains the * parsed information about the modes which are changed. */ public void onMode(String chan, IRCUser user, IRCModeParser modeParser); // ------------------------------ /** * Fired when somebody changes somebody's usermodes. * Note that this event is not fired when a channel-mode is set, for example * when someone sets another user as operator or the mode moderated. * @param user The user who changes the modes of another user or himself. * Contains nick, username and host. * @param passiveNick The nickname of the person whose modes are changed by * another user or himself. * @param mode The changed modes which are set. */ public void onMode(IRCUser user, String passiveNick, String mode); // ------------------------------ /** * Fired when somebody changes his nickname successfully. * @param user The user who changes his nickname. * Contains nick, username and host. * @param newNick The new nickname of the user who changes his nickname. */ public void onNick(IRCUser user, String newNick); // ------------------------------ /** * Fired when somebody sends a NOTICE to a user or a group. * @param target The channel or nickname the user sent a NOTICE * to. * @param user The user who notices another person or a group. * Contains nick, username and host. * @param msg The message. */ public void onNotice(String target, IRCUser user, String msg); // ------------------------------ /** * Fired when somebody parts from a channel. * @param chan The channel somebody parts from. * @param user The user who parts from a channel. * Contains nick, username and host. * @param msg The part-message which is optionally. * If it's empty, msg is "". */ public void onPart(String chan, IRCUser user, String msg); // ------------------------------ /** * Fired when a PING comes in. * The IRC server tests in different periods if the client is still there by * sending PING <ping>. The client must response PONG <ping>. * @param ping The ping which is received from the server. */ public void onPing(String ping); // ------------------------------ /** * Fired when a user sends a PRIVMSG to a user or to a * group. * @param target The channel or nickname the user sent a PRIVMSG * to. * @param user The user who sent the PRIVMSG. * Contains nick, username and host. * @param msg The message the user transmits. */ public void onPrivmsg(String target, IRCUser user, String msg); // ------------------------------ /** * Fired when somebody quits from the network. * @param user The user who quits. Contains nick, username and host. * @param msg The optional message. "" if no message is set by * the user. */ public void onQuit(IRCUser user, String msg); // ------------------------------ /** * Fired when a numeric reply is received. * For example, WHOIS queries are answered by the server with * numeric replies. * The msg's format is different for every reply. All replies' * formats are described in the {@link org.schwering.irc.lib.IRCUtil}. * The first word in the value is always your own nickname! * @param num The numeric reply. * @param value The first part of the message. * @param msg The main part of the message. */ public void onReply(int num, String value, String msg); // ------------------------------ /** * Fired when the topic is changed by operators. * Note that the topic is given as a numeric reply fired in * onReply when you join a channel. * @param chan The channel where the topic is changed. * @param user The user who changes the topic. * Contains nick, username and host. * @param topic The new topic. */ public void onTopic(String chan, IRCUser user, String topic); // ------------------------------ /** * This event is fired when the incoming line can not be identified as a known * event. * @param prefix The prefix of the incoming line. * @param command The command of the incoming line. * @param middle The part until the colon (:). * @param trailing The part behind the colon (:). */ public void unknown(String prefix, String command, String middle, String trailing); } libirclib-java-1.10/src/org/schwering/irc/lib/IRCModeParser.java000066400000000000000000000200021155103677700244470ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class IRCModeParser * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; /** * Parses channel-modes. *

* An instance of this class is an argument of the {@link * org.schwering.irc.lib.IRCEventListener#onMode(String chan, IRCUser user, * IRCModeParser modeParser)}. * It's intended to help the programmer to work with the modes. *

* Channelmodes are: *

    *
  • +/- o nick
  • *
  • +/- v nick
  • *
  • +/- b banmask
  • *
  • +/- l limit
  • *
  • +/- k key
  • *
  • +/- p
  • *
  • +/- s
  • *
  • +/- i
  • *
  • +/- t
  • *
  • +/- n
  • *
  • +/- m
  • *
*

* These are all channel-modes defined in RFC1459. Nevertheless, most * networks provide more channel-modes. This class can handle all modes; it's * not restricted to the rights defined in RFC1459. * @author Christoph Schwering <schwering@gmail.com> * @version 1.22 * @see IRCEventListener */ public class IRCModeParser { /** * Represents the operators, modes and nicks as they were sent from the IRC * server. */ private String line; /** * Contains pluses (+) and minuses (-) which show * if the mode is taken or given. */ private char[] operatorsArr; /** * This array contains the modes that are set with the operator of the * operatorsArr-array. * */ private char[] modesArr; /** * Represents the parsed nicks, hostnames, limits or keys in an array of * Strings. */ private String[] argsArr; // ------------------------------ /** * Analyzes the modes and parses them into the parts operators (+ * or -), modes (one character) and optional arguments (one * word or number). * @param line The modes and the arguments; nothing more. */ public IRCModeParser(String line) { line = line.trim(); this.line = line; int index = line.indexOf(' '); if (index >= 2) { // with arguments String modes = line.substring(0, index); String args = line.substring(index + 1); parse(modes, args); // call real constructor. } else if (line.length() >= 2) { // no arguments String modes = line; String args = ""; parse(modes, args); } else { // nothing argsArr = new String[0]; operatorsArr = new char[0]; modesArr = new char[0]; } } // ------------------------------ /** * Analyzes the modes and parses them into the parts operators (+ * or -), modes (one character) and optional arguments (one * word or number). * @param modes The modes (for example +oo+m-v). * @param args The modes' arguments (for example Heinz Hans * Thomas). */ public IRCModeParser(String modes, String args) { line = modes +" "+ args; parse(modes, args); } // ------------------------------ /** * Parses the modes into two char-arrays and one * String-array.
* The first one contains the operator of the mode (+ or *
-
) and the second one the mode (w, * i, s, o or any other mode). * The String[] contains the nicknames. * @param modes The modes (for example +oo+m-v). * @param args The modes' arguments (for example Heinz Hans * Thomas). */ private void parse(String modes, String args) { String[] argsTmp = IRCUtil.split(args, ' '); int modesLen = modes.length(); int modesCount = getModesCount(modes); char c; char operator = '+'; // any value cause it must be initialized operatorsArr = new char[modesCount]; modesArr = new char[modesCount]; argsArr = new String[modesCount]; // parse and fill the arrays for (int i = 0, j = 0, n = 0; i < modesLen; i++) { c = modes.charAt(i); if (c == '+' || c == '-') { operator = c; } else { // add the operator (which was found earlier in the loop) operatorsArr[n] = operator; modesArr[n] = c; // add the mode if ((c == 'o' || c == 'v' || c == 'b' || c == 'k') // come with arg || (c == 'l' && operator == '+')) { // key comes with arg if '+' argsArr[n] = (j < argsTmp.length) ? argsTmp[j++] : ""; } else { argsArr[n] = ""; // null if mode has no argument (for example m, p, s) } n++; // increase n, not i. n is used to fill the arrays } } } // ------------------------------ /** * Returns the amount of modes in the string. This is done by counting all * chars which are not + or -. * @param modes The modes which are to analyze. * @return The count of modes without operators. */ private int getModesCount(String modes) { int count = 0; for (int i = 0, c, len = modes.length(); i < len; i++) if ((c = modes.charAt(i)) != '+' && c != '-') count++; return count; } // ------------------------------ /** * Returns count of modes. * @return The count of modes. * @see #getOperatorAt(int) * @see #getModeAt(int) * @see #getArgAt(int) */ public int getCount() { return operatorsArr.length; } // ------------------------------ /** * Returns the operator (+ or -) of a given index. * @param i The index of the operator you want to get. The index starts * with 1 and not with 0. * @return The operator at the given index (+ or -). * @see #getCount() * @see #getModeAt(int) * @see #getArgAt(int) */ public char getOperatorAt(int i) { return operatorsArr[i - 1]; } // ------------------------------ /** * Returns the mode (for example o, v, * m, i) of a given index. * @param i The index of the mode you want to get. The index starts with * 1 and not with 0. * @return The mode of the given index (for example o, * v, m, i) * @see #getCount() * @see #getOperatorAt(int) * @see #getArgAt(int) */ public char getModeAt(int i) { return modesArr[i - 1]; } // ------------------------------ /** * Returns the nick of a given index. * @param i The index of the argument you want to get. The index starts with * 1 and not with 0. * @return The argument you requested. It's "" if there's no * argument at this index (for example +m for moderated * has never an argument). * @see #getCount() * @see #getOperatorAt(int) * @see #getModeAt(int) */ public String getArgAt(int i) { return argsArr[i - 1]; } // ------------------------------ /** * Returns the line as it was sent from the IRC server. * The line contains the the operators, the modes and the nicknames, but not * the channel or the nickname who executed the MODE command! * @return The line which was set as argument when the parser was initialized. */ public String getLine() { return line; } // ------------------------------ /** * Generates a String with some information about the instance of * IRCModeParser. * Its format is: classname[line]. * @return A String with information about the instance. */ public String toString() { return getClass().getName() +"["+ getLine() +"]"; } } libirclib-java-1.10/src/org/schwering/irc/lib/IRCParser.java000066400000000000000000000433511155103677700236560ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class IRCParser * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; /** * Parses a line sent from the IRC server. *

* Note: Probably this class is unimportant for you. It's used by the * IRCConnection to parse incoming lines. Nevertheless I declared * it as public because you might want to use it to parse IRC * command-shortcuts like MSG instead of PRIVMSG in * your client.
* The following text goes on with the description of the class and what it * does. *

* According with RFC1459 it divides the line into a prefix, a command and * its parameters. *

* The prefix is only given if a line starts with a : (colon) * and is used to indicate from where the line is send. *

* The next word in the line (if no prefix exists it is the first, else the * second word) is the command. * The command is eiter a valid IRC command or a three-digit number which * represents a numeric reply or a numeric error. *

* The parameters are divided into a middle and a trailing part. * In the middle part one word means one parameter while the trailing part is * just one parameter independent from the amount of words in it. * If there is a " :" (space+colon) in the line, this point * means the beginning of the trailing. * If there is no such space+colon, the trailing is just the last word. * All words behind the space+colon mean just one parameter. * If there is only one parameter given (the parameter is the first, the last * and the only one), the parameter is available as trailing (with * getTrailing), not as middle! *

* One line may have up to 15 parameters. Therefore up to 14 are middle and * one is the trailing. *

* The line may have up to 510 characters plus the CR-LF (carriage return - * line feed) which trails the incoming line. *

* The following extract of the RFC1459 shows the message format in BNF: *

* <message>  ::= * [':' <prefix> <SPACE> ] <command> <params> * <crlf>
* <prefix>   ::= * <servername> | <nick> * [ '!' <username> ] [ '@' <host> ] *
* <command>  ::= * <letter> { <letter> } | <number> <number> * <number>
* <SPACE>    ::= * ' ' { ' ' }
* <params>   ::= * <SPACE> [ ':' <trailing> | <middle> <params> ]
* <middle>   ::= * <Any *non-empty* sequence of octets not including SPACE or NUL or CR or * LF, the first of which may not be ':'>
* <trailing> ::= * <Any, possibly *empty*, sequence of octets not including NUL or CR or * LF>
* <crlf>     ::= * CR LF
*
* @author Christoph Schwering <schwering@gmail.com> * @version 3.22 * @see IRCConnection */ public class IRCParser { /** * The StringBuffer contains the line which was analyzed. */ private StringBuffer buf; /** * The length of the line. */ private int len; /** * The prefix, which is parsed out in the constructor. */ private String prefix; /** * The command, which is parsed out in the constructor. */ private String command; /** * The middle, which is parsed out in the constructor. */ private String middle; /** * The trailing, which is parsed out in the constructor. The trailing is the * part behind the colon (:) or the last parameter. */ private String trailing; /** * The parameters' array. It's not initialized in the constructor because of * rare access. The methods which use and need this parameter-array * (getParametersCount, getParameter, getParameterFrom etc.) initialize this * array by calling initParameters, if the array isn't initialized yet. */ private String[] parameters; // ------------------------------ /** * Parses the line after erasing all mIRC color codes. * This constructor is a shorthand for IRCParser(line, false). * @param line The line which will be parsed. */ public IRCParser(String line) { this(line, false); } // ------------------------------ /** * The main constructor. * Parses prefix, command, middle and trailing. * @param line The line which will be parsed. * @param colorsEnabled If false, mIRC color codes are parsed out * by using IRCUtil.parseColors method. */ public IRCParser(String line, boolean colorsEnabled) { int index = 0; int trail; buf = new StringBuffer(line); if (!colorsEnabled) buf = IRCUtil.parseColors(buf); len = buf.length(); // prefix if (buf.charAt(0) == ':') { prefix = buf.substring(1, (index = indexOf(' ', index))); index++; } while (buf.charAt(index) == ' ') index++; // command command = buf.substring(index, ((index = indexOf(' ', index)) != -1) ? index : (index = len)); while (index < len && buf.charAt(index) == ' ') index++; index--; // middle & trailing if ((trail = indexOf(" :", index)) != -1) trailing = buf.substring(trail + 2, len); else if ((trail = lastIndexOf(' ')) != -1 && trail >= index) trailing = buf.substring(trail + 1, len); middle = (index < trail) ? buf.substring(index + 1, trail) : ""; // save this.prefix = (prefix != null) ? prefix : ""; this.command = (command != null) ? command : ""; this.middle = (middle != null) ? middle : ""; this.trailing = (trailing != null) ? trailing : ""; } // ------------------------------ /** * Searches for a char in the StringBuffer buf from a given index * and returns its index. * @param c The char to search. * @param i The index the method will start searching at. * @return The index of the searched char. */ private int indexOf(int c, int i) { while (i < len) if (buf.charAt(i++) == c) return --i; return -1; } // ------------------------------ /** * Searches for a string in the StringBuffer buf from a given * index and returns its beginning index. * @param str The string to search. * @param i The index the method will start searching at. * @return The index of the searched string. */ private int indexOf(String str, int i) { int sublen = str.length(); int index = -1; int j; for ( ; i < len; i++) for (index = i, j = 0; i < len && j < sublen; i++, j++) if (buf.charAt(i) != str.charAt(j)) break; else if (j + 1 == sublen) return index; return -1; } // ------------------------------ /** * Searches for a given char in the StringBuffer buf.
* It starts at the end.
* Note: The method expects a character which is not c before * it can return an index. Thus in a string like "nick moor   *   " with four trailing spaces * lastIndexOf(' ') does not return the the index of the last * space. It first waits for characters which are not a space (r, o, o, m) and * then returns the index of the next space: the space between * nick and moor. By this, also in lines with * trailing whitespace the trailing-part is correctly recognized. * @param c The char to search. * @return The last index of the searched char. */ private int lastIndexOf(int c) { int i = len; boolean ok = false; while (i > 0) if (buf.charAt(--i) != c) ok = true; else if (ok) return i; return -1; } // ------------------------------ /** * Initializes the parameters[]. * This method is called by getParam, getParamFrom * and getParamTo, if the parameters[] aren't * initialized yet.
* The method splits the middle into all words using and appends * the trailing as last parameter. It uses the IRCUtil.split * method. */ private void initParameters() { parameters = IRCUtil.split(middle, ' ', trailing); } // ------------------------------ /** * Returns the line's prefix. A prefix is the part which contains information * about the sender of the line. If no prefix is set, "" is * returned; but in fact there's always a prefix. * @return The line's prefix. */ public String getPrefix() { return prefix; } // ------------------------------ /** * Returns the line's command. * @return The line's command. */ public String getCommand() { return command; } // ------------------------------ /** * Returns the line's middle. * @return The line's middle. */ public String getMiddle() { return middle; } // ------------------------------ /** * Returns the line's trailing. * @return The line's trailing. */ public String getTrailing() { return trailing; } // ------------------------------ /** * Returns the unparsed line. It looks exacttly as the server sent it, but * if colors are disabled and therefore already parsed out by * IRCUtil.parseColors, the colors are not included in here. * @return The line. */ public String getLine() { return buf.toString(); } // ------------------------------ /** * Returns the line's parameters which consists of the middle and the * trailing. * @return The line's parameters. */ public String getParameters() { return middle + ((middle.length() != 0 && trailing.length() != 0) ? " " : "") + trailing; } // ------------------------------ /** * Returns the nickname of the person who sent the line * or the servername of the server which sent the line.
* It is found in the prefix which always looks like that:
* * <servername> | <nick> * [ '!' <username> ] [ '@' <host> ] *

* If no prefix is given in the whole line, null is returned. *

* Note: This method is totally equal to getServername! *
* Note: There is also the method getUser which returns * an IRCUser object which holds the nickname, username and host. * By the way, the getUser uses the getNick, * getUsername and getHost methods to create this * object. * @return The nickname or the servername of the line. If no prefix is given, * null is returned. * @see #getServername() * @see #getUsername() * @see #getHost() * @see #getUser() */ public String getNick() { int i = prefix.indexOf('!'); if (i != -1 || (i = prefix.indexOf('@')) != -1) return prefix.substring(0, i); return (prefix.length() != 0) ? prefix : null; } // ------------------------------ /** * Returns the servername of the server which sent the line * or the nickname of the person who sent the line.
* It is found in the prefix which always looks like that:
* * <servername> | <nick> * [ '!' <username> ] [ '@' <host> ] *

* If no prefix is given in the whole line, null is returned. *

* Note: This method is totally equal to getNick! *
* Note: There is also the method getUser which returns * an IRCUser object which holds the nickname, username and host. * By the way, the getUser uses the getNick, * getUsername and getHost methods to create this * object. * @return The servername or the nickname of the line. If no prefix is given, * null is returned. * @see #getNick() * @see #getUser() */ public String getServername() { return getNick(); } // ------------------------------ /** * Returns the username of the person who sent the line.
* It is found in the prefix which always looks like that:
* * <servername> | <nick> * [ '!' <username> ] [ '@' <host> ] *

* If the username is not specified, this method returns null. *
* Note: There is also the method getUser which returns * an IRCUser object which holds the nickname, username and host. * By the way, the getUser uses the getNick, * getUsername and getHost methods to create this * object. * @return The username of the line; null if it's not given. * @see #getNick() * @see #getHost() * @see #getUser() */ public String getUsername() { int i = prefix.indexOf('!') + 1; if (i != 0) { int j = prefix.indexOf('@', i); return prefix.substring(i, (j != -1) ? j : prefix.length()); } return null; } // ------------------------------ /** * Returns the host of the person who sent the line.
* It is found in the prefix which always looks like that:
* * <servername> | <nick> * [ '!' <username> ] [ '@' <host> ] *

* If the host is not specified, this method returns null. *
* Note: There is also the method getUser which returns * an IRCUser object which holds the nickname, username and host. * By the way, the getUser uses the getNick, * getUsername and getHost methods to create this * object. * @return The host of the line; null if it's not given. * @see #getNick() * @see #getUsername() * @see #getUser() */ public String getHost() { int i = prefix.indexOf('@') + 1; if (i != 0) return prefix.substring(i, prefix.length()); return null; } // ------------------------------ /** * Returns a new IRCUser object. * This method is equal to new IRCUser(IRCParser.getNick(), * IRCParser.getUsername(), IRCParser.getHost()). See those methods to * learn which value they return if they are not set. * @return A new IRCUser object with exactly those values which * are returned by the getNick, getUsername * and getHost methods. * @see #getNick() * @see #getUsername() * @see #getHost() */ public IRCUser getUser() { return new IRCUser(getNick(), getUsername(), getHost()); } // ------------------------------ /** * Gets count of parameters. * If parameters isn't initialized yet, it calls * initParameters to do that. * @return The number of parameters. */ public int getParameterCount() { if (parameters == null) initParameters(); return parameters.length; } // ------------------------------ /** * Get one parameter of the line. * If parameters isn't initialized yet, it calls * initParameters to do that. * @param i The index of the parameter you want to get. The index starts with * 1 and not with 0. * @return The ith parameter. If i is out of bounds, * "" is returned. */ public String getParameter(int i) { if (parameters == null) initParameters(); --i; if (i >= 0 && i < parameters.length) return parameters[i]; else return ""; } // ------------------------------ /** * Grabs the line's parameters from the ith to the last * parameter (including the ith). * If parameters isn't initialized yet, it calls * initParameters to do that. * @param i The index of the first parameter you want to get. * @return All parameters behind another beginning at the ith. * If i is out of bounds, "" is returned. */ public String getParametersFrom(int i) { if (parameters == null) initParameters(); StringBuffer params = new StringBuffer(); for (i--; i < parameters.length; i++) params.append(parameters[i] +" "); return params.toString(); } // ------------------------------ /** * Grabs the line's parameters from the first to the ith * parameters (including the ith). * If parameters isn't initialized yet, it calls * initParameters to do that. * @param i The index of the last parameter you want to get. * @return All parameters beginning at the first and ending at the * ith. If i is out of bounds, * "" is returned. */ public String getParametersTo(int i) { if (parameters == null) initParameters(); StringBuffer params = new StringBuffer(); int max = (i < parameters.length) ? i : parameters.length; for (i = 0; i < max; i++) params.append(parameters[i] +" "); return params.toString(); } // ------------------------------ /** * Generates a String with some information about the instance of * IRCParser.
* Its format is: classname[prefix,command,middle,trailing]. * @return A String with information about the instance. */ public String toString() { return getClass().getName() +"["+ prefix +","+ command +","+ middle +","+ trailing +"]"; } } libirclib-java-1.10/src/org/schwering/irc/lib/IRCUser.java000066400000000000000000000063771155103677700233470ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class IRCUser * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; /** * Holds variables for the nick, username and host of a user. *

* It's used to pack these information in one object. * @author Christoph Schwering <schwering@gmail.com> * @version 1.02 * @see IRCEventListener * @see IRCParser */ public class IRCUser { /** * The user's nickname. */ private String nick; /** * The user's username. */ private String username; /** * The user's host. */ private String host; // ------------------------------ /** * Creates a new IRCUser object. * @param nick The user's nickname. * @param username The user's username. * @param host The user's host. */ public IRCUser(String nick, String username, String host) { this.nick = nick; this.username = username; this.host = host; } // ------------------------------ /** * Returns the nickname of the person who sent the line * or the servername of the server which sent the line.
* If no nickname is given, null is returned. *

* Note: This method is totally equal to getServername! * @return The nickname or the servername of the line. If no nick is given, * null is returned. * @see #getServername() * @see #getUsername() * @see #getHost() */ public String getNick() { return nick; } // ------------------------------ /** * Returns the servername of the server which sent the line or the nickname of * the person who sent the line.
* If no nickname is given, null is returned. *

* Note: This method is totally equal to getNick! * @return The servername or the nickname of the line. If no server is given, * null is returned. * @see #getNick() */ public String getServername() { return getNick(); } // ------------------------------ /** * Returns the username of the person who sent the line.
* If the username is not specified, this method returns null. * @return The username of the line; null if it's not given. * @see #getNick() * @see #getHost() */ public String getUsername() { return username; } // ------------------------------ /** * Returns the host of the person who sent the line.
* If the host is not specified, this method returns null. * @return The host of the line; null if it's not given. * @see #getNick() * @see #getUsername() */ public String getHost() { return host; } // ------------------------------ /** * Returns the nickname. * @return The nickname. */ public String toString() { return getNick(); } } libirclib-java-1.10/src/org/schwering/irc/lib/IRCUtil.java000066400000000000000000000200771155103677700233370ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class IRCUtil * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; import java.util.Vector; /** * Contains some utilities like numeric error and reply numbers. *

* The most description of the numeric errors and numeric replies are copied * from RFC1459. * @author Christoph Schwering <schwering@gmail.com> * @author Normton <normton@latinmail.com> * @version 2.03 * @see IRCConnection * @see IRCEventListener#onError(int, String) * @see IRCEventListener#onReply(int, String, String) */ public class IRCUtil implements IRCConstants { /** * This is part of the mIRC code and shows that a color-code starts / ends. * Here it is as the ASCII decimal int 3. * @deprecated Moved to IRCConstants. */ public static char colorIndicator = 3; // ASCII code /** * This is part of the mIRC code and shows that bold starts / ends. * Here it is as the ASCII decimal int 32. * @deprecated Moved to IRCConstants. */ public static char boldIndicator = 31; // ASCII code /** * This is part of the mIRC code and shows that bold starts / ends. * Here it is as the ASCII decimal int 2. * @deprecated Moved to IRCConstants. */ public static char underlinedIndicator = 2; // ASCII code /** * This is part of the mIRC code and shows that bold, underline and colors * end. * Here it is as the ASCII decimal int 15. * @deprecated Moved to IRCConstants. */ public static char colorEndIndicator = 15; // ASCII code /** * This is part of the mIRC code and indicates that the client's colors are * reversed (background -> foreground and foreground -> background). * Here it is as the ASCII decimal int 1. * @deprecated Moved to IRCConstants. */ public static char colorReverseIndicator = 22; // ASCII code /** * This is part of the mIRC code and shows that a PRIVMSG is an ACTION * (/me). * Here it is as the ASCII decimal int 22. * @deprecated Moved to IRCConstants. */ public static char actionIndicator = 1; // ASCII code // ------------------------------ /** * This is an empty constructor, it does nothing. Nobody may instantiate this * class. */ private IRCUtil() { // nothing } // ------------------------------ /** * According to RFC2812 the channel's name may and must start with one of the * following characters. *

    *
  • ! == 33 (ASCII)
  • *
  • # == 35
  • *
  • & == 38
  • *
  • + == 43
  • *
. * @param str The name to check if it's a channel. * @return true if the argument starts with one of the characters * mentioned above. */ public static boolean isChan(String str) { int c; return (str.length() >= 2) && ((c = str.charAt(0)) == 35 || c == 38 || c == 33 || c == 43); } // ------------------------------ /** * Parses a String to an int via * Integer.parseInt but avoids the * NumberFormatException. * @param str The String to parse. * @return The parsed new int. -1 if * NumberFormatException was thrown. */ public static int parseInt(String str) { try { return Integer.parseInt(str); } catch (NumberFormatException exc) { return -1; } } // ------------------------------ /** * Erases the mIRC colorcodes from a String. * The documentation of the evil color codes is available on * http://www.mirc.co.uk/help/color.txt. * This method links to the parseColors(StringBuffer) method. * @param str The line which should be parsed. * @return A line cleaned from any mIRC colorcodes. * @see #parseColors(StringBuffer) */ public static String parseColors(String str) { return parseColors(new StringBuffer(str)).toString(); } // ------------------------------ /** * Erases the mIRC colorcodes from a String. * The documentation of the evil color codes is available on * http://www.mirc.co.uk/help/color.txt. * @param buf The line which should be parsed. * @return A line as StringBuffer object which is cleaned from * any mIRC colorcodes. * @see #parseColors(String) */ public static StringBuffer parseColors(StringBuffer buf) { int len = buf.length(); for (int i = 0, j = 0, c; i < len; i++, j = i) { c = buf.charAt(i); try { // COLORS Beginning // (format: [][[,[]] if (c == COLOR_INDICATOR) { c = buf.charAt(++j); if ('0' <= c && c <= '9') { // first int c = buf.charAt(++j); if ('0' <= c && c <= '9') c = buf.charAt(++j); // second int } if (c == ',') c = buf.charAt(++j); // comma if ('0' <= c && c <= '9') { // first int c = buf.charAt(++j); if ('0' <= c && c <= '9') c = buf.charAt(++j); // second int } // ACTION / BOLD / UNDERLINE / COLOR END // (format: / etc.) } else if (c == ACTION_INDICATOR || c == BOLD_INDICATOR || c == UNDERLINE_INDICATOR || c == COLOR_END_INDICATOR || c == COLOR_REVERSE_INDICATOR) { j++; } } catch(StringIndexOutOfBoundsException exc) { // we got the end of the string with a call to charAt(++iIndexEnd) // nothing } if (j > i) { buf = buf.delete(i, j); // remove the cars len -= (j - i); i -= (j - i); } } return buf; } // ------------------------------ /** * Splits a string into substrings. * @param str The string which is to split. * @param delim The delimiter character, for example a space ' '. * @param trailing The ending which is added as a substring though it wasn't * in the str. This parameter is just for the * IRCParser class which uses this method to * split the middle part into the parameters. * But as last parameter always the trailing is * added. This is done here because it's the fastest way to * do it here.
* If the end is null or * "", nothing is appended. * @return An array with all substrings. * @see #split(String, int) */ public static String[] split(String str, int delim, String trailing) { Vector items = new Vector(15); int last = 0; int index = 0; int len = str.length(); while (index < len) { if (str.charAt(index) == delim) { items.add(str.substring(last, index)); last = index + 1; } index++; } if (last != len) items.add(str.substring(last)); if (trailing != null && trailing.length() != 0) items.add(trailing); String[] result = new String[items.size()]; items.copyInto(result); return result; } // ------------------------------ /** * Splits a string into substrings. This method is totally equal to * split(str, delim, null). * @param str The string which is to split. * @param delim The delimiter character, for example a space ' '. * @return An array with all substrings. * @see #split(String, int, String) */ public static String[] split(String str, int delim) { return split(str, delim, null); } } libirclib-java-1.10/src/org/schwering/irc/lib/SSLDefaultTrustManager.java000066400000000000000000000061511155103677700263640ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class SSLDefaultTrustManager * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; import com.sun.net.ssl.X509TrustManager; import java.security.cert.X509Certificate; /** * The default TrustManager of the * SSLIRCConnection. *

* Note that this class is deprecated. The SSL supporting classes moved * to org.schwering.irc.lib.ssl since IRClib 1.10. *

* It automatically accepts the X509 certificate. *

* In many cases you should change the SSLIRCConnection's * TrustManager. For examle if you write an IRC client for human * users, you may want to ask the user whether he accepts the server's * certificate or not. You could do this by a new class which extends the * SSLDefaultTrustManager class and overrides the * checkServerTrusted method and asks the user whether he wants to * accept the certification or not. * @deprecated This class has been replaced with * org.schwering.irc.lib.ssl.SSLDefaultTrustManager. * @author Christoph Schwering <schwering@gmail.com> * @version 1.13 * @see SSLIRCConnection * @see com.sun.net.ssl.TrustManager */ public class SSLDefaultTrustManager implements X509TrustManager { /** * The X509Certificates which are accepted. */ protected X509Certificate[] accepted = new X509Certificate[0]; // ------------------------------ /** * Creates a new instance of the SSLDefaultTrustManager class. */ public SSLDefaultTrustManager() { // nothing } // ------------------------------ /** * Does nothing. This method would check whether we (the server) trust the * client. But we are the client and not the server.
* It's final so that nobody can override it; it would make no sense. * @param chain The peer certificate chain. * @return Always false. */ public final boolean isClientTrusted(X509Certificate chain[]) { return false; } // ------------------------------ /** * Invoked when the client should check whether he trusts the server or not. * This method trusts the server. But this method can be overriden and then * ask the user whether he truts the client or not. * @param chain The peer certificate chain. * @return Always true. */ public boolean isServerTrusted(X509Certificate chain[]) { accepted = chain; return true; } // ------------------------------ /** * Returns the accepted certificates. They are set in the * checkServerTrusted method. * @return A non-null (possibly empty) array of acceptable CA issuer * certificates. */ public X509Certificate[] getAcceptedIssuers() { return accepted; } } libirclib-java-1.10/src/org/schwering/irc/lib/SSLIRCConnection.java000066400000000000000000000335101155103677700250770ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class SSLIRCConnection * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib; import com.sun.net.ssl.SSLContext; import com.sun.net.ssl.TrustManager; import com.sun.net.ssl.internal.ssl.Provider; import java.io.IOException; import java.io.StringWriter; import java.io.PrintWriter; import java.net.SocketException; import java.security.Security; import java.util.Vector; import javax.net.ssl.SSLException; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; /** * The SSL extension of the IRCConnection class. *

* Note that this class is deprecated. The SSL supporting classes moved * to org.schwering.irc.lib.ssl since IRClib 1.10. *

* The IRC server you want to connect to must accept SSL connections. * Otherwise you cannot connect to it with an instance of * SSLIRCConnection. IRC servers which accept SSL connections are * really very rare, because SSL means a high load for the server. *

* The following sample code tries to establish an IRC connection to an * IRC server which must support SSL. Differences to the code which * demonstrates the use of of the {@link org.schwering.irc.lib.IRCConnection} * class are printed in bold font: *

*


 * /* 
 *  * The following code of a class which imports org.schwering.irc.lib.*
 *  * prepares an SSL IRC connection and then tries to establish the 
 *  * connection. The server is "irc.somenetwork.com", the ports are 
 *  * the default SSL port (443) and the port used on most SSL IRC servers
 *  * (994). No password is used (null). The nickname is "Foo" and 
 *  * the realname is "Mr. Foobar". The username "foobar".
 *  * Because of setDaemon(true), the JVM exits even if this thread is 
 *  * running.
 *  * By setting an instance of SSLDefaultTrustManager as TrustManager
 *  * (which is also done implicitely by the SSLIRCConnection class if no
 *  * TrustManager is set until the connect method is invoked), the
 *  * X509Certificate is accepted automatically. Of course, you can write
 *  * your own TrustManager. For example, you could write a class which
 *  * extends SSLDefaultTrustManager and overrides its checkServerTrusted
 *  * method. In the new checkServerTrusted method, you could ask the user
 *  * to accept or reject the certificate.
 *  * An instance of the class MyListener which must implement 
 *  * IRCActionListener is set as event-listener for the connection. 
 *  * The connection is told to parse out mIRC color codes and to enable
 *  * automatic PING? PONG! replies.
 *  */
 * SSLIRCConnection conn = new SSLIRCConnection(
 *                               "irc.somenetwork.com", 
 *                               new int[] { 443, 994 },  
 *                               null, 
 *                               "Foo", 
 *                               "Mr. Foobar", 
 *                               "foo@bar.com" 
 *                             ); 
 * 
 * conn.addIRCEventListener(new MyListener()); 
 * conn.addTrustManager(new SSLDefaultTrustManager());
 * conn.setDaemon(true);
 * conn.setColors(false); 
 * conn.setPong(true); 
 *   
 * try {
 *   conn.connect(); // Try to connect!!! Don't forget this!!!
 * } catch (IOException ioexc) {
 *   ioexc.printStackTrace(); 
 * }
 * 

*

* The serverpassword isn't needed in most cases. You can give * null or "" instead as done in this example. *

* TrustManagers can be added and removed until the * connect method is invoked. If no TrustManagers are * set until then, an {@link org.schwering.irc.lib.SSLDefaultTrustManager} is * set automatically. It accepts all X509 certificates. * @deprecated This class has been replaced with * org.schwering.irc.lib.ssl.SSLDefaultTrustManager. * @author Christoph Schwering <schwering@gmail.com> * @version 1.33 * @see IRCConnection * @see SSLDefaultTrustManager * @see com.sun.net.ssl.TrustManager */ public class SSLIRCConnection extends IRCConnection { /** * The list of TrustManagers. TrustManagers can be * added with the addTrustManager method and removed with the * removeTrustManager method. If no TrustManager * is included, the getTrustManagers method sets an instance of * SSLDefaultTrustManager as only TrustManager. */ private Vector trustManagers = new Vector(1); // ------------------------------ /** * Creates a new IRC connection with secure sockets (SSL).
* The difference to the other constructor is, that it transmits the ports in * an int[]. Thus, also ports like 994, 6000 and 6697 can be * selected.

* The constructor prepares a new IRC connection with secure sockets which * can be really started by invoking the connect method. Before * invoking it, you should set the IRCEventListener, optionally * the TrustManager, if you don't want to use the * SSLDefaultTrustManager which accepts the X509 certificate * automatically, and other settings.
* Note that you do not need to set a password to connect to the large public * IRC networks like QuakeNet, EFNet etc. To use no password in your IRC * connection, use "" or null for the password * argument in the constructor. * @param host The hostname of the server we want to connect to. * @param ports The portrange to which we want to connect. * @param pass The password of the IRC server. If your server isn't * secured by a password (that's normal), use * null or "". * @param nick The nickname for the connection. Is used to register the * connection. * @param username The username. Is used to register the connection. * @param realname The realname. Is used to register the connection. * @throws IllegalArgumentException If the host or * ports is null or * ports' length is * 0. * @see #connect() */ public SSLIRCConnection(String host, int[] ports, String pass, String nick, String username, String realname) { super(host, ports, pass, nick, username, realname); } // ------------------------------ /** * Creates a new IRC connection with secure sockets (SSL).
* The difference to the other constructor is, that it transmits the ports as * two ints. Thus, only a portrange from port x to * port y like from port 6000 to 6010 can be selected.
*
* The constructor prepares a new IRC connection with secure sockets which * can be really started by invoking the connect method. Before * invoking it, you should set the IRCEventListener, optionally * the TrustManager, if you don't want to use the * SSLDefaultTrustManager which accepts the X509 certificate * automatically, and other settings.
* Note that you do not need to set a password to connect to the large public * IRC networks like QuakeNet, EFNet etc. To use no password in your IRC * connection, use "" or null for the password * argument in the constructor. * @param host The hostname of the server we want to connect to. * @param portMin The beginning of the port range we are going to connect * to. * @param portMax The ending of the port range we are going to connect to. * @param pass The password of the IRC server. If your server isn't * secured by a password (that's normal), use * null or "". * @param nick The nickname for the connection. Is used to register the * connection. * @param username The username. Is used to register the connection. * @param realname The realname. Is used to register the connection. * @throws IllegalArgumentException If the host is * null. * @see #connect() */ public SSLIRCConnection(String host, int portMin, int portMax, String pass, String nick, String username, String realname) { super(host, portMin, portMax, pass, nick, username, realname); } // ------------------------------ /** * Establish a connection to the server.
* This method must be invoked to start a connection; the constructor doesn't * do that!
* It tries all set ports until one is open. If all ports fail it throws an * IOException. If anything SSL related fails (for example * conflicts with the algorithms or during the handshaking), a * SSLException is thrown.
* You can invoke connect only one time. * @throws IOException If an I/O error occurs. * @throws SSLException If anything with the secure sockets fails. * @throws SocketException If the connect method was already * invoked. * @see #isConnected() * @see #doQuit() * @see #doQuit(String) * @see #close() */ public void connect() throws IOException { if (level != 0) // otherwise disconnected or connect throw new SocketException("Socket closed or already open ("+ level +")"); IOException exception = null; SSLSocketFactory sf = null; SSLSocket s = null; for (int i = 0; i < ports.length && s == null; i++) { try { if (sf == null) sf = getSocketFactory(); s = (SSLSocket)sf.createSocket(host, ports[i]); s.startHandshake(); exception = null; } catch (IOException exc) { if (s != null) s.close(); s = null; exception = exc; } } if (exception != null) throw exception; // connection wasn't successful at any port prepare(s); } // ------------------------------ /** * Creates a new SSLSocketFactory on whose base a new * SSLSocket can be created. This method is used by the * connect method. If a NoSuchAlgorithmException, * KeyManagementException, or any other exception is thrown, * it's catched a SSLException is thrown. This * SSLException contains all information about the exception * which was really thrown.

* If there are now TrustManagers set at the moment, an instance * of SSLDefultTrustManager is set automatically. * @throws SSLException If any exception is thrown. It contains all the thrown * exception's information. * @return A new SSLSocketFactory on which base a new * SSLSocket can be created. */ private SSLSocketFactory getSocketFactory() throws SSLException { if (trustManagers.size() == 0) addTrustManager(new SSLDefaultTrustManager()); try { Security.addProvider(new Provider()); SSLContext context = SSLContext.getInstance("SSL"); context.init(null, getTrustManagers(), null); SSLSocketFactory socketFactory = context.getSocketFactory(); return socketFactory; } catch (Exception exc) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); exc.printStackTrace(pw); pw.close(); throw new SSLException("Exception while preparing "+ "the SSLSocket:\n---\n"+ sw.toString() + "---"); } } // ------------------------------ /** * Adds a new TrustManager.
* Please remind that we're talking here about * com.sun.net.ssl.TrustManagers of the JSSE API and not the * javax.net.ssl.TrustManagers of the Java 1.4 API! * @param trustManager The TrustManager object which is to add. * @see #removeTrustManager(TrustManager) * @see #getTrustManagers() */ public void addTrustManager(TrustManager trustManager) { trustManagers.add(trustManager); } // ------------------------------ /** * Removes one TrustManager.
* Please remind that we're talking here about * com.sun.net.ssl.TrustManagers of the JSSE API and not the * javax.net.ssl.TrustManagers of the Java 1.4 API! * @param trustManager The TrustManager object which is to * remove. * @return true if a TrustManager was removed. * @see #addTrustManager(TrustManager) * @see #getTrustManagers() */ public boolean removeTrustManager(TrustManager trustManager) { return trustManagers.remove(trustManager); } // ------------------------------ /** * Returns the set TrustManagers. The default * TrustManager is an instance of * SSLDefaultTrustManager, which is set when you invoke the * connect method without having set another * TrustManager.
* Please remind that we're talking here about * com.sun.net.ssl.TrustManagers of the JSSE API and not the * javax.net.ssl.TrustManagers of the Java 1.4 API! * @return The set TrustManagers. * @see #addTrustManager(TrustManager) * @see #removeTrustManager(TrustManager) */ public TrustManager[] getTrustManagers() { TrustManager[] tm = new TrustManager[trustManagers.size()]; trustManagers.copyInto(tm); return tm; } } libirclib-java-1.10/src/org/schwering/irc/lib/package.html000066400000000000000000000023211155103677700234720ustar00rootroot00000000000000 IRClib is a library for the client-side of IRC (Internet Relay Chat) connections.

IRClib is RFC1459 and RFC2812 compliant. It's licensed under the GNU Lesser General Public License, the Apache License 2.0 and the Eclipse Public License so that you can use and modify it for your purposes for free.

By instantiating the {@link org.schwering.irc.lib.IRCConnection} class you can establish a new connection to an IRC server. The {@link org.schwering.irc.lib.IRCEventListener} informs your class about lines coming from the server which are parsed by the {@link org.schwering.irc.lib.IRCParser}. The {@link org.schwering.irc.lib.IRCModeParser} is especially made for channel-modes.
To create a secure connection with SSL, instantiate the {@link org.schwering.irc.lib.ssl.SSLIRCConnection}.

This project's home page is available at http://moepii.sourceforge.net.

If you're using IRClib, write a mail to me so that I can put you on the using-IRClib-list! @version 1.10 @author Christoph Schwering <schwering@gmail.com> libirclib-java-1.10/src/org/schwering/irc/lib/ssl/000077500000000000000000000000001155103677700220145ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/000077500000000000000000000000001155103677700227005ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/README.txt000066400000000000000000000001661155103677700244010ustar00rootroot00000000000000This is a Subversion working copy administrative directory. Visit http://subversion.tigris.org/ for more information. libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/dir-wcprops000066400000000000000000000001501155103677700250700ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 63 /svnroot/moepii/!svn/ver/30/trunk/src/org/schwering/irc/lib/ssl END libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/empty-file000066400000000000000000000000001155103677700246640ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/entries000066400000000000000000000046771155103677700243120ustar00rootroot00000000000000 libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/format000066400000000000000000000000021155103677700241030ustar00rootroot000000000000004 libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/text-base/000077500000000000000000000000001155103677700245745ustar00rootroot00000000000000SSLDefaultTrustManager.java.svn-base000066400000000000000000000036501155103677700334040ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/text-base/* * IRClib -- A Java Internet Relay Chat library -- class SSLDefaultTrustManager * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib.ssl; import java.security.cert.X509Certificate; /** * The default TrustManager of the * SSLIRCConnection. *

* It automatically accepts the X509 certificate. *

* In many cases you should change the SSLIRCConnection's * SSLTrustManager. For examle if you write an IRC client for human * users, you may want to ask the user whether he accepts the server's * certificate or not. * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 2.00 * @see SSLIRCConnection * @see SSLTrustManager */ public class SSLDefaultTrustManager implements SSLTrustManager { /** * The X509Certificates which are accepted. */ protected X509Certificate[] accepted = new X509Certificate[0]; // ------------------------------ /** * Trusts the complete certificate chain and returns true. * @param chain The peer certificate chain. * @return true. */ public boolean isTrusted(X509Certificate[] chain) { accepted = chain; return true; } // ------------------------------ /** * Returns the accepted certificates. They are set in the * checkServerTrusted method. * @return A non-null (possibly empty) array of acceptable CA issuer * certificates. */ public X509Certificate[] getAcceptedIssuers() { return accepted; } } libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/text-base/SSLIRCConnection.java.svn-base000066400000000000000000000303651155103677700322020ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class SSLIRCConnection * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib.ssl; import java.io.IOException; import java.net.SocketException; import java.util.Vector; import javax.net.ssl.SSLException; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import org.schwering.irc.lib.IRCConnection; /** * The SSL extension of the IRCConnection class. *

* The IRC server you want to connect to must accept SSL connections. * Otherwise you cannot connect to it with an instance of * SSLIRCConnection. IRC servers which accept SSL connections are * really very rare, because SSL means a high load for the server. *

* The following sample code tries to establish an IRC connection to an * IRC server which must support SSL. Differences to the code which * demonstrates the use of of the {@link org.schwering.irc.lib.IRCConnection} * class are printed in bold font: *

*


 * /* 
 *  * The following code of a class which imports org.schwering.irc.lib.*
 *  * prepares an SSL IRC connection and then tries to establish the 
 *  * connection. The server is "irc.somenetwork.com", the ports are 
 *  * the default SSL port (443) and the port used on most SSL IRC servers
 *  * (994). No password is used (null). The nickname is "Foo" and 
 *  * the realname is "Mr. Foobar". The username "foobar".
 *  * Because of setDaemon(true), the JVM exits even if this thread is 
 *  * running.
 *  * By setting an instance of SSLDefaultTrustManager as TrustManager
 *  * (which is also done implicitely by the SSLIRCConnection class if no
 *  * TrustManager is set until the connect method is invoked), the
 *  * X509Certificate is accepted automatically. Of course, you can write
 *  * your own TrustManager. For example, you could write a class which
 *  * extends SSLDefaultTrustManager and overrides its checkServerTrusted
 *  * method. In the new checkServerTrusted method, you could ask the user
 *  * to accept or reject the certificate.
 *  * An instance of the class MyListener which must implement 
 *  * IRCActionListener is set as event-listener for the connection. 
 *  * The connection is told to parse out mIRC color codes and to enable
 *  * automatic PING? PONG! replies.
 *  */
 * SSLIRCConnection conn = new SSLIRCConnection(
 *                               "irc.somenetwork.com", 
 *                               new int[] { 443, 994 },  
 *                               null, 
 *                               "Foo", 
 *                               "Mr. Foobar", 
 *                               "foo@bar.com" 
 *                             ); 
 * 
 * conn.addIRCEventListener(new MyListener()); 
 * conn.addTrustManager(new SSLDefaultTrustManager());
 * conn.setDaemon(true);
 * conn.setColors(false); 
 * conn.setPong(true); 
 *   
 * try {
 *   conn.connect(); // Try to connect!!! Don't forget this!!!
 * } catch (IOException ioexc) {
 *   ioexc.printStackTrace(); 
 * }
 * 

*

* The serverpassword isn't needed in most cases. You can give * null or "" instead as done in this example. *

* SSLTrustManagers can be added and removed until the * connect method is invoked. If no SSLTrustManagers * are set until then, an * {@link org.schwering.irc.lib.ssl.SSLDefaultTrustManager} is set * automatically. It accepts all X509 certificates. * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 2.00 * @see org.schwering.irc.lib.IRCConnection * @see SSLTrustManager */ public class SSLIRCConnection extends IRCConnection { /** * The SSL protocol of choice. Values can be "TLS", "SSLv3" or "SSL". * "SSL" is the default value. */ public static String protocol = "SSL"; /** * The list of SSLTrustManagers. */ private Vector trustManagers = new Vector(1); // ------------------------------ /** * Creates a new IRC connection with secure sockets (SSL).
* The difference to the other constructor is, that it transmits the ports in * an int[]. Thus, also ports like 994, 6000 and 6697 can be * selected.

* The constructor prepares a new IRC connection with secure sockets which * can be really started by invoking the connect method. Before * invoking it, you should set the IRCEventListener, optionally * the SSLTrustManager, if you don't want to use the * SSLDefaultTrustManager which accepts the X509 certificate * automatically, and other settings.
* Note that you do not need to set a password to connect to the large public * IRC networks like QuakeNet, EFNet etc. To use no password in your IRC * connection, use "" or null for the password * argument in the constructor. * @param host The hostname of the server we want to connect to. * @param ports The portrange to which we want to connect. * @param pass The password of the IRC server. If your server isn't * secured by a password (that's normal), use * null or "". * @param nick The nickname for the connection. Is used to register the * connection. * @param username The username. Is used to register the connection. * @param realname The realname. Is used to register the connection. * @throws IllegalArgumentException If the host or * ports is null or * ports' length is * 0. * @see #connect() */ public SSLIRCConnection(String host, int[] ports, String pass, String nick, String username, String realname) { super(host, ports, pass, nick, username, realname); } // ------------------------------ /** * Creates a new IRC connection with secure sockets (SSL).
* The difference to the other constructor is, that it transmits the ports as * two ints. Thus, only a portrange from port x to * port y like from port 6000 to 6010 can be selected.
*
* The constructor prepares a new IRC connection with secure sockets which * can be really started by invoking the connect method. Before * invoking it, you should set the IRCEventListener, optionally * the SSLTrustManager, if you don't want to use the * SSLDefaultTrustManager which accepts the X509 certificate * automatically, and other settings.
* Note that you do not need to set a password to connect to the large public * IRC networks like QuakeNet, EFNet etc. To use no password in your IRC * connection, use "" or null for the password * argument in the constructor. * @param host The hostname of the server we want to connect to. * @param portMin The beginning of the port range we are going to connect * to. * @param portMax The ending of the port range we are going to connect to. * @param pass The password of the IRC server. If your server isn't * secured by a password (that's normal), use * null or "". * @param nick The nickname for the connection. Is used to register the * connection. * @param username The username. Is used to register the connection. * @param realname The realname. Is used to register the connection. * @throws IllegalArgumentException If the host is * null. * @see #connect() */ public SSLIRCConnection(String host, int portMin, int portMax, String pass, String nick, String username, String realname) { super(host, portMin, portMax, pass, nick, username, realname); } // ------------------------------ /** * Establish a connection to the server.
* This method must be invoked to start a connection; the constructor doesn't * do that!
* It tries all set ports until one is open. If all ports fail it throws an * IOException. If anything SSL related fails (for example * conflicts with the algorithms or during the handshaking), a * SSLException is thrown.
* You can invoke connect only one time. * @throws NoClassDefFoundError If SSL is not supported. This is the case * if neither JSSE nor J2SE 1.4 or later is * installed. * @throws SSLNotSupportedException If SSL is not supported. This is the * case if neither JSSE nor J2SE 1.4 or * later is installed. This exception is * thrown if no NoClassDefFoundError is * thrown. * @throws IOException If an I/O error occurs. * @throws SSLException If anything with the secure sockets fails. * @throws SocketException If the connect method was already * invoked. * @see #isConnected() * @see #doQuit() * @see #doQuit(String) * @see #close() */ public void connect() throws IOException { if (level != 0) // otherwise disconnected or connect throw new SocketException("Socket closed or already open ("+ level +")"); IOException exception = null; if (trustManagers.size() == 0) addTrustManager(new SSLDefaultTrustManager()); SSLSocketFactory sf = null; SSLSocket s = null; for (int i = 0; i < ports.length && s == null; i++) { try { if (sf == null) sf = SSLSocketFactoryFactory.createSSLSocketFactory(getTrustManagers()); s = (SSLSocket)sf.createSocket(host, ports[i]); s.startHandshake(); exception = null; } catch (SSLNotSupportedException exc) { if (s != null) s.close(); s = null; throw exc; } catch (IOException exc) { if (s != null) s.close(); s = null; exception = exc; } } if (exception != null) throw exception; // connection wasn't successful at any port prepare(s); } // ------------------------------ /** * Adds a new SSLTrustManager. * @param trustManager The SSLTrustManager object which is to * add. * @see #removeTrustManager(SSLTrustManager) * @see #getTrustManagers() */ public void addTrustManager(SSLTrustManager trustManager) { trustManagers.add(trustManager); } // ------------------------------ /** * Removes one SSLTrustManager. * @param trustManager The SSLTrustManager object which is to * remove. * @return true if a SSLTrustManager was removed. * @see #addTrustManager(SSLTrustManager) * @see #getTrustManagers() */ public boolean removeTrustManager(SSLTrustManager trustManager) { return trustManagers.remove(trustManager); } // ------------------------------ /** * Returns the set SSLTrustManagers. The default * SSLTrustManager is an instance of * SSLDefaultTrustManager, which is set when you invoke the * connect method without having set another * SSLTrustManager. * @return The set SSLTrustManagers. * @see #addTrustManager(SSLTrustManager) * @see #removeTrustManager(SSLTrustManager) */ public SSLTrustManager[] getTrustManagers() { SSLTrustManager[] tm = new SSLTrustManager[trustManagers.size()]; trustManagers.copyInto(tm); return tm; } } SSLNotSupportedException.java.svn-base000066400000000000000000000024071155103677700340070ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/text-base/* * IRClib -- A Java Internet Relay Chat library -- class SSLNotSupportedException * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib.ssl; /** * Indicates that SSL is not supported. However, a * NoClassDefFoundError is probably thrown before a * SSLNotSupportedException can be thrown, because the * javax.net.SocketFactory will not be found (among others). * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 1.00 * @see SSLIRCConnection */ public class SSLNotSupportedException extends RuntimeException { private static final long serialVersionUID = -5108810948951810903L; /** * Empty exception. */ public SSLNotSupportedException() { super(); } // ------------------------------ /** * Creates an exception with description. * @param s The description. */ public SSLNotSupportedException(String s) { super(s); } } SSLSocketFactoryFactory.java.svn-base000066400000000000000000000213731155103677700335750ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/text-base/* * IRClib -- A Java Internet Relay Chat library -- class SSLSocketFactoryFactory * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib.ssl; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.SSLException; /** * Factory for javax.net.ssl.SSLSocketFactory. Firstly tries to * creates this object using exclusively the javax.net.ssl.* * classes and then tries to do so using the javax.net.ssl.* * classes plus the com.sun.net.ssl.* classes. * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 1.00 * @see SSLIRCConnection * @see SSLIRCConnection#connect() */ class SSLSocketFactoryFactory { /** * Disallow instances. */ private SSLSocketFactoryFactory() { } // ------------------------------ /** * Creates a new SSLSocketFactory. This method first tries to * create it using javax.net.ssl.* classes. If this fails, it * tries to access the old JSSE classes in com.sun.net.ssl.*. * @throws SSLNotSupportedException If neither JSSE nor J2SE >= 1.4 are * installed. * @throws SSLException If any exception is thrown. It contains all the * thrown exception's information. * @return A new SSLSocketFactory. */ public static SSLSocketFactory createSSLSocketFactory(SSLTrustManager[] tm) throws SSLException, SSLNotSupportedException { boolean sslNotSupported = false; Exception exception = null; try { return createJava14SSLSocketFactory(tm); } catch (ClassNotFoundException cnfe) { // try JSSE after try/catch block } catch (NoSuchMethodException nsme) { // try JSSE after try/catch block } catch (InvocationTargetException ite) { // try JSSE after try/catch block } catch (IllegalAccessException eae) { // try JSSE after try/catch block } catch (Exception exc) { // try JSSE after try/catch block } try { return createJsseSSLSocketFactory(tm); } catch (ClassNotFoundException cnfe) { exception = cnfe; sslNotSupported = true; } catch (NoSuchMethodException nsme) { exception = nsme; sslNotSupported = true; } catch (InstantiationException ie) { exception = ie; sslNotSupported = true; } catch (InvocationTargetException ite) { exception = ite; sslNotSupported = true; } catch (IllegalAccessException eae) { exception = eae; sslNotSupported = true; } catch (Exception exc) { exception = exc; } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); exception.printStackTrace(pw); pw.close(); if (sslNotSupported) { throw new SSLNotSupportedException("Neither JSSE nor J2SE " + ">= 1.4 installed:\n---\n"+ sw.toString() +"---"); } else { throw new SSLException("Exception while creating "+ "the SSLSocketFactory with JSSE:\n---\n"+ sw.toString() + "---"); } } // ------------------------------ /** * Creates a new SSLSocketFactory using the * javax.net.ssl.* classes. * @param tm The trustmanagers. * @return A javax.net.ssl.SSLSocketFactory. * @throws ClassNotFoundException If the classes could not be loaded and * accessed properly * @throws NoSuchMethodException If the classes could not be loaded and * accessed properly * @throws InvocationTargetException If the classes could not be loaded and * accessed properly * @throws IllegalAccessException If the classes could not be loaded and * accessed properly */ private static SSLSocketFactory createJava14SSLSocketFactory(SSLTrustManager[] tm) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { /* * The code below does the following: * TrustManagerJava14Wrapper[] tmWrappers = TrustManagerJava14Wrapper.wrap(tm); * javax.net.ssl.SSLContext context = javax.net.ssl.SSLContext.getInstance("SSL"); * context.init(null, tmWrappers, null); * SSLSocketFactory socketFactory = context.getSocketFactory(); */ Class stringClass = String.class; Class contextClass = Class.forName("javax.net.ssl.SSLContext"); Class keyManagerClass = Class.forName("javax.net.ssl.KeyManager"); Class keyManagerArrayClass = java.lang.reflect.Array.newInstance(keyManagerClass, 0).getClass(); Class trustManagerClass = Class.forName("javax.net.ssl.TrustManager"); Class trustManagerArrayClass = java.lang.reflect.Array.newInstance(trustManagerClass, 0).getClass(); Class secureRandomClass = java.security.SecureRandom.class; Method getInstanceMethod = contextClass.getMethod("getInstance", new Class[] { stringClass }); Method initMethod = contextClass.getMethod("init", new Class[] { keyManagerArrayClass, trustManagerArrayClass, secureRandomClass }); Method getSocketFactoryMethod = contextClass.getMethod("getSocketFactory", null); Class.forName("javax.net.ssl.X509TrustManager"); // check for availability TrustManagerJava14Wrapper[] tmWrappers = TrustManagerJava14Wrapper.wrap(tm); String protocol = SSLIRCConnection.protocol; Object context = getInstanceMethod.invoke(null, new Object[] { protocol }); initMethod.invoke(context, new Object[] { null, tmWrappers, null }); Object socketFactory = getSocketFactoryMethod.invoke(context, null); return (SSLSocketFactory)socketFactory; } // ------------------------------ /** * Creates a new SSLSocketFactory using the * com.sun.net.ssl.* and javax.net.ssl.* classes. * @param tm The trustmanagers. * @return A javax.net.ssl.SSLSocketFactory. * @throws ClassNotFoundException If the classes could not be loaded and * accessed properly * @throws NoSuchMethodException If the classes could not be loaded and * accessed properly * @throws InvocationTargetException If the classes could not be loaded and * accessed properly * @throws IllegalAccessException If the classes could not be loaded and * accessed properly */ private static SSLSocketFactory createJsseSSLSocketFactory(SSLTrustManager[] tm) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, InvocationTargetException, IllegalAccessException { /* * The code below does the following: * java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); * * TrustManagerJsseWrapper[] tmWrappers = TrustManagerJsseWrapper.wrap(tm); * com.sun.net.ssl.SSLContext context = com.sun.net.ssl.SSLContext.getInstance("SSL"); * context.init(null, tmWrappers, null); * SSLSocketFactory socketFactory = context.getSocketFactory(); */ Class securityClass = Class.forName("java.security.Security"); Class providerClass = Class.forName("java.security.Provider"); Class sslProviderClass = Class.forName("com.sun.net.ssl.internal.ssl.Provider"); Method addProvider = securityClass.getMethod("addProvider", new Class[] { providerClass }); Object provider = sslProviderClass.newInstance(); addProvider.invoke(null, new Object[] { provider }); Class stringClass = String.class; Class contextClass = Class.forName("com.sun.net.ssl.SSLContext"); Class keyManagerClass = Class.forName("com.sun.net.ssl.KeyManager"); Class keyManagerArrayClass = java.lang.reflect.Array.newInstance(keyManagerClass, 0).getClass(); Class trustManagerClass = Class.forName("com.sun.net.ssl.TrustManager"); Class trustManagerArrayClass = java.lang.reflect.Array.newInstance(trustManagerClass, 0).getClass(); Class secureRandomClass = java.security.SecureRandom.class; Method getInstanceMethod = contextClass.getMethod("getInstance", new Class[] { stringClass }); Method initMethod = contextClass.getMethod("init", new Class[] { keyManagerArrayClass, trustManagerArrayClass, secureRandomClass }); Method getSocketFactoryMethod = contextClass.getMethod("getSocketFactory", null); Class.forName("com.sun.net.ssl.X509TrustManager"); // check for availability TrustManagerJsseWrapper[] tmWrappers = TrustManagerJsseWrapper.wrap(tm); String protocol = SSLIRCConnection.protocol; Object context = getInstanceMethod.invoke(null, new Object[] { protocol }); initMethod.invoke(context, new Object[] { null, tmWrappers, null }); Object socketFactory = getSocketFactoryMethod.invoke(context, null); return (SSLSocketFactory)socketFactory; } } libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/text-base/SSLTrustManager.java.svn-base000066400000000000000000000030421155103677700321510ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class SSLTrustManager * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib.ssl; import java.security.cert.X509Certificate; /** * A trust manager decides whether the server is trusted or not. * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 1.00 * @see SSLIRCConnection * @see SSLDefaultTrustManager */ public interface SSLTrustManager { /** * Checks whether the server is trusted or not.
* Given the partial or complete certificate chain provided by the peer, * build a certificate path to a trusted root and return true if it can * be validated and is trusted for server SSL authentication. * @param chain The peer certificate chain. * @return true if the server is trusted, false * if the server is not trusted. */ public boolean isTrusted(X509Certificate[] chain); // ------------------------------ /** * Return an array of certificate authority certificates which are trusted * for authenticating peers. * @return A non-null (possibly empty) array of acceptable CA issuer * certificates. */ public X509Certificate[] getAcceptedIssuers(); } TrustManagerJava14Wrapper.java.svn-base000066400000000000000000000057551155103677700340350ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/text-base/* * IRClib -- A Java Internet Relay Chat library -- class TrustManagerJava14Wrapper * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib.ssl; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; /** * Wraps a SSLTrustManager in a * javax.net.ssl.X509TrustManager. * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 1.00 * @see SSLTrustManager * @see javax.net.ssl.X509TrustManager */ class TrustManagerJava14Wrapper implements javax.net.ssl.X509TrustManager { /** * The trust manager that is wrapped. */ private SSLTrustManager trustManager; // ------------------------------ public static TrustManagerJava14Wrapper[] wrap(SSLTrustManager[] tm) { TrustManagerJava14Wrapper[] w = new TrustManagerJava14Wrapper[tm.length]; for (int i = 0; i < tm.length; i++) { w[i] = new TrustManagerJava14Wrapper(tm[i]); } return w; } // ------------------------------ /** * Creates a new trust manager wrapper. * @param trustManager The SSLTrustManager that should be * wrapped by a javax.net.ssl.X509TrustManager. */ public TrustManagerJava14Wrapper(SSLTrustManager trustManager) { if (trustManager == null) { throw new IllegalArgumentException("trustManager == null"); } this.trustManager = trustManager; } // ------------------------------ /** * Always throws a CertificateException. * @param chain The peer certificate chain. * @param authType The authentication type based on the client certificate. * @throws CertificateException Always. */ public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { throw new CertificateException("This trust manager _is_ for clients. "+ "What other client should be trusted?"); } // ------------------------------ /** * Does nothing if the server is trusted, throws a * CertificateException otherwise. This decision is made by * the trustManager. * @throws CertificateException If the server is not trusted. */ public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { if (!trustManager.isTrusted(chain)) { throw new CertificateException("The certificate chain is not "+ "trusted!"); } } // ------------------------------ /** * Returns true if the server is trusted. This decision is * made by the trustManager. * @return trustManager.isTrusted(chain). */ public X509Certificate[] getAcceptedIssuers() { return trustManager.getAcceptedIssuers(); } } TrustManagerJsseWrapper.java.svn-base000066400000000000000000000047711155103677700337100ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/text-base/* * IRClib -- A Java Internet Relay Chat library -- class TrustManagerJsseWrapper * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib.ssl; import java.security.cert.X509Certificate; /** * Wraps a SSLTrustManager in a * com.sun.net.ssl.X509TrustManager. * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 1.00 * @see SSLTrustManager * @see com.sun.net.ssl.TrustManager */ class TrustManagerJsseWrapper implements com.sun.net.ssl.X509TrustManager { /** * The trust manager that is wrapped. */ private SSLTrustManager trustManager; // ------------------------------ public static TrustManagerJsseWrapper[] wrap(SSLTrustManager[] tm) { TrustManagerJsseWrapper[] w = new TrustManagerJsseWrapper[tm.length]; for (int i = 0; i < tm.length; i++) { w[i] = new TrustManagerJsseWrapper(tm[i]); } return w; } // ------------------------------ /** * Creates a new trust manager wrapper. * @param trustManager The SSLTrustManager that should be * wrapped by a com.sun.net.ssl.X509TrustManager. */ public TrustManagerJsseWrapper(SSLTrustManager trustManager) { if (trustManager == null) { throw new IllegalArgumentException("trustManager == null"); } this.trustManager = trustManager; } // ------------------------------ /** * Always returns false. * @param chain The peer certificate chain. * @return Always false. */ public boolean isClientTrusted(X509Certificate[] chain) { return false; } // ------------------------------ /** * Returns true if the server is trusted. This decision is * made by the trustManager. * @return trustManager.isTrusted(chain). */ public boolean isServerTrusted(X509Certificate[] chain) { return trustManager.isTrusted(chain); } // ------------------------------ /** * Return an array of certificate authority certificates which are trusted * for authenticating peers. * @return trustManager.getAcceptedIssuers. */ public X509Certificate[] getAcceptedIssuers() { return trustManager.getAcceptedIssuers(); } } libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/text-base/package.html.svn-base000066400000000000000000000006751155103677700306020ustar00rootroot00000000000000 Provides support for secure IRC connections.

The {@link org.schwering.irc.lib.ssl.SSLIRCConnection} firstly tries to use the javax.net.ssl.* classes which were added in J2SE 1.4. If this fails, it tries to load the classes of the JSSE library (from the packages javax.net.ssl.* and com.sun.net.ssl.*). @since 1.10 @version 1.00 @author Christoph Schwering <schwering@gmail.com> libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/wcprops/000077500000000000000000000000001155103677700243755ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/wcprops/SSLDefaultTrustManager.java.svn-work000066400000000000000000000002041155103677700333240ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 91 /svnroot/moepii/!svn/ver/25/trunk/src/org/schwering/irc/lib/ssl/SSLDefaultTrustManager.java END libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/wcprops/SSLIRCConnection.java.svn-work000066400000000000000000000001761155103677700320500ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 85 /svnroot/moepii/!svn/ver/29/trunk/src/org/schwering/irc/lib/ssl/SSLIRCConnection.java END SSLNotSupportedException.java.svn-work000066400000000000000000000002061155103677700336530ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/wcpropsK 25 svn:wc:ra_dav:version-url V 93 /svnroot/moepii/!svn/ver/34/trunk/src/org/schwering/irc/lib/ssl/SSLNotSupportedException.java END libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/wcprops/SSLSocketFactoryFactory.java.svn-work000066400000000000000000000002051155103677700335140ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 92 /svnroot/moepii/!svn/ver/34/trunk/src/org/schwering/irc/lib/ssl/SSLSocketFactoryFactory.java END libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/wcprops/SSLTrustManager.java.svn-work000066400000000000000000000001751155103677700320260ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 84 /svnroot/moepii/!svn/ver/34/trunk/src/org/schwering/irc/lib/ssl/SSLTrustManager.java END TrustManagerJava14Wrapper.java.svn-work000066400000000000000000000002071155103677700336710ustar00rootroot00000000000000libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/wcpropsK 25 svn:wc:ra_dav:version-url V 94 /svnroot/moepii/!svn/ver/34/trunk/src/org/schwering/irc/lib/ssl/TrustManagerJava14Wrapper.java END libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/wcprops/TrustManagerJsseWrapper.java.svn-work000066400000000000000000000002051155103677700336240ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 92 /svnroot/moepii/!svn/ver/34/trunk/src/org/schwering/irc/lib/ssl/TrustManagerJsseWrapper.java END libirclib-java-1.10/src/org/schwering/irc/lib/ssl/.svn/wcprops/package.html.svn-work000066400000000000000000000001651155103677700304450ustar00rootroot00000000000000K 25 svn:wc:ra_dav:version-url V 76 /svnroot/moepii/!svn/ver/26/trunk/src/org/schwering/irc/lib/ssl/package.html END libirclib-java-1.10/src/org/schwering/irc/lib/ssl/SSLDefaultTrustManager.java000066400000000000000000000036501155103677700271660ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class SSLDefaultTrustManager * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib.ssl; import java.security.cert.X509Certificate; /** * The default TrustManager of the * SSLIRCConnection. *

* It automatically accepts the X509 certificate. *

* In many cases you should change the SSLIRCConnection's * SSLTrustManager. For examle if you write an IRC client for human * users, you may want to ask the user whether he accepts the server's * certificate or not. * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 2.00 * @see SSLIRCConnection * @see SSLTrustManager */ public class SSLDefaultTrustManager implements SSLTrustManager { /** * The X509Certificates which are accepted. */ protected X509Certificate[] accepted = new X509Certificate[0]; // ------------------------------ /** * Trusts the complete certificate chain and returns true. * @param chain The peer certificate chain. * @return true. */ public boolean isTrusted(X509Certificate[] chain) { accepted = chain; return true; } // ------------------------------ /** * Returns the accepted certificates. They are set in the * checkServerTrusted method. * @return A non-null (possibly empty) array of acceptable CA issuer * certificates. */ public X509Certificate[] getAcceptedIssuers() { return accepted; } } libirclib-java-1.10/src/org/schwering/irc/lib/ssl/SSLIRCConnection.java000066400000000000000000000303651155103677700257050ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class SSLIRCConnection * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib.ssl; import java.io.IOException; import java.net.SocketException; import java.util.Vector; import javax.net.ssl.SSLException; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import org.schwering.irc.lib.IRCConnection; /** * The SSL extension of the IRCConnection class. *

* The IRC server you want to connect to must accept SSL connections. * Otherwise you cannot connect to it with an instance of * SSLIRCConnection. IRC servers which accept SSL connections are * really very rare, because SSL means a high load for the server. *

* The following sample code tries to establish an IRC connection to an * IRC server which must support SSL. Differences to the code which * demonstrates the use of of the {@link org.schwering.irc.lib.IRCConnection} * class are printed in bold font: *

*


 * /* 
 *  * The following code of a class which imports org.schwering.irc.lib.*
 *  * prepares an SSL IRC connection and then tries to establish the 
 *  * connection. The server is "irc.somenetwork.com", the ports are 
 *  * the default SSL port (443) and the port used on most SSL IRC servers
 *  * (994). No password is used (null). The nickname is "Foo" and 
 *  * the realname is "Mr. Foobar". The username "foobar".
 *  * Because of setDaemon(true), the JVM exits even if this thread is 
 *  * running.
 *  * By setting an instance of SSLDefaultTrustManager as TrustManager
 *  * (which is also done implicitely by the SSLIRCConnection class if no
 *  * TrustManager is set until the connect method is invoked), the
 *  * X509Certificate is accepted automatically. Of course, you can write
 *  * your own TrustManager. For example, you could write a class which
 *  * extends SSLDefaultTrustManager and overrides its checkServerTrusted
 *  * method. In the new checkServerTrusted method, you could ask the user
 *  * to accept or reject the certificate.
 *  * An instance of the class MyListener which must implement 
 *  * IRCActionListener is set as event-listener for the connection. 
 *  * The connection is told to parse out mIRC color codes and to enable
 *  * automatic PING? PONG! replies.
 *  */
 * SSLIRCConnection conn = new SSLIRCConnection(
 *                               "irc.somenetwork.com", 
 *                               new int[] { 443, 994 },  
 *                               null, 
 *                               "Foo", 
 *                               "Mr. Foobar", 
 *                               "foo@bar.com" 
 *                             ); 
 * 
 * conn.addIRCEventListener(new MyListener()); 
 * conn.addTrustManager(new SSLDefaultTrustManager());
 * conn.setDaemon(true);
 * conn.setColors(false); 
 * conn.setPong(true); 
 *   
 * try {
 *   conn.connect(); // Try to connect!!! Don't forget this!!!
 * } catch (IOException ioexc) {
 *   ioexc.printStackTrace(); 
 * }
 * 

*

* The serverpassword isn't needed in most cases. You can give * null or "" instead as done in this example. *

* SSLTrustManagers can be added and removed until the * connect method is invoked. If no SSLTrustManagers * are set until then, an * {@link org.schwering.irc.lib.ssl.SSLDefaultTrustManager} is set * automatically. It accepts all X509 certificates. * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 2.00 * @see org.schwering.irc.lib.IRCConnection * @see SSLTrustManager */ public class SSLIRCConnection extends IRCConnection { /** * The SSL protocol of choice. Values can be "TLS", "SSLv3" or "SSL". * "SSL" is the default value. */ public static String protocol = "SSL"; /** * The list of SSLTrustManagers. */ private Vector trustManagers = new Vector(1); // ------------------------------ /** * Creates a new IRC connection with secure sockets (SSL).
* The difference to the other constructor is, that it transmits the ports in * an int[]. Thus, also ports like 994, 6000 and 6697 can be * selected.

* The constructor prepares a new IRC connection with secure sockets which * can be really started by invoking the connect method. Before * invoking it, you should set the IRCEventListener, optionally * the SSLTrustManager, if you don't want to use the * SSLDefaultTrustManager which accepts the X509 certificate * automatically, and other settings.
* Note that you do not need to set a password to connect to the large public * IRC networks like QuakeNet, EFNet etc. To use no password in your IRC * connection, use "" or null for the password * argument in the constructor. * @param host The hostname of the server we want to connect to. * @param ports The portrange to which we want to connect. * @param pass The password of the IRC server. If your server isn't * secured by a password (that's normal), use * null or "". * @param nick The nickname for the connection. Is used to register the * connection. * @param username The username. Is used to register the connection. * @param realname The realname. Is used to register the connection. * @throws IllegalArgumentException If the host or * ports is null or * ports' length is * 0. * @see #connect() */ public SSLIRCConnection(String host, int[] ports, String pass, String nick, String username, String realname) { super(host, ports, pass, nick, username, realname); } // ------------------------------ /** * Creates a new IRC connection with secure sockets (SSL).
* The difference to the other constructor is, that it transmits the ports as * two ints. Thus, only a portrange from port x to * port y like from port 6000 to 6010 can be selected.
*
* The constructor prepares a new IRC connection with secure sockets which * can be really started by invoking the connect method. Before * invoking it, you should set the IRCEventListener, optionally * the SSLTrustManager, if you don't want to use the * SSLDefaultTrustManager which accepts the X509 certificate * automatically, and other settings.
* Note that you do not need to set a password to connect to the large public * IRC networks like QuakeNet, EFNet etc. To use no password in your IRC * connection, use "" or null for the password * argument in the constructor. * @param host The hostname of the server we want to connect to. * @param portMin The beginning of the port range we are going to connect * to. * @param portMax The ending of the port range we are going to connect to. * @param pass The password of the IRC server. If your server isn't * secured by a password (that's normal), use * null or "". * @param nick The nickname for the connection. Is used to register the * connection. * @param username The username. Is used to register the connection. * @param realname The realname. Is used to register the connection. * @throws IllegalArgumentException If the host is * null. * @see #connect() */ public SSLIRCConnection(String host, int portMin, int portMax, String pass, String nick, String username, String realname) { super(host, portMin, portMax, pass, nick, username, realname); } // ------------------------------ /** * Establish a connection to the server.
* This method must be invoked to start a connection; the constructor doesn't * do that!
* It tries all set ports until one is open. If all ports fail it throws an * IOException. If anything SSL related fails (for example * conflicts with the algorithms or during the handshaking), a * SSLException is thrown.
* You can invoke connect only one time. * @throws NoClassDefFoundError If SSL is not supported. This is the case * if neither JSSE nor J2SE 1.4 or later is * installed. * @throws SSLNotSupportedException If SSL is not supported. This is the * case if neither JSSE nor J2SE 1.4 or * later is installed. This exception is * thrown if no NoClassDefFoundError is * thrown. * @throws IOException If an I/O error occurs. * @throws SSLException If anything with the secure sockets fails. * @throws SocketException If the connect method was already * invoked. * @see #isConnected() * @see #doQuit() * @see #doQuit(String) * @see #close() */ public void connect() throws IOException { if (level != 0) // otherwise disconnected or connect throw new SocketException("Socket closed or already open ("+ level +")"); IOException exception = null; if (trustManagers.size() == 0) addTrustManager(new SSLDefaultTrustManager()); SSLSocketFactory sf = null; SSLSocket s = null; for (int i = 0; i < ports.length && s == null; i++) { try { if (sf == null) sf = SSLSocketFactoryFactory.createSSLSocketFactory(getTrustManagers()); s = (SSLSocket)sf.createSocket(host, ports[i]); s.startHandshake(); exception = null; } catch (SSLNotSupportedException exc) { if (s != null) s.close(); s = null; throw exc; } catch (IOException exc) { if (s != null) s.close(); s = null; exception = exc; } } if (exception != null) throw exception; // connection wasn't successful at any port prepare(s); } // ------------------------------ /** * Adds a new SSLTrustManager. * @param trustManager The SSLTrustManager object which is to * add. * @see #removeTrustManager(SSLTrustManager) * @see #getTrustManagers() */ public void addTrustManager(SSLTrustManager trustManager) { trustManagers.add(trustManager); } // ------------------------------ /** * Removes one SSLTrustManager. * @param trustManager The SSLTrustManager object which is to * remove. * @return true if a SSLTrustManager was removed. * @see #addTrustManager(SSLTrustManager) * @see #getTrustManagers() */ public boolean removeTrustManager(SSLTrustManager trustManager) { return trustManagers.remove(trustManager); } // ------------------------------ /** * Returns the set SSLTrustManagers. The default * SSLTrustManager is an instance of * SSLDefaultTrustManager, which is set when you invoke the * connect method without having set another * SSLTrustManager. * @return The set SSLTrustManagers. * @see #addTrustManager(SSLTrustManager) * @see #removeTrustManager(SSLTrustManager) */ public SSLTrustManager[] getTrustManagers() { SSLTrustManager[] tm = new SSLTrustManager[trustManagers.size()]; trustManagers.copyInto(tm); return tm; } } libirclib-java-1.10/src/org/schwering/irc/lib/ssl/SSLNotSupportedException.java000066400000000000000000000024071155103677700275710ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class SSLNotSupportedException * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib.ssl; /** * Indicates that SSL is not supported. However, a * NoClassDefFoundError is probably thrown before a * SSLNotSupportedException can be thrown, because the * javax.net.SocketFactory will not be found (among others). * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 1.00 * @see SSLIRCConnection */ public class SSLNotSupportedException extends RuntimeException { private static final long serialVersionUID = -5108810948951810903L; /** * Empty exception. */ public SSLNotSupportedException() { super(); } // ------------------------------ /** * Creates an exception with description. * @param s The description. */ public SSLNotSupportedException(String s) { super(s); } } libirclib-java-1.10/src/org/schwering/irc/lib/ssl/SSLSocketFactoryFactory.java000066400000000000000000000213731155103677700273570ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class SSLSocketFactoryFactory * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib.ssl; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.SSLException; /** * Factory for javax.net.ssl.SSLSocketFactory. Firstly tries to * creates this object using exclusively the javax.net.ssl.* * classes and then tries to do so using the javax.net.ssl.* * classes plus the com.sun.net.ssl.* classes. * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 1.00 * @see SSLIRCConnection * @see SSLIRCConnection#connect() */ class SSLSocketFactoryFactory { /** * Disallow instances. */ private SSLSocketFactoryFactory() { } // ------------------------------ /** * Creates a new SSLSocketFactory. This method first tries to * create it using javax.net.ssl.* classes. If this fails, it * tries to access the old JSSE classes in com.sun.net.ssl.*. * @throws SSLNotSupportedException If neither JSSE nor J2SE >= 1.4 are * installed. * @throws SSLException If any exception is thrown. It contains all the * thrown exception's information. * @return A new SSLSocketFactory. */ public static SSLSocketFactory createSSLSocketFactory(SSLTrustManager[] tm) throws SSLException, SSLNotSupportedException { boolean sslNotSupported = false; Exception exception = null; try { return createJava14SSLSocketFactory(tm); } catch (ClassNotFoundException cnfe) { // try JSSE after try/catch block } catch (NoSuchMethodException nsme) { // try JSSE after try/catch block } catch (InvocationTargetException ite) { // try JSSE after try/catch block } catch (IllegalAccessException eae) { // try JSSE after try/catch block } catch (Exception exc) { // try JSSE after try/catch block } try { return createJsseSSLSocketFactory(tm); } catch (ClassNotFoundException cnfe) { exception = cnfe; sslNotSupported = true; } catch (NoSuchMethodException nsme) { exception = nsme; sslNotSupported = true; } catch (InstantiationException ie) { exception = ie; sslNotSupported = true; } catch (InvocationTargetException ite) { exception = ite; sslNotSupported = true; } catch (IllegalAccessException eae) { exception = eae; sslNotSupported = true; } catch (Exception exc) { exception = exc; } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); exception.printStackTrace(pw); pw.close(); if (sslNotSupported) { throw new SSLNotSupportedException("Neither JSSE nor J2SE " + ">= 1.4 installed:\n---\n"+ sw.toString() +"---"); } else { throw new SSLException("Exception while creating "+ "the SSLSocketFactory with JSSE:\n---\n"+ sw.toString() + "---"); } } // ------------------------------ /** * Creates a new SSLSocketFactory using the * javax.net.ssl.* classes. * @param tm The trustmanagers. * @return A javax.net.ssl.SSLSocketFactory. * @throws ClassNotFoundException If the classes could not be loaded and * accessed properly * @throws NoSuchMethodException If the classes could not be loaded and * accessed properly * @throws InvocationTargetException If the classes could not be loaded and * accessed properly * @throws IllegalAccessException If the classes could not be loaded and * accessed properly */ private static SSLSocketFactory createJava14SSLSocketFactory(SSLTrustManager[] tm) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { /* * The code below does the following: * TrustManagerJava14Wrapper[] tmWrappers = TrustManagerJava14Wrapper.wrap(tm); * javax.net.ssl.SSLContext context = javax.net.ssl.SSLContext.getInstance("SSL"); * context.init(null, tmWrappers, null); * SSLSocketFactory socketFactory = context.getSocketFactory(); */ Class stringClass = String.class; Class contextClass = Class.forName("javax.net.ssl.SSLContext"); Class keyManagerClass = Class.forName("javax.net.ssl.KeyManager"); Class keyManagerArrayClass = java.lang.reflect.Array.newInstance(keyManagerClass, 0).getClass(); Class trustManagerClass = Class.forName("javax.net.ssl.TrustManager"); Class trustManagerArrayClass = java.lang.reflect.Array.newInstance(trustManagerClass, 0).getClass(); Class secureRandomClass = java.security.SecureRandom.class; Method getInstanceMethod = contextClass.getMethod("getInstance", new Class[] { stringClass }); Method initMethod = contextClass.getMethod("init", new Class[] { keyManagerArrayClass, trustManagerArrayClass, secureRandomClass }); Method getSocketFactoryMethod = contextClass.getMethod("getSocketFactory", null); Class.forName("javax.net.ssl.X509TrustManager"); // check for availability TrustManagerJava14Wrapper[] tmWrappers = TrustManagerJava14Wrapper.wrap(tm); String protocol = SSLIRCConnection.protocol; Object context = getInstanceMethod.invoke(null, new Object[] { protocol }); initMethod.invoke(context, new Object[] { null, tmWrappers, null }); Object socketFactory = getSocketFactoryMethod.invoke(context, null); return (SSLSocketFactory)socketFactory; } // ------------------------------ /** * Creates a new SSLSocketFactory using the * com.sun.net.ssl.* and javax.net.ssl.* classes. * @param tm The trustmanagers. * @return A javax.net.ssl.SSLSocketFactory. * @throws ClassNotFoundException If the classes could not be loaded and * accessed properly * @throws NoSuchMethodException If the classes could not be loaded and * accessed properly * @throws InvocationTargetException If the classes could not be loaded and * accessed properly * @throws IllegalAccessException If the classes could not be loaded and * accessed properly */ private static SSLSocketFactory createJsseSSLSocketFactory(SSLTrustManager[] tm) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, InvocationTargetException, IllegalAccessException { /* * The code below does the following: * java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); * * TrustManagerJsseWrapper[] tmWrappers = TrustManagerJsseWrapper.wrap(tm); * com.sun.net.ssl.SSLContext context = com.sun.net.ssl.SSLContext.getInstance("SSL"); * context.init(null, tmWrappers, null); * SSLSocketFactory socketFactory = context.getSocketFactory(); */ Class securityClass = Class.forName("java.security.Security"); Class providerClass = Class.forName("java.security.Provider"); Class sslProviderClass = Class.forName("com.sun.net.ssl.internal.ssl.Provider"); Method addProvider = securityClass.getMethod("addProvider", new Class[] { providerClass }); Object provider = sslProviderClass.newInstance(); addProvider.invoke(null, new Object[] { provider }); Class stringClass = String.class; Class contextClass = Class.forName("com.sun.net.ssl.SSLContext"); Class keyManagerClass = Class.forName("com.sun.net.ssl.KeyManager"); Class keyManagerArrayClass = java.lang.reflect.Array.newInstance(keyManagerClass, 0).getClass(); Class trustManagerClass = Class.forName("com.sun.net.ssl.TrustManager"); Class trustManagerArrayClass = java.lang.reflect.Array.newInstance(trustManagerClass, 0).getClass(); Class secureRandomClass = java.security.SecureRandom.class; Method getInstanceMethod = contextClass.getMethod("getInstance", new Class[] { stringClass }); Method initMethod = contextClass.getMethod("init", new Class[] { keyManagerArrayClass, trustManagerArrayClass, secureRandomClass }); Method getSocketFactoryMethod = contextClass.getMethod("getSocketFactory", null); Class.forName("com.sun.net.ssl.X509TrustManager"); // check for availability TrustManagerJsseWrapper[] tmWrappers = TrustManagerJsseWrapper.wrap(tm); String protocol = SSLIRCConnection.protocol; Object context = getInstanceMethod.invoke(null, new Object[] { protocol }); initMethod.invoke(context, new Object[] { null, tmWrappers, null }); Object socketFactory = getSocketFactoryMethod.invoke(context, null); return (SSLSocketFactory)socketFactory; } } libirclib-java-1.10/src/org/schwering/irc/lib/ssl/SSLTrustManager.java000066400000000000000000000030421155103677700256540ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class SSLTrustManager * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib.ssl; import java.security.cert.X509Certificate; /** * A trust manager decides whether the server is trusted or not. * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 1.00 * @see SSLIRCConnection * @see SSLDefaultTrustManager */ public interface SSLTrustManager { /** * Checks whether the server is trusted or not.
* Given the partial or complete certificate chain provided by the peer, * build a certificate path to a trusted root and return true if it can * be validated and is trusted for server SSL authentication. * @param chain The peer certificate chain. * @return true if the server is trusted, false * if the server is not trusted. */ public boolean isTrusted(X509Certificate[] chain); // ------------------------------ /** * Return an array of certificate authority certificates which are trusted * for authenticating peers. * @return A non-null (possibly empty) array of acceptable CA issuer * certificates. */ public X509Certificate[] getAcceptedIssuers(); } libirclib-java-1.10/src/org/schwering/irc/lib/ssl/TrustManagerJava14Wrapper.java000066400000000000000000000057551155103677700276170ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class TrustManagerJava14Wrapper * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib.ssl; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; /** * Wraps a SSLTrustManager in a * javax.net.ssl.X509TrustManager. * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 1.00 * @see SSLTrustManager * @see javax.net.ssl.X509TrustManager */ class TrustManagerJava14Wrapper implements javax.net.ssl.X509TrustManager { /** * The trust manager that is wrapped. */ private SSLTrustManager trustManager; // ------------------------------ public static TrustManagerJava14Wrapper[] wrap(SSLTrustManager[] tm) { TrustManagerJava14Wrapper[] w = new TrustManagerJava14Wrapper[tm.length]; for (int i = 0; i < tm.length; i++) { w[i] = new TrustManagerJava14Wrapper(tm[i]); } return w; } // ------------------------------ /** * Creates a new trust manager wrapper. * @param trustManager The SSLTrustManager that should be * wrapped by a javax.net.ssl.X509TrustManager. */ public TrustManagerJava14Wrapper(SSLTrustManager trustManager) { if (trustManager == null) { throw new IllegalArgumentException("trustManager == null"); } this.trustManager = trustManager; } // ------------------------------ /** * Always throws a CertificateException. * @param chain The peer certificate chain. * @param authType The authentication type based on the client certificate. * @throws CertificateException Always. */ public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { throw new CertificateException("This trust manager _is_ for clients. "+ "What other client should be trusted?"); } // ------------------------------ /** * Does nothing if the server is trusted, throws a * CertificateException otherwise. This decision is made by * the trustManager. * @throws CertificateException If the server is not trusted. */ public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { if (!trustManager.isTrusted(chain)) { throw new CertificateException("The certificate chain is not "+ "trusted!"); } } // ------------------------------ /** * Returns true if the server is trusted. This decision is * made by the trustManager. * @return trustManager.isTrusted(chain). */ public X509Certificate[] getAcceptedIssuers() { return trustManager.getAcceptedIssuers(); } } libirclib-java-1.10/src/org/schwering/irc/lib/ssl/TrustManagerJsseWrapper.java000066400000000000000000000047711155103677700274720ustar00rootroot00000000000000/* * IRClib -- A Java Internet Relay Chat library -- class TrustManagerJsseWrapper * Copyright (C) 2002 - 2006 Christoph Schwering * * This library and the accompanying materials are made available under the * terms of the * - GNU Lesser General Public License, * - Apache License, Version 2.0 and * - Eclipse Public License v1.0. * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. */ package org.schwering.irc.lib.ssl; import java.security.cert.X509Certificate; /** * Wraps a SSLTrustManager in a * com.sun.net.ssl.X509TrustManager. * @author Christoph Schwering <schwering@gmail.com> * @since 1.10 * @version 1.00 * @see SSLTrustManager * @see com.sun.net.ssl.TrustManager */ class TrustManagerJsseWrapper implements com.sun.net.ssl.X509TrustManager { /** * The trust manager that is wrapped. */ private SSLTrustManager trustManager; // ------------------------------ public static TrustManagerJsseWrapper[] wrap(SSLTrustManager[] tm) { TrustManagerJsseWrapper[] w = new TrustManagerJsseWrapper[tm.length]; for (int i = 0; i < tm.length; i++) { w[i] = new TrustManagerJsseWrapper(tm[i]); } return w; } // ------------------------------ /** * Creates a new trust manager wrapper. * @param trustManager The SSLTrustManager that should be * wrapped by a com.sun.net.ssl.X509TrustManager. */ public TrustManagerJsseWrapper(SSLTrustManager trustManager) { if (trustManager == null) { throw new IllegalArgumentException("trustManager == null"); } this.trustManager = trustManager; } // ------------------------------ /** * Always returns false. * @param chain The peer certificate chain. * @return Always false. */ public boolean isClientTrusted(X509Certificate[] chain) { return false; } // ------------------------------ /** * Returns true if the server is trusted. This decision is * made by the trustManager. * @return trustManager.isTrusted(chain). */ public boolean isServerTrusted(X509Certificate[] chain) { return trustManager.isTrusted(chain); } // ------------------------------ /** * Return an array of certificate authority certificates which are trusted * for authenticating peers. * @return trustManager.getAcceptedIssuers. */ public X509Certificate[] getAcceptedIssuers() { return trustManager.getAcceptedIssuers(); } } libirclib-java-1.10/src/org/schwering/irc/lib/ssl/package.html000066400000000000000000000006751155103677700243050ustar00rootroot00000000000000 Provides support for secure IRC connections.

The {@link org.schwering.irc.lib.ssl.SSLIRCConnection} firstly tries to use the javax.net.ssl.* classes which were added in J2SE 1.4. If this fails, it tries to load the classes of the JSSE library (from the packages javax.net.ssl.* and com.sun.net.ssl.*). @since 1.10 @version 1.00 @author Christoph Schwering <schwering@gmail.com>