View Single Post
Bundyo's Avatar
Posts: 4,708 | Thanked: 4,649 times | Joined on Oct 2007 @ Bulgaria
#587
I already converted your code to Vala, but had a problem running it (the auto capitalization was my initial problem with DBus)

Code:
using GLib;
using Gtk;
using DBus;
using Osso;

BrowserProxyServer server;

[DBus (name = "com.nokia.osso_browser")]
public class BrowserProxyServer : GLib.Object {

	[DBus (visible = false)]
    public void OpenAddress(string uri) {
        uri.printf();
		Process.spawn_async( null, ("/usr/bin/dbus-send --session --type=method_call --print-reply --dest=com.nokia.tear "+
									"/com/nokia/tear com.nokia.Tear.OpenAddress string:"+uri).split(" "),
							 null, 0, null, null );
    }
	
    public int load_url(string uri) {
        warning( "load_url" );
        this.OpenAddress( uri );
        return 1;
    }

    public int open_new_window(string uri) {
		warning( "open_new_window" );
        return this.load_url( uri );
	}
	
}

public class BrowserProxy : GLib.Object {
	
	construct {
		var connection = DBus.Bus.get( BusType.SESSION );
		
        dynamic DBus.Object bus = connection.get_object ("org.freedesktop.DBus",
                                                   "/org/freedesktop/DBus",
                                                   "org.freedesktop.DBus");
                                                   
		uint request_name_result = bus.request_name ("com.nokia.osso_browser", (uint) 0);

        if (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER)
	        connection.register_object ("/com/nokia/osso_browser", server);
	}
		
    static int main (string[] args) {
        Osso.Context ctx;

        Gtk.init (ref args);
        
        ctx = new Osso.Context("BrowserProxy", "0.1", false, null);
        if (ctx.display_state_on() != Osso.Status.OK)
            warning("Osso Initialization failed.");
            
        server = new BrowserProxyServer();
        var pbrowser = new BrowserProxy();
        Gtk.main();
        
        return 0;
    }
}
__________________
Technically, there are three determinate states the cat could be in: Alive, Dead, and Bloody Furious.