Commit f492fa82 authored by Matt Colyer's avatar Matt Colyer

A few cleanups, got rid of global afc variable.

parent d05ae226
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
#include "AFC.h" #include "AFC.h"
#include "userpref.h" #include "userpref.h"
AFClient *afc = NULL;
GHashTable *file_handles; GHashTable *file_handles;
int fh_index = 0; int fh_index = 0;
...@@ -47,6 +45,7 @@ int debug = 0; ...@@ -47,6 +45,7 @@ int debug = 0;
static int ifuse_getattr(const char *path, struct stat *stbuf) { static int ifuse_getattr(const char *path, struct stat *stbuf) {
int res = 0; int res = 0;
AFCFile *file; AFCFile *file;
AFClient *afc = fuse_get_context()->private_data;
memset(stbuf, 0, sizeof(struct stat)); memset(stbuf, 0, sizeof(struct stat));
file = afc_get_file_info(afc, path); file = afc_get_file_info(afc, path);
...@@ -66,6 +65,7 @@ static int ifuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler, ...@@ -66,6 +65,7 @@ static int ifuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi) { off_t offset, struct fuse_file_info *fi) {
int i; int i;
char **dirs, **filename; char **dirs, **filename;
AFClient *afc = fuse_get_context()->private_data;
dirs = afc_get_dir_list(afc, path); dirs = afc_get_dir_list(afc, path);
for (i = 0; strcmp(dirs[i], ""); i++) { for (i = 0; strcmp(dirs[i], ""); i++) {
...@@ -79,6 +79,7 @@ static int ifuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler, ...@@ -79,6 +79,7 @@ static int ifuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
static int ifuse_open(const char *path, struct fuse_file_info *fi) { static int ifuse_open(const char *path, struct fuse_file_info *fi) {
AFCFile *file; AFCFile *file;
AFClient *afc = fuse_get_context()->private_data;
if((fi->flags & 3) != O_RDONLY) if((fi->flags & 3) != O_RDONLY)
return -EACCES; return -EACCES;
...@@ -96,6 +97,7 @@ static int ifuse_read(const char *path, char *buf, size_t size, off_t offset, ...@@ -96,6 +97,7 @@ static int ifuse_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi) { struct fuse_file_info *fi) {
int bytes; int bytes;
AFCFile *file; AFCFile *file;
AFClient *afc = fuse_get_context()->private_data;
file = g_hash_table_lookup(file_handles, &(fi->fh)); file = g_hash_table_lookup(file_handles, &(fi->fh));
if (!file){ if (!file){
...@@ -111,6 +113,9 @@ void *ifuse_init(struct fuse_conn_info *conn) { ...@@ -111,6 +113,9 @@ void *ifuse_init(struct fuse_conn_info *conn) {
char *response = (char*)malloc(sizeof(char) * 2048); char *response = (char*)malloc(sizeof(char) * 2048);
int bytes = 0, port = 0, i = 0; int bytes = 0, port = 0, i = 0;
char* host_id = NULL; char* host_id = NULL;
AFClient *afc = NULL;
conn->async_read = 0;
file_handles = g_hash_table_new(g_int_hash, g_int_equal); file_handles = g_hash_table_new(g_int_hash, g_int_equal);
...@@ -127,8 +132,8 @@ void *ifuse_init(struct fuse_conn_info *conn) { ...@@ -127,8 +132,8 @@ void *ifuse_init(struct fuse_conn_info *conn) {
} }
host_id = get_host_id(); host_id = get_host_id();
if (host_id && !lockdownd_start_SSL_session(control, host_id)) { if (host_id && !lockdownd_start_SSL_session(control, host_id) || !host_id) {
fprintf(stderr, "Something went wrong in GnuTLS.\n"); fprintf(stderr, "Something went wrong in GnuTLS. Is your HostID configured in .config/libiphone/libiphonerc?\n");
return NULL; return NULL;
} }
free(host_id); free(host_id);
...@@ -145,9 +150,11 @@ void *ifuse_init(struct fuse_conn_info *conn) { ...@@ -145,9 +150,11 @@ void *ifuse_init(struct fuse_conn_info *conn) {
return afc; return afc;
} }
void ifuse_cleanup() { void ifuse_cleanup(AFClient *afc) {
if (afc) {
free_iPhone(afc->phone); free_iPhone(afc->phone);
afc_disconnect(afc); afc_disconnect(afc);
}
} }
static struct fuse_operations ifuse_oper = { static struct fuse_operations ifuse_oper = {
......
...@@ -35,7 +35,7 @@ char* get_host_id() ...@@ -35,7 +35,7 @@ char* get_host_id()
config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_CONF_FILE, NULL); config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_CONF_FILE, NULL);
if (g_file_test(config_file, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))) { if (g_file_test(config_file, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))) {
/*now parse file to get the HostID*/ /* now parse file to get the HostID */
GKeyFile* key_file = g_key_file_new (); GKeyFile* key_file = g_key_file_new ();
if( g_key_file_load_from_file (key_file, config_file, G_KEY_FILE_KEEP_COMMENTS, NULL) ) { if( g_key_file_load_from_file (key_file, config_file, G_KEY_FILE_KEEP_COMMENTS, NULL) ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment