Re: Question in function nm_device_state_changed()
- From: Dan Williams <dcbw redhat com>
- To: 代尔欣 <daierxin gmail com>
- Cc: networkmanager-list gnome org
- Subject: Re: Question in function nm_device_state_changed()
- Date: Tue, 12 May 2009 12:10:00 -0400
On Tue, 2009-05-12 at 22:17 +0800, 代尔欣 wrote:
> From my understanding:
>
> nm-client.c
> nm_client_deactivate_connection()
>
> then through dbus, call:
> impl_manager_deactivate_connection (NMManager *manager,
> const char *connection_path,
> GError **error)
> {
> return nm_manager_deactivate_connection (manager,
> connection_path,
>
> NM_DEVICE_STATE_REASON_USER_REQUESTED,
> error);
> }
> *The reason is "NM_DEVICE_STATE_REASON_USER_REQUESTED" in above
> function call.*
>
> Then nm_device_state_changed() will be called. From my previous mail,
> in nm_device_state_changed(NMDevice *device,
> NMDeviceState state,
> NMDeviceStateReason reason):
>
> g_signal_emit_by_name (device, "state-changed", state, old_state, 0);
You are correct. My mistake.
027ef78682baa8f733a7b19d22d78ca551c2bfa3 (master)
851957e272a9829195801eae0136e58d90360561 (0.7.x)
Thanks!
Dan
> but not
>
> g_signal_emit_by_name (device, "state-changed", state, old_state,
> reason);
>
> Then the reason "NM_DEVICE_STATE_REASON_USER_REQUESTED" can't be
> received by
> related device_state_changed() function.
> The reason always is 0(NM_DEVICE_STATE_REASON_NONE).
>
> Think MobileBroad band, it has a "Disconnect" item in nm-applet menu.
> When click it, nm_client_deactivate_connection() will be called, if
> the user(programer) want to check the disconnect reason to do
> something, e.g. user disconnected, do not auto connect again. They
> seems can not.
>
> Thanks!
>
> 2009/5/12 Dan Williams <dcbw redhat com>
> On Wed, 2009-05-06 at 11:40 +0800, 代尔欣 wrote:
> > Hi all,
> > I have a question about the NetworkManager-0.7.1 codes.
> > In NetworkManager-0.7.1/src/nm-device.c:
> >
> > void nm_device_state_changed (NMDevice *device,
> > NMDeviceState state,
> > NMDeviceStateReason reason)
> > {
> > ...
> > // Here the fifth parameter is set to 0. I think it
> should be set
> > to "reason" so that the receiver of the signal
> "state-changed" can
> > do
>
>
> The question is what event is causing the reason to be 0. Was
> it a
> user-requested disconnection? Was it something else? There
> may
> definitely be some places in NM that don't set the code
> correctly, but
> we need to identify which scenario you've hit here.
>
> > // something special base on the "state change reason".
> e.g. When
> > "NM_DEVICE_STATE_DISCONNECTED" state signaled, if
> > // the reason is "NM_DEVICE_STATE_REASON_USER_REQUESTED"
> then we
> > do not schedule auto connect in
> > // NetworkManagerPolicy.c device_state_changed() or
> > // set a flag in device-related device_state_changed()
> and reload
> > the can_activate() function to check this flag.
> > g_signal_emit_by_name (device, "state-changed", state,
> old_state,
> > 0);
> > ...
>
>
> The reason we probably don't schedule autoconnection on
> disconnect is
> precisely because the user chose to manually disconnect. If
> we did
> reschedule the autoconnect, then NM would simply reconnect the
> connection the user just disconnected.
>
> Dan
>
> > }
> >
> > If I'm wrong, please point out. Thanks!
> >
> >
> >
>
> > _______________________________________________
> > NetworkManager-list mailing list
> > NetworkManager-list gnome org
> > http://mail.gnome.org/mailman/listinfo/networkmanager-list
>
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]