Showing posts with label kde. Show all posts
Showing posts with label kde. Show all posts

Wednesday, March 23, 2011

Code reading and Bug fixing 101

Summer is here, and Google Summer of Code is on its way. The biggest hurdle new contributors often face (after compiling trunk ;)) is to get their head around the project they would like to work on, understanding how it works, where the parts fit in, and how to fix bugs or make improvements. Speaking from my experience, it took me the better part of a month to understand how KWin worked before I could actually hack on it for Season on KDE.

This is my attempt to explain how I approach new code and the tools I use. To demonstrate, I am going to try and fix this bug in Amarok. I am sorry for stealing a Junior Job.

The most important thing when working on existing code is:

DO NOT modify existing code that works, even if you absolutely have too1


This means, avoid changing function signatures, variable names, and especially surrounding code that does not affect you. You may inadvertently introduce bugs.
That said, remember that you are using a version control system, so code fearlessly. The best way to understand new code conceptually is to liberally insert some kind of debug/print statements all over relevant functions. With that in mind, let’s start.

Understand the problem

The bug report says:

When you filter all items in Amarok, a warning notice is shown that “tracks have been hidden in the playlist”. However, if you filter, and then delete all results of that filter from the playlist, this warning is not shown

Reproducible: Always

Steps to Reproduce:

Set a filter
Remove all matcheS
This is a fairly straight-forward bug with well written steps to reproduce. If not, its best to ask questions on the bug tracker or talk to someone more experienced to understand what the bug/feature actually requires. The next step is to reproduce the bug. If you cannot make the bug occur, you have no way to prove that your changes fix it. Again, try to reproduce bug in the bleeding edge version of the project. Otherwise it has already been fixed. So let’s add some tracks to the playlist, put something in the filter text. Observe that if you put a pattern that doesn’t match any track, you get the warning. Now change the pattern to match a few tracks. Remove those tracks from the playlist. No warning! This is what we have to fix.
Up to this point, the process has been just what a user would do, now its time to enter the code.

Where is the problem?

The Amarok source tree is pretty large. By convention, all source code is in the src/ directory. This is true for almost all open source projects. But what now?
The easiest way to find out the source of the problem is to find a nice clue in the interface that gives us a good idea of what the relevant file will be called or where we can make a change.
At this point, let me introduce a tool called ack, which is grep optimized for programmers. I won’t bother describing the features, but trust me, you should be using it!
Let’s enter the Amarok source tree, and try to find “Warning: tracks have been hidden in the playlist”. Why so, well, since it is being hidden and shown, it obviously has something to do with our task.

$ cs amarok
$ cd src # all code is here
$ ls
...
playlist
...
$ ack "Warning: tracks have been hidden" playlist/
playlist/ProgressiveSearchWidget.cpp
45: m_warningLabel = new QLabel( i18n("Warning: tracks have been hidden in the playlist"), this );

Notice a few things. First, I ran the search only on the playlist directory. You could have run it on src and it would just have taken more time. But its good to do a ls on src because knowing the directory structure is a good way to get the highest-level overview of a project. playlist is a suspiciously strong pointer to our bug. So let’s run it on this.

This seems like a good start, there is a label being created that has the message. But we need more information. So fire up your editor/IDE and go to line 45 of src/playlist/ProgressiveSearchWidget.cpp. Knowing nifty utilities in your editor is a good investment, you absolutely must know the shortcut to jump to a specific line since line numbers are used all over programming, in compilers, editors, and humans talking to each other. With vim it’s:

$ vim playlist/ProgressiveSearchWidget.cpp +45

Now, let’s see where this label is being manipulated. For this we need another useful editor feature, to find instances of symbol under cursor. QtCreator or KDevelop allow you to just right click on the variable name and find all uses. With vim I hit the * key.

void ProgressiveSearchWidget::showHiddenTracksWarning()
{
m_warningLabel->show();
}

void ProgressiveSearchWidget::hideHiddenTracksWarning()
{
m_warningLabel->hide();
}
And there is our first break. A pair of functions which show or hide the label. Continue this technique of ‘follow the useful symbol’. Let’s see where showHiddenTracksWarning() is being called. In this case, its just above the definition.
void ProgressiveSearchWidget::noMatch()
{
...
if( m_showOnlyMatches )
showHiddenTracksWarning();
}

void ProgressiveSearchWidget::showHiddenTracksWarning()
But if you try to follow noMatch(), it won’t be in this file. Running ack again:

$ ack 'noMatch' playlist/
playlist/ProgressiveSearchWidget.h
130: void noMatch();
playlist/ProgressiveSearchWidget.cpp
216:void ProgressiveSearchWidget::noMatch()
playlist/PlaylistDock.cpp
144: connect( m_playlistView, SIGNAL( notFound() ), m_searchWidget, SLOT( noMatch() ) );

At this point, I assume you are smart enough to follow the code on your own, because pasting every sample here is annoying :) If you see playlist/PlaylistDock.cpp, then m_playlistView represents the playlist in some manner. m_searchWidget on the other hand is the place where the user types the filter. So when the playlist can’t find any matches, it tells the search widget, which then shows the label!

Except, something is going wrong in the exact circumstances of the bug. One possible explanation is that noMatch() never gets called. Your first idea might be – lets call notFound() when tracks are deleted and be done with it. But let’s dig deeper.

