Category Archives: coding

Some love for KGpg

For a course I did (Information Security) we had to create our own gpg key and do some signing and encrypting, well the normal stuff you seem to do with these things. As a side note, I did already did this twice some time ago but forgot the passwords of my private keys because I never used them so now I have two dangling accounts on the pgp servers *sigh*.

However, this made me have a look at KGpg which in turn made me cry. Heh, it seems in a not too good state. Having a bit of time, and being really annoyed by issues in the key server configuration page made me start hacking on it a bit. I fixed (hopefully) all issues in there. I have done this in trunk, maybe I should also back port this to 3.5 as the issues seems to be there also.

I don’t know if there is a maintainer currently and if there is I hope I didn’t pass you by. I did a quick search on bugs.kde.org but did not find any bugs related to this. Maybe I’ll take a stab to other issues I find too if I a) really start using gpg, b) have some spare time, c) find more issues (although that won’t be a constraint I think).

And last, it is not totally clear to me if there is any relation between kgpg and kleopatra, and if so what that relation is. If some kind soul could enlighten me on this….. that would be great. Continue reading

Posted in coding | Tagged | 8 Comments

Code cosmetics and quality.

About two weeks ago I added the postfixop check to krazy. This checks for postfix uses of ++/– usage. Initially I constrained the check to for-loops. However this lead to a huge amount of issues because also postfix usage of ++/– operators on simple types where marked as an issue. After some discussion with Eckhart Woerner and Allen Winterz I relaxed the check more so that usage on simple types is also not taken in account anymore.

Although postfix usage on simple types won’t gain you any/much I still think it’s a good thing to consequently use prefix wherever appropriate. However that has more a cosmetic reason (which I why I took it out actually) then a perfomance reason. Consider for example the next piece of code (and yes I’ve seen something like this somewhere in the KDE codebase):

QList::Iterator it = list.begin();
for( int i = someNumber(); it != list.end(); ++it, i++ )
{
...
}

I realize that it’s partly a matter of taste if you like this kind of code snippets in your code base or not. However for people who never have had some in depth programming course it might look like if it is arbitrary what you choose.

Another thing I’ve been thinking about last weeks is "What is the importance of cosmetic changes in relation to code quality". When browsing through the source of KMail while fixing issues reported by krazy I see a lot of things which make me cry. For example defining variables which are used only ~25 lines later or in 3 different context. These kind of things make my fingers itch to rewrite such parts. Well, don’t be scared, I didn’t….. if it ain’t broken don’t fix it, right? But I still can’t find a good answer on the question: is that sort of code broken? In some sense it is in my opinion. When I as a newcomer to the KMail code look into some sections I really have to read that twice or sometimes even more times to get some vague idea what is happening over there. I think that is something that can be avoided (to some extend of course, as not everything in life is as easy as we would like it to be). All this made me think that it would be a nice to have something in addition to the normal krazy checks which checks for situations where some cosmetic change might improve the readability (and therefore the quality?) of the code.

Well, leave me a comment if you have some noteworthy ideas about these topics.

p.s. KMail only served as example here, I guess there are more places which have similar issues. It’s just that I was browsing through KMails code while these thoughts came up. Continue reading

Posted in coding | Tagged , | 18 Comments

Help us testing KPilot using your n810/n800/n770

Dear lazyweb (at least the KDE part of that, having an n810 Garnet VM supported device),

I just heard from Jason “vanRijn” Kaspaer that there is a VM for the n810 which makes it possible to run Palm applications on your n810. I just gave it a try and its just awesome! When you install the VM you instantly have the addressbook, calendar and todo applications available. As these are currently the only supported applications in KPilot this should be enough ;) . I tried to install, configured kpilot, pressed the hotsync button in the VM and guess what? It just seem to work. So how to turn your n810 in a PIM device which can be synced against trunk?

  1. Goto: Garnet VM and download the GVM on your n810 (mind you, you need to register).
  2. configure KPilot to look for device: net:any (kpilot -s -> General Setup -> Device -> Pilot Device
  3. Make sure you have some valid resource configured for the conduit you want to test (Note: first try to create a new resource in Akonadi and don’t use your production resources. Note 2: Don’t tell me I didn’t warn you. Note 3: If you use the resource bridge of Kevin Krammer you can even add it to the kde PIM like kaddressbook.)
  4. start adding some items on one or both sides
  5. Start KPilot
  6. press the hotsync button in the GVM (Note: you have to leave the specific application e.g. addressbook to see that button).

That’s it, happy syncing :)

If you have Issues please let us know and no, no screen shots today. Try out yourself! For issues please drop by in #kpilot, #kontact or #akonadi (whatever is most appropriate for the issue).

Update: Of course this works for every Nokia device that is supported by the Garnet VM. Thanks Lynoure Braakman for pointing out my narrow mindedness on this point =:). Continue reading

Posted in coding | Tagged , , | 7 Comments

Fixing EBN isues.

Study has started again, which means that my attention is (slowly) shifting from KDE hacking to all kind of study related things. Which is not that bad as I have some quite interesting courses (information security, advanced c++ programming and computer vision). Normally this means for me that I don’t have time (but more, no energy) to do very much KDE hacking. However I found some task which can be done relative easily in between. Bringing down EBN  issues. I have worked out a lot of issues in KPilot already and currently I’m giving a stab at KMail.

While it might seem very dull, which it is in some sense, it is also very satisfying. Not in the first place to see the numbers going down on EBN itself ;) . But when working on the issues you also see code transforming, becoming more uniform and in some cases more readable. I don’t know what it is but I just enjoy seeing beautiful code. (Might be due to the book Google send me this summer, and by hanging out too much with [ade] in the past).

One of the things I noted in KMail (but I’ve seen this also in KPilot) is a quite inconsistent use of header inclusion. This happens in two areas. The first is that in some header files no forward declarations are used even when that is possible (when only pointers or references of that type are declared).

So

#include <QtModule/QClass>

class MyClass {
...
QCLass *mVariable;
....
void method( const QClass& c );
...
}

The second thing is that the include lists are a real mess in some files. Sometimes even k includes and Q includes are mixed up. What I would like to see is having a preferred order for includes in each file. Let’s say: own headers, project headers, k headers, q headers and other headers. And the next thing I’d like to see would be to have the includes sorted alphabetically. These are in fact relatively small changes but I think most of the headers and cpp files can be designed to look that way. This really would make it easier for (new) developers to see in a glance which classes/methods are actually used and also to see if the class he wants to used is included already. Another little annoyance I did see was mixing up (between files): #include KMyClass and #include "kmyclass.h". I guess most of these things are not new for the readers of my blog and still we (including myself) make really a mess of things so now and then =:).
This wasn’t meant as some rant on the kmail coding style or something. Just wanted to share some thought about this in general. Please let me know if you have some useful comment on this subject. Currently there is unfortunately not a check for unneeded includes in headers in krazy, but this would be very nice. If you have perl skills please give winterz a hand on this. p.s. Even this can snoop a lot of time which should be spend on my study =:S. p.p.s. If you find issues in KMail due to EBN Fixes I did, please drop me a mail at: [b DOT broeksema AT home DOT nl] and I’ll try to fix or revert the change if necessary. p.p.p.s. The line edits in KMail will soon have that cool clear button…. Continue reading

Posted in coding | Tagged , , | Comments Off

OpenSync meeting in Berlin

This weekend I have been in Berlin at the KDAB office to meet with the OpenSync guys. I arrived Friday at around 20:00 in a really nice atmosphere. Volker and Tobias where already there as well as some OpenSync guys. Volker had enlightened the OpenSync guys about Akonadi by the time I arrived. We went for a dinner first and after that we got an introduction of OpenSync from Daniel Gollub. They are currently working on a new release so there’s a lot of API breaking going on currently. However most of the functionality seems to get in shape right now.
As a side note, breaking API seems to be part of their regular development work. I really hope that they can get to some stable API which won’t change with every release they do. This issue seems to be a bit of a pain currently.
I gave a short talk about the current status of KPilot and we looked a bit what OpenSync could mean for KPilot. It became (again) clear that KPilot has a couple of features for which OpenSync is really not designed. However the baseconduit framework I created is quite like OpenSync (at least in the functionality it has, the designs differ some). Currently I’ll not start on integration of OpenSync into KPilot because what we have now is working reasonably well. When however KitchenSync is ported to the new API and the opensync palm plugins too, then I might give it a try to delegate the actual syncing to KitchenSync/OpenSync.
Volker started working on an OpenSync Akonadi plugin. The basic code is already there but unfortunately not yet very useful due to missing/not working functionality in the OpenSync library.
Further more we got a lot of information from Michael Bell, who is working on the libsyncml library. He gave us a nice overview of the architecture and also a guide to get started. The guide contained a lot of details and pitfalls, so much that I loosed track a bit. Well I guess that’s the other side of the coin when you want to support every device out there.
All in all, it was a great atmosphere, really good coffee, a lot off cookies, a lot of hacking, a lot of strange music coming from the streets, a lot of good food and a lot of fun!

On the KPilot front: I’m currently working on a “not so nice thing to do”. Cleaning up the huge amount of krazy warnings. This is kind a dull job but it is annoying me for ages now. Currently KPilot is not the black sheep of kdepim anymore but I want to get that number as low as possible (0 preferably). I also still have some items on my to do list regarding the Akonadi code and the base framework. Hope I can get to that soon. Continue reading

Posted in coding | Tagged , , | 7 Comments

Wrapping up: GSoC and Akademy are over already.

Akademy is over, GSoC is over, so finally some time to cool down =:). Well, I guess this is more a sign that real life will take over very soon again. Within a week or two the college year will kick off and whatever more. However, I really have had a great time. It was again a real pleasure to work with vanRijn on my summer of code project. Like him I also am very pleased with the results of the summer of code. As mentioned earlier there is still some polishing left to do but I think that KPilot is in a reasonable good shape right now.

I cannot do anything else than confirm all the positive feedback given on Akademy. It was the second time I attended but this year it was just awesome! So much interesting talks, great ideas and wide visions for KDE. I also really enjoyed meeting all those cool people. It was just great to discuss code, problems in the Banlieus of Paris, eating habits, funny things in spoken language and what not more. So thank you Armin, Alex, Andre, David, Kevin, Patrick, Volker, Thomas and all of you who I have spoken but who I don’t remember right now. I truly enjoyed!

Akademy has got a tail for me as I was invited to join the KDE/OpenSync meeting in Berlin next weekend. I’m really exited to see what we can get out of that. Now KPilot is getting into shape and the amount of types of devices on my desk is growing I’m really looking forward to have a desktop which is prepared to sync all me personal stuff between those gadgets and my normal pc. I have a growing conviction that a desktop should be just able to sync when I pop in one of my devices. So lets see what can be done to make this happen.

note to self: I should start reading the OpenSync and KitchenSync code. Continue reading

Posted in coding | Tagged , , | 2 Comments

Exporting symbols only for testing.

I finally tried out what I wanted to try for some time now. The problem (if you can call it a problem) I had is that one of the libs I worked on for my GSoC contained class that I wanted to test but that I did not want to expose to the rest of the world. As I did not have the time nor the knowledge to make that happen I just exported the classes so that the testcode could link against it.

Well that changed today and I took some time to figure this out. (Note: I’m not an expert on C++, libraries and such so if I do stupid things here, let me know). In the KPilot code we have an KPILOT_EXPORT define which looks like this:

#include <kdemacros.h>

#ifndef KPILOT_EXPORT
# if defined(MAKE_KPILOT_LIB)
/* We are building this library */
# define KPILOT_EXPORT KDE_EXPORT
# else
/* We are using this library */
# define KPILOT_EXPORT KDE_IMPORT
# endif
#endif

The way I understand this snippet is that it makes the symbol that is prefixed with it visible anyhow. But what I wanted is that the symbol is only exported when the tests are enabled. Therefore I added another define which looks like this:

#ifndef KPILOT_TEST_EXPORT
# if defined(HAVE_TESTS_ENABLED)
# define KPILOT_TEST_EXPORT KDE_EXPORT
# else
# define KPILOT_TEST_EXPORT KDE_NO_EXPORT
# endif
#endif

To make this work I added this to the CMakeLists.txt file:

string(COMPARE EQUAL ${KDE4_BUILD_TESTS} "ON" buildtests)
macro_bool_to_01(buildtests HAVE_TESTS_ENABLED)
configure_file(config-kpilot.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kpilot.h )

And the config-kpilot.h.cmake file got a line added that looks like:

#cmakedefine HAVE_TESTS_ENABLED

Now I can use:

class KPILOT_TEST_EXPORT IDMapperXmlSource
{
....
};

and the given class gets only global in the library when testing is enabled. I wondered why there is no such export in kdemacros.h as I found this quite a nice solution. The library won’t export symbols in release mode, which is a bit cleaner than just exporting everyting only to be able to test imo. But as said, I’m only a novice on this kind of things =:). This whole thing made wondering if there is some GUI tool to explore libraries. Continue reading

Posted in coding | Tagged , | 6 Comments

The future of KPilot

Now the Google Summer of Code approaches its end I’d like to share some thoughts on KPilot. First of these is that I was slightly surprised by the responses I got on an earlier blog. I know that there are still KPilot users but in some sense I did not really believe it. So if you are a user and want to use it in KDE4 please let us know. It is really encouraging when getting some nice message from someone out there . I know, we are not so good in keeping our website up to date, so you might also want to drop by in #kpilot on irc.freenode.org or at our personal websites. Furthermore, you can follow development activities at the KPilot ohloh site.

That said, what are the plans for KPilot? Our major goal is to release a new KPilot version with KDE 4.2. So that will be in six months or so. In the past couple of months we have done a lot of work to get KPilot syncing with akonadi and the results are promising. At the end of this GSoC (that is, after two weeks from now) we have “working” todo, contacts and calendar conduits. Working is quoted as polishing of the KPilot code as well as some kdepim/akonadi code is needed. How usefull KPilot will be at release time also depends a bit on the other kdepim applications as none of them (except mailody?) are ported to Akonadi yet if I’m correct. However at 4.2 that has changed (we hope) and therefore the following conduits will be released then:

  • calendar
  • contacts
  • file installer
  • memofile
  • time
  • todos

The results of this GSoC and the previous one is that most conduits share way more code than they did before. This should make the maintenance and bugfixing a bit easier for us.

We also slimmed down our focus. KPilot will be the application to synchronize your KDE PIM data with your palm device. This means that we will remove the old database viewers that where in it in the 3.5 series. The viewer code is old, not good working, does not have any real purpose and we do not have time/energy to work on that. In return of that you will get category synchronization for each record based conduit. I have been thinking a bit about the gui of KPilot but have no clear idea yet how it should look. So good ideas on this are welcome.

Besides the “getting things working again” again, the codebase needs a lot of clean up. But first things first. All in all, this should make KPilot should survive another KDE series. Continue reading

Posted in coding | Tagged , , | 17 Comments

Applepie monsters and the return of good old friends.

Agnes and I have had a very nice weekend. We relaxed a lot after hard a week of hard working, cleaned up the house a bit and we baked a very nice applepie. Someone here in the neighborhood has a big appletree with apples that are very suitable to bake an applepie from. So we took enough apples for our pie (yes we asked of course =:) and started to peel and cut in pieces the apples. We just started this work when Agnes gave a loud scream. I looked and asked what the problem was and discovered some creature on which I could nicely try the macro feature of our camera. This gave this picture as a nice result:

[img_assist|nid=34|title=|desc=Click for original size|link=popup|align=center|width=100|height=75]

Less nice, was that she refused to peel any apple so that I could do most of the work, sigh. I also discovered that freshly crunched cinnamon is way better than the cinnamon you get out of a supermarket can. I wish I could take photographs of smells =:( Unfortunatly I can’t but the looks where great also (I only forgot to take a picture of the final result, but I can tell you, it was delecious):

[img_assist|nid=37|title=|desc=|link=popup|align=left|width=100|height=75][img_assist|nid=35|title=|desc=|link=popup|align=left|width=100|height=75][img_assist|nid=36|title=|desc=|link=popup|align=left|width=100|height=75]

While working on the applepie the phone ringed. When I took it, I was really surprised and even more glad that our friends, which have been to Ghana for 10 months, are back and wanted to come by. We had a great evening together, joining the wether, a good meal, wine, beer and everything else they must had been missing. It was really good to see each other again and have some good talks on the balcony. Continue reading

Posted in coding | Comments Off

Coding practices

Warning, this is a “dear lazyweb post”, however help would be very appreciated. While working on my GSoC project I see a lot differences between code written by various people. When I look at the code I wrote previous GSoC I’m not always very pleased with especially when I compare it with code I see in Akonadi for example. This brought me to a couple of questions:

  1. When should I use a d pointer in stead of private/protected members, and should I always use QSharedDataPointer when using a d-pointer?
  2. Should I use:
    copy( const Record* from, Record* to )
    or
    copy( const Record& from, Record& to )
    and if the last option, why?

Well, if you have some answers for me I would be very pleased =:) Continue reading

Posted in coding | 33 Comments