RE: networkmanager control issue



On Thu, 2010-03-18 at 10:41 +0800, Edward_Doong wistron com wrote:
> Dear Dan:
> Thanks for your reply.
> 1. I had look over this spec. in few days.
>   Now, I can check my system network state. (
> org.freedesktop.NetworkManager )
>   And I will try to get AP list from D-Bus. ( when I click icon that
> will scan AP. Not always scan )

Take a look at the 'cli/src' directory in the NM git repo
(http://git.freedesktop.org) to see some easier details about how to ask
for APs and such with libnm-glib, if you're basing your application off
glib.  If you're not basing your application off glib, then using direct
D-Bus C calls (ie, libdbus) will work too, but is more painful since you
can't use libnm-glib.

With libnm-glib it's basically:

NMClient *client;
const GPtrArray *devices, *aps;
int i, z;

client = nm_client_new ();
devices = nm_client_get_devices ();
for (i = 0; devices && (i < devices->len); i++) {
    NMDevice *device = g_ptr_array_index (devices, i);

    if (NM_IS_DEVICE_WIFI (device)) {
        aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device));
        for (z = 0; aps && (z < aps->len); z++) {
            NMAccessPoint *ap = g_ptr_array_index (aps, z);

            <get AP attributes here and show them to the user>
        }
    }
}

> 2. Yes, I will register another D-Bus that communication with UI.
>   So, my D-Bus will communication between UI & NetworkManager.

You could put both the UI and the saved connection storage service in
the same process to keep things simpler, but you don't have to.

>   Because I want that UI just only have AP & PW for type. 
>   Other networksecret, etc... don't choice by UI.
>   And is it "Feasible"?

Yes.

>   BTW, I will change python language to C language. ( That let me
> "crazy" )

Yeah, there are tradeoffs either way.

Dan

> Thanks
> Edward
> 
> On Tue, 2010-03-16 at 10:52 +0800, 
> > Dear,
> >            I study network-manager 0.8 first time by myself.
> > And I meet some issue. Now I use python & gtk+ language.
> > I want to control all network interfaces in my window.
> > What do I add D-bus script in my language,
> > Like this : 
> > First window I can scan AP & choice.
> 
> NetworkManager periodically scans for you, though we're looking into
> making a scan request call via D-Bus if you want updated AP lists more
> often than every 2 minutes, which I suspect you'd be interested in.
> 
> You can get the list of all APs the devices sees via D-Bus; see the NM
> D-Bus API spec here:
> 
> http://projects.gnome.org/NetworkManager/developers/spec-08.html
> 
> This allows you to ask NetworkManager for the AP list for a specific
> wifi device and get each AP's details like signal strength and
> encryption type.
> 
> > Second window I can type password.
> 
> NetworkManager doesn't quite operate like that; instead you have "saved
> connections" (representing all the parameters needed to connect to a
> specific network) that the user-interface applet provides to
> NetworkManager via D-Bus.  NM will only connect to APs that are
> specified by these "saved connections".  How you store that saved
> connection is up to your applet; the GNOME nm-applet saves them in
> GConf, the KDE networkmanager applet saves them in other ways.  The
> programs that provide this connection data to NM are called "settings
> services".
> 
> So when you want to connect, your applet does the following:
> 
> 1) do I have a saved connection that matches up with this access point?
> If so, tell NM to connect to the AP using this saved connection.
> 
> 2) If not, create a saved connection, tell NetworkManager that you've
> created a new saved connection via D-Bus (see the system settings
> interface documentation [1]), then tell NM that you want to connect to
> the AP using that saved connection.
> 
> 3) When the D-Bus ActivateConnection() call returns, it'll send an
> "ActiveConnection" object back to you, which you can use to track the
> status of the in-progress connection to the access point, and you can
> show that progress in the UI.
> 
> If you want any other help or clarification, let me know.
> 
> Dan
> 
> [1]
> http://projects.gnome.org/NetworkManager/developers/spec-08.html#org.fre
> edesktop.NetworkManagerSettings
> 
> 




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