ircproxy The Ultimate Cyborg |
#include <Nick.h>
Definition at line 155 of file Nick.h.
Public Member Functions | |
Nick (ServerSession const &server_session, std::string const &target_name) | |
Construct a Nick object for server session server_session and target name target_name. | |
Nick (ClientSession const &client_session, std::string const &target_name, Network &private_network) | |
Construct a private Nick for client session client_session, nick name target_name and private network private_network. | |
~Nick () | |
Destructor (for debugging purpose: prints the destruction event). | |
bool | is_initialized (mask_type mask) const |
Returns true if the non-channel related info for this nick as specified by mask is known. | |
bool | is_synced (mask_type mask) const |
Returns true if the non-channel related info for this nick as specified by mask is up to date. | |
mask_type | initialized (mask_type mask) const |
Return the exact bits for mask that are initialized. | |
mask_type | synced (mask_type mask) const |
Return the exact bits for mask that are up to date. | |
NickData const & | data (void) const |
Const data accessor. | |
NickData & | data (void) |
Non-const data accessor. | |
void | serverside_nick_changed_to (ServerSession const &server_session, std::string const &new_nick) |
Called when a NICK message was received from the server. | |
void | clientside_nick_changed_to (ClientSession const &client_session, std::string const &new_nick) |
Called when a NICK message is send to the client. | |
void | add_channel (boost::shared_ptr< Channel > const &channel) |
Add a channel to the common channels map. | |
void | sub_channel (Channel const &channel) |
Remove a channel from the common channels map. | |
virtual bool | is_me (void) const |
Return true if this is my nick. | |
void | set_network (Network *network) |
Update the network pointer from the temporary private network to the final real network. | |
virtual void | new_client_message_received (ClientMessageIn const &msg) |
This is called when a new message targetted at this target is received. | |
virtual void | new_server_message_received (ServerMessageIn const &msg) |
This is called when a new message targetted at this target is received. | |
Protected Member Functions | |
Nick (Identity &identity) | |
Construct my own nick. | |
Private Member Functions | |
Nick (Nick const &nick) | |
Copyconstructor (for debugging purpose: prints the copy event). | |
Private Attributes | |
NickData | M_data |
All non-channel related info about a nick name (WHO output). | |
int | M_common_channels |
The number of channels that this nick is on that we are on as well. | |
Array< std::string > | M_clientside_name |
The (input) nick name as function of the client session. | |
Array< std::string > | M_serverside_name |
The (input) nick name as function of the server session. |
Nick::Nick | ( | Identity & | identity | ) | [protected] |
Construct my own nick.
Definition at line 26 of file Nick.cc.
References debug::channels::dc::objects.
00026 : Target(&identity.private_network()), M_common_channels(0) 00027 { 00028 Dout(dc::objects, "Constructing my own Nick(" << identity << "\")"); 00029 }
Nick::Nick | ( | ServerSession const & | server_session, | |
std::string const & | target_name | |||
) |
Construct a Nick object for server session server_session and target name target_name.
Definition at line 39 of file Nick.cc.
References M_serverside_name, and debug::channels::dc::objects.
00039 : 00040 Target(&server_session.server_connection().network()), M_common_channels(0) 00041 { 00042 M_serverside_name[server_session] = target_name; 00043 Dout(dc::objects, "Constructing Nick(" << server_session << ", \"" << target_name << "\")"); 00044 }
Nick::Nick | ( | ClientSession const & | client_session, | |
std::string const & | target_name, | |||
Network & | private_network | |||
) |
Construct a private Nick for client session client_session, nick name target_name and private network private_network.
Definition at line 31 of file Nick.cc.
References ASSERT, Network::is_private(), M_clientside_name, and debug::channels::dc::objects.
00031 : 00032 Target(&private_network), M_common_channels(0) 00033 { 00034 ASSERT(private_network.is_private()); 00035 M_clientside_name[client_session] = target_name; 00036 Dout(dc::objects, "Constructing Nick(" << client_session << ", \"" << target_name << "\", " << private_network << ")"); 00037 }
Nick::~Nick | ( | ) | [inline] |
Destructor (for debugging purpose: prints the destruction event).
Definition at line 175 of file Nick.h.
00175 { Dout(dc::objects, "Destructing Nick " << *this); }
Nick::Nick | ( | Nick const & | nick | ) | [inline, private] |
Copyconstructor (for debugging purpose: prints the copy event).
Definition at line 178 of file Nick.h.
00178 : Target(nick), 00179 M_data(nick.M_data), M_common_channels(nick.M_common_channels) 00180 { DoutFatal(dc::core, "Copy-constructing Nick from " << nick); }
bool Nick::is_initialized | ( | mask_type | mask | ) | const [inline] |
Returns true if the non-channel related info for this nick as specified by mask is known.
Definition at line 185 of file Nick.h.
References NickData::initialized(), and M_data.
00185 { return (M_data.initialized() & mask) == mask; }
bool Nick::is_synced | ( | mask_type | mask | ) | const [inline] |
Returns true if the non-channel related info for this nick as specified by mask is up to date.
Definition at line 187 of file Nick.h.
References NickData::initialized(), M_common_channels, and M_data.
00187 { return M_common_channels > 0 && (M_data.initialized() & mask) == mask; }
Return the exact bits for mask that are initialized.
Definition at line 189 of file Nick.h.
References NickData::initialized(), and M_data.
00189 { return M_data.initialized() & mask; }
Return the exact bits for mask that are up to date.
Definition at line 191 of file Nick.h.
References NickData::initialized(), M_common_channels, and M_data.
00191 { return M_common_channels > 0 ? M_data.initialized() & mask : 0; }
NickData const& Nick::data | ( | void | ) | const [inline] |
Const data accessor.
Definition at line 194 of file Nick.h.
References M_data.
Referenced by operator<<(), and serverside_nick_changed_to().
00194 { return M_data; }
NickData& Nick::data | ( | void | ) | [inline] |
void Nick::serverside_nick_changed_to | ( | ServerSession const & | server_session, | |
std::string const & | new_nick | |||
) |
Called when a NICK message was received from the server.
Definition at line 46 of file Nick.cc.
References ASSERT, NickData::common_channels(), data(), DoutEntering, Network::is_private(), Target::M_network, M_serverside_name, debug::channels::dc::maps, and Network::targets().
00047 { 00048 ASSERT(!debug::secondary_connection); 00049 DoutEntering(dc::debug, "Nick::serverside_nick_changed_to(\"" << new_nick << "\")"); 00050 if (!M_network->is_private()) 00051 { 00052 target_lookup_map_type::iterator iter = M_network->targets().find(in_name(server_session)); 00053 ASSERT(iter != M_network->targets().end()); 00054 boost::weak_ptr<Target> this_target(iter->second); 00055 Dout(dc::maps, "Erasing " << in_name(server_session) << " from Network map."); 00056 M_network->targets().erase(iter); 00057 for (NickData::common_channels_type::iterator iter1 = data().common_channels().begin(); iter1 != data().common_channels().end(); ++iter1) 00058 { 00059 boost::shared_ptr<Channel> channel(iter1->second); 00060 Channel::members_type::iterator iter2 = channel->members().find(in_name(server_session)); 00061 ASSERT(iter2 != channel->members().end()); 00062 Dout(dc::maps, "Erasing " << in_name(server_session) << " from members of " << *channel); 00063 Member member(iter2->second); 00064 channel->members().erase(iter2); 00065 Dout(dc::maps, "Inserting " << new_nick << " in members of " << *channel); 00066 channel->members().insert(Channel::members_type::value_type(new_nick, member)); 00067 } 00068 Dout(dc::maps, "Inserting " << new_nick << " in Network map."); 00069 #if defined(CWDEBUG) || defined(DEBUG) 00070 std::pair<target_lookup_map_type::iterator, bool> res = 00071 #endif 00072 M_network->targets().insert(target_lookup_map_type::value_type(new_nick, this_target)); 00073 ASSERT(res.second); 00074 } 00075 M_serverside_name[server_session] = new_nick; 00076 }
void Nick::clientside_nick_changed_to | ( | ClientSession const & | client_session, | |
std::string const & | new_nick | |||
) |
Called when a NICK message is send to the client.
Definition at line 78 of file Nick.cc.
References DoutEntering, and M_clientside_name.
00079 { 00080 DoutEntering(dc::debug, "Nick::clientside_nick_changed_to(\"" << new_nick << "\")"); 00081 M_clientside_name[client_session] = new_nick; 00082 }
void Nick::add_channel | ( | boost::shared_ptr< Channel > const & | channel | ) |
Add a channel to the common channels map.
Definition at line 94 of file Nick.cc.
References ASSERT, NickData::common_channels(), M_data, and debug::channels::dc::maps.
00095 { 00096 #if 0 00097 Dout(dc::maps, "Inserting " << channel->in_name(...) << " in common_channels of " << *this); 00098 #if defined(CWDEBUG) || defined(DEBUG) 00099 std::pair<NickData::common_channels_type::iterator, bool> res = 00100 #endif 00101 M_data.common_channels().insert(NickData::common_channels_type::value_type(channel->serverside_name(), channel)); 00102 ASSERT(res.second); 00103 #endif 00104 }
void Nick::sub_channel | ( | Channel const & | channel | ) |
Remove a channel from the common channels map.
Definition at line 106 of file Nick.cc.
References ASSERT, NickData::common_channels(), M_data, and debug::channels::dc::maps.
00107 { 00108 #if 0 00109 NickData::common_channels_type::iterator iter = M_data.common_channels().find(channel.serverside_name()); 00110 ASSERT(iter != M_data.common_channels().end()); 00111 Dout(dc::maps, "Erasing " << channel.serverside_name() << " from common_channels of " << *this); 00112 M_data.common_channels().erase(iter); 00113 #endif 00114 }
virtual bool Nick::is_me | ( | void | ) | const [inline, virtual] |
void Nick::set_network | ( | Network * | network | ) | [inline] |
Update the network pointer from the temporary private network to the final real network.
Definition at line 216 of file Nick.h.
References ASSERT, Network::is_private(), and Target::M_network.
00216 { ASSERT(!network->is_private() && (M_network->is_private() || M_network == network)); M_network = network; }
void Nick::new_client_message_received | ( | ClientMessageIn const & | ) | [virtual] |
This is called when a new message targetted at this target is received.
Implements Target.
Definition at line 84 of file Nick.cc.
References ClientMessageIn::client_session(), and DoutEntering.
00085 { 00086 DoutEntering(dc::debug, "Nick::new_client_message_received(" << msg << ") for target \"" << in_name(msg.client_session()) << "\"."); 00087 }
void Nick::new_server_message_received | ( | ServerMessageIn const & | ) | [virtual] |
This is called when a new message targetted at this target is received.
Implements Target.
Definition at line 89 of file Nick.cc.
References DoutEntering, and ServerMessageIn::server_session().
00090 { 00091 DoutEntering(dc::debug, "Nick::new_server_message_received(" << msg << ") for target \"" << in_name(msg.server_session()) << "\"."); 00092 }
NickData Nick::M_data [private] |
All non-channel related info about a nick name (WHO output).
Definition at line 157 of file Nick.h.
Referenced by add_channel(), data(), initialized(), is_initialized(), is_synced(), sub_channel(), and synced().
int Nick::M_common_channels [private] |
The number of channels that this nick is on that we are on as well.
Definition at line 158 of file Nick.h.
Referenced by is_synced(), and synced().
Array<std::string> Nick::M_clientside_name [private] |
The (input) nick name as function of the client session.
Definition at line 159 of file Nick.h.
Referenced by clientside_nick_changed_to(), and Nick().
Array<std::string> Nick::M_serverside_name [private] |
The (input) nick name as function of the server session.
Definition at line 160 of file Nick.h.
Referenced by Nick(), and serverside_nick_changed_to().
Copyright © 2005-2007 Carlo Wood. All rights reserved. |
---|