Merge lp:~jeremywootten/pantheon-files/dropbox-updated-for-loki into lp:~elementary-apps/pantheon-files/pantheon-files-plugin-dropbox

Proposed by Jeremy Wootten
Status: Merged
Approved by: Zisu Andrei
Approved revision: 26
Merged at revision: 24
Proposed branch: lp:~jeremywootten/pantheon-files/dropbox-updated-for-loki
Merge into: lp:~elementary-apps/pantheon-files/pantheon-files-plugin-dropbox
Prerequisite: lp:~jeremywootten/pantheon-files/dropbox-plugin-reformat-for-loki
Diff against target: 1148 lines (+180/-347)
10 files modified
CMakeLists.txt (+7/-8)
dropbox-client.c (+7/-7)
dropbox-client.h (+1/-1)
dropbox-command-client.c (+15/-15)
dropbox-command-client.h (+7/-7)
dropbox-hooks.c (+11/-11)
dropbox-hooks.h (+20/-20)
dropbox.plug (+1/-1)
plugin.c (+93/-254)
plugin.h (+18/-23)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/dropbox-updated-for-loki
Reviewer Review Type Date Requested Status
Zisu Andrei (community) Approve
Review via email: mp+298094@code.launchpad.net

Commit message

Namespace changes for dropbox plugin

Description of the change

This branch is built on lp:~jeremywootten/pantheon-files/dropbox-plugin-reformat-for-loki.

The code is updated to be compatible with Loki. Some namespaces are changed from marlin to pantheon-files or PF. Emblem names are updated.

To post a comment you must log in.
25. By Jeremy Wootten

Do not link unnecessarily to pantheon-files-widgets

26. By Jeremy Wootten

Merge changes from parent

Revision history for this message
Zisu Andrei (matzipan) wrote :

