~ubuntu-branches/debian/sid/network-manager/sid

« back to all changes in this revision

Viewing changes to src/nm-manager.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2011-11-03 21:32:50 UTC
  • mfrom: (1.4.6)
  • Revision ID: package-import@ubuntu.com-20111103213250-w49ucjmux3hbwnta
Tags: 0.9.1.95-1
* New upstream release (0.9.2 rc1).
  - Fix connection sharing with newer iptables versions. (Closes: #638995)
  - Fix handling of numeric SSIDs in the keyfile plugin. (Closes: #642912)
* debian/watch: Track .xz tarballs.
* debian/libnm-util2.symbols: Add new symbols for libnm-util.
* debian/patches/04-dont-update-routing-and-dns-for-unmanaged-devices.patch
  - Avoid blowing away existing routes and resolv.conf if NM never managed
    any devices. (Closes: #546893, #624159, #637005, #641904)
* debian/control: Add Build-Depends on libglib2.0-doc for proper
  cross-references in the gtk-doc API documentation.
* Enable default hardening options from dpkg-buildflags.
  - Use buildflags.mk snippet in debian/rules.
  - Add Build-Depends on dpkg-dev (>= 1.6.1).

Show diffs side-by-side

added added

removed removed

Lines of Context:
196
196
} RadioState;
197
197
 
198
198
typedef struct {
199
 
        char *config_file;
200
199
        char *state_file;
201
200
 
202
201
        GSList *devices;
214
213
        gboolean net_enabled;
215
214
 
216
215
        NMVPNManager *vpn_manager;
217
 
        guint vpn_manager_id;
 
216
        gulong vpn_manager_activated_id;
 
217
        gulong vpn_manager_deactivated_id;
218
218
 
219
219
        NMModemManager *modem_manager;
220
220
        guint modem_added_id;
377
377
}
378
378
 
379
379
static void
 
380
vpn_manager_connection_activated_cb (NMVPNManager *manager,
 
381
                                     NMVPNConnection *vpn,
 
382
                                     NMVPNConnectionState state,
 
383
                                     NMVPNConnectionStateReason reason,
 
384
                                     gpointer user_data)
 
385
{
 
386
        /* Update timestamp for the VPN connection */
 
387
        nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (nm_vpn_connection_get_connection (vpn)),
 
388
                                                 (guint64) time (NULL));
 
389
}
 
390
 
 
391
static void
380
392
vpn_manager_connection_deactivated_cb (NMVPNManager *manager,
381
393
                                       NMVPNConnection *vpn,
382
394
                                       NMVPNConnectionState state,
1980
1992
                vpn_connection = nm_vpn_manager_activate_connection (priv->vpn_manager,
1981
1993
                                                                     connection,
1982
1994
                                                                     device,
 
1995
                                                                     nm_act_request_get_active_connection_path (parent_req),
1983
1996
                                                                     TRUE,
1984
1997
                                                                     sender_uid,
1985
1998
                                                                     error);
3029
3042
        return DBUS_HANDLER_RESULT_HANDLED;
3030
3043
}
3031
3044
 
3032
 
NMManager *
3033
 
nm_manager_get (NMSettings *settings,
3034
 
                const char *config_file,
3035
 
                const char *plugins,
 
3045
static NMManager *singleton = NULL;
 
3046
 
 
3047
NMManager *
 
3048
nm_manager_get (void)
 
3049
{
 
3050
        g_assert (singleton);
 
3051
        return g_object_ref (singleton);
 
3052
}
 
3053
 
 
3054
NMManager *
 
3055
nm_manager_new (NMSettings *settings,
3036
3056
                const char *state_file,
3037
3057
                gboolean initial_net_enabled,
3038
3058
                gboolean initial_wifi_enabled,
3040
3060
                gboolean initial_wimax_enabled,
3041
3061
                GError **error)
3042
3062
{
3043
 
        static NMManager *singleton = NULL;
3044
3063
        NMManagerPrivate *priv;
3045
3064
        DBusGConnection *bus;
3046
3065
        DBusConnection *dbus_connection;
3047
3066
 
3048
 
        if (singleton)
3049
 
                return g_object_ref (singleton);
3050
 
 
3051
3067
        g_assert (settings);
3052
3068
 
 
3069
        /* Can only be called once */
 
3070
        g_assert (singleton == NULL);
3053
3071
        singleton = (NMManager *) g_object_new (NM_TYPE_MANAGER, NULL);
3054
3072
        g_assert (singleton);
3055
3073
 
3068
3086
 
3069
3087
        priv->settings = g_object_ref (settings);
3070
3088
 
3071
 
        priv->config_file = g_strdup (config_file);
3072
3089
        priv->state_file = g_strdup (state_file);
3073
3090
 
3074
3091
        priv->net_enabled = initial_net_enabled;
3155
3172
        }
3156
3173
 
3157
3174
        g_free (priv->hostname);
3158
 
        g_free (priv->config_file);
3159
3175
 
3160
3176
        g_object_unref (priv->settings);
3161
3177
 
3162
 
        if (priv->vpn_manager_id) {
3163
 
                g_source_remove (priv->vpn_manager_id);
3164
 
                priv->vpn_manager_id = 0;
 
3178
        if (priv->vpn_manager_activated_id) {
 
3179
                g_source_remove (priv->vpn_manager_activated_id);
 
3180
                priv->vpn_manager_activated_id = 0;
 
3181
        }
 
3182
        if (priv->vpn_manager_deactivated_id) {
 
3183
                g_source_remove (priv->vpn_manager_deactivated_id);
 
3184
                priv->vpn_manager_deactivated_id = 0;
3165
3185
        }
3166
3186
        g_object_unref (priv->vpn_manager);
3167
3187
 
3402
3422
periodic_update_active_connection_timestamps (gpointer user_data)
3403
3423
{
3404
3424
        NMManager *manager = NM_MANAGER (user_data);
 
3425
        NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
3405
3426
        GPtrArray *active;
3406
3427
        int i;
3407
3428
 
3416
3437
                if (device && nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED)
3417
3438
                        nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (nm_act_request_get_connection (req)),
3418
3439
                                                                 (guint64) time (NULL));
 
3440
                else {
 
3441
                        /* The connection is probably VPN */
 
3442
                        NMVPNConnection *vpn_con;
 
3443
 
 
3444
                        vpn_con = nm_vpn_manager_get_vpn_connection_for_active (priv->vpn_manager, active_path);
 
3445
                        if (vpn_con && nm_vpn_connection_get_vpn_state (vpn_con) == NM_VPN_CONNECTION_STATE_ACTIVATED)
 
3446
                                nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (nm_vpn_connection_get_connection (vpn_con)),
 
3447
                                                                         (guint64) time (NULL));
 
3448
                }
3419
3449
        }
3420
3450
 
3421
3451
        return TRUE;
3426
3456
{
3427
3457
        NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
3428
3458
        DBusGConnection *g_connection;
3429
 
        guint id, i;
 
3459
        guint i;
3430
3460
        GFile *file;
3431
3461
 
3432
3462
        /* Initialize rfkill structures and states */
3471
3501
                                                   G_CALLBACK (modem_removed), manager);
3472
3502
 
3473
3503
        priv->vpn_manager = nm_vpn_manager_get ();
3474
 
        id = g_signal_connect (G_OBJECT (priv->vpn_manager), "connection-deactivated",
3475
 
                               G_CALLBACK (vpn_manager_connection_deactivated_cb), manager);
3476
 
        priv->vpn_manager_id = id;
 
3504
        priv->vpn_manager_activated_id = g_signal_connect (G_OBJECT (priv->vpn_manager), "connection-activated",
 
3505
                                                           G_CALLBACK (vpn_manager_connection_activated_cb), manager);
 
3506
        priv->vpn_manager_deactivated_id = g_signal_connect (G_OBJECT (priv->vpn_manager), "connection-deactivated",
 
3507
                                                           G_CALLBACK (vpn_manager_connection_deactivated_cb), manager);
3477
3508
 
3478
3509
        g_connection = nm_dbus_manager_get_connection (priv->dbus_mgr);
3479
3510