application/davcontroller.c

changeset 11
26acbfa75c1f
parent 10
f8dfc5705516
child 12
3eb0cbab53db
equal deleted inserted replaced
10:f8dfc5705516 11:26acbfa75c1f
76 76
77 77
78 // ------------------------------ davbrowser_query_path ------------------------------ 78 // ------------------------------ davbrowser_query_path ------------------------------
79 79
80 typedef struct DavBrowserQueryPath { 80 typedef struct DavBrowserQueryPath {
81 UiThreadpool *pool;
81 DavBrowser *browser; 82 DavBrowser *browser;
82 char *path; 83 char *path;
83 DavResource *result; 84 DavResource *result;
84 } DavBrowserQueryPath; 85 } DavBrowserQueryPath;
85 86
95 96
96 static void browser_query_finished(UiEvent *event, void *data) { 97 static void browser_query_finished(UiEvent *event, void *data) {
97 DavBrowserQueryPath *query = data; 98 DavBrowserQueryPath *query = data;
98 DavBrowser *browser = event->document; 99 DavBrowser *browser = event->document;
99 100
100 if (query->result) { 101 if (query->pool == browser->dav_queue) {
101 davbrowser_set_collection(event->obj, browser, query->result); 102 if (query->result) {
103 davbrowser_set_collection(event->obj, browser, query->result);
104 } else {
105 // TODO: error
106 }
107
108 window_progress(event->window, 0);
102 } else { 109 } else {
103 // TODO: error 110 // operation aborted
111 if (query->result) {
112 dav_resource_free_all(query->result);
113 }
104 } 114 }
105 115
106 free(query->path); 116 free(query->path);
107 free(query); 117 free(query);
108
109 window_progress(event->window, 0);
110 } 118 }
111 119
112 void davbrowser_query_path(UiObject *ui, DavBrowser *browser, const char *path) { 120 void davbrowser_query_path(UiObject *ui, DavBrowser *browser, const char *path) {
113 // for comparison, we need the current base_url/repo_name + path 121 // for comparison, we need the current base_url/repo_name + path
114 size_t len = path ? strlen(path) : 0; 122 size_t len = path ? strlen(path) : 0;
123 ui_set(browser->path, full_path); 131 ui_set(browser->path, full_path);
124 } 132 }
125 free(full_path); 133 free(full_path);
126 134
127 DavBrowserQueryPath *query = malloc(sizeof(DavBrowserQueryPath)); 135 DavBrowserQueryPath *query = malloc(sizeof(DavBrowserQueryPath));
136 query->pool = browser->dav_queue;
128 query->browser = browser; 137 query->browser = browser;
129 query->path = strdup(path); 138 query->path = strdup(path);
130 query->result = NULL; 139 query->result = NULL;
131 ui_threadpool_job(browser->dav_queue, ui, browser_query_path, query, browser_query_finished, query); 140 ui_threadpool_job(browser->dav_queue, ui, browser_query_path, query, browser_query_finished, query);
132 141
133 window_progress(ui->window, 1); 142 window_progress(ui->window, 1);
134 } 143 }
144
145 void davbrowser_query_url(UiObject *ui, DavBrowser *browser, const char *url) {
146 if (browser->repo_base) {
147 cxstring base = cx_str(browser->repo_base);
148 cxstring newurl = cx_str(url);
149
150 if (cx_strprefix(newurl, base)) {
151 const char *path = url + base.length;
152 davbrowser_query_path(ui, browser, path);
153 return;
154 }
155 }
156
157 // TODO:
158 }

mercurial