So what is m_playlistView? Simple, open the header file for PlaylistDock.

PrettyListView* m_playlistView;

Hmm, now where might PrettyListView be? At this point, you can use your fancy IDE, but I am going to introduce another ancient UNIX tool – find. When programming, it is helpful to generalize assumptions about how the code is organized and named, since it makes navigation a lot easier. If you’ve seen even the Amarok code that is just in this article, you can see that classes usually map one-to-one to file names.
$ find -iname 'prettylistview*'
./playlist/view/listview/PrettyListView.cpp
./playlist/view/listview/PrettyListView.h
find takes a lot of powerful options, but here we say

Find all files from the current directory (src) downwards, whose name (-name) matches the pattern ‘prettylistview*’, but ignore case (-iname)

and there you go, open PrettyListView.cpp and search for notFound. So notFound is emitted by the PrettyListView::find method, which itself is incidentally connected to ProgressiveSearchWidget::filterChanged (connected in Playlist::Dock::polish). Here is how our mental model goes till now:


Mental model

When the user types something, ProgressiveSearchWidget::filterChanged is being invoked, which is triggering PrettyListView::find. When find sees that no tracks are visible, it emits notFound. This triggers ProgressiveSearchWidget::noMatch which shows the warning label.
With some more effort, you will also find that PrettyListView::find is only called due to filterChanged. We can now use this knowledge to figure out why the bug happens.
Deleting a track does not change the filter in any manner. So following the call chain, noMatch never gets called when tracks are deleted to re-evaluate the situation!


The solution

The obvious solution is to somehow call PrettyListView::find manually when tracks are deleted in the playlist. But how will we know that? We will again use some GUI hints. Tracks are deleted by right-clicking them and selecting ‘Remove From Playlist’. If you ack this, you will find the action triggers a removeSelection() (playlist/view/PlaylistViewCommon.cpp). The type of the receiver is just QWidget, so it would be a hassle to try and find out the type of parent, but there is only one definition of a method called removeSelection() related to playlists. It is in PrettyListView. At this point, you suddenly feel empowered as the solution clicks before your eyes.

As soon as we remove the tracks, we can just call find() again and we will be done!

A fundamental constraint that inhibits us is the loose coupling made possible by signals and slots.
PrettyListView is unaware of ProgressiveSearchWidget and its properties.
All it knows is that it is expected to emit certain signals (found/notFound) and things happen. PrettyListView also does not have direct access to whether items are being filtered or not. These things are passed on to it from the filterChanged() signal’s arguments.
At this stage, I hope that you now have a good idea of how things are connected. For a little indepth understanding of how things are playing out see 2.

With this in mind, there are atleast 2 solutions that come to mind. Our task is to somehow force the filter action to be performed again on the view so that it emits the relevant signals. Unfortunately the view itself does not have access to the showOnlyMatches attribute present in the dock, and in the SortFilterProxies. We can,

1. Use PlaylistDock, which has access to the search widget

A roundabout method I did first, involving:
  1. adding a getter, ProgressiveSearchWidget::currentSearchFields().
  2. Connecting to the controller’s (The::playlistController()) changed() signal, a custom slot in Playlist::Dock called slotReapplyFilter().
  3. slotReapplyFilter() calls PrettyListView::find() again with relevant arguments.

2. Make the view store showOnlyMatches

A much simpler three line change.
  1. Add a bool m_showOnlyMatches to PrettyListView.
  2. When PrettyListView::showOnlyMatches() is called, along with passing along the value to the playlist, we also set m_showOnlyMatches.
  3. In PrettyListView::removeSelection(), call PrettyListView::find() since we now have complete knowledge.

Programmers exchange changes in code with something called a diff, or a file which only logs the changes made in the code.

$ git diff
diff --git a/src/playlist/view/listview/PrettyListView.cpp b/src/playlist/view/listview/PrettyListView.cpp
index cd650f6..e81d396 100644
--- a/src/playlist/view/listview/PrettyListView.cpp
+++ b/src/playlist/view/listview/PrettyListView.cpp
@@ -194,6 +194,8 @@ Playlist::PrettyListView::removeSelection()
QModelIndex newSelectionIndex = model()->index( firstRow, 0 );
setCurrentIndex( newSelectionIndex );
selectionModel()->select( newSelectionIndex, QItemSelectionModel::Select );
+
+ find( The::playlist()->currentSearchTerm(), The::playlist()->currentSearchFields(), m_showOnlyMatches );
}
}

@@ -912,6 +914,7 @@ void Playlist::PrettyListView::updateProxyTimeout()

void Playlist::PrettyListView::showOnlyMatches( bool onlyMatches )
{
+ m_showOnlyMatches = onlyMatches;
The::playlist()->showOnlyMatches( onlyMatches );
}

diff --git a/src/playlist/view/listview/PrettyListView.h b/src/playlist/view/listview/PrettyListView.h
index f22a7c8..612be0b 100644
--- a/src/playlist/view/listview/PrettyListView.h
+++ b/src/playlist/view/listview/PrettyListView.h
@@ -139,6 +139,8 @@ private:

QTimer *m_animationTimer;

