1 /*
2  * Copyright (C) 1998,1999,2001  Ross Combs (rocombs@cs.nmsu.edu)
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 typedef enum
36 {
37     message_type_adduser,
38     message_type_join,
39     message_type_part,
40     message_type_whisper,
41     message_type_talk,
42     message_type_broadcast,
43     message_type_channel,
44     message_type_userflags,
45     message_type_whisperack,
46     message_type_friendwhisperack,
47     message_type_channelfull,
48     message_type_channeldoesnotexist,
49     message_type_channelrestricted,
50     message_type_info,
51     message_type_error,
52     message_type_emote,
53     message_type_uniqueid,
54     message_type_mode,
55 
56     /**
57     *   IRC specific messages
58     */
59     message_type_notice,
60 
61     /**
62     *  Westwood Online Extensions
63     */
64     message_wol_joingame,
65     message_wol_gameopt_owner,
66     message_wol_gameopt_join,
67     message_wol_start_game,
68     message_wol_page,
69 
70     message_type_null
71 } t_message_type;
72 
73 typedef enum {
74     message_class_normal,
75     message_class_charjoin,	/* use char*account (if account isnt d2 char is "") */
76 } t_message_class;
77 
78 typedef struct message
79 #ifdef MESSAGE_INTERNAL_ACCESS
80 {
81     unsigned int   num_cached;
82     t_packet * *   packets;    /* cached messages */
83     t_conn_class * classes;    /* classes of cached message connections */
84     unsigned int * dstflags;   /* overlaid flags of cached messages */
85     t_message_class * mclasses; /* classes of cached messages */
86     /* ---- */
87     t_message_type type;       /* format of message */
88     t_connection * src;        /* originator message */
89     t_connection * dst;        /* destination */
90     char const *   text;       /* text of message */
91 }
92 #endif
93 t_message;
94 
95 #endif
96 
97 /*****/
98 #ifndef JUST_NEED_TYPES
99 #ifndef INCLUDED_MESSAGE_PROTOS
100 #define INCLUDED_MESSAGE_PROTOS
101 
102 #define JUST_NEED_TYPES
103 #include <stdio.h>
104 #include "connection.h"
105 #undef JUST_NEED_TYPES
106 
107 extern char * message_format_line(t_connection const * c, char const * in);
108 extern t_message * message_create(t_message_type type, t_connection * src, t_connection * dst, char const * text);
109 extern int message_destroy(t_message * message);
110 extern int message_send(t_message * message, t_connection * dst);
111 extern int message_send_all(t_message * message);
112 extern int message_send_admins(t_connection * src, t_message_type type, char const * text);
113 
114 /* the following are "shortcuts" to avoid calling message_create(), message_send(), message_destroy() */
115 extern int message_send_text(t_connection * dst, t_message_type type, t_connection * src, char const * text);
116 extern int message_send_formatted(t_connection * dst, char const * text);
117 extern int message_send_file(t_connection * dst, FILE * fd);
118 
119 #endif
120 #endif
121