ChanServ.suspend duration
[srvx.git] / src / chanserv.h
index 4f6aaa66c01c7423ec006b3e2b422ce8ec80bef2..336671511d7159f576eca8772f711a366a18ddc1 100644 (file)
@@ -1,11 +1,12 @@
 /* chanserv.h - Channel service bot
  * Copyright 2000-2004 srvx Development Team
  *
- * This program is free software; you can redistribute it and/or modify
+ * This file is part of srvx.
+ *
+ * srvx is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.  Important limitations are
- * listed in the COPYING file that accompanies this software.
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -13,7 +14,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, email srvx-maintainers@srvx.net.
+ * along with srvx; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
 #ifndef _chanserv_h
@@ -32,6 +34,7 @@ enum UL_ALIASES {
 };
 
 enum levelOption {
+    lvlGiveVoice,
     lvlGiveOps,
     lvlEnfOps,
     lvlEnfModes,
@@ -39,6 +42,10 @@ enum levelOption {
     lvlPubCmd,
     lvlSetters,
     lvlCTCPUsers,
+    lvlUserInfo,
+    lvlInviteMe,
+    lvlTopicSnarf,
+    lvlVote,
     NUM_LEVEL_OPTIONS
 };
 
@@ -50,51 +57,67 @@ enum charOption {
     NUM_CHAR_OPTIONS
 };
 
-#define CHANNEL_NODELETE       0x00000001 /* (1 << 0) */
-#define CHANNEL_SUSPENDED      0x00000002 /* (1 << 1) */
-#define CHANNEL_INFO_LINES     0x00000004 /* (1 << 2) */
-#define CHANNEL_VOICE_ALL      0x00000008 /* (1 << 3) */
+#define CHANNEL_NODELETE    0x00000001 /* (1 << 0) */
+#define CHANNEL_SUSPENDED   0x00000002 /* (1 << 1) */
+#define CHANNEL_INFO_LINES  0x00000004 /* (1 << 2) - DEPRECATED */
+#define CHANNEL_VOICE_ALL   0x00000008 /* (1 << 3) - DEPRECATED */
 /* No longer used. */                      /* (1 << 4) */
-#define CHANNEL_DYNAMIC_LIMIT  0x00000020 /* (1 << 5) */
-#define CHANNEL_TOPIC_SNARF    0x00000040 /* (1 << 6) */
-#define CHANNEL_PEON_INVITE     0x00000080 /* (1 << 7) */
+#define CHANNEL_DYNAMIC_LIMIT   0x00000020 /* (1 << 5) */
+#define CHANNEL_TOPIC_SNARF     0x00000040 /* (1 << 6) - DEPRECATED */
+#define CHANNEL_PEON_INVITE     0x00000080 /* (1 << 7) - DEPRECATED */
+#define CHANNEL_OFFCHANNEL      0x00000100 /* (1 << 8) */
+#define CHANNEL_UNREVIEWED      0x00000200 /* (1 << 9) */
+#define CHANNEL_ADVTOPIC        0x00000400 /* (1 << 10) */
 /* Flags with values over 0x20000000 or (1 << 29) will not work
  * because chanData.flags is a 30-bit field.
  */
 
-#define IsProtected(x)         ((x)->flags & CHANNEL_NODELETE)
-#define IsSuspended(x)         ((x)->flags & CHANNEL_SUSPENDED)
+#define IsProtected(x)  ((x)->flags & CHANNEL_NODELETE)
+#define IsSuspended(x)  ((x)->flags & CHANNEL_SUSPENDED)
+#define IsOffChannel(x) (((x)->flags & CHANNEL_OFFCHANNEL) && (off_channel > 1))
+
+#define MAXADVTOPICENTRIES 9
 
 struct chanData
 {
-    struct chanNode    *channel;
+    struct chanNode     *channel;
     struct mod_chanmode modes;
 
-    time_t             registered;
-    time_t             visited;
-    time_t             limitAdjusted;
+    unsigned long       registered;
+    unsigned long       visited;
+    unsigned long       limitAdjusted;
+    unsigned long       ownerTransfer;
+    unsigned long       expiry;
+
+    char    *topic;
+    char    *greeting;
+    char    *user_greeting;
+    char    *registrar;
+    char    *topic_mask;
 
-    char               *topic;
-    char               *greeting;
-    char               *user_greeting;
-    char               *registrar;
-    char                *topic_mask;
+    char          *vote;
+    unsigned int  vote_start;
+    dict_t        vote_options;
 
-    unsigned int       flags : 30;
+    unsigned int        flags : 30;
     unsigned int        may_opchan : 1;
     unsigned int        max;
+    unsigned int        max_time;
     unsigned int        last_refresh;
     unsigned short      banCount;
     unsigned short      userCount;
     unsigned short      lvlOpts[NUM_LEVEL_OPTIONS];
     unsigned char       chOpts[NUM_CHAR_OPTIONS];
 
-    struct userData    *users;
-    struct banData     *bans;
+    char *advtopic[MAXADVTOPICENTRIES];
+
+    struct userData     *users;
+    struct banData      *bans;
     struct dict         *notes;
-    struct suspended   *suspended;
-    struct chanData    *prev;
-    struct chanData    *next;
+    struct suspended    *suspended;
+    struct giveownership *giveownership;
+    struct chanData     *prev;
+    struct chanData     *next;
 };
 
 #define USER_AUTO_OP            0x00000001
@@ -108,18 +131,22 @@ struct chanData
 
 struct userData
 {
-    struct handle_info *handle;
-    struct chanData    *channel;
+    struct handle_info  *handle;
+    struct chanData     *channel;
 
-    char               *info;
-    time_t             seen;
+    char                *info;
+    unsigned long       seen;
+    time_t             expires; /* suspend */
     unsigned short      access;
-    unsigned int       present : 1;
+    unsigned int        present : 1;
     unsigned int        flags : USER_FLAGS_SIZE;
 
+    unsigned short      voted;
+    unsigned int        votefor;
+
     /* linked list of userDatas for a chanData */
-    struct userData    *prev;
-    struct userData    *next;
+    struct userData     *prev;
+    struct userData     *next;
     /* linked list of userDatas for a handle_info */
     struct userData     *u_prev;
     struct userData     *u_next;
@@ -127,42 +154,73 @@ struct userData
 
 struct banData
 {
-    char               mask[NICKLEN + USERLEN + HOSTLEN + 3];
-    char               owner[NICKLEN+1];
-    struct chanData     *channel;
+    char            mask[NICKLEN + USERLEN + HOSTLEN + 3];
+    char            owner[NICKLEN+1];
+    struct chanData *channel;
 
-    time_t             set;
-    time_t             triggered;
-    time_t              expires;
+    unsigned long   set;
+    unsigned long   triggered;
+    unsigned long   expires;
 
-    char               *reason;
+    char            *reason;
 
-    struct banData     *prev;
-    struct banData     *next;
+    struct banData  *prev;
+    struct banData  *next;
 };
 
 struct suspended
 {
-    struct chanData    *cData;
-    char               *suspender;
+    struct chanData     *cData;
+    char                *suspender;
     char                *reason;
-    time_t              issued, expires, revoked;
+    unsigned long       issued;
+    unsigned long       expires;
+    unsigned long       revoked;
     struct suspended    *previous;
 };
 
+struct vote_option
+{
+    char                *name;
+    unsigned int        option_id;
+    char                *option_str;
+    unsigned int        voted;
+};
+
+struct giveownership
+{
+    char                 *staff_issuer;
+
+    char                  *old_owner;
+
+    char                  *target;
+    unsigned short        target_access;
+
+    time_t                issued;
+    char                  *reason;
+
+    struct giveownership  *previous;
+};
+
 struct do_not_register
 {
     char   chan_name[CHANNELLEN+1];
     char   setter[NICKSERV_HANDLE_LEN+1];
-    time_t set; 
+    unsigned long set;
+    unsigned long expires;
     char   reason[1];
 };
 
+#define GetChannelUser(channel, handle) _GetChannelUser(channel, handle, 1, 0)
+struct userData *_GetChannelUser(struct chanData *channel, struct handle_info *handle, int override, int allow_suspended);
+struct banData *add_channel_ban(struct chanData *channel, const char *mask, char *owner, unsigned long set, unsigned long triggered, unsigned long expires, char *reason);
 void init_chanserv(const char *nick);
 void del_channel_user(struct userData *user, int do_gc);
 struct channelList *chanserv_support_channels(void);
 unsigned short user_level_from_name(const char *name, unsigned short clamp_level);
 struct do_not_register *chanserv_is_dnr(const char *chan_name, struct handle_info *handle);
 int check_user_level(struct chanNode *channel, struct userNode *user, enum levelOption opt, int allow_override, int exempt_owner);
+struct mod_chanmode *find_matching_bans(struct banList *bans, struct userNode *actee, const char *mask);
+void handle_new_channel_created(char *chan, struct userNode *user);
 
 #endif