+ bool m_showOnlyMatches;
+
public:
QList<int> selectedRows() const;
};
Since this is a minor patch, I could just commit this change. But I’m not going to for two reasons:
  1. You don’t have commit access, so I will show you how its done in that case.
  2. This is not code that I have worked with before, so however small, it should go through review. The reason is that I may have inadvertently affected the system due to incomplete knowledge. This is were unit and regression tests can also come in handy.
So let’s first get our diff into a file

$ git diff > /tmp/amarok-bugfix-260352.patch
Now hop on to reviewboard, and submit it. (Don’t actually do it, I’ve already done it!). Here is how the final submission looks.
Now wait for somebody to reply or commit on behalf of you. That is it! Your first bug fix.

Code reading only gets easier as you go along. It does not involve complex equations, but instead mentally executing the program just as a computer would. The catch is to be able to go from the low level details to creating the software architecture in your head, and watching the messages flow through the program. You must know your tools really well since they are a big time-saver.

To summarise, the following usually help to get a good idea of the code and allow you to fix bugs or add features.


  1. Use UI hints
  2. Use debug statements where required.
  3. Sometimes purposely crashing a program (assert(0); anyone?) is a great way to see what code-path is being followed.
  4. Follow the code along, until you can build a mental model.
  5. Use the mental model to figure out multiple solutions.
  6. Implement a solution.
  7. Test it.
  8. Submit for review or commit.

I hope this post has been useful. If you do wish to continue participating in an open source project, it is a good idea to spend the first few days just glossing over various parts of the code to get a feel of the system. Then you can go into your little section and get comfortable.



  1. except when really required


  2. If you don’t understand what I say in this paragraph, accept it at face value and continue. There is a powerful design pattern called Model-view-controller that allows separation of concern between the playlist contents, modifying them and drawing them. This is embedded into Qt using the various Item/View classes. Amarok uses this extensively. (probably one of the biggest uses of Model View within KDE?) The PrettyListView is just deciding how to show and draw the tracks, which are actually stored in a set of models. Similarly a Controller will often modify the models as required, and the changes will automatically show up in the PrettyListView.


Wednesday, February 16, 2011

Why you should be at conf.kde.in

conf.kde.in is happening in Bangalore from 9th-13th March. This is a golden opportunity for students to have fun and learn some really interesting things that no college or class can teach. It is also a chance to form friendships that last forever.

If you don’t like long posts: here is the gist.

  • Short term benefits – a great time and a cool t-shirt.
  • Long term benefits – create something awesome, lots of friends and an impressive CV that recruiters will notice.

Remember that feeling you had the first time you made a paper boat all by yourself and set it on the water? Or the time when you sang really well on stage and a hundred people gave you a standing ovation? With KDE, its possible to create beauty everyday!

When I first started using Linux in 2004, KDE 3.2 was an eye-opener about what truly functional and powerful computing could be. It was liberating. But the real magic of KDE is in its people, highly talented, motivated and very warm individuals with a lot of free hugs. So come and join the community. You don’t have to be a top-grade programmer, a really great designer or a Indian language expert to enter. At KDE we welcome everybody who has the passion to improve the computing experience for millions of people.

If you are a programmer, at conf.kde.in you have a chance to take away intimate knowledge about working with technologies like Qt, a cross-platform library which allows you to create high-quality applications on Linux, Windows, Mac OS, Symbian and even Android. With so much web and social and information, you might want to make use of KDE’s excellent Nepomuk framework to create semantically aware apps that can look at things like humans. Or the lab sessions will have you get started with submitting bug fixes for KDE in no time.

If drawing and painting is your forte, we have sessions to get you contributing your skills to open source applications and improving the KDE look and feel. You could create the next UI paradigm and dominate the world! :)

A billion people are waiting to use computers, and one of the things stopping them from having cheap, affordable machines is the lack of English literacy. So if you know more than one language, you could jump in and translate applications to Indian languages and bring a smile to some kid, and make his future!

Don’t think that as a student you lack the qualifications to attend. A HUGE chunk of KDE is made of students, with even teenage contributors! I myself am just a 3rd year undergraduate. We encourage students through programs like Google Summer of Code, Season of KDE and Google Code-In for high-school students. conf.kde.in is here to guide you even if you have never programmed before. We have excellent talks for all levels, by notable members of the KDE community. We also have interactive lab sessions where you will get to hack and explore more code than you will ever do in your college courses :P

Make sure you drag along your teachers too. They can be introduced to the educational tools that make KDE such a great platform to learn new things on. Whether its astronomy or jigsaw puzzles or Ph. D. level computer courses, KDE has applications for them to make their teaching more tangible!

Student passes are Rs. 500 (for all 3 days, including lunch), teachers can register for Rs. 700. For others its Rs. 900. Register online before 25th February to attend conf.kde.in. Although you can register after that, even on the spot at the day of the conference, it will be more expensive later (Students: Rs. 700, Teachers: Rs. 900, Normal: Rs. 1200). Remember to enter discount codes to get a discount, and get your college ID card to the event.

  • Student discount: KDEIN_DIS_STU
  • Teacher discount: KDEIN_DIS_TCR

If you need a letter to get permission from your college, we can arrange that.

PS. If you can get a laptop with Linux on it to conf.kde.in, you can have twice the fun :)

