I've modified your application to make it compile
Code:
/* gcc hal.c -o hal -Wall $(pkg-config --cflags --libs gtk+-2.0 hildon-1 hal hal-storage dbus-glib-1 libosso) */
#include <gtk/gtk.h>
#include <glib.h>
#include <stdlib.h>
#include <hildon/hildon.h>
#include <libhal.h>
#include <libosso.h>
#include <libhal-storage.h>
#include <dbus/dbus-glib-lowlevel.h>
int main( int argc, char* argv[] )
{
/* Create needed variables */
HildonProgram *program;
HildonWindow *window;
GtkWidget *button;
osso_context_t *osso_cont;
osso_return_t ret;
/*
locale_init();
*/
osso_cont = osso_initialize("APP_NAME", "1.0", TRUE, NULL);
if (osso_cont == NULL)
{
fprintf (stderr, "osso_initialize failed.\n");
exit (1);
}
/* Initialize the GTK. */
gtk_init( &argc, &argv );
/* Create the hildon program and setup the title */
program = HILDON_PROGRAM(hildon_program_get_instance());
g_set_application_name("Hello World");
/* Create HildonWindow and set it to HildonProgram */
window = HILDON_WINDOW(hildon_window_new());
hildon_program_add_window(program, window);
/* Quit program when window is closed. */
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (gtk_main_quit), NULL);
/* Quit program when window is otherwise destroyed. */
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (gtk_main_quit), NULL);
/* Create button and add it to main view */
button = gtk_button_new_with_label("Hello World!!!");
gtk_container_add(GTK_CONTAINER(window),
button);
/*
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (button_clicked), NULL);
ret = osso_rpc_set_cb_f (osso_cont,
APP_SERVICE,
APP_METHOD,
APP_SERVICE,
dbus_callback, GTK_WIDGET( window ));
if (ret != OSSO_OK) {
fprintf (stderr, "osso_rpc_set_cb_f failed: %d.\n", ret);
exit (1);
}
*/
int getn = mem_info();
/* Begin the main application */
gtk_widget_show_all ( GTK_WIDGET ( window ) );
gtk_main();
/* Exit */
return 0;
}
int mem_info()
{
DBusError error;
DBusConnection *connection;
LibHalContext *ctx = libhal_ctx_new();
const char *udi = "/sdrom";
dbus_error_init(&error);
connection = dbus_bus_get(DBUS_BUS_SYSTEM,&error);
if(!connection)
{
printf("Error %s\n",error.message);
dbus_error_free(&error);
return 1;
}
if ( dbus_error_is_set(&error) )
{
printf("Unable to connect to DBus: %s\n",error.message);
dbus_error_free(&error);
return 1;
}
//set dbus connection to talk to hald
if ( !libhal_ctx_set_dbus_connection(ctx, connection) )
{
printf("Error %s\n",error.message);
dbus_error_free(&error);
return 1;
}
//Initialize connection to hald
if ( !libhal_ctx_init(ctx, &error) )
{
printf("Hal context initializing failure %s\n",error.message);
dbus_error_free(&error);
return 1;
}
else
{
printf("Successful\n");
return 0;
}
}
And this is output when I run it on N900:
Code:
~ $ ./hal
Successful
Ok, you were running the app in scratchbox, where HAL is not supported.