#include <channels.h>
Inheritance diagram for chanrec:
Public Member Functions | |
void | SetCustomMode (char mode, bool mode_on) |
Sets or unsets a custom mode in the channels info. | |
void | SetCustomModeParam (char mode, char *parameter, bool mode_on) |
Sets or unsets the parameters for a custom mode in a channels info. | |
bool | IsCustomModeSet (char mode) |
Returns true if a custom mode is set on a channel. | |
std::string | GetModeParameter (char mode) |
Returns the parameter for a custom mode on a channel. | |
long | GetUserCounter () |
Obtain the channel "user counter" This returns the channel reference counter, which is initialized to 0 when the channel is created and incremented/decremented upon joins, parts quits and kicks. | |
void | AddUser (char *castuser) |
Add a user pointer to the internal reference list. | |
void | DelUser (char *castuser) |
Delete a user pointer to the internal reference list. | |
std::vector< char * > * | GetUsers () |
Obrain the internal reference list The internal reference list contains a list of userrec* cast to char*. | |
chanrec () | |
Creates a channel record and initialises it with default values. | |
virtual | ~chanrec () |
Public Attributes | |
char | name [CHANMAX] |
The channels name. | |
char | custom_modes [MAXMODES] |
Custom modes for the channel. | |
std::vector< char * > | internal_userlist |
User list (casted to char*'s to stop forward declaration stuff) (chicken and egg scenario!). | |
char | topic [MAXBUF] |
Channel topic. | |
time_t | created |
Creation time. | |
time_t | topicset |
Time topic was set. | |
char | setby [NICKMAX] |
The last user to set the topic. | |
short int | limit |
Contains the channel user limit. | |
char | key [32] |
Contains the channel key. | |
char | binarymodes |
Contains a bitmask of the CM_* builtin (RFC) binary mode symbols. | |
BanList | bans |
The list of all bans set on the channel. |
This class represents a channel, and contains its name, modes, time created, topic, topic set time, etc, and an instance of the BanList type.
Definition at line 101 of file channels.h.
|
Creates a channel record and initialises it with default values.
Definition at line 107 of file channels.cpp. References binarymodes, created, custom_modes, internal_userlist, key, limit, name, setby, topic, and topicset.
00108 { 00109 strcpy(name,""); 00110 strcpy(custom_modes,""); 00111 strcpy(topic,""); 00112 strcpy(setby,""); 00113 strcpy(key,""); 00114 created = topicset = limit = 0; 00115 binarymodes = 0; 00116 internal_userlist.clear(); 00117 } |
|
Definition at line 224 of file channels.h.
00224 { /* stub */ }
|
|
Add a user pointer to the internal reference list.
Definition at line 201 of file channels.cpp. References DEBUG, and internal_userlist.
00202 { 00203 internal_userlist.push_back(castuser); 00204 log(DEBUG,"Added casted user to channel's internal list"); 00205 } |
|
Delete a user pointer to the internal reference list.
Definition at line 207 of file channels.cpp. References DEBUG, internal_userlist, and name.
00208 { 00209 for (std::vector<char*>::iterator a = internal_userlist.begin(); a < internal_userlist.end(); a++) 00210 { 00211 if (*a == castuser) 00212 { 00213 log(DEBUG,"Removed casted user from channel's internal list"); 00214 internal_userlist.erase(a); 00215 return; 00216 } 00217 } 00218 log(DEBUG,"BUG BUG BUG! Attempt to remove an uncasted user from the internal list of %s!",name); 00219 } |
|
Returns the parameter for a custom mode on a channel.
Definition at line 181 of file channels.cpp. References custom_mode_params.
00182 { 00183 if (custom_mode_params.size()) 00184 { 00185 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++) 00186 { 00187 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel))) 00188 { 00189 return i->parameter; 00190 } 00191 } 00192 } 00193 return ""; 00194 } |
|
Obtain the channel "user counter" This returns the channel reference counter, which is initialized to 0 when the channel is created and incremented/decremented upon joins, parts quits and kicks.
Definition at line 196 of file channels.cpp. References internal_userlist.
00197 { 00198 return (this->internal_userlist.size()); 00199 } |
|
Obrain the internal reference list The internal reference list contains a list of userrec* cast to char*. These are used for rapid comparison to determine channel membership for PRIVMSG, NOTICE, QUIT, PART etc. The resulting pointer to the vector should be considered readonly and only modified via AddUser and DelUser.
Definition at line 221 of file channels.cpp. References internal_userlist. Referenced by Server::GetUsers().
00222 { 00223 return &internal_userlist; 00224 } |
|
Returns true if a custom mode is set on a channel.
Definition at line 175 of file channels.cpp. References DEBUG.
00176 { 00177 log(DEBUG,"Checking ISCustomModeSet: %c %s",mode,this->custom_modes); 00178 return (strchr(this->custom_modes,mode) != 0); 00179 } |
|
Sets or unsets a custom mode in the channels info.
Definition at line 119 of file channels.cpp. References custom_modes, DEBUG, and SetCustomModeParam().
00120 { 00121 if (mode_on) { 00122 static char m[3]; 00123 m[0] = mode; 00124 m[1] = '\0'; 00125 if (!strchr(this->custom_modes,mode)) 00126 { 00127 strlcat(custom_modes,m,MAXMODES); 00128 } 00129 log(DEBUG,"Custom mode %c set",mode); 00130 } 00131 else { 00132 00133 std::string a = this->custom_modes; 00134 int pos = a.find(mode); 00135 a.erase(pos,1); 00136 strncpy(this->custom_modes,a.c_str(),MAXMODES); 00137 00138 log(DEBUG,"Custom mode %c removed: modelist='%s'",mode,this->custom_modes); 00139 this->SetCustomModeParam(mode,"",false); 00140 } 00141 } |
|
Sets or unsets the parameters for a custom mode in a channels info.
Definition at line 144 of file channels.cpp. References ModeParameter::channel, custom_mode_params, DEBUG, ModeParameter::mode, and ModeParameter::parameter. Referenced by SetCustomMode().
00145 { 00146 00147 log(DEBUG,"SetCustomModeParam called"); 00148 ModeParameter M; 00149 M.mode = mode; 00150 strlcpy(M.channel,this->name,CHANMAX); 00151 strlcpy(M.parameter,parameter,MAXBUF); 00152 if (mode_on) 00153 { 00154 log(DEBUG,"Custom mode parameter %c %s added",mode,parameter); 00155 custom_mode_params.push_back(M); 00156 } 00157 else 00158 { 00159 if (custom_mode_params.size()) 00160 { 00161 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++) 00162 { 00163 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel))) 00164 { 00165 log(DEBUG,"Custom mode parameter %c %s removed",mode,parameter); 00166 custom_mode_params.erase(i); 00167 return; 00168 } 00169 } 00170 } 00171 log(DEBUG,"*** BUG *** Attempt to remove non-existent mode parameter!"); 00172 } 00173 } |
|
The list of all bans set on the channel.
Definition at line 149 of file channels.h. |
|
Contains a bitmask of the CM_* builtin (RFC) binary mode symbols.
Definition at line 145 of file channels.h. Referenced by chanrec(). |
|
Creation time.
Definition at line 123 of file channels.h. Referenced by chanrec(). |
|
Custom modes for the channel. Plugins may use this field in any way they see fit. Definition at line 110 of file channels.h. Referenced by chanrec(), and SetCustomMode(). |
|
User list (casted to char*'s to stop forward declaration stuff) (chicken and egg scenario!).
Definition at line 115 of file channels.h. Referenced by AddUser(), chanrec(), DelUser(), GetUserCounter(), and GetUsers(). |
|
Contains the channel key. If this value is an empty string, there is no channel key in place. Definition at line 141 of file channels.h. Referenced by chanrec(). |
|
Contains the channel user limit. If this value is zero, there is no limit in place. Definition at line 136 of file channels.h. Referenced by chanrec(). |
|
The channels name.
Definition at line 106 of file channels.h. Referenced by chanrec(), DelUser(), and Server::PseudoToUser(). |
|
The last user to set the topic. If this member is an empty string, no topic was ever set. Definition at line 131 of file channels.h. Referenced by chanrec(), and Server::PseudoToUser(). |
|
Channel topic. If this is an empty string, no channel topic is set. Definition at line 120 of file channels.h. Referenced by chanrec(), and Server::PseudoToUser(). |
|
Time topic was set. If no topic was ever set, this will be equal to chanrec::created Definition at line 127 of file channels.h. Referenced by chanrec(), and Server::PseudoToUser(). |