conf.KDE.in badge

Posted via email from nikhil's posterous

Sunday, February 06, 2011

QHttpServer: Web Apps in Qt

Qt is a great GUI toolkit, but it is also an entire C++ standard library waiting to be used for other tasks. In addition the network module is really powerful. I’ve been playing around with node.js for a while now, and realized that Qt’s default asynchronous nature maps over perfectly to create a event-based web server. To make things better, Ryan Dahl’s small and fast http-parser is freely available. So I just combined the two, and here is QHttpServer.



Here is a ‘web-application’ written completely in C++/Qt. You can even try it out.



#!cpp
#include "greeting.h"

#include <QCoreApplication>
#include <QRegExp>
#include <QStringList>

#include <qhttpserver.h>
#include <qhttprequest.h>
#include <qhttpresponse.h>

Greeting::Greeting()
{
QHttpServer *server = new QHttpServer;
server->listen(QHostAddress::Any, 5000);
connect(server, SIGNAL(newRequest(QHttpRequest*, QHttpResponse*)),
this, SLOT(handle(QHttpRequest*, QHttpResponse*)));
}

void Greeting::handle(QHttpRequest *req, QHttpResponse *resp)
{
QRegExp exp("^/user/([a-z]+)$");
if( exp.indexIn(req->path()) != -1 )
{
resp->setHeader("Content-Type", "text/html");
resp->writeHead(200);
QString name = exp.capturedTexts()[1];

QString reply = tr("<html><head><title>Greeting App</title></head><body><h1>Hello %1!</h1></body></html>");
resp->end(reply.arg(name).toAscii());
}
else
{
resp->writeHead(403);
resp->end("You aren't allowed here!");
}
}

int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);

Greeting hello;

app.exec();
}


Awesome isn’t it? You launch an instance of QHttpServer, it emits a signal whenever a new request comes in, you can handle and respond to it. The code is fully documented, so you can do a git clone and run doxygen in the docs/ folder to get API documentation. For now it doesn’t deal with everything that can happen in HTTP, but it does know about keep-alives (no chunked encoding though). QHttpServer is streaming, see the body data example.



Here is a simple ApacheBench run comparing qhttpserver and node.



QHttpServer Greeting app:



> ab -n 1000 -c 100 http://localhost:5000/user/nikhil
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)


Server Software:
Server Hostname: localhost
Server Port: 5000

Document Path: /user/nikhil
Document Length: 88 bytes

Concurrency Level: 100
Time taken for tests: 0.467 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 151000 bytes
HTML transferred: 88000 bytes
Requests per second: 2142.47 [#/sec] (mean)
Time per request: 46.675 [ms] (mean)
Time per request: 0.467 [ms] (mean, across all concurrent requests)
Transfer rate: 315.93 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 4.7 0 23
Processing: 14 43 18.9 40 123
Waiting: 13 43 18.9 40 123
Total: 14 45 18.9 41 130

Percentage of the requests served within a certain time (ms)
50% 41
66% 48
75% 53
80% 58
90% 69
95% 80
98% 98
99% 117
100% 130 (longest request)


node.js greeting app:



> ab -n 1000 -c 100 http://localhost:5000/user/nikhil
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)


Server Software:
Server Hostname: localhost
Server Port: 5000

Document Path: /user/nikhil
Document Length: 88 bytes

