Re: one connection at a time



On Fri, 2008-06-13 at 23:40 +0530, Bhupesh Rawal wrote:
> I want to disable active VPN too. 

So in addition to the bits I mentioned before, in the same place you
will additionally want to do something like:

GPtrArray *array;
int i;

array = g_ptr_array_sized_new (1);
vpn_manager = nm_vpn_manager_get ();
nm_vpn_manager_add_active_connections (vpn_manager, filter, active);
g_object_unref (vpn_manager);

for (i = 0; i < array->len; i++) {
    char *path = (const char *) g_ptr_array_index (array, i);
    nm_manager_deactivate_connection (self, (const char *) path, error);
    g_free (path);
}

g_ptr_array_free (array, TRUE);


Dan

> Bhupesh
> 
> On Fri, Jun 13, 2008 at 9:13 PM, Dan Williams <dcbw redhat com> wrote:
>         
>         On Fri, 2008-06-13 at 00:13 +0530, Bhupesh Rawal wrote:
>         > Hi,
>         >
>         > I am using Network-Manager-0.7 and it supports two or more
>         connections
>         > present at same time. For example both WWAN and WLAN are
>         present.
>         > Please suggest where i can put checks in code to make only
>         one
>         > connection at a time. If i make any connection then other
>         should get
>         > down automatically. Any help would be appreciated.
>         
>         
>         src/nm-manager.c::internal_activate_device() - right before
>         the
>         nm_act_request_new() call, you'll want to search the manager's
>         device
>         list and for any device in the list:
>         
>         for (each device in priv->devices) {
>            NMActRequest *req;
>            GError *my_error = NULL;
>         
>            req = nm_device_get_act_request (device);
>            if (req) {
>                if (!nm_manager_deactivate_connection(manager,
>         nm_act_request_get_active_connection_path (req), &my_error)) {
>                    /* deactivation failed for some reason; just ignore
>         */
>                    g_error_free (my_error);
>                }
>            }
>         }
>         
>         Note that this will ignore active VPN connections, which is
>         probably
>         what you want.
>         
>         Dan
>         
>         
> 



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