1
0
mirror of https://github.com/anope/anope.git synced 2026-06-25 09:16:38 +02:00

Mark some stuff deprecated, move implementation from the interface into the user class.

git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1206 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
Robin Burchell w00t@inspircd.org
2008-09-30 18:45:10 +00:00
parent ca8996472c
commit e6111d9ff4
5 changed files with 58 additions and 27 deletions
+3 -3
View File
@@ -1019,9 +1019,9 @@ E void notice_server(char *source, Server * s, char *fmt, ...)
E void notice_user(char *source, User *u, const char *fmt, ...)
FORMAT(printf,3,4);
E void notice_list(const char *source, const char *dest, char **text);
E void notice_lang(const char *source, User *dest, int message, ...);
E void notice_help(const char *source, User *dest, int message, ...);
E void notice_list(const char *source, const char *dest, char **text) MARK_DEPRECATED;
E void notice_lang(const char *source, User *dest, int message, ...) MARK_DEPRECATED;
E void notice_help(const char *source, User *dest, int message, ...) MARK_DEPRECATED;
/**** servers.c ****/
+7 -13
View File
@@ -55,12 +55,8 @@
#include <stdlib.h>
#include <string.h>
/* Windows does not have:
* unistd.h, grp.h,
* netdb.h, netinet/in.h,
* sys/socket.h, sys/time.h
* Windows requires:
* winsock.h
/* Windows does not have: unistd.h, grp.h, netdb.h, netinet/in.h, sys/socket.h, sys/time.h
* Windows requires: winsock.h
* -- codemastr
*/
@@ -164,13 +160,6 @@
* prototypes. */
extern int strcasecmp(const char *, const char *);
extern int strncasecmp(const char *, const char *, size_t);
# if 0 /* These break on some AIX boxes (4.3.1 reported). */
extern int gettimeofday(struct timeval *, struct timezone *);
extern int socket(int, int, int);
extern int bind(int, struct sockaddr *, int);
extern int connect(int, struct sockaddr *, int);
extern int shutdown(int, int);
# endif
# undef FD_ZERO
# define FD_ZERO(p) memset((p), 0, sizeof(*(p)))
#endif /* _AIX */
@@ -206,6 +195,11 @@ extern int shutdown(int, int);
# undef int32
#endif
#ifndef _WIN32
#define MARK_DEPRECATED __attribute((deprecated))
#else
#define MARK_DEPRECATED
#endif
/* Miscellaneous definitions. */
#include "defs.h"
+10
View File
@@ -90,5 +90,15 @@ class User
/** Updates the realname of the user record.
*/
void SetRealname(const std::string &realname);
/**
* Send a message (notice or privmsg, depending on settings) to a user
* @param source Sender nick
* @param fmt Format of the Message
* @param ... any number of parameters
* @return void
*/
void SendMessage(const char *source, const char *fmt, ...);
void SendMessage(const char *source, const std::string &msg);
};
+2 -11
View File
@@ -100,17 +100,8 @@ void notice_user(char *source, User * u, const char *fmt, ...)
va_start(args, fmt);
vsnprintf(buf, BUFSIZE - 1, fmt, args);
/* Send privmsg instead of notice if:
* - UsePrivmsg is enabled
* - The user is not registered and NSDefMsg is enabled
* - The user is registered and has set /ns set msg on
*/
if (UsePrivmsg && ((!u->na && (NSDefFlags & NI_MSG))
|| (u->na && (u->na->nc->flags & NI_MSG)))) {
anope_cmd_privmsg2(source, u->nick, buf);
} else {
anope_cmd_notice2(source, u->nick, buf);
}
u->SendMessage(source, buf);
va_end(args);
}
}
+36
View File
@@ -260,6 +260,42 @@ User::~User()
alog("debug: User::~User() done");
}
void User::SendMessage(const char *source, const char *fmt, ...)
{
va_list args;
char buf[BUFSIZE];
*buf = '\0';
if (fmt)
{
va_start(args, fmt);
vsnprintf(buf, BUFSIZE - 1, fmt, args);
this->SendMessage(source, std::string(buf));
va_end(args);
}
}
void User::SendMessage(const char *source, const std::string &msg)
{
/* Send privmsg instead of notice if:
* - UsePrivmsg is enabled
* - The user is not registered and NSDefMsg is enabled
* - The user is registered and has set /ns set msg on
*/
if (UsePrivmsg &&
((!this->na && NSDefFlags & NI_MSG) || (this->na && this->na->nc->flags & NI_MSG)))
{
anope_cmd_privmsg2(source, this->nick, msg.c_str());
}
else
{
anope_cmd_notice2(source, this->nick, msg.c_str());
}
}
/*************************************************************************/
/*************************************************************************/