Concurrency Level: 100
Time taken for tests: 0.441 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 151000 bytes
HTML transferred: 88000 bytes
Requests per second: 2267.94 [#/sec] (mean)
Time per request: 44.093 [ms] (mean)
Time per request: 0.441 [ms] (mean, across all concurrent requests)
Transfer rate: 334.43 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 4.4 0 18
Processing: 4 40 22.7 37 101
Waiting: 4 40 22.9 37 101
Total: 4 42 21.7 39 101

Percentage of the requests served within a certain time (ms)
50% 39
66% 50
75% 57
80% 63
90% 73
95% 83
98% 91
99% 95
100% 101 (longest request)


While not a very scientific benchmark, this does show them pretty close. C++ is compiled, but I believe node has less ‘layers’ and a particularly efficient I/O infrastructure which allows it to be better even with an interpreted language.



I would really like to see this being used in Qt apps that need a web interface for remote control, or for simple delivery of files.



In addition, if you will be attending conf.kde.in in Bangalore, India on March 9th-13th, my talk on Qt Scripting will involve writing a thin JavaScript wrapper over this and doing some other cool stuff! So be there.

Wednesday, January 05, 2011

Spreading the KDE love in India

conf logo

The first ever KDE conference in India takes place this March. On March 9th, 2011, gearheads will descend to the RV College of Engineering for conf.kde.in. If you are interested in using or contributing to KDE, we look forward to meeting you there.

There have been KDE contributors in India since the late 90s, but in recent years we have reached a more sizeable number. Contributors usually hang out on #kde-in, the KDE India IRC channel. The idea for a pure KDE conference in India first emerged about 2 months ago, and we’ve been doing the behind-the-scenes work since then. Now it’s time to GO! So we have this superb website made by Sayak Banerjee, brilliant artwork by Eugene Trounev, and hosting on the excellent KDE infrastructure.

conf.kde.in will take place from 9th-11th March followed by a 2 day sprint/hackathon for existing contributors. conf.kde.in is a platform for Qt and KDE contributors and enthusiasts to meet up, share their knowledge, contribute, learn, play, have fun and create limitless possibilities. The primary objective is to have fun while learning something. We are especially looking forward to students and teachers, as they are the ones who benefit the most from KDE, but also have the most to give back to it, by contributing and promoting KDE throughout India. Registrations for the conference will begin soon. Meanwhile, the FAQ should answer most questions. If not, contact us.

There will of course be excellent talks by Qt and KDE contributors from around the world. If you would like to give a talk or conduct a workshop, the Call for Participation is now in progress. It will end on 22:00 IST 15th January, 2011.

For more updates, follow us on Twitter, Identi.ca, or Facebook.

Posted via email from nikhil's posterous

Wednesday, December 15, 2010

Introducing Mugshot

There is a certain fun in hacks, little projects you do on a whim and finish in a few days. And then you go and buy a domain for it and launch it. That's Mugshot.

Mugshot is a web service which offers face-detection. It uses the libface library which was implemented mainly as a Google Summer of Code project for KDE. So one day I was thinking that services like Facebook and Flickr allow you to upload images and then tag them. But why not let the faces be detected automatically. So I hacked out Mugshot. It doesn't wrap the entire libface api for node.js, but only one function to detect the faces. Further details can be found on the website, including the documentation.

At the moment libface can stumble on some faces, but when it works, the results can be quite interesting! That image is by Pierre Tourigny and is under the Creative Commons Share-alike Attribution license. Its used to avoid uploading any real faces.

Are there plans to add recognition support and other advanced services? I don't know, maybe if I have a whim. Meanwhile, go fork it.

Posted via email from nikhil's posterous

Sunday, October 17, 2010

UPnP MediaServer KIO Slave is OUT!

I’ve released the first version of the UPnP MediaServer KIO slave which allows KDE applications to seamlessly browse UPnP devices on the network, and access their files. An outcome of my Google Summer of Code, this is the first step towards getting UPnP Collection support into Amarok. For now, the slave is meant for application developers since dolphin & co. in KDE 4.5 do not directly know how to launch it.

The recommended way to detect UPnP devices and invoke the slave is with Cagibi. To browse the device, run konqueror with the URL “upnp-ms://” where UUID is something like

bf7eace9-e63f-4267-a871-7b572d750653

which has been retrieved from Cagibi

Full release announcement is at http://mail.kde.org/pipermail/kde-announce-apps/2010-October/004566.html

Download v0.8.0: http://download.kde.org/download.php?url=stable/kio-upnp-ms/0.8.0/src/kio-upnp-ms-0.8.0.tar.gz

I request early adopters and developers to test this out. Bugs and feedback is welcomed at nsm.nikhil@gmail.com.

Posted via email from nikhil's posterous

Wednesday, October 06, 2010

Hackfest 2010

The usual convention in open source is that new developers get into a project by themselves. They follow online documentation and get into IRC channels and find their way around by themselves. Its not often that we get the chance to meet new guys and teach them the ‘tricks of the trade’. But that is exactly what happened at Hackfest @ Shaastra 2010

Hackfest got together mentors from various projects to introduce students to contributing to open source projects. We had Yuvi Panda for GNOME, Pratul Kalia for Android, and also Minix, and the Linux Kernel, and me for KDE. We also had the t3rmin4t0r for an excellent talk about the state of the Web.

KDE had 8 students. On day 1 (30th September) the computer systems weren’t set up, so we covered basic signals and slots, and I discussed the KDE architecture and useful libraries and then walked them through some sample code. After that the students found a Junior Job each that they would like to fix.

On day 2 we got KDE trunk compiled successfully and wrote a basic Hello Qt Application, following which I walked through a simple tweet fetcher to explain configuration, and creating basic GUIs. By the end of day 2, Anirudh S had got a simple menu entry bug fixed. I also fixed this Okular wish live, starting from scratch to demonstrate how to approach a bug. I will reviewboard it soon.

On day 3, three of the participants fixed a kwin Junior Job and we tried to take a shot at adding something like a ‘tick mark’ to the Notes plasmoid, although that didn’t succeed completely. After that everybody was pretty tired and so we stopped coding and we the mentors shared some stories of how we got into open source and so on with the crowd, Pratul being particularly good at that sort of thing. With that the actual event was done, and since my flight had been advanced to 5:30 in the morning I left.

The customized Shaastra distro made for the event!

The entire event was excellent, with the Hackfest coords and volunteers Subhashini, Sarthak, Kashyap, Kirtika and others did a great job with making us feel comfortable. I’ve never had someone send a taxi to the airport for me before :)

Posted via email from nikhil's posterous

Saturday, August 21, 2010

Final Evaluations results processed for Amarok and KDE UPnP Integration

Hi Nikhil Marathe,

We have processed the evaluation for your project named Amarok and KDE UPnP Integration with KDE.

Congratulations, from our data it seems that you have successfully passed the Final Evaluations. Please contact your mentor to discuss >the results of your evaluation and to plan your goals and development plan for the rest of the program

Greetings, The Google Open Source Programs Team

Yay!

Posted via email from nikhil's posterous

Saturday, July 31, 2010

Whats up doc?

