2018-08-12 02:13:49 +00:00
|
|
|
#ifndef FILE_HANDLER_H
|
2018-09-13 14:27:19 +00:00
|
|
|
#define FILE_HANDLER_H
|
2018-08-12 02:13:49 +00:00
|
|
|
|
2021-01-08 18:24:51 +00:00
|
|
|
#include "common.h"
|
|
|
|
|
2019-03-02 22:52:22 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2021-01-03 13:55:15 +00:00
|
|
|
#include "adb.h"
|
2019-11-24 10:53:00 +00:00
|
|
|
#include "util/cbuf.h"
|
2021-01-31 17:24:35 +00:00
|
|
|
#include "util/thread.h"
|
2018-08-12 02:13:49 +00:00
|
|
|
|
2018-08-12 02:40:00 +00:00
|
|
|
typedef enum {
|
|
|
|
ACTION_INSTALL_APK,
|
|
|
|
ACTION_PUSH_FILE,
|
|
|
|
} file_handler_action_t;
|
2018-08-12 02:13:49 +00:00
|
|
|
|
2019-05-29 19:46:16 +00:00
|
|
|
struct file_handler_request {
|
|
|
|
file_handler_action_t action;
|
|
|
|
char *file;
|
2018-08-12 02:13:49 +00:00
|
|
|
};
|
|
|
|
|
2019-05-29 19:46:16 +00:00
|
|
|
struct file_handler_request_queue CBUF(struct file_handler_request, 16);
|
|
|
|
|
2018-08-12 02:13:49 +00:00
|
|
|
struct file_handler {
|
2019-05-24 15:24:17 +00:00
|
|
|
char *serial;
|
2019-07-30 23:48:32 +00:00
|
|
|
const char *push_target;
|
2021-01-31 17:24:35 +00:00
|
|
|
sc_thread thread;
|
|
|
|
sc_mutex mutex;
|
|
|
|
sc_cond event_cond;
|
2019-03-02 22:52:22 +00:00
|
|
|
bool stopped;
|
|
|
|
bool initialized;
|
2018-08-12 02:13:49 +00:00
|
|
|
process_t current_process;
|
2019-05-29 19:46:16 +00:00
|
|
|
struct file_handler_request_queue queue;
|
2018-08-12 02:13:49 +00:00
|
|
|
};
|
|
|
|
|
2019-03-02 22:52:22 +00:00
|
|
|
bool
|
2019-07-30 23:48:32 +00:00
|
|
|
file_handler_init(struct file_handler *file_handler, const char *serial,
|
|
|
|
const char *push_target);
|
2018-08-12 02:13:49 +00:00
|
|
|
|
2019-03-02 19:09:56 +00:00
|
|
|
void
|
|
|
|
file_handler_destroy(struct file_handler *file_handler);
|
2018-08-12 02:13:49 +00:00
|
|
|
|
2019-03-02 22:52:22 +00:00
|
|
|
bool
|
2019-03-02 19:09:56 +00:00
|
|
|
file_handler_start(struct file_handler *file_handler);
|
|
|
|
|
|
|
|
void
|
|
|
|
file_handler_stop(struct file_handler *file_handler);
|
|
|
|
|
|
|
|
void
|
|
|
|
file_handler_join(struct file_handler *file_handler);
|
|
|
|
|
2021-01-24 14:14:53 +00:00
|
|
|
// take ownership of file, and will free() it
|
2019-03-02 22:52:22 +00:00
|
|
|
bool
|
2019-03-02 19:09:56 +00:00
|
|
|
file_handler_request(struct file_handler *file_handler,
|
|
|
|
file_handler_action_t action,
|
2019-05-24 15:25:31 +00:00
|
|
|
char *file);
|
2018-08-12 02:13:49 +00:00
|
|
|
|
|
|
|
#endif
|