mirror of
https://github.com/anope/anope.git
synced 2026-07-06 01:13:14 +02:00
Add User::SetIdent(). Also remove duplication by using update_host().
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1190 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
@@ -1149,8 +1149,6 @@ E char *TS6SID;
|
||||
E char *TS6UPLINK;
|
||||
|
||||
E void update_host(User * user);
|
||||
E void change_user_username(User * user, const char *username);
|
||||
E void change_user_realname(User * user, const char *realname);
|
||||
|
||||
E User *do_nick(const char *source, char *nick, char *username, char *host,
|
||||
char *server, char *realname, time_t ts, uint32 svid, uint32 ip, char *vhost, char *uid);
|
||||
|
||||
@@ -78,5 +78,9 @@ class User
|
||||
* This is used (if set) instead of real host.
|
||||
*/
|
||||
void SetDisplayedHost(const std::string &host);
|
||||
|
||||
/** Update the displayed ident (username) of a user record.
|
||||
*/
|
||||
void SetIdent(const std::string &ident);
|
||||
};
|
||||
|
||||
|
||||
+15
-26
@@ -120,6 +120,21 @@ void User::SetDisplayedHost(const std::string &host)
|
||||
update_host(this);
|
||||
}
|
||||
|
||||
void User::SetIdent(const std::string &ident)
|
||||
{
|
||||
if (ident.empty())
|
||||
throw "empty ident in SetIdent";
|
||||
|
||||
if (this->vident)
|
||||
free(this->vident);
|
||||
this->vident = sstrdup(ident.c_str());
|
||||
|
||||
if (debug)
|
||||
alog("debug: %s changed ident to %s", this->nick, username);
|
||||
|
||||
update_host(this);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
@@ -170,32 +185,6 @@ void change_user_realname(User * user, const char *realname)
|
||||
alog("debug: %s changes its realname to %s", user->nick, realname);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Change the username of a user. */
|
||||
|
||||
void change_user_username(User * user, const char *username)
|
||||
{
|
||||
if (user->vident)
|
||||
free(user->vident);
|
||||
user->vident = sstrdup(username);
|
||||
if (user->na && (nick_identified(user)
|
||||
|| (!(user->na->nc->flags & NI_SECURE)
|
||||
&& nick_recognized(user)))) {
|
||||
if (user->na->last_usermask)
|
||||
free(user->na->last_usermask);
|
||||
|
||||
user->na->last_usermask =
|
||||
(char *)smalloc(strlen(common_get_vident(user)) +
|
||||
strlen(common_get_vhost(user)) + 2);
|
||||
sprintf(user->na->last_usermask, "%s@%s", common_get_vident(user),
|
||||
common_get_vhost(user));
|
||||
}
|
||||
if (debug)
|
||||
alog("debug: %s changes its username to %s", user->nick, username);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Remove and free a User structure. */
|
||||
|
||||
Reference in New Issue
Block a user