src/irc_chan.h
author Tero Marttila <terom@fixme.fi>
Wed, 27 May 2009 23:57:48 +0300
branchnew-lib-errors
changeset 217 7728d6ec3abf
parent 171 b54f393c3df0
permissions -rw-r--r--
nexus.c compiles
26
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
#ifndef IRC_CHAN_H
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
#define IRC_CHAN_H
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
/**
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
 * @file
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
 *
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
 * Support for IRC channels, including tracking their state and actions on them.
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
 */
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
struct irc_chan_info;
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
struct irc_chan;
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
#include "irc_net.h"
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    13
#include "irc_user.h"
37
4fe4a3c4496e change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
    14
#include "irc_cmd.h"
45
71e65564afd2 remove irc_chan.state, modify irc_chan_callbacks.on_msg to take a irc_nm, improve error handling a bit further (up to irc_net now)
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    15
#include "irc_proto.h"
26
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
#include "error.h"
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    17
#include <sys/queue.h>
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    18
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
/**
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
 * IRC channel info, as required to create an irc_chan
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    21
 */
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    22
struct irc_chan_info {
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    23
    /** Channel name, with the [#&!] prefix */
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    24
    const char *channel;
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    25
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    26
};
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    27
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    28
/**
89
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    29
 * Per-channel-user state. This is used to store the list of irc_user's on an irc_chan.
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    30
 *
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    31
 * The nickname is accessible via user->nickname.
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    32
 */
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    33
struct irc_chan_user {
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    34
    /** The per-network user info */
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    35
    struct irc_user *user;
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    36
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    37
    /** The irc_chan list */
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    38
    LIST_ENTRY(irc_chan_user) chan_users;
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    39
};
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    40
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    41
/**
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    42
 * High-level IRC channel callbacks for convenience.
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    43
 *
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    44
 * These are based on the normal irc_chan::handlers interface, and you can use both freely.
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    45
 *
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    46
 * The on_self_* handlers are for actions that affect our own status on the channel, the rest are only for actions
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    47
 * done by other users.
45
71e65564afd2 remove irc_chan.state, modify irc_chan_callbacks.on_msg to take a irc_nm, improve error handling a bit further (up to irc_net now)
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    48
 *
71e65564afd2 remove irc_chan.state, modify irc_chan_callbacks.on_msg to take a irc_nm, improve error handling a bit further (up to irc_net now)
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    49
 * Where callbacks have irc_nm arguments, these are MAY be given as NULL if the prefix could not be parsed.
26
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    50
 */
37
4fe4a3c4496e change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
    51
