application/settings.c

changeset 117
b174e721663e
parent 116
376ef91111f6
equal deleted inserted replaced
116:376ef91111f6 117:b174e721663e
144 return; 144 return;
145 } 145 }
146 146
147 CxList *locations = NULL; 147 CxList *locations = NULL;
148 if(addlocation) { 148 if(addlocation) {
149 locations = cxLinkedListCreateSimple(CX_STORE_POINTERS); 149 locations = cxLinkedListCreate(NULL, CX_STORE_POINTERS);
150 cxListAdd(locations, strdup(wdata->url)); 150 cxListAdd(locations, strdup(wdata->url));
151 } 151 }
152 pwdstore_put(wdata->settings->pwdstore, id, user, password); 152 pwdstore_put(wdata->settings->pwdstore, id, user, password);
153 pwdstore_put_index(wdata->settings->pwdstore, strdup(id), locations); 153 pwdstore_put_index(wdata->settings->pwdstore, strdup(id), locations);
154 154
852 settings->repo_keys = ui_list_new(obj->ctx, NULL); 852 settings->repo_keys = ui_list_new(obj->ctx, NULL);
853 settings->repo_tls_versions = ui_list_new(obj->ctx, NULL); 853 settings->repo_tls_versions = ui_list_new(obj->ctx, NULL);
854 settings->repo_encryption = ui_int_new(obj->ctx, NULL); 854 settings->repo_encryption = ui_int_new(obj->ctx, NULL);
855 settings->repo_disable_verification = ui_int_new(obj->ctx, NULL); 855 settings->repo_disable_verification = ui_int_new(obj->ctx, NULL);
856 CxList *repo_keys = settings->repo_keys->data; 856 CxList *repo_keys = settings->repo_keys->data;
857 repo_keys->collection.cmpfunc = (cx_compare_func)strcmp; 857 cxSetCompareFunc(repo_keys, strcmp);
858 858
859 ui_list_append(settings->repo_tls_versions, "Default"); 859 ui_list_append(settings->repo_tls_versions, "Default");
860 ui_list_append(settings->repo_tls_versions, "TLSv1.3"); 860 ui_list_append(settings->repo_tls_versions, "TLSv1.3");
861 ui_list_append(settings->repo_tls_versions, "TLSv1.2"); 861 ui_list_append(settings->repo_tls_versions, "TLSv1.2");
862 ui_list_append(settings->repo_tls_versions, "TLSv1.1"); 862 ui_list_append(settings->repo_tls_versions, "TLSv1.1");
870 settings->credentials_password = ui_string_new(obj->ctx, NULL); 870 settings->credentials_password = ui_string_new(obj->ctx, NULL);
871 CxList *credentials_users = settings->credentials_users->data; 871 CxList *credentials_users = settings->credentials_users->data;
872 CxList *credentials_locations = settings->credentials_locations->data; 872 CxList *credentials_locations = settings->credentials_locations->data;
873 credentials_users->collection.advanced_destructor = list_str_destructor; 873 credentials_users->collection.advanced_destructor = list_str_destructor;
874 credentials_users->collection.destructor_data = settings->obj->ctx; 874 credentials_users->collection.destructor_data = settings->obj->ctx;
875 credentials_users->collection.cmpfunc = (cx_compare_func)strcmp; 875 cxSetCompareFunc(credentials_users, strcmp);
876 credentials_locations->collection.advanced_destructor = list_str_destructor; 876 credentials_locations->collection.advanced_destructor = list_str_destructor;
877 credentials_locations->collection.destructor_data = settings->obj->ctx; 877 credentials_locations->collection.destructor_data = settings->obj->ctx;
878 credentials_locations->collection.cmpfunc = (cx_compare_func)strcmp; 878 cxSetCompareFunc(credentials_locations, strcmp);
879 879
880 settings->keys_list = ui_list_new(obj->ctx, NULL); 880 settings->keys_list = ui_list_new(obj->ctx, NULL);
881 settings->key_name = ui_string_new(obj->ctx, NULL); 881 settings->key_name = ui_string_new(obj->ctx, NULL);
882 settings->key_type = ui_string_new(obj->ctx, NULL); 882 settings->key_type = ui_string_new(obj->ctx, NULL);
883 settings->key_file = ui_string_new(obj->ctx, NULL); 883 settings->key_file = ui_string_new(obj->ctx, NULL);
919 free(decoded_pw); 919 free(decoded_pw);
920 } 920 }
921 921
922 // select credentials dropdown value 922 // select credentials dropdown value
923 CxList *cred = settings->repo_credentials->data; 923 CxList *cred = settings->repo_credentials->data;
924 cred->collection.cmpfunc = (cx_compare_func)strcmp; 924 cxSetCompareFunc(cred, strcmp);
925 ssize_t cred_index = repo->stored_user.value.ptr ? cxListFind(cred, repo->stored_user.value.ptr) : 0; 925 ssize_t cred_index = repo->stored_user.value.ptr ? cxListFind(cred, repo->stored_user.value.ptr) : 0;
926 if(cred_index > 0) { 926 if(cred_index > 0) {
927 ui_list_setselection(settings->repo_credentials, cred_index); 927 ui_list_setselection(settings->repo_credentials, cred_index);
928 } else { 928 } else {
929 ui_list_setselection(settings->repo_credentials, 0); 929 ui_list_setselection(settings->repo_credentials, 0);
930 } 930 }
931 931
932 // load encryption value and default key value 932 // load encryption value and default key value
933 ui_set(settings->repo_encryption, repo->full_encryption.value); 933 ui_set(settings->repo_encryption, repo->full_encryption.value);
934 CxList *keys = settings->repo_keys->data; 934 CxList *keys = settings->repo_keys->data;
935 keys->collection.cmpfunc = (cx_compare_func)strcmp; 935 cxSetCompareFunc(keys, strcmp);
936 ssize_t key_index = repo->default_key.value.ptr ? cxListFind(keys, repo->default_key.value.ptr) : 0; 936 ssize_t key_index = repo->default_key.value.ptr ? cxListFind(keys, repo->default_key.value.ptr) : 0;
937 if(key_index > 0) { 937 if(key_index > 0) {
938 ui_list_setselection(settings->repo_keys, key_index); 938 ui_list_setselection(settings->repo_keys, key_index);
939 } else { 939 } else {
940 ui_list_setselection(settings->repo_keys, 0); 940 ui_list_setselection(settings->repo_keys, 0);
941 } 941 }
942 942
943 // select tls version from dropdown menu 943 // select tls version from dropdown menu
944 CxList *tlsVersions = settings->repo_tls_versions->data; 944 CxList *tlsVersions = settings->repo_tls_versions->data;
945 tlsVersions->collection.cmpfunc = (cx_compare_func)strcmp; 945 cxSetCompareFunc(tlsVersions, strcmp);
946 const char *tls_str = dav_tlsversion2str(repo->ssl_version.value); 946 const char *tls_str = dav_tlsversion2str(repo->ssl_version.value);
947 if(!tls_str) tls_str = ""; 947 if(!tls_str) tls_str = "";
948 ssize_t tlsv_index = cxListFind(tlsVersions, tls_str); 948 ssize_t tlsv_index = cxListFind(tlsVersions, tls_str);
949 if(tlsv_index > 0) { 949 if(tlsv_index > 0) {
950 ui_list_setselection(settings->repo_tls_versions, tlsv_index); 950 ui_list_setselection(settings->repo_tls_versions, tlsv_index);
1315 char *password = ui_get(settings->credentials_password); 1315 char *password = ui_get(settings->credentials_password);
1316 CxList *ui_locations = settings->credentials_locations->data; 1316 CxList *ui_locations = settings->credentials_locations->data;
1317 size_t numlocations = cxListSize(ui_locations); 1317 size_t numlocations = cxListSize(ui_locations);
1318 CxList *locations = NULL; 1318 CxList *locations = NULL;
1319 if(numlocations > 0) { 1319 if(numlocations > 0) {
1320 locations = cxArrayListCreateSimple(CX_STORE_POINTERS, numlocations); 1320 locations = cxArrayListCreate(NULL, CX_STORE_POINTERS, numlocations);
1321 CxIterator i = cxListIterator(ui_locations); 1321 CxIterator i = cxListIterator(ui_locations);
1322 cx_foreach(char*, loc, i) { 1322 cx_foreach(char*, loc, i) {
1323 cxListAdd(locations, strdup(loc)); 1323 cxListAdd(locations, strdup(loc));
1324 } 1324 }
1325 } 1325 }

mercurial