It's working like Lucas said, see a example in attachment.
On Tue, Jul 24, 2012 at 12:30 PM, Nick Hughart <mek...@mekius.net> wrote:
> On Tue, 24 Jul 2012 07:01:37 -0300
> Lucas De Marchi <lucas.demar...@profusion.mobi> wrote:
>
>> On Tue, Jul 24, 2012 at 12:36 AM, Nick Hughart <mek...@mekius.net>
>> wrote:
>> > Alright, so I'm working on a PolicyKit1 authentication agent and
>> > have run into something of a problem. I am working on implementing
>> > this dbus method:
>> >
>> > http://hal.freedesktop.org/docs/polkit/eggdbus-interface-org.freedesktop.PolicyKit1.AuthenticationAgent.html#eggdbus-method-org.freedesktop.PolicyKit1.AuthenticationAgent.BeginAuthentication
>> >
>> > I am unmarshaling the command and all that just fine inside a
>> > callback function that was specified in when setting up
>> > BeginAuthentication via e_dbus_interface_method_add.
>> >
>> > The problem is that I have to somehow popup a window to authenticate
>> > the user before calling AuthenticationAgentResponse and also before
>> > I send the reply for BeginAuthentication.
>> >
>> > Given that while I'm in the callback, the elm main loop will not be
>> > running, I'm not sure how to popup the dialog without returning from
>> > the callback and thus replying to the dbus message before making the
>> > call to AuthenticationAgentResponse().
>> >
>> > Will I need to fork off a process to do the GUI part of the app
>> > while leaving another process to do the DBus communication or is
>> > there something I'm missing?
>>
>> Nops. You can keep a ref to the message and decide to respond later.
>> Just make the method return NULL. If it's not working, it's a bug and
>> should be fixed.
>>
>> See e_dbus_object_handler() in src/lib/dbus/e_dbus_object.c how it's
>> implemented.
>>
>
> Just the answer I was looking for :D
>
> I had thought about trying this, but hadn't given it a shot yet as I
> was working on some other aspects still. I will try it and let you
> know if it's working.
>
>>
>> Lucas De Marchi
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond.
>> Discussions will include endpoint security, mobile security and the
>> latest in malware threats.
>> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________ enlightenment-devel
>> mailing list enlightenment-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
/*
* gcc -o edbus_client_async edbus_client_async.c `pkg-config --cflags --libs ecore eina edbus` -Wall -Wextra -Wno-unused-parameter
*/
#include <E_DBus.h>
#include <Ecore.h>
#define DBUS_NAME "com.profusion"
#define OBJECT_PATH "/com/profusion/test"
#define IFACE_NAME "com.Profusion.Test"
static E_DBus_Connection *conn = NULL;
static void
_cb_resp(void *data, DBusMessage *msg, DBusError *error)
{
DBusError new_error;
int size;
if (dbus_error_is_set(error))
{
printf("dbus error\nName: %s\nDescription: %s\n", error->name,
error->message);
ecore_main_loop_quit();
return;
}
dbus_error_init(&new_error);
dbus_message_get_args(msg, &new_error, DBUS_TYPE_INT32, &size,
DBUS_TYPE_INVALID);
if (dbus_error_is_set(&new_error))
printf("dbus error\nName: %s\nDescription: %s\n", new_error.name,
new_error.message);
else printf("size = %d\n", size);
ecore_main_loop_quit();
}
int
main(int argc, char *argv[])
{
char *string = "lalala";
DBusMessage *msg;
e_dbus_init();
conn = e_dbus_bus_get(DBUS_BUS_SESSION);
msg = dbus_message_new_method_call(DBUS_NAME, OBJECT_PATH,
IFACE_NAME, "string_len_async");
dbus_message_append_args(msg, DBUS_TYPE_STRING, &string, DBUS_TYPE_INVALID);
e_dbus_message_send(conn, msg, _cb_resp, -1, NULL);
dbus_message_unref(msg);
ecore_main_loop_begin();
e_dbus_shutdown();
return 0;
}
/*
* gcc -o edbus_server_async edbus_server_async.c `pkg-config --cflags --libs ecore eina edbus` -Wall -Wextra -Wno-unused-parameter
*/
#include <E_DBus.h>
#include <Ecore.h>
#define DBUS_NAME "com.profusion"
#define OBJECT_PATH "/com/profusion/test"
#define IFACE_NAME "com.Profusion.Test"
static E_DBus_Connection *conn = NULL;
static E_DBus_Object *obj_path = NULL;
typedef struct _EDBus_Method
{
char *member;
char *signature;
char *reply_signature;
E_DBus_Method_Cb func;
} EDBus_Method;
static void
obj_register(char *path_name, char *iface_name, EDBus_Method *methods)
{
obj_path = e_dbus_object_add(conn, path_name, NULL);
E_DBus_Interface *iface = e_dbus_interface_new(iface_name);
const EDBus_Method *_method;
e_dbus_object_interface_attach(obj_path, iface);
e_dbus_interface_unref(iface);
for (_method = methods; _method != NULL && _method->member != NULL; _method++)
e_dbus_interface_method_add(iface, _method->member,
_method->signature,
_method->reply_signature,
_method->func);
}
static void
_dbus_error_check(DBusError *error)
{
if (dbus_error_is_set(error))
{
printf("dbus error\nName: %s\nDescription: %s\n", error->name,
error->message);
ecore_main_loop_quit();
}
}
Eina_Bool
_resp_async(void *data)
{
DBusMessage *msg = data;
DBusMessage *reply;
DBusError new_err;
char *string;
int size;
dbus_error_init(&new_err);
dbus_message_get_args(msg, &new_err, DBUS_TYPE_STRING, &string,
DBUS_TYPE_INVALID);
_dbus_error_check(&new_err);
reply = dbus_message_new_method_return(msg);
size = strlen(string);
dbus_message_append_args(reply, DBUS_TYPE_INT32, &size, DBUS_TYPE_INVALID);
e_dbus_message_send(conn, reply, NULL, -1, NULL);
dbus_message_unref(msg);
dbus_message_unref(reply);
return ECORE_CALLBACK_CANCEL;
}
static DBusMessage *
_async(E_DBus_Object *obj, DBusMessage *msg)
{
dbus_message_ref(msg);
printf("received a string_len_async call\n");
printf("response will be send in 5 seconds\n");
ecore_timer_add (5, _resp_async, msg);
return NULL;
}
static void
_cb_dbus_request_name(void *context, DBusMessage *msg, DBusError *err)
{
DBusError new_err;
dbus_uint32_t msgtype;
EDBus_Method table_methods[] =
{
{ "string_len_async", "s", "d", _async},
{ NULL, NULL, NULL, NULL }
};
_dbus_error_check(err);
dbus_error_init(&new_err);
dbus_message_get_args(msg, &new_err, DBUS_TYPE_UINT32, &msgtype,
DBUS_TYPE_INVALID);
if (msgtype != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
{
printf("Could not get the DBus name: reply=%d", msgtype);
ecore_main_loop_quit();
}
obj_register(OBJECT_PATH, IFACE_NAME, table_methods);
}
int
main(int argc, char *argv[])
{
e_dbus_init();
conn = e_dbus_bus_get(DBUS_BUS_SESSION);
e_dbus_request_name(conn, DBUS_NAME, DBUS_NAME_FLAG_DO_NOT_QUEUE,
_cb_dbus_request_name, NULL);
ecore_main_loop_begin();
e_dbus_shutdown();
return 0;
}
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel