28
28
G_DEFINE_TYPE (MarlinDropbox, marlin_dropbox, MARLIN_PLUGINS_TYPE_BASE);
30
static char *db_emblems[] = {"dropbox-uptodate", "dropbox-syncing", "dropbox-unsyncable"};
31
static char *emblems[] = {"emblem-ubuntuone-synchronized", "emblem-ubuntuone-updating", "dropbox-unsyncable"};
30
static char *db_emblems[] = {"dropbox-uptodate", "dropbox-syncing", "dropbox-unsyncable", "web", "people", "photos", "star"};
31
static char *emblems[] = {"emblem-ubuntuone-synchronized", "emblem-ubuntuone-updating", "dropbox-unsyncable", "emblem-web", "emblem-people", "emblem-photos", "emblem-star"};
32
32
//gchar *DEFAULT_EMBLEM_PATHS[2] = { EMBLEMDIR , NULL };
34
34
static void marlin_dropbox_finalize (MarlinPluginsBase* obj);
72
reset_file(GOFFile *file) {
73
debug("resetting file %p", (void *) file);
74
gof_file_update_emblem (file);
78
reset_all_files(MarlinDropbox *cvs) {
79
/* Only run this on the main loop or you'll cause problems. */
81
/* this works because you can call a function pointer with
82
more arguments than it takes */
83
g_hash_table_foreach(cvs->obj2filename, (GHFunc) reset_file, NULL);
72
88
when_file_dies(MarlinDropbox *cvs, GOFFile *file) {
183
199
g_mutex_unlock(cvs->emblem_paths_mutex);
185
201
g_idle_add((GSourceFunc) add_emblem_paths, g_hash_table_ref(emblem_paths_response));
187
//g_idle_add((GSourceFunc) reset_all_files, cvs);
202
g_idle_add((GSourceFunc) reset_all_files, cvs);
192
207
on_connect(MarlinDropbox *cvs) {
193
//reset_all_files(cvs);
208
reset_all_files(cvs);
195
210
g_message ("%s", G_STRFUNC);
235
handle_shell_touch(GHashTable *args, MarlinDropbox *cvs) {
240
if ((path = g_hash_table_lookup(args, "path")) != NULL &&
245
filename = canonicalize_path(path[0]);
247
debug("shell touch for %s", filename);
249
file = g_hash_table_lookup(cvs->filename2obj, filename);
252
debug("gonna reset %s", filename);
220
262
translate_emblem (char *str)
266
for (i; i<sizeof(emblems); i++) {
225
267
if (strcmp (str, db_emblems[i]) == 0) {
226
268
return emblems[i];
245
287
isdir = dficr->dfic->file->is_directory;
248
/*if (dficr->folder_tag_response != NULL)
249
g_critical ("hummmmmmmmmmmmmmm");*/
251
289
/* if we have emblems just use them. */
252
290
if (dficr->emblems_response != NULL &&
253
291
(status = g_hash_table_lookup(dficr->emblems_response, "emblems")) != NULL) {
255
293
for ( i = 0; status[i] != NULL; i++) {
256
294
if (status[i][0]) {
295
g_message ("emblem %s", status[i]);
257
296
if ((str_emblem = translate_emblem (status[i])) != NULL)
258
297
gof_file_add_emblem(dficr->dfic->file, str_emblem);
299
g_warning ("emblem %s not found - %s", status[i], dficr->dfic->file->uri);
261
//result = NAUTILUS_OPERATION_COMPLETE;
263
303
/* if the file status command went okay */
264
//FIXME double check and clean this mess
265
/* icon_overlay_file_status and get_emblems seems to both provide the file status */
267
//else if ((dficr->file_status_response != NULL &&
268
/*if ((dficr->file_status_response != NULL &&
304
else if ((dficr->file_status_response != NULL &&
270
306
g_hash_table_lookup(dficr->file_status_response, "status")) != NULL) &&
271
307
((isdir == TRUE &&
272
dficr->folder_tag_response != NULL) || isdir == FALSE)) {*/
273
if (isdir == TRUE && dficr->folder_tag_response != NULL) {
308
dficr->folder_tag_response != NULL) || isdir == FALSE)) {
310
g_critical ("grrrr %s", G_STRFUNC);
274
311
gchar **tag = NULL;
276
313
/* set the tag emblem */
278
(tag = g_hash_table_lookup(dficr->folder_tag_response, "tag")) != NULL) {*/
279
if ((tag = g_hash_table_lookup(dficr->folder_tag_response, "tag")) != NULL) {
315
(tag = g_hash_table_lookup(dficr->folder_tag_response, "tag")) != NULL) {
280
316
if (strcmp("public", tag[0]) == 0) {
281
317
gof_file_add_emblem(dficr->dfic->file, "emblem-web");
311
346
g_filename_from_uri(dficr->dfic->file->uri,
314
350
g_message ("emblem code %d", emblem_code);
315
351
gof_file_add_emblem(dficr->dfic->file, emblems[emblem_code-1]);
317
//result = NAUTILUS_OPERATION_COMPLETE;
327
361
(NautilusOperationHandle*) dficr->dfic,
364
//reset_file (dficr->dfic->file);
365
gof_monitor_file_changed (dficr->dfic->file);
331
367
/* destroy the objects we created */
332
368
if (dficr->file_status_response != NULL)
393
429
//g_signal_handlers_disconnect_by_func(file, G_CALLBACK(changed_cb), cvs);
432
/*else if (stored_filename == NULL) {
433
g_critical ("grrrrrrrrr");
397
436
else if (stored_filename == NULL) {
398
NautilusFileInfo *f2;
400
439
if ((f2 = g_hash_table_lookup(cvs->filename2obj, filename)) != NULL) {
401
440
/* if the filename exists in the filename2obj hash
407
446
just remove the association to the older file object, it's obsolete
409
448
g_object_weak_unref(G_OBJECT(f2), (GWeakNotify) when_file_dies, cvs);
410
g_signal_handlers_disconnect_by_func(f2, G_CALLBACK(changed_cb), cvs);
449
//g_signal_handlers_disconnect_by_func(f2, G_CALLBACK(changed_cb), cvs);
411
450
g_hash_table_remove(cvs->filename2obj, filename);
412
451
g_hash_table_remove(cvs->obj2filename, f2);
418
457
/* debug("adding %s <-> 0x%p", filename, file);*/
505
544
dropbox_client_setup(&(cvs->dc));
508
//FIXME remove marlin monitor the directory too.
509
/*nautilus_dropbox_hooks_add(&(cvs->dc.hookserv), "shell_touch",
510
(DropboxUpdateHook) handle_shell_touch, cvs);*/
547
/* tricky name: shell_touch signal is used for real time events too (like transfert done event) */
548
marlin_dropbox_hooks_add(&(cvs->dc.hookserv), "shell_touch",
549
(DropboxUpdateHook) handle_shell_touch, cvs);
512
551
/* add connection handlers */
513
552
dropbox_client_add_on_connect_hook(&(cvs->dc),