199 if (!repo->node) { |
199 if (!repo->node) { |
200 dav_repository_free(get_config(), repo); |
200 dav_repository_free(get_config(), repo); |
201 } |
201 } |
202 } |
202 } |
203 |
203 |
204 void davbrowser_open_resource(UiObject *ui, DavBrowser *browser, DavResource *res) { |
204 void davbrowser_open_resource(UiObject *ui, DavBrowser *browser, DavResource *res, const char *contenttype) { |
205 char *url = util_concat_path(browser->sn->base_url, res->path); |
|
206 void *x = cxMapGet(browser->res_open_inprogress, url); |
|
207 free(url); |
|
208 if(x) { |
|
209 return; // open resource already in progress |
|
210 } |
|
211 |
|
212 DavResourceViewType type = DAV_RESOURCE_VIEW_PROPERTIES; |
205 DavResourceViewType type = DAV_RESOURCE_VIEW_PROPERTIES; |
|
206 if(!contenttype) { |
|
207 contenttype = res->contenttype; |
|
208 } |
|
209 |
213 if(res->iscollection) { |
210 if(res->iscollection) { |
214 // default type |
211 // default type |
215 } else if(res->contenttype) { |
212 } else if(contenttype) { |
216 cxstring contenttype = cx_str(res->contenttype); |
213 cxstring ctype = cx_str(contenttype); |
217 if(cx_strprefix(contenttype, CX_STR("text/"))) { |
214 if(cx_strprefix(ctype, CX_STR("text/"))) { |
218 type = DAV_RESOURCE_VIEW_TEXT; |
215 type = DAV_RESOURCE_VIEW_TEXT; |
219 } else if(cx_strprefix(contenttype, CX_STR("image/"))) { |
216 } else if(cx_strprefix(ctype, CX_STR("image/"))) { |
220 type = DAV_RESOURCE_VIEW_IMAGE; |
217 type = DAV_RESOURCE_VIEW_IMAGE; |
221 } else if(cx_strprefix(contenttype, CX_STR("application/"))) { |
218 } else if(cx_strprefix(ctype, CX_STR("application/"))) { |
222 if(cx_strsuffix(contenttype, CX_STR("json"))) { |
219 if(cx_strsuffix(ctype, CX_STR("json"))) { |
223 type = DAV_RESOURCE_VIEW_TEXT; |
220 type = DAV_RESOURCE_VIEW_TEXT; |
224 } else if(cx_strsuffix(contenttype, CX_STR("/xml"))) { |
221 } else if(cx_strsuffix(ctype, CX_STR("/xml"))) { |
225 type = DAV_RESOURCE_VIEW_TEXT; |
222 type = DAV_RESOURCE_VIEW_TEXT; |
226 } else if(cx_strsuffix(contenttype, CX_STR("+xml"))) { |
223 } else if(cx_strsuffix(ctype, CX_STR("+xml"))) { |
227 type = DAV_RESOURCE_VIEW_TEXT; |
224 type = DAV_RESOURCE_VIEW_TEXT; |
228 } else if(cx_strsuffix(contenttype, CX_STR("/xml"))) { |
225 } else if(cx_strsuffix(ctype, CX_STR("/xml"))) { |
229 type = DAV_RESOURCE_VIEW_TEXT; |
226 type = DAV_RESOURCE_VIEW_TEXT; |
230 } |
227 } |
231 } |
228 } |
232 } else { |
229 } else { |
233 cxstring path = cx_str(res->path); |
230 cxstring path = cx_str(res->path); |