summaryrefslogtreecommitdiff
path: root/src/lib/eio
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-09-18 08:21:00 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-09-18 08:21:00 -0400
commit5a7102a589e512872a7f70823459a7a178c1671d (patch)
treeebfb9d62dfa2f81c826bb98549aec12a35a3a711 /src/lib/eio
parentf4290cb330f8c594c460bb5fdbf36fcaf5459152 (diff)
Revert "efl_io_model: remove custom counting logic"
Summary: This reverts commit d794a0d3d95c3addcb21df75606c444c6e3ed6d8. This breaks Efl_Io_Model. Reviewers: cedric, zmike Reviewed By: zmike Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10003
Diffstat (limited to 'src/lib/eio')
-rw-r--r--src/lib/eio/efl_io_model.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/lib/eio/efl_io_model.c b/src/lib/eio/efl_io_model.c
index 06f27f5..e6b6149 100644
--- a/src/lib/eio/efl_io_model.c
+++ b/src/lib/eio/efl_io_model.c
@@ -762,6 +762,63 @@ _efl_io_model_efl_model_property_set(Eo *obj,
762 return efl_loop_future_rejected(obj, err); 762 return efl_loop_future_rejected(obj, err);
763} 763}
764 764
765static void
766_efl_io_model_children_list(void *data, Eina_Array *entries)
767{
768 Eina_File_Direct_Info *info;
769 Efl_Model *obj = data;
770 Efl_Io_Model_Data *pd;
771 Efl_Model_Children_Event cevt = { 0 };
772 Eina_Array_Iterator iterator;
773 unsigned int i;
774
775 pd = efl_data_scope_get(obj, EFL_IO_MODEL_CLASS);
776 if (!pd) return ;
777
778 EINA_ARRAY_ITER_NEXT(entries, i, info, iterator)
779 {
780 Efl_Io_Model_Info *mi;
781
782 if (_already_added(pd, info->path)) continue;
783
784 if (pd->filter.cb)
785 {
786 if (!pd->filter.cb(pd->filter.data, obj, info))
787 continue ;
788 }
789
790 mi = calloc(1, sizeof (Efl_Io_Model_Info));
791 if (!mi) continue ;
792
793 mi->path_length = info->path_length;
794 mi->path = eina_stringshare_add(info->path);
795
796 mi->name_start = info->name_start;
797 mi->name_length = info->name_length;
798 mi->type = _efl_io_model_info_type_get(info, NULL);
799 mi->parent_ref = EINA_FALSE;
800 mi->child_ref = EINA_TRUE;
801
802 cevt.index = eina_list_count(pd->files);
803 cevt.child = NULL;
804
805 pd->files = eina_list_append(pd->files, mi);
806
807 efl_event_callback_call(obj, EFL_MODEL_EVENT_CHILD_ADDED, &cevt);
808 }
809
810 efl_event_callback_call(obj, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, NULL);
811}
812
813static void
814_efl_io_model_children_list_cleanup(Eo *o EINA_UNUSED, void *data, const Eina_Future *dead_future EINA_UNUSED)
815{
816 Efl_Io_Model_Data *pd = data;
817
818 pd->request.listing = NULL;
819 pd->listed = EINA_TRUE;
820}
821
765/** 822/**
766 * Children Count Get 823 * Children Count Get
767 */ 824 */
@@ -778,6 +835,30 @@ _efl_io_model_efl_model_children_count_get(const Eo *obj, Efl_Io_Model_Data *pd)
778 { 835 {
779 _eio_build_st(obj, pd); 836 _eio_build_st(obj, pd);
780 } 837 }
838 else if (!pd->listed &&
839 !pd->request.listing &&
840 pd->info->type == EINA_FILE_DIR)
841 {
842 Efl_Io_Manager *iom;
843 Eina_Future *f;
844
845 iom = efl_provider_find(obj, EFL_IO_MANAGER_CLASS);
846 if (!iom)
847 {
848 ERR("Could not find an Efl.Io.Manager on %p.", obj);
849 return 0;
850 }
851
852 f = efl_io_manager_direct_ls(iom, pd->path, EINA_FALSE,
853 (void*) obj, _efl_io_model_children_list, NULL);
854
855 //start monitoring before listing is done
856 //we will filter later on if we already published a file or not
857 _efl_io_model_efl_model_monitor_add(pd);
858 pd->request.listing = efl_future_then(obj, f,
859 .free = _efl_io_model_children_list_cleanup,
860 .data = pd);
861 }
781 862
782 return eina_list_count(pd->files); 863 return eina_list_count(pd->files);
783} 864}