]> jfr.im git - solanum.git/blobdiff - src/channel.c
chmode: Remove chm_regonly, a vestige from ratbox which doesn't apply to native chary...
[solanum.git] / src / channel.c
index 7483b6e50f690b4f0bbfd7b62e0531f0e9741ecd..6151ec7e323c223cd121a076dd12c14bd16b3cb7 100644 (file)
@@ -96,6 +96,7 @@ void
 free_channel(struct Channel *chptr)
 {
        rb_free(chptr->chname);
+       rb_free(chptr->mode_lock);
        rb_bh_free(channel_heap, chptr);
 }
 
@@ -704,6 +705,7 @@ is_quieted(struct Channel *chptr, struct Client *who, struct membership *msptr,
  * input       - client to check, channel to check for, key
  * output      - reason for not being able to join, else 0
  * side effects -
+ * caveats      - this function should only be called on a local user.
  */
 int
 can_join(struct Client *source_p, struct Channel *chptr, char *key)
@@ -1073,10 +1075,9 @@ set_channel_topic(struct Channel *chptr, const char *topic, const char *topic_in
        }
 }
 
-/* channel_modes_real()
+/* channel_modes()
  *
  * inputs       - pointer to channel
- *              - pointer to channel Mode struct
  *              - pointer to client
  * output       - string with simple modes
  * side effects - result from previous calls overwritten
@@ -1084,7 +1085,7 @@ set_channel_topic(struct Channel *chptr, const char *topic, const char *topic_in
  * Stolen from ShadowIRCd 4 --nenolod
  */
 const char *
-channel_modes_real(struct Channel *chptr, struct Mode *mode, struct Client *client_p)
+channel_modes(struct Channel *chptr, struct Client *client_p)
 {
        int i;
        char buf1[BUFSIZE];
@@ -1097,40 +1098,40 @@ channel_modes_real(struct Channel *chptr, struct Mode *mode, struct Client *clie
        *pbuf = '\0';
 
        for (i = 0; i < 256; i++)
-               if(mode->mode & chmode_flags[i])
+               if(chptr->mode.mode & chmode_flags[i])
                        *mbuf++ = i;
 
-       if(mode->limit)
+       if(chptr->mode.limit)
        {
                *mbuf++ = 'l';
 
                if(!IsClient(client_p) || IsMember(client_p, chptr))
-                       pbuf += rb_sprintf(pbuf, " %d", mode->limit);
+                       pbuf += rb_sprintf(pbuf, " %d", chptr->mode.limit);
        }
 
-       if(*mode->key)
+       if(*chptr->mode.key)
        {
                *mbuf++ = 'k';
 
                if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
-                       pbuf += rb_sprintf(pbuf, " %s", mode->key);
+                       pbuf += rb_sprintf(pbuf, " %s", chptr->mode.key);
        }
 
-       if(mode->join_num)
+       if(chptr->mode.join_num)
        {
                *mbuf++ = 'j';
 
                if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
-                       pbuf += rb_sprintf(pbuf, " %d:%d", mode->join_num,
-                                          mode->join_time);
+                       pbuf += rb_sprintf(pbuf, " %d:%d", chptr->mode.join_num,
+                                          chptr->mode.join_time);
        }
 
-       if(*mode->forward && (ConfigChannel.use_forward || !IsClient(client_p)))
+       if(*chptr->mode.forward && (ConfigChannel.use_forward || !IsClient(client_p)))
        {
                *mbuf++ = 'f';
 
                if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
-                       pbuf += rb_sprintf(pbuf, " %s", mode->forward);
+                       pbuf += rb_sprintf(pbuf, " %s", chptr->mode.forward);
        }
 
        *mbuf = '\0';
@@ -1358,3 +1359,54 @@ send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
                        sendto_server(client_p, chptr, cap, nocap, "%s %s", modebuf, parabuf);
        }
 }
+
+void 
+resv_chan_forcepart(const char *name, const char *reason, int temp_time)
+{
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
+       struct Channel *chptr;
+       struct membership *msptr;
+       struct Client *target_p;
+
+       if(!ConfigChannel.resv_forcepart)
+               return;
+
+       /* for each user on our server in the channel list
+        * send them a PART, and notify opers.
+        */
+       chptr = find_channel(name);
+       if(chptr != NULL)
+       {
+               RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
+               {
+                       msptr = ptr->data;
+                       target_p = msptr->client_p;
+
+                       if(IsExemptResv(target_p))
+                               continue;
+
+                       sendto_server(target_p, chptr, CAP_TS6, NOCAPS,
+                                     ":%s PART %s", target_p->id, chptr->chname);
+
+                       sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :%s",
+                                            target_p->name, target_p->username,
+                                            target_p->host, chptr->chname, target_p->name);
+
+                       remove_user_from_channel(msptr);
+
+                       /* notify opers & user they were removed from the channel */
+                       sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                                            "Forced PART for %s!%s@%s from %s (%s)",
+                                            target_p->name, target_p->username, 
+                                            target_p->host, name, reason);
+
+                       if(temp_time > 0)
+                               sendto_one_notice(target_p, ":*** Channel %s is temporarily unavailable on this server.",
+                                          name);
+                       else
+                               sendto_one_notice(target_p, ":*** Channel %s is no longer available on this server.",
+                                          name);
+               }
+       }
+}