2014-09-15 20:22:02 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2013 Bryan Christ <bryan.christ@mediafire.com>
|
2014-09-16 12:40:52 +02:00
|
|
|
* 2014 Johannes Schauer <j.schauer@email.de>
|
2014-09-15 20:22:02 +02:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License version 2, as published by
|
|
|
|
|
* the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc., 51
|
|
|
|
|
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2014-09-20 09:40:59 +02:00
|
|
|
#ifndef _MFAPI_APICALLS_H_
|
|
|
|
|
#define _MFAPI_APICALLS_H_
|
2014-09-15 20:00:05 +02:00
|
|
|
|
2014-12-05 11:37:51 +01:00
|
|
|
#include <jansson.h>
|
2014-09-18 09:11:00 +02:00
|
|
|
#include <stdint.h>
|
2014-12-04 16:07:12 +01:00
|
|
|
#include <stdio.h>
|
2015-01-12 14:43:23 +01:00
|
|
|
#include <stdbool.h>
|
2014-09-15 20:00:05 +02:00
|
|
|
|
2014-09-18 09:11:00 +02:00
|
|
|
#include "file.h"
|
|
|
|
|
#include "folder.h"
|
2014-12-01 16:30:32 +01:00
|
|
|
#include "patch.h"
|
2014-09-18 09:11:00 +02:00
|
|
|
#include "mfconn.h"
|
2014-12-05 11:37:51 +01:00
|
|
|
#include "../utils/http.h"
|
2014-09-15 20:00:05 +02:00
|
|
|
|
2014-09-27 13:53:44 +02:00
|
|
|
#define MFAPI_MAX_LEN_KEY 15
|
|
|
|
|
#define MFAPI_MAX_LEN_NAME 255
|
|
|
|
|
|
2014-12-26 20:28:23 -06:00
|
|
|
#define MFAPI_VERSION "1.2"
|
|
|
|
|
|
2014-09-25 21:51:42 +02:00
|
|
|
enum mfconn_device_change_type {
|
|
|
|
|
MFCONN_DEVICE_CHANGE_DELETED_FOLDER,
|
|
|
|
|
MFCONN_DEVICE_CHANGE_DELETED_FILE,
|
|
|
|
|
MFCONN_DEVICE_CHANGE_UPDATED_FOLDER,
|
2014-09-27 13:53:44 +02:00
|
|
|
MFCONN_DEVICE_CHANGE_UPDATED_FILE,
|
|
|
|
|
MFCONN_DEVICE_CHANGE_END
|
2014-09-25 21:51:42 +02:00
|
|
|
};
|
|
|
|
|
|
2014-12-29 09:49:48 +01:00
|
|
|
enum mfconn_file_link_type {
|
|
|
|
|
MFCONN_FILE_LINK_TYPE_NORMAL_DOWNLOAD,
|
|
|
|
|
MFCONN_FILE_LINK_TYPE_DIRECT_DOWNLOAD,
|
|
|
|
|
MFCONN_FILE_LINK_TYPE_VIEW,
|
|
|
|
|
MFCONN_FILE_LINK_TYPE_EDIT,
|
|
|
|
|
MFCONN_FILE_LINK_TYPE_WATCH,
|
|
|
|
|
MFCONN_FILE_LINK_TYPE_LISTEN,
|
|
|
|
|
MFCONN_FILE_LINK_TYPE_STREAMING,
|
|
|
|
|
MFCONN_FILE_LINK_TYPE_ONE_TIME_DOWNLOAD
|
2014-12-27 22:26:24 -06:00
|
|
|
};
|
|
|
|
|
|
2014-12-29 13:57:53 +01:00
|
|
|
extern const char *mfconn_file_link_types[]; // declared in apicalls.c
|
2014-12-27 22:26:24 -06:00
|
|
|
|
2014-09-25 21:51:42 +02:00
|
|
|
struct mfconn_device_change {
|
|
|
|
|
enum mfconn_device_change_type change;
|
2014-09-27 13:53:44 +02:00
|
|
|
char key[16];
|
2014-09-25 21:51:42 +02:00
|
|
|
uint64_t revision;
|
2014-09-27 13:53:44 +02:00
|
|
|
char parent[16];
|
2014-09-25 21:51:42 +02:00
|
|
|
};
|
|
|
|
|
|
2015-01-12 14:43:23 +01:00
|
|
|
struct mfconn_upload_check_result {
|
|
|
|
|
bool hash_exists;
|
|
|
|
|
bool in_account;
|
|
|
|
|
bool file_exists;
|
|
|
|
|
bool different_hash;
|
|
|
|
|
/* TODO: add resumable_upload */
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-05 11:37:51 +01:00
|
|
|
int mfapi_check_response(json_t * response, const char *apicall);
|
|
|
|
|
|
|
|
|
|
int mfapi_decode_common(mfhttp * conn, void *user_ptr);
|
|
|
|
|
|
2014-09-20 10:59:54 +02:00
|
|
|
int mfconn_api_file_get_info(mfconn * conn, mffile * file,
|
2014-09-29 16:48:26 +02:00
|
|
|
const char *quickkey);
|
2014-09-16 12:40:52 +02:00
|
|
|
|
2014-09-20 10:59:54 +02:00
|
|
|
int mfconn_api_file_get_links(mfconn * conn, mffile * file,
|
2014-12-27 22:26:24 -06:00
|
|
|
const char *quickkey,
|
2014-12-29 13:57:53 +01:00
|
|
|
enum mfconn_file_link_type
|
|
|
|
|
link_mask);
|
2014-09-16 12:40:52 +02:00
|
|
|
|
2014-12-19 08:20:20 +01:00
|
|
|
int mfconn_api_file_move(mfconn * conn, const char *quickkey,
|
|
|
|
|
const char *folderkey);
|
|
|
|
|
|
|
|
|
|
int mfconn_api_file_update(mfconn * conn, const char *quickkey,
|
|
|
|
|
const char *filename);
|
|
|
|
|
|
2014-09-24 09:34:56 +02:00
|
|
|
int mfconn_api_folder_create(mfconn * conn, const char *parent,
|
|
|
|
|
const char *name);
|
2014-09-15 20:00:05 +02:00
|
|
|
|
2014-12-06 11:04:04 +01:00
|
|
|
long mfconn_api_folder_get_content(mfconn * conn, const int mode,
|
2014-09-25 13:05:17 +02:00
|
|
|
const char *folderkey,
|
2014-09-25 19:34:03 +02:00
|
|
|
mffolder *** folder_result,
|
|
|
|
|
mffile *** file_result);
|
2014-09-15 20:00:05 +02:00
|
|
|
|
2014-09-20 10:59:54 +02:00
|
|
|
int mfconn_api_folder_get_info(mfconn * conn, mffolder * folder,
|
2014-09-24 09:34:56 +02:00
|
|
|
const char *folderkey);
|
2014-09-15 20:00:05 +02:00
|
|
|
|
2014-12-19 08:57:11 +01:00
|
|
|
int mfconn_api_folder_move(mfconn * conn,
|
|
|
|
|
const char *folder_key_src,
|
|
|
|
|
const char *folder_key_dst);
|
|
|
|
|
|
|
|
|
|
int mfconn_api_folder_update(mfconn * conn, const char *folder_key,
|
|
|
|
|
const char *foldername);
|
|
|
|
|
|
2014-09-20 10:59:54 +02:00
|
|
|
int mfconn_api_user_get_info(mfconn * conn);
|
2014-09-15 20:00:05 +02:00
|
|
|
|
2014-09-21 15:59:52 +02:00
|
|
|
int mfconn_api_user_get_session_token(mfconn * conn,
|
|
|
|
|
const char *server,
|
|
|
|
|
const char *username,
|
|
|
|
|
const char *password,
|
|
|
|
|
int app_id,
|
|
|
|
|
const char *app_key,
|
2014-09-20 10:59:54 +02:00
|
|
|
uint32_t * secret_key,
|
|
|
|
|
char **secret_time,
|
2014-12-29 15:11:53 +01:00
|
|
|
char **session_token,
|
|
|
|
|
char **ekey);
|
2014-09-15 20:00:05 +02:00
|
|
|
|
2014-09-20 14:37:24 +02:00
|
|
|
int mfconn_api_folder_delete(mfconn * conn, const char *folderkey);
|
|
|
|
|
|
2014-12-02 10:18:12 +01:00
|
|
|
int mfconn_api_file_delete(mfconn * conn, const char *quickkey);
|
|
|
|
|
|
2014-09-25 19:34:03 +02:00
|
|
|
int mfconn_api_device_get_status(mfconn * conn,
|
|
|
|
|
uint64_t * revision);
|
2014-09-25 13:04:40 +02:00
|
|
|
|
2014-09-25 21:51:42 +02:00
|
|
|
int mfconn_api_device_get_changes(mfconn * conn, uint64_t revision, struct mfconn_device_change
|
|
|
|
|
**changes);
|
2014-09-24 18:33:04 +02:00
|
|
|
|
2014-12-01 16:30:32 +01:00
|
|
|
int mfconn_api_device_get_updates(mfconn * conn,
|
|
|
|
|
const char *quickkey,
|
|
|
|
|
uint64_t revision,
|
|
|
|
|
uint64_t target_revision,
|
|
|
|
|
mfpatch *** patches);
|
|
|
|
|
|
|
|
|
|
int mfconn_api_device_get_patch(mfconn * conn, mfpatch * patch,
|
|
|
|
|
const char *quickkey,
|
|
|
|
|
uint64_t source_revision,
|
|
|
|
|
uint64_t target_revision);
|
|
|
|
|
|
2015-01-12 14:43:23 +01:00
|
|
|
int mfconn_api_upload_check(mfconn * conn, const char *filename,
|
|
|
|
|
const char *hash,
|
|
|
|
|
uint64_t size, const char *folder_key,
|
2015-01-16 08:49:23 +01:00
|
|
|
struct mfconn_upload_check_result
|
|
|
|
|
*result);
|
2015-01-12 14:43:23 +01:00
|
|
|
|
|
|
|
|
int mfconn_api_upload_instant(mfconn * conn, const char *quick_key,
|
2015-01-16 08:49:23 +01:00
|
|
|
const char *filename,
|
|
|
|
|
const char *hash, uint64_t size,
|
|
|
|
|
const char *folder_key);
|
2015-01-12 14:43:23 +01:00
|
|
|
|
2014-12-04 10:34:54 +01:00
|
|
|
int mfconn_api_upload_simple(mfconn * conn, const char *folderkey,
|
2014-12-04 16:07:12 +01:00
|
|
|
FILE * fh, const char *file_name,
|
2014-12-04 10:34:54 +01:00
|
|
|
char **upload_key);
|
|
|
|
|
|
2014-12-07 15:38:50 +01:00
|
|
|
int mfconn_api_upload_patch(mfconn * conn, const char *quickkey,
|
2014-12-08 14:12:17 +01:00
|
|
|
const char *source_hash,
|
|
|
|
|
const char *target_hash,
|
|
|
|
|
uint64_t target_size,
|
|
|
|
|
const char *patch_path,
|
|
|
|
|
char **upload_key);
|
2014-12-07 15:38:50 +01:00
|
|
|
|
2014-12-04 10:34:54 +01:00
|
|
|
int mfconn_api_upload_poll_upload(mfconn * conn,
|
|
|
|
|
const char *upload_key,
|
|
|
|
|
int *status, int *fileerror);
|
|
|
|
|
|
2014-09-18 09:11:00 +02:00
|
|
|
#endif
|