changeset 13356:554575d1f9b5

[gaim-migrate @ 15729] Move gaim_str_sub_away_formatters into the oscar PRPL. It wasn't used anywhere else. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 01 Mar 2006 05:13:26 +0000
parents d278dac585a5
children af03d3b20cd2
files plugins/perl/common/Util.xs src/protocols/oscar/oscar.c src/util.c src/util.h
diffstat 4 files changed, 70 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/perl/common/Util.xs	Wed Mar 01 04:08:17 2006 +0000
+++ b/plugins/perl/common/Util.xs	Wed Mar 01 05:13:26 2006 +0000
@@ -176,11 +176,6 @@
 	char *str
 	char thechar
 
-gchar *
-gaim_str_sub_away_formatters(str, name)
-	const char *str
-	const char *name
-
 time_t
 gaim_str_to_time(timestamp, utc = FALSE, tm = NULL, tz_off = NULL, rest = NULL)
 	const char *timestamp
--- a/src/protocols/oscar/oscar.c	Wed Mar 01 04:08:17 2006 +0000
+++ b/src/protocols/oscar/oscar.c	Wed Mar 01 05:13:26 2006 +0000
@@ -618,6 +618,70 @@
 	return;
 }
 
+/**
+ * Looks for %n, %d, or %t in a string, and replaces them with the
+ * specified name, date, and time, respectively.
+ *
+ * @param str  The string that may contain the special variables.
+ * @param name The sender name.
+ *
+ * @return A newly allocated string where the special variables are
+ *         expanded.  This should be g_free'd by the caller.
+ */
+static gchar *
+gaim_str_sub_away_formatters(const char *str, const char *name)
+{
+	char *c;
+	GString *cpy;
+	time_t t;
+	struct tm *tme;
+
+	g_return_val_if_fail(str  != NULL, NULL);
+	g_return_val_if_fail(name != NULL, NULL);
+
+	/* Create an empty GString that is hopefully big enough for most messages */
+	cpy = g_string_sized_new(1024);
+
+	t = time(NULL);
+	tme = localtime(&t);
+
+	c = (char *)str;
+	while (*c) {
+		switch (*c) {
+		case '%':
+			if (*(c + 1)) {
+				switch (*(c + 1)) {
+				case 'n':
+					/* append name */
+					g_string_append(cpy, name);
+					c++;
+					break;
+				case 'd':
+					/* append date */
+					g_string_append(cpy, gaim_date_format_short(tme));
+					c++;
+					break;
+				case 't':
+					/* append time */
+					g_string_append(cpy, gaim_time_format(tme));
+					c++;
+					break;
+				default:
+					g_string_append_c(cpy, *c);
+				}
+			} else {
+				g_string_append_c(cpy, *c);
+			}
+			break;
+		default:
+			g_string_append_c(cpy, *c);
+		}
+		c++;
+	}
+
+	return g_string_free(cpy, FALSE);
+}
+
 static gchar *oscar_caps_to_string(guint caps)
 {
 	GString *str;
@@ -6443,6 +6507,12 @@
 	char *tmp1, *tmp2;
 
 	if (imflags & GAIM_MESSAGE_AUTO_RESP)
+		/*
+		 * TODO: Do this earlier in the IM-sending chain of events.
+		 *       We should attach to an IM-sending signal and do it
+		 *       there.  As it is currently implemented, encrypted
+		 *       messages are not substituted.
+		 */
 		tmp1 = gaim_str_sub_away_formatters(message, name);
 	else
 		tmp1 = g_strdup(message);
--- a/src/util.c	Wed Mar 01 04:08:17 2006 +0000
+++ b/src/util.c	Wed Mar 01 05:13:26 2006 +0000
@@ -2672,60 +2672,6 @@
 }
 
 gchar *
-gaim_str_sub_away_formatters(const char *str, const char *name)
-{
-	char *c;
-	GString *cpy;
-	time_t t;
-	struct tm *tme;
-
-	g_return_val_if_fail(str  != NULL, NULL);
-	g_return_val_if_fail(name != NULL, NULL);
-
-	/* Create an empty GString that is hopefully big enough for most messages */
-	cpy = g_string_sized_new(1024);
-
-	t = time(NULL);
-	tme = localtime(&t);
-
-	c = (char *)str;
-	while (*c) {
-		switch (*c) {
-		case '%':
-			if (*(c + 1)) {
-				switch (*(c + 1)) {
-				case 'n':
-					/* append name */
-					g_string_append(cpy, name);
-					c++;
-					break;
-				case 'd':
-					/* append date */
-					g_string_append(cpy, gaim_date_format_short(tme));
-					c++;
-					break;
-				case 't':
-					/* append time */
-					g_string_append(cpy, gaim_time_format(tme));
-					c++;
-					break;
-				default:
-					g_string_append_c(cpy, *c);
-				}
-			} else {
-				g_string_append_c(cpy, *c);
-			}
-			break;
-		default:
-			g_string_append_c(cpy, *c);
-		}
-		c++;
-	}
-
-	return g_string_free(cpy, FALSE);
-}
-
-gchar *
 gaim_strdup_withhtml(const gchar *src)
 {
 	gulong destsize, i, j;
--- a/src/util.h	Wed Mar 01 04:08:17 2006 +0000
+++ b/src/util.h	Wed Mar 01 05:13:26 2006 +0000
@@ -654,18 +654,6 @@
 gboolean gaim_str_has_suffix(const char *s, const char *x);
 
 /**
- * Looks for %n, %d, or %t in a string, and replaces them with the
- * specified name, date, and time, respectively.
- *
- * @param str  The string that may contain the special variables.
- * @param name The sender name.
- *
- * @return A newly allocated string where the special variables are
- *         expanded.  This should be g_free'd by the caller.
- */
-gchar *gaim_str_sub_away_formatters(const char *str, const char *name);
-
-/**
  * Duplicates a string and replaces all newline characters from the
  * source string with HTML linebreaks.
  *