extern "C" {
#endif
+typedef struct MainWindow {
+ UiList *notebooks;
+ UiList *sources;
+} MainWindow;
+
void application_startup(UiEvent *event, void *data);
*/
#include "window.h"
+#include "application.h"
void window_create() {
UiObject *obj = ui_sidebar_window("note", NULL);
+ MainWindow *wdata = window_init_data(obj);
- UiSubList sublists[] = { NULL };
+ UiSubList sublists[] = {
+ { .value = wdata->notebooks, .header = "Notebooks" },
+ { .value = wdata->sources, .header = "Sources", .separator = TRUE }
+ };
ui_sidebar(obj) {
- ui_sourcelist(obj, .sublists = sublists);
+ ui_sourcelist(obj, .sublists = sublists, .numsublists = 2, .getvalue = window_sidebar_getvalue, .fill = UI_ON);
+ ui_hbox(obj, .spacing = 2, .fill = UI_OFF) {
+ ui_button(obj, .icon = "folder-new-symbolic", .style_class = "flat");
+ }
}
ui_show(obj);
}
+
+MainWindow* window_init_data(UiObject *obj) {
+ MainWindow *wdata = ui_calloc(obj->ctx, 1, sizeof(MainWindow));
+ obj->window = wdata;
+
+ wdata->notebooks = ui_list_new(obj->ctx, "notebooks");
+ wdata->sources = ui_list_new(obj->ctx, "source");
+
+ return wdata;
+}
+
+void window_sidebar_getvalue(void *sublist_userdata, void *rowdata, int index, UiSubListItem *item) {
+
+}
#define WINDOW_H
#include <ui/ui.h>
+#include "application.h"
#ifdef __cplusplus
extern "C" {
void window_create();
+MainWindow* window_init_data(UiObject *obj);
+
+void window_sidebar_getvalue(void *sublist_userdata, void *rowdata, int index, UiSubListItem *item);
+
#ifdef __cplusplus
}
if(ret != 0 && error) {
*error = ret;
- cxMempoolDestroy(cfg_mp);
+ cxMempoolFree(cfg_mp);
}
return config;
}
void dav_config_free(DavConfig *config) {
- cxMempoolDestroy(config->mp);
+ cxMempoolFree(config->mp);
}
CxBuffer* dav_config2buf(DavConfig *config) {
CxIterator i = cxListIterator(fields);
cx_foreach(DavQLField*, field, i) {
if(!cx_strcmp(field->name, CX_STR("*"))) {
- cxMapDestroy(properties);
+ cxMapFree(properties);
*isallprop = 1;
return create_allprop_propfind_request();
} else if(!cx_strcmp(field->name, CX_STR("-"))) {
- cxMapDestroy(properties);
+ cxMapFree(properties);
return create_propfind_request(sn, NULL, "propfind", 0);
} else {
if(fl_add_properties(sn, a, properties, field->expr)) {
// TODO: set error
- cxMapDestroy(properties);
+ cxMapFree(properties);
return NULL;
}
}
}
CxBuffer *reqbuf = create_propfind_request(sn, list, "propfind", 0);
- cxListDestroy(list);
- cxMapDestroy(properties);
+ cxListFree(list);
+ cxMapFree(properties);
return reqbuf;
}
int isallprop;
CxBuffer *rqbuf = fieldlist2propfindrequest(sn, mp->allocator, st->fields, &isallprop);
if(!rqbuf) {
- cxMempoolDestroy(mp);
+ cxMempoolFree(mp);
return result;
}
cxMempoolRegister(mp, rqbuf, (cx_destructor_func)cxBufferFree);
cxmutstr path = dav_format_string(mp->allocator, st->path, args, &error);
if(error) {
// TODO: cleanup
- cxMempoolDestroy(mp);
+ cxMempoolFree(mp);
return result;
}
CxBuffer *where = dav_compile_expr(sn->context, mp->allocator, st->where, args);
if(st->where && !where) {
// TODO: cleanup
- cxMempoolDestroy(mp);
+ cxMempoolFree(mp);
return result;
}
} else {
// error
// TODO: cleanup
- cxMempoolDestroy(mp);
+ cxMempoolFree(mp);
return result;
}
} else if(dav_identifier2resprop(column->srctext, &resprop)) {
} else {
// error
// TODO: cleanup
- cxMempoolDestroy(mp);
+ cxMempoolFree(mp);
return result;
}
} else {
// something is broken
// TODO: cleanup
- cxMempoolDestroy(mp);
+ cxMempoolFree(mp);
return result;
}
}
CxBuffer *rpbuf = cxBufferCreate(NULL, 4096, mp->allocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
if(!rpbuf) {
// TODO: cleanup
- cxMempoolDestroy(mp);
+ cxMempoolFree(mp);
return result;
}
result.result = NULL;
result.status = -1;
dav_resource_free_all(selroot);
- cxListDestroy(stack);
+ cxListFree(stack);
break;
}
} else {
cxBufferSeek(rpbuf, SEEK_SET, 0);
}
- cxMempoolDestroy(mp);
+ cxMempoolFree(mp);
return result;
}
void dav_free_statement(DavQLStatement *stmt) {
if(stmt->fields) {
cxDefineDestructor(stmt->fields, dav_free_field);
- cxListDestroy(stmt->fields);
+ cxListFree(stmt->fields);
}
if (stmt->where) {
if(stmt->orderby) {
cxDefineDestructor(stmt->orderby, dav_free_order_criterion);
- cxListDestroy(stmt->orderby);
+ cxListFree(stmt->orderby);
}
if(stmt->args) {
- cxListDestroy(stmt->args);
+ cxListFree(stmt->args);
}
free(stmt);
}
// deactivate header capturing and free captured map
util_capture_header(handle, NULL);
- cxMapDestroy(respheaders);
+ cxMapFree(respheaders);
return ret;
}
// end
cx_bprintf(buf, "</D:prop>\n</D:%s>\n", rootelm);
- cxMapDestroy(namespaces);
+ cxMapFree(namespaces);
return buf;
}
void cleanup_response(ResponseTag *result) {
if(result) {
- cxListDestroy(result->properties);
+ cxListFree(result->properties);
}
}
}
}
}
- cxListDestroy(properties);
+ cxListFree(properties);
if(crypto_prop && crypto_key) {
char *crypto_prop_content = util_xml_get_text(crypto_prop);
cxBufferWrite(s.ptr, 1, s.length, buf);
// cleanup namespace map
- cxMapDestroy(namespaces);
+ cxMapFree(namespaces);
return buf;
}
if(ret) {
pwdstore_put_index(p, id, locations);
if(cxListSize(locations) == 0) {
- cxListDestroy(locations);
+ cxListFree(locations);
}
} else {
if(id) free(id);
- cxListDestroy(locations);
+ cxListFree(locations);
}
return ret;
remove_list_entries(s, id);
CxHashKey key = cx_hash_key_str(id);
- PwdIndexEntry *i = cxMapRemoveAndGet(s->index, key);
- PwdEntry *e = cxMapRemoveAndGet(s->ids, key);
+ PwdIndexEntry *i = NULL;
+ cxMapRemoveAndGet(s->index, key, &i);
+ PwdEntry *e = NULL;
+ cxMapRemoveAndGet(s->ids, key, &e);
if(i) {
if(i->locations) {
- cxListDestroy(i->locations);
+ cxListFree(i->locations);
}
free(i->id);
free(i);
void pwdstore_free(PwdStore* p) {
cxDefineDestructor(p->ids, pwdstore_free_entry);
- cxMapDestroy(p->ids);
+ cxMapFree(p->ids);
- cxListDestroy(p->locations);
+ cxListFree(p->locations);
if(p->content) {
cxBufferFree(p->content);
// TODO: free everything
dav_session_free(sn, property);
}
- cxMapDestroy(properties);
+ cxMapFree(properties);
}
void dav_resource_free(DavResource *res) {
CxBuffer *rqbuf = create_propfind_request(res->session, proplist, "propfind", 0);
int ret = dav_propfind(res->session, res, rqbuf);
cxBufferFree(rqbuf);
- cxMempoolDestroy(mp);
+ cxMempoolFree(mp);
return ret;
}
cx_foreach(DavProperty *, property, i) {
cxmutstr keystr = dav_property_key(property->ns->name, property->name);
CxHashKey key = cx_hash_key(keystr.ptr, keystr.length);
- DavProperty *existing_prop = cxMapRemoveAndGet(crypto_props, key);
+ DavProperty *existing_prop = NULL;
+ cxMapRemoveAndGet(crypto_props, key, &existing_prop);
cxMapPut(crypto_props, key, property);
if(existing_prop) {
// TODO: free existing_prop
cxBufferPutString(content, "</D:prop>");
- cxMapDestroy(nsmap);
+ cxMapFree(nsmap);
// encrypt xml document
char *crypto_prop_content = aes_encrypt(content->space, content->size, sn->key);
xmlFreeDoc(doc);
if(cxMapSize(map) == 0) {
- cxMapDestroy(map);
+ cxMapFree(map);
return NULL;
}
return map;
char *log_method;
char *log_url;
curl_easy_getinfo(sn->handle, CURLINFO_EFFECTIVE_URL, &log_url);
+#if LIBCURL_VERSION_NUM >= 0x074800
curl_easy_getinfo(sn->handle, CURLINFO_EFFECTIVE_METHOD , &log_method);
+#else
+ long opt_upload = 0;
+ curl_easy_getinfo(sn->handle, CURLOPT_UPLOAD, &opt_upload);
+ char *opt_custom = NULL;
+ curl_easy_getinfo(sn->handle, CURLOPT_CUSTOMREQUEST, &opt_custom);
+ if(opt_custom) {
+ log_method = opt_custom;
+ } else if(opt_upload) {
+ log_method = "PUT";
+ } else {
+ log_method = "GET";
+ }
+#endif
char *log_reqbody = NULL;
size_t log_reqbodylen = 0;
char *log_rpbody = NULL;
}
void dav_session_destructor(DavSession *sn) {
- cxMempoolDestroy(sn->mp);
+ cxMempoolFree(sn->mp);
curl_easy_cleanup(sn->handle);
free(sn);
}
return;
}
- if(cxMapRemoveAndGet(locks->resource_locks, cx_hash_key_str(path))) {
+ if(!cxMapRemove(locks->resource_locks, cx_hash_key_str(path))) {
return;
}
cx_foreach(DavProperty*, p, i) {
free(p->name);
}
- cxListDestroy(proplist);
+ cxListFree(proplist);
}
if(error && versions) {
void dav_context_destroy(DavContext *ctx) {
// destroy all sessions assoziated with this context
// ctx->sessions destructor must be dav_session_destructor
- cxListDestroy(ctx->sessions);
+ cxListFree(ctx->sessions);
if(ctx->http_proxy) {
free(ctx->http_proxy);
}
free(ns);
}
- cxMapDestroy(ctx->namespaces);
+ cxMapFree(ctx->namespaces);
}
if(ctx->namespaceinfo) {
// TODO: implement
}
free(key);
}
- cxMapDestroy(ctx->keys);
+ cxMapFree(ctx->keys);
}
free(ctx);
cx_foreach(DavProperty*, p, i) {
free(p->name);
}
- cxListDestroy(proplist);
+ cxListFree(proplist);
}
return resource;