From fdf5006d3295856d8c92cf12273233a46a32c405 Mon Sep 17 00:00:00 2001 From: Jakub Adam Date: Wed, 18 Jul 2012 21:47:00 +0200 Subject: [PATCH] Fix #3543294: Support Lync 2010 meet URLs Backport of commit b5bca951f11b3dac864a1c1ef2a7108ea9cdd2a8 commit f2e90629e633559e4336c6f2e700bd518510b270 but removed all translation changes. --- src/core/sipe-conf.c | 108 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 87 insertions(+), 21 deletions(-) diff --git a/src/core/sipe-conf.c b/src/core/sipe-conf.c index c0783913..2d31a2e3 100644 --- a/src/core/sipe-conf.c +++ b/src/core/sipe-conf.c @@ -288,40 +288,106 @@ process_invite_conf_focus_response(struct sipe_core_private *sipe_private, return TRUE; } +static gchar * +parse_ocs_focus_uri(const gchar *uri) +{ + const gchar *confkey; + size_t uri_len; + + if (!uri) + return NULL; + + // URI can have this prefix if it was typed in by the user + if (g_str_has_prefix(uri, "meet:")) { + uri += 5; + } + + uri_len = strlen(uri); + + if (!uri || !g_str_has_prefix(uri, "sip:") || + uri_len == 4 || g_strstr_len(uri, -1, "%")) { + return NULL; + } + + confkey = g_strstr_len(uri, -1, "?"); + if (confkey) { + /* TODO: Investigate how conf-key field should be used, + * ignoring for now */ + uri_len = confkey - uri; + } + + return g_strndup(uri, uri_len); +} + +static gchar * +parse_lync_join_url(const gchar *uri) +{ + gchar *focus_uri = NULL; + gchar **parts; + int parts_count = 0; + + if (!uri) + return NULL; + + if (g_str_has_prefix(uri, "https://")) { + uri += 8; + } else if (g_str_has_prefix(uri, "http://")) { + uri += 7; + } + + parts = g_strsplit(uri, "/", 0); + + for (parts_count = 0; parts[parts_count]; ++parts_count); + if (parts_count >= 3) { + gchar *base_url = parts[0]; + gchar *conference_id = parts[parts_count - 1]; + gchar *organizer_alias = parts[parts_count - 2]; + + gchar **url_parts = g_strsplit(base_url, ".", 0); + int url_parts_count = 0; + for (url_parts_count = 0; url_parts[url_parts_count]; ++url_parts_count); + + if (url_parts_count >= 3) { + focus_uri = g_strdup_printf("sip:%s@%s.%s;gruu;opaque=app:conf:focus:id:%s", + organizer_alias, + url_parts[url_parts_count - 2], url_parts[url_parts_count - 1], + conference_id); + } + + g_strfreev(url_parts); + } + + g_strfreev(parts); + + return focus_uri; +} + struct sip_session * sipe_core_conf_create(struct sipe_core_public *sipe_public, - const gchar *focus_uri) + const gchar *uri) { - gchar *buf; - const gchar *focus_uri_ue; + gchar *uri_ue = sipe_utils_uri_unescape(uri); + gchar *focus_uri; struct sip_session *session = NULL; - focus_uri_ue = buf = sipe_utils_uri_unescape(focus_uri); - - // URI can have this prefix if it was typed in by the user - if (g_str_has_prefix(focus_uri_ue, "meet:")) - focus_uri_ue += 5; + focus_uri = parse_ocs_focus_uri(uri_ue); + if (!focus_uri) { + focus_uri = parse_lync_join_url(uri_ue); + } - if (!focus_uri_ue || !g_str_has_prefix(focus_uri_ue, "sip:") || - strlen(focus_uri_ue) == 4 || g_strstr_len(focus_uri_ue, -1, "%")) { + if (focus_uri) { + session = sipe_conf_create(SIPE_CORE_PRIVATE, NULL, focus_uri); + g_free(focus_uri); + } else { gchar *error = g_strdup_printf(_("\"%s\" is not a valid focus URI"), - focus_uri ? focus_uri : ""); + uri ? uri : ""); sipe_backend_notify_error(sipe_public, _("Failed to join the conference"), error); g_free(error); - } else { - gchar *querystr = g_strstr_len(focus_uri_ue, -1, "?"); - if (querystr) { - /* TODO: Investigate how conf-key field should be used, - * ignoring for now */ - *querystr = '\0'; - } - - session = sipe_conf_create(SIPE_CORE_PRIVATE, NULL, focus_uri_ue); } - g_free(buf); + g_free(uri_ue); return session; } -- 2.11.4.GIT