/* kircentity.h - IRC Client Copyright (c) 2004 by Michel Hermier Kopete (c) 2004 by the Kopete developers ************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ************************************************************************* */ #ifndef KIRCENTITY_H #define KIRCENTITY_H #include #include #include #include #include #include #include namespace KIRC { class Engine; class Entity : public TQObject, public TDEShared { Q_OBJECT public: enum Type { Unknown, Server, Channel, Service, User }; Entity(const TQString &name, const Type type = Unknown); virtual ~Entity(); TQString name() const; TQString host() const; KIRC::Entity::Type type() const; KIRC::Entity::Type guessType(); static KIRC::Entity::Type guessType(const TQString &name); // FIXME: Remove these is* functions ... They are duplicate with the ::guessType(const TQString&) inline static bool isUser( const TQString &s ) { return sm_userRegExp.exactMatch(s); }; inline bool isChannel() { return isChannel(m_name); }; inline static bool isChannel( const TQString &s ) { return sm_channelRegExp.exactMatch(s); }; TQString userNick() const; static TQString userNick(const TQString &s); TQString userName() const; static TQString userName(const TQString &s); TQString userHost() const; static TQString userHost(const TQString &s); signals: void destroyed(KIRC::Entity *self); private: static TQString userInfo(const TQString &s, int num_cap); static const TQRegExp sm_userRegExp; static const TQRegExp sm_userStrictRegExp; static const TQRegExp sm_channelRegExp; KIRC::Entity::Type m_type; TQString m_name; // peer ip address if the entity is a User. TQString m_address; }; class EntityPtr : public TDESharedPtr { public: EntityPtr(KIRC::Entity *entity = 0) : TDESharedPtr(entity) { } EntityPtr(const KIRC::EntityPtr &entity) : TDESharedPtr(entity) { } }; class EntityPtrList : public TQValueList { public: EntityPtrList() { } EntityPtrList(const EntityPtr &entity) { append(entity); } EntityPtrList(const TQValueList &list) : TQValueList(list) { } }; } #endif