Pardon me for the excessively cliche title, I was short on time :P

Its been a week now since college began, and already I feel the
extreme busy-ness that occurs trying to squeeze every activity into 24
hours. The vacations were comparatively totally empty.

The UPnP collection support in Amarok is concluding pretty well. Today
I committed the fix that considerably shortens the amount of data
transfer required over the network for subsequent queries once the
local cache is relatively filled. With a relatively small share on
miniDLNA, I got near native performance, with the tracks being
populated as soon as I opened up a tree. The kioslave too has had some
additions that allow applications using it to bypass many of the
user-friendly features (required for browsing via Dolphin or
Konqueror) and get blazing fast results instead.

With another Amarok release coming up, I want to get some time to fix
bugs, but it has been hard to come by, even on a weekend.

My other pet KDE project has been Rekonq, more specifically Chrome
extension support. I can't remember the last time I blagged about it,
but just so it doesn't get buried as defunct project, let me give a
status update. Work is slow but not stalled. I have extension
installation working. I have figured out how to interface the C++ and
JS parts, although it is a bit hacky. The Chrome Tabs API is mostly
implemented, (localization and script injection and message passing
are not), including the captureVisibleTab() method. Now that I have
some experience, it should be much easier to implement the rest of the
APIs. I still have to figure out how to implement background pages
(most likely a WebTab not added to the UI), implement safe message
passing and so on. A nice UI to manage extensions would also be
required, and it would be great if others are interested in jumping in
to the project.
I would be glad to explain the architecture ( I have a IRC log lying
around, thanks to Rohan Garg :P )

I don't know about 1.0, but extension support will get there in the
end, so lets not remove my name from the Credits :)

Posted via email from nikhil's posterous

Saturday, July 17, 2010

UPnP Searching

I’ve been pretty quite about GSoC progress. But I had a great time at aKademy and forgot all about blog posts. So the current status is thus. If programming was just about getting things done, I am done! But its not, which means although everything I was supposed to do is done in a big picture way, the next few weeks will see bug fixes, optimization and ensuring that certain things can be done faster, more accurately or in a more user-friendly manner. I also have to port the code over to use Solid, now that fellow GSoCer Paulo Romulo has improved UPnP support in it.

Last time I gave a glimpse of the Browse based collection. UPnP MediaServers have two methods of accessing their content. Browse() is similar to going through your hard-disk directory by directory. As you can see, this can be quite inefficient for a Collection since it has to keep track of a large number of tracks. The other method is Search(), wherein users can query the MediaServer to give tracks/media matching certain criteria, such as belonging to a specific artist, or containing a certain pattern in the name. This is much more efficient because all the work is done by the server and we just need to handle the results.

That has been the crux of my work this past month. Due to the restricted format of the UPnP search standard, it required a bit of work to handle more complex queries. In addition, due to the way the Amarok Collection and QueryMaker code works, I have to always ask the server for tracks rather than telling it to return on Artists or Albums. It took quite a bit of experimenting to understand these two things. But two days ago the collection started working with actual searching for simple patterns.

Here is the Search based collection with no search.

Here it is with a search term.

I should point out that the code is intelligent. It will contact the server and ask it if it supports Searching, or only Browsing and use the appropriate collection.

Other than that there are several bug fixes in the slave and in Amarok and support for reference IDs to prevent duplicate items ( every FOSS software server I tried still doesn’t support refID properly though ).

By the way, I passed mid-term evaluations. Yay!

Posted via email from nikhil's posterous

Friday, July 09, 2010

Akademy Day 5/6

Day 5 of Akademy was spent hacking too. Then I had a great meal at Plevna), Tamperelainen, which was mashed potatoes + lingonberry jam + Tampere’s famous blood sausages. Well it lived up to its expectations, the sausages were definitely good, but different. It was kind of like sabudana vada.

Unfortunately Germany lost :( The final will still be a good watch though.

Once again, I would like to raise my fictional hat to COSS and all the volunteers for the excellent organisation of this year’s Akademy.

The day trip was spectacular.

We were treated to Finland’s natural beauty in abundance. Merunlahti Centre for Nature Tourism has this camp like area right next to lake Höytämöjärvi with canoeing, slacklining and other activities.

The first thing to do was to jump in the lake, which was pretty cold. I have never properly swum in fresh water before ( which says something about India’s screwed up Nature ) so it was great. And unlike the sea, a lake actually has a reachable ‘other side’. So I swam across and back about 150 m or so. Give a human a log in the water and he is transformed to a 5 year old. KDE developers spent half the time trying various things like standing on the log, getting everyone on without falling off and other stunts, which was really funny and great ‘community bonding’. Maybe day trips should be done at the beginning of Akademy :)

I tried my hand at a bit of darts, but I am bad at it. Archery was more my thing. Slacklining was not. Canoeing was great though. I got a feel of the boat immediately, although it was my first time ever, I think I’ll be trying it again when I get the opportunity.

The food was great too. We had bread and fruits and BBQed corn and potatoes, sausages we could cook ourselves over a fire and marshmallows!

Now a sauna isn’t really my thing, but they had a great sauna house and so I took a few spins. When in Finland, do what the Finnish do. Get out of the sauna and jump into the lake!

