Commit Diff


commit - 342f20f88931d823088dccf5af45281df64e3c51
commit + ca32c1b311379445d1c8bee5705a9371cf2fa1a7
blob - f1634ae340a6ffd703353a3ca3b11d5dcd2e7c4a
blob + 155bae9921674652e9ed5d342209617339f63ac4
--- ChangeLog
+++ ChangeLog
@@ -12,6 +12,7 @@
 
 ngIRCd CVSHEAD
 
+  - Implementec numeric "333": Time and user name who set a channel topic.
   - Fixed server NOTICEs to users with "s" mode ("server messages").
   - Enhanced the handler for PING and PONG commands: fix forwarding and enable
     back-passing of a client supplied additional argument of PING.
@@ -637,4 +638,4 @@ ngIRCd 0.0.1, 31.12.2001
 
 
 -- 
-$Id: ChangeLog,v 1.291 2005/08/29 10:58:00 alex Exp $
+$Id: ChangeLog,v 1.292 2005/09/02 12:50:25 alex Exp $
blob - 3659b19f8c23dc4d7ae20ceaa1dcd01ae5a6adf5
blob + ac5eb5c4616370015d9f7c4ed679ddd67c7f64c8
--- src/ngircd/channel.c
+++ src/ngircd/channel.c
@@ -17,7 +17,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: channel.c,v 1.53 2005/07/31 20:13:08 alex Exp $";
+static char UNUSED id[] = "$Id: channel.c,v 1.54 2005/09/02 12:50:25 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -100,22 +100,25 @@ Channel_InitPredefined( void )
 			array_free(&Conf_Channel[i].topic);
 			continue;
 		}
-		
-		/* Channel anlegen */
-		chan = Channel_Create( Conf_Channel[i].name );
-		if( chan )
-		{
-			Channel_ModeAdd( chan, 'P' );
-			if (!array_copy(&chan->topic, &Conf_Channel[i].topic)) {
-				Log( LOG_WARNING, "Could not set topic for new pre-defined channel: %s",
-											strerror(errno));
-			}
+
+		/* Create channel */
+		chan = Channel_Create(Conf_Channel[i].name);
+		if (chan) {
+			Channel_ModeAdd(chan, 'P');
+
+			Channel_SetTopic(chan, NULL,
+					 array_start(&Conf_Channel[i].topic));
 			array_free(&Conf_Channel[i].topic);
+
 			c = Conf_Channel[i].modes;
-			while( *c ) Channel_ModeAdd( chan, *c++ );
-			Log( LOG_INFO, "Created pre-defined channel \"%s\".", Conf_Channel[i].name );
+			while (*c)
+				Channel_ModeAdd(chan, *c++);
+		
+			Log(LOG_INFO, "Created pre-defined channel \"%s\".",
+							Conf_Channel[i].name );
 		}
-		else Log( LOG_ERR, "Can't create pre-defined channel \"%s\"!", Conf_Channel[i].name );
+		else Log(LOG_ERR, "Can't create pre-defined channel \"%s\"!",
+							Conf_Channel[i].name );
 	}
 } /* Channel_InitPredefined */
 
@@ -634,10 +637,30 @@ Channel_Topic( CHANNEL *Chan )
 	ret = array_start(&Chan->topic);
 	return ret ? ret : "";
 } /* Channel_Topic */
+
+	
+#ifndef STRICT_RFC
+
+GLOBAL unsigned int
+Channel_TopicTime(CHANNEL *Chan)
+{
+	assert(Chan != NULL);
+	return (unsigned int) Chan->topic_time;
+} /* Channel_TopicTime */
 
 
+GLOBAL char *
+Channel_TopicWho(CHANNEL *Chan)
+{
+	assert(Chan != NULL);
+	return Chan->topic_who;
+} /* Channel_TopicWho */
+
+#endif
+
+
 GLOBAL void
-Channel_SetTopic( CHANNEL *Chan, char *Topic )
+Channel_SetTopic(CHANNEL *Chan, CLIENT *Client, char *Topic)
 {
 	size_t len;
 	assert( Chan != NULL );
@@ -648,9 +671,22 @@ Channel_SetTopic( CHANNEL *Chan, char *Topic )
 		array_free(&Chan->topic);
 
 	if (!array_copyb(&Chan->topic, Topic, len))
-		Log(LOG_WARNING, "could not set new Topic %s: %s", Topic, strerror(errno));
+		Log(LOG_WARNING, "could not set new Topic \"%s\" on %s: %s",
+					Topic, Chan->name, strerror(errno));
 
 	array_cat0(&Chan->topic);
+
+#ifndef STRICT_RFC
+	Chan->topic_time = time(NULL);
+	if (Client != NULL && Client_Type(Client) != CLIENT_SERVER)
+		strlcpy(Chan->topic_who, Client_ID(Client),
+			sizeof Chan->topic_who);
+	else
+		strlcpy(Chan->topic_who, DEFAULT_TOPIC_ID,
+			sizeof Chan->topic_who);
+#else
+	(void) Client;
+#endif
 } /* Channel_SetTopic */
 
 