struct irc_chan_callbacks {
4fe4a3c4496e change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
    52
    /** Joined the channel */
4fe4a3c4496e change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
    53
    void (*on_self_join) (struct irc_chan *chan, void *arg);
38
0c2e0cb46c3a implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    54
74
11ec458d1cbf add irc_chan_on_PART, irc_net_put_user and test_irc_chan_user_part
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    55
    /** We parted the channel */
11ec458d1cbf add irc_chan_on_PART, irc_net_put_user and test_irc_chan_user_part
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    56
    void (*on_self_part) (struct irc_chan *chan, void *arg);
11ec458d1cbf add irc_chan_on_PART, irc_net_put_user and test_irc_chan_user_part
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    57
89
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    58
    /** We were kicked from the channel */
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    59
    void (*on_self_kicked) (struct irc_chan *chan, const struct irc_nm *source, const char *msg, void *arg);
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    60
152
dae7bcf08474 implement irc_chan_callbacks::on_self_msg/on_self_notice, and add code for mod_irc_log to use them
Tero Marttila <terom@fixme.fi>
parents: 148
diff changeset
    61
    /** We sent a message to the channel using irc_chan_PRIVMSG */
dae7bcf08474 implement irc_chan_callbacks::on_self_msg/on_self_notice, and add code for mod_irc_log to use them
Tero Marttila <terom@fixme.fi>
parents: 148
diff changeset
    62
    void (*on_self_msg) (struct irc_chan *chan, const char *msg, void *arg);
dae7bcf08474 implement irc_chan_callbacks::on_self_msg/on_self_notice, and add code for mod_irc_log to use them
Tero Marttila <terom@fixme.fi>
parents: 148
diff changeset
    63
dae7bcf08474 implement irc_chan_callbacks::on_self_msg/on_self_notice, and add code for mod_irc_log to use them
Tero Marttila <terom@fixme.fi>
parents: 148
diff changeset
    64
    /** We sent a notice to the channel using irc_chan_NOTICE */
dae7bcf08474 implement irc_chan_callbacks::on_self_msg/on_self_notice, and add code for mod_irc_log to use them
Tero Marttila <terom@fixme.fi>
parents: 148
diff changeset
    65
    void (*on_self_notice) (struct irc_chan *chan, const char *msg, void *arg);
dae7bcf08474 implement irc_chan_callbacks::on_self_msg/on_self_notice, and add code for mod_irc_log to use them
Tero Marttila <terom@fixme.fi>
parents: 148
diff changeset
    66
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    67
    /** Someone joined the channel */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    68
    void (*on_join) (struct irc_chan *chan, const struct irc_nm *source, void *arg);
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    69
74
11ec458d1cbf add irc_chan_on_PART, irc_net_put_user and test_irc_chan_user_part
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    70
    /** Someone parted the channel. The irc_chan_user is still present */
11ec458d1cbf add irc_chan_on_PART, irc_net_put_user and test_irc_chan_user_part
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    71
    void (*on_part) (struct irc_chan *chan, const struct irc_nm *source, const char *msg, void *arg);
11ec458d1cbf add irc_chan_on_PART, irc_net_put_user and test_irc_chan_user_part
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    72
89
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    73
    /** Someone was kicked from the channel. The irc_chan_user is still present */
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    74
    void (*on_kick)  (struct irc_chan *chan, const struct irc_nm *source, struct irc_chan_user *target, const char *msg, void *arg);
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
    75
78
941bb8379d3d implement NICK/QUIT handling for irc_net/irc_chan
Tero Marttila <terom@fixme.fi>
parents: 74
diff changeset
    76
    /** Someone quit the channel. The irc_chan_user is still present */
941bb8379d3d implement NICK/QUIT handling for irc_net/irc_chan
Tero Marttila <terom@fixme.fi>
parents: 74
diff changeset
    77
    void (*on_quit) (struct irc_chan *chan, const struct irc_nm *source, const char *msg, void *arg);
941bb8379d3d implement NICK/QUIT handling for irc_net/irc_chan
Tero Marttila <terom@fixme.fi>
parents: 74
diff changeset
    78
38
0c2e0cb46c3a implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    79
    /** Someone sent a message to the channel */
45
71e65564afd2 remove irc_chan.state, modify irc_chan_callbacks.on_msg to take a irc_nm, improve error handling a bit further (up to irc_net now)
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    80
    void (*on_msg) (struct irc_chan *chan, const struct irc_nm *source, const char *msg, void *arg);
26
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    81
};
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    82
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    83
/**
171
b54f393c3df0 evil chain.h macro magic, fix irc_conn_set_nickname bug, misc. test bugs (mem leaks, missing #includes)
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    84
 * Callback storage struct
b54f393c3df0 evil chain.h macro magic, fix irc_conn_set_nickname bug, misc. test bugs (mem leaks, missing #includes)
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    85
 */
b54f393c3df0 evil chain.h macro magic, fix irc_conn_set_nickname bug, misc. test bugs (mem leaks, missing #includes)
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    86
struct irc_chan_callback_item {
b54f393c3df0 evil chain.h macro magic, fix irc_conn_set_nickname bug, misc. test bugs (mem leaks, missing #includes)
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    87
    CHAIN_ITEM_HEADER(irc_chan_callback_item);
b54f393c3df0 evil chain.h macro magic, fix irc_conn_set_nickname bug, misc. test bugs (mem leaks, missing #includes)
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    88
b54f393c3df0 evil chain.h macro magic, fix irc_conn_set_nickname bug, misc. test bugs (mem leaks, missing #includes)
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    89
    const struct irc_chan_callbacks *callbacks;
b54f393c3df0 evil chain.h macro magic, fix irc_conn_set_nickname bug, misc. test bugs (mem leaks, missing #includes)
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    90
b54f393c3df0 evil chain.h macro magic, fix irc_conn_set_nickname bug, misc. test bugs (mem leaks, missing #includes)
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    91
    void *arg;
b54f393c3df0 evil chain.h macro magic, fix irc_conn_set_nickname bug, misc. test bugs (mem leaks, missing #includes)
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    92
};
b54f393c3df0 evil chain.h macro magic, fix irc_conn_set_nickname bug, misc. test bugs (mem leaks, missing #includes)
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    93
b54f393c3df0 evil chain.h macro magic, fix irc_conn_set_nickname bug, misc. test bugs (mem leaks, missing #includes)
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    94
/**
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    95
 * Persistent IRC channel state, part of irc_net.
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    96
 *
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    97
 * This stores the channel's info, status flags, users list, and handlers/callbacks.
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    98
 *
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    99
 * Create/get channels using the irc_net_add_chan()/irc_net_get_chan() interface, and then attach your own
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   100
 * callbacks/handlers using irc_chan_add_callbacks()/irc_chan::handlers and irc_cmd_add().
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   101
 *
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   102
 * Note that irc_net will propagate all relevant events for each channel.
26
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   103
 */
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   104
struct irc_chan {
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   105
    /** The network we're part of */
26
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   106
    struct irc_net *net;
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   107
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   108
    /** Our identifying info */
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   109
    struct irc_chan_info info;
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   110
    
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   111
    /** 
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   112
     * @defgroup irc_chan_state State flags 
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   113
     * @{ 
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   114
     */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   115
    /** JOIN request sent, waiting for reply */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   116
    bool joining;
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   117
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   118
    /** Currently joined to channel */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   119
    bool joined;
37
4fe4a3c4496e change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
   120
74
11ec458d1cbf add irc_chan_on_PART, irc_net_put_user and test_irc_chan_user_part
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   121
    /** We PART'd the channel */
11ec458d1cbf add irc_chan_on_PART, irc_net_put_user and test_irc_chan_user_part
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   122
    bool parted;
11ec458d1cbf add irc_chan_on_PART, irc_net_put_user and test_irc_chan_user_part
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   123
89
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
   124
    /** We were KICK'd from the channel */
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
   125
    bool kicked;
68345a9b99a3 irc_chan_on_KICK
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
   126
45
71e65564afd2 remove irc_chan.state, modify irc_chan_callbacks.on_msg to take a irc_nm, improve error handling a bit further (up to irc_net now)
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
   127
    // @}
71e65564afd2 remove irc_chan.state, modify irc_chan_callbacks.on_msg to take a irc_nm, improve error handling a bit further (up to irc_net now)
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
   128
    
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   129
    /** List of users on channel */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   130
    LIST_HEAD(irc_chan_users_list, irc_chan_user) users;
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   131
    
37
4fe4a3c4496e change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
   132
    /** General command handlers */
171
b54f393c3df0 evil chain.h macro magic, fix irc_conn_set_nickname bug, misc. test bugs (mem leaks, missing #includes)
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
   133
    struct irc_cmd_handlers handlers;
38
0c2e0cb46c3a implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   134
0c2e0cb46c3a implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   135
    /** High-level user callbacks */
171
b54f393c3df0 evil chain.h macro magic, fix irc_conn_set_nickname bug, misc. test bugs (mem leaks, missing #includes)
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
   136
    CHAIN_HEAD_TYPE(irc_chan_callback_list, irc_chan_callback_item) callbacks;
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   137
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   138
    /** The irc_net::channels list */
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   139
    TAILQ_ENTRY(irc_chan) net_channels;
26
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   140
};
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   141
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   142
/**
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   143
 * Return the channel's name
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   144
 */
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   145
const char* irc_chan_name (struct irc_chan *chan);
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   146
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   147
/**
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   148
 * Build/initialize a new irc_chan struct. This does not have any external side-effects.
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   149
 *
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   150
 * The channel will be in the IRC_CHAN_INIT state after this.
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   151
 *
148
2d8dec363f9e fix irc_chan to copy the irc_chan_info strings
Tero Marttila <terom@fixme.fi>
parents: 127
diff changeset
   152
 * The contents of \a info will be copied.
2d8dec363f9e fix irc_chan to copy the irc_chan_info strings
Tero Marttila <terom@fixme.fi>
parents: 127
diff changeset
   153
 *
26
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   154
 * @param chan_ptr the new irc_chan is returned via this pointer
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   155
 * @param net the irc_net this channel is on
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   156
 * @param info the channel's identifying information
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   157
 * @param err error codes are returned via this
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   158
 */
217
7728d6ec3abf nexus.c compiles
Tero Marttila <terom@fixme.fi>
parents: 171
diff changeset
   159
err_t irc_chan_create (struct irc_chan **chan_ptr, struct irc_net *net, const struct irc_chan_info *info, error_t *err);
26
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   160
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   161
/**
37
4fe4a3c4496e change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
   162
 * Destroy irc_chan state, without doing anything to the network
4fe4a3c4496e change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
   163
 */
4fe4a3c4496e change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
   164
void irc_chan_destroy (struct irc_chan *chan);
4fe4a3c4496e change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
   165
4fe4a3c4496e change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
   166
/**
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   167
 * Add a set of high-level irc_chan callbacks. Not all callbacks need to be implemented.
38
0c2e0cb46c3a implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   168
 */
0c2e0cb46c3a implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   169
err_t irc_chan_add_callbacks (struct irc_chan *chan, const struct irc_chan_callbacks *callbacks, void *arg);
0c2e0cb46c3a implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   170
0c2e0cb46c3a implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   171
/**
69
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
   172
 * Remove high-level irc_chan callbacks.
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
   173
 */
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
   174
void irc_chan_remove_callbacks (struct irc_chan *chan, const struct irc_chan_callbacks *callbacks, void *arg);
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
   175
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
   176
/**
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   177
 * Look up an irc_chan_user struct by nickname for this channel, returning NULL if no such chan_user exists.
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   178
 *
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   179
 * Be careful not to hold on to this, as the irc_chan_user struct may be released if the user leaves the channel.
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   180
 *
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   181
 * @param chan the channel context
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   182
 * @param nickname the user's current nickname
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   183
 * @return the irc_chan_user state, or NULL if nickname not found
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   184
 */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   185
struct irc_chan_user* irc_chan_get_user (struct irc_chan *chan, const char *nickname);
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   186
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   187
/**
26
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   188
 * Send the initial JOIN message.
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   189
 *
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   190
 * @param chan the channel to JOIN
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   191
 */
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   192
err_t irc_chan_join (struct irc_chan *chan);
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   193
97
d3bc82ee76cb add irc_conn_PRIVMSG/irc_chan_PRIVMSG and lua bindings
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   194
/**
d3bc82ee76cb add irc_conn_PRIVMSG/irc_chan_PRIVMSG and lua bindings
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   195
 * Send a normal PRIVMSG to the channel. If we're being pedantic, one should use NOTICE instead for messages sent in
d3bc82ee76cb add irc_conn_PRIVMSG/irc_chan_PRIVMSG and lua bindings
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   196
 * reply to PRIVMSG's, but the real world is different.
d3bc82ee76cb add irc_conn_PRIVMSG/irc_chan_PRIVMSG and lua bindings
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   197
 *
152
dae7bcf08474 implement irc_chan_callbacks::on_self_msg/on_self_notice, and add code for mod_irc_log to use them
Tero Marttila <terom@fixme.fi>
parents: 148
diff changeset
   198
 * This also invokes any self_msg callbacks.
dae7bcf08474 implement irc_chan_callbacks::on_self_msg/on_self_notice, and add code for mod_irc_log to use them
Tero Marttila <terom@fixme.fi>
parents: 148
diff changeset
   199
 *
97
d3bc82ee76cb add irc_conn_PRIVMSG/irc_chan_PRIVMSG and lua bindings
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   200
 * @param chan the IRC channel
d3bc82ee76cb add irc_conn_PRIVMSG/irc_chan_PRIVMSG and lua bindings
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   201
 * @param message the message to send
d3bc82ee76cb add irc_conn_PRIVMSG/irc_chan_PRIVMSG and lua bindings
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   202
 */
d3bc82ee76cb add irc_conn_PRIVMSG/irc_chan_PRIVMSG and lua bindings
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   203
err_t irc_chan_PRIVMSG (struct irc_chan *chan, const char *message);
d3bc82ee76cb add irc_conn_PRIVMSG/irc_chan_PRIVMSG and lua bindings
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   204
127
94e6c3b4230f implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents: 97
diff changeset
   205
/**
94e6c3b4230f implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents: 97
diff changeset
   206
 * Send a NOTICE message to the channel.
94e6c3b4230f implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents: 97
diff changeset
   207
 *
152
dae7bcf08474 implement irc_chan_callbacks::on_self_msg/on_self_notice, and add code for mod_irc_log to use them
Tero Marttila <terom@fixme.fi>
parents: 148
diff changeset
   208
 * This also invokes any self_notice callbacks.
dae7bcf08474 implement irc_chan_callbacks::on_self_msg/on_self_notice, and add code for mod_irc_log to use them
Tero Marttila <terom@fixme.fi>
parents: 148
diff changeset
   209
 *
127
94e6c3b4230f implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents: 97
diff changeset
   210
 * @param chan the IRC channel
94e6c3b4230f implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents: 97
diff changeset
   211
 * @param message the message to send
94e6c3b4230f implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents: 97
diff changeset
   212
 */
94e6c3b4230f implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents: 97
diff changeset
   213
err_t irc_chan_NOTICE (struct irc_chan *chan, const char *message);
94e6c3b4230f implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents: 97
diff changeset
   214
26
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   215
#endif