Re: difference between "g_signal_emit and g_object_notify" and how to listen to these signals

On Fri, 2010-10-29 at 10:41 -0700, hong sheng wrote:
> Hi Jirka,
> Thank you very much. I got the signal in another program. there is
> g_signal_emit of signal called "signal-quality" in modemmanager, and
> this signal is received as SignalQuality in another program. However,
> I feel it is confusing to make the signal name different in the same
> program without any definition, except that in the creating of new 

The D-Bus interface is the only interface that ModemManager exports
externally, and that interface specifies SignalQuality as the signal
name.  It's an implementation detail internally that it's represented as

That D-Bus interface is specified here:

and if you're trying to talk to ModemManager via D-Bus, that's the only
API that you need to care about.

The reason for the difference is that GObject signals are traditionally
lower-case with words separated by dashes (-).  D-Bus signals have
traditionally been StudlyCaps.  Thus to allow GObject-based programs to
use their normal conventions, dbus-glib converts the signal names
internally so that GObject developers are not confused, *and* so that
D-Bus developers are not confused.

If you're adding new signals, you create the GObject signals as you
normally would in GObject programs, but you add the signal to the
introspection data in introspection/ using StudlyCaps, and dbus-glib
will handle everything seamlessly.


> signal for the object, mapping the order of signal array into the
> introspection of the xml signals. I think it's not robust and not very
> clear and may need further improvement.
> thanks a lot for many helps.
> Xiaohong
> On Fri, Oct 29, 2010 at 5:17 AM, Jirka Klimes <jklimes redhat com>
> wrote:
>         On Thursday 28 of October 2010 01:30:40 hong sheng wrote:
>         > Hi Daniel,
>         >
>         > Thank you very much. I have some more questions.
>         >
>         > If I used g_signal_connect at the same program for
>         g_signal_emit, for
>         > example, in modemmanager, I can receive that signal because
>         I know the
>         > right object for the signal to connect.
>         >
>         > However, in a different program, how can I get the right
>         GObject to connect
>         > the signal?
>         >
>         You can't use pure Glib signals as inter-process communication
>         (IPC). They are
>         limited for one process only. For communication between two
>         processes you need
>         some IPC means, like D-Bus.
>         Nevertheless, D-Bus signals can be used to "extend" glib
>         signals. Thus
>         g_signal_emit() will in turn issue "SignalQuality" signal on
>         D-Bus. And this
>         signal is received by the other process and converted to
>         "local" glib signal.
>         >
>         > For example, in the open source modemmanager, there is a
>         function called "
>         > g_signal_emit (self, signals[SIGNAL_QUALITY], 0, quality)",
>         where object:
>         > self is a modemclass.  If I write my own applet, how can I
>         set
>         > "g_signal_connect" with right Object of Modem? I mean how
>         can I get the
>         > right object pointer of Modem for the signal to be
>         connected?
>         >
>         > In addition, I found in the openSource applet, there is a
>         function to
>         > connect signal"SignalQuality" as follows:
>         >
>         >         dbus_g_proxy_add_signal (info->cdma_proxy,
>         "SignalQuality",
>         >         dbus_g_proxy_connect_signal (info->cdma_proxy,
>         "SignalQuality",
>         >                                      G_CALLBACK
>         > (signal_quality_changed_cb), info, NULL);
>         >
>         > But I didn't find a place to emit this
>         signal("SignalQuality") either in
>         > modemmanager or in the networkmanager. Something missed in
>         modemmanager or
>         > networkmanager?
>         >
>         This is the client part of the whole picture.
>          dbus_g_proxy_add_signal()
>         specify the signal we are interested in and
>         dbus_g_proxy_connect_signal()
>         install the handlers that will be called upon signal
>         reception. So, when
>         ModemManager emits SIGNAL_QUALITY, "SignalQuality" D-Bus
>         signal is emitted (in
>         addition to local glib signal). The D-Bus signal is received
>         by the applet and
>         via dbus-glib converted to local glib signal. This causes
>         signal_quality_changed_cb() handler to be called.
>         proxy-add-signal
>         Jirka
> _______________________________________________
> networkmanager-list mailing list
> networkmanager-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]