remove "myfiles" as a moniker for the root. Use NULL or empty string instead

This commit is contained in:
josch
2014-09-24 09:34:56 +02:00
parent 00ff91c15a
commit 18db8742dd
9 changed files with 71 additions and 86 deletions

View File

@@ -25,7 +25,7 @@
#include "../mfconn.h"
#include "../apicalls.h" // IWYU pragma: keep
int mfconn_api_folder_create(mfconn * conn, char *parent, char *name)
int mfconn_api_folder_create(mfconn * conn, const char *parent, const char *name)
{
const char *api_call;
int retval;
@@ -39,19 +39,15 @@ int mfconn_api_folder_create(mfconn * conn, char *parent, char *name)
if (strlen(name) < 1)
return -1;
// key must either be 11 chars or "myfiles"
if (parent != NULL) {
if (strlen(parent) != 13) {
// if it is myfiles, set paret to NULL
if (strcmp(parent, "myfiles") == 0)
parent = NULL;
}
// key must either be 13 chars or NULL
if (parent != NULL && strlen(parent) != 13) {
return -1;
}
if (parent != NULL) {
api_call =
mfconn_create_signed_get(conn, 0, "folder/create.php",
"?parent_key=%s" "&foldername=%s"
"?parent_key=%s&foldername=%s"
"&response_format=json", parent, name);
} else {
api_call =

View File

@@ -51,18 +51,17 @@ mfconn_api_folder_get_content(mfconn * conn, int mode, mffolder * folder_curr)
folderkey = folder_get_key(folder_curr);
if (folderkey == NULL) {
fprintf(stderr, "folder_get_key NULL\n");
return 0;
}
/*if (folderkey[0] == '\0') {
fprintf(stderr, "folder_get_key '\\0'\n");
return 0;
} */
api_call = mfconn_create_signed_get(conn, 0, "folder/get_content.php",
api_call = mfconn_create_signed_get(conn, 0, "folder/get_content.php",
"?content_type=%s"
"&response_format=json",
content_type);
} else {
api_call = mfconn_create_signed_get(conn, 0, "folder/get_content.php",
"?folder_key=%s"
"&content_type=%s"
"&response_format=json",
folderkey, content_type);
}
http = http_create();
if (mode == 0)

View File

@@ -31,7 +31,7 @@
static int _decode_folder_get_info(mfhttp * conn, void *data);
int
mfconn_api_folder_get_info(mfconn * conn, mffolder * folder, char *folderkey)
mfconn_api_folder_get_info(mfconn * conn, mffolder * folder, const char *folderkey)
{
const char *api_call;
int retval;
@@ -42,18 +42,21 @@ mfconn_api_folder_get_info(mfconn * conn, mffolder * folder, char *folderkey)
if (folder == NULL)
return -1;
if (folderkey == NULL)
return -1;
// key must either be 11 chars or "myfiles"
if (strlen(folderkey) != 13) {
if (strcmp(folderkey, "myfiles") == 0)
return -1;
// key must either be 13 chars or NULL
if (folderkey != NULL && strlen(folderkey) != 13) {
return -1;
}
api_call = mfconn_create_signed_get(conn, 0, "folder/get_info.php",
"?folder_key=%s&response_format=json",
folderkey);
if (folderkey == NULL) {
api_call = mfconn_create_signed_get(conn, 0, "folder/get_info.php",
"?response_format=json");
} else {
api_call = mfconn_create_signed_get(conn, 0, "folder/get_info.php",
"?folder_key=%s"
"&response_format=json",
folderkey);
}
http = http_create();
retval = http_get_buf(http, api_call, _decode_folder_get_info, folder);
@@ -96,9 +99,9 @@ static int _decode_folder_get_info(mfhttp * conn, void *data)
if (parent_folder != NULL) {
folder_set_parent(folder, json_string_value(parent_folder));
}
// infer that the parent folder must be "myfiles" root
// infer that the parent folder must be root
if (parent_folder == NULL && folderkey != NULL)
folder_set_parent(folder, "myfiles");
folder_set_parent(folder, NULL);
if (folderkey == NULL)
retval = -1;