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.

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.

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.

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 =:)

Posted in coding | 33 Comments

GSoC Update: Finished category syncing and Contacts conduit

Things are progressing very nicely although not at the speed I original intended. Yesterday I finished some small bugs in the Category sync code which were still there when doing a life sync. Now you can actually add a category to you palm and it will be added at the pc side during sync and vice versa. The cool thing of this is that this code is in the base library which means that all conduits based on it will have support for category syncing. The fixes make the KeyringConduit less or more fully functional. The only problem is that there is not really a good Keyring database editor. And no don’t try the java keyring editor as it will bork your database file. As I needed something for testing I started working on a editor but that one is far from complete and I first need to finish my GSoC work. It does, however, support adding, deleting and modifications of records as well as creating new and opening existing databases.

Another thing that I’ve finished ™ the last couple of days is the contacts conduit. This conduit is able to sync the addressbook of the palm with an Akonadi contacts resource (currently I only tested with the vcard resource, but I guess other resources that only contain contacts should work as well). Of course there will be some polishing and bullet-proofing needed before it is ready for day-to-day use but the first results are really promissing. I really have to say that working with the Akonadi libraries is a real pleasure. Good work guys!

Next steps will be abstracting some code that can be used for all conduits that are talking to Akonadi and port the other two PIM conduits Calendar and Todo.

Oh and before I forget: which is only possible thanks to generous sponsoring from the KDE e.v.

Posted in coding | 2 Comments

GSoC: A small side step.

One of the goals of my GSoC is to let Akonadi do the storage handling for KPilot. At least for the PIM conduits. In my previous blog I already mentioned that Akonadi entered KPilot. However yesterday and today I had to dive into the code of Akonadi itself.

Akonadi stores a revision number of for each item that is stored with it. KPilot however, does not have a notion of revisions. What it does store is the last time that the handheld was synced. So to see if a record on the pc side is changed it looks if the modification time of that record is after the last time that there occurred a sync. The dirty and quick solution (read work around) would be to store the modification time in a custom attribute of Item.

Well, Akonadi had *some* code already there for modification time but not yet on the client side and also not completely on the server side. Behold! =:) That has changed. (Thanks to a lot of patient of vkrause). Patches are send to the kde-pim list for review and will probably be committed soon. Unfortunately I did not have the time to implement more sophisticated features like: give me all items modified after <date>.

That’s all for now folks. I need to get back to KPilot hacking to keep Mr. vanRijn happy =:).

Posted in coding | Comments Off

SoC update: Akonadi enters KPilot

According to the testcode category syncing seems to work, although I did not yet test it extensively in a real sync. The test code does a sync, but between two local databases. It might be that there are still issues when using a database on the palm. But with the absence of any reasonable good working conduit (the only one which works ™ is the keyring conduit.) I’ll leave it as it is for now. The fundamentals are in and it should not need too much polishing.

The next step is to get a conduit syncing with an Akonadi collection. I started working on replacement for the abbrowserconduit (yes horrible name, the new one is called contacts). It does not much right now but the first code is promissing. I’m already able to contact Akonadi and fetch the addressbook items from it. What I’ve seen until now from Akanodi makes me already falling in love with it. A short chat of 15 minutes with vkrause, another 30 minutes of coding and compiling and the first working code is there. I hope that within a week or two KPilot is able to sync it’s contacts with Akanodi.

Oh and my brother and father came home yesterday with Czech ambulance. I was quite relieved when my dad called to tell he was home. My brother does reasonable well luckily. I hope he became a bit wiser now (although I doubt =:).

Posted in coding | 11 Comments

I need some rest after holliday.

What should have been one of the most relaxing weeks of the year became quite stressfull. It all started quite okay. First we had a wedding of a old school friend of Agnes. It was a beautiful day, the bride looked wonderfull and the wether was quite okay. Next day we celebrated the birthday of a sister of Agnes and prepared for our trip to Prague and Rokytnice nad jizerou (where we would met the rest of my family).

Before we left, we got a phonecall from my parents that my sister and her husband had to leave early because the mother of a good friend of them died. A friend of us brought us to Dortmund where we took the plane to Prague. The trip went quite well. In Prague we had a couple of wonderfull days with just the two of us. Of course I kept my promise and kissed Agnes on the Charles Bridge (karluv most):

Prague is really a wonderfull city and really romantic =:). However you have to look to the right direction. Luckily Agnes studies art history and points my glance from the tourist shop level to the wonderfull details of buildings that are at a bit higher level. We enjoyed a wonderfull classical concert of a small chamber orchestra in the national museum (really good ambiance and acoustic) and several other bands that play music on the street. Wandered around the city enjoying buildings, people, colors, sound and sights.

On sunday my parents picked us up and we traveled with them to Rokytnice nad jizerou, a small town ~100 km above Prague. We had to get acclimatized a bit because we really enjoyed being with just the two of us, and now we where with 7 people. However the landscape there was also very great. It has some small mountains (up to 1400 metres). Agnes and I rented some mountain bikes and made a really wonderful ride in the woods and mountains.

My two brothers and the girlfriend of my oldest brother also rented mountain bikes. However, they where too lazy to climb up and did not joined our ride. In stead they took a ski elevator with the bikes and just drove down. On Wednesday they wanted to drive again and the oldest of my brothers decided that he didn’t need a helmet this time *sigh*. Youngish recklessness I guess. This became almost fatal because he flew out of a curve and seriously damaged his skull. He had a skull base fracture. He is operated the same day in a town 30 km away from where we resided. From that moment on we where only busy with driving between our vacation address and the hospital, trying to get information about his status (the nurses in the Czech Republic do not speak English nor German) and arranging the journey back to Netherlands for us and my brother. Luckily he’s quite well right now and even got back his sense of humor. (At least he could laugh when I suggested “brain breakers” after he asked for a puzzle magazine to kill time. The doctors had to shave his head for the surgery which made him even uglier then he was =:)

As it looks now he can come back to Holland somewhere this week.

Posted in coding | 2 Comments

users, contributors, SoC and holliday.

First of all, I was pretty shocked reading about the disappearing of Aaron and all the fuss around. One of the things I really liked, and still like about the KDE community was the nice atmosphere in the community. I still know how Adriaan encouraged me to write some code for some functionality I wanted into KPilot. And also Jason has been quite an inspirator the last years. They are just some of the guys that help the new comers to step over the doorstep and to join “the club”. This is actually exactly what kept me from contributing to my distro of choice. (Yes I switched back again).

Now the question arose, what we need, user or contributors. (1, 2). I think that we need both of them. Even users that do not contribute directly to the project have some use. If only that they show to their family, friends, colleagues etc. that it is possible to have cool, featurefull and most importand free software. A more important question in my opinion is: how does the contributing part of the project respond to people that drop by. Even more urgent stated, how do you and I react on people dropping by and spitting out there thoughts, wishes and complaints? I guess we should more often count to ten before giving an answer. Oh and of course we should not keep quite when one of the contributors is attacked personally, especially not when that happens publically. I hope that the dot revamp will make it a bit easier to moderate this sort of poisonous attacks, but it still leaves us with a lot of other places like b.k.o and mailling lists.

So far my thoughts on this. (Oh and Aaron, I’d love to see you blog online again =:)

Of course I’ve not only been reading blogs the past couple of weeks. I still was finishing my internship. I created an implementation of compressed XML indexes (only the creational part unfortunately, the searching part is left for the master thesis I think). As the code is not very usefull yet I don’t publish it right now. The report is not finished yet, but I’ll put online somewhere when it is. The cool thing about this is that you can get compression ratios between 20%-60% (of the original file size) while have structures that support both navigational and content search queries. Which in turn is nice when you want to have search in XML on small devices for example.

Besides that I worked on my summer of code project. And currently I finished the first part of it namely category syncing. The framework I created previous year is now able to sync the categories of pc records and handheld records. This is quite cool, because it’s implemented in such a way that conduits don’t have to add additional code for this. Next step: port some of the conduits to the akonadi framework. I’m not sure yet how to start on this one, if you have some hints, please let me know. The basic idea is this: The base conduit initializes a dataproxy object for the handheld and one for the pc data store. Both are implemented by specific conduits (let’s say addressbook). The data store is responsible for iterating over the records. In a hotsync this should be only the modified records (is there even some way in akonadi to see if a record is changed after a sync or do I have to keep track of that somehow), and in a fullsync it iterates over all records.

But first I’ll be off for a wedding, a weekend in Prague (I promissed my wife to kiss her on the Karls bridge) and a midweek to some small town 100km above Prague (forgot the name of it).

Posted in coding | Comments Off

Time flies when you ……

have fun. Indeed it does. We’re already at the beginning of the summer of code again. Well that in itself is not a bad thing of course but the fact that I wasn’t able to do much in between this and the previous SoC is a bad thing. But besides the fact that I was not able to code much, I had quite an interesting year. I’ve had some great courses at the university and now I’m finishing an even more interesting internship. I hope to exaggerate on that a bit more soon.

However new SoC, new changes. First thing I’ll be working on is a long wanted feature in KPilot. Consistent support of category syncing. There where some conduits that did support it, I think addressbook had the best support. But every conduit did this in it’s own way. So abstracting this into the base conduit will finish the foundation for every record based conduit. You can find some more info at categorysync.txt. Comments on that are always welcome =:). I’ve also set up a project page which you can find at: SoC 2008 project page

Posted in coding | Comments Off