Changeset 3fbce97 for protocols/jabber/hipchat.c
- Timestamp:
- 2016-09-24T20:14:34Z (8 years ago)
- Children:
- ba52ac5
- Parents:
- 63cad66 (diff), 82cb190 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/hipchat.c
r63cad66 r3fbce97 42 42 *sep = '/'; 43 43 } 44 45 jd->muc_host = g_strdup(xt_find_attr(node, "muc_host")); 44 46 45 47 /* Hipchat's auth doesn't expect a restart here */ … … 92 94 93 95 } 96 97 /* Returns a newly allocated string that tries to match the "slug" part of the JID using an 98 * approximation of the method used by the server. This might fail in some rare conditions 99 * (old JIDs generated a different way, locale settings unicode, etc) */ 100 char *hipchat_make_channel_slug(const char *name) 101 { 102 char *lower; 103 char *new = g_malloc(strlen(name) + 1); 104 int i = 0; 105 106 do { 107 if (*name == ' ') { 108 new[i++] = '_'; 109 } else if (*name && !strchr("\"&'/:<>@", *name)) { 110 new[i++] = *name; 111 } 112 } while (*(name++)); 113 114 new[i] = '\0'; 115 116 lower = g_utf8_strdown(new, -1); 117 g_free(new); 118 119 return lower; 120 } 121 122 char *hipchat_guess_channel_name(struct im_connection *ic, const char *name) 123 { 124 struct jabber_data *jd = ic->proto_data; 125 char *slug, *retval, *underscore; 126 127 if (!(underscore = strchr(jd->username, '_')) || !jd->muc_host) { 128 return NULL; 129 } 130 131 slug = hipchat_make_channel_slug(name); 132 133 /* Get the organization ID from the username, before the underscore */ 134 *underscore = '\0'; 135 136 retval = g_strdup_printf("%s_%s@%s", jd->username, slug, jd->muc_host); 137 138 *underscore = '_'; 139 140 g_free(slug); 141 142 return retval; 143 }
Note: See TracChangeset
for help on using the changeset viewer.