Skip to content
Permalink
Browse files

Remove deprecated glib2.0 API calls

origin commit from:
dropbox/nautilus-dropbox#62
  • Loading branch information...
e7appew authored and raveit65 committed Dec 8, 2018
1 parent 167bfab commit c85aaec1c46afdd1d7a975dd32d25c835b6daf10
Showing with 15 additions and 24 deletions.
  1. +6 −11 src/caja-dropbox.c
  2. +1 −1 src/caja-dropbox.h
  3. +7 −11 src/dropbox-command-client.c
  4. +1 −1 src/dropbox-command-client.h
@@ -693,17 +693,12 @@ caja_dropbox_get_file_items(CajaMenuProvider *provider,
CajaDropbox *cvs = CAJA_DROPBOX(provider);
dropbox_command_client_request(&(cvs->dc.dcc), (DropboxCommand *) dgc);

GTimeVal gtv;

/*
* 4. We have to block until it's done because caja expects a reply. But we will
* only block for 50 ms for a reply.
*/

g_get_current_time(&gtv);
g_time_val_add(&gtv, 50000);

GHashTable *context_options_response = g_async_queue_timed_pop(reply_queue, &gtv);
GHashTable *context_options_response = g_async_queue_timeout_pop(reply_queue, 50000);
g_async_queue_unref(reply_queue);

if (!context_options_response) {
@@ -831,13 +826,13 @@ void get_emblem_paths_cb(GHashTable *emblem_paths_response, CajaDropbox *cvs)
g_hash_table_ref(emblem_paths_response);
}

g_mutex_lock(cvs->emblem_paths_mutex);
g_mutex_lock(&(cvs->emblem_paths_mutex));
if (cvs->emblem_paths) {
g_idle_add((GSourceFunc) remove_emblem_paths, cvs->emblem_paths);
cvs->emblem_paths = NULL;
}
cvs->emblem_paths = emblem_paths_response;
g_mutex_unlock(cvs->emblem_paths_mutex);
g_mutex_unlock(&(cvs->emblem_paths_mutex));

g_idle_add((GSourceFunc) add_emblem_paths, g_hash_table_ref(emblem_paths_response));
g_idle_add((GSourceFunc) reset_all_files, cvs);
@@ -856,11 +851,11 @@ static void
on_disconnect(CajaDropbox *cvs) {
reset_all_files(cvs);

g_mutex_lock(cvs->emblem_paths_mutex);
g_mutex_lock(&(cvs->emblem_paths_mutex));
/* This call will free the data too. */
g_idle_add((GSourceFunc) remove_emblem_paths, cvs->emblem_paths);
cvs->emblem_paths = NULL;
g_mutex_unlock(cvs->emblem_paths_mutex);
g_mutex_unlock(&(cvs->emblem_paths_mutex));
}


@@ -887,7 +882,7 @@ caja_dropbox_instance_init (CajaDropbox *cvs) {
(GEqualFunc) g_direct_equal,
(GDestroyNotify) NULL,
(GDestroyNotify) g_free);
cvs->emblem_paths_mutex = g_mutex_new();
g_mutex_init(&(cvs->emblem_paths_mutex));
cvs->emblem_paths = NULL;

/* setup the connection obj*/
@@ -49,7 +49,7 @@ struct _CajaDropbox {
GObject parent_slot;
GHashTable *filename2obj;
GHashTable *obj2filename;
GMutex *emblem_paths_mutex;
GMutex emblem_paths_mutex;
GHashTable *emblem_paths;
DropboxClient dc;
};
@@ -645,9 +645,9 @@ dropbox_command_client_thread(DropboxCommandClient *dcc) {
g_io_channel_set_line_term(chan, "\n", -1);

#define SET_CONNECTED_STATE(s) { \
g_mutex_lock(dcc->command_connected_mutex); \
g_mutex_lock(&(dcc->command_connected_mutex)); \
dcc->command_connected = s; \
g_mutex_unlock(dcc->command_connected_mutex); \
g_mutex_unlock(&(dcc->command_connected_mutex)); \
}

SET_CONNECTED_STATE(TRUE);
@@ -658,12 +658,9 @@ dropbox_command_client_thread(DropboxCommandClient *dcc) {
DropboxCommand *dc;

while (1) {
GTimeVal gtv;

g_get_current_time(&gtv);
g_time_val_add(&gtv, G_USEC_PER_SEC / 10);
/* get a request from caja */
dc = g_async_queue_timed_pop(dcc->command_queue, &gtv);
dc = g_async_queue_timeout_pop(dcc->command_queue, G_USEC_PER_SEC / 10);
if (dc != NULL) {
break;
}
@@ -735,9 +732,9 @@ gboolean
dropbox_command_client_is_connected(DropboxCommandClient *dcc) {
gboolean command_connected;

g_mutex_lock(dcc->command_connected_mutex);
g_mutex_lock(&(dcc->command_connected_mutex));
command_connected = dcc->command_connected;
g_mutex_unlock(dcc->command_connected_mutex);
g_mutex_unlock(&(dcc->command_connected_mutex));

return command_connected;
}
@@ -760,7 +757,7 @@ dropbox_command_client_request(DropboxCommandClient *dcc, DropboxCommand *dc) {
void
dropbox_command_client_setup(DropboxCommandClient *dcc) {
dcc->command_queue = g_async_queue_new();
dcc->command_connected_mutex = g_mutex_new();
g_mutex_init(&(dcc->command_connected_mutex));
dcc->command_connected = FALSE;
dcc->ca_hooklist = NULL;

@@ -814,8 +811,7 @@ void
dropbox_command_client_start(DropboxCommandClient *dcc) {
/* setup the connect to the command server */
debug("starting command thread");
g_thread_create((gpointer (*)(gpointer data)) dropbox_command_client_thread,
dcc, FALSE, NULL);
g_thread_new(NULL, (GThreadFunc) dropbox_command_client_thread, dcc);
}

/* thread safe */
@@ -65,7 +65,7 @@ typedef void (*DropboxCommandClientConnectionAttemptHook)(guint, gpointer);
typedef GHookFunc DropboxCommandClientConnectHook;

typedef struct {
GMutex *command_connected_mutex;
GMutex command_connected_mutex;
gboolean command_connected;
GAsyncQueue *command_queue;
GList *ca_hooklist;

0 comments on commit c85aaec

Please sign in to comment.
You can’t perform that action at this time.