src/irc_chan.h
changeset 37 4fe4a3c4496e
parent 26 aec062af155d
child 38 0c2e0cb46c3a
equal deleted inserted replaced
36:791d7a5532e2 37:4fe4a3c4496e
     8  */
     8  */
     9 struct irc_chan_info;
     9 struct irc_chan_info;
    10 struct irc_chan;
    10 struct irc_chan;
    11 
    11 
    12 #include "irc_net.h"
    12 #include "irc_net.h"
       
    13 #include "irc_cmd.h"
    13 #include "error.h"
    14 #include "error.h"
    14 #include <sys/queue.h>
    15 #include <sys/queue.h>
    15 
    16 
    16 /**
    17 /**
    17  * IRC channel info, as required to create an irc_chan
    18  * IRC channel info, as required to create an irc_chan
    21     const char *channel;
    22     const char *channel;
    22 
    23 
    23 };
    24 };
    24 
    25 
    25 /**
    26 /**
    26  * General IRC channel states
    27  * Semantic IRC channel callbacks
    27  */
    28  */
    28 enum irc_chan_state {
    29 struct irc_chan_callbacks {
    29     /** Initialized, but idle */
    30     /** Joined the channel */
    30     IRC_CHAN_INIT,
    31     void (*on_self_join) (struct irc_chan *chan, void *arg);
    31 
       
    32     /** JOIN request sent */
       
    33     IRC_CHAN_JOINING,
       
    34 
       
    35     /** Currently joined to the channel */
       
    36     IRC_CHAN_JOINED,
       
    37 };
    32 };
    38 
    33 
    39 /**
    34 /**
    40  * IRC channel state
    35  * IRC channel state
    41  */
    36  */
    47     struct irc_net *net;
    42     struct irc_net *net;
    48 
    43 
    49     /** Our identifying info */
    44     /** Our identifying info */
    50     struct irc_chan_info info;
    45     struct irc_chan_info info;
    51     
    46     
    52     /** Current state */
    47     /** State flags */
    53     enum irc_chan_state state;
    48     struct {
       
    49         /** JOIN request sent, waiting for reply */
       
    50         bool joining;
       
    51 
       
    52         /** Currently joined to channel */
       
    53         bool joined;
       
    54 
       
    55     } state;
       
    56 
       
    57     /** General command handlers */
       
    58     irc_cmd_handlers_t handlers;
    54 };
    59 };
    55 
    60 
    56 /**
    61 /**
    57  * Return the channel's name
    62  * Return the channel's name
    58  */
    63  */
    69  * @param err error codes are returned via this
    74  * @param err error codes are returned via this
    70  */
    75  */
    71 err_t irc_chan_create (struct irc_chan **chan_ptr, struct irc_net *net, const struct irc_chan_info *info, struct error_info *err);
    76 err_t irc_chan_create (struct irc_chan **chan_ptr, struct irc_net *net, const struct irc_chan_info *info, struct error_info *err);
    72 
    77 
    73 /**
    78 /**
       
    79  * Destroy irc_chan state, without doing anything to the network
       
    80  */
       
    81 void irc_chan_destroy (struct irc_chan *chan);
       
    82 
       
    83 /**
    74  * Send the initial JOIN message.
    84  * Send the initial JOIN message.
    75  *
    85  *
    76  * The channel must be in the IRC_CHAN_INIT state, and will transition to the IRC_CHAN_JOINING state.
    86  * The channel must be in the IRC_CHAN_INIT state, and will transition to the IRC_CHAN_JOINING state.
    77  *
    87  *
    78  * @param chan the channel to JOIN
    88  * @param chan the channel to JOIN
    79  */
    89  */
    80 err_t irc_chan_join (struct irc_chan *chan);
    90 err_t irc_chan_join (struct irc_chan *chan);
    81 
    91 
       
    92 
    82 #endif
    93 #endif