Re: Connection update made by plugin won't change system connection



On Sun, May 2, 2010 at 6:21 PM, Mu Qiao <qiaomuf gmail com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Dan,
> I've implemented monitoring using GFileMonitor. Configuration files
> changes could be noticed by the plug-in and then corresponding actions
> will be taken.
> Currently, connection adding and removing caused by configuration
> change could be correctly handled and I can see the change via
> nm-applet.
>
> However, though connection update can be seen via nm-applet by editing
> connections, the ""connection information"" provided by nm-applet will
> not show the change. Meanwhile, ifconfig will show that the network
> configuration is not changed at all. Nothing changed in
> /etc/resolv.conf.
>
> I update connections in these steps:
> new = nm_ifnet_connection_new(conn_name);
> old = g_hash_table_lookup(priv->config_connections, conn_name);
>
> nm_sysconfig_connection_update(NM_SYSCONFIG_CONNECTION(old),
>                                            NM_CONNECTION(new), TRUE,
>                                            error));             //(No
> error returned and return value is TRUE)
>
> g_object_unref(new);
> g_signal_emit_by_name(self,
>
> NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED,
>                                              NM_EXPORTED_CONNECTION
>                                              (old));
>
> Did I miss anything?
>
> - --
> Best wishes,
> Mu Qiao
> GnuPG fingerprint: 92B1 B0C4 8D14 F8C4 EFA5  3ACC 30B3 0DE4 17B1 57E9
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.14 (GNU/Linux)
> Comment: Use GnuPG with Firefox : http://getfiregpg.org (Version: 0.7.10)
>
> iQEcBAEBAgAGBQJL3VIlAAoJEDCzDeQXsVfpXHwIAJ5PpKve8NIS+del/+0hgyGv
> EbbkFjAAEsI4/UEIelscECiTSUv47dYyIqd1qbSHWU2a9d996nQsioMjU+zA02sc
> 2YTlDwdnJbWT/drkdNiWEnScI/OgEQZrbLlSB7fLESpUexSap2bjCqyENCF9k9h5
> pNrbiwQzlq5TBQU9ZLA7d+YHNAO/AFe3MoGmQfVI6M0WDv5D5S2KMyGKTEk/t7Ur
> wgl2aLH0HuiouuR7ln87ILEf5s9S+aLwy5OhAqzGeOzEjdq08Gm6EqkVHv4idy1s
> PBl6U3WovGWv73pdi8vFJW2FZyZZEemjiB2z36FqzBpqNH6B3K/eqdQvo6pwnG8=
> =bXL0
> -----END PGP SIGNATURE-----
>

I got this to work as expected. I did this in this way:

g_signal_emit_by_name(old,
                      NM_SETTINGS_CONNECTION_INTERFACE_REMOVED);
g_hash_table_remove(priv->config_connections,
                    conn_name);
g_hash_table_insert(priv->config_connections,
                    g_strdup(conn_name),
                    new);

just remove the old connection add the new one :P. Network will be
disconnected in a very short period.

-- 
Best wishes,
Mu Qiao
GnuPG fingerprint: 92B1 B0C4 8D14 F8C4 EFA5  3ACC 30B3 0DE4 17B1 57E9


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