Re: calling a Qt dbus method from a HILDON desktop widget

2010-02-14 Thread Daniil Ivanov
Hi!

  Is your service really running on system bus?
  You don't need Qt client for testing as dbus-send exists.

Thanks, Daniil.

On Tue, Feb 9, 2010 at 2:53 PM, ibrahim  wrote:
> greetings;
>
> I was creating an application with Qt that exposes a dbus service. the
> service returns its output  as a QStringList. I tested this dbus service
> with a client written in Qt and it worked perfectly.
>
> I wanted to create a Desktop widget that can consume this dbus service. I
> created a normal C file that calls the dbus service - just as POC to see if
> it works by modifying some code i found (a C file that gets the imei ,
> written by mr.faheem
> http://talk.maemo.org/showpost.php?p=371496&postcount=45)
> my code is :
>
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> static GList* ptimes_list = NULL;
> int fn() {
> DBusGConnection *conn;
>   GError *error = NULL;
>
>   conn = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
>   if (!conn) {
>           g_printerr ("Error: %s\n", error->message);
>           g_error_free (error);
>           return 0;
>   }
>   DBusGProxy *proxy = NULL;
>   /* replaced the cinstants with values from my dbus interface */
>   proxy = dbus_g_proxy_new_for_name(conn, SERVICE_NAME,PATH ,INTERFACE);
>               if (!proxy) {
>   printf("No proxy, dbus_g_proxy_new_for_name() failed \n");
>       return 0;
>   }
>         if (!dbus_g_proxy_call(proxy,"mthod_name", &error,my_list) )
>       {
>           /* dbus_g_proxy_call failed */
>           printf("dbus_g_proxy_call(proxy,method, &error,myList) returned
> FALSE \n");
>           return 0;
>       }
>       if (!my_list) {
>           /* output list is empty */
>           printf("my_list) glist is still NULL \n");
>           return 0;
>       }
>       g_object_unref(proxy);
>   char[10] element = (char*) g_list_nth_data(my_list),0);     printf("the
> value of the fajr first is %s \n",element);
>   return 1;
> }
> the program fails at this point: proxy = dbus_g_proxy_new_for_name(conn,
> SERVICE_NAME,PATH ,INTERFACE);
> and my application stops.
>
> I wonder what is wrong with the way I called my DBus service . Any help is
> appreciated!
> ___
> maemo-developers mailing list
> maemo-developers@maemo.org
> https://lists.maemo.org/mailman/listinfo/maemo-developers
>
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: calling a Qt dbus method from a HILDON desktop widget

2010-02-09 Thread Ville M. Vainio
On Tue, Feb 9, 2010 at 2:53 PM, ibrahim  wrote:

>   conn = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);

Home widgets should get the connection with

hd_home_plugin_item_get_dbus_connection()

I was able to use dbus just fine with that, and the raw libdbus apiv

-- 
Ville M. Vainio
http://tinyurl.com/vainio
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


calling a Qt dbus method from a HILDON desktop widget

2010-02-09 Thread ibrahim

greetings;

I was creating an application with Qt that exposes a dbus service. the 
service returns its output  as a QStringList. I tested this dbus service 
with a client written in Qt and it worked perfectly.


I wanted to create a Desktop widget that can consume this dbus service. 
I created a normal C file that calls the dbus service - just as POC to 
see if it works by modifying some code i found (a C file that gets the 
imei , written by mr.faheem 
http://talk.maemo.org/showpost.php?p=371496&postcount=45)

my code is :

#include 
#include 
#include 
#include 
#include 
#include 
static GList* ptimes_list = NULL;
int fn() {
DBusGConnection *conn;
   GError *error = NULL;

   conn = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
   if (!conn) {
   g_printerr ("Error: %s\n", error->message);
   g_error_free (error);
   return 0;
   }
   DBusGProxy *proxy = NULL;
   /* replaced the cinstants with values from my dbus interface */
   proxy = dbus_g_proxy_new_for_name(conn, SERVICE_NAME,PATH ,INTERFACE);

   if (!proxy) {

   printf("No proxy, dbus_g_proxy_new_for_name() failed \n");
   return 0;
   }
  
   if (!dbus_g_proxy_call(proxy,"mthod_name", &error,my_list) )

   {
   /* dbus_g_proxy_call failed */
   printf("dbus_g_proxy_call(proxy,method, &error,myList) 
returned FALSE \n");

   return 0;
   }
   if (!my_list) {
   /* output list is empty */
   printf("my_list) glist is still NULL \n");
   return 0;
   }
   g_object_unref(proxy);
   char[10] element = (char*) g_list_nth_data(my_list),0);   
   printf("the value of the fajr first is %s \n",element);

   return 1;
}
the program fails at this point: proxy = dbus_g_proxy_new_for_name(conn, 
SERVICE_NAME,PATH ,INTERFACE);

and my application stops.

I wonder what is wrong with the way I called my DBus service . Any help 
is appreciated!

___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers