Facebook support in KDEPIM

27 02 2011

I am at the  annual KDEPIM meeting in Osnabrück for the weekend. It is awesome meeting old friends again and seeing new faces as well. Even better is that it is a welcome break from writing my thesis which is due next week, one weekend of hacking in discussing without worries.

I took the opportunity to hack on Facebook support for KDEPIM. The result is an Akonadi resource that provides access to your Facebook friends and events.
Screenshots say more than thousand words, so below are two screenshots, showing my Facebook friends in KAddressbook and showing my Facebook events in KOrganizer. Notice how birthdays from Facebook are automatically integrated (although birthdays without the year display the wrong age at the moment).
Sorry for the ugly widget style in the screenshots, for some reason the Oxygen style doesn’t work for me.

Facebook in KAddressbook

Facebook in KAddressbook

Facebook in KOrganizer

Facebook in KOrganizer

That is not all! Since events also show in the Plasma clock calendar, the events from Facebook are automatically shown there as well. The Kontact summary will of course show upcoming birthdays and events from Facebook. The data is also cached when you are offline, thanks to the Akonadi framework. Much more is planned for the future:

  • Show the Facebook news feed in the Kontact summary and in a plasma widget
  • Show Facebook notes in KJots
  • Support for Facebook messages, either in KMail or in a custom Kontact plugin
  • Support for creating and editing events

The Facebook resource is still very young, thus there is no official release yet. Work is underway for a 0.1 release, just a bit of polishing is needed.
Please try out the resource for yourself and help with testing. Since it is a developer preview, you need to build the resource from source code. Do the following:

  1. Make sure to have an up-to-date kdepimlibs from Git master, the resource needs new API that was added this weekend
  2. Get the source code with git clone git://anongit.kde.org/akonadi-facebook
  3. Build and install
  4. Open KAddressbook and chose File->New->Add Address Book.
    1. Select Facebook. A settings dialog will open.
    2. In the settings dialog, click the Authenticate button
    3. A webpage will open and ask you to give the KDE Connector access to the Facebook data. Confirm that. You may need to login to Facebook first.
    4. Close the settings dialog. The address book and calendar should automatically synchronize with Facebook. If not, you can always do that manually by  right-clicking on the Facebook address book or calendar folder.
  5. Enjoy!

Please contact me in case you have any problems or feedback. Bugs are best reported on the KDE bugtracker, there is a Facebook component for the Akonadi product.

For version 0.1, I plan to move the repository to projects.kde.org and add support for translations. More importantly, 0.1 will be the first real release, which will hopefully be picked up by packagers, so stay tuned!

Oh, and since we’re talking about Facebook, there is also a page for the Akonadi resource here, click the Like button if you like it 🙂

Writing the resource was easy and lots of fun, and hopefully many of you will find it useful. I am certainly looking forward adding more cool features to it.

Update: The Facebook resource should now compile against KDE SC 4.6.0. Please comment or file a bug report if you still have a problem compiling.

Update: Some people report having trouble authenticating with Facebook, sometimes the links in the embedded web view don’t seem to work. I would appreciate help from a KDE webkit developer here. To workaround that problem, first log in to Facebook with Konqueror. You may also need to grab the authentication URL from the debug output of the resource and view that URL in Konqueror, you should see something like “https://graph.facebook.com/oauth/authorize?…” in the debug output. Update: The bug in the authentication was caused by a bug in kdelibs master, which has already been fixed.



56 responses

27 02 2011

very nice!
it will included in 4.7?

27 02 2011
Thomas McGuire

The plan right now is to release it as an extragear application, which means it would be available way before 4.7.
The advantage of that is that we are not tied to the KDE release cycle and can react to changes of the Facebook API faster.

27 02 2011

The possibility to break Facebook into pieces and then integrate it to the desktop is quite awesome – the site being as horrible as it is. Now that there’s IM clients that support the chat, possibly Choqok support in the future, FaceBook Kipi-plugin and akonadi resources… nice.

