Skip to main content

a silhouette of a person's head and shoulders, used as a default avatar

Using D-Bus in Java

I think one of the most fun things I've got to learn during Summer of Code is d-bus. I had to learn it to open instant message conversations in the Pidgin module. And I guess I can present a noobish tutorial to do something simple in Java using d-bus. Before you start, you can refer to this excellent manual here.

Pre-requisites-

1. you need JVM and JDK (the version I used was openJDK 1.6 taken from the standard repository)

2. dbus-java (which requires you to install libmatthew as well).

The task at hand is to make an empty note in Tomboy using a java program.

Step-1 Extend the required interface for the function you're looking to implement (you can use a software called d-feet which can help you analyze various buses, object paths and interface names)


package org.gnome.Tomboy;

import org.freedesktop.dbus.DBusInterface;
import org.freedesktop.dbus.DBusInterfaceName;

/**
*
* @author sourcemorph
*/

@DBusInterfaceName("org.gnome.Tomboy.RemoteControl")
public interface RemoteControl extends DBusInterface {

public String CreateNote();
}


[The annotation is important, and you need to mention the corresponding object path of the interface you're extending, here I have declared just one function that we needed, but you can choose from the available functions from d-feet].

Step-2 Write a main class to get an object of this interface type and execute the function.


/**
*
* @author sourcemorph
*/

import org.freedesktop.dbus.DBusConnection;
import org.freedesktop.dbus.exceptions.DBusException;
import org.gnome.Tomboy.RemoteControl;

public class NewClass {

private static String ObjectPath = "/org/gnome/Tomboy/RemoteControl";
private static String ServiceBusName = "org.gnome.Tomboy";
private static DBusConnection conn;

public NewClass() {
try {
conn = DBusConnection.getConnection(DBusConnection.SESSION);
RemoteControl c = (RemoteControl) conn.getRemoteObject(ServiceBusName, ObjectPath);
c.CreateNote();
} catch(DBusException ex) {
ex.printStackTrace();
}
}

public static void main(String [] args) {
NewClass n = new NewClass();
}
}


Fairly simple. By the way its something really admirable about D-Bus because now my Java code can interact with processes which could have been coded in C sharp, Python etc. I am going to call methods on the Pidgin interface through Java code, and learning D-Bus was totally worth the effort.

PS: thanks to my mentor Stephen Shaw for patiently referring me to the README files when dbus-java wasn't compiling.. :) and also for d-feet, its awesome!

the avatar of Matthias Hopf

PowerPlayInfo V4.1

I finally spent a few spare minutes (underestimation of the week) to sort-of reverse engineer the PowerPlayInfo tables of newer ATI cards - and somewhat succeeded. But the information I found so far is not as encouraging as I'd like it to be.
Basically, you get a list of potential combinations of engine clock, memory clock, and core voltage, plus a number of unknown flags. So far so good, but on some (especially high class) cards the entries do not vary as much as I'd like them to do, and many combinations do not exactly make sense. Others are repeated over and over.

Examples (engine clock in Mhz / memory clock in MHz / core voltage in Volt):
  • RV770: 750/900/1.263 - 500/950/1.263 - 750/950/1.263
  • RV670: 669/829/1.214 - 300/829/1.014 - 300/829/1.014 - 300/829/1.214
  • RV635: 725/800/1.250 - 110/405/0.900 - 300/405/1.000 - 300/800/1.250 - 600/500/1.150
IMHO the RV635 values are the most reasonable ones - while the RV770 values are completely bogus.

Also, the PowerPlayInfo V4.1 still has quite a number of fields we don't understand - marked as unknown in my AtomDis disassembler and table dumper.
a silhouette of a person's head and shoulders, used as a default avatar

On kontact

I will go on holiday next week, so today is my last day in the office. I have decided that the things I have to do today are too many and I should work in the train in my way to the office.

All good, start the computer, of course no internet, so I had to shutdown kontact to stop him crying about not being able to connect.

Being able to easy go to an offline mode  would be a very nice and useful feature to have in kontact, and kde applications in general. Checking that before you want to communicate with some third party that you actually have the phone instead complaining that he is not answer, would be a very good design decision, too.

Now being the holiday season I hope at least one of the kde/kontact developers would get hit by this missing feature and soon we will have it.

a silhouette of a person's head and shoulders, used as a default avatar

API Design Matters

API Design Matters

I was reading a very interesting article called "API Design Matters" with the subtitle "Bad application programming interfaces plague software engineering. How can we get things right?". Very cool stuff.

In OpenOffice.org we have an API "plague" too: The ODF import/export is based on the "UNO-API" and so is the OOXML import for Writer. And developers hate these APIs.

So the question is why do developers hate the "UNO-API"? And the obvious --- but wrong answer --- is: "I hate the UNO-API because of UNO". Don't get me wrong here: This is neither about pro or contra UNO. But the statement that "UNO is the problem of the ODF import/export and OOXML import problems" is wrong. It's not UNO per se, but its the design of the API.
[In case you're wondering what "UNO" is: UNO=COM ;-) So UNO is OpenOffice.org's way of COM.]

And just to be sure I do not offend the wrong people: The UNO-API was not designed to be used in the import/export filters. It was designed to be the API for "OpenOffice.org BASIC" developers, i.e. it was designed to provide a similar API to what VBA developers have in Microsoft Office. It was never designed to be used for import/export filters.

The problem was the decision to base the import/export code on such a high-level API! And we suffer from this decision until now!

Anyway. How can we fix this?
a) We claim the current API is the best mankind can do and print T-Shirts with 1000 years of OOo experience.
b) We claim UNO and abstraction is the problem and use the internal legacy APIs, so that we never get a chance to refactor the internal legacy stuff since we're creating even more dependencies.
c) We come up with a better API.

Option a) was demonstrated at the OpenOffice.org conference in Beijing. [Does anybody have a picture of the T-Shirt?]

Option b) is the straightforward approach. E.g. in Writer the “.DOC”, “.RTF”, .”HTML” filters are based on the internal “Core” APIs. So lets use these APIs instead of the UNO-APIs.
Whats wrong with the approach? The problem is that these internal APIs do not abstract from the underlying implementation at all. Repeat: The internal APIs do not abstract from the underlying implementation at all.
Does this answer the question why using the internal APIs is the wrong approach? Obviously *not* having an abstraction between your core implementation details and your import/exports filters is ... [offensive language detected ;-)].

Option c) only has one problem: How should the API look like?

I have some ideas here, but before posting them maybe there are some strong believes out there?

a silhouette of a person's head and shoulders, used as a default avatar

How to build MonoDevelop with Visual Studio

How to build MonoDevelop with Visual Studio in five easy steps:
  • Install GTK# (get installer here)
  • Install the Mono Libraries (get installer here)
  • Get MonoDevelop from SVN (update: instructions here)
  • Open main/Main.sln in Visual Studio
  • Press F5 (update: make sure you have the configuration DebugWin32 and platform x86 selected).
the avatar of Medwinz's Notes

Some Small Tips (but useful enough)

Some while ago there is a threat and discussion in openSUSE mailing list about the slowness of Firefox initiation after someone start it (click the icon). Sankar gave the solution that actually very useful to clean the the sqlite database within the Firefox. This will compact the disk blocks of your sqlite database and from then on, Firefox will start noticeably faster if your are a long time user.

The command is simple and run as normal user:
1. Shutdown the Firefox
2. Go to ~/.mozilla directory
3. From the konsole run "find . -name '*.sqlite' -exec sqlite3 '{}' 'VACUUM;' \;" without the quote

Try it and you will see the different. You can use it as much as you like if you use Firefox heavily :-)

Another tips here is about how to determine the date of installation or file system creation. Well, even that it is a bit tricky and actually I still try to find the exact answer, maybe you can use the date when you create your partition for you Linux installation. Assuming this is what you want, we can use the command below from the terminal/konsole as root.

1. su
2. find your / partition with "df -h"
3. assuming your / partition is /dev/sda2 run "dumpe2fs /dev/sda2 | grep "created""

change sda2 with your / partition
Try it, and till then have a lot of fun.
a silhouette of a person's head and shoulders, used as a default avatar

Installation: Resizing Windows before proposing Linux partitions

While “selling” openSUSE to a friend of mine, I tried to explain him all the steps of the installation and all the configuration options which I had changed. He was not any geek and it was his first time seeing Linux.

While most of the installation did not need much explanations, I definitely spent most of the time on partitioning. Not that initial proposal was not fine, unless one has special requirements, but there is one elementar input, which even newbies may want to set: How to split disk between Windows and Linux. The installation proposal works just fine, but if one needs to keep more or less space for Windows than proposed and does not have any skills, he is doomed – and so would have been he.

There is a graphical dialog for resizing of the windows partition, but, sadly, there is no way to resize Windows and propose Linux partitions in the remaining disk space – which is something that would help new users a lot, they can say “I want 30% of my disk for Windows and the rest for Linux”.
Inserting additional dialog before proposing disk configuration was not that hard as I was afraid of — and, even more surprisingly, it also works in combination with LVM (see the images).

Resizing WindowsPartitioning proposalLVM Proposal

You can see it with 11.2 Milestone 2, where it is not enabled by default; to enable it, boot with start_shell=1 on kernel command line and uncomment the

<module>
<label>Disk</label>
<name>resize_dialog</name>
<enable_back>yes</enable_back>
<enable_next>yes</enable_next>
</module>

part of /control.xml.

What do you think of it? Is it worth it? Any ideas for improvement?

the avatar of Medwinz's Notes

Busy Mode On!

I've been a bit busy lately. There are at least 3 projects I should manage to work on. In one project I become a Project Manager (technical side also), and in the other two I join as a member. So in the second half of 2009 I already fully booked ;)

The project that I act as a project manager is development of 3 crisis center/emergency operation center in 3 provinces in Indonesia. I should prepare our engineer to install asterisk, heartbeat and working with programmer to prepare some GIS and database software for the center. Sound interesting.

In the second project, I join with some experts in education to prepare a design of e-learning system for education quality enhancement for elementary and junior-high schools in one province in Indonesia.

In the last project I should help a team of programmer to prepare the infrastructure for customize service for a new GSM handset type that will be launched in Indonesia at the Q3 of this year.

Maybe you will not see many articles in this blog or in my other blog for the next couple of months. I promise to use my free time to write anything and hope I can put in in my blog later on.

Have a lot of fun!
a silhouette of a person's head and shoulders, used as a default avatar

Report on F-Spot loading times


before: (on 0.5.0.3, averaged loading times on the first 10 items of my collection)
Loading image took 1.292241s

after: (current master, averaged on the same 10 items)
Loading image took 0.518812s



[UPDATE] Yes, that's on a dual core machine (Intel(R) Core(TM)2 Duo CPU L7500 @ 1.60GHz).
a silhouette of a person's head and shoulders, used as a default avatar

On KDE4.3

We are almost one month far away from the kde4.3 release. Yesterday the 4.3 rc1 was tagged and due to excellent work of our colleagues in OBS we have it already.

Personally, I would have liked it to go a little bit further away in terms of usability, we will speak about that later.  This release will mark the break with 3.5. I see no real reason for not using kde 4.3. All the functionality that people were crying after from 3.5 is finally up and running (a lot of time better) in KDE 4.3.

What more would you like then, people may ask.

I would like to be able to give a kde4 desktop to a secretary to use and to a teenager who is into Web2.0.

  • a features consistent kontact, a kalendar that actually can be used in a real life environment, avoiding silly design inconsistencies like you can spell check your popup notes but you cannot do it for your notebooks entries.
  • a kopete that actually supports video/audio features of protocols.
  • a rock solid kblogger may help.
  • a way to synchronize mobile devices.

and the last

  • adding more work on making existing features working perfect rather than adding new ones.

Alin