Good catch, much better solution. Will fix.

S.

Den 2. nov. 2012 kl. 23:23 skrev Gustavo Sverzut Barbieri 
<barbi...@profusion.mobi>:

> Hi Englebass,
> 
> It would be nice to not rely on UnRegister (also bad name, Why not
> Unregister?), I'd get the sender bus name and watch for them (ie: :1.2),
> when they die we automatically do the UnRegister... then Register would
> need to keep a list of monitored bus names.
> 
> Regards,
> -- Gustavo
> 
> 
> On Fri, Nov 2, 2012 at 6:12 PM, Enlightenment SVN <
> no-re...@enlightenment.org> wrote:
> 
>> Log:
>> efreet: track efreetd clients
>> 
>> Author:       englebass
>> Date:         2012-11-02 13:12:41 -0700 (Fri, 02 Nov 2012)
>> New Revision: 78874
>> Trac:         http://trac.enlightenment.org/e/changeset/78874
>> 
>> Modified:
>>  trunk/efreet/src/bin/efreetd.c trunk/efreet/src/bin/efreetd.h
>> trunk/efreet/src/bin/efreetd_dbus.c trunk/efreet/src/lib/efreet_cache.c
>> 
>> Modified: trunk/efreet/src/bin/efreetd.c
>> ===================================================================
>> --- trunk/efreet/src/bin/efreetd.c      2012-11-02 20:12:27 UTC (rev 78873)
>> +++ trunk/efreet/src/bin/efreetd.c      2012-11-02 20:12:41 UTC (rev 78874)
>> @@ -11,6 +11,12 @@
>> 
>> int efreetd_log_dom = -1;
>> 
>> +void
>> +quit(void)
>> +{
>> +   ecore_main_loop_quit();
>> +}
>> +
>> int
>> main(void)
>> {
>> 
>> Modified: trunk/efreet/src/bin/efreetd.h
>> ===================================================================
>> --- trunk/efreet/src/bin/efreetd.h      2012-11-02 20:12:27 UTC (rev 78873)
>> +++ trunk/efreet/src/bin/efreetd.h      2012-11-02 20:12:41 UTC (rev 78874)
>> @@ -29,4 +29,6 @@
>> #endif
>> #define WRN(...) EINA_LOG_DOM_WARN(efreetd_log_dom, __VA_ARGS__)
>> 
>> +void quit(void);
>> +
>> #endif
>> 
>> Modified: trunk/efreet/src/bin/efreetd_dbus.c
>> ===================================================================
>> --- trunk/efreet/src/bin/efreetd_dbus.c 2012-11-02 20:12:27 UTC (rev 78873)
>> +++ trunk/efreet/src/bin/efreetd_dbus.c 2012-11-02 20:12:41 UTC (rev 78874)
>> @@ -2,6 +2,7 @@
>> # include <config.h>
>> #endif
>> 
>> +#include <Ecore.h>
>> #include <EDBus.h>
>> 
>> #include "efreetd.h"
>> @@ -21,17 +22,43 @@
>> static EDBus_Connection *conn;
>> static EDBus_Service_Interface *iface;
>> 
>> +static Ecore_Timer *shutdown = NULL;
>> +static int clients = 0;
>> +
>> +static Eina_Bool
>> +do_shutdown(void *data __UNUSED__)
>> +{
>> +   quit();
>> +   return ECORE_CALLBACK_CANCEL;
>> +}
>> +
>> static EDBus_Message *
>> -ping(const EDBus_Service_Interface *ifc __UNUSED__, const EDBus_Message
>> *message)
>> +do_register(const EDBus_Service_Interface *ifc __UNUSED__, const
>> EDBus_Message *message)
>> {
>>    EDBus_Message *reply;
>> 
>> +   clients++;
>> +   if (shutdown) ecore_timer_del(shutdown);
>> +   shutdown = NULL;
>>    reply = edbus_message_method_return_new(message);
>>    edbus_message_arguments_set(reply, "b", cache_desktop_exists());
>>    return reply;
>> }
>> 
>> static EDBus_Message *
>> +do_unregister(const EDBus_Service_Interface *ifc __UNUSED__, const
>> EDBus_Message *message __UNUSED__)
>> +{
>> +   clients--;
>> +   if (clients <= 0)
>> +     {
>> +        clients = 0;
>> +        if (shutdown) ecore_timer_del(shutdown);
>> +        shutdown = ecore_timer_add(10.0, do_shutdown, NULL);
>> +     }
>> +   return NULL;
>> +}
>> +
>> +static EDBus_Message *
>> add_desktop_dirs(const EDBus_Service_Interface *ifc __UNUSED__, const
>> EDBus_Message *message)
>> {
>>    EDBus_Message_Iter *array = NULL;
>> @@ -105,12 +132,15 @@
>> };
>> 
>> static const EDBus_Method methods[] = {
>> -     /* TODO: Register / Unregister */
>>        {
>> -          "Ping", NULL, EDBUS_ARGS({"b", "cache exists"}),
>> -          ping, 0
>> +          "Register", NULL, EDBUS_ARGS({"b", "cache exists"}),
>> +          do_register, 0
>>        },
>>        {
>> +          "UnRegister", NULL, NULL,
>> +          do_unregister, 0
>> +       },
>> +       {
>>           "AddDesktopDirs", EDBUS_ARGS({"as", "dirs"}), NULL,
>>           add_desktop_dirs, EDBUS_METHOD_FLAG_NOREPLY
>>        },
>> @@ -130,7 +160,7 @@
>> };
>> 
>> static const EDBus_Service_Interface_Desc desc = {
>> -   INTERFACE, methods, signals
>> +   INTERFACE, methods, signals, NULL, NULL, NULL
>> };
>> 
>> static void
>> 
>> Modified: trunk/efreet/src/lib/efreet_cache.c
>> ===================================================================
>> --- trunk/efreet/src/lib/efreet_cache.c 2012-11-02 20:12:27 UTC (rev 78873)
>> +++ trunk/efreet/src/lib/efreet_cache.c 2012-11-02 20:12:41 UTC (rev 78874)
>> @@ -93,7 +93,7 @@
>> static Eina_Bool efreet_cache_check(Eet_File **ef, const char *path, int
>> major);
>> static void *efreet_cache_close(Eet_File *ef);
>> 
>> -static void on_send_ping(void *data, const EDBus_Message *msg,
>> EDBus_Pending *pending);
>> +static void on_send_register(void *data, const EDBus_Message *msg,
>> EDBus_Pending *pending);
>> static void desktop_cache_update(void *context, const EDBus_Message *msg);
>> static void icon_cache_update(void *context, const EDBus_Message *msg);
>> 
>> @@ -134,7 +134,7 @@
>>         edbus_proxy_signal_handler_add(proxy, "IconCacheUpdate",
>> icon_cache_update, NULL);
>>         edbus_proxy_signal_handler_add(proxy, "DesktopCacheUpdate",
>> desktop_cache_update, NULL);
>> 
>> -        edbus_proxy_call(proxy, "Ping", on_send_ping, NULL, -1, "");
>> +        edbus_proxy_call(proxy, "Register", on_send_register, NULL, -1,
>> "");
>> 
>>         /*
>>          * TODO: Needed?
>> @@ -210,7 +210,11 @@
>>      * TODO: Needed??
>>     edbus_name_owner_changed_callback_del(conn, BUS,
>> on_name_owner_changed, conn);
>>     */
>> -    if (conn) edbus_connection_unref(conn);
>> +    if (conn)
>> +    {
>> +        edbus_proxy_call(proxy, "UnRegister", NULL, NULL, -1, "");
>> +        edbus_connection_unref(conn);
>> +    }
>> 
>>     edbus_shutdown();
>> }
>> @@ -1049,7 +1053,7 @@
>> }
>> 
>> static void
>> -on_send_ping(void *data __UNUSED__, const EDBus_Message *msg,
>> EDBus_Pending *pending __UNUSED__)
>> +on_send_register(void *data __UNUSED__, const EDBus_Message *msg,
>> EDBus_Pending *pending __UNUSED__)
>> {
>>     const char *errname, *errmsg;
>>     Eina_Bool exists;
>> 
>> 
>> 
>> ------------------------------------------------------------------------------
>> LogMeIn Central: Instant, anywhere, Remote PC access and management.
>> Stay in control, update software, and manage PCs from one command center
>> Diagnose problems and improve visibility into emerging IT issues
>> Automate, monitor and manage. Do more in less time with Central
>> http://p.sf.net/sfu/logmein12331_d2d
>> _______________________________________________
>> enlightenment-svn mailing list
>> enlightenment-...@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/enlightenment-svn
> 
> 
> 
> -- 
> Gustavo Sverzut Barbieri
> http://profusion.mobi embedded systems
> --------------------------------------
> MSN: barbi...@gmail.com
> Skype: gsbarbieri
> Mobile: +55 (19) 9225-2202
> ------------------------------------------------------------------------------
> LogMeIn Central: Instant, anywhere, Remote PC access and management.
> Stay in control, update software, and manage PCs from one command center
> Diagnose problems and improve visibility into emerging IT issues
> Automate, monitor and manage. Do more in less time with Central
> http://p.sf.net/sfu/logmein12331_d2d
> _______________________________________________
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to