xmpp_muc.h

Go to the documentation of this file.
00001 /*
00002  * xmpp_muc.h
00003  *
00004  * Extensible Messaging and Presence Protocol (XMPP)
00005  * JEP-0045 Multi-User Chat
00006  *
00007  * Portable Windows Library
00008  *
00009  * Copyright (c) 2004 Reitek S.p.A.
00010  *
00011  * The contents of this file are subject to the Mozilla Public License
00012  * Version 1.0 (the "License"); you may not use this file except in
00013  * compliance with the License. You may obtain a copy of the License at
00014  * http://www.mozilla.org/MPL/
00015  *
00016  * Software distributed under the License is distributed on an "AS IS"
00017  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00018  * the License for the specific language governing rights and limitations
00019  * under the License.
00020  *
00021  * The Original Code is Portable Windows Library.
00022  *
00023  * The Initial Developer of the Original Code is Post Increment
00024  *
00025  * Contributor(s): ______________________________________.
00026  *
00027  * $Revision: 20385 $
00028  * $Author: rjongbloed $
00029  * $Date: 2008-06-04 10:40:38 +0000 (Wed, 04 Jun 2008) $
00030  */
00031 
00032 #ifndef _XMPP_MUC
00033 #define _XMPP_MUC
00034 
00035 #ifdef P_USE_PRAGMA
00036 #pragma interface
00037 #endif
00038 
00039 #include <ptclib/xmpp_c2s.h>
00040 
00041 #if P_EXPAT
00042 
00044 
00045 namespace XMPP
00046 {
00047   namespace MUC
00048   {
00049     extern const PString & NamespaceTag();
00050 
00051     class User : public PObject
00052     {
00053       PCLASSINFO(User, PObject);
00054     public:
00055       User();
00056       ~User();
00057 
00058       static const PString & NamespaceTag();
00059 
00060       enum Role {
00061         None,
00062         Moderator,
00063         Participant,
00064         Visitor,
00065         Unknown = 999
00066       };
00067 
00068       enum Affiliation {
00069         None_a,
00070         Owner,
00071         Admin,
00072         Member,
00073         Outcast,
00074         Unknown_a = 999
00075       };
00076 
00077       PString       m_Nick;
00078       Role          m_Role;
00079       Affiliation   m_Affiliation;
00080 
00081       Comparison Compare(const PObject & obj) const;
00082     };
00083     PSORTED_LIST(Users, User);
00084 
00085     class Room : public PObject
00086     {
00087       PCLASSINFO(Room, PObject);
00088       PDECLARE_SMART_NOTIFIEE;
00089     public:
00090       Room(C2S::StreamHandler * handler,  
00091            const JID& jid,                
00092            const PString& nick);          
00093 
00094       const User&   GetUser() const         { return m_User; }
00095       const Users&  GetOtherUsers() const   { return m_OtherUsers; }
00096 
00097       virtual PBoolean  Enter();
00098       virtual PBoolean  Leave();
00099       virtual PBoolean  SendMessage(const PString& msg);
00100       virtual PBoolean  SendMessage(Message& msg);
00101 
00102       // Event methods
00103       virtual void  OnMessage(Message& msg);
00104       virtual void  OnRoomJoined();
00105       virtual void  OnRoomLeft();
00106       virtual void  OnUserAdded(User& user);
00107       virtual void  OnUserRemoved(User& user);
00108       virtual void  OnUserChanged(User& user);
00109 
00110     protected:
00111       PDECLARE_SMART_NOTIFIER(C2S::StreamHandler, Room, OnSessionReleased);
00112       PDECLARE_SMART_NOTIFIER(Message, Room, OnMessage);
00113       PDECLARE_SMART_NOTIFIER(Presence, Room, OnPresence);
00114 
00115       C2S::StreamHandler *  m_Handler;
00116       BareJID               m_RoomJID;
00117       User                  m_User;
00118       Users                 m_OtherUsers;
00119 
00120       PNotifierList         m_MessageHandlers;
00121       PNotifierList         m_RoomJoinedHandlers;
00122       PNotifierList         m_RoomLeftHandlers;
00123       PNotifierList         m_UserAddedHandlers;
00124       PNotifierList         m_UserRemovedHandlers;
00125       PNotifierList         m_UserChangedHandlers;
00126     };
00127 
00128   }  // namespace MUC
00129 } // namespace XMPP
00130 
00131 
00132 #endif  // P_EXPAT
00133 
00134 #endif  // _XMPP_MUC
00135 
00136 // End of File ///////////////////////////////////////////////////////////////
00137 
00138 
00139 

Generated on Mon Feb 23 01:57:55 2009 for PTLib by  doxygen 1.5.1