Hi,

I'm not familiar in C/C++ programming. I analyze C examples and transform them to Free Pascal. Free Pascal have no dbus-glib bindings yet, so I can't use this example:
http://developer.pidgin.im/wiki/DbusHowto#DBUSglibexample
I must use low level API. I found DBUS function "dbus_connection_try_register_object_path" for asynchronously listening pidgin signals. This works but only on my computer. When I send this plugin to my friend, "message_handler" function is never called. I don't know what is a reason of this (Free Pascal compiler, DBUS or Pidgin), so I'm trying to write this same in pure C to confirm what is the cause. As mentioned earlier, I'm not familiar in C and below example is compiling but doesn't work. This is modified example of skype DBUS client. Can anyone help me?

Regards

#include <iostream>
#define DBUS_API_SUBJECT_TO_CHANGE
#include <dbus/dbus.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <dbus/dbus-glib-lowlevel.h>

DBusConnection *connection;

using namespace std;

static DBusHandlerResult notify_handler( DBusConnection *bus, DBusMessage *msg, void *user_data )
  {
  fprintf( stderr, "notify_handler called\n");

  return (DBusHandlerResult) TRUE;
  }

int main()
{
  DBusObjectPathVTable vtable;
  GMainLoop *loop;
  DBusError error;
  fprintf( stderr, "Main func\n" );

  dbus_error_init( &error );
  connection = dbus_bus_get( DBUS_BUS_SESSION, &error );
  if ( connection == NULL )
    {
fprintf( stderr, "Failed to open connection to bus: %s\n", error.message );
    dbus_error_free( &error );
    exit( 1 );
    }

  loop = g_main_loop_new( NULL, FALSE );

dbus_connection_setup_with_g_main( connection, NULL ); // set up te DBus connection

vtable.message_function = notify_handler; // register handler for incoming data on DBus if (dbus_connection_register_object_path( connection, "/im/pidgin/purple/PurpleObject", &vtable, 0 )==0)
  {
    fprintf( stderr, "Cant register object path\n");
  }

  g_main_loop_run( loop );                    // the main loop
  return 0;
}

_______________________________________________
Support@pidgin.im mailing list
Want to unsubscribe?  Use this link:
http://pidgin.im/cgi-bin/mailman/listinfo/support

Reply via email to