Wednesday, 24 February 2010

Detection of architecture violations in C/C++ applications

In a small project, I am experimenting with a cleaner and in this case layered architecture for certain parts of PoDoFo. I think it is a quite usual problem, to have an architecture and a grown application and you would like to check whether the sources adhere to the previously defined architecture. Therefore, it is important to have tools to check for architecture violations. These can be used to validate the architecture at certain points of time or even after each commit to the source repository on a continuous integration server.

I did not know any tool which can easily do this kind of validations for C/C++ source code, so I came up with a small bash script that does exactly this. The only configuration needed are some rules that define the architecture. Architecture is in this case a layered architecture where certain modules are only allowed to include certain other modules. See image 1 for a small UML diagram of the architecture.



These rules can be edited at the top of the script:

RULES="content->structure \
content->datatype \
content->io \
content->util \
structure->datatype \
structure->io \
structure->util \
datatype->io \
datatype->util \
io->util \
content->fontconfig \
content->Carbon \
util->\.\. \
src->.* \
.*->tr1 \
.*->sys"

As you can see, it is also possible to use regular expressions. Also, I had to add some rules for includes like fontconfig (external libraries) that are not available in the UML diagram above.

The script produces quite a lot of output, but grepping for "violation" shows only the important results:


If you are interested you can get the bash script from here: check_architecture.sh The script should be self-explaining and pretty easy to adapt to your needs.

Sunday, 14 February 2010

Building KRename trunk from SVN

I just noticed that there is no up to date documentation on how to build KRename trunk from SVN on our website. Well, everyone who is interested in getting the latest version of KRename and does not want to wait for the next release - these are the steps to get KRename trunk from SVN and build it.


svn co https://krename.svn.sourceforge.net/svnroot/krename/trunk krename
cd krename
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$KDEDIR ../
make
sudo make install


This assumes that $KDEDIR is an environment variable pointing to your KDE installation. You can set $KDEDIR using the following bash command:

export KDEDIR=/usr


Most other KDE applications can be built the same way.

Saturday, 6 February 2010

Generic web-service queries on your desktop using Plasma

Some days ago, I applied for a new passport. In Munich, where I currently live, you apply for the passport at the city hall and usually can pick the passport up there 3 weeks later. I was surprised to see that they have a new service: You get an ID number with which you can check the status of your passport via a web-service. So, if you check regularly, the web-service will tell you when your
passport is ready to pick it up.

What is the usual you do in cases like that? Of course, you write a Plasmoid that checks the web-service periodically and informs you when your passport is ready. This plasmoid - PersonalKwery - can be seen in screenshot 1.


Thinking further about this quick hack, I came to the conclusion that with only a little bit of work, I could create a generic plasmoid that can query webservices and display the result on your desktop. I managed to create a plasmoid that takes the following configuration:

  • Base URL of the web-service

  • Attributes to the URL (like the ID number of my passport, or arguments to a Google query)

  • An optional XSLT to transform the results

  • An interval, how often the query should be performed



With this little configuration you can easily query many web-services. Of course, most users won't be in the mood to create their own XSLT transformations! Therefore it is possible to store the configurations as XML and share them - for example over "get hot new stuff". In this case, users can
download predefined web-service queries and only have to enter a few necessary attribute values. The screenshot below shows the configuration dialog for a query:


Another small example is a simple query, that get's your current internet IP address.


Of course, the tool is not perfect yet and can be made more user friendly. If you are interested, you can get the tarball here: personalkwery-0.1.tar.gz.

Sunday, 29 November 2009

"Modifiers" in KRename

Andi Clemens did some amazing work on the batch renamer included and integrated into digiKam. I really like the simple UI and some of the features he included. I think I can get some inspiration from him for KRename (e.g. syntax highlighting).

Lately he posted over the topic of "Modifiers" in the digiKam rename tool, which he added to digiKams renamer and was not able to find in KRename. Modifiers are a way to convert a token, let's say the name of a directory or the artist of a mp3 in some way before inserting it. For example if you insert the name of the directory into the new filename and the directory name is in all uppercase and to match the look of the new filename, you want it to be inserted in lowercase. In digiKam's renamer it is achieved by the token:
[dir.]{lower}

In KRename you would use:
[%dirname.]

So contrary to Andi's post, KRename has modifiers, too. You can add a modifier before any token (after the opening bracket and before the actual name of the token). The modifierst are those used to insert filename's and convert there case. To list the most important ones:





$No conversion, insert the token as it is
%Convert to lowercase
&Convert to uppercase
*Convert every first letter in a word to uppercase
##Format a number with leading zeros


So you can even use modifierst to format numbers for tokens that return number. For example [##tagTrack] will insert the track number of a MP3 formatted with one leading zero if the track number is less than 10.

It is true that KRename does not have a really readable syntax for modifiers here, I think appending {upper} or {lower} like digiKam does it, is a good idea. But there are several other places, too, where the KRename syntax could be improved. I hope that this post will help a few people that also did not know about this feature.

Modifiers in action

Tuesday, 11 November 2008

KRename on Windows

Some time ago - during a longer trip by train - I booted the Windows XP installed on my Eee PC and tried to port KRename to Windows. Thanks to the efforts of the KDE on Windows team it was only a matter of about 1-2 hours.

You don't believe it? Well see the screenshots:





I am really impressed how easy it is to get KDE on Windows installed and start compiling using Visual Studio. The only changes necessary were related to some Unix syscalls in the Permissions and Date&Time plugin. To try KRename out, it is best to get a current snapshot from SVN (I justed checked in the changes necessary for compilation on Win32).
A pre-compiled binary can be found here. It requires a working installation of KDE 4.1 for Windows. Simply copy it to %KDEDIR%/bin and it should work. If there is interest I might try to provide a real setup for Windows or create more regularly SVN builds.

Saturday, 4 October 2008

PoDoFoBrowser updates

I had finally sometime to work on PoDoFoBrowser again.

Most notably, I added finally a hex widget so that binary streams can be viewed directly from within PoDoFoBrowser:



Credits for the QHexView widget goes to Evan Teran.


Other changes include an implementation for Find and Replace in text streams and a new Goto Page feature. Both will safe you a lot of time when you have to work with content streams.

To try the changes, get PoDoFoBrowser from SVN.

Tuesday, 26 February 2008

KRename Video

Peter Upfold from fosswire.com has posted a great video on how to use KRename.

I think this video is great to show how KRename (or any other application) is working. I love the way he made the video: easy to understand and very well commented! Great work Peter!

You can find his article including the links to the video here. The video is available as flash for viewing online or as OGG for download.