blob - 493161b034cb1433fc2690b0e08e4a66259413fb
blob + 2f6e32513d60107c52dfa4e608a491cc492cbcd4
--- src/ngircd/channel.h
+++ src/ngircd/channel.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: channel.h,v 1.28 2005/07/28 16:23:55 fw Exp $
+ * $Id: channel.h,v 1.29 2005/09/02 12:50:25 alex Exp $
  *
  * Channel management (header)
  */
@@ -30,6 +30,10 @@ typedef struct _CHANNEL
 	UINT32 hash;			/* Hash of the (lowecase!) name */
 	char modes[CHANNEL_MODE_LEN];	/* Channel modes */
 	array topic;			/* Topic of the channel */
+#ifndef STRICT_RFC
+	time_t topic_time;		/* Time when topic was set */
+	char topic_who[CLIENT_NICK_LEN];/* Nickname of user that set topic */
+#endif
 	char key[CLIENT_PASS_LEN];	/* Channel key ("password", mode "k" ) */
 	long maxusers;			/* Maximum number of members (mode "l") */
 } CHANNEL;
@@ -72,7 +76,7 @@ GLOBAL char *Channel_Topic PARAMS(( CHANNEL *Chan ));
 GLOBAL char *Channel_Key PARAMS(( CHANNEL *Chan ));
 GLOBAL long Channel_MaxUsers PARAMS(( CHANNEL *Chan ));
 
-GLOBAL void Channel_SetTopic PARAMS(( CHANNEL *Chan, char *Topic ));
+GLOBAL void Channel_SetTopic PARAMS(( CHANNEL *Chan, CLIENT *Client, char *Topic ));
 GLOBAL void Channel_SetModes PARAMS(( CHANNEL *Chan, char *Modes ));
 GLOBAL void Channel_SetKey PARAMS(( CHANNEL *Chan, char *Key ));
 GLOBAL void Channel_SetMaxUsers PARAMS(( CHANNEL *Chan, long Count ));
