PircBot.h

00001 #ifndef PIRCBOT_PIRCBOT_H
00002 #define PIRCBOT_PIRCBOT_H
00003 
00004 /*
00005  * pircbotcpp, C++ port of the pircbot Java version
00006  * A IRC C++ software development kit. An Object 
00007  * Oriented client framework which lets you 
00008  * write quick and easy C++ IRC bots
00009  *
00010  * Copyright (C) 2006 Frank Hassanabad 
00011  * http://pircbotcpp.sourceforge.net/
00012  *
00013  * Java version 
00014  * Copyright Paul James Mutton, 2001-2004, http://www.jibble.org/
00015  *
00016  * This library is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU General Public
00018  * License as published by the Free Software Foundation; either
00019  * version 2.1 of the License, or (at your option) any later version.
00020  *
00021  * This library is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024  * General Public License for more details.
00025  *
00026  * You should have received a copy of the GNU General Public
00027  * License along with this library; if not, write to the Free Software
00028  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00029  */
00030 
00031 
00032 //pircbot includes
00033 //To get the PIRCBOT_EXPORT macro
00034 #include <pircbot/exports.h>
00035 #include <pircbot/ReplyConstants.h>
00036 #include <pircbot/Exceptions.h>
00037 
00038 /* Disable Windows VC 7.x warning about 
00039  * it ignoring the throw specification
00040  */
00041 #ifdef _WIN32
00042 #    pragma warning ( push )
00043 #    pragma warning( disable : 4290 )
00044 #endif
00045 
00046 namespace pircbot
00047 {
00048 namespace impl
00049 {
00050 
00061 class PircBotImpl;
00062 
00063 //Forward decleration
00064 class User;
00065 
00100 class PIRCBOT_EXPORT PircBot : public ReplyConstants
00101 {
00102     public:
00103 
00113         PircBot()
00114             throw(Exception &);
00115 
00129         virtual void connect(const char * const hostname) 
00130             throw(IOException &, IrcException &, NickAlreadyInUseException &, Exception &);
00131 
00146         virtual void connect(const char * const hostname, 
00147                              const unsigned int &port)
00148             throw(IOException &, IrcException &, NickAlreadyInUseException &, Exception &);
00149 
00166         virtual void connect(const char * const hostname, 
00167                              const unsigned int &port, 
00168                              const char * const password)
00169             throw(IOException &, IrcException &, NickAlreadyInUseException &, Exception &);
00170 
00184         virtual void reconnect()
00185             throw(IOException &, IrcException &, NickAlreadyInUseException &, Exception &);
00186 
00187 
00201         virtual void disconnect() const
00202             throw(Exception &);
00203 
00217         virtual void setAutoNickChange(bool autoNickChange) 
00218             throw(Exception &);
00219 
00251         virtual void startIdentServer() const
00252             throw(Exception &);
00253 
00263         virtual void joinChannel(const char * const channel) const
00264             throw(Exception &);
00265 
00276         virtual void joinChannel(const char * const channel, 
00277                                  const char * const key) const
00278             throw(Exception &); 
00279 
00289         virtual void partChannel(const char * const channel) const
00290             throw(Exception &);
00291 
00302         virtual void partChannel(const char * const channel, 
00303                                  const char * const reason) const
00304             throw(Exception &);
00305 
00316         virtual void quitServer() const
00317             throw(Exception &);
00318 
00331         virtual void quitServer(const char * const reason) const
00332             throw(Exception &);
00333 
00340         virtual void sendRawLine(const char * const line) const
00341             throw(Exception &);
00342 
00352         virtual void sendRawLineViaQueue(const char * const line) const
00353             throw(Exception &);
00354         
00379         virtual void sendMessage(const char * const target, 
00380                                  const char * const message) const
00381             throw(Exception &);
00382 
00395         virtual void sendAction(const char * const target, 
00396                                 const char * const action) const
00397             throw(Exception &);
00398 
00409         virtual void sendNotice(const char * const target, 
00410                                 const char * const notice) const
00411             throw(Exception &);
00412 
00428         virtual void sendCTCPCommand(const char * const target, 
00429                                      const char * const command) const
00430             throw(Exception &);
00431 
00432 
00445         virtual void changeNick(const char * const newNick) const
00446             throw(Exception &);
00447         
00467         virtual void setMode(const char * const channel, 
00468                              const char * const mode) const
00469             throw(Exception &);
00470 
00483         virtual void sendInvite(const char * const nick, 
00484                                 const char * const channel) const
00485             throw(Exception &);
00486 
00501         virtual void ban(const char * const channel, 
00502                          const char * const hostmask) const
00503             throw(Exception &);
00504 
00518         virtual void unBan(const char * const channel, 
00519                            const char * const hostmask) const 
00520             throw(Exception &);
00521 
00534         virtual void op(const char * const channel, 
00535                         const char * const nick) const
00536             throw(Exception &);
00537 
00550         virtual void deOp(const char * const channel, 
00551                           const char * const nick) const
00552             throw(Exception &);
00553         
00566         virtual void voice(const char * const channel, 
00567                            const char * const nick) const
00568             throw(Exception &);
00569 
00582         virtual void deVoice(const char * const channel, 
00583                              const char * const nick) const
00584             throw(Exception &);
00585 
00599         virtual void setTopic(const char * const channel, 
00600                               const char * const topic) const
00601             throw(Exception &);
00602 
00615         virtual void kick(const char * const channel, 
00616                           const char * const nick) const
00617             throw(Exception &);
00618 
00632         virtual void kick(const char * const channel, 
00633                           const char * const nick, 
00634                           const char * const reason) const
00635             throw(Exception &);
00636         
00649         virtual void listChannels() const 
00650             throw(Exception &);
00651 
00672         virtual void listChannels(const char * const parameters) const
00673             throw(Exception &);
00674 
00699 
00700         //public void DccFileTransfer dccSendFile(File file, string nick, int timeout);
00701         //  DccFileTransfer transfer = new DccFileTransfer(this, _dccManager, file, nick, timeout);
00702         //  transfer.doSend(true);
00703         //  return transfer;
00704         //}
00705 
00706 
00717 
00718         //protected final void dccReceiveFile(File file, long address, int port, int size) {
00719         //throw new RuntimeException("dccReceiveFile is deprecated, please use sendFile");
00720         //}
00721 
00748 
00749         //public final DccChat dccSendChatRequest(string nick, int timeout) {
00750 
00751 
00762 
00763         //protected final DccChat dccAcceptChatRequest(string sourceNick, long address, int port) {
00764         //  throw new RuntimeException("dccAcceptChatRequest is deprecated, please use onIncomingChatRequest");
00765         //}
00766 
00790         virtual void log(const char * const line) const
00791             throw(Exception &);
00792 
00809         virtual void handleLine(const char * const line)
00810             throw(Exception &);
00811 
00812     protected:
00813 
00825         virtual void onConnect()
00826             throw(Exception &);
00827 
00828     public:
00829 
00855         virtual void onDisconnect() 
00856             throw(Exception &); 
00857 
00858     protected:
00859 
00860         //Written, this is part of the pimpl in the PircBot.cpp class
00861         //void processServerResponse(const int &code, const string &response) 
00862 
00897         virtual void onServerResponse(const int &code, 
00898                                       const char * const response)
00899             throw(Exception &);
00900 
00933         virtual void onUserList(const char * const channel, 
00934                                 User* users, int usersArraySize)
00935             throw(Exception &);
00936 
00953         virtual void onMessage(const char * const channel, 
00954                                const char * const sender, 
00955                                const char * const login, 
00956                                const char * const hostname, 
00957                                const char * const message)
00958             throw(Exception &);
00959 
00975         virtual void onPrivateMessage(const char * const sender, 
00976                                       const char * const login, 
00977                                       const char * const hostname, 
00978                                       const char * const message)
00979             throw(Exception &);
00980 
00998         virtual void onAction(const char * const sender, 
00999                               const char * const login, 
01000                               const char * const hostname, 
01001                               const char * const target, 
01002                               const char * const action)
01003             throw(Exception &);
01004 
01021         virtual void onNotice(const char * const sourceNick, 
01022                               const char * const sourceLogin, 
01023                               const char * const sourceHostname, 
01024                               const char * const target, 
01025                               const char * const notice)
01026             throw(Exception &);
01027 
01044         virtual void onJoin(const char * const channel, 
01045                             const char * const sender, 
01046                             const char * const login, 
01047                             const char * const hostname)
01048             throw(Exception &);
01049 
01066         virtual void onPart(const char * const channel, 
01067                             const char * const sender, 
01068                             const char * const login, 
01069                             const char * const hostname)
01070             throw(Exception &);
01071 
01088         virtual void onNickChange(const char * const oldNick, 
01089                                   const char * const login, 
01090                                   const char * const hostname, 
01091                                   const char * const newNick)
01092             throw(Exception &);
01093 
01112         virtual void onKick(const char * const channel, 
01113                             const char * const kickerNick, 
01114                             const char * const kickerLogin, 
01115                             const char * const kickerHostname, 
01116                             const char * const recipientNick, 
01117                             const char * const reason)
01118             throw(Exception &);
01119 
01137         virtual void onQuit(const char * const sourceNick, 
01138                             const char * const sourceLogin, 
01139                             const char * const sourceHostname, 
01140                             const char * const reason)
01141             throw(Exception &);
01142 
01160         virtual void onTopic(const char * const channel, 
01161                              const char * const topic)
01162              throw(Exception &);
01163 
01182         virtual void onTopic(const char * const channel, 
01183                              const char * const topic, 
01184                              const char * const setBy, 
01185                              long date, bool changed)
01186             throw(Exception &);
01187 
01210         virtual void onChannelInfo(const char * const channel, 
01211                                    const int &userCount, 
01212                                    const char * const topic)
01213             throw(Exception &);
01214 
01215     private:
01216         //This is in the pimpl inside of PircBot.cpp
01217         //void processMode(string target, string sourceNick, 
01218         //               string sourceLogin, string sourceHostname, 
01219         //               string mode) 
01220     protected:
01221 
01243         virtual void onMode(const char * const channel, 
01244                             const char * const sourceNick, 
01245                             const char * const sourceLogin, 
01246                             const char * const sourceHostname, 
01247                             const char * const mode)
01248             throw(Exception &);
01249 
01266         virtual void onUserMode(const char * const targetNick, 
01267                                 const char * const sourceNick, 
01268                                 const char * const sourceLogin, 
01269                                 const char * const sourceHostname, 
01270                                 const char * const mode)
01271             throw(Exception &);
01272 
01292         virtual void onOp(const char * const channel, 
01293                           const char * const sourceNick, 
01294                           const char * const sourceLogin, 
01295                           const char * const sourceHostname, 
01296                           const char * const recipient)
01297             throw(Exception &);
01298 
01318         virtual void onDeop(const char * const channel, 
01319                             const char * const sourceNick, 
01320                             const char * const sourceLogin, 
01321                             const char * const sourceHostname, 
01322                             const char * const recipient)
01323             throw(Exception &);
01324 
01344         virtual void onVoice(const char * const channel, 
01345                              const char * const sourceNick, 
01346                              const char * const sourceLogin, 
01347                              const char * const sourceHostname, 
01348                              const char * const recipient)
01349             throw(Exception &);
01350 
01370         virtual void onDeVoice(const char * const channel, 
01371                                const char * const sourceNick, 
01372                                const char * const sourceLogin, 
01373                                const char * const sourceHostname, 
01374                                const char * const recipient)
01375             throw(Exception &);
01376 
01398         virtual void onSetChannelKey(const char * const channel, 
01399                                      const char * const sourceNick, 
01400                                      const char * const sourceLogin, 
01401                                      const char * const sourceHostname, 
01402                                      const char * const key)
01403             throw(Exception &);
01404 
01424         virtual void onRemoveChannelKey(const char * const channel, 
01425                                         const char * const sourceNick, 
01426                                         const char * const sourceLogin, 
01427                                         const char * const sourceHostname, 
01428                                         const char * const key)
01429             throw(Exception &);
01430 
01451         virtual void onSetChannelLimit(const char * const channel, 
01452                                        const char * const sourceNick, 
01453                                        const char * const sourceLogin, 
01454                                        const char * const sourceHostname, 
01455                                        const int &limit)
01456             throw(Exception &);
01457 
01476         virtual void onRemoveChannelLimit(const char * const channel, 
01477                                           const char * const sourceNick, 
01478                                           const char * const sourceLogin, 
01479                                           const char * const sourceHostname)
01480             throw(Exception &);
01481 
01504         virtual void onSetChannelBan(const char * const channel, 
01505                                      const char * const sourceNick, 
01506                                      const char * const sourceLogin, 
01507                                      const char * const sourceHostname, 
01508                                      const char * const hostmask)
01509             throw(Exception &);
01510 
01530         virtual void onRemoveChannelBan(const char * const channel, 
01531                                         const char * const sourceNick, 
01532                                         const char * const sourceLogin, 
01533                                         const char * const sourceHostname, 
01534                                         const char * const hostmask)
01535             throw(Exception &);
01536 
01556         virtual void onSetTopicProtection(const char * const channel, 
01557                                           const char * const sourceNick, 
01558                                           const char * const sourceLogin, 
01559                                           const char * const sourceHostname)
01560             throw(Exception &);
01561 
01580         virtual void onRemoveTopicProtection(const char * const channel, 
01581                                              const char * const sourceNick, 
01582                                              const char * const sourceLogin, 
01583                                              const char * const sourceHostname)
01584             throw(Exception &);
01585 
01605         virtual void onSetNoExternalMessages(const char * const channel, 
01606                                              const char * const sourceNick, 
01607                                              const char * const sourceLogin, 
01608                                              const char * const sourceHostname)
01609             throw(Exception &);
01610         
01630         virtual void onRemoveNoExternalMessages(const char * const channel, 
01631                                                 const char * const sourceNick, 
01632                                                 const char * const sourceLogin, 
01633                                                 const char * const sourceHostname)
01634             throw(Exception &);
01635                 
01656         virtual void onSetInviteOnly(const char * const channel, 
01657                                      const char * const sourceNick, 
01658                                      const char * const sourceLogin, 
01659                                      const char * const sourceHostname)
01660             throw(Exception &);
01661                 
01680         virtual void onRemoveInviteOnly(const char * const channel, 
01681                                         const char * const sourceNick, 
01682                                         const char * const sourceLogin, 
01683                                         const char * const sourceHostname)
01684             throw(Exception &);
01685                 
01706         virtual void onSetModerated(const char * const channel, 
01707                                     const char * const sourceNick, 
01708                                     const char * const sourceLogin, 
01709                                     const char * const sourceHostname)
01710             throw(Exception &);
01711                 
01730         virtual void onRemoveModerated(const char * const channel, 
01731                                        const char * const sourceNick, 
01732                                        const char * const sourceLogin, 
01733                                        const char * const sourceHostname)
01734             throw(Exception &);
01735                 
01754         virtual void onSetPrivate(const char * const channel, 
01755                                   const char * const sourceNick, 
01756                                   const char * const sourceLogin, 
01757                                   const char * const sourceHostname)
01758             throw(Exception &);
01759                 
01778         virtual void onRemovePrivate(const char * const channel, 
01779                                      const char * const sourceNick, 
01780                                      const char * const sourceLogin, 
01781                                      const char * const sourceHostname)
01782             throw(Exception &);
01783                 
01803         virtual void onSetSecret(const char * const channel, 
01804                                  const char * const sourceNick, 
01805                                  const char * const sourceLogin, 
01806                                  const char * const sourceHostname)
01807             throw(Exception &);     
01808         
01827         virtual void onRemoveSecret(const char * const channel, 
01828                                     const char * const sourceNick, 
01829                                     const char * const sourceLogin, 
01830                                     const char * const sourceHostname)
01831             throw(Exception &);
01832 
01849        virtual void onInvite(const char * const targetNick, 
01850                              const char * const sourceNick, 
01851                              const char * const sourceLogin, 
01852                              const char * const sourceHostname, 
01853                              const char * const channel)
01854             throw(Exception &);
01855 
01867 
01868         //protected void onDccSendRequest(string sourceNick, string sourceLogin, string sourceHostname, string filename, long address, int port, int size) {}
01869         
01870         
01882 
01883         //protected void onDccChatRequest(string sourceNick, string sourceLogin, string sourceHostname, long address, int port) {}
01884         
01885         
01931 
01932         //protected void onIncomingFileTransfer(DccFileTransfer transfer) {}
01933         
01934         
01955 
01956         //protected void onFileTransferFinished(DccFileTransfer transfer, Exception e) {
01957         
01958         
02003 
02004         //protected void onIncomingChatRequest(DccChat chat) {}
02005 
02021         virtual void onVersion(const char * const sourceNick, 
02022                                const char * const sourceLogin, 
02023                                const char * const sourceHostname, 
02024                                const char * const target)
02025             throw(Exception &);
02026 
02045         virtual void onPing(const char * const sourceNick, 
02046                             const char * const sourceLogin, 
02047                             const char * const sourceHostname, 
02048                             const char * const target, 
02049                             const char * const pingValue)
02050             throw(Exception &);
02051 
02065         virtual void onServerPing(const char * const response)
02066             throw(Exception &);
02067 
02084         virtual void onTime(const char * const sourceNick, 
02085                             const char * const sourceLogin, 
02086                             const char * const sourceHostname, 
02087                             const char * const target)
02088             throw(Exception &);
02089 
02106         virtual void onFinger(const char * const sourceNick, 
02107                               const char * const sourceLogin, 
02108                               const char * const sourceHostname, 
02109                               const char * const target)
02110             throw(Exception &);
02111 
02125         virtual void onUnknown(const char * const line)
02126             throw(Exception &);
02127         
02128     public:
02129 
02142         virtual void setVerbose(const bool &verbose)
02143             throw(Exception &);
02144 
02145     protected:
02146 
02163         virtual void setName(const char * const name)
02164             throw(Exception &);
02165         
02166     private:
02167 
02168         //This is written in PircBot.cpp in the pimpl
02169         //void setNick(string nick) 
02170 
02171     protected:
02182         virtual void setLogin(const char * const login)
02183             throw(Exception &);
02184 
02195         virtual void setVersion(const char * const version)
02196             throw(Exception &);
02197 
02208         virtual void setFinger(const char * const finger) 
02209             throw(Exception &);
02210 
02211     public:
02212 
02223         virtual const char *getName() const
02224             throw(Exception &); 
02225 
02240         virtual const char *getNick()
02241             throw(Exception &);
02242 
02252         virtual const char *getLogin() const
02253             throw(Exception &);
02254 
02264         virtual const char *getVersion() const
02265             throw(Exception &);
02266 
02276         virtual const char *getFinger() const 
02277             throw(Exception &);
02278 
02290         virtual bool isConnected() const
02291             throw(Exception &);
02292 
02308         virtual void setMessageDelay(const unsigned int &delay)
02309             throw(Exception &);
02310         
02321         virtual unsigned int getMessageDelay() const
02322             throw(Exception &);
02323 
02337         virtual unsigned int getMaxLineLength() const
02338             throw(Exception &);
02339 
02351         virtual unsigned int getOutgoingQueueSize() const
02352             throw(Exception &);
02353 
02368         const char *getServer() const
02369             throw(Exception &);
02370 
02386         unsigned int getPort() const
02387             throw(Exception &);
02388 
02403         const char *getPassword() const
02404             throw(Exception &);
02405 
02406         //This method will never be written
02407         //public int[] longToIp(long address)
02408         
02409         //This method will never be written
02410         //public long ipToLong(byte[] address)
02411 
02412         //This method will never be written
02413         //public void setEncoding(string charset) throws UnsupportedEncodingException 
02414         
02415         //This method will never be written
02416         //public string getEncoding() {
02417             
02418         //This method will never be written
02419         //public InetAddress getInetAddress() {
02420 
02433 
02434         /*
02435         public void setDccInetAddress(InetAddress dccInetAddress) {
02436             _dccInetAddress = dccInetAddress;
02437         }
02438         */
02439     
02450 
02451     /*
02452         public InetAddress getDccInetAddress() {
02453             return _dccInetAddress;
02454         }
02455     */
02456     
02472 
02473         /*
02474         public int[] getDccPorts() {
02475             if (_dccPorts == null || _dccPorts.length == 0) {
02476                 return null;
02477             }
02478             // Clone the array to prevent external modification.
02479             return (int[]) _dccPorts.clone();
02480         }
02481         */
02482     
02499 
02500         /*
02501         public void setDccPorts(int[] ports) {
02502             if (ports == null || ports.length == 0) {
02503                 _dccPorts = null;
02504             }
02505             else {
02506                 // Clone the array to prevent external modification.
02507                 _dccPorts = (int[]) ports.clone();
02508             }
02509         }    
02510         */
02511         
02512         //This method will never be written.
02513         //public boolean equals(Object o)
02514         
02515         //This method will never be written.
02516         //public int hashCode()
02517 
02518         //This method will never be written.
02519         //public string toString()
02520 
02559         virtual User* getUsers(const char * const channel, 
02560                                unsigned int &arraySize) const
02561             throw(Exception &);
02562 
02583         virtual const char** getChannels(int &sizeOfArray) const
02584             throw(Exception &);
02585 
02605         virtual void dispose()
02606             throw(Exception &);
02607         
02608     private:
02609         //This is written in pircbot.cpp file in the pimpl
02610         //void addUser(string channel, const User &user)
02611         //User removeUser(string channel, string nick) 
02612         //void removeUser(string nick) 
02613         //void renameUser(string oldNick, string newNick) 
02614         //void removeChannel(string channel) 
02615         //void removeAllChannels() 
02616         //void updateUser(string channel, int userMode, string nick) 
02617 
02618     public:
02619 
02639         virtual void join() const
02640             throw(Exception &);
02641         
02642 
02659         static void releaseMemoryOfUserArray(User *userArray)
02660             throw(Exception &);
02661         
02680         static void releaseMemoryOfCharArray(const char **array, const unsigned int size)
02681             throw(Exception &);
02682 
02705         void operator delete(void* p);
02706 
02731         void *operator new(unsigned int size);
02732         
02740         virtual ~PircBot();
02741 
02742     private: 
02743 
02750         PircBot &operator=(const PircBot &pircbot);
02751 
02758         PircBot(const PircBot &pircbot);
02759 
02770         PircBotImpl *m_pimpl;
02771         friend class PircBotImpl;
02772 };
02773 
02774 
02775 } //end of impl namespace
02776 
02777 //expose PircBot to the pircbot namespace
02778 using pircbot::impl::PircBot;
02779 
02780 } //end of pircbot namespace 
02781 
02782 #ifdef _WIN32
02783 #    pragma warning( disable : 4290 )
02784 #endif
02785 
02786 #endif
02787 

Generated on Sun Sep 3 16:43:20 2006 for pircbotcpp by  doxygen 1.4.5