Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

SNAC-base.h

00001 /*
00002  * SNAC - base classes
00003  *
00004  * Copyright (C) 2001 Barnaby Gray <barnaby@beedesign.co.uk>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef SNAC_BASE_H
00023 #define SNAC_BASE_H
00024 
00025 class Buffer;
00026 
00027 namespace ICQ2000 {
00028  
00029   // ------------- SNAC numerical constants ------------
00030 
00031   // SNAC Families
00032   const unsigned short SNAC_FAM_GEN = 0x0001;
00033   const unsigned short SNAC_FAM_LOC = 0x0002;
00034   const unsigned short SNAC_FAM_BUD = 0x0003;
00035   const unsigned short SNAC_FAM_MSG = 0x0004;
00036   const unsigned short SNAC_FAM_ADS = 0x0005;
00037   const unsigned short SNAC_FAM_INV = 0x0006;
00038   const unsigned short SNAC_FAM_ADM = 0x0007;
00039   const unsigned short SNAC_FAM_POP = 0x0008;
00040   const unsigned short SNAC_FAM_BOS = 0x0009;
00041   const unsigned short SNAC_FAM_LUP = 0x000a;
00042   const unsigned short SNAC_FAM_STS = 0x000b;
00043   const unsigned short SNAC_FAM_TRT = 0x000c;
00044   const unsigned short SNAC_FAM_CNV = 0x000d;
00045   const unsigned short SNAC_FAM_CHT = 0x000e;
00046 
00047   const unsigned short SNAC_FAM_SBL = 0x0013; // Server-based lists
00048 
00049   const unsigned short SNAC_FAM_SRV = 0x0015; // Server messages
00050   const unsigned short SNAC_FAM_UIN = 0x0017; // UIN registration
00051 
00052   // ------------- abstract SNAC classes ---------------
00053 
00054   class SNAC {
00055    protected:
00056     unsigned short m_flags;
00057     unsigned int m_requestID;
00058     
00059    public:
00060     SNAC();
00061     virtual ~SNAC() { }
00062     
00063     virtual unsigned short Family() const = 0;
00064     virtual unsigned short Subtype() const = 0;
00065 
00066     virtual unsigned short Flags() const;
00067     virtual unsigned int RequestID() const;
00068     void setRequestID(unsigned int id);
00069     void setFlags(unsigned short fl);
00070   };
00071 
00072   // -- Inbound SNAC --
00073   class InSNAC : virtual public SNAC {
00074    protected:
00075     virtual void ParseBody(Buffer& b) = 0;
00076 
00077    public:
00078     virtual void Parse(Buffer& b);
00079   };
00080 
00081   // -- Outbound SNAC --
00082   class OutSNAC : virtual public SNAC {
00083    protected:
00084     virtual void OutputHeader(Buffer& b) const;
00085     virtual void OutputBody(Buffer& b) const = 0;
00086 
00087    public:
00088     virtual void Output(Buffer& b) const;
00089   };
00090 
00091   // ------------ Raw SNAC ----------------------------------
00092   
00093   class RawSNAC : public InSNAC {
00094    protected:
00095     unsigned short m_family, m_subtype;
00096 
00097     void ParseBody(Buffer& b);
00098     
00099    public:
00100     RawSNAC(unsigned short f, unsigned short t);
00101 
00102     unsigned short Family() const { return m_family; }
00103     unsigned short Subtype() const { return m_subtype; }
00104   };
00105 
00106 }
00107 
00108 Buffer& operator<<(Buffer& b, const ICQ2000::OutSNAC& t);
00109 
00110 #endif

Generated on Tue Jan 15 12:24:35 2002 for libicq2000 by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001