It would also be great to have somesort of overview page which would brings all the information on any of the known kontacst you have – possibly using the Nepomuk persons ontology like Facebook News feed and chat history but why not information from other services that that persons might have, like Gmail.

27 02 2011
Thomas McGuire

The idea of having an overview page showing information about a person like emails, tweets, blog entries, chat history, Facebook updates and messages and heck, maybe even KDE commits, is indeed awesome.
In fact we talked about this today during the PIM meeting. We will put this up as a Google summer of code idea. It is not an easy task, but a motivated student could surely pull it off. It would be a great addition to Kontact (or a great Plasma widget).

27 02 2011

Great!, I was really waiting for this feature specially because of birthday events.
Facebook Akonadi resource will be of my favorites as the Google Akonadi resource.

Now the only pending are Google bookmarks and Google docs Akonadi resource and I will be complete.

Thank you very much for this work, you are making my life easier in KDE!

27 02 2011

Seriously, I don’t get it. Why would you do such a thing ? Why give freedom and internet away to giant corporations ? Especially at times where there’s an effort building towards getting rid of centralized crap and taking control back of our personal data by removing it from the surveillance network internet has become. Why this particular cia funded/backed up website and not one of the several decentralized opensource alternatives such as movim [1] ?

You might want to read these: http://lwn.net/Articles/426763/ http://www.nytimes.com/2011/02/16/nyregion/16about.html?_r=1

[1]: http://www.movim.eu/

27 02 2011
Thomas McGuire

I am well aware of the privacy risks, and for example I avoid Google calendar and Google contacts. Yet I use Facebook, even though the privacy concerns there are much bigger. The value Facebook gives me is simply way greater than the privacy risk. I am living abroad in Edinburgh right now, and _all_ of my international friends are using Facebook there. It is a great way to keep in touch, and especially it is the best tool for inviting people to parties or other events, other tools come nowhere near the convenience.

The amount of people using a social networking platform is also crucial, I need something my friends use as well. I really hope movim will gain momentum, I would definitely switch to a decentralized platform once enough others are using it (yes, chicken and egg problem, but I’m using this for real life and don’t want that to be overtaken by idealism).

27 02 2011

@onan: Because people are actually using Facebook. Why tell a user what social network he should be using?
KDE won’t be getting nowhere if it doesn’t add features people need just because those features might not be completely open (as in open source) or closed (as in privacy).
A user should know himself what services he/she uses, who are you (as a developer) to deny that?

8 03 2011
Alejandro Nova

You forgot the most important reason for this, and that reason has a lot to do with what Onan said. You don’t have an easy way to retrieve all of your Facebook information, and the page where you can download it is only available if you set your interface to English (what a bummer!)

With Akonadi, you can retrieve and backup your Facebook info, and become less and less dependent on Facebook, if you want to leave it.

27 02 2011

> taking control back of our personal data by removing it from the surveillance
> network internet has become

Facebook has 500 million users, do you think there’s some organization that gives a rats ass about your wedding photos and your movie preferences?

28 02 2011

I use facebook myself, but I’d like to answer something to this. While you’re trying to ridicule the OP’s opinion, you’re actually proving that you don’t understand the interest companies have in such data bases. Indeed, they most probably won’t be interested in your single movie preferences, but I’m absolutely sure Time Warner is interested in the consolidated movie preferences of all Facebook users, ordered and grouped by any arbitrary private information they want, e.g. by age, by profession, by educational background, etc. pp. The same is true for every other information or action you’re entering or doing at facebook.

28 02 2011


28 02 2011

I’m really looking forward to KDE PIM 4.6! This is a great addition. 🙂

28 02 2011
Ed Daniel

While I’m no fan of facebook nor use their service the work carried out here, i.e. to work with 3rd party external APIs and integrate their services into KDEPIM, is a great contribution that many others will be able to learn from and follow in order to use as templates for integration with many other similar services.

With that thought in mind I do hope that you approach the challenge with abstract classes as often as possible so as to make this easier for other 3rd party API integration efforts – a plugin framework that allows one to use multiple services, not just Facebook, would be fantastic.