Tomorrow is the last day of Akademy, and I will miss this place and all the fascinating people. I wish I had a hackspace like Demola, fast internet, food, no disturbances. Kudos to the organizers again.

Posted via email from nikhil's posterous

Wednesday, July 07, 2010

Akademy Day 3/4

Akademy just keeps getting better and better, and this year's location
couldn't have been more perfect.

The Demola office, if it could be called that, is the perfect
hackspace. Lots of tables strewn over the place, no partitions, sofas
to relax on and even a retro arcade game!

Yesterday and today and the rest of the week will be hackdays and
BoFs, so there isn't really much to report.
But at the end of today I just took a random walk across Tampere, and
its a beautiful city as you can see.

Tomorrow I plan to take the free walking tour that takes place everyday in Tampere, any other KDE
hackers planning to go?

Posted via email from nikhil's posterous

Monday, July 05, 2010

Akademy Day 2

Today was the day of fluffy, hands down! Frederik Gladhorn gave a
super lightning talk introducing his quite serious pet project

Other than this I attended Lubos' performance talk, and Milian and
Aleix's great KDevelop feature promo. I mean if Ctrl+Space can give a
complete program, why am I even learning C++? :) In addition Casper
gave a very nice talk about getting KDE to work on windows, and hats
of to the KDE-Windows team for there efforts.

The show-stealer was of course Aaron Seigo's keynote, exhorting all of
us to strive for 'elegance' now that KDE has achieved a great
technical base. The simple brush paintings, which I assume are done
with Krita, complemented it perfectly. So here's to more elegant
software.

I spent the rest of the day tracking down a pretty annoying bug in the
UpnpSearchCollection and then find out that UPnP has no way to group
searches to clarify precedence. So I have to think about that
tomorrow. The thing with the first two days of Akademy has been that
by the time you settle in to do some coding, there is an interesting
talk :) So with that done, I am planning to get quite some work done,
not only with the GSoC but a few kwin and Amarok things too.

I will also attempt the Qt certification to see if I'm good enough.

The most important thing is that we had free icecream today, thanks to
the basyskom guys.

Unlike yesterday's party, today was a relaxed evening, with the TOAS
sauna running. I attempted it, but my body's capability to produce
sweat is very high and I had to get out in 5 minutes. I did some
random stuff, met some more people and figured out where the laundry
room is!

Posted via email from nikhil's posterous

Sunday, July 04, 2010

Akademy Day 1

Into the sea of existing akademy posts enters another one.

Technically its my second day in Finland. I arrived on the 2nd with Pradeepto from mumbai. We met seele and Justin at Schiphol itself, while blauzahl and Mek were on the same flight! If that wasn’t enough, the bus from Helsinki to Tampere found aseigo and Hans Chen on it too, making it the Akademy bus.

The Student House TOAS city is an awesome place to live in, with rooms just like in college, a bit better :)

The Finlayson area hack room was really cool too, and yesterday I spent a few hours there getting to know quite a few people, including Vishesh Handa. I also bought my KDE shirt. At 8:30, the sun was still high up in the sky, at 11, its like evening in Mumbai which was bizarre. Akarsh and Prakash also caught up after a delayed flight.

Today was even better. The keynote was pretty good, its great to see KDE going deeper into the mobile space. Meanwhile (Qt made sure to give us all a rubber duck)[http://developer.qt.nokia.com/duck].

I met a lot of people who have been mentors, helpers and friends over IRC – Martin Grasslin, Leo Franchi, Nikolaj Nielsen, Friedrich Kossebau, Martin Sandsmark, Lydia Pintscher and many many more, whom I have to talk too about various topics.

Thomas Thym’s talk about principles in open source communities was very interesting while both Nikolaj and Leo conveyed social music capabilities and Amarok’s role in it very well. During the few talks I didn’t attend, I tried to do a bit of work, but it was a little hard due to all the excitement :)

Now Martin had written a plugin for the match, but I couldn’t stand not watching it and missed his talk. I wasn’t alone. It was great fun to travel 9000 km to watch football with other KDE developers. And since KDE has a large number of Germans you can guess who was supported. Germany were amazing with a 4 goal trouncing of Argentina, and with this form they can easily win the Cup.

With all the talks out of the way, me, kstar and pinocchio went to the downstairs supermarket. I had a strawberry-pineapple bread and rajma-chawal for dinner :) followed by liquorice sticks.

The KDE Akademy party was at the Love Hotel on Hameenkatu and it was fun meeting a lot of people and talking non code stuff and enjoying the Spain-Paraguay match. But now I’m really tired and have to crash if I want to be attentive tomorrow, particularly with performance, UX and cloud talks.

Posted via email from nikhil's posterous

Saturday, June 19, 2010

Notification madness

Planet, my slave went awry :(
I terminated the processes, but is there a way to kill all the notifications at once.



Friday, June 11, 2010

GSoC Week 4: Experimenting with Collections

I didn't write a post last week, and it looks really bad in my form completion :) but I didn't have any user visible updates at all. This week is much better. First the visual then the text.



That's cover art fetched from the UPnP device when the Content Directory has it available!

Other updates include smoother full and incremental scanning of the Collection. This is one area which needs a lot more improvement. The kio slave is now threaded and continuously monitors the UPnP device for updates. This is used by the Collection to mirror the actual contents whenever possible. The slave is also now fully normally evented, without pesky internal event loops and blocking. I learned a lot about how signals and slots work in the mean time, and uniqueness and disconnections. Certain thread related things have been sorted so that the slave is much more bug free, although Bart Cerneels still made it crash :)

