| 1 | /* |
| 2 | * Copyright (C) 1998,1999,2001 Ross Combs ([email protected]) |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; either version 2 |
| 7 | * of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | */ |
| 18 | #ifndef INCLUDED_MESSAGE_TYPES |
| 19 | #define INCLUDED_MESSAGE_TYPES |
| 20 | |
| 21 | #ifdef MESSAGE_INTERNAL_ACCESS |
| 22 | |
| 23 | #ifdef JUST_NEED_TYPES |
| 24 | # include "common/packet.h" |
| 25 | # include "connection.h" |
| 26 | #else |
| 27 | # define JUST_NEED_TYPES |
| 28 | # include "common/packet.h" |
| 29 | # include "connection.h" |
| 30 | # undef JUST_NEED_TYPES |
| 31 | #endif |
| 32 | |
| 33 | #endif |
| 34 | |
| 35 | namespace pvpgn |
| 36 | { |
| 37 | |
| 38 | namespace bnetd |
| 39 | { |
| 40 | |
| 41 | typedef enum |
| 42 | { |
| 43 | message_type_adduser, |
| 44 | message_type_join, |
| 45 | message_type_part, |
| 46 | message_type_whisper, |
| 47 | message_type_talk, |
| 48 | message_type_broadcast, |
| 49 | message_type_channel, |
| 50 | message_type_userflags, |
| 51 | message_type_whisperack, |
| 52 | message_type_friendwhisperack, |
| 53 | message_type_channelfull, |
| 54 | message_type_channeldoesnotexist, |
| 55 | message_type_channelrestricted, |
| 56 | message_type_info, |
| 57 | message_type_error, |
| 58 | message_type_emote, |
| 59 | message_type_uniqueid, |
| 60 | message_type_mode, |
| 61 | message_type_kick, |
| 62 | message_type_quit, |
| 63 | |
| 64 | /** |
| 65 | * IRC specific messages |
| 66 | */ |
| 67 | message_type_nick, |
| 68 | message_type_notice, |
| 69 | message_type_namreply, |
| 70 | message_type_topic, |
| 71 | |
| 72 | /** |
| 73 | * Westwood Online Extensions |
| 74 | */ |
| 75 | message_type_host, |
| 76 | message_type_invmsg, |
| 77 | message_type_page, |
| 78 | message_wol_joingame, |
| 79 | message_type_gameopt_talk, |
| 80 | message_type_gameopt_whisper, |
| 81 | message_wol_start_game, |
| 82 | message_wol_advertr, |
| 83 | message_wol_chanchk, |
| 84 | message_wol_userip, |
| 85 | |
| 86 | message_type_null |
| 87 | } t_message_type; |
| 88 | |
| 89 | typedef enum { |
| 90 | message_class_normal, |
| 91 | message_class_charjoin /* use char*account (if account isnt d2 char is "") */ |
| 92 | } t_message_class; |
| 93 | |
| 94 | typedef struct message |
| 95 | #ifdef MESSAGE_INTERNAL_ACCESS |
| 96 | { |
| 97 | unsigned int num_cached; |
| 98 | t_packet * * packets; /* cached messages */ |
| 99 | t_conn_class * classes; /* classes of cached message connections */ |
| 100 | unsigned int * dstflags; /* overlaid flags of cached messages */ |
| 101 | t_message_class * mclasses; /* classes of cached messages */ |
| 102 | /* ---- */ |
| 103 | t_message_type type; /* format of message */ |
| 104 | t_connection * src; /* originator message */ |
| 105 | char const * text; /* text of message */ |
| 106 | } |
| 107 | #endif |
| 108 | t_message; |
| 109 | |
| 110 | } |
| 111 | |
| 112 | } |
| 113 | |
| 114 | #endif |
| 115 | |
| 116 | /*****/ |
| 117 | #ifndef JUST_NEED_TYPES |
| 118 | #ifndef INCLUDED_MESSAGE_PROTOS |
| 119 | #define INCLUDED_MESSAGE_PROTOS |
| 120 | |
| 121 | #include <cstdio> |
| 122 | #define JUST_NEED_TYPES |
| 123 | #include <string> |
| 124 | #include "connection.h" |
| 125 | #include "common/bnet_protocol.h" |
| 126 | #undef JUST_NEED_TYPES |
| 127 | |
| 128 | namespace pvpgn |
| 129 | { |
| 130 | |
| 131 | namespace bnetd |
| 132 | { |
| 133 | |
| 134 | extern char * message_format_line(t_connection const * c, char const * in); |
| 135 | extern t_message * message_create(t_message_type type, t_connection * src, char const * text); |
| 136 | extern int message_destroy(t_message * message); |
| 137 | extern int message_send(t_message * message, t_connection * dst); |
| 138 | extern int message_send_all(t_message * message); |
| 139 | extern int message_send_admins(t_connection * src, t_message_type type, char const * text); |
| 140 | |
| 141 | /* the following are "shortcuts" to avoid calling message_create(), message_send(), message_destroy() */ |
| 142 | extern int message_send_text(t_connection * dst, t_message_type type, t_connection * src, std::string text); |
| 143 | extern int message_send_text(t_connection * dst, t_message_type type, t_connection * src, char const * text); |
| 144 | extern int message_send_formatted(t_connection * dst, char const * text); |
| 145 | extern int message_send_file(t_connection * dst, std::FILE * fd); |
| 146 | extern int messagebox_show(t_connection * dst, char const * text, char const * caption = "", int type = SERVER_MESSAGEBOX_OK); |
| 147 | |
| 148 | } |
| 149 | |
| 150 | } |
| 151 | |
| 152 | #endif |
| 153 | #endif |