Notices


Reply
Thread Tools
Posts: 7 | Thanked: 4 times | Joined on Jul 2009
#11
@Bunduo: Thanks again for your suggestions. I was able to get everything functioning! I've replaced Microb with Midori!

Now the tablet is so much more useful. I'll put the modified script below so anyone else searching for this can implement it.

Thanks every one!

Code:
import os
import gtk
import dbus
import dbus.service
import dbus.glib

class ProxyBrowserService(dbus.service.Object):
    def __init__(self):
        bus_name = dbus.service.BusName('com.nokia.osso_browser', bus=dbus.SessionBus())
        dbus.service.Object.__init__(self, bus_name, '/com/nokia/osso_browser')
        dbus.service.Object.__init__(self, bus_name, '/com/nokia/osso_browser/request')

    def OpenAddress(self, uri):
        print uri

        if uri[0] == '/':
            print "prefixing apparent local path with file://"
            uri = "file://" + uri

        os.execl('/usr/bin/dbus-launch', 
            '/usr/bin/dbus-launch', 'midori', uri)

    @dbus.service.method(dbus_interface='com.nokia.osso_browser', in_signature='s')
    def load_url(self, uri):
        print "load_url"
        self.OpenAddress(uri)

    @dbus.service.method(dbus_interface='com.nokia.osso_browser', in_signature='s')
    def open_new_window(self, uri):
        print "open_new_window"
        self.OpenAddress(uri)

    @dbus.service.method(dbus_interface='com.nokia.osso_browser')
    def top_application(self):
        print "top_application"
        if os.system("lsof /usr/sbin/browserd") != 0:
            os.system("/usr/sbin/browserd -d")
        os.execl('/usr/bin/browser', '/usr/bin/browser')

pbrowser = ProxyBrowserService()
gtk.main()
 

The Following 4 Users Say Thank You to jdarnell For This Useful Post:
mgoebel's Avatar
Posts: 52 | Thanked: 27 times | Joined on Mar 2008 @ Berlin, Germany
#12
That looks great and I implemented it directly. But it doesn't work. When I click a link in Mauku, it just says "opening internet" (as always before) but then nothing happens. No browser opens.

I guess that's because one piece is missing for me: My N810 cannot run the Python script. I would have to install a software for that, but I don't know which one.

The other forum post, where Maemo user xiojason introduced the idea of this script, only says:
I'm not sure which Python packages you might need to install, if any, to make use of this script. Please let me know if you find out what pre-requisite packages it requires.
Can you please help? What is this "Python package" that he is talking about? In my installer I see many programs that start with Py..., but which one do I need to install for this purpose? Unfortunately I am no Linux pro.
__________________
My Blog: Markus Göbel's Tech News Comments.
 
debernardis's Avatar
Posts: 2,142 | Thanked: 2,054 times | Joined on Dec 2006 @ Sicily
#13
Originally Posted by mgoebel View Post
In my installer I see many programs that start with Py..., but which one do I need to install for this purpose? Unfortunately I am no Linux pro.

I guess you need the python2.5 package and maybe some other.
My machine which has no problem to run that hack has the following:

Code:
ii  hildon-desktop-python-loader                   0.0.2-1                            Hildon Desktop Python Plugin Loader
ii  python-dateutil                                1.4.1-1                            Extension to the standard python datetime mo
ii  python-gdata                                   1.2.3-0maemo2                      Google Data Python client library
ii  python-sqlite                                  1.0.1-7maemo2                      python interface to SQLite 2
ii  python2.5                                      2.5.2-1osso4                       An interactive high-level object-oriented la
ii  python2.5-beautifulsoup                        3.0.7-0maemo2                      error-tolerant HTML parser for Python
ii  python2.5-bluez                                0.9.1-1osso2                       Python wrappers around BlueZ
ii  python2.5-cairo                                1.4.0-1osso2                       Python bindings for the Cairo vector graphic
ii  python2.5-conic                                0.1-1osso2                         Python bindings for ConIc Framework.
ii  python2.5-dbus                                 0.82-4osso2                        Python wrappers around D-Bus.
ii  python2.5-gnome                                2.18.0-1osso3                      Python bindings for GConf and GnomeVFS
ii  python2.5-gobject                              2.14.1-1osso2                      Python bindings for the GTK+ widget set
ii  python2.5-gpsbt                                0.1-18osso2                        Python bindings for osso-gpsd lib.
ii  python2.5-gstreamer                            0.10.5-0osso2                      generic media-playing framework (Python bind
ii  python2.5-gtk2                                 2.12.1-1osso3                      Python bindings for the GTK+ widget set
ii  python2.5-hildon                               0.8.9-1osso2                       Python bindings for Hildon Framework.
ii  python2.5-hildondesktop                        0.0.2-1                            Python bindings for libhildondesktop
ii  python2.5-id3lib                               0.5.1-1osso2                       id3lib wrapper for Python - library
ii  python2.5-imaging                              1.1.6-1osso2                       Python Imaging Library
ii  python2.5-numeric                              24.2-1osso5                        Numerical (matrix-oriented) Mathematics for 
ii  python2.5-osso                                 0.3-1osso4                         Python bindings for Libosso library
ii  python2.5-pycurl                               7.15.5-1osso3                      Python bindings for libcurl.
ii  python2.5-pygame                               1.7.1-1osso2                       SDL bindings for games development in Python
ii  python2.5-runtime                              c1.0-6                             Python runtime environment.
ii  python2.5-xml                                  0.8.4-1osso9                       XML tools for Python
I'm no coder (pity me) but seeing these lines in the source
Code:
import os
import gtk
import dbus
import dbus.service
import dbus.glib
I guess that you should have at least python2.5, python2.5-dbus and python2.5-gtk2.
__________________
Ernesto de Bernardis


Last edited by debernardis; 2009-07-27 at 09:43.
 
jukey's Avatar
Posts: 246 | Thanked: 204 times | Joined on Jun 2007 @ Potsdam (Germany)
#14
Originally Posted by jdarnell View Post
@Bunduo: Thanks again for your suggestions. I was able to get everything functioning! I've replaced Microb with Midori!
[...]
Thank you so much! :-)

It also works with fennec instead of Midori in your listing. Maybe this should be placed in the wiki as a Howto?

But there is still one issue left for me:
I have to run
/home/user/browser-proxy.py
one time. Only after this I am able to start fennec using the "normal" Bookmark-Application in the global browser menu (first icon on the left menu).

How I can start the browser.py in the boot process?

EDIT: Seems to be no solution for me. After changing:
/usr/share/dbus-1/services/com.nokia.osso_browser.service

to:

[D-BUS Service]
Name=com.nokia.osso_browser
Exec=/home/user/browser-proxy.py

and restarting my tablet most of the other applications don't start. For example the mail-application and mauku don't start. xterm don't accepts parameter and so on...
__________________
-> Join the SailfishOS Meetup Berlin - every first Monday a month <-

Me on twitter

Last edited by jukey; 2009-07-27 at 10:31.
 
mgoebel's Avatar
Posts: 52 | Thanked: 27 times | Joined on Mar 2008 @ Berlin, Germany
#15
Originally Posted by debernardis View Post
I guess you need the python2.5 package and maybe some other.
This doesn't work.

I installed python2.5, python2.5-dbus, python2.5-gtk2 and other Python apps I don't really need, hoping that they bring the right libraries with them. But when I click a link in Mauku or Modest it just says "opening internet" (like it always did to open MicroB) and then nothing happens. It doesn't start Midori as it should.

"I'm not sure which Python packages you might need to install, if any, to make use of this script. Please let me know if you find out what pre-requisite packages it requires", is not a helpful answer. I feel that I am quite there but I cannot get it running. Do know this newbie feeling when you think you understood something but it will not work?

Could some of the pros please explain how to get a Python script running? Which Python software do I have to install beforehand? What do I have to do then so that software like Mauku or Modest can call this script to open Midori with the clicked URL?

Thanks a lot!

Or does it have to do with making the script executable?

I can do the necessary "chmod +x browser-proxy.py" only as Root. Can a program with normal user rigths then call it and let it run? I my case it seems to work halfway: The dbus service file for osso_browser calls the script, but then Midori doesn't open. Does this sound familiar to someone who could tell where I am mistaken? Your help is very appreciated.

Thank you very much.
__________________
My Blog: Markus Göbel's Tech News Comments.
 
mgoebel's Avatar
Posts: 52 | Thanked: 27 times | Joined on Mar 2008 @ Berlin, Germany
#16
OK,

my friend Diez could finally solve the problem. He is a real Python wizard and changed the script by xiojason. Now everything works fine. Every link I click, in every software I have installed on my N810, opens Midori instead of MicroB. It works flawlessly, after initial hiccups when it worked only for one time.

You can also change the word midori for fennec or tear if you prefer these other browsers.

Thank you all and thanks to Diez!



Code:
#!/usr/bin/python
# browser-proxy.py
# version 1.4 by xiojason
# simple python-dbus service that proxies osso_browser events to Tear
# based on code from http://paste.lisp.org/display/45824
#
# installation:
# 1. place this file in /home/user as browser-proxy.py
# 2. make executable (chmod +x browser-proxy.py)
# 3. change /usr/share/dbus-1/services/com.nokia.osso_browser.service to read:
# [D-BUS Service]
# Name=com.nokia.osso_browser
# Exec=/home/user/browser-proxy.py
# 4. disable tablet-browser-service (aka browserd) (optional, saves memory)
# 5. you may wish to reboot.
#
# notes:
# - opening urls will be a bit slow. it takes some time to relay the messages to Tear
# - modifying the osso_browser.service file prevents MicroB/browserd from working.
#   if you wish to restore MicroB/browserd, change the service file's contents back to:
# [D-BUS Service]
# Name=com.nokia.osso_browser
# Exec=/usr/bin/browser
#   and re-enable tablet-browser-service again.
#
# revision history:
# 1.0
# 1.1 -> fixed wrong capitalization in dbus message
# 1.2 -> removed return values, added osso_browser/request namespace (fixes Pidgin)
# 1.3 -> sniff for local paths, prefix with file:// (fixes feedcircuit)
# 1.4 -> can now manually launch MicroB/browser -- while open, it will be used instead
#     -- without --print-reply, the initial launching message seems to get lost
# 1.5 -> removed dbus-launch that caused other software to hang. Used subprocess to 
#        spawn new processes instead of replacing the current process, which DBUS wasn't
#        taking to well.

import sys
import os
import gtk
import dbus
import dbus.service
import dbus.glib
import subprocess


def log(message):
    outf = open("/tmp/bp.log", "a")
    outf.write(message)
    outf.write("\n")
    outf.close()


class ProxyBrowserService(dbus.service.Object):
    def __init__(self):
        bus_name = dbus.service.BusName('com.nokia.osso_browser', bus=dbus.SessionBus())
        dbus.service.Object.__init__(self, bus_name, '/com/nokia/osso_browser')
        dbus.service.Object.__init__(self, bus_name, '/com/nokia/osso_browser/request')

    def OpenAddress(self, uri):
        log(uri)
        if uri[0] == '/':
            print "prefixing apparent local path with file://"
            uri = "file://" + uri

        subprocess.Popen(['/usr/bin/midori', uri])



    @dbus.service.method(dbus_interface='com.nokia.osso_browser', in_signature='s')
    def load_url(self, uri):
        log("load_url")
        self.OpenAddress(uri)

    @dbus.service.method(dbus_interface='com.nokia.osso_browser', in_signature='s')
    def open_new_window(self, uri):
        log("open_new_window")
        self.OpenAddress(uri)

    @dbus.service.method(dbus_interface='com.nokia.osso_browser')
    def top_application(self):
        log("top_application")        
        if os.system("lsof /usr/sbin/browserd") != 0:
            os.system("/usr/sbin/browserd -d")
        os.execl('/usr/bin/browser', '/usr/bin/browser')

pbrowser = ProxyBrowserService()
log("before main")
try:
    gtk.main()
except:
    log("error")
    log(repr(sys.exc_info()))
log("after main")
__________________
My Blog: Markus Göbel's Tech News Comments.
 

The Following 7 Users Say Thank You to mgoebel For This Useful Post:
tso's Avatar
Posts: 4,783 | Thanked: 1,253 times | Joined on Aug 2007 @ norway
#17
any issues with double-opening the initial window with tear?
__________________
Be warned, posts are often line of thoughts at highway speeds...
 
mgoebel's Avatar
Posts: 52 | Thanked: 27 times | Joined on Mar 2008 @ Berlin, Germany
#18
No such issues, no issues at all. The script replaces MicroB for clicks on links in other apps. Everything works like before, only that - in my case - Midori comes up instead of MicroB.
__________________
My Blog: Markus Göbel's Tech News Comments.
 
tso's Avatar
Posts: 4,783 | Thanked: 1,253 times | Joined on Aug 2007 @ norway
#19
ok, i guess its a tear issue then...
__________________
Be warned, posts are often line of thoughts at highway speeds...
 
mgoebel's Avatar
Posts: 52 | Thanked: 27 times | Joined on Mar 2008 @ Berlin, Germany
#20
We have tried it, without problems, with Midori and Fennec.
__________________
My Blog: Markus Göbel's Tech News Comments.
 
Reply

Tags
browser, default, fennec, microb

Thread Tools

 
Forum Jump


All times are GMT. The time now is 06:32.