src/Core/Socket/UBSocket.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008 by Sverre Rabbelier                                *
00003  *   sverre@rabbelier.nl                                                   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 3 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #pragma once
00021 
00029 #include "SavableHeaders.h"
00030 #include "SavableTypes.h"
00031 
00032 #include <list>
00033 
00034 #include <TcpSocket.h>
00035 #include <ISocketHandler.h>
00036 
00037 class Editor;
00038 typedef std::list<Editor*> EditorList; 
00046 class UBSocket : public TcpSocket
00047 {
00048 public:
00050         UBSocket(ISocketHandler& h);
00051         
00053         ~UBSocket(void);
00054 
00055 
00057         void OnAccept();
00058 
00060         void OnLine(const std::string& line);
00061         
00062         
00064         void Send(const std::string& msg);
00065         
00067         void Sendf(const char* format, ...);
00068 
00069         
00071         bool hasAccount() const;
00072         
00074         mud::AccountPtr GetAccount() const;
00075         
00077         bool hasForcer() const;
00078         
00080         UBSocket* GetForcer() const;
00081         
00083         bool isHighForced() const { return m_highforced; }
00084         
00086         bool isForced() const { return m_forced; }
00087         
00089         bool isLowForced() const { return m_lowforced; }
00090                 
00092         bool canReceiveChannel(mud::ChannelPtr channel);
00093         
00094         
00096         void SetAccount(mud::AccountPtr account) { m_account = account; }
00097         
00108         void SetEditor(Editor* editor, bool popLast = false);
00109         
00111         void PopEditor();
00112         
00126         void SetForcer(UBSocket* forcer, bool weakForced = true, bool forced = false, bool highForced = false);
00127         
00129         void EndForce();
00130 
00142         void SwitchEditors();
00143         
00150         static UBSocket* Cast(Socket* sock, bool error = true);
00151 
00152 private:
00154         UBSocket(const UBSocket& rhs);
00155         
00157         UBSocket operator=(const UBSocket& rhs);
00158         
00159         void SetPrompt(const std::string& prompt = "");
00160         void SendPrompt();
00161         bool handlePrefixes(const std::string& line);
00162         
00163         std::string m_prompt;           
00164         mud::AccountPtr m_account;      
00165         bool m_popeditor;                       
00166         bool m_popLast;                         
00167         EditorList m_editors;           
00168         Editor* m_nexteditor;           
00169         UBSocket* m_forcer;             
00170         bool m_lowforced;                       
00171         bool m_forced;                          
00172         bool m_highforced;                      
00173         bool m_hascolor;                        
00174         char m_colorcode;                       
00175 };

Generated for UnsignedByte by  doxygen 1.5.3
SourceForge.net Logo