Tuesday, 22 September 2009

How not to use signals and slots

I wanted sound module to work for brand-new git/master Kadu with Phonon backend. So I've looked at code of sound and phonon_sound modules and I've discovered a big misuse of signal-slot mechanism.

Please look at sound.h file from 0.6.5 branch. The interesting part is signals: from SoundManager class:
  void openDeviceImpl(SoundDeviceType type,
       int sample_rate, int channels,
       SoundDevice* device);
  void closeDeviceImpl(SoundDevice device);
  void playSampleImpl(SoundDevice device,
       const int16_t* data, int length,
       bool *result);
  void recordSampleImpl(SoundDevice device,
       int16_t* data, int length, bool *result);

How this works? A module such as phonon_module creates new object that connects to these signals. Then a signal is emited and a slot is executed. Everything works, but this creates a lot of problems:
  • many object can conencts to these slots so sound may be played many times by different backend
  • so we need to ensure that only one backend is loaded, this requires additional code in module-managing classes
  • object can just ignore some signals and do not implement slots and/or connect them
  • results are returned using pointers in last parameters of these signals
This kind of problem requires another solution, that is still very simple and nice to implement:
  • create abstract class, like SoundPlayer, that has methods like SoundDevice *openDevice() and so on
  • create object SoundPlayer *Player in SoundManager
  • use this object instead of emitting signals
  • make SoundPlayer parent class of backend classes instead of connecting signals
Thats all today ;)

Monday, 14 September 2009

New history window

Juzef has been working on new history window (and SQL history backend) for some time. So I've finally give it a try and after some tweaks I will show you effects of his work (this window still needs lot of work from our UI team, but it works as it should):

On the left side there is list of all chats (single ones and conferences - future modules like irc_protocol would be able to add new types of chats). You can use edit box above this tree view to filter chats by name, contacts, contacts' ids and whatever you want.

On the right side you have list of dates. You can select any one of them and you will get list of messages from that date. Above that is edit box for searching words (it will filter chats and dates lists too) and for selecting date range (it will filter chats list also).

What needs to be done:
* usability (this window does not have any)
* highlighting of found words (needs backport from

Monday, 7 September 2009

New channels

Three new channels for KaduTeam-world communication were open today:
I hope you will enjoy reading our microblogs ;)

Saturday, 5 September 2009

New history feature

Yesterday I've added a feature known from Skype - user can display messages from yesterday/last 7 days/last 30 days in chat window. I needed only one hour to implement it, thanks to Juzef's SQL history and improving Kadu API ;)


I know, the icon is the same as "Show history" one. I'll ask our art team to make a new one :)

Wednesday, 2 September 2009

Another git repository

White Eagle has set up a new git repository for Kadu: on gitorious.org. It is way better that the one I've set: it has all our SVN tags, branches and externals (libiris). He has spent a lot of time to do that ;)

So now repositorium on Github is just a mirror of master branch and other git branches (not including old svn-ones). Feel free to ask for access to any of them.