2018-08-12 10:13:49 +08:00
|
|
|
#ifndef FILE_HANDLER_H
|
|
|
|
#define FILE_HADNELR_H
|
|
|
|
|
|
|
|
#include <SDL2/SDL_mutex.h>
|
|
|
|
#include <SDL2/SDL_stdinc.h>
|
|
|
|
#include <SDL2/SDL_thread.h>
|
|
|
|
#include "command.h"
|
|
|
|
|
2018-08-12 10:40:00 +08:00
|
|
|
#define REQUEST_QUEUE_SIZE 16
|
2018-08-12 10:13:49 +08:00
|
|
|
|
2018-08-12 10:40:00 +08:00
|
|
|
typedef enum {
|
|
|
|
ACTION_INSTALL_APK,
|
|
|
|
ACTION_PUSH_FILE,
|
|
|
|
} file_handler_action_t;
|
2018-08-12 10:13:49 +08:00
|
|
|
|
2018-08-12 10:40:00 +08:00
|
|
|
struct request_queue {
|
|
|
|
struct request *reqs[REQUEST_QUEUE_SIZE];
|
2018-08-12 10:13:49 +08:00
|
|
|
int tail;
|
|
|
|
int head;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct file_handler {
|
|
|
|
const char *serial;
|
|
|
|
SDL_Thread *thread;
|
|
|
|
SDL_mutex *mutex;
|
|
|
|
SDL_cond *event_cond;
|
|
|
|
SDL_bool stopped;
|
|
|
|
SDL_bool initialized;
|
|
|
|
process_t current_process;
|
2018-08-12 10:40:00 +08:00
|
|
|
struct request_queue queue;
|
2018-08-12 10:13:49 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
SDL_bool file_handler_init(struct file_handler *file_handler, const char *serial);
|
|
|
|
void file_handler_destroy(struct file_handler *file_handler);
|
|
|
|
|
|
|
|
SDL_bool 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);
|
|
|
|
|
2018-08-12 10:40:00 +08:00
|
|
|
SDL_bool file_handler_request(struct file_handler *file_handler,
|
|
|
|
file_handler_action_t action,
|
|
|
|
const char *file);
|
2018-08-12 10:13:49 +08:00
|
|
|
|
|
|
|
#endif
|