@@ -105,7 +109,12 @@ GLOBAL bool Channel_Write PARAMS(( CHANNEL *Chan, CLIE
 
 GLOBAL CHANNEL *Channel_Create PARAMS(( char *Name ));
 
+#ifndef STRICT_RFC
+GLOBAL unsigned int Channel_TopicTime PARAMS(( CHANNEL *Chan ));
+GLOBAL char *Channel_TopicWho PARAMS(( CHANNEL *Chan ));
+#endif
 
+
 #endif
 
 
blob - 70800c3d65c4d2354eb9ce9662720786c4020678
blob + d314f1a969bef7c3d2676ef7a97559a7155b033f
--- src/ngircd/defines.h
+++ src/ngircd/defines.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: defines.h,v 1.56 2005/07/28 16:23:55 fw Exp $
+ * $Id: defines.h,v 1.57 2005/09/02 12:50:25 alex Exp $
  */
 
 
@@ -103,6 +103,8 @@
 #define DEFAULT_AWAY_MSG "Away"		/* Away message for users connected to
 					   linked servers. */
 
+#define DEFAULT_TOPIC_ID "-Server-"	/* Default ID for "topic owner". */
+
 #define CONFIG_FILE "/ngircd.conf"	/* Configuration file name. */
 #define MOTD_FILE "/ngircd.motd"	/* Name of the MOTD file. */
 #define MOTD_PHRASE ""			/* Default MOTD phrase string. */
blob - 4708af1d7fbcff86560e4d4af2e3fc05444464a1
blob + dbf26fe2bec01fe806e42962bb5cdf53d47610f9
--- src/ngircd/irc-channel.c
+++ src/ngircd/irc-channel.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-channel.c,v 1.30 2005/06/12 18:23:59 alex Exp $";
+static char UNUSED id[] = "$Id: irc-channel.c,v 1.31 2005/09/02 12:50:25 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -47,7 +47,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
 	bool is_new_chan, is_invited, is_banned;
 	CLIENT *target;
 	CHANNEL *chan;
-
+	
 	assert( Client != NULL );
 	assert( Req != NULL );
 
@@ -211,9 +211,18 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
 			/* an Client bestaetigen */
 			IRC_WriteStrClientPrefix( Client, target, "JOIN :%s", channame );
 
-			/* Topic an Client schicken */
-			topic = Channel_Topic( chan );
-			if( *topic ) IRC_WriteStrClient( Client, RPL_TOPIC_MSG, Client_ID( Client ), channame, topic );
+			/* Send topic to client, if any */
+			topic = Channel_Topic(chan);
+			if (*topic) {
+				IRC_WriteStrClient(Client, RPL_TOPIC_MSG,
+					Client_ID(Client), channame, topic);
+#ifndef STRICT_RFC
+				IRC_WriteStrClient(Client, RPL_TOPICSETBY_MSG,
+					Client_ID(Client), channame,
+					Channel_TopicWho(chan),
+					Channel_TopicTime(chan));
+#endif
+			}
 
 			/* Mitglieder an Client Melden */
 			IRC_Send_NAMES( Client, chan );
@@ -268,6 +277,7 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
 	CHANNEL *chan;
 	CLIENT *from;
 	char *topic;
+	bool r;
 
 	assert( Client != NULL );
 	assert( Req != NULL );
@@ -288,10 +298,22 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
 
 	if( Req->argc == 1 )
 	{
-		/* Topic erfragen */
-		topic = Channel_Topic( chan );
-		if( *topic ) return IRC_WriteStrClient( from, RPL_TOPIC_MSG, Client_ID( from ), Channel_Name( chan ), topic );
-		else return IRC_WriteStrClient( from, RPL_NOTOPIC_MSG, Client_ID( from ), Channel_Name( chan ));
+		/* Request actual topic */
+		topic = Channel_Topic(chan);
+		if (*topic) {
+			r = IRC_WriteStrClient(from, RPL_TOPIC_MSG,
+				Client_ID(Client), Channel_Name(chan), topic);
+#ifndef STRICT_RFC
+			r = IRC_WriteStrClient(from, RPL_TOPICSETBY_MSG,
+				Client_ID(Client), Channel_Name(chan),
+				Channel_TopicWho(chan),
+				Channel_TopicTime(chan));
+#endif
+			return r;
+		}
+		else
+			 return IRC_WriteStrClient(from, RPL_NOTOPIC_MSG,
+					Client_ID(from), Channel_Name(chan));
 	}
 
 	if( strchr( Channel_Modes( chan ), 't' ))
@@ -300,9 +322,11 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
 		if( ! strchr( Channel_UserModes( chan, from ), 'o' )) return IRC_WriteStrClient( from, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( from ), Channel_Name( chan ));
 	}
 
-	/* Topic setzen */
-	Channel_SetTopic( chan, Req->argv[1] );
-	Log( LOG_DEBUG, "User \"%s\" set topic on \"%s\": %s", Client_Mask( from ), Channel_Name( chan ), Req->argv[1][0] ? Req->argv[1] : "<none>" );
+	/* Set new topic */
+	Channel_SetTopic(chan, from, Req->argv[1]);
+	Log(LOG_DEBUG, "User \"%s\" set topic on \"%s\": %s",
+		Client_Mask(from), Channel_Name(chan),
+		Req->argv[1][0] ? Req->argv[1] : "<none>");
 
 	/* im Channel bekannt machen und an Server weiterleiten */
 	IRC_WriteStrServersPrefix( Client, from, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
@@ -478,8 +502,9 @@ IRC_CHANINFO( CLIENT *Client, REQUEST *Req )
 		if(( ! *ptr ) && ( Req->argv[arg_topic][0] ))
 		{
 			/* OK, there is no topic jet */
-			Channel_SetTopic( chan, Req->argv[arg_topic] );
-			IRC_WriteStrChannelPrefix( Client, chan, from, false, "TOPIC %s :%s", Req->argv[0], Channel_Topic( chan ));
+			Channel_SetTopic(chan, Client, Req->argv[arg_topic]);
+			IRC_WriteStrChannelPrefix(Client, chan, from, false,
+			     "TOPIC %s :%s", Req->argv[0], Channel_Topic(chan));
 		}
 	}
 
blob - c6847cf4ccd0395056ba38841d6c0f862049f082
blob + ee1eff67711c895defa38a56bd1e534df4f96a4f
--- src/ngircd/messages.h
+++ src/ngircd/messages.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: messages.h,v 1.66 2004/02/28 02:18:16 alex Exp $
+ * $Id: messages.h,v 1.67 2005/09/02 12:50:25 alex Exp $
  *
  * IRC numerics (Header)
  */
@@ -62,6 +62,7 @@
 #define RPL_CHANNELMODEIS_MSG		"324 %s %s +%s"
 #define RPL_NOTOPIC_MSG			"331 %s %s :No topic is set"
 #define RPL_TOPIC_MSG			"332 %s %s :%s"
+#define RPL_TOPICSETBY_MSG		"333 %s %s %s %u"
 #define RPL_INVITING_MSG		"341 %s %s %s"
 #define RPL_INVITELIST_MSG		"346 %s %s %s"
 #define RPL_ENDOFINVITELIST_MSG		"347 %s %s :End of channel invite list"