libpurple/util.h

changeset 39120
cf4633d588f7
parent 39115
53435f0bef6c
parent 39027
2dcbddd76a80
child 39122
f18928dc403f
--- a/libpurple/util.h	Fri Feb 16 18:30:15 2018 +0300
+++ b/libpurple/util.h	Thu May 31 16:50:27 2018 +0300
@@ -367,17 +367,6 @@
 const char *purple_utf8_strftime(const char *format, const struct tm *tm);
 
 /**
- * purple_get_tzoff_str:
- * @tm:   The time to get the timezone for
- * @iso:  TRUE to format the offset according to ISO-8601, FALSE to
- *             not substitute 'Z' for 0 offset, and to not separate
- *             hours and minutes with a colon.
- *
- * Gets a string representation of the local timezone offset
- */
-const char *purple_get_tzoff_str(const struct tm *tm, gboolean iso);
-
-/**
  * purple_date_format_short:
  * @tm: The time to format, or %NULL to use the current local time
  *
@@ -754,11 +743,14 @@
  * purple_user_dir:
  *
  * Returns the purple settings directory in the user's home directory.
- * This is usually ~/.purple
+ * This is usually $HOME/.purple
  *
  *  See purple_home_dir()
  *
  * Returns: The purple settings directory.
+ * 
+ * Deprecated: Use purple_cache_dir(), purple_config_dir() or
+ *             purple_data_dir() instead.
  */
 const char *purple_user_dir(void);
 
@@ -766,37 +758,51 @@
  * purple_cache_dir:
  *
  * Returns the purple cache directory according to XDG Base Directory Specification.
- * This is usually ~/.cache/purple.
+ * This is usually $HOME/.cache/purple.
  * If custom user dir was specified then this is cache
  * sub-directory of DIR argument passed to -c option.
  *
  * Returns: The purple cache directory.
  */
-const char *purple_cache_dir(void);
+const gchar *purple_cache_dir(void);
 
 /**
  * purple_config_dir:
  *
  * Returns the purple configuration directory according to XDG Base Directory Specification.
- * This is usually ~/.config/purple.
+ * This is usually $HOME/.config/purple.
  * If custom user dir was specified then this is config
  * sub-directory of DIR argument passed to -c option.
  *
  * Returns: The purple configuration directory.
  */
-const char *purple_config_dir(void);
+const gchar *purple_config_dir(void);
 
 /**
  * purple_data_dir:
  *
  * Returns the purple data directory according to XDG Base Directory Specification.
- * This is usually ~/.local/share/purple.
+ * This is usually $HOME/.local/share/purple.
  * If custom user dir was specified then this is data
  * sub-directory of DIR argument passed to -c option.
  *
  * Returns: The purple data directory.
  */
-const char *purple_data_dir(void);
+const gchar *purple_data_dir(void);
+
+/**
+ * purple_move_to_xdg_base_dir:
+ * @purple_xdg_dir: The path to cache, config or data dir.
+ *                  Use respective function
+ * @path:           File or directory in purple_user_dir
+ * 
+ * Moves file or directory from legacy user dir to XDG
+ * based dir.
+ * 
+ * Returns: TRUE if moved successfully, FALSE otherwise
+ */
+gboolean
+purple_move_to_xdg_base_dir(const char *purple_xdg_dir, char *path);
 
 /**
  * purple_util_set_user_dir:
@@ -822,7 +828,7 @@
 /**
  * purple_util_write_data_to_file:
  * @filename: The basename of the file to write in the purple_user_dir.
- * @data:     A null-terminated string of data to write.
+ * @data:     A string of data to write.
  * @size:     The size of the data to save.  If data is
  *                 null-terminated you can pass in -1.
  *
@@ -834,6 +840,10 @@
  * should work fine for saving binary files as well.
  *
  * Returns: TRUE if the file was written successfully.  FALSE otherwise.
+ * 
+ * Deprecated: Use purple_util_write_data_to_cache_file(),
+ *             purple_util_write_data_to_config_file() or
+ *             purple_util_write_data_to_data_file() instead.
  */
 gboolean purple_util_write_data_to_file(const char *filename, const char *data,
 									  gssize size);
