src/irc_chan.h
changeset 37 4fe4a3c4496e
parent 26 aec062af155d
child 38 0c2e0cb46c3a
--- a/src/irc_chan.h	Thu Mar 12 18:08:27 2009 +0200
+++ b/src/irc_chan.h	Thu Mar 12 18:11:44 2009 +0200
@@ -10,6 +10,7 @@
 struct irc_chan;
 
 #include "irc_net.h"
+#include "irc_cmd.h"
 #include "error.h"
 #include <sys/queue.h>
 
@@ -23,17 +24,11 @@
 };
 
 /**
- * General IRC channel states
+ * Semantic IRC channel callbacks
  */
-enum irc_chan_state {
-    /** Initialized, but idle */
-    IRC_CHAN_INIT,
-
-    /** JOIN request sent */
-    IRC_CHAN_JOINING,
-
-    /** Currently joined to the channel */
-    IRC_CHAN_JOINED,
+struct irc_chan_callbacks {
+    /** Joined the channel */
+    void (*on_self_join) (struct irc_chan *chan, void *arg);
 };
 
 /**
@@ -49,8 +44,18 @@
     /** Our identifying info */
     struct irc_chan_info info;
     
-    /** Current state */
-    enum irc_chan_state state;
+    /** State flags */
+    struct {
+        /** JOIN request sent, waiting for reply */
+        bool joining;
+
+        /** Currently joined to channel */
+        bool joined;
+
+    } state;
+
+    /** General command handlers */
+    irc_cmd_handlers_t handlers;
 };
 
 /**
@@ -71,6 +76,11 @@
 err_t irc_chan_create (struct irc_chan **chan_ptr, struct irc_net *net, const struct irc_chan_info *info, struct error_info *err);
 
 /**
+ * Destroy irc_chan state, without doing anything to the network
+ */
+void irc_chan_destroy (struct irc_chan *chan);
+
+/**
  * Send the initial JOIN message.
  *
  * The channel must be in the IRC_CHAN_INIT state, and will transition to the IRC_CHAN_JOINING state.
@@ -79,4 +89,5 @@
  */
 err_t irc_chan_join (struct irc_chan *chan);
 
+
 #endif