That said, well done for all the hard work you’re putting into KDEPIM – it’s a cornerstone of productivity for many KDE users and one of my most used software tools – it’s an evolution many of us are very excited about.

28 02 2011

Awesome! Creating a akonadi-facebook-resource was on my todo list! However now I’ll just hack on your version I guess 🙂

28 02 2011

Do you plan to also use FQL to also query users e-mail addresses etc? So the contacts will be much more complete (and usefull)…

28 02 2011
Thomas McGuire

Hey, glad you want to join the team 🙂
Please come to IRC so we can chat, I am usually in the #kontact and #akonadi channels. This week I’ll probably not available as I’ll finish my master thesis and then move to a new flat, starting with next Monday I’ll have lots of time.

Regarding FQL and email addresses: I though it isn’t possible to get the email addresses and phone numbers out of FB because of privacy concerns, not because of the choice of API (Graph API vs FQL). Is it actually possible to get the real (not the proxy one) email address out of Facebook with FQL? If so, how?

19 06 2011

i think you need to request more permissions for the Application (http://developers.facebook.com/docs/authentication/permissions/) so the Friends are returned with additional properies (friends_about_me e.g) , my htc sense requires a lot of those friends_* permissions

1 03 2011
Petr Zmek

Hi Thomas,

I try to build this akonadi resource, but following errors appear. I donẗ know how to eliminate them, I’m new in compiling, may you help me or tell me where I can find relevant information?

I compile fith prefixes:
[petr@petr-ntb build]$ cmake -DCMAKE_INSTALL_PREFIX=`kde4-config –prefix` ..

and after running make command these errors appear:
[ 96%] Building CXX object resource/CMakeFiles/akonadi_facebook_resource.dir/settingsbase.o
[100%] Building CXX object resource/CMakeFiles/akonadi_facebook_resource.dir/settingsadaptor.o
Linking CXX executable akonadi_facebook_resource
/usr/bin/ld: CMakeFiles/akonadi_facebook_resource.dir/facebookresource.o: undefined reference to symbol ‘KABC::Addressee::Addressee(KABC::Addressee const&)’
/usr/bin/ld: note: ‘KABC::Addressee::Addressee(KABC::Addressee const&)’ is defined in DSO /usr/lib64/libkabc.so.4 so try adding it to the linker command line
/usr/lib64/libkabc.so.4: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[2]: *** [resource/akonadi_facebook_resource] Error 1
make[1]: *** [resource/CMakeFiles/akonadi_facebook_resource.dir/all] Error 2
make: *** [all] Error 2

I use Fedora 14 x86_64, KDE 4.6 and KDEPIM 4.6 beta4 installed from kde-redhat testing or unstable repos.

May you help me please? Because this thing looks awesome and very useful!
Many thanks,

1 03 2011
Thomas McGuire

Hi Petr,

thanks for testing the compilation. For someone new to that, you managed quite well so far 🙂
I think you found a problem in the Facebook resource and Fedora’s recent changes to DSO linking[1], I’ve just pushed a potential fix[2]. Please do a “git pull –rebase” in the source directory, which should fetch the update I pushed. Then try to rebuild.

[1] https://fedoraproject.org/wiki/UnderstandingDSOLinkChange
[2] http://quickgit.kde.org/?p=scratch%2Ftmcguire%2Fkfacebook.git&a=commit&h=48b7a64310c53c0b3565abc4f3e4838d1c7808a5

1 03 2011
Petr Zmek

Woow, great, it works and it’s awesome! Thanks for plugin and of course for your help. I’m looking forward new features 🙂

20 12 2011
Sean Miller

Well I’m not exactly sure how to compile this using cmake. I haven’t used cmake before. I’m on Ubuntu 11.10 Oneiric Ocelot x86. I’d appreciate help greatly. Thank you.

27 12 2011
Thomas McGuire

Basically you get the sources, and then run:

cmake -DCMAKE_INSTALL_PREFIX=`kde4-config–prefix`
make install

You need to have cmake, gcc, make etc and the kdelibs and kdepimlibs development packages installed.

1 03 2011

I get a crash every time it tries to sync.

Application: Akonadi Resource (akonadi_facebook_resource), signal: Aborted
[Current thread is 1 (Thread 0x7f1423349760 (LWP 20990))]

Thread 2 (Thread 0x7f140ee83700 (LWP 20996)):
#0 0x00007f142219c6f9 in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00007f14224270b2 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib64/libQtCore.so.4
#2 0x00007f142241ceb8 in ?? () from /usr/lib64/libQtCore.so.4
#3 0x00007f1422426a5e in ?? () from /usr/lib64/libQtCore.so.4
#4 0x00007f1422197a3f in start_thread () from /lib64/libpthread.so.0
#5 0x00007f141f6f067d in clone () from /lib64/libc.so.6
#6 0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7f1423349760 (LWP 20990)):
[KCrash Handler]
#6 0x00007f141f64fab5 in raise () from /lib64/libc.so.6
#7 0x00007f141f650fb6 in abort () from /lib64/libc.so.6
#8 0x00007f141feb5a9d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib64/libstdc++.so.6
#9 0x00007f141feb3cb6 in ?? () from /usr/lib64/libstdc++.so.6
#10 0x00007f141feb3ce3 in std::terminate() () from /usr/lib64/libstdc++.so.6
#11 0x00007f141feb3e36 in __cxa_rethrow () from /usr/lib64/libstdc++.so.6
#12 0x00007f142250f333 in QEventLoop::exec(QFlags) () from /usr/lib64/libQtCore.so.4
#13 0x00007f14225136ab in QCoreApplication::exec() () from /usr/lib64/libQtCore.so.4
#14 0x00007f1422e186e2 in Akonadi::ResourceBase::init(Akonadi::ResourceBase*) () from /usr/lib64/libakonadi-kde.so.4
#15 0x000000000040c4c8 in init (argc=, argv=) at /usr/include/KDE/Akonadi/../../akonadi/resourcebase.h:188
#16 main (argc=, argv=) at /home/alex/devel/kfacebook/resource/facebookresource.cpp:430

1 03 2011

Okay it seems syncing Friends works, but as soon as I try syncing the Events it crashes

1 03 2011
Thomas McGuire

Hey Alex,

thanks for testing. The discussion about the crash will get longer, so please open a ticket on bugs.kde.org for this, product “Akonadi” and component “Facebook Resource”.

It seems you get an exception while syncing the events folder, unfortunately standard backtraces are of no use in case of exceptions.

First thing to try is to get a better backtrace.
1. Attach GDB to the running process of the Facebook resource with “gdb –pid `pidof akonadi_facebook_resource`” (without the quotes, but with the backticks). GDB will attach to the process, it will take some moments to load all symbols.
2. Type “catch throw” to instruct GDB to break when an exception is thrown
3. Type “continue” to continue execution of the Facebook process
4. Sync your calendar folder in KOrganizer or in Akonadiconsole.
5. Now the Facebook resource should crash, you should see a message about that in GDB
6. Type “bt” to get a backtrace. Paste that backtrace into a new bug report on bugs.kde.org
7. Also leave a short notice about the bug report number here, so that I don’t miss it.

Many thanks!

1 03 2011

Bug ID is 267396

4 03 2011
Linux Dave

I got it compiled and installed, but the resources don’t show up as choices in the add dialogs for akonadi. Do I need to do something more than make install?

7 03 2011
Thomas McGuire

Normally just doing a “make install” should be enough.
Might be a path problem, try setting environment variable XDG_BASE_DIR as described in http://forum.kde.org/viewtopic.php?f=20&t=85072

28 09 2011
Kenny Fairweather

I had the same issue. I worked around it by adding a link:

ln -s /usr/local/share/akonadi/agents/facebookresource.desktop /usr/share/akonadi/agents/facebookresource.desktop

I’m on Kubuntu Natty with backports for kde4.7.1

12 03 2011

hi I have this output
— Found KDE 4.6 library dir: /usr/lib
— Found the KDE4 kconfig_compiler preprocessor: /usr/bin/kconfig_compiler
— Found automoc4: /usr/bin/automoc4
CMake Error at resource/CMakeLists.txt:34 (kcfg_generate_dbus_interface):
Unknown CMake command “kcfg_generate_dbus_interface”.

14 03 2011
Thomas McGuire

Maybe you don’t have “xsltproc” installed? Although the build system should check for that.
When you first run CMake, it presents you a list of dependencies that were found, like “The following external packages were located on your system.”. Is xsltproc in there for you?

28 09 2011
Kenny Fairweather

Thanks for that tip Thomas – that solved above issue for me, and cheers for the Facebook resource 😀

1 07 2013

Thanks as well. The message itself wouldn’t lead me to the solution.

17 03 2011
KDE一周提交摘要(2011/3/13) | I, KDE

[…] Akonadi-Facebook:https://thomasmcguire.wordpress.com/2011/02/27/facebook-support-in-kdepim/ This entry was posted in 技术. Bookmark the permalink. ← Kubuntu 的 kde-snapshot 源又回地球了 […]

6 04 2011

Um, you say to build and install, but I have very little experience compiling things that don’t come with precise instructions, so how do I build and install it? It downloaded from git ok…

6 04 2011
Thomas McGuire

Hi Jane,

In general this is a developer preview for now, if you don’t know how to build it is probably best to wait for the first official release, for which packages will be available.
I couldn’t find good instructions on how to build KDE software from source, the best is probably http://techbase.kde.org/Getting_Started/Build, although that mainly talks about building all of KDE from source, which is not needed in this case. Unfortunately the link to the page “Build KDE Applications” doesn’t exist there.

4 06 2011

Ah, ok thanks. 🙂

6 04 2011

Could you update us on the status of KDEPIM in general? The lack of communication is frustrating a lot of users. Every once in a while we see a proposed release date (e.g. your first link says “Final release in about a month (4.6.2, April 5th)”), but then the date passes without release or comment. I know that releasing it prematurely will be bad, but we users could really use some news.

6 04 2011
Thomas McGuire

There isn’t much news on the KDEPIM front in general, as there wasn’t much development going on, which is also why the release date slipped, simply not enough people fixing bugs. So we can’t give a release date for sure.
See also http://dot.kde.org/2011/03/15/9th-annual-pim-meeting-renews-commitment-innovation, in the “Releasing” section (though that might be optimistic)

6 04 2011
Alejandro Nova

1. I second that. I want information about progresses with KDE-PIM, and I am also frustrated about the lack of a release. I am using KDE-PIM/Akonadi git, and there has been really a solid bug squashing. Except for the migration bugs, this KDE-PIM is really release-ready, and if you can’t get out a release candidate with the migration bugs fixed, please, at least give us another beta with KDE-PIM in its current status.

I’d also like to point out that KDE-PIM git requires libstreams and libstreamanalyzer from git, so, if you can rush a new release for those packages (part of Strigi) it would be great.

2. Akonadi Facebook compilation fails with this, under Fedora 15.

In file included from /usr/include/kde4/akonadi/collection.h:25:0,
from /usr/include/kde4/KDE/Akonadi/../../akonadi/resourcebase.h:29,
from /usr/include/kde4/KDE/Akonadi/ResourceBase:1,
from /root/buildtrees/akonadi-facebook/resource/facebookresource.h:24,
from /root/buildtrees/akonadi-facebook/resource/facebookresource_friends.cpp:20:
/usr/include/kde4/akonadi/entity.h: In member function ‘bool Akonadi::Entity::hasAttribute() const [with T = TimeStampAttribute]’:
/root/buildtrees/akonadi-facebook/resource/facebookresource_friends.cpp:50:50: instantiated from here
/usr/include/kde4/akonadi/entity.h:256:15: error: uninitialized const ‘dummy’ [-fpermissive]
/root/buildtrees/akonadi-facebook/resource/timestampattribute.h:25:7: note: ‘const class TimeStampAttribute’ has no user-provided default constructor
/usr/include/kde4/akonadi/entity.h: In member function ‘T* Akonadi::Entity::attribute() const [with T = TimeStampAttribute]’:
/root/buildtrees/akonadi-facebook/resource/facebookresource_friends.cpp:51:86: instantiated from here
/usr/include/kde4/akonadi/entity.h:230:15: error: uninitialized const ‘dummy’ [-fpermissive]
/root/buildtrees/akonadi-facebook/resource/timestampattribute.h:25:7: note: ‘const class TimeStampAttribute’ has no user-provided default constructor
make[2]: *** [resource/CMakeFiles/akonadi_facebook_resource.dir/facebookresource_friends.o] Error 1
make[2]: *** Waiting for unfinished jobs….
make[1]: *** [resource/CMakeFiles/akonadi_facebook_resource.dir/all] Error 2
make: *** [all] Error 2

6 04 2011
Thomas McGuire

The compile error might be fixed now, please try again.
See http://commits.kde.org/akonadi-facebook/e601506ea2afac830cdd852b2342f8f240fb8a26

7 04 2011
Alejandro Nova

Great work, Thomas, it compiles and works.

However, I have some bad news for you: you have uncovered some bugs in KMail/Akonadi with your awesome work.

– KMail/Akonadi tries to browse the birthdays of my Facebook contacts, as if they were tagged e-mails. It fails spectacularly, with a 100% CPU usage loop.
– While the Akonadi-Facebook connector syncs flawlessly, it makes Kontact crash in the process.

7 04 2011
Thomas McGuire

Could you please file bug reports for both issues, and leave the bug report numbers as a comment here so I can have a look?
Especially the first issue I have no idea what you are talking about 🙂
And for the second issue a backtrace would help.

8 04 2011
Alejandro Nova

Couldn’t reproduce the crash, so no bug report on that :(.

About the “folder issue”, here is my report:

30 04 2011

Wow, just discovered that… that’s pretty cool!!

However, some of my friends just posted their date (ie. day and month) as their birthday and not the year. So KAdressbook tells me, they are “2011 years old”… pretty old, isn’t it? 😉

2 05 2011
Thomas McGuire

Yeah, I know about that, KDE doesn’t have support for birthdays with undefined years yet. See https://bugs.kde.org/show_bug.cgi?id=190782.

24 05 2011

Thanks, this is great addition to my already amazing kde desktop enviroment.

25 05 2011

strange thing.
on one F14 installation I got it to work and I get all my facebook contacts.

on another I don’t, i am waiting for few hours now and no sync… any idea?

25 05 2011

I think the problem is with the notes.
it shows in the progress percentages of millions…

31 05 2011
Thomas McGuire

Hi yehiel, could you please report a bug for this on bugs.kde.org? My guess is that the synchronization of notes gets stuck, and therefore the sync of contacts never starts.
If you start Akonadi from console (akonadictl stop; wait a bit; akonadictl start; kontact), then you should see output from the facebook resource there, that would be helpful in the bug report.

31 05 2011

I followed the steps you provided, stopping and starting akonadi from console. but I can not see anything related to facebook in the output…


4 06 2011
Google support in Akonadi, post 1 | progdan.cz

[…] fetching of contacts photos. I have to mention here, that the code is inspired by code of the great Akonadi Facebook Resource, because this is my first Akonadi-related code and I really need something to learn from […]

30 06 2011
Fabio Andres Correa Duran

Hello, thanks for writing this plugin, it’s fantastic!

14 05 2012
Agostini Sylvain

Thanks for this plugin. I installed it and it is working well (version from AUR on archlinux as of 2012/05/14).
I just saw that it is synchronising the facebook notes. I have been looking for a way to synchronize my kjots notes across different computer and it may be a solution. The only thing is that we need to be able to set privacy on the notes created. Is it possible ? Is it a planned features? It may be good if we could set a default policy in the akonadi ressources settings.

23 05 2012

niiice job!
but, why doesn’t sync with facebook ? e.g., when installed, has 126 friends and 3 events. Now with 156 friends and 2 new events, kontact has just old 126 friends and 3 old events. Why don’t implement a way to syncronize, say, once per week or day or when connected??

%d bloggers like this: