From cd2d091660ff46b5adaa9c7ab42133f5b0df3692 Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Thu, 15 Aug 2013 22:23:17 +0300 Subject: [PATCH] ucs: add SetImGroup operation Used to rename groups. Our first operation that can modify UCS. Yeah! --- src/core/sipe-group.c | 32 ++++++++++++++++++++------------ src/core/sipe-ucs.c | 27 +++++++++++++++++++++++++++ src/core/sipe-ucs.h | 14 ++++++++++++++ 3 files changed, 61 insertions(+), 12 deletions(-) diff --git a/src/core/sipe-group.c b/src/core/sipe-group.c index b33c5a68..1e9c423c 100755 --- a/src/core/sipe-group.c +++ b/src/core/sipe-group.c @@ -35,6 +35,7 @@ #include "sipe-core-private.h" #include "sipe-group.h" #include "sipe-nls.h" +#include "sipe-ucs.h" #include "sipe-utils.h" #include "sipe-xml.h" @@ -259,22 +260,29 @@ sipe_core_group_rename(struct sipe_core_public *sipe_public, struct sipe_group *s_group = sipe_group_find_by_name(sipe_private, old_name); if (s_group) { - gchar *request; - SIPE_DEBUG_INFO("Renaming group %s to %s", old_name, new_name); - /* new_name can contain restricted characters */ - request = g_markup_printf_escaped("%d" - "%s" - "", - s_group->id, new_name); - sip_soap_request(sipe_private, - "modifyGroup", - request); - g_free(request); + SIPE_DEBUG_INFO("sipe_core_group_rename: from '%s' to '%s'", old_name, new_name); + + if (sipe_ucs_is_migrated(sipe_private)) { + sipe_ucs_group_rename(sipe_private, + s_group, + new_name); + } else { + /* new_name can contain restricted characters */ + gchar *request = g_markup_printf_escaped("%d" + "%s" + "", + s_group->id, + new_name); + sip_soap_request(sipe_private, + "modifyGroup", + request); + g_free(request); + } g_free(s_group->name); s_group->name = g_strdup(new_name); } else { - SIPE_DEBUG_INFO("Cannot find group %s to rename", old_name); + SIPE_DEBUG_INFO("sipe_core_group_rename: cannot find group '%s'", old_name); } } diff --git a/src/core/sipe-ucs.c b/src/core/sipe-ucs.c index 788ec1c0..0c3c8195 100644 --- a/src/core/sipe-ucs.c +++ b/src/core/sipe-ucs.c @@ -246,6 +246,33 @@ void sipe_ucs_get_photo(struct sipe_core_private *sipe_private, g_free(body); } +static void sipe_ucs_ignore_response(SIPE_UNUSED_PARAMETER struct sipe_core_private *sipe_private, + SIPE_UNUSED_PARAMETER const sipe_xml *body, + SIPE_UNUSED_PARAMETER gpointer callback_data) +{ + SIPE_DEBUG_INFO_NOFORMAT("sipe_ucs_ignore_response: done"); +} + +void sipe_ucs_group_rename(struct sipe_core_private *sipe_private, + struct sipe_group *group, + const gchar *new_name) +{ + /* new_name can contain restricted characters */ + gchar *body = g_markup_printf_escaped("" + " " + " %s" + "", + group->exchange_key, + group->change_key, + new_name); + + sipe_ucs_http_request(sipe_private, + body, + sipe_ucs_ignore_response, + NULL); + g_free(body); +} + static void sipe_ucs_get_im_item_list_response(struct sipe_core_private *sipe_private, const sipe_xml *body, SIPE_UNUSED_PARAMETER gpointer callback_data) diff --git a/src/core/sipe-ucs.h b/src/core/sipe-ucs.h index 12c6e2b2..c49c4215 100644 --- a/src/core/sipe-ucs.h +++ b/src/core/sipe-ucs.h @@ -21,6 +21,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* Forward declarations */ +struct sipe_core_private; +struct sipe_group; /** * Get buddy photo @@ -43,6 +46,17 @@ void sipe_ucs_get_photo(struct sipe_core_private *sipe_private, gboolean sipe_ucs_is_migrated(struct sipe_core_private *sipe_private); /** + * Rename group + * + * @param sipe_private SIPE core private data + * @param group sipe_group structure + * @param new_name new name for group + */ +void sipe_ucs_group_rename(struct sipe_core_private *sipe_private, + struct sipe_group *group, + const gchar *new_name); + +/** * Initialize UCS * * @param sipe_private SIPE core private data -- 2.11.4.GIT