pidgin/pidgin

Remove some unused utility functions.

2019-11-04, Elliott Sales de Andrade
15c3354736c3
Parents 3682f08744da
Children cdce45867b10
Remove some unused utility functions.

* purple_escape_js was used for WebKit stuff, now gone.
* purple_ipv6_address_is_valid was removed earlier and the prototype was
accidentally left in.
* purple_markup_extract_info_field was used for MSN and Yahoo, now gone.
* purple_str_binary_to_ascii seems to be from MSN and/or Yahoo.
* purple_uts35_to_str was used for MSN, now gone.
--- a/ChangeLog.API Mon Nov 04 03:58:59 2019 +0000
+++ b/ChangeLog.API Mon Nov 04 02:16:33 2019 -0500
@@ -420,6 +420,7 @@
* purple_ip_address_is_valid, purple_ipv4_address_is_valid, and
purple_ipv6_address_is_valid. Use g_hostname_is_ip_address()
or #GInetAddress instead.
+ * purple_markup_extract_info_field
* PurpleMimeDocument, PurpleMimePart,
purple_mime_document_new, purple_mime_document_free,
purple_mime_document_parse, purple_mime_document_parsen,
@@ -496,6 +497,7 @@
* purple_status_type_set_primary_attr
* purple_strlcat
* purple_strlcpy
+ * purple_str_binary_to_ascii
* purple_str_size_to_units. Use g_format_size() instead.
* purple_timeout_*. Use g_timeout_* or g_idle_* instead.
* purple_txt_cancel
@@ -508,6 +510,7 @@
purple_util_fetch_url_request, instead.
* purple_util_get_image_checksum. Use
g_compute_checksum_for_data(G_CHECKSUM_SHA1, ...), instead.
+ * purple_uts35_to_str
* PurpleCertificateVerificationStatus.PURPLE_CERTIFICATE_INVALID
* PurpleConnectionUiOps.report_disconnect_reason
* PurplePluginProtocolInfo.add_buddy_with_invite
--- a/libpurple/core.c Mon Nov 04 03:58:59 2019 +0000
+++ b/libpurple/core.c Mon Nov 04 02:16:33 2019 -0500
@@ -249,7 +249,7 @@
purple_log_uninit();
_purple_message_uninit();
/* Everything after util_uninit cannot try to write things to the
- * confdir nor use purple_escape_js
+ * confdir.
*/
purple_util_uninit();
--- a/libpurple/util.c Mon Nov 04 03:58:59 2019 +0000
+++ b/libpurple/util.c Mon Nov 04 02:16:33 2019 -0500
@@ -35,15 +35,9 @@
static gchar *config_dir = NULL;
static gchar *data_dir = NULL;
-static JsonNode *escape_js_node = NULL;
-static JsonGenerator *escape_js_gen = NULL;
-
void
purple_util_init(void)
{
- escape_js_node = json_node_new(JSON_NODE_VALUE);
- escape_js_gen = json_generator_new();
- json_node_set_boolean(escape_js_node, FALSE);
}
void
@@ -65,12 +59,6 @@
g_free(data_dir);
data_dir = NULL;
-
- json_node_free(escape_js_node);
- escape_js_node = NULL;
-
- g_object_unref(escape_js_gen);
- escape_js_gen = NULL;
}
/**************************************************************************
@@ -573,333 +561,6 @@
return retval;
}
-char *
-purple_uts35_to_str(const char *format, size_t len, struct tm *tm)
-{
- GString *string;
- guint i, count;
-
- if (tm == NULL) {
- time_t now = time(NULL);
- tm = localtime(&now);
- }
-
- string = g_string_sized_new(len);
- i = 0;
- while (i < len) {
- count = 1;
- while ((i + count) < len && format[i] == format[i+count])
- count++;
-
- switch (format[i]) {
- /* Era Designator */
- case 'G':
- if (count <= 3) {
- /* Abbreviated */
- } else if (count == 4) {
- /* Full */
- } else if (count >= 5) {
- /* Narrow */
- count = 5;
- }
- break;
-
-
- /* Year */
- case 'y':
- if (count == 2) {
- /* Two-digits only */
- g_string_append(string, purple_utf8_strftime("%y", tm));
- } else {
- /* Zero-padding */
- g_string_append_printf(string, "%0*d",
- count,
- tm->tm_year + 1900);
- }
- break;
-
- /* Year (in "Week of Year" based calendars) */
- case 'Y':
- if (count == 2) {
- /* Two-digits only */
- } else {
- /* Zero-padding */
- }
- break;
-
- /* Extended Year */
- case 'u':
- break;
-
- /* Cyclic Year Name */
- case 'U':
- if (count <= 3) {
- /* Abbreviated */
- } else if (count == 4) {
- /* Full */
- } else if (count >= 5) {
- /* Narrow */
- count = 5;
- }
- break;
-
-
- /* Quarter */
- case 'Q':
- /* Stand-alone Quarter */
- case 'q':
- if (count <= 2) {
- /* Numerical */
- } else if (count == 3) {
- /* Abbreviation */
- } else if (count >= 4) {
- /* Full */
- count = 4;
- }
- break;
-
- /* Month */
- case 'M':
- /* Stand-alone Month */
- case 'L':
- if (count <= 2) {
- /* Numerical */
- g_string_append(string, purple_utf8_strftime("%m", tm));
- } else if (count == 3) {
- /* Abbreviation */
- g_string_append(string, purple_utf8_strftime("%b", tm));
- } else if (count == 4) {
- /* Full */
- g_string_append(string, purple_utf8_strftime("%B", tm));
- } else if (count >= 5) {
- g_string_append_len(string, purple_utf8_strftime("%b", tm), 1);
- count = 5;
- }
- break;
-
- /* Ignored */
- case 'l':
- break;
-
-
- /* Week of Year */
- case 'w':
- g_string_append(string, purple_utf8_strftime("%W", tm));
- count = MIN(count, 2);
- break;
-
- /* Week of Month */
- case 'W':
- count = 1;
- break;
-
-
- /* Day of Month */
- case 'd':
- g_string_append(string, purple_utf8_strftime("%d", tm));
- count = MIN(count, 2);
- break;
-
- /* Day of Year */
- case 'D':
- g_string_append(string, purple_utf8_strftime("%j", tm));
- count = MIN(count, 3);
- break;
-
- /* Day of Year in Month */
- case 'F':
- count = 1;
- break;
-
- /* Modified Julian Day */
- case 'g':
- break;
-
-
- /* Day of Week */
- case 'E':
- if (count <= 3) {
- /* Short */
- g_string_append(string, purple_utf8_strftime("%a", tm));
- } else if (count == 4) {
- /* Full */
- g_string_append(string, purple_utf8_strftime("%A", tm));
- } else if (count >= 5) {
- /* Narrow */
- g_string_append_len(string, purple_utf8_strftime("%a", tm), 1);
- count = 5;
- }
- break;
-
- /* Local Day of Week */
- case 'e':
- if (count <= 2) {
- /* Numeric */
- g_string_append(string, purple_utf8_strftime("%u", tm));
- } else if (count == 3) {
- /* Short */
- g_string_append(string, purple_utf8_strftime("%a", tm));
- } else if (count == 4) {
- /* Full */
- g_string_append(string, purple_utf8_strftime("%A", tm));
- } else if (count >= 5) {
- /* Narrow */
- g_string_append_len(string, purple_utf8_strftime("%a", tm), 1);
- count = 5;
- }
- break;
-
- /* Stand-alone Local Day of Week */
- case 'c':
- if (count <= 2) {
- /* Numeric */
- g_string_append(string, purple_utf8_strftime("%u", tm));
- count = 1;
- } else if (count == 3) {
- /* Short */
- g_string_append(string, purple_utf8_strftime("%a", tm));
- } else if (count == 4) {
- /* Full */
- g_string_append(string, purple_utf8_strftime("%A", tm));
- } else if (count >= 5) {
- /* Narrow */
- g_string_append_len(string, purple_utf8_strftime("%a", tm), 1);
- count = 5;
- }
- break;
-
-
- /* AM/PM */
- case 'a':
- g_string_append(string, purple_utf8_strftime("%p", tm));
- break;
-
-
- /* Hour (1-12) */
- case 'h':
- if (count == 1) {
- /* No padding */
- g_string_append(string, purple_utf8_strftime("%I", tm));
- } else if (count >= 2) {
- /* Zero-padded */
- g_string_append(string, purple_utf8_strftime("%I", tm));
- count = 2;
- }
- break;
-
- /* Hour (0-23) */
- case 'H':
- if (count == 1) {
- /* No padding */
- g_string_append(string, purple_utf8_strftime("%H", tm));
- } else if (count >= 2) {
- /* Zero-padded */
- g_string_append(string, purple_utf8_strftime("%H", tm));
- count = 2;
- }
- break;
-
- /* Hour (0-11) */
- case 'K':
- /* Hour (1-24) */
- case 'k':
- if (count == 1) {
- /* No padding */
- } else if (count >= 2) {
- /* Zero-padded */
- count = 2;
- }
- break;
-
- /* Hour (hHkK by locale) */
- case 'j':
- break;
-
-
- /* Minute */
- case 'm':
- g_string_append(string, purple_utf8_strftime("%M", tm));
- count = MIN(count, 2);
- break;
-
-
- /* Second */
- case 's':
- g_string_append(string, purple_utf8_strftime("%S", tm));
- count = MIN(count, 2);
- break;
-
- /* Fractional Sub-second */
- case 'S':
- break;
-
- /* Millisecond */
- case 'A':
- break;
-
-
- /* Time Zone (specific non-location format) */
- case 'z':
- if (count <= 3) {
- /* Short */
- } else if (count >= 4) {
- /* Full */
- count = 4;
- }
- break;
-
- /* Time Zone */
- case 'Z':
- if (count <= 3) {
- /* RFC822 */
- g_string_append(string, purple_utf8_strftime("%z", tm));
- } else if (count == 4) {
- /* Localized GMT */
- } else if (count >= 5) {
- /* ISO8601 */
- g_string_append(string, purple_utf8_strftime("%z", tm));
- count = 5;
- }
- break;
-
- /* Time Zone (generic non-location format) */
- case 'v':
- if (count <= 3) {
- /* Short */
- g_string_append(string, purple_utf8_strftime("%Z", tm));
- count = 1;
- } else if (count >= 4) {
- /* Long */
- g_string_append(string, purple_utf8_strftime("%Z", tm));
- count = 4;
- }
- break;
-
- /* Time Zone */
- case 'V':
- if (count <= 3) {
- /* Same as z */
- count = 1;
- } else if (count >= 4) {
- /* Generic Location Format) */
- g_string_append(string, purple_utf8_strftime("%Z", tm));
- count = 4;
- }
- break;
-
-
- default:
- g_string_append_len(string, format + i, count);
- break;
- }
-
- i += count;
- }
-
- return g_string_free(string, FALSE);
-}
-
-
/**************************************************************************
* Markup Functions
**************************************************************************/
@@ -1282,100 +943,6 @@
return found;
}
-gboolean
-purple_markup_extract_info_field(const char *str, int len, PurpleNotifyUserInfo *user_info,
- const char *start_token, int skip,
- const char *end_token, char check_value,
- const char *no_value_token,
- const char *display_name, gboolean is_link,
- const char *link_prefix,
- PurpleInfoFieldFormatCallback format_cb)
-{
- const char *p, *q;
-
- g_return_val_if_fail(str != NULL, FALSE);
- g_return_val_if_fail(user_info != NULL, FALSE);
- g_return_val_if_fail(start_token != NULL, FALSE);
- g_return_val_if_fail(end_token != NULL, FALSE);
- g_return_val_if_fail(display_name != NULL, FALSE);
-
- p = strstr(str, start_token);
-
- if (p == NULL)
- return FALSE;
-
- p += strlen(start_token) + skip;
-
- if (p >= str + len)
- return FALSE;
-
- if (check_value != '\0' && *p == check_value)
- return FALSE;
-
- q = strstr(p, end_token);
-
- /* Trim leading blanks */
- while (*p != '\n' && g_ascii_isspace(*p)) {
- p += 1;
- }
-
- /* Trim trailing blanks */
- while (q > p && g_ascii_isspace(*(q - 1))) {
- q -= 1;
- }
-
- /* Don't bother with null strings */
- if (p == q)
- return FALSE;
-
- if (q != NULL && (!no_value_token ||
- strncmp(p, no_value_token, strlen(no_value_token)))) {
- GString *dest = g_string_new("");
-
- if (is_link)
- {
- g_string_append(dest, "<a href=\"");
-
- if (link_prefix)
- g_string_append(dest, link_prefix);
-
- if (format_cb != NULL)
- {
- char *reformatted = format_cb(p, q - p);
- g_string_append(dest, reformatted);
- g_free(reformatted);
- }
- else
- g_string_append_len(dest, p, q - p);
- g_string_append(dest, "\">");
-
- if (link_prefix)
- g_string_append(dest, link_prefix);
-
- g_string_append_len(dest, p, q - p);
- g_string_append(dest, "</a>");
- }
- else
- {
- if (format_cb != NULL)
- {
- char *reformatted = format_cb(p, q - p);
- g_string_append(dest, reformatted);
- g_free(reformatted);
- }
- else
- g_string_append_len(dest, p, q - p);
- }
-
- purple_notify_user_info_add_pair_html(user_info, display_name, dest->str);
- g_string_free(dest, TRUE);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
struct purple_parse_tag {
char *src_tag;
char *dest_tag;
@@ -3351,27 +2918,6 @@
}
-char *
-purple_str_binary_to_ascii(const unsigned char *binary, guint len)
-{
- GString *ret;
- guint i;
-
- g_return_val_if_fail(len > 0, NULL);
-
- ret = g_string_sized_new(len);
-
- for (i = 0; i < len; i++)
- if (binary[i] < 32 || binary[i] > 126)
- g_string_append_printf(ret, "\\x%02x", binary[i] & 0xFF);
- else if (binary[i] == '\\')
- g_string_append(ret, "\\\\");
- else
- g_string_append_c(ret, binary[i]);
-
- return g_string_free(ret, FALSE);
-}
-
size_t
purple_utf16_size(const gunichar2 *str)
{
@@ -4146,18 +3692,6 @@
return buf;
}
-gchar * purple_escape_js(const gchar *str)
-{
- gchar *escaped;
-
- json_node_set_string(escape_js_node, str);
- json_generator_set_root(escape_js_gen, escape_js_node);
- escaped = json_generator_to_data(escape_js_gen, NULL);
- json_node_set_boolean(escape_js_node, FALSE);
-
- return escaped;
-}
-
void purple_restore_default_signal_handlers(void)
{
#ifndef _WIN32
--- a/libpurple/util.h Mon Nov 04 03:58:59 2019 +0000
+++ b/libpurple/util.h Mon Nov 04 02:16:33 2019 -0500
@@ -306,21 +306,6 @@
*/
GDateTime *purple_str_to_date_time(const char *timestamp, gboolean utc);
-/**
- * purple_uts35_to_str:
- * @format: The formatting string, according to UTS \#35
- * See http://unicode.org/reports/tr35/
- * (NOTE: not all formats are supported)
- * @len: The length of the formatting string
- * @tm: The time to format, or %NULL to use the current local time
- *
- * Formats a datetime according to a UTS-35 Date Format Pattern.
- *
- * Returns: The time, formatted as per the user's settings.
- */
-char *purple_uts35_to_str(const char *format, size_t len, struct tm *tm);
-
-
/**************************************************************************/
/* Markup Functions */
/**************************************************************************/
@@ -362,38 +347,6 @@
GData **attributes);
/**
- * purple_markup_extract_info_field:
- * @str: The string to parse.
- * @len: The size of str.
- * @user_info: The destination PurpleNotifyUserInfo to which the new
- * field info should be added.
- * @start_token: The beginning token.
- * @skip: The number of characters to skip after the
- * start token.
- * @end_token: The ending token.
- * @check_value: The value that the last character must meet.
- * @no_value_token: The token indicating no value is given.
- * @display_name: The short descriptive name to display for this token.
- * @is_link: TRUE if this should be a link, or FALSE otherwise.
- * @link_prefix: The prefix for the link.
- * @format_cb: (scope call): A callback to format the value before adding it.
- *
- * Extracts a field of data from HTML.
- *
- * This is a scary function. It used to be used for MSN and Yahoo prpls,
- * but since those prpls have been removed, this is now deprecated.
- *
- * Returns: TRUE if successful, or FALSE otherwise.
- */
-gboolean purple_markup_extract_info_field(const char *str, int len, PurpleNotifyUserInfo *user_info,
- const char *start_token, int skip,
- const char *end_token, char check_value,
- const char *no_value_token,
- const char *display_name, gboolean is_link,
- const char *link_prefix,
- PurpleInfoFieldFormatCallback format_cb);
-
-/**
* purple_markup_html_to_xhtml:
* @html: The HTML markup.
* @dest_xhtml: The destination XHTML output.
@@ -1157,22 +1110,6 @@
char *purple_str_seconds_to_string(guint sec);
/**
- * purple_str_binary_to_ascii:
- * @binary: A string of random data, possibly with embedded NULs
- * and such.
- * @len: The length in bytes of the input string. Must not be 0.
- *
- * Converts a binary string into a NUL terminated ascii string,
- * replacing nonascii characters and characters below SPACE (including
- * NUL) into \\xyy, where yy are two hex digits. Also backslashes are
- * changed into two backslashes (\\\\). The returned, newly allocated
- * string can be outputted to the console, and must be g_free()d.
- *
- * Returns: A newly allocated ASCIIZ string.
- */
-char *purple_str_binary_to_ascii(const unsigned char *binary, guint len);
-
-/**
* purple_utf16_size:
* @str: String to check.
*
@@ -1244,16 +1181,6 @@
gboolean purple_email_is_valid(const char *address);
/**
- * purple_ipv6_address_is_valid:
- * @ip: The IP address to validate.
- *
- * Checks if the given IP address is a syntactically valid IPv6 address.
- *
- * Returns: True if the IP address is syntactically correct.
- */
-gboolean purple_ipv6_address_is_valid(const char *ip);
-
-/**
* purple_uri_list_extract_uris:
* @uri_list: An uri-list in the standard format.
*
@@ -1421,16 +1348,6 @@
const char *purple_escape_filename(const char *str);
/**
- * purple_escape_js:
- * @str: The string to escape.
- *
- * Escapes javascript-unfriendly substrings from a string.
- *
- * Returns: The javascript-safe string (must be g_free'd after use).
- */
-gchar * purple_escape_js(const gchar *str);
-
-/**
* purple_restore_default_signal_handlers:
*
* Restore default signal handlers for signals which might reasonably have