After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 608086 - wrong return value of notify_init()
wrong return value of notify_init()
Status: RESOLVED FIXED
Product: libnotify
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: William Jon McCann
Depends on:
Blocks:
 
 
Reported: 2010-01-25 21:19 UTC by William Jon McCann
Modified: 2010-06-26 23:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch notify_init (553 bytes, patch)
2010-01-25 21:19 UTC, William Jon McCann
none Details | Review

Description William Jon McCann 2010-01-25 21:19:20 UTC
Created attachment 152261 [details] [review]
patch notify_init

from http://trac.galago-project.org/ticket/184

"/usr/include/libnotify/notify.h says:

<-- snip -->

...

    * @return TRUE if the library initialized properly and a connection to a
    * notification server was made. 

    */ gboolean notify_init(const char *app_name); ...

<-- snip -->

Different from the documentation, notify_init() returns TRUE when no notification server is available at all (which also implies that no connection could be made to a notification server).

In Liferea 1.5.12 we have the problem that due to this bug notify_get_server_caps() generates "libnotify-Message: GetCapabilities call failed: The name org.freedesktop.Notifications was not provided by any .service files" messages.

03/06/09 14:08:58: Modified by Adrian Bunk

My patch does not fully address the problem (it does not try to make a connection), but it checks whether a notification server is available at all, and returns FALSE if there isn't one (this would at least be enough for Liferea).

Someone who knows all the notification stuff can most likely make a better patch.

03/08/09 04:03:18: Modified by Adrian Bunk

    * attachment patch-notify_init added.

03/08/09 04:09:09: Modified by Adrian Bunk

This new patch might be the correct solution:

Make a GetCapabilities? at the end of notify_init(), and if it fails call notify_uninit() and return FALSE.

Note that we must not print any message here, since depending on the caller a failed notify_init() could either be fatal or no big problem. The latter is e.g. true for Liferea, where it is optional functionality, and it's perfectly fine for a user to install a distribution package of Liferea with libnotify support without having a notification-daemon running.
03/08/09 04:38:50: Modified by Adrian Bunk

    * patch_included set to 1.
"
Comment 1 William Jon McCann 2010-06-23 23:55:40 UTC
Don't think it is a good idea to make a synchronous dbus call in notify_init().  Also, the fix for bug 610880 means this bug shouldn't be fixed.

I've changed the comment in the header file instead.

commit 560aaaadd1583c1c421553b56f31e677e118f7a2
Author: William Jon McCann <jmccann@redhat.com>
Date:   Wed Jun 23 19:55:09 2010 -0400

    Don't claim that notify_init connects to the server
    
    https://bugzilla.gnome.org/show_bug.cgi?id=608086
Comment 2 Adrian Bunk 2010-06-24 04:45:42 UTC
This does not address my actual problem.

How can I check at the libnotify API level if a notification server is running?
Comment 3 William Jon McCann 2010-06-24 04:51:37 UTC
I'm not sure what you are trying to do.  But perhaps using notify_get_server_caps (void); to make a round trip to the server?
Comment 4 Adrian Bunk 2010-06-24 05:09:36 UTC
(In reply to comment #3)
> I'm not sure what you are trying to do.

I said in my bug report:

In Liferea 1.5.12 we have the problem that due to this bug
notify_get_server_caps() generates "libnotify-Message: GetCapabilities call
failed: The name org.freedesktop.Notifications was not provided by any .service
files" messages.

> But perhaps using
> notify_get_server_caps (void); to make a round trip to the server?

That runs into exactly the message I want to avoid...
Comment 5 William Jon McCann 2010-06-24 05:22:31 UTC
Besides the warning message what is the issue?  That is the message I'd expect to see when you don't have a daemon that is configured to activate on demand for that D-Bus interface.
Comment 6 Adrian Bunk 2010-06-24 05:57:18 UTC
(In reply to comment #5)
> Besides the warning message what is the issue?  That is the message I'd expect
> to see when you don't have a daemon that is configured to activate on demand
> for that D-Bus interface.

The warning message is the issue.

Distributions compile liferea with libnotify support enabled.

The user might or might not have a notification server installed. Not having a notification server installed is a perfectly fine situation in this case, and printing a scary warning message for a perfectly fine situation isn't right.

Whether a missing notification server is a problem or perfectly fine is nothing that can be decided inside libnotify.

I'm not insisting on the solution from my patch, but I really want some way to check for the presence of a notification server without getting any warning message printed, and without manually doing dbus calls.
Comment 7 William Jon McCann 2010-06-24 06:01:21 UTC
Oh so you just want to patch out the g_message?  That's fine.
Comment 8 William Jon McCann 2010-06-26 23:33:46 UTC
Removed in master.