There's nothing which strikes me as out-of-place

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2016-06-24 12:59:58 +0000
+++ CMakeLists.txt 2016-06-24 12:59:58 +0000
@@ -2,9 +2,9 @@
22
3cmake_minimum_required (VERSION 2.6)3cmake_minimum_required (VERSION 2.6)
4cmake_policy(VERSION 2.6)4cmake_policy(VERSION 2.6)
5project(Marlin-Dropbox)5project(Pantheon-Files-Dropbox)
6list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake )6list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake )
7set(GETTEXT_PACKAGE "marlin-dropbox")7set(GETTEXT_PACKAGE "pantheon-files-dropbox")
8set(PACKAGE_VERSION 0.1)8set(PACKAGE_VERSION 0.1)
9set(VERSION 0.1)9set(VERSION 0.1)
10configure_file (${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h)10configure_file (${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
@@ -13,9 +13,9 @@
13find_package(PkgConfig)13find_package(PkgConfig)
14pkg_check_modules(DROPBOX REQUIRED14pkg_check_modules(DROPBOX REQUIRED
15 gtk+-3.015 gtk+-3.0
16 gee-1.016 gee-0.8
17 glib-2.017 glib-2.0
18 marlincore18 pantheon-files-core
19 )19 )
20set(CFLAGS20set(CFLAGS
21 ${DROPBOX_CFLAGS} ${DROPBOX_CFLAGS_OTHER}21 ${DROPBOX_CFLAGS} ${DROPBOX_CFLAGS_OTHER}
@@ -25,8 +25,7 @@
25include_directories(${CMAKE_BINARY_DIR}/libcore/)25include_directories(${CMAKE_BINARY_DIR}/libcore/)
26add_definitions(${CFLAGS})26add_definitions(${CFLAGS})
27link_directories(${LIB_PATHS})27link_directories(${LIB_PATHS})
28add_library(marlin-dropbox SHARED28add_library(pantheon-files-dropbox SHARED
29 plugin.c dropbox-client-util.c dropbox-command-client.c dropbox-client.c dropbox-hooks.c)29 plugin.c dropbox-client-util.c dropbox-command-client.c dropbox-client.c dropbox-hooks.c)
30target_link_libraries(marlin-dropbox marlincore marlinwidgets ${DROPBOX_LIBRARIES})30target_link_libraries(pantheon-files-dropbox pantheon-files-core ${DROPBOX_LIBRARIES})
31install(TARGETS marlin-dropbox DESTINATION lib/pantheon-files/plugins/)31install(TARGETS pantheon-files-dropbox DESTINATION lib/pantheon-files/plugins/)
32
3332
=== modified file 'dropbox-client.c'
--- dropbox-client.c 2016-06-24 12:59:58 +0000
+++ dropbox-client.c 2016-06-24 12:59:58 +0000
@@ -62,7 +62,7 @@
62 dc->hook_disconnect_called = dc->command_disconnect_called = FALSE;62 dc->hook_disconnect_called = dc->command_disconnect_called = FALSE;
63 }63 }
64 else {64 else {
65 marlin_dropbox_hooks_force_reconnect(&(dc->hookserv));65 pf_dropbox_hooks_force_reconnect(&(dc->hookserv));
66 }66 }
67}67}
6868
@@ -84,7 +84,7 @@
84gboolean84gboolean
85dropbox_client_is_connected(DropboxClient *dc) {85dropbox_client_is_connected(DropboxClient *dc) {
86 return (dropbox_command_client_is_connected(&(dc->dcc)) &&86 return (dropbox_command_client_is_connected(&(dc->dcc)) &&
87 marlin_dropbox_hooks_is_connected(&(dc->hookserv)));87 pf_dropbox_hooks_is_connected(&(dc->hookserv)));
88}88}
8989
90void90void
@@ -92,14 +92,14 @@
92 if (dropbox_client_is_connected(dc) == TRUE) {92 if (dropbox_client_is_connected(dc) == TRUE) {
93 debug("forcing client to reconnect");93 debug("forcing client to reconnect");
94 dropbox_command_client_force_reconnect(&(dc->dcc));94 dropbox_command_client_force_reconnect(&(dc->dcc));
95 marlin_dropbox_hooks_force_reconnect(&(dc->hookserv));95 pf_dropbox_hooks_force_reconnect(&(dc->hookserv));
96 }96 }
97}97}
9898
99/* should only be called once on initialization */99/* should only be called once on initialization */
100void100void
101dropbox_client_setup(DropboxClient *dc) {101dropbox_client_setup(DropboxClient *dc) {
102 marlin_dropbox_hooks_setup(&(dc->hookserv));102 pf_dropbox_hooks_setup(&(dc->hookserv));
103 dropbox_command_client_setup(&(dc->dcc));103 dropbox_command_client_setup(&(dc->dcc));
104104
105 g_hook_list_init(&(dc->ondisconnect_hooklist), sizeof(GHook));105 g_hook_list_init(&(dc->ondisconnect_hooklist), sizeof(GHook));
@@ -108,7 +108,7 @@
108 dc->hook_disconnect_called = dc->command_disconnect_called = FALSE;108 dc->hook_disconnect_called = dc->command_disconnect_called = FALSE;
109 dc->hook_connect_called = dc->command_connect_called = FALSE;109 dc->hook_connect_called = dc->command_connect_called = FALSE;
110110
111 marlin_dropbox_hooks_add_on_connect_hook(&(dc->hookserv),111 pf_dropbox_hooks_add_on_connect_hook(&(dc->hookserv),
112 (DropboxHookClientConnectHook)112 (DropboxHookClientConnectHook)
113 hook_on_connect, dc);113 hook_on_connect, dc);
114114
@@ -116,7 +116,7 @@
116 (DropboxCommandClientConnectHook)116 (DropboxCommandClientConnectHook)
117 command_on_connect, dc);117 command_on_connect, dc);
118118
119 marlin_dropbox_hooks_add_on_disconnect_hook(&(dc->hookserv),119 pf_dropbox_hooks_add_on_disconnect_hook(&(dc->hookserv),
120 (DropboxHookClientConnectHook)120 (DropboxHookClientConnectHook)
121 hook_on_disconnect, dc);121 hook_on_disconnect, dc);
122122
@@ -168,6 +168,6 @@
168void168void
169dropbox_client_start(DropboxClient *dc) {169dropbox_client_start(DropboxClient *dc) {
170 debug("starting connections");170 debug("starting connections");
171 marlin_dropbox_hooks_start(&(dc->hookserv));171 pf_dropbox_hooks_start(&(dc->hookserv));
172 dropbox_command_client_start(&(dc->dcc));172 dropbox_command_client_start(&(dc->dcc));
173}173}
174174
=== modified file 'dropbox-client.h'
--- dropbox-client.h 2016-06-24 12:59:58 +0000
+++ dropbox-client.h 2016-06-24 12:59:58 +0000
@@ -32,7 +32,7 @@
3232
33typedef struct {33typedef struct {
34 DropboxCommandClient dcc;34 DropboxCommandClient dcc;
35 MarlinDropboxHookserv hookserv;35 PFDropboxHookserv hookserv;
36 GHookList onconnect_hooklist;36 GHookList onconnect_hooklist;
37 GHookList ondisconnect_hooklist;37 GHookList ondisconnect_hooklist;
38 gboolean hook_connect_called;38 gboolean hook_connect_called;
3939
=== modified file 'dropbox-command-client.c'
--- dropbox-command-client.c 2016-06-24 12:59:58 +0000
+++ dropbox-command-client.c 2016-06-24 12:59:58 +0000
@@ -47,7 +47,7 @@
47 this can be cleaned up once the file_info_command isn't a special47 this can be cleaned up once the file_info_command isn't a special
48 case anylonger48 case anylonger
49 */49 */
50gboolean marlin_dropbox_finish_file_info_command(DropboxFileInfoCommandResponse *);50gboolean pf_dropbox_finish_file_info_command(DropboxFileInfoCommandResponse *);
5151
52typedef struct {52typedef struct {
53 DropboxCommandClient *dcc;53 DropboxCommandClient *dcc;
@@ -430,7 +430,7 @@
430 dficr->folder_tag_response = folder_tag_response;430 dficr->folder_tag_response = folder_tag_response;
431 dficr->file_status_response = file_status_response;431 dficr->file_status_response = file_status_response;
432 dficr->emblems_response = emblems_response;432 dficr->emblems_response = emblems_response;
433 g_idle_add((GSourceFunc) marlin_dropbox_finish_file_info_command, dficr);433 g_idle_add((GSourceFunc) pf_dropbox_finish_file_info_command, dficr);
434434
435 g_free(filename);435 g_free(filename);
436436
@@ -528,7 +528,7 @@
528 dficr->dfic = dfic;528 dficr->dfic = dfic;
529 dficr->file_status_response = NULL;529 dficr->file_status_response = NULL;
530 dficr->emblems_response = NULL;530 dficr->emblems_response = NULL;
531 g_idle_add((GSourceFunc) marlin_dropbox_finish_file_info_command, dficr);531 g_idle_add((GSourceFunc) pf_dropbox_finish_file_info_command, dficr);
532 }532 }
533 break;533 break;
534 case GENERAL_COMMAND: {534 case GENERAL_COMMAND: {
@@ -657,9 +657,9 @@
657 g_io_channel_set_line_term(chan, "\n", -1);657 g_io_channel_set_line_term(chan, "\n", -1);
658658
659#define SET_CONNECTED_STATE(s) { \659#define SET_CONNECTED_STATE(s) { \
660 g_mutex_lock(dcc->command_connected_mutex); \660 g_mutex_lock(&(dcc->command_connected_mutex)); \
661 dcc->command_connected = s; \661 dcc->command_connected = s; \
662 g_mutex_unlock(dcc->command_connected_mutex); \662 g_mutex_unlock(&(dcc->command_connected_mutex)); \
663}663}
664664
665 SET_CONNECTED_STATE(TRUE);665 SET_CONNECTED_STATE(TRUE);
@@ -670,12 +670,12 @@
670 DropboxCommand *dc;670 DropboxCommand *dc;
671671
672 while (1) {672 while (1) {
673 GTimeVal gtv;673 guint64 gtv;
674674
675 g_get_current_time(&gtv);675 gtv = g_get_real_time();
676 g_time_val_add(&gtv, G_USEC_PER_SEC / 10);676 gtv = gtv + G_USEC_PER_SEC / 10;
677 /* get a request from nautilus */677 /* get a request from nautilus */
678 dc = g_async_queue_timed_pop(dcc->command_queue, &gtv);678 dc = g_async_queue_timeout_pop(dcc->command_queue, gtv);
679 if (dc != NULL) {679 if (dc != NULL) {
680 break;680 break;
681 }681 }
@@ -747,9 +747,9 @@
747dropbox_command_client_is_connected(DropboxCommandClient *dcc) {747dropbox_command_client_is_connected(DropboxCommandClient *dcc) {
748 gboolean command_connected;748 gboolean command_connected;
749749
750 g_mutex_lock(dcc->command_connected_mutex);750 g_mutex_lock(&(dcc->command_connected_mutex));
751 command_connected = dcc->command_connected;751 command_connected = dcc->command_connected;
752 g_mutex_unlock(dcc->command_connected_mutex);752 g_mutex_unlock(&(dcc->command_connected_mutex));
753753
754 return command_connected;754 return command_connected;
755}755}
@@ -772,7 +772,7 @@
772void772void
773dropbox_command_client_setup(DropboxCommandClient *dcc) {773dropbox_command_client_setup(DropboxCommandClient *dcc) {
774 dcc->command_queue = g_async_queue_new();774 dcc->command_queue = g_async_queue_new();
775 dcc->command_connected_mutex = g_mutex_new();775 g_mutex_init(&(dcc->command_connected_mutex));
776 dcc->command_connected = FALSE;776 dcc->command_connected = FALSE;
777 dcc->ca_hooklist = NULL;777 dcc->ca_hooklist = NULL;
778778
@@ -826,8 +826,8 @@
826dropbox_command_client_start(DropboxCommandClient *dcc) {826dropbox_command_client_start(DropboxCommandClient *dcc) {
827 /* setup the connect to the command server */827 /* setup the connect to the command server */
828 debug("starting command thread");828 debug("starting command thread");
829 g_thread_create((gpointer (*)(gpointer data)) dropbox_command_client_thread,829 g_thread_new("pantheon-files-plugin-dropbox", (gpointer (*)(gpointer data)) dropbox_command_client_thread,
830 dcc, FALSE, NULL);830 dcc);
831}831}
832832
833/* thread safe */833/* thread safe */
@@ -850,7 +850,7 @@
850/* this is the C API, there is another send_command_to_db850/* this is the C API, there is another send_command_to_db
851 that is more the actual over the wire command */851 that is more the actual over the wire command */
852void dropbox_command_client_send_command(DropboxCommandClient *dcc,852void dropbox_command_client_send_command(DropboxCommandClient *dcc,
853 MarlinDropboxCommandResponseHandler h,853 PFDropboxCommandResponseHandler h,
854 gpointer ud,854 gpointer ud,
855 const char *command, ...) {855 const char *command, ...) {
856 va_list ap;856 va_list ap;
857857
=== modified file 'dropbox-command-client.h'
--- dropbox-command-client.h 2016-06-24 12:59:58 +0000
+++ dropbox-command-client.h 2016-06-24 12:59:58 +0000
@@ -24,16 +24,16 @@
24#ifndef DROPBOX_COMMAND_CLIENT_H24#ifndef DROPBOX_COMMAND_CLIENT_H
25#define DROPBOX_COMMAND_CLIENT_H25#define DROPBOX_COMMAND_CLIENT_H
2626
27#include <marlincore.h>27#include <pantheon-files-core.h>
28#include <gof-file.h>28#include <gof-file.h>
2929
30G_BEGIN_DECLS30G_BEGIN_DECLS
3131
32/* command structs */32/* command structs */
33typedef enum {GET_FILE_INFO, GENERAL_COMMAND} MarlinDropboxRequestType;33typedef enum {GET_FILE_INFO, GENERAL_COMMAND} PFDropboxRequestType;
3434
35typedef struct {35typedef struct {
36 MarlinDropboxRequestType request_type;36 PFDropboxRequestType request_type;
37} DropboxCommand;37} DropboxCommand;
3838
39typedef struct {39typedef struct {
@@ -51,13 +51,13 @@
51 GHashTable *emblems_response;51 GHashTable *emblems_response;
52} DropboxFileInfoCommandResponse;52} DropboxFileInfoCommandResponse;
5353
54typedef void (*MarlinDropboxCommandResponseHandler)(GHashTable *, gpointer);54typedef void (*PFDropboxCommandResponseHandler)(GHashTable *, gpointer);
5555
56typedef struct {56typedef struct {
57 DropboxCommand dc;57 DropboxCommand dc;
58 gchar *command_name;58 gchar *command_name;
59 GHashTable *command_args;59 GHashTable *command_args;
60 MarlinDropboxCommandResponseHandler handler;60 PFDropboxCommandResponseHandler handler;
61 gpointer handler_ud;61 gpointer handler_ud;
62} DropboxGeneralCommand;62} DropboxGeneralCommand;
6363
@@ -65,7 +65,7 @@
65typedef GHookFunc DropboxCommandClientConnectHook;65typedef GHookFunc DropboxCommandClientConnectHook;
6666
67typedef struct {67typedef struct {
68 GMutex *command_connected_mutex;68 GMutex command_connected_mutex;
69 gboolean command_connected;69 gboolean command_connected;
70 GAsyncQueue *command_queue;70 GAsyncQueue *command_queue;
71 GList *ca_hooklist;71 GList *ca_hooklist;
@@ -90,7 +90,7 @@
90 const char *command);90 const char *command);
9191
92void dropbox_command_client_send_command(DropboxCommandClient *dcc,92void dropbox_command_client_send_command(DropboxCommandClient *dcc,
93 MarlinDropboxCommandResponseHandler h,93 PFDropboxCommandResponseHandler h,
94 gpointer ud,94 gpointer ud,
95 const char *command, ...);95 const char *command, ...);
96void96void
9797
=== modified file 'dropbox-hooks.c'
--- dropbox-hooks.c 2016-06-24 12:59:58 +0000
+++ dropbox-hooks.c 2016-06-24 12:59:58 +0000
@@ -43,12 +43,12 @@
43} HookData;43} HookData;
4444
45static gboolean45static gboolean
46try_to_connect(MarlinDropboxHookserv *hookserv);46try_to_connect(PFDropboxHookserv *hookserv);
4747
48static gboolean48static gboolean
49handle_hook_server_input(GIOChannel *chan,49handle_hook_server_input(GIOChannel *chan,
50 GIOCondition cond,50 GIOCondition cond,
51 MarlinDropboxHookserv *hookserv) {51 PFDropboxHookserv *hookserv) {
52 /*debug_enter(); */52 /*debug_enter(); */
5353
54 /* we have some sweet macros defined that allow us to write this54 /* we have some sweet macros defined that allow us to write this
@@ -123,7 +123,7 @@
123}123}
124124
125static void125static void
126watch_killer(MarlinDropboxHookserv *hookserv) {126watch_killer(PFDropboxHookserv *hookserv) {
127 debug("hook client disconnected");127 debug("hook client disconnected");
128128
129 hookserv->connected = FALSE;129 hookserv->connected = FALSE;
@@ -152,7 +152,7 @@
152}152}
153153
154static gboolean154static gboolean
155try_to_connect(MarlinDropboxHookserv *hookserv) {155try_to_connect(PFDropboxHookserv *hookserv) {
156 /* create socket */156 /* create socket */
157 hookserv->socket = socket(PF_UNIX, SOCK_STREAM, 0);157 hookserv->socket = socket(PF_UNIX, SOCK_STREAM, 0);
158158
@@ -258,7 +258,7 @@
258258
259/* should only be called in glib main loop */259/* should only be called in glib main loop */
260/* returns a gboolean because it is a GSourceFunc */260/* returns a gboolean because it is a GSourceFunc */
261gboolean marlin_dropbox_hooks_force_reconnect(MarlinDropboxHookserv *hookserv) {261gboolean pf_dropbox_hooks_force_reconnect(PFDropboxHookserv *hookserv) {
262 debug_enter();262 debug_enter();
263263
264 if (hookserv->connected == FALSE) {264 if (hookserv->connected == FALSE) {
@@ -280,12 +280,12 @@
280}280}
281281
282gboolean282gboolean
283marlin_dropbox_hooks_is_connected(MarlinDropboxHookserv *hookserv) {283pf_dropbox_hooks_is_connected(PFDropboxHookserv *hookserv) {
284 return hookserv->connected;284 return hookserv->connected;
285}285}
286286
287void287void
288marlin_dropbox_hooks_setup(MarlinDropboxHookserv *hookserv) {288pf_dropbox_hooks_setup(PFDropboxHookserv *hookserv) {
289 hookserv->dispatch_table = g_hash_table_new_full((GHashFunc) g_str_hash,289 hookserv->dispatch_table = g_hash_table_new_full((GHashFunc) g_str_hash,
290 (GEqualFunc) g_str_equal,290 (GEqualFunc) g_str_equal,
291 g_free, g_free);291 g_free, g_free);
@@ -296,7 +296,7 @@
296}296}
297297
298void298void
299marlin_dropbox_hooks_add_on_disconnect_hook(MarlinDropboxHookserv *hookserv,299pf_dropbox_hooks_add_on_disconnect_hook(PFDropboxHookserv *hookserv,
300 DropboxHookClientConnectHook dhcch,300 DropboxHookClientConnectHook dhcch,
301 gpointer ud) {301 gpointer ud) {
302 GHook *newhook;302 GHook *newhook;
@@ -309,7 +309,7 @@
309}309}
310310
311void311void
312marlin_dropbox_hooks_add_on_connect_hook(MarlinDropboxHookserv *hookserv,312pf_dropbox_hooks_add_on_connect_hook(PFDropboxHookserv *hookserv,
313 DropboxHookClientConnectHook dhcch,313 DropboxHookClientConnectHook dhcch,
314 gpointer ud) {314 gpointer ud) {
315 GHook *newhook;315 GHook *newhook;
@@ -321,7 +321,7 @@
321 g_hook_append(&(hookserv->onconnect_hooklist), newhook);321 g_hook_append(&(hookserv->onconnect_hooklist), newhook);
322}322}
323323
324void marlin_dropbox_hooks_add(MarlinDropboxHookserv *ndhs,324void pf_dropbox_hooks_add(PFDropboxHookserv *ndhs,
325 const gchar *hook_name,325 const gchar *hook_name,
326 DropboxUpdateHook hook, gpointer ud) {326 DropboxUpdateHook hook, gpointer ud) {
327 HookData *hd;327 HookData *hd;
@@ -332,6 +332,6 @@
332}332}
333333
334void334void
335marlin_dropbox_hooks_start(MarlinDropboxHookserv *hookserv) {335pf_dropbox_hooks_start(PFDropboxHookserv *hookserv) {
336 try_to_connect(hookserv);336 try_to_connect(hookserv);
337}337}
338338
=== modified file 'dropbox-hooks.h'
--- dropbox-hooks.h 2011-10-05 04:35:08 +0000
+++ dropbox-hooks.h 2016-06-24 12:59:58 +0000
@@ -21,8 +21,8 @@
21 *21 *
22 */22 */
2323
24#ifndef MARLIN_DROPBOX_HOOKS_H24#ifndef PF_DROPBOX_HOOKS_H
25#define MARLIN_DROPBOX_HOOKS_H25#define PF_DROPBOX_HOOKS_H
2626
27#include <glib.h>27#include <glib.h>
2828
@@ -45,31 +45,31 @@
45 GHashTable *dispatch_table;45 GHashTable *dispatch_table;
46 GHookList ondisconnect_hooklist;46 GHookList ondisconnect_hooklist;
47 GHookList onconnect_hooklist;47 GHookList onconnect_hooklist;
48} MarlinDropboxHookserv;48} PFDropboxHookserv;
4949
50void50void
51marlin_dropbox_hooks_setup(MarlinDropboxHookserv *);51pf_dropbox_hooks_setup(PFDropboxHookserv *);
5252
53void53void
54marlin_dropbox_hooks_start(MarlinDropboxHookserv *);54pf_dropbox_hooks_start(PFDropboxHookserv *);
5555
56gboolean56gboolean
57marlin_dropbox_hooks_is_connected(MarlinDropboxHookserv *);57pf_dropbox_hooks_is_connected(PFDropboxHookserv *);
5858
59gboolean59gboolean
60marlin_dropbox_hooks_force_reconnect(MarlinDropboxHookserv *);60pf_dropbox_hooks_force_reconnect(PFDropboxHookserv *);
6161
62void62void
63marlin_dropbox_hooks_add(MarlinDropboxHookserv *ndhs,63pf_dropbox_hooks_add(PFDropboxHookserv *ndhs,
64 const gchar *hook_name,64 const gchar *hook_name,
65 DropboxUpdateHook hook, gpointer ud);65 DropboxUpdateHook hook, gpointer ud);
66void66void
67marlin_dropbox_hooks_add_on_disconnect_hook(MarlinDropboxHookserv *hookserv,67pf_dropbox_hooks_add_on_disconnect_hook(PFDropboxHookserv *hookserv,
68 DropboxHookClientConnectHook dhcch,68 DropboxHookClientConnectHook dhcch,
69 gpointer ud);69 gpointer ud);
7070
71void71void
72marlin_dropbox_hooks_add_on_connect_hook(MarlinDropboxHookserv *hookserv,72pf_dropbox_hooks_add_on_connect_hook(PFDropboxHookserv *hookserv,
73 DropboxHookClientConnectHook dhcch,73 DropboxHookClientConnectHook dhcch,
74 gpointer ud);74 gpointer ud);
7575
7676
=== modified file 'dropbox.plug'
--- dropbox.plug 2011-10-04 09:11:24 +0000
+++ dropbox.plug 2016-06-24 12:59:58 +0000
@@ -1,3 +1,3 @@
1[Plugin]1[Plugin]
2Name=Dropbox2Name=Dropbox
3File=libmarlin-dropbox.so3File=libpantheon-files-dropbox.so
44
=== modified file 'plugin.c'
--- plugin.c 2016-06-24 12:59:58 +0000
+++ plugin.c 2016-06-24 12:59:58 +0000
@@ -1,12 +1,12 @@
1/*1/*
2 * Copyright (C) 2011 ammonkey <am.monkeyd@gmail.com>2 * Copyright (C) 2011 ammonkey <am.monkeyd@gmail.com>
3 *3 *
4 * Marlin is free software: you can redistribute it and/or modify it4 * PantheonFiles is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation, either version 3 of the License, or6 * Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.7 * (at your option) any later version.
8 *8 *
9 * Marlin is distributed in the hope that it will be useful, but9 * PantheonFiles is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.12 * See the GNU General Public License for more details.
@@ -21,14 +21,10 @@
21#include "g-util.h"21#include "g-util.h"
22#include "plugin.h"22#include "plugin.h"
2323
24//static gpointer marlin_dropbox_parent_class = NULL;24G_DEFINE_TYPE (PFDropbox, pf_dropbox, MARLIN_PLUGINS_TYPE_BASE);
25
26//#define MARLIN_DROPBOX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MARLIN_TYPE_DROPBOX, MarlinDropboxPrivate))
27
28G_DEFINE_TYPE (MarlinDropbox, marlin_dropbox, MARLIN_PLUGINS_TYPE_BASE);
2925
30typedef struct {26typedef struct {
31 MarlinDropbox *cvs;27 PFDropbox *cvs;
32 gchar *verb;28 gchar *verb;
33 GOFFile *file;29 GOFFile *file;
34} MenuCallbackData;30} MenuCallbackData;
@@ -42,22 +38,32 @@
42 g_free (cb_data);38 g_free (cb_data);
43}39}
4440
45static char *db_emblems[] = {"dropbox-uptodate", "dropbox-syncing", "dropbox-unsyncable", "web", "people", "photos", "star"};41static char *db_emblems[] = {"dropbox-uptodate", \
46static char *emblems[] = {"emblem-ubuntuone-synchronized", "emblem-ubuntuone-updating", "dropbox-unsyncable", "emblem-web", "emblem-people", "emblem-photos", "emblem-star"};42 "dropbox-syncing", \
47//gchar *DEFAULT_EMBLEM_PATHS[2] = { EMBLEMDIR , NULL };43 "dropbox-unsyncable", \
4844 "dropbox-selsync", \
49static void marlin_dropbox_finalize (MarlinPluginsBase* obj);45 "dropbox-app", \
46 "web", \
47 "people", \
48 "photos", \
49 "star"};
50
51static char *emblems[] = {"process-completed-symbolic", \
52 "aptdaemon-upgrade", \
53 "process-error-symbolic", \
54 "aptdaemon-upgrade", \
55 "dropbox-app", \
56 "applications-internet", \
57 "avatar-default", \
58 "emblem-photos-symbolic", \
59 "emblem-favorite-symbolic"};
60
61static void pf_dropbox_finalize (MarlinPluginsBase* obj);
5062
51static gpointer _g_object_ref0 (gpointer self) {63static gpointer _g_object_ref0 (gpointer self) {
52 return self ? g_object_ref (self) : NULL;64 return self ? g_object_ref (self) : NULL;
53}65}
5466
55/*static gchar* current_path = NULL;
56 static gboolean menu_added = FALSE;
57 static GSettings* settings = NULL;
58 static GList *menus = NULL;
59 static GtkWidget *menu;*/
60
61/* probably my favorite function */67/* probably my favorite function */
62static gchar *68static gchar *
63canonicalize_path(gchar *path) {69canonicalize_path(gchar *path) {
@@ -94,7 +100,7 @@
94}100}
95101
96gboolean102gboolean
97reset_all_files(MarlinDropbox *cvs) {103reset_all_files(PFDropbox *cvs) {
98 /* Only run this on the main loop or you'll cause problems. */104 /* Only run this on the main loop or you'll cause problems. */
99105
100 /* this works because you can call a function pointer with106 /* this works because you can call a function pointer with
@@ -104,7 +110,7 @@
104}110}
105111
106static void112static void
107when_file_dies(MarlinDropbox *cvs, GOFFile *file) {113when_file_dies(PFDropbox *cvs, GOFFile *file) {
108 gchar *filename;114 gchar *filename;
109115
110 filename = g_hash_table_lookup(cvs->obj2filename, file);116 filename = g_hash_table_lookup(cvs->obj2filename, file);
@@ -121,141 +127,21 @@
121 g_hash_table_remove(cvs->obj2filename, file);127 g_hash_table_remove(cvs->obj2filename, file);
122}128}
123129
124/*****/130
125#if 0131static void
126gboolean132on_connect(PFDropbox *cvs) {
127add_emblem_paths(GHashTable* emblem_paths_response)133 reset_all_files(cvs);
128{134}
129 /* Only run this on the main loop or you'll cause problems. */135
130 if (!emblem_paths_response)136static void
131 return FALSE;137on_disconnect(PFDropbox *cvs) {
132138 reset_all_files(cvs);
133 gchar **emblem_paths_list;139}
134 int i;140
135141static void
136 GtkIconTheme *theme = gtk_icon_theme_get_default();142handle_shell_touch(GHashTable *args, PFDropbox *cvs) {
137
138 if (emblem_paths_response &&
139 (emblem_paths_list = g_hash_table_lookup(emblem_paths_response, "path"))) {
140 for (i = 0; emblem_paths_list[i] != NULL; i++) {
141 if (emblem_paths_list[i][0])
142 gtk_icon_theme_append_search_path(theme, emblem_paths_list[i]);
143 }
144 }
145 g_hash_table_unref(emblem_paths_response);
146 return FALSE;
147}
148
149gboolean
150remove_emblem_paths(GHashTable* emblem_paths_response)
151{
152 /* Only run this on the main loop or you'll cause problems. */
153 if (!emblem_paths_response)
154 return FALSE;
155
156 gchar **emblem_paths_list = g_hash_table_lookup(emblem_paths_response, "path");
157 if (!emblem_paths_list)
158 goto exit;
159
160 // We need to remove the old paths.
161 GtkIconTheme * icon_theme = gtk_icon_theme_get_default();
162 gchar ** paths;
163 gint path_count;
164
165 gtk_icon_theme_get_search_path(icon_theme, &paths, &path_count);
166
167 gint i, j, out = 0;
168 gboolean found = FALSE;
169 for (i = 0; i < path_count; i++) {
170 gboolean keep = TRUE;
171 for (j = 0; emblem_paths_list[j] != NULL; j++) {
172 if (emblem_paths_list[j][0]) {
173 if (!g_strcmp0(paths[i], emblem_paths_list[j])) {
174 found = TRUE;
175 keep = FALSE;
176 g_free(paths[i]);
177 break;
178 }
179 }
180 }
181 if (keep) {
182 paths[out] = paths[i];
183 out++;
184 }
185 }
186
187 /* If we found one we need to reset the path to
188 accomodate the changes */
189 if (found) {
190 paths[out] = NULL; /* Clear the last one */
191 gtk_icon_theme_set_search_path(icon_theme, (const gchar **)paths, out);
192 }
193
194 g_strfreev(paths);
195exit:
196 g_hash_table_unref(emblem_paths_response);
197 return FALSE;
198}
199
200void get_emblem_paths_cb(GHashTable *emblem_paths_response, MarlinDropbox *cvs)
201{
202 if (!emblem_paths_response) {
203 emblem_paths_response = g_hash_table_new((GHashFunc) g_str_hash,
204 (GEqualFunc) g_str_equal);
205 //FIXME
206 //g_hash_table_insert(emblem_paths_response, "path", DEFAULT_EMBLEM_PATHS);
207 } else {
208 /* Increase the ref so that finish_general_command doesn't delete it. */
209 g_hash_table_ref(emblem_paths_response);
210 }
211
212 g_mutex_lock(cvs->emblem_paths_mutex);
213 if (cvs->emblem_paths) {
214 g_idle_add((GSourceFunc) remove_emblem_paths, cvs->emblem_paths);
215 cvs->emblem_paths = NULL;
216 }
217 cvs->emblem_paths = emblem_paths_response;
218 g_mutex_unlock(cvs->emblem_paths_mutex);
219
220 g_idle_add((GSourceFunc) add_emblem_paths, g_hash_table_ref(emblem_paths_response));
221 g_idle_add((GSourceFunc) reset_all_files, cvs);
222}
223#endif
224
225static void
226on_connect(MarlinDropbox *cvs) {
227 reset_all_files(cvs);
228
229 g_message ("%s", G_STRFUNC);
230 //amtest
231 /* We don't necessarly need the original dropbox icons */
232 /*dropbox_command_client_send_command(&(cvs->dc.dcc),
233 (MarlinDropboxCommandResponseHandler) get_emblem_paths_cb,
234 cvs, "get_emblem_paths", NULL);*/
235}
236
237static void
238on_disconnect(MarlinDropbox *cvs) {
239 reset_all_files(cvs);
240
241 //FIXME
242 g_message ("%s", G_STRFUNC);
243 //amtest
244#if 0
245 g_mutex_lock(cvs->emblem_paths_mutex);
246 /* This call will free the data too. */
247 g_idle_add((GSourceFunc) remove_emblem_paths, cvs->emblem_paths);
248 cvs->emblem_paths = NULL;
249 g_mutex_unlock(cvs->emblem_paths_mutex);
250#endif
251}
252
253static void
254handle_shell_touch(GHashTable *args, MarlinDropbox *cvs) {
255 gchar **path;143 gchar **path;
256144
257 // debug_enter();
258
259 if ((path = g_hash_table_lookup(args, "path")) != NULL &&145 if ((path = g_hash_table_lookup(args, "path")) != NULL &&
260 path[0][0] == '/') {146 path[0][0] == '/') {
261 GOFFile *file;147 GOFFile *file;
@@ -292,13 +178,9 @@
292}178}
293179
294gboolean180gboolean
295marlin_dropbox_finish_file_info_command(DropboxFileInfoCommandResponse *dficr) {181pf_dropbox_finish_file_info_command(DropboxFileInfoCommandResponse *dficr) {
296
297 char *str_emblem;182 char *str_emblem;
298183
299 //debug_enter();
300 //NautilusOperationResult result = NAUTILUS_OPERATION_FAILED;
301
302 if (!dficr->dfic->cancelled) {184 if (!dficr->dfic->cancelled) {
303 gchar **status = NULL;185 gchar **status = NULL;
304 gboolean isdir;186 gboolean isdir;
@@ -311,10 +193,9 @@
311 int i;193 int i;
312 for ( i = 0; status[i] != NULL; i++) {194 for ( i = 0; status[i] != NULL; i++) {
313 if (status[i][0]) {195 if (status[i][0]) {
314 //g_message ("emblem %s", status[i]);196 if ((str_emblem = translate_emblem (status[i])) != NULL) {
315 if ((str_emblem = translate_emblem (status[i])) != NULL)
316 gof_file_add_emblem(dficr->dfic->file, str_emblem);197 gof_file_add_emblem(dficr->dfic->file, str_emblem);
317 else198 } else
318 g_warning ("emblem %s not found - %s", status[i], dficr->dfic->file->uri);199 g_warning ("emblem %s not found - %s", status[i], dficr->dfic->file->uri);
319 }200 }
320 }201 }
@@ -333,16 +214,16 @@
333 if (isdir &&214 if (isdir &&
334 (tag = g_hash_table_lookup(dficr->folder_tag_response, "tag")) != NULL) {215 (tag = g_hash_table_lookup(dficr->folder_tag_response, "tag")) != NULL) {
335 if (strcmp("public", tag[0]) == 0) {216 if (strcmp("public", tag[0]) == 0) {
336 gof_file_add_emblem(dficr->dfic->file, "emblem-web");217 gof_file_add_emblem(dficr->dfic->file, emblems[5]);
337 }218 }
338 else if (strcmp("shared", tag[0]) == 0) {219 else if (strcmp("shared", tag[0]) == 0) {
339 gof_file_add_emblem(dficr->dfic->file, "emblem-people");220 gof_file_add_emblem(dficr->dfic->file, emblems[6]);
340 }221 }
341 else if (strcmp("photos", tag[0]) == 0) {222 else if (strcmp("photos", tag[0]) == 0) {
342 gof_file_add_emblem(dficr->dfic->file, "emblem-photos");223 gof_file_add_emblem(dficr->dfic->file, emblems[7]);
343 }224 }
344 else if (strcmp("sandbox", tag[0]) == 0) {225 else if (strcmp("sandbox", tag[0]) == 0) {
345 gof_file_add_emblem(dficr->dfic->file, "emblem-star");226 gof_file_add_emblem(dficr->dfic->file, emblems[8]);
346 }227 }
347 }228 }
348229
@@ -358,29 +239,19 @@
358 else if (strcmp("unsyncable", status[0]) == 0) {239 else if (strcmp("unsyncable", status[0]) == 0) {
359 emblem_code = 3;240 emblem_code = 3;
360 }241 }
242 else if (strcmp("selsync", status[0]) == 0) {
243 emblem_code = 4;
244 }
245 else if (strcmp("app", status[0]) == 0) {
246 emblem_code = 5;
247 }
361248
362 if (emblem_code > 0) {249 if (emblem_code > 0) {
363 /*
364 debug("%s to %s", emblems[emblem_code-1],
365 g_filename_from_uri(dficr->dfic->file->uri,
366 NULL, NULL));
367 */
368 //FIXME
369 g_message ("emblem code %d", emblem_code);
370 gof_file_add_emblem(dficr->dfic->file, emblems[emblem_code-1]);250 gof_file_add_emblem(dficr->dfic->file, emblems[emblem_code-1]);
371 }251 }
372 }252 }
373 }253 }
374254
375 /* complete the info request */
376 //FIXME
377 /*if (!dropbox_use_operation_in_progress_workaround) {
378 nautilus_info_provider_update_complete_invoke(dficr->dfic->update_complete,
379 dficr->dfic->provider,
380 (NautilusOperationHandle*) dficr->dfic,
381 result);
382 }*/
383
384 /* destroy the objects we created */255 /* destroy the objects we created */
385 if (dficr->file_status_response != NULL)256 if (dficr->file_status_response != NULL)
386 g_hash_table_unref(dficr->file_status_response);257 g_hash_table_unref(dficr->file_status_response);
@@ -390,8 +261,6 @@
390 g_hash_table_unref(dficr->emblems_response);261 g_hash_table_unref(dficr->emblems_response);
391262
392 /* unref the objects we didn't create */263 /* unref the objects we didn't create */
393 //FIXME
394 //g_closure_unref(dficr->dfic->update_complete);
395 g_object_unref(dficr->dfic->file);264 g_object_unref(dficr->dfic->file);
396265
397 /* now free the structs */266 /* now free the structs */
@@ -402,22 +271,15 @@
402}271}
403272
404static void273static void
405marlin_dropbox_real_directory_loaded (MarlinPluginsBase *base, void *user_data)274pf_dropbox_real_directory_loaded (MarlinPluginsBase *base, void *user_data)
406{275{
407 /*GOFFile *file;
408
409 GObject *obj = ((GObject**) user_data)[2];
410 file = g_object_ref ((GOFFile *) obj);
411 g_message ("%s : %s", G_STRFUNC, file->uri);*/
412
413 //unref file
414276
415}277}
416278
417static void279static void
418marlin_dropbox_update_file_info (MarlinPluginsBase *base, GOFFile *file)280pf_dropbox_update_file_info (MarlinPluginsBase *base, GOFFile *file)
419{281{
420 MarlinDropbox *cvs = MARLIN_DROPBOX (base);282 PFDropbox *cvs = PF_DROPBOX (base);
421283
422 gchar *path = NULL;284 gchar *path = NULL;
423285
@@ -443,13 +305,7 @@
443 g_object_weak_unref(G_OBJECT(file), (GWeakNotify) when_file_dies, cvs);305 g_object_weak_unref(G_OBJECT(file), (GWeakNotify) when_file_dies, cvs);
444 g_hash_table_remove(cvs->obj2filename, file);306 g_hash_table_remove(cvs->obj2filename, file);
445 g_hash_table_remove(cvs->filename2obj, stored_filename);307 g_hash_table_remove(cvs->filename2obj, stored_filename);
446 //g_signal_handlers_disconnect_by_func(file, G_CALLBACK(changed_cb), cvs);
447 }308 }
448 //FIXME check
449 /*else if (stored_filename == NULL) {
450 g_critical ("grrrrrrrrr");
451 }*/
452 //#if 0
453 else if (stored_filename == NULL) {309 else if (stored_filename == NULL) {
454 GOFFile *f2;310 GOFFile *f2;
455311
@@ -463,15 +319,12 @@
463 just remove the association to the older file object, it's obsolete319 just remove the association to the older file object, it's obsolete
464 */320 */
465 g_object_weak_unref(G_OBJECT(f2), (GWeakNotify) when_file_dies, cvs);321 g_object_weak_unref(G_OBJECT(f2), (GWeakNotify) when_file_dies, cvs);
466 //g_signal_handlers_disconnect_by_func(f2, G_CALLBACK(changed_cb), cvs);322
467 g_hash_table_remove(cvs->filename2obj, filename);323 g_hash_table_remove(cvs->filename2obj, filename);
468 g_hash_table_remove(cvs->obj2filename, f2);324 g_hash_table_remove(cvs->obj2filename, f2);
469 }325 }
470 }326 }
471 //#endif
472327
473 /* too chatty */
474 /* debug("adding %s <-> 0x%p", filename, file);*/
475 g_object_weak_ref(G_OBJECT(file), (GWeakNotify) when_file_dies, cvs);328 g_object_weak_ref(G_OBJECT(file), (GWeakNotify) when_file_dies, cvs);
476 g_hash_table_insert(cvs->filename2obj, g_strdup(filename), file);329 g_hash_table_insert(cvs->filename2obj, g_strdup(filename), file);
477 g_hash_table_insert(cvs->obj2filename, file, g_strdup(filename));330 g_hash_table_insert(cvs->obj2filename, file, g_strdup(filename));
@@ -488,25 +341,16 @@
488 dfic->cancelled = FALSE;341 dfic->cancelled = FALSE;
489 dfic->provider = base;342 dfic->provider = base;
490 dfic->dc.request_type = GET_FILE_INFO;343 dfic->dc.request_type = GET_FILE_INFO;
491 //FIXME
492 //dfic->update_complete = g_closure_ref(update_complete);
493 dfic->update_complete = NULL;344 dfic->update_complete = NULL;
494 dfic->file = g_object_ref(file);345 dfic->file = g_object_ref(file);
495346
496 dropbox_command_client_request(&(cvs->dc.dcc), (DropboxCommand *) dfic);347 dropbox_command_client_request(&(cvs->dc.dcc), (DropboxCommand *) dfic);
497348
498 //FIXME
499 //*handle = (NautilusOperationHandle *) dfic;
500
501 /*return dropbox_use_operation_in_progress_workaround
502 ? NAUTILUS_OPERATION_COMPLETE
503 : NAUTILUS_OPERATION_IN_PROGRESS;*/
504
505 g_free (path);349 g_free (path);
506}350}
507351
508static char from_hex(gchar ch) {352static char from_hex(gchar ch) {
509 return isdigit(ch) ? ch - '0' : tolower(ch) - 'a' + 10;353 return g_ascii_isdigit(ch) ? ch - '0' : g_ascii_tolower(ch) - 'a' + 10;
510}354}
511355
512// decode in --> out, but dont fill more than n chars into out356// decode in --> out, but dont fill more than n chars into out
@@ -536,7 +380,7 @@
536static void380static void
537menu_item_cb(GtkWidget *item, MenuCallbackData *cb_data)381menu_item_cb(GtkWidget *item, MenuCallbackData *cb_data)
538{382{
539 MarlinDropbox *cvs = cb_data->cvs;383 PFDropbox *cvs = cb_data->cvs;
540 DropboxGeneralCommand *dcac;384 DropboxGeneralCommand *dcac;
541385
542 dcac = g_new(DropboxGeneralCommand, 1);386 dcac = g_new(DropboxGeneralCommand, 1);
@@ -567,12 +411,12 @@
567}411}
568412
569static void413static void
570marlin_dropbox_parse_menu(gchar **options,414pf_dropbox_parse_menu(gchar **options,
571 GtkWidget *menu,415 GtkWidget *menu,
572 MarlinPluginsBase *base,416 MarlinPluginsBase *base,
573 GOFFile *file)417 GOFFile *file)
574{418{
575 MarlinDropbox *cvs = MARLIN_DROPBOX (base);419 PFDropbox *cvs = PF_DROPBOX (base);
576 MenuCallbackData *cb_data;420 MenuCallbackData *cb_data;
577 int i;421 int i;
578422
@@ -593,9 +437,9 @@
593 GhettoURLDecode(verb, verb, strlen(verb));437 GhettoURLDecode(verb, verb, strlen(verb));
594 GhettoURLDecode(item_inner, item_inner, strlen(item_inner));438 GhettoURLDecode(item_inner, item_inner, strlen(item_inner));
595439
596 g_message ("menu %s", item_name);440 g_debug ("menu %s", item_name);
597 g_message ("verb %s", verb);441 g_debug ("verb %s", verb);
598 g_message ("item_inner %s", item_inner);442 g_debug ("item_inner %s", item_inner);
599443
600 cb_data = g_new0 (MenuCallbackData, 1);444 cb_data = g_new0 (MenuCallbackData, 1);
601 cb_data->cvs = cvs;445 cb_data->cvs = cvs;
@@ -664,16 +508,13 @@
664}508}
665509
666static void510static void
667marlin_dropbox_context_menu (MarlinPluginsBase *base, GtkWidget *menu, GList *files)511pf_dropbox_context_menu (MarlinPluginsBase *base, GtkWidget *menu, GList *files)
668{512{
669 MarlinDropbox *cvs = MARLIN_DROPBOX (base);513 PFDropbox *cvs = PF_DROPBOX (base);
670 GOFFile *file;514 GOFFile *file;
671 gchar *filename_un, *filename;515 gchar *filename_un, *filename;
672 int file_count;516 int file_count;
673517
674 g_message ("%s", G_STRFUNC);
675 //context_menu_new (u1, menu);
676
677 cvs->selection = files;518 cvs->selection = files;
678 if ((file_count = g_list_length (cvs->selection)) != 1)519 if ((file_count = g_list_length (cvs->selection)) != 1)
679 return;520 return;
@@ -715,17 +556,17 @@
715 */556 */
716 dropbox_command_client_request(&(cvs->dc.dcc), (DropboxCommand *) dgc);557 dropbox_command_client_request(&(cvs->dc.dcc), (DropboxCommand *) dgc);
717558
718 GTimeVal gtv;559 guint64 gtv;
719560
720 /*561 /*
721 * 4. We have to block until it's done because nautilus expects a reply. But we will562 * 4. We have to block until it's done because nautilus expects a reply. But we will
722 * only block for 50 ms for a reply.563 * only block for 50 ms for a reply.
723 */564 */
724565
725 g_get_current_time(&gtv);566 gtv = g_get_real_time();
726 g_time_val_add(&gtv, 50000);567 gtv = gtv + 5000;
727568
728 GHashTable *context_options_response = g_async_queue_timed_pop(reply_queue, &gtv);569 GHashTable *context_options_response = g_async_queue_timeout_pop(reply_queue, gtv);
729 g_async_queue_unref(reply_queue);570 g_async_queue_unref(reply_queue);
730571
731 if (!context_options_response)572 if (!context_options_response)
@@ -739,16 +580,21 @@
739 GList *toret = NULL;580 GList *toret = NULL;
740581
741 if (options && *options && **options) {582 if (options && *options && **options) {
742 GtkWidget *submenu, *root_item;583 GtkWidget *submenu, *root_item, *separator;
743584
744 root_item = gtk_menu_item_new_with_mnemonic (_("Dropbo_x"));585 root_item = gtk_menu_item_new_with_label (_("Dropbox"));
745 submenu = gtk_menu_new ();586 submenu = gtk_menu_new ();
746 gtk_widget_show (root_item);587 gtk_widget_show (root_item);
747 gtk_menu_item_set_submenu ((GtkMenuItem *) root_item,submenu);588 gtk_menu_item_set_submenu ((GtkMenuItem *) root_item,submenu);
589
590 separator = gtk_separator_menu_item_new ();
591 gtk_widget_show (separator);
592 gtk_menu_shell_append ((GtkMenuShell*) menu, separator);
593
748 gtk_menu_shell_append ((GtkMenuShell*) menu, root_item);594 gtk_menu_shell_append ((GtkMenuShell*) menu, root_item);
749 plugins->menus = g_list_prepend (plugins->menus, _g_object_ref0 (root_item));595 plugins->menus = g_list_prepend (plugins->menus, _g_object_ref0 (root_item));
750596
751 marlin_dropbox_parse_menu(options, submenu, base, file);597 pf_dropbox_parse_menu(options, submenu, base, file);
752 }598 }
753599
754 g_hash_table_unref(context_options_response);600 g_hash_table_unref(context_options_response);
@@ -758,22 +604,18 @@
758}604}
759605
760static void606static void
761marlin_dropbox_class_init (MarlinDropboxClass *klass) {607pf_dropbox_class_init (PFDropboxClass *klass) {
762 MarlinPluginsBaseClass *object_class = MARLIN_PLUGINS_BASE_CLASS (klass);608 MarlinPluginsBaseClass *object_class = MARLIN_PLUGINS_BASE_CLASS (klass);
763 //g_type_class_add_private (klass, sizeof (MarlinDropboxPrivate));
764609
765 object_class->finalize = marlin_dropbox_finalize;610 object_class->finalize = pf_dropbox_finalize;
766 object_class->directory_loaded = marlin_dropbox_real_directory_loaded;611 object_class->directory_loaded = pf_dropbox_real_directory_loaded;
767 object_class->update_file_info = marlin_dropbox_update_file_info;612 object_class->update_file_info = pf_dropbox_update_file_info;
768 object_class->context_menu = marlin_dropbox_context_menu;613 object_class->context_menu = pf_dropbox_context_menu;
769}614}
770615
771616
772static void617static void
773marlin_dropbox_init (MarlinDropbox *cvs) {618pf_dropbox_init (PFDropbox *cvs) {
774 //self->priv = MARLIN_DROPBOX_GET_PRIVATE (self);
775 //self->priv = g_new0 (MarlinDropboxPrivate, 1);
776
777 cvs->filename2obj = g_hash_table_new_full((GHashFunc) g_str_hash,619 cvs->filename2obj = g_hash_table_new_full((GHashFunc) g_str_hash,
778 (GEqualFunc) g_str_equal,620 (GEqualFunc) g_str_equal,
779 (GDestroyNotify) g_free,621 (GDestroyNotify) g_free,
@@ -782,16 +624,13 @@
782 (GEqualFunc) g_direct_equal,624 (GEqualFunc) g_direct_equal,
783 (GDestroyNotify) NULL,625 (GDestroyNotify) NULL,
784 (GDestroyNotify) g_free);626 (GDestroyNotify) g_free);
785 //amtest
786 /*cvs->emblem_paths_mutex = g_mutex_new();
787 cvs->emblem_paths = NULL;*/
788627
789 /* setup the connection obj*/628 /* setup the connection obj*/
790 dropbox_client_setup(&(cvs->dc));629 dropbox_client_setup(&(cvs->dc));
791630
792 /* our hooks */631 /* our hooks */
793 /* tricky name: shell_touch signal is used for real time events too (like transfert done event) */632 /* tricky name: shell_touch signal is used for real time events too (like transfert done event) */
794 marlin_dropbox_hooks_add(&(cvs->dc.hookserv), "shell_touch",633 pf_dropbox_hooks_add(&(cvs->dc.hookserv), "shell_touch",
795 (DropboxUpdateHook) handle_shell_touch, cvs);634 (DropboxUpdateHook) handle_shell_touch, cvs);
796635
797 /* add connection handlers */636 /* add connection handlers */
@@ -809,25 +648,25 @@
809648
810649
811static void650static void
812marlin_dropbox_finalize (MarlinPluginsBase* obj) {651pf_dropbox_finalize (MarlinPluginsBase* obj) {
813 MarlinDropbox * self = MARLIN_DROPBOX (obj);652 PFDropbox * self = PF_DROPBOX (obj);
814653
815 //_g_object_unref0 (self->priv->trash_monitor);654 MARLIN_PLUGINS_BASE_CLASS (pf_dropbox_parent_class)->finalize (obj);
816 MARLIN_PLUGINS_BASE_CLASS (marlin_dropbox_parent_class)->finalize (obj);
817}655}
818656
819MarlinDropbox* marlin_dropbox_new () {657PFDropbox* pf_dropbox_new () {
820 MarlinDropbox *u1;658 PFDropbox *u1;
821659
822 u1 = (MarlinDropbox*) marlin_plugins_base_construct (MARLIN_TYPE_DROPBOX);660 u1 = (PFDropbox*) marlin_plugins_base_construct (PF_TYPE_DROPBOX);
823661
824 return u1;662 return u1;
825}663}
826664
827MarlinPluginsBase* module_init()665MarlinPluginsBase* module_init()
828{666{
829 MarlinDropbox* u1 = marlin_dropbox_new ();667 PFDropbox* u1 = pf_dropbox_new ();
830668
831 return MARLIN_PLUGINS_BASE (u1);669 return MARLIN_PLUGINS_BASE (u1);
832}670}
833671
672
834673
=== modified file 'plugin.h'
--- plugin.h 2016-06-24 12:59:58 +0000
+++ plugin.h 2016-06-24 12:59:58 +0000
@@ -1,12 +1,12 @@
1/*1/*
2 * Copyright (C) 2011 ammonkey <am.monkeyd@gmail.com>2 * Copyright (C) 2011 ammonkey <am.monkeyd@gmail.com>
3 *3 *
4 * Marlin is free software: you can redistribute it and/or modify it4 * PantheonFiles is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation, either version 3 of the License, or6 * Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.7 * (at your option) any later version.
8 *8 *
9 * Marlin is distributed in the hope that it will be useful, but9 * PantheonFiles is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.12 * See the GNU General Public License for more details.
@@ -15,51 +15,46 @@
15 * with this program. If not, see <http://www.gnu.org/licenses/>.15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */16 */
1717
18#ifndef MARLIN_DROPBOX_H18#ifndef PF_DROPBOX_H
19#define MARLIN_DROPBOX_H19#define PF_DROPBOX_H
2020
21#include <glib.h>21#include <glib.h>
22#include <glib-object.h>22#include <glib-object.h>
23#include <marlincore.h>23#include <pantheon-files-core.h>
24//#include <dbus/dbus-glib.h>
2524
26#include "dropbox-command-client.h"25#include "dropbox-command-client.h"
27#include "dropbox-hooks.h"26#include "dropbox-hooks.h"
28#include "dropbox-client.h"27#include "dropbox-client.h"
2928
30#define MARLIN_TYPE_DROPBOX (marlin_dropbox_get_type ())29#define PF_TYPE_DROPBOX (pf_dropbox_get_type ())
31#define MARLIN_DROPBOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MARLIN_TYPE_DROPBOX, MarlinDropbox))30#define PF_DROPBOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PF_TYPE_DROPBOX, PFDropbox))
32#define MARLIN_DROPBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MARLIN_TYPE_DROPBOX, MarlinDropboxClass))31#define PF_DROPBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PF_TYPE_DROPBOX, PFDropboxClass))
33#define MARLIN_IS_DROPBOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MARLIN_TYPE_DROPBOX))32#define PF_IS_DROPBOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PF_TYPE_DROPBOX))
34#define MARLIN_IS_DROPBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MARLIN_TYPE_DROPBOX))33#define PF_IS_DROPBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PF_TYPE_DROPBOX))
35#define MARLIN_DROPBOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MARLIN_TYPE_DROPBOX, MarlinDropboxClass))34#define PF_DROPBOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PF_TYPE_DROPBOX, PFDropboxClass))
3635
37typedef struct _MarlinDropbox MarlinDropbox;36typedef struct _PFDropbox PFDropbox;
38typedef struct _MarlinDropboxClass MarlinDropboxClass;37typedef struct _PFDropboxClass PFDropboxClass;
39typedef struct _MarlinDropboxPrivate MarlinDropboxPrivate;38typedef struct _PFDropboxPrivate PFDropboxPrivate;
40#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))39#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
4140
42struct _MarlinDropbox {41struct _PFDropbox {
43 MarlinPluginsBase parent_instance;42 MarlinPluginsBase parent_instance;
44 //MarlinDropboxPrivate * priv;
4543
46 GHashTable *filename2obj;44 GHashTable *filename2obj;
47 GHashTable *obj2filename;45 GHashTable *obj2filename;
48 /*GMutex *emblem_paths_mutex;
49 GHashTable *emblem_paths;*/
50 DropboxClient dc;46 DropboxClient dc;
5147
52 GList *selection;48 GList *selection;
53};49};
5450
55struct _MarlinDropboxClass {51struct _PFDropboxClass {
56 MarlinPluginsBaseClass parent_class;52 MarlinPluginsBaseClass parent_class;
57};53};
5854
59struct _MarlinDropboxPrivate {55struct _PFDropboxPrivate {
60 /*MarlinTrashMonitor* trash_monitor;*/
61};56};
6257
63GType marlin_dropbox_get_type (void) G_GNUC_CONST;58GType pf_dropbox_get_type (void) G_GNUC_CONST;
6459
65#endif60#endif

Subscribers

People subscribed via source and target branches