--- a/libpurple/protocols/facebook/api.c Wed Dec 16 14:04:26 2015 -0500
+++ b/libpurple/protocols/facebook/api.c Wed Dec 16 15:13:36 2015 -0500
@@ -717,7 +717,7 @@
fb_http_params_set_str(params, "format", "json");
fb_http_params_set_str(params, "method", method);
- val = fb_util_locale_str();
+ val = fb_util_get_locale(); fb_http_params_set_str(params, "locale", val);
@@ -919,7 +919,7 @@
fb_thrift_write_stop(thft);
bytes = fb_thrift_get_bytes(thft);
- cytes = fb_util_zcompress(bytes, &err);
+ cytes = fb_util_zlib_deflate(bytes, &err); FB_API_ERROR_EMIT(api, err,
@@ -1619,10 +1619,10 @@
{"/t_p", fb_api_cb_publish_p}
- comp = fb_util_zcompressed(pload);
+ comp = fb_util_zlib_test(pload); - bytes = fb_util_zuncompress(pload, &err);
+ bytes = fb_util_zlib_inflate(pload, &err); FB_API_ERROR_EMIT(api, err, return);
bytes = (GByteArray*) pload;
@@ -1685,7 +1685,7 @@
- priv->cid = fb_util_randstr(32);
+ priv->cid = fb_util_rand_alnum(32); @@ -2127,7 +2127,7 @@
bytes = g_byte_array_new_take((guint8*) msg, strlen(msg));
- cytes = fb_util_zcompress(bytes, &err);
+ cytes = fb_util_zlib_deflate(bytes, &err); FB_API_ERROR_EMIT(api, err,
g_byte_array_free(bytes, TRUE);
--- a/libpurple/protocols/facebook/id.h Wed Dec 16 14:04:26 2015 -0500
+++ b/libpurple/protocols/facebook/id.h Wed Dec 16 15:13:36 2015 -0500
@@ -93,7 +93,7 @@
* Return: #TRUE if the string is an #FbId, otherwise #FALSE.
-#define FB_ID_IS_STR(s) fb_util_str_is(s, G_ASCII_DIGIT)
+#define FB_ID_IS_STR(s) fb_util_strtest(s, G_ASCII_DIGIT) --- a/libpurple/protocols/facebook/util.c Wed Dec 16 14:04:26 2015 -0500
+++ b/libpurple/protocols/facebook/util.c Wed Dec 16 15:13:36 2015 -0500
@@ -244,7 +244,7 @@
-fb_util_locale_str(void)
+fb_util_get_locale(void) const gchar * const *langs;
@@ -272,7 +272,7 @@
-fb_util_randstr(gsize size)
+fb_util_rand_alnum(guint len) @@ -285,19 +285,16 @@
static const gsize charc = G_N_ELEMENTS(chars) - 1;
- if (G_UNLIKELY(size < 1)) {
+ g_return_val_if_fail(len > 0, NULL); + ret = g_new(gchar, len + 1);
- ret = g_new(gchar, size + 1);
- for (i = 0; i < size; i++) {
+ for (i = 0; i < len; i++) { j = g_rand_int_range(rand, 0, charc);
@@ -463,7 +460,7 @@
-fb_util_str_is(const gchar *str, GAsciiType type)
+fb_util_strtest(const gchar *str, GAsciiType type) @@ -484,7 +481,7 @@
-fb_util_zcompressed(const GByteArray *bytes)
+fb_util_zlib_test(const GByteArray *bytes) @@ -503,7 +500,7 @@
-fb_util_zconv(GConverter *conv, const GByteArray *bytes, GError **error)
+fb_util_zlib_conv(GConverter *conv, const GByteArray *bytes, GError **error) @@ -546,25 +543,25 @@
-fb_util_zcompress(const GByteArray *bytes, GError **error)
+fb_util_zlib_deflate(const GByteArray *bytes, GError **error) conv = g_zlib_compressor_new(G_ZLIB_COMPRESSOR_FORMAT_ZLIB, -1);
- ret = fb_util_zconv(G_CONVERTER(conv), bytes, error);
+ ret = fb_util_zlib_conv(G_CONVERTER(conv), bytes, error); -fb_util_zuncompress(const GByteArray *bytes, GError **error)
+fb_util_zlib_inflate(const GByteArray *bytes, GError **error) conv = g_zlib_decompressor_new(G_ZLIB_COMPRESSOR_FORMAT_ZLIB);
- ret = fb_util_zconv(G_CONVERTER(conv), bytes, error);
+ ret = fb_util_zlib_conv(G_CONVERTER(conv), bytes, error); --- a/libpurple/protocols/facebook/util.h Wed Dec 16 14:04:26 2015 -0500
+++ b/libpurple/protocols/facebook/util.h Wed Dec 16 15:13:36 2015 -0500
@@ -216,7 +216,7 @@
* Gets the locale string (ex: en_US) from the system. The returned
* string should be freed with #g_free() when no longer needed.
@@ -224,19 +224,20 @@
* Returns: The locale string.
-fb_util_locale_str(void);
+fb_util_get_locale(void);
- * @size: The size of the string.
+ * @len: The length of the string. - * Gets a random alphanumeric string. The returned string should be
- * freed with #g_free() when no longer needed.
+ * Gets a random alphanumeric (A-Za-z0-9) string. This function should + * *not* be relied on for cryptographic operations. The returned string + * should be freed with #g_free() when no longer needed. - * Returns: The random string.
+ * Returns: The alphanumeric string. -fb_util_randstr(gsize size);
+fb_util_rand_alnum(guint len); @@ -295,52 +296,55 @@
* @type: The #GAsciiType.
- * Determines if @str abides to the #GAsciiType.
+ * Tests if the string only contains characters allowed by the + * #GAsciiType. More than one type can be specified by ORing the types - * Returns: #TRUE if the string abides to @type, otherwise #FALSE.
+ * Returns: #TRUE if the string only contains characters allowed by the + * #GAsciiType, otherwise #FALSE. -fb_util_str_is(const gchar *str, GAsciiType type);
+fb_util_strtest(const gchar *str, GAsciiType type);
* @bytes: The #GByteArray.
- * Determines if the #GByteArray is zlib compressed.
+ * Tests if the #GByteArray is zlib compressed. * Returns: #TRUE if the #GByteArray is compressed, otherwise #FALSE.
-fb_util_zcompressed(const GByteArray *bytes);
+fb_util_zlib_test(const GByteArray *bytes);
+ * fb_util_zlib_deflate: * @bytes: The #GByteArray.
* @error: The return location for the #GError or #NULL.
- * Compresses a #GByteArray with zlib. The returned #GByteArray should
- * be freed with #g_byte_array_free() when no longer needed.
+ * Deflates a #GByteArray with zlib. The returned #GByteArray should be + * freed with #g_byte_array_free() when no longer needed. - * Returns: The compressed #GByteArray.
+ * Returns: The deflated #GByteArray or #NULL on error. -fb_util_zcompress(const GByteArray *bytes, GError **error);
+fb_util_zlib_deflate(const GByteArray *bytes, GError **error);
+ * fb_util_zlib_inflate: * @bytes: The #GByteArray.
* @error: The return location for the #GError or #NULL.
- * Uncompresses a #GByteArray with zlib. The returned #GByteArray
- * should be freed with #g_byte_array_free() when no longer needed.
+ * Inflates a #GByteArray with zlib. The returned #GByteArray should be + * freed with #g_byte_array_free() when no longer needed. - * Returns: The uncompressed #GByteArray or #NULL on error.
+ * Returns: The inflated #GByteArray or #NULL on error. -fb_util_zuncompress(const GByteArray *bytes, GError **error);
+fb_util_zlib_inflate(const GByteArray *bytes, GError **error); #endif /* _FACEBOOK_UTIL_H_ */