src/irc_chan.h
author Tero Marttila <terom@fixme.fi>
Mon, 30 Mar 2009 01:31:27 +0300
changeset 87 f0db6ebf18b9
parent 78 941bb8379d3d
child 89 68345a9b99a3
permissions -rw-r--r--
documentation tweaks
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
/**
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    29
 * High-level IRC channel callbacks for convenience.
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    30
 *
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    31
 * 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
    32
 *
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    33
 * 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
    34
 * 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
    35
 *
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
    36
 * 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
    37
 */
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
    38
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
    39
    /** 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
    40
    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
    41
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
    42
    /** 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
    43
    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
    44
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    45
    /** 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
    46
    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
    47
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
    48
    /** 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
    49
    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
    50
78
941bb8379d3d implement NICK/QUIT handling for irc_net/irc_chan
Tero Marttila <terom@fixme.fi>
parents: 74
diff changeset
    51
    /** 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
    52
    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
    53
38
0c2e0cb46c3a implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    54
    /** 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
    55
    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
    56
};
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    57
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    58
/**
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    59
 * Per-channel-user state. This is used to store the list of irc_user's on an irc_chan.
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    60
 *
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    61
 * The nickname is accessible via user->nickname.
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    62
 */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    63
struct irc_chan_user {
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    64
    /** The per-network user info */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    65
    struct irc_user *user;
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    66
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    67
    /** The irc_chan list */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    68
    LIST_ENTRY(irc_chan_user) chan_users;
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    69
};
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    70
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    71
/**
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    72
 * Persistent IRC channel state, part of irc_net.
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    73
 *
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    74
 * 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
    75
 *
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    76
 * 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
    77
 * 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
    78
 *
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    79
 * 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
    80
 */
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    81
struct irc_chan {
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    82
    /** The network we're part of */
26
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    83
    struct irc_net *net;
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    84
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    85
    /** Our identifying info */
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    86
    struct irc_chan_info info;
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    87
    
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    88
    /** 
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    89
     * @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
    90
     * @{ 
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    91
     */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    92
    /** 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
    93
    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
    94
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    95
    /** 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
    96
    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
    97
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
    98
    /** 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
    99
    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
   100
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
   101
    // @}
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
   102
    
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   103
    /** 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
   104
    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
   105
    
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
   106
    /** General command handlers */
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
   107
    irc_cmd_handlers_t handlers;
38
0c2e0cb46c3a implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   108
0c2e0cb46c3a implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   109
    /** High-level user callbacks */
0c2e0cb46c3a implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   110
    struct chain_list callbacks;
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   111
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   112
    /** The irc_net::channels list */
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   113
    TAILQ_ENTRY(irc_chan) net_channels;
26
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   114
};
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   115
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   116
/**
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   117
 * Return the channel's name
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   118
 */
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   119
const char* irc_chan_name (struct irc_chan *chan);
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   120
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   121
/**
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   122
 * 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
   123
 *
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   124
 * 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
   125
 *
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   126
 * @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
   127
 * @param net the irc_net this channel is on
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   128
 * @param info the channel's identifying information
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   129
 * @param err error codes are returned via this
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   130
 */
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   131
err_t irc_chan_create (struct irc_chan **chan_ptr, struct irc_net *net, const struct irc_chan_info *info, struct error_info *err);
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   132
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   133
/**
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
   134
 * 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
   135
 */
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
   136
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
   137
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
   138
/**
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   139
 * 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
   140
 */
0c2e0cb46c3a implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   141
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
   142
0c2e0cb46c3a implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   143
/**
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
   144
 * 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
   145
 */
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
   146
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
   147
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
   148
/**
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   149
 * 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
   150
 *
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   151
 * 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
   152
 *
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   153
 * @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
   154
 * @param nickname the user's current nickname
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
   155
 * @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
   156
 */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   157
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
   158
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   159
/**
26
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   160
 * Send the initial JOIN message.
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   161
 *
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   162
 * @param chan the channel to JOIN
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   163
 */
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   164
err_t irc_chan_join (struct irc_chan *chan);
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   165
aec062af155d add irc_chan module
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   166
#endif