Now today I'm stopping work much earlier, because its time for the World Cup to begin, and I'm supporting Germany! I hope my excuse is good enough.

Oh, by the way:
Here's to meeting a lot of KDE devs soon...

Saturday, May 29, 2010

GSoC Week 2: Experimenting with Collections

Another week is already gone, and although it didn't see much progress feature wise, I've been working a lot on the project. Three days were spent on a nasty little hard to produce bug, one that would only occur 4 levels deep into the Content Directory, and not always in that case either. Finally with a lot of debug statements, many hours talking to Tuomo Penttinen of HUpnp we fixed a little bug in his library.

The reason the bug was present - MediaTomb was disconnecting my slave for connecting multiple times very very quickly. When it rejected the request, two slots were fired in the HUpnp code which caused multiple access's to certain data which should be modified only once... I'll spare the details.

Once that was fixed, I spent half a day getting the DLNA recommended meta-data being reported by the slave using custom UDSEntry fields. That was pretty easy.

That pretty much finishes the slave's Browse() API, since fetching file's is delegated to the HTTP slave. The next step is Search().

But I took a little break and started experimenting with Amarok's Collection code, which is HUMONGOUS and complicated. I still haven't figured it out completely. Like why Collection::queryMaker() has too return a new instance of a QueryMaker sub class everytime, or how the Capabilities system works, but I'll get there in the end. The result for today is manually inserting a track into the collection. Ah, I do like seeing progress:

Friday, May 21, 2010

GSoC Week 1: Kioslave is shaping up

(This post was published on Friday, but I put in a wrong tag and I didn't get aggregated, so, republished)

Although I've been hacking on my GSoC project for quite a while, doing little experiments and getting my mind around various factors involved, this week was my first official coding period, since that was what I had in my timeline.

The first piece to implement is the kioslave to browse UPnP MediaServers. This involves writing a parser for the DIDL-Lite XML format used to describe directory structures. The parser I developed this week can now parse containers and items and their titles and pass them on to the slave. Meta-data and extra tag handling isn't done yet, but I have time :) The slave scheme is upnp-ms and right now you have to pass the UUID. But once the network:// slave is modified, it should be seamless for normal users




Their are a few issues I have to take care of in the slave. UPnP identifies all objects merely by a numeric ID. Now it wouldn't be fun to have the user deal with IDs. So the kioslave uses names just like normal file browsing. This involves reconversion back to the ID whenever I have to talk to the server. If the user manually types a URL to jump to some other point, I have no information about the IDs leading up to that location. So I've to implement some resolving. This is what I did this week. It is still a bit buggy, but I haven't figured out if the bug is in my code or HUpnp ( most likely my code ).

Tuesday, April 27, 2010

Success! Google Summer Of Code

Well after all the micro-blogging at night and the IRC chat, and writing an exam, here is a really good post!

The proposal is Amarok and KDE UPnP Integration. I'll be working with mentor Bart Cerneels. This news was awesome! Last year I didn't get in for kwin-tiling, but I participated in Season of KDE and did a few other contributions all year and it paid off. This year I started of quite early and worked hard on the proposal. When the ideas list went up, Amarok UPnP integration seemed the most interesting to me. Since then I was in talks with Bart and started a discussion on the Amarok mailing list, that much to my surprise, was very responsive :-)

Now with the result out of the way, its time to start working as soon as my final exams get over this week. This will involve choosing a UPnP library and daemon for device discovery. The next step is to implement a KIO slave which can browse UPnP media servers like any other folder. The final thing will be to write an Amarok Collection which can index music on UPnP servers on the network. This involves filtering and sorting and also making the server play music when in the playlist :-), can't forget that. So its going to be a very eventful 3 months, with lots of commits, a T-shirt and lets not forget the money. Right now I'm waiting for the invitation to the private mailing list.

It was great to hear some stats. KDE got 50 slots, 11 Indians got into KDE, and 3 from DA-IICT got into KDE. Which is awesome! Sai Dinesh will be working on getting mobile phones working nicely with KDE. Aditya Bhatt will be working on Digikam face recognition. Others I know are Varrun Ramani, working on Amarok too, implementing Distributed Collections. Vishesh Handa will be working on Nepomuk, and finally the one and only :) Shantanu Tushar on Gluon. Happy hacking everyone...

Monday, April 26, 2010

KWin tiling is merged

I'm glad to announce that yesterday the kwin-tiling branch was merged into kwin trunk by commit 1118677!. It will be available in KDE SC 4.5. Please keep in mind that it is an experimental feature with rough edges. Bug fixes are already on the way, but some things, like session saving and so on are absent. Please do add feature requests and bugs to the KDE bug tracker.

This screencast should show off a few things. Apparently xvidcap produced really bad video, so I will have to do it again, watch out for updates here.

Thanks to Martin Graesslin for being my mentor during Season of KDE, and all the others who bugged me with emails about when tiling would be integrated into KWin :)

GSoC results now 13 hours away...

( Mamma, I'm not stressed out :-) )