summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2021-04-24 08:39:18 +0200
committerDave Andreoli <dave@gurumeditation.it>2021-04-24 08:39:18 +0200
commit9d06c71425124f1899fecae4b621960391577616 (patch)
treed9b5327c2488a6f1990211bab960700174517a74
parentc45452ccaf37eca33fe7e84188d76848419486d7 (diff)
PoorMan debug utils
-rw-r--r--src/backend_mount.c12
-rw-r--r--src/backend_udisks2.c44
-rw-r--r--src/e_mod_places.c21
3 files changed, 47 insertions, 30 deletions
diff --git a/src/backend_mount.c b/src/backend_mount.c
index e6a0ebf..3144ef7 100644
--- a/src/backend_mount.c
+++ b/src/backend_mount.c
@@ -7,6 +7,10 @@
7#include "e_mod_places.h" 7#include "e_mod_places.h"
8 8
9 9
10/* Enable/Disable debug messages */
11// #define PDBG(...) do {} while (0)
12#define PDBG(...) printf("PLACES(mnt): "__VA_ARGS__)
13
10 14
11#define FSTAB_FILE "/etc/fstab" 15#define FSTAB_FILE "/etc/fstab"
12#define MTAB_FILE "/proc/mounts" 16#define MTAB_FILE "/proc/mounts"
@@ -236,12 +240,12 @@ _places_mount_mtab_timer_cb(void *data)
236Eina_Bool 240Eina_Bool
237places_mount_init(void) 241places_mount_init(void)
238{ 242{
239 printf("PLACES: mount: init()\n"); 243 PDBG("init()\n");
240 244
241 if (!ecore_file_exists(FSTAB_FILE) || 245 if (!ecore_file_exists(FSTAB_FILE) ||
242 !ecore_file_exists(MTAB_FILE)) 246 !ecore_file_exists(MTAB_FILE))
243 { 247 {
244 printf("PLACES: mount: Cannot find required files\n"); 248 printf("PLACES(mnt): Cannot find required files\n");
245 return EINA_FALSE; 249 return EINA_FALSE;
246 } 250 }
247 251
@@ -260,12 +264,12 @@ places_mount_init(void)
260void 264void
261places_mount_shutdown(void) 265places_mount_shutdown(void)
262{ 266{
263 printf("PLACES: mtab: shutdown()\n"); 267 PDBG("shutdown()\n");
264 E_FREE_FUNC(mtab_timer, ecore_timer_del); 268 E_FREE_FUNC(mtab_timer, ecore_timer_del);
265 E_FREE_FUNC(know_mounts, eina_list_free); 269 E_FREE_FUNC(know_mounts, eina_list_free);
266 E_FREE_FUNC(eeh1, ecore_event_handler_del); 270 E_FREE_FUNC(eeh1, ecore_event_handler_del);
267 E_FREE_FUNC(eeh2, ecore_event_handler_del); 271 E_FREE_FUNC(eeh2, ecore_event_handler_del);
268} 272}
269 273
270 274#undef PDBG
271#endif 275#endif
diff --git a/src/backend_udisks2.c b/src/backend_udisks2.c
index 55faef0..db586aa 100644
--- a/src/backend_udisks2.c
+++ b/src/backend_udisks2.c
@@ -10,6 +10,11 @@
10#include "e_mod_places.h" 10#include "e_mod_places.h"
11 11
12 12
13/* Enable/Disable debug messages */
14// #define PDBG(...) do {} while (0)
15#define PDBG(...) printf("PLACES(ud2): "__VA_ARGS__)
16
17
13/* UDisks2 defines */ 18/* UDisks2 defines */
14#define UDISKS2_BUS "org.freedesktop.UDisks2" 19#define UDISKS2_BUS "org.freedesktop.UDisks2"
15#define UDISKS2_PATH "/org/freedesktop/UDisks2" 20#define UDISKS2_PATH "/org/freedesktop/UDisks2"
@@ -66,14 +71,14 @@ static Eldbus_Object *_places_ud2_object_manager = NULL;
66Eina_Bool 71Eina_Bool
67places_udisks2_init(void) 72places_udisks2_init(void)
68{ 73{
69 printf("PLACES: udisks2: init()\n"); 74 PDBG("init()\n");
70 75
71 EINA_SAFETY_ON_FALSE_RETURN_VAL(eldbus_init(), EINA_FALSE); 76 EINA_SAFETY_ON_FALSE_RETURN_VAL(eldbus_init(), EINA_FALSE);
72 77
73 _places_ud2_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); 78 _places_ud2_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM);
74 if (!_places_ud2_conn) 79 if (!_places_ud2_conn)
75 { 80 {
76 printf("PLACES: udisks2: Error connecting to system bus.\n"); 81 printf("udisks2: Error connecting to system bus.\n");
77 return EINA_FALSE; 82 return EINA_FALSE;
78 } 83 }
79 84
@@ -86,7 +91,7 @@ places_udisks2_init(void)
86void 91void
87places_udisks2_shutdown(void) 92places_udisks2_shutdown(void)
88{ 93{
89 printf("PLACES: udisks2: shutdown()\n"); 94 PDBG("shutdown()\n");
90 E_FREE_FUNC(_places_ud2_object_manager, eldbus_object_unref); 95 E_FREE_FUNC(_places_ud2_object_manager, eldbus_object_unref);
91 E_FREE_FUNC(_places_ud2_conn, eldbus_connection_unref); 96 E_FREE_FUNC(_places_ud2_conn, eldbus_connection_unref);
92 eldbus_shutdown(); 97 eldbus_shutdown();
@@ -168,7 +173,6 @@ _places_udisks2_string_convert(Eldbus_Message_Iter *ay)
168 if (!p) break; 173 if (!p) break;
169 p++; 174 p++;
170 } 175 }
171 // printf("PLACES: stupid string %s\n", str);
172 return strdup(buf); 176 return strdup(buf);
173} 177}
174 178
@@ -212,7 +216,7 @@ _places_ud2_get_managed_objects_cb(void *data, const Eldbus_Message *msg, Eldbus
212 216
213 PLACES_ON_MSG_ERROR_RETURN(msg); 217 PLACES_ON_MSG_ERROR_RETURN(msg);
214 218
215 printf("PLACES: GetManagedObjects\n"); 219 PDBG("GetManagedObjects\n");
216 if (!eldbus_message_arguments_get(msg, "a{oa{sa{sv}}}", &objs_array)) 220 if (!eldbus_message_arguments_get(msg, "a{oa{sa{sv}}}", &objs_array))
217 return; 221 return;
218 222
@@ -240,7 +244,7 @@ _places_ud2_interfaces_added_cb(void *data, const Eldbus_Message *msg)
240 244
241 if (eldbus_message_arguments_get(msg, "oa{sa{sv}}", &obj_path, &ifaces_array)) 245 if (eldbus_message_arguments_get(msg, "oa{sa{sv}}", &obj_path, &ifaces_array))
242 { 246 {
243 printf("PLACES: InterfacesAdded on obj: %s\n", obj_path); 247 PDBG("InterfacesAdded on obj: %s\n", obj_path);
244 // we are only interested at block_device objects 248 // we are only interested at block_device objects
245 if (eina_str_has_prefix(obj_path, UDISKS2_BLOCK_PREFIX)) 249 if (eina_str_has_prefix(obj_path, UDISKS2_BLOCK_PREFIX))
246 _places_ud2_read_block_ifaces(obj_path, ifaces_array, EINA_FALSE); 250 _places_ud2_read_block_ifaces(obj_path, ifaces_array, EINA_FALSE);
@@ -263,7 +267,7 @@ _places_ud2_interfaces_removed_cb(void *data, const Eldbus_Message *msg)
263 267
264 while (eldbus_message_iter_get_and_next(array_ifaces, 's', &iface_name)) 268 while (eldbus_message_iter_get_and_next(array_ifaces, 's', &iface_name))
265 { 269 {
266 printf("PLACES: InterfaceRemoved obj:%s - iface:%s\n", obj_path, iface_name); 270 PDBG("InterfaceRemoved obj:%s - iface:%s\n", obj_path, iface_name);
267 if (eina_streq(iface_name, UDISKS2_FILESYSTEM_IFACE) || 271 if (eina_streq(iface_name, UDISKS2_FILESYSTEM_IFACE) ||
268 eina_streq(iface_name, UDISKS2_BLOCK_IFACE)) 272 eina_streq(iface_name, UDISKS2_BLOCK_IFACE))
269 if ((vol = places_volume_by_id_get(obj_path))) 273 if ((vol = places_volume_by_id_get(obj_path)))
@@ -288,7 +292,7 @@ _places_ud2_block_props_changed_cb(void *data, const Eldbus_Message *msg)
288 &changed_props, &invalidated_props)) 292 &changed_props, &invalidated_props))
289 return; 293 return;
290 294
291 printf("PLACES: PropertiesChanged obj:%s - iface:%s\n", vol->id, iface_name); 295 PDBG("PropertiesChanged obj:%s - iface:%s\n", vol->id, iface_name);
292 296
293 // atm we are only intrested in the mounted state (on the FS iface) 297 // atm we are only intrested in the mounted state (on the FS iface)
294 if (!eina_streq(iface_name, UDISKS2_FILESYSTEM_IFACE)) 298 if (!eina_streq(iface_name, UDISKS2_FILESYSTEM_IFACE))
@@ -299,7 +303,7 @@ _places_ud2_block_props_changed_cb(void *data, const Eldbus_Message *msg)
299 if (!eldbus_message_iter_arguments_get(props_entry, "sv", &prop_name, &var)) 303 if (!eldbus_message_iter_arguments_get(props_entry, "sv", &prop_name, &var))
300 continue; 304 continue;
301 305
302 printf("PLACES: Changed prop: %s\n", prop_name); 306 PDBG(" Changed prop: %s\n", prop_name);
303 if (eina_streq(prop_name, "MountPoints")) 307 if (eina_streq(prop_name, "MountPoints"))
304 { 308 {
305 Eldbus_Message_Iter *mounts_array, *ay; 309 Eldbus_Message_Iter *mounts_array, *ay;
@@ -329,7 +333,7 @@ _places_ud2_drive_props_changed_cb(void *data, const Eldbus_Message *msg)
329 &changed_props, &invalidated_props)) 333 &changed_props, &invalidated_props))
330 return; 334 return;
331 335
332 printf("PLACES: PropertiesChanged obj:%s - iface:%s\n", vol->id, iface_name); 336 PDBG("PropertiesChanged obj:%s - iface:%s\n", vol->id, iface_name);
333 if (eina_streq(iface_name, UDISKS2_DRIVE_IFACE)) 337 if (eina_streq(iface_name, UDISKS2_DRIVE_IFACE))
334 _places_ud2_read_drive_properies(vol, changed_props); 338 _places_ud2_read_drive_properies(vol, changed_props);
335} 339}
@@ -352,19 +356,19 @@ _places_ud2_read_block_ifaces(const char *block_obj_path, Eldbus_Message_Iter *i
352 unsigned long long blockdevice_size = 0; 356 unsigned long long blockdevice_size = 0;
353 unsigned long long filesystem_size = 0; 357 unsigned long long filesystem_size = 0;
354 358
355 printf("PLACES: Parsing block_device: %s\n", block_obj_path); 359 PDBG("Parsing block_device: %s\n", block_obj_path);
356 360
357 while (eldbus_message_iter_get_and_next(ifaces_array, 'e', &iface_entry)) 361 while (eldbus_message_iter_get_and_next(ifaces_array, 'e', &iface_entry))
358 { 362 {
359 if (!eldbus_message_iter_arguments_get(iface_entry, "sa{sv}", &iface_name, &props_array)) 363 if (!eldbus_message_iter_arguments_get(iface_entry, "sa{sv}", &iface_name, &props_array))
360 continue; 364 continue;
361 365
362 // printf("PLACES: Iface: %s\n", iface_name); 366 // PDBG("PLACES: Iface: %s\n", iface_name);
363 while (eldbus_message_iter_get_and_next(props_array, 'e', &props_entry)) 367 while (eldbus_message_iter_get_and_next(props_array, 'e', &props_entry))
364 { 368 {
365 if (!eldbus_message_iter_arguments_get(props_entry, "sv", &key, &var)) 369 if (!eldbus_message_iter_arguments_get(props_entry, "sv", &key, &var))
366 continue; 370 continue;
367 // printf("PLACES: Prop: %s\n", key); 371 // PDBG("PLACES: Prop: %s\n", key);
368 372
369 /* block device with the following ifaces must be ignored */ 373 /* block device with the following ifaces must be ignored */
370 if(eina_streq(iface_name, UDISKS2_PARTITIONTABLE_IFACE) || 374 if(eina_streq(iface_name, UDISKS2_PARTITIONTABLE_IFACE) ||
@@ -418,11 +422,11 @@ _places_ud2_read_block_ifaces(const char *block_obj_path, Eldbus_Message_Iter *i
418 mount_point = _places_udisks2_string_convert(chrarray); 422 mount_point = _places_udisks2_string_convert(chrarray);
419 } 423 }
420 } 424 }
421 // else printf("PLACES: WARNING - Unknown iface: %s\n", iface_name); 425 // else PDBG("PLACES: WARNING - Unknown iface: %s\n", iface_name);
422 } 426 }
423 } 427 }
424 428
425 printf("PLACES: Found device: %s\n", block_obj_path); 429 PDBG("Found device: %s\n", block_obj_path);
426 430
427 // create (or get an already created) places Volume 431 // create (or get an already created) places Volume
428 Volume *vol = _places_ud2_volume_add(block_obj_path, drive_obj_path, first_time); 432 Volume *vol = _places_ud2_volume_add(block_obj_path, drive_obj_path, first_time);
@@ -451,7 +455,7 @@ _places_ud2_read_block_ifaces(const char *block_obj_path, Eldbus_Message_Iter *i
451 eldbus_proxy_property_get_all(proxy, _places_ud2_drive_props_cb, vol); 455 eldbus_proxy_property_get_all(proxy, _places_ud2_drive_props_cb, vol);
452 eldbus_proxy_unref(proxy); 456 eldbus_proxy_unref(proxy);
453 } 457 }
454 else printf("PLACES: WARNING - NO DRIVE FOR OBJECT %s\n", block_obj_path); 458 else PDBG("WARNING - NO DRIVE FOR OBJECT %s\n", block_obj_path);
455 459
456skip: 460skip:
457 if (device) free(device); 461 if (device) free(device);
@@ -469,7 +473,7 @@ _places_ud2_drive_props_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending
469 EINA_SAFETY_ON_NULL_RETURN(vol); 473 EINA_SAFETY_ON_NULL_RETURN(vol);
470 PLACES_ON_MSG_ERROR_RETURN(msg); 474 PLACES_ON_MSG_ERROR_RETURN(msg);
471 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_arguments_get(msg, "a{sv}", &props_array)); 475 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_arguments_get(msg, "a{sv}", &props_array));
472 printf("PLACES: Drive properties for: %s\n", vol->id); 476 PDBG("Drive properties for: %s\n", vol->id);
473 _places_ud2_read_drive_properies(vol, props_array); 477 _places_ud2_read_drive_properies(vol, props_array);
474} 478}
475 479
@@ -531,7 +535,7 @@ static void
531_places_ud2_volume_finalize(Volume *vol) 535_places_ud2_volume_finalize(Volume *vol)
532{ 536{
533 Eina_Bool is_valid = EINA_TRUE; 537 Eina_Bool is_valid = EINA_TRUE;
534 printf("PLACES: Validating %s\n", vol->id); 538 PDBG("Validating %s\n", vol->id);
535 539
536 // set mounted state 540 // set mounted state
537 if (vol->mount_point && vol->mount_point[0]) 541 if (vol->mount_point && vol->mount_point[0])
@@ -597,7 +601,7 @@ _places_ud2_mount_func(Volume *vol, Eina_List *opts)
597 // const char *opt_txt; 601 // const char *opt_txt;
598 // EINA_LIST_FOREACH(opts, l, opt_txt) 602 // EINA_LIST_FOREACH(opts, l, opt_txt)
599 // { 603 // {
600 // // printf(" opt: '%s'\n", opt_txt); 604 // // PDBG(" opt: '%s'\n", opt_txt);
601 // eldbus_message_iter_basic_append(array, 's', opt_txt); 605 // eldbus_message_iter_basic_append(array, 's', opt_txt);
602 // } 606 // }
603 // eldbus_message_iter_container_close(main_iter, array); 607 // eldbus_message_iter_container_close(main_iter, array);
@@ -641,5 +645,5 @@ _places_ud2_eject_func(Volume *vol, Eina_List *opts)
641 eldbus_object_send(bdata->drive_obj, msg, _places_udisks2_task_cb, vol, -1); 645 eldbus_object_send(bdata->drive_obj, msg, _places_udisks2_task_cb, vol, -1);
642} 646}
643 647
644 648#undef PDBG
645#endif 649#endif
diff --git a/src/e_mod_places.c b/src/e_mod_places.c
index 6ea3cd6..5edfabc 100644
--- a/src/e_mod_places.c
+++ b/src/e_mod_places.c
@@ -26,6 +26,12 @@
26#endif 26#endif
27 27
28 28
29
30/* Enable/Disable debug messages */
31// #define PDBG(...) do {} while (0)
32#define PDBG(...) printf("PLACES: "__VA_ARGS__)
33
34
29/* Local Typedefs */ 35/* Local Typedefs */
30typedef struct _FreespaceThreadData FreespaceThreadData; 36typedef struct _FreespaceThreadData FreespaceThreadData;
31struct _FreespaceThreadData 37struct _FreespaceThreadData
@@ -68,7 +74,7 @@ places_init(void)
68{ 74{
69 volumes = NULL; 75 volumes = NULL;
70 76
71 printf("PLACES: Init\n"); 77 PDBG("module init\n");
72 78
73#ifdef PLACES_HAVE_SYSTEMD 79#ifdef PLACES_HAVE_SYSTEMD
74 places_systemd_init(); 80 places_systemd_init();
@@ -480,7 +486,7 @@ places_fill_box(Evas_Object *main, Eina_Bool horiz)
480 486
481 edje_object_calc_force(main); 487 edje_object_calc_force(main);
482 edje_object_size_min_restricted_calc(main, &min_w, &min_h, 99, 1); 488 edje_object_size_min_restricted_calc(main, &min_w, &min_h, 99, 1);
483 // printf("PLACES: SIZE: %d %d\n", min_w, min_h); 489 // PDBG("SIZE: %d %d\n", min_w, min_h);
484 evas_object_size_hint_min_set(main, min_w, min_h); 490 evas_object_size_hint_min_set(main, min_w, min_h);
485} 491}
486 492
@@ -608,7 +614,7 @@ _places_freespace_thread_run(void *data, Ecore_Thread *thread)
608 FreespaceThreadData *td = NULL; 614 FreespaceThreadData *td = NULL;
609 struct statvfs s; 615 struct statvfs s;
610 616
611 // printf("PLACES: THIS RUN IN THREAD %p\n", thread); 617 // PDBG("THIS RUN IN THREAD %p\n", thread);
612 618
613 if (ecore_thread_check(thread) == EINA_TRUE) // thread cancelled 619 if (ecore_thread_check(thread) == EINA_TRUE) // thread cancelled
614 return; 620 return;
@@ -650,7 +656,7 @@ _places_freespace_thread_done(void *data, Ecore_Thread *thread)
650 E_FREE(td); 656 E_FREE(td);
651 } 657 }
652 658
653 // printf("PLACES: THREAD DONE %p\n", thread); 659 // PDBG(" THREAD DONE %p\n", thread);
654 freespace_thread = NULL; 660 freespace_thread = NULL;
655} 661}
656 662
@@ -675,10 +681,10 @@ _places_freespace_timer_cb(void *data EINA_UNUSED)
675 Eina_List *l, *tdl = NULL; 681 Eina_List *l, *tdl = NULL;
676 FreespaceThreadData *td = NULL; 682 FreespaceThreadData *td = NULL;
677 683
678 // printf("PLACES: TIMER %.1f\n", ecore_time_get()); 684 // PDBG("TIMER %.1f\n", ecore_time_get());
679 if (freespace_thread) 685 if (freespace_thread)
680 { 686 {
681 // printf("PLACES: *** SOMETHING WRONG *** thread:%p still running...\n", freespace_thread); 687 // PDBG("*** SOMETHING WRONG *** thread:%p still running...\n", freespace_thread);
682 return ECORE_CALLBACK_RENEW; 688 return ECORE_CALLBACK_RENEW;
683 } 689 }
684 690
@@ -1053,3 +1059,6 @@ places_augmentation(void *data, E_Menu *em)
1053 1059
1054 e_menu_pre_activate_callback_set(m, places_generate_menu, NULL); 1060 e_menu_pre_activate_callback_set(m, places_generate_menu, NULL);
1055} 1061}
1062
1063
1064#undef PDBG \ No newline at end of file