@@ -841,7 +851,7 @@
 /**
  * purple_util_write_data_to_cache_file:
  * @filename: The basename of the file to write in the purple_cache_dir.
- * @data:     A null-terminated string of data to write.
+ * @data:     A string of data to write.
  * @size:     The size of the data to save.  If data is
  *                 null-terminated you can pass in -1.
  *
@@ -858,7 +868,7 @@
 /**
  * purple_util_write_data_to_config_file:
  * @filename: The basename of the file to write in the purple_config_dir.
- * @data:     A null-terminated string of data to write.
+ * @data:     A string of data to write.
  * @size:     The size of the data to save.  If data is
  *                 null-terminated you can pass in -1.
  *
@@ -875,7 +885,7 @@
 /**
  * purple_util_write_data_to_data_file:
  * @filename: The basename of the file to write in the purple_data_dir.
- * @data:     A null-terminated string of data to write.
+ * @data:     A string of data to write.
  * @size:     The size of the data to save.  If data is
  *                 null-terminated you can pass in -1.
  *
@@ -892,7 +902,7 @@
 /**
  * purple_util_write_data_to_file_absolute:
  * @filename_full: Filename to write to
- * @data:          A null-terminated string of data to write.
+ * @data:          A string of data to write.
  * @size:          The size of the data to save.  If data is
  *                      null-terminated you can pass in -1.
  *
@@ -923,11 +933,69 @@
  *
  * Returns: An PurpleXmlNode tree of the contents of the given file.  Or NULL, if
  *         the file does not exist or there was an error reading the file.
+ * 
+ * Deprecated: Use purple_util_read_xml_from_cache_file(),
+ *             purple_util_read_xml_from_config_file() or
+ *             purple_util_read_xml_from_data_file() instead.
  */
 PurpleXmlNode *purple_util_read_xml_from_file(const char *filename,
 									  const char *description);
 
 /**
+ * purple_util_read_xml_from_cache_file:
+ * @filename:    The basename of the file to open in the purple_cache_dir.
+ * @description: A very short description of the contents of this
+ *                    file.  This is used in error messages shown to the
+ *                    user when the file can not be opened.  For example,
+ *                    "preferences," or "buddy pounces."
+ *
+ * Read the contents of a given file and parse the results into an
+ * PurpleXmlNode tree structure.  This is intended to be used to read
+ * Purple's cache xml files (xmpp-caps.xml, etc.)
+ *
+ * Returns: An PurpleXmlNode tree of the contents of the given file.  Or NULL, if
+ *         the file does not exist or there was an error reading the file.
+ */
+PurpleXmlNode *
+purple_util_read_xml_from_cache_file(const char *filename, const char *description);
+
+/**
+ * purple_util_read_xml_from_config_file:
+ * @filename:    The basename of the file to open in the purple_config_dir.
+ * @description: A very short description of the contents of this
+ *                    file.  This is used in error messages shown to the
+ *                    user when the file can not be opened.  For example,
+ *                    "preferences," or "buddy pounces."
+ *
+ * Read the contents of a given file and parse the results into an
+ * PurpleXmlNode tree structure.  This is intended to be used to read
+ * Purple's config xml files (prefs.xml, pounces.xml, etc.)
+ *
+ * Returns: An PurpleXmlNode tree of the contents of the given file.  Or NULL, if
+ *         the file does not exist or there was an error reading the file.
+ */
+PurpleXmlNode *
+purple_util_read_xml_from_config_file(const char *filename, const char *description);
+
+/**
+ * purple_util_read_xml_from_data_file:
+ * @filename:    The basename of the file to open in the purple_data_dir.
+ * @description: A very short description of the contents of this
+ *                    file.  This is used in error messages shown to the
+ *                    user when the file can not be opened.  For example,
+ *                    "preferences," or "buddy pounces."
+ *
+ * Read the contents of a given file and parse the results into an
+ * PurpleXmlNode tree structure.  This is intended to be used to read
+ * Purple's cache xml files (accounts.xml, etc.)
+ *
+ * Returns: An PurpleXmlNode tree of the contents of the given file.  Or NULL, if
+ *         the file does not exist or there was an error reading the file.
+ */
+PurpleXmlNode *
+purple_util_read_xml_from_data_file(const char *filename, const char *description);
+
+/**
  * purple_mkstemp:
  * @path:   The returned path to the temp file.
  * @binary: Text or binary, for platforms where it matters.
@@ -1417,6 +1485,18 @@
 GList *purple_uri_list_extract_filenames(const gchar *uri_list);
 
 /**
+ * purple_uri_escape_for_open:
+ * @unescaped: The unescaped URI.
+ *
+ * This function escapes any characters that might be interpreted by the shell
+ * when executing a program to open a URI on some systems.
+ *
+ * Returns: A newly allocated string with any shell metacharacters replaced
+ *          with their escaped equivalents.
+ */
+char *purple_uri_escape_for_open(const char *unescaped);
+
+/**
  * This function escapes any characters that might be interpreted by the shell
  * when executing a program to open a URI on some systems.
  *

mercurial