Simplify the namespace interface
* imap4d/namespace.c (prefix_translate_name): Remove the url parameter. All uses changed. (namespace_translate_name): Likewise. (i_translate_name): Rename to translate_name. Remove the url and ns parameters. All uses changed. * imap4d/imap4d.h (namespace_translate_name): Change signature.
Showing
3 changed files
with
11 additions
and
25 deletions
... | @@ -411,7 +411,7 @@ struct namespace | ... | @@ -411,7 +411,7 @@ struct namespace |
411 | void namespace_init (void); | 411 | void namespace_init (void); |
412 | struct namespace *namespace_lookup (char const *name); | 412 | struct namespace *namespace_lookup (char const *name); |
413 | 413 | ||
414 | char *namespace_translate_name (char const *name, int url, | 414 | char *namespace_translate_name (char const *name, |
415 | struct namespace_prefix const **pfx); | 415 | struct namespace_prefix const **pfx); |
416 | char *namespace_get_name (char const *name, mu_record_t *rec, int *mode); | 416 | char *namespace_get_name (char const *name, mu_record_t *rec, int *mode); |
417 | 417 | ... | ... |
... | @@ -241,7 +241,7 @@ imap4d_list (struct imap4d_session *session, | ... | @@ -241,7 +241,7 @@ imap4d_list (struct imap4d_session *session, |
241 | 241 | ||
242 | if (ref[0] == 0) | 242 | if (ref[0] == 0) |
243 | { | 243 | { |
244 | cwd = namespace_translate_name (wcard, 0, &pfx); | 244 | cwd = namespace_translate_name (wcard, &pfx); |
245 | if (cwd) | 245 | if (cwd) |
246 | { | 246 | { |
247 | char *p = wcard + strlen (pfx->prefix); | 247 | char *p = wcard + strlen (pfx->prefix); |
... | @@ -275,7 +275,7 @@ imap4d_list (struct imap4d_session *session, | ... | @@ -275,7 +275,7 @@ imap4d_list (struct imap4d_session *session, |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | cwd = namespace_translate_name (ref, 0, &pfx); | 278 | cwd = namespace_translate_name (ref, &pfx); |
279 | if (cwd) | 279 | if (cwd) |
280 | status = list_ref (ref, wcard, cwd, pfx); | 280 | status = list_ref (ref, wcard, cwd, pfx); |
281 | else | 281 | else | ... | ... |
... | @@ -158,7 +158,7 @@ namespace_init (void) | ... | @@ -158,7 +158,7 @@ namespace_init (void) |
158 | 158 | ||
159 | static char * | 159 | static char * |
160 | prefix_translate_name (struct namespace_prefix const *pfx, char const *name, | 160 | prefix_translate_name (struct namespace_prefix const *pfx, char const *name, |
161 | size_t namelen, int url) | 161 | size_t namelen) |
162 | { | 162 | { |
163 | size_t pfxlen = strlen (pfx->prefix); | 163 | size_t pfxlen = strlen (pfx->prefix); |
164 | int delim = 0; | 164 | int delim = 0; |
... | @@ -174,8 +174,6 @@ prefix_translate_name (struct namespace_prefix const *pfx, char const *name, | ... | @@ -174,8 +174,6 @@ prefix_translate_name (struct namespace_prefix const *pfx, char const *name, |
174 | { | 174 | { |
175 | char *tmpl, *p; | 175 | char *tmpl, *p; |
176 | 176 | ||
177 | if (!pfx->scheme) | ||
178 | url = 0; | ||
179 | name += pfxlen; | 177 | name += pfxlen; |
180 | 178 | ||
181 | if (pfx->ns == NS_PERSONAL && strcmp (name, "INBOX") == 0) | 179 | if (pfx->ns == NS_PERSONAL && strcmp (name, "INBOX") == 0) |
... | @@ -184,16 +182,8 @@ prefix_translate_name (struct namespace_prefix const *pfx, char const *name, | ... | @@ -184,16 +182,8 @@ prefix_translate_name (struct namespace_prefix const *pfx, char const *name, |
184 | return tmpl;//FIXME | 182 | return tmpl;//FIXME |
185 | } | 183 | } |
186 | 184 | ||
187 | tmpl = mu_alloc (namelen - pfxlen + strlen (pfx->dir) | 185 | tmpl = mu_alloc (namelen - pfxlen + strlen (pfx->dir) + 2); |
188 | + (url ? strlen (pfx->scheme) + 3 : 0) | 186 | p = tmpl; |
189 | + 2); | ||
190 | if (url) | ||
191 | { | ||
192 | p = mu_stpcpy (tmpl, pfx->scheme); | ||
193 | p = mu_stpcpy (p, "://"); | ||
194 | } | ||
195 | else | ||
196 | p = tmpl; | ||
197 | 187 | ||
198 | p = mu_stpcpy (p, pfx->dir); | 188 | p = mu_stpcpy (p, pfx->dir); |
199 | if (*name) | 189 | if (*name) |
... | @@ -215,8 +205,7 @@ prefix_translate_name (struct namespace_prefix const *pfx, char const *name, | ... | @@ -215,8 +205,7 @@ prefix_translate_name (struct namespace_prefix const *pfx, char const *name, |
215 | } | 205 | } |
216 | 206 | ||
217 | static char * | 207 | static char * |
218 | i_translate_name (char const *name, int url, int ns, | 208 | translate_name (char const *name, struct namespace_prefix const **return_pfx) |
219 | struct namespace_prefix const **return_pfx) | ||
220 | { | 209 | { |
221 | mu_iterator_t itr; | 210 | mu_iterator_t itr; |
222 | int rc; | 211 | int rc; |
... | @@ -241,10 +230,7 @@ i_translate_name (char const *name, int url, int ns, | ... | @@ -241,10 +230,7 @@ i_translate_name (char const *name, int url, int ns, |
241 | continue; | 230 | continue; |
242 | } | 231 | } |
243 | 232 | ||
244 | if (ns != NS_MAX && ns != pfx->ns) | 233 | res = prefix_translate_name (pfx, name, namelen); |
245 | continue; | ||
246 | |||
247 | res = prefix_translate_name (pfx, name, namelen, url); | ||
248 | if (res) | 234 | if (res) |
249 | { | 235 | { |
250 | if (return_pfx) | 236 | if (return_pfx) |
... | @@ -280,7 +266,7 @@ extract_username (char const *name, struct namespace_prefix const *pfx) | ... | @@ -280,7 +266,7 @@ extract_username (char const *name, struct namespace_prefix const *pfx) |
280 | } | 266 | } |
281 | 267 | ||
282 | char * | 268 | char * |
283 | namespace_translate_name (char const *name, int url, | 269 | namespace_translate_name (char const *name, |
284 | struct namespace_prefix const **return_pfx) | 270 | struct namespace_prefix const **return_pfx) |
285 | { | 271 | { |
286 | char *res = NULL; | 272 | char *res = NULL; |
... | @@ -292,7 +278,7 @@ namespace_translate_name (char const *name, int url, | ... | @@ -292,7 +278,7 @@ namespace_translate_name (char const *name, int url, |
292 | pfx = mu_assoc_get (prefixes, ""); | 278 | pfx = mu_assoc_get (prefixes, ""); |
293 | } | 279 | } |
294 | else | 280 | else |
295 | res = i_translate_name (name, url, NS_MAX, &pfx); | 281 | res = translate_name (name, &pfx); |
296 | 282 | ||
297 | if (res) | 283 | if (res) |
298 | { | 284 | { |
... | @@ -365,7 +351,7 @@ char * | ... | @@ -365,7 +351,7 @@ char * |
365 | namespace_get_name (char const *name, mu_record_t *rec, int *mode) | 351 | namespace_get_name (char const *name, mu_record_t *rec, int *mode) |
366 | { | 352 | { |
367 | struct namespace_prefix const *pfx; | 353 | struct namespace_prefix const *pfx; |
368 | char *path = namespace_translate_name (name, 0, &pfx); | 354 | char *path = namespace_translate_name (name, &pfx); |
369 | if (rec) | 355 | if (rec) |
370 | *rec = pfx->record; | 356 | *rec = pfx->record; |
371 | if (mode) | 357 | if (mode) | ... | ... |
-
Please register or sign in to post a comment