diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/async-io-coroutine.h | 2 | ||||
-rw-r--r-- | src/caja-dropbox-hooks.c | 30 | ||||
-rw-r--r-- | src/caja-dropbox.c | 34 | ||||
-rw-r--r-- | src/caja-dropbox.h | 2 | ||||
-rw-r--r-- | src/dropbox-client-util.c | 12 | ||||
-rw-r--r-- | src/dropbox-client.c | 26 | ||||
-rw-r--r-- | src/dropbox-command-client.c | 76 | ||||
-rw-r--r-- | src/dropbox-command-client.h | 4 |
8 files changed, 93 insertions, 93 deletions
diff --git a/src/async-io-coroutine.h b/src/async-io-coroutine.h index 3e27bf4..9f10e33 100644 --- a/src/async-io-coroutine.h +++ b/src/async-io-coroutine.h @@ -31,7 +31,7 @@ G_BEGIN_DECLS #define CRBEGIN(pos) switch (pos) { case 0: #define CREND } return FALSE #define CRYIELD(pos) do { pos = __LINE__; return TRUE; case __LINE__:;} while (0) -#define CRHALT return FALSE +#define CRHALT return FALSE #define CRREADLINE(pos, chan, where) \ while (1) { \ diff --git a/src/caja-dropbox-hooks.c b/src/caja-dropbox-hooks.c index 86cb07d..6a13ef8 100644 --- a/src/caja-dropbox-hooks.c +++ b/src/caja-dropbox-hooks.c @@ -61,7 +61,7 @@ handle_hook_server_input(GIOChannel *chan, (GDestroyNotify) g_free, (GDestroyNotify) g_strfreev); hookserv->hhsi.numargs = 0; - + /* read the command name */ { gchar *line; @@ -89,7 +89,7 @@ handle_hook_server_input(GIOChannel *chan, } else { gboolean parse_result; - + parse_result = dropbox_client_util_command_parse_arg(line, hookserv->hhsi.command_args); @@ -113,7 +113,7 @@ handle_hook_server_input(GIOChannel *chan, (hd->hook)(hookserv->hhsi.command_args, hd->ud); } } - + g_free(hookserv->hhsi.command_name); g_hash_table_unref(hookserv->hhsi.command_args); hookserv->hhsi.command_name = NULL; @@ -129,7 +129,7 @@ watch_killer(CajaDropboxHookserv *hookserv) { hookserv->connected = FALSE; g_hook_list_invoke(&(hookserv->ondisconnect_hooklist), FALSE); - + /* we basically just have to free the memory allocated in the handle_hook_server_init ctx */ if (hookserv->hhsi.command_name != NULL) { @@ -155,7 +155,7 @@ static gboolean try_to_connect(CajaDropboxHookserv *hookserv) { /* create socket */ hookserv->socket = socket(PF_UNIX, SOCK_STREAM, 0); - + /* set native non-blocking, for connect timeout */ { unsigned int flags; @@ -173,7 +173,7 @@ try_to_connect(CajaDropboxHookserv *hookserv) { { struct sockaddr_un addr; socklen_t addr_len; - + /* intialize address structure */ addr.sun_family = AF_UNIX; g_snprintf(addr.sun_path, @@ -189,7 +189,7 @@ try_to_connect(CajaDropboxHookserv *hookserv) { struct timeval tv = {1, 0}; FD_ZERO(&writers); FD_SET(hookserv->socket, &writers); - + /* if nothing was ready after 3 seconds, fail out homie */ if (select(hookserv->socket+1, NULL, &writers, NULL, &tv) == 0) { goto FAIL_CLEANUP; @@ -225,7 +225,7 @@ try_to_connect(CajaDropboxHookserv *hookserv) { { GIOFlags flags; GIOStatus iostat; - + flags = g_io_channel_get_flags(hookserv->chan); iostat = g_io_channel_set_flags(hookserv->chan, flags | G_IO_FLAG_NONBLOCK, NULL); @@ -242,7 +242,7 @@ try_to_connect(CajaDropboxHookserv *hookserv) { hookserv->hhsi.line = 0; hookserv->hhsi.command_args = NULL; hookserv->hhsi.command_name = NULL; - hookserv->event_source = + hookserv->event_source = g_io_add_watch_full(hookserv->chan, G_PRIORITY_DEFAULT, G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP | G_IO_NVAL, (GIOFunc) handle_hook_server_input, hookserv, @@ -268,14 +268,14 @@ gboolean caja_dropbox_hooks_force_reconnect(CajaDropboxHookserv *hookserv) { debug("forcing hook to reconnect"); g_assert(hookserv->event_source >= 0); - + if (hookserv->event_source > 0) { g_source_remove(hookserv->event_source); } else if (hookserv->event_source == 0) { debug("event source was zero!!!!!"); } - + return FALSE; } @@ -300,11 +300,11 @@ caja_dropbox_hooks_add_on_disconnect_hook(CajaDropboxHookserv *hookserv, DropboxHookClientConnectHook dhcch, gpointer ud) { GHook *newhook; - + newhook = g_hook_alloc(&(hookserv->ondisconnect_hooklist)); newhook->func = dhcch; newhook->data = ud; - + g_hook_append(&(hookserv->ondisconnect_hooklist), newhook); } @@ -313,11 +313,11 @@ caja_dropbox_hooks_add_on_connect_hook(CajaDropboxHookserv *hookserv, DropboxHookClientConnectHook dhcch, gpointer ud) { GHook *newhook; - + newhook = g_hook_alloc(&(hookserv->onconnect_hooklist)); newhook->func = dhcch; newhook->data = ud; - + g_hook_append(&(hookserv->onconnect_hooklist), newhook); } diff --git a/src/caja-dropbox.c b/src/caja-dropbox.c index 6451015..ef30e1e 100644 --- a/src/caja-dropbox.c +++ b/src/caja-dropbox.c @@ -2,7 +2,7 @@ * Copyright 2008 Evenflow, Inc. * * caja-dropbox.c - * Implements the Caja extension API for Dropbox. + * Implements the Caja extension API for Dropbox. * * This file is part of caja-dropbox. * @@ -74,7 +74,7 @@ static gchar * canonicalize_path(gchar *path) { int i, j = 0; gchar *toret, **cpy, **elts; - + g_assert(path != NULL); g_assert(path[0] == '/'); @@ -89,12 +89,12 @@ canonicalize_path(gchar *path) { cpy[j++] = elts[i]; } } - + cpy[j] = NULL; toret = g_build_filenamev(cpy); g_free(cpy); g_strfreev(elts); - + return toret; } @@ -120,7 +120,7 @@ when_file_dies(CajaDropbox *cvs, CajaFileInfo *address) { gchar *filename; filename = g_hash_table_lookup(cvs->obj2filename, address); - + /* we never got a change to view this file */ if (filename == NULL) { return; @@ -189,7 +189,7 @@ changed_cb(CajaFileInfo *file, CajaDropbox *cvs) { g_hash_table_insert(cvs->filename2obj, g_strdup(filename), file); reset_file(file); } - + g_free(filename); } @@ -217,7 +217,7 @@ caja_dropbox_update_file_info(CajaInfoProvider *provider, int cmp = 0; gchar *stored_filename; gchar *filename; - + filename = canonicalize_path(pfilename); g_free(pfilename); stored_filename = g_hash_table_lookup(cvs->obj2filename, file); @@ -226,9 +226,9 @@ caja_dropbox_update_file_info(CajaInfoProvider *provider, GCSE ftw */ if ((stored_filename != NULL && (cmp = strcmp(stored_filename, filename)) != 0) || stored_filename == NULL) { - + if (stored_filename != NULL && cmp != 0) { - /* this happens when the filename changes name on a file obj + /* this happens when the filename changes name on a file obj but changed_cb isn't called */ g_object_weak_unref(G_OBJECT(file), (GWeakNotify) when_file_dies, cvs); g_hash_table_remove(cvs->obj2filename, file); @@ -241,10 +241,10 @@ caja_dropbox_update_file_info(CajaInfoProvider *provider, if ((f2 = g_hash_table_lookup(cvs->filename2obj, filename)) != NULL) { /* if the filename exists in the filename2obj hash but the file obj doesn't exist in the obj2filename hash: - + this happens when caja allocates another file object for a filename without first deleting the original file object - + just remove the association to the older file object, it's obsolete */ g_object_weak_unref(G_OBJECT(f2), (GWeakNotify) when_file_dies, cvs); @@ -279,11 +279,11 @@ caja_dropbox_update_file_info(CajaInfoProvider *provider, dfic->dc.request_type = GET_FILE_INFO; dfic->update_complete = g_closure_ref(update_complete); dfic->file = g_object_ref(file); - + dropbox_command_client_request(&(cvs->dc.dcc), (DropboxCommand *) dfic); - + *handle = (CajaOperationHandle *) dfic; - + return dropbox_use_operation_in_progress_workaround ? CAJA_OPERATION_COMPLETE : CAJA_OPERATION_IN_PROGRESS; @@ -660,7 +660,7 @@ caja_dropbox_get_file_items(CajaMenuProvider *provider, } GAsyncQueue *reply_queue = g_async_queue_new_full((GDestroyNotify)g_hash_table_unref); - + /* * 2. Create a DropboxGeneralCommand to call "icon_overlay_context_options" */ @@ -893,7 +893,7 @@ caja_dropbox_instance_init (CajaDropbox *cvs) { dropbox_client_add_on_disconnect_hook(&(cvs->dc), (DropboxClientConnectHook) on_disconnect, cvs); - + /* now start the connection */ debug("about to start client connection"); dropbox_client_start(&(cvs->dc)); @@ -947,7 +947,7 @@ caja_dropbox_register_type (GTypeModule *module) { G_TYPE_OBJECT, "CajaDropbox", &info, 0); - + g_type_module_add_interface (module, dropbox_type, CAJA_TYPE_MENU_PROVIDER, diff --git a/src/caja-dropbox.h b/src/caja-dropbox.h index b0b3c59..95fd99e 100644 --- a/src/caja-dropbox.h +++ b/src/caja-dropbox.h @@ -36,7 +36,7 @@ G_BEGIN_DECLS /* Declarations for the dropbox extension object. This object will be - * instantiated by caja. It implements the GInterfaces + * instantiated by caja. It implements the GInterfaces * exported by libcaja. */ #define CAJA_TYPE_DROPBOX (caja_dropbox_get_type ()) diff --git a/src/dropbox-client-util.c b/src/dropbox-client-util.c index 8419957..5677dff 100644 --- a/src/dropbox-client-util.c +++ b/src/dropbox-client-util.c @@ -58,24 +58,24 @@ dropbox_client_util_command_parse_arg(const gchar *line, GHashTable *return_tabl gchar **argval; guint len; gboolean retval; - + argval = g_strsplit(line, "\t", 0); len = g_strv_length(argval); /* debug("parsed: (%d) %s", len, line); */ - + if (len > 1) { int i; gchar **vals; - + vals = g_new(gchar *, len); vals[len - 1] = NULL; - + for (i = 1; argval[i] != NULL; i++) { vals[i-1] = dropbox_client_util_desanitize(argval[i]); - + } - + g_hash_table_insert(return_table, dropbox_client_util_desanitize(argval[0]), vals); diff --git a/src/dropbox-client.c b/src/dropbox-client.c index 8563197..6a08da0 100644 --- a/src/dropbox-client.c +++ b/src/dropbox-client.c @@ -31,7 +31,7 @@ static void hook_on_connect(DropboxClient *dc) { dc->hook_connect_called = TRUE; - + if (dc->command_connect_called) { debug("client connection"); g_hook_list_invoke(&(dc->onconnect_hooklist), FALSE); @@ -43,7 +43,7 @@ hook_on_connect(DropboxClient *dc) { static void command_on_connect(DropboxClient *dc) { dc->command_connect_called = TRUE; - + if (dc->hook_connect_called) { debug("client connection"); g_hook_list_invoke(&(dc->onconnect_hooklist), FALSE); @@ -55,7 +55,7 @@ command_on_connect(DropboxClient *dc) { static void command_on_disconnect(DropboxClient *dc) { dc->command_disconnect_called = TRUE; - + if (dc->hook_disconnect_called) { debug("client disconnect"); g_hook_list_invoke(&(dc->ondisconnect_hooklist), FALSE); @@ -70,7 +70,7 @@ command_on_disconnect(DropboxClient *dc) { static void hook_on_disconnect(DropboxClient *dc) { dc->hook_disconnect_called = TRUE; - + if (dc->command_disconnect_called) { debug("client disconnect"); g_hook_list_invoke(&(dc->ondisconnect_hooklist), FALSE); @@ -109,18 +109,18 @@ dropbox_client_setup(DropboxClient *dc) { dc->hook_disconnect_called = dc->command_disconnect_called = FALSE; dc->hook_connect_called = dc->command_connect_called = FALSE; - caja_dropbox_hooks_add_on_connect_hook(&(dc->hookserv), + caja_dropbox_hooks_add_on_connect_hook(&(dc->hookserv), (DropboxHookClientConnectHook) hook_on_connect, dc); - + dropbox_command_client_add_on_connect_hook(&(dc->dcc), (DropboxCommandClientConnectHook) command_on_connect, dc); - - caja_dropbox_hooks_add_on_disconnect_hook(&(dc->hookserv), + + caja_dropbox_hooks_add_on_disconnect_hook(&(dc->hookserv), (DropboxHookClientConnectHook) hook_on_disconnect, dc); - + dropbox_command_client_add_on_disconnect_hook(&(dc->dcc), (DropboxCommandClientConnectHook) command_on_disconnect, dc); @@ -132,11 +132,11 @@ dropbox_client_add_on_disconnect_hook(DropboxClient *dc, DropboxClientConnectHook dhcch, gpointer ud) { GHook *newhook; - + newhook = g_hook_alloc(&(dc->ondisconnect_hooklist)); newhook->func = dhcch; newhook->data = ud; - + g_hook_append(&(dc->ondisconnect_hooklist), newhook); } @@ -146,11 +146,11 @@ dropbox_client_add_on_connect_hook(DropboxClient *dc, DropboxClientConnectHook dhcch, gpointer ud) { GHook *newhook; - + newhook = g_hook_alloc(&(dc->onconnect_hooklist)); newhook->func = dhcch; newhook->data = ud; - + g_hook_append(&(dc->onconnect_hooklist), newhook); } diff --git a/src/dropbox-command-client.c b/src/dropbox-command-client.c index dd02fd0..817d989 100644 --- a/src/dropbox-command-client.c +++ b/src/dropbox-command-client.c @@ -109,7 +109,7 @@ receive_args_until_done(GIOChannel *chan, GHashTable *return_table, 0, "malicious connection"); return FALSE; } - + /* get the string */ iostat = g_io_channel_read_line(chan, &line, NULL, &term_pos, &tmp_error); @@ -147,7 +147,7 @@ receive_args_until_done(GIOChannel *chan, GHashTable *return_table, return FALSE; } } - + numargs += 1; } @@ -162,7 +162,7 @@ static void my_g_hash_table_get_keys_helper(gpointer key, static GList *my_g_hash_table_get_keys(GHashTable *ght) { GList *list = NULL; - g_hash_table_foreach(ght, (GHFunc) + g_hash_table_foreach(ght, (GHFunc) my_g_hash_table_get_keys_helper, &list); return list; } @@ -185,7 +185,7 @@ send_command_to_db(GIOChannel *chan, const gchar *command_name, g_assert(chan != NULL); g_assert(command_name != NULL); - + #define WRITE_OR_DIE_SANI(s,l) { \ gchar *sani_s; \ @@ -201,7 +201,7 @@ send_command_to_db(GIOChannel *chan, const gchar *command_name, return NULL; \ } \ } - + #define WRITE_OR_DIE(s,l) { \ iostat = g_io_channel_write_chars(chan, s,l, &bytes_trans, \ &tmp_error); \ @@ -213,7 +213,7 @@ send_command_to_db(GIOChannel *chan, const gchar *command_name, return NULL; \ } \ } - + /* send command to server */ WRITE_OR_DIE_SANI(command_name, -1); WRITE_OR_DIE("\n", -1); @@ -229,9 +229,9 @@ send_command_to_db(GIOChannel *chan, const gchar *command_name, for (li = keys; li != NULL; li = g_list_next(li)) { int i; gchar **value; - + WRITE_OR_DIE_SANI((gchar *) li->data, -1); - + value = g_hash_table_lookup(args, li->data); for (i = 0; value[i] != NULL; i++) { WRITE_OR_DIE("\t", -1); @@ -281,12 +281,12 @@ send_command_to_db(GIOChannel *chan, const gchar *command_name, /* if the response was okay */ if (strncmp(line, "ok\n", 3) == 0) { - GHashTable *return_table = + GHashTable *return_table = g_hash_table_new_full((GHashFunc) g_str_hash, (GEqualFunc) g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) g_strfreev); - + g_free(line); line = NULL; @@ -296,7 +296,7 @@ send_command_to_db(GIOChannel *chan, const gchar *command_name, g_propagate_error(err, tmp_error); return NULL; } - + return return_table; } /* otherwise */ @@ -305,7 +305,7 @@ send_command_to_db(GIOChannel *chan, const gchar *command_name, do { g_free(line); line = NULL; - + /* clear string */ iostat = g_io_channel_read_line(chan, &line, NULL, NULL, &tmp_error); @@ -321,7 +321,7 @@ send_command_to_db(GIOChannel *chan, const gchar *command_name, 0, "dropbox command connection timed out"); return NULL; - + } else if (iostat == G_IO_STATUS_EOF) { g_assert(line == NULL); @@ -412,7 +412,7 @@ do_file_info_command(GIOChannel *chan, DropboxFileInfoCommand *dfic, GError **ge paths_arg[1] = NULL; g_hash_table_insert(args, g_strdup("path"), paths_arg); } - + folder_tag_response = send_command_to_db(chan, "get_folder_tag", args, &tmp_gerr); g_hash_table_unref(args); @@ -425,7 +425,7 @@ do_file_info_command(GIOChannel *chan, DropboxFileInfoCommand *dfic, GError **ge return; } } - + /* great server responded perfectly, now let's get this request done, ...in the glib main loop */ @@ -438,7 +438,7 @@ exit: g_idle_add((GSourceFunc) caja_dropbox_finish_file_info_command, dficr); g_free(filename); - + return; } @@ -447,7 +447,7 @@ finish_general_command(DropboxGeneralCommandResponse *dgcr) { if (dgcr->dgc->handler != NULL) { dgcr->dgc->handler(dgcr->response, dgcr->dgc->handler_ud); } - + if (dgcr->response != NULL) { g_hash_table_unref(dgcr->response); } @@ -458,7 +458,7 @@ finish_general_command(DropboxGeneralCommandResponse *dgcr) { } g_free(dgcr->dgc); g_free(dgcr); - + return FALSE; } @@ -485,7 +485,7 @@ do_general_command(GIOChannel *chan, DropboxGeneralCommand *dcac, dgcr->response = response; finish_general_command(dgcr); } - + return; } @@ -498,15 +498,15 @@ check_connection(GIOChannel *chan) { GIOStatus ret, iostat; flags = g_io_channel_get_flags(chan); - + /* set non-blocking */ ret = g_io_channel_set_flags(chan, flags | G_IO_FLAG_NONBLOCK, NULL); if (ret == G_IO_STATUS_ERROR) { return FALSE; } - + iostat = g_io_channel_read_chars(chan, fake_buf, - sizeof(fake_buf), + sizeof(fake_buf), &bytes_read, &tmp_error); ret = g_io_channel_set_flags(chan, flags, NULL); @@ -543,7 +543,7 @@ end_request(DropboxCommand *dc) { finish_general_command(dgcr); } break; - default: + default: g_assert_not_reached(); break; } @@ -707,11 +707,11 @@ dropbox_command_client_thread(DropboxCommandClient *dcc) { do_general_command(chan, (DropboxGeneralCommand *) dc, &gerr); } break; - default: + default: g_assert_not_reached(); break; } - + debug("done."); if (gerr != NULL) { @@ -720,7 +720,7 @@ dropbox_command_client_thread(DropboxCommandClient *dcc) { end_request(dc); debug("command error: %s", gerr->message); - + g_error_free(gerr); BADCONNECTION: /* grab all the rest of the data off the async queue and mark it @@ -739,10 +739,10 @@ dropbox_command_client_thread(DropboxCommandClient *dcc) { break; } } - + #undef SET_CONNECTED_STATE } - + return NULL; } @@ -789,11 +789,11 @@ dropbox_command_client_add_on_disconnect_hook(DropboxCommandClient *dcc, DropboxCommandClientConnectHook dhcch, gpointer ud) { GHook *newhook; - + newhook = g_hook_alloc(&(dcc->ondisconnect_hooklist)); newhook->func = dhcch; newhook->data = ud; - + g_hook_append(&(dcc->ondisconnect_hooklist), newhook); } @@ -802,11 +802,11 @@ dropbox_command_client_add_on_connect_hook(DropboxCommandClient *dcc, DropboxCommandClientConnectHook dhcch, gpointer ud) { GHook *newhook; - + newhook = g_hook_alloc(&(dcc->onconnect_hooklist)); newhook->func = dhcch; newhook->data = ud; - + g_hook_append(&(dcc->onconnect_hooklist), newhook); } @@ -817,7 +817,7 @@ dropbox_command_client_add_connection_attempt_hook(DropboxCommandClient *dcc, DropboxCommandClientConnectionAttempt *newhook; debug("shouldn't be here..."); - + newhook = g_new(DropboxCommandClientConnectionAttempt, 1); newhook->h = dhcch; newhook->ud = ud; @@ -835,25 +835,25 @@ dropbox_command_client_start(DropboxCommandClient *dcc) { } /* thread safe */ -void dropbox_command_client_send_simple_command(DropboxCommandClient *dcc, +void dropbox_command_client_send_simple_command(DropboxCommandClient *dcc, const char *command) { DropboxGeneralCommand *dgc; - + dgc = g_new(DropboxGeneralCommand, 1); - + dgc->dc.request_type = GENERAL_COMMAND; dgc->command_name = g_strdup(command); dgc->command_args = NULL; dgc->handler = NULL; dgc->handler_ud = NULL; - + dropbox_command_client_request(dcc, (DropboxCommand *) dgc); } /* thread safe */ /* this is the C API, there is another send_command_to_db that is more the actual over the wire command */ -void dropbox_command_client_send_command(DropboxCommandClient *dcc, +void dropbox_command_client_send_command(DropboxCommandClient *dcc, CajaDropboxCommandResponseHandler h, gpointer ud, const char *command, ...) { diff --git a/src/dropbox-command-client.h b/src/dropbox-command-client.h index a06f777..1c1b279 100644 --- a/src/dropbox-command-client.h +++ b/src/dropbox-command-client.h @@ -67,7 +67,7 @@ typedef GHookFunc DropboxCommandClientConnectHook; typedef struct { GMutex *command_connected_mutex; gboolean command_connected; - GAsyncQueue *command_queue; + GAsyncQueue *command_queue; GList *ca_hooklist; GHookList onconnect_hooklist; GHookList ondisconnect_hooklist; @@ -89,7 +89,7 @@ dropbox_command_client_start(DropboxCommandClient *dcc); void dropbox_command_client_send_simple_command(DropboxCommandClient *dcc, const char *command); -void dropbox_command_client_send_command(DropboxCommandClient *dcc, +void dropbox_command_client_send_command(DropboxCommandClient *dcc, CajaDropboxCommandResponseHandler h, gpointer ud, const char *command, ...); |