mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-21 20:20:31 +01:00
2007-08-14 Dan Williams <dcbw@redhat.com>
* src/nm-openvpn-service.c - Handle NM_VPN_STATE_* -> NM_VPN_SERVICE_STATE_* and NMVPNState -> NMVPNServiceState renames git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2679 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
35d4657071
commit
af34f1ac79
2 changed files with 32 additions and 26 deletions
|
|
@ -1,3 +1,9 @@
|
|||
2007-08-14 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* src/nm-openvpn-service.c
|
||||
- Handle NM_VPN_STATE_* -> NM_VPN_SERVICE_STATE_* and NMVPNState ->
|
||||
NMVPNServiceState renames
|
||||
|
||||
2007-07-26 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Patch from Kelemen Gábor <kelemeng@gnome.hu>
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ typedef struct NmPPPData
|
|||
{
|
||||
GMainLoop *loop;
|
||||
DBusConnection *con;
|
||||
NMVPNState state;
|
||||
NMVPNServiceState state;
|
||||
GPid pid;
|
||||
guint quit_timer;
|
||||
guint helper_timer;
|
||||
|
|
@ -162,7 +162,7 @@ static void nm_ppp_dbus_signal_failure (NmPPPData *data, const char *signal, con
|
|||
* Signal the bus that our state changed.
|
||||
*
|
||||
*/
|
||||
static void nm_ppp_dbus_signal_state_change (NmPPPData *data, NMVPNState old_state)
|
||||
static void nm_ppp_dbus_signal_state_change (NmPPPData *data, NMVPNServiceState old_state)
|
||||
{
|
||||
DBusMessage *message;
|
||||
|
||||
|
|
@ -189,9 +189,9 @@ static void nm_ppp_dbus_signal_state_change (NmPPPData *data, NMVPNState old_sta
|
|||
* Set our state and make sure to signal the bus.
|
||||
*
|
||||
*/
|
||||
static void nm_ppp_set_state (NmPPPData *data, NMVPNState new_state)
|
||||
static void nm_ppp_set_state (NmPPPData *data, NMVPNServiceState new_state)
|
||||
{
|
||||
NMVPNState old_state;
|
||||
NMVPNServiceState old_state;
|
||||
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
|
|
@ -356,7 +356,7 @@ static void pppd_start_watch_cb (GPid pid, gint status, gpointer user_data)
|
|||
break;
|
||||
}
|
||||
|
||||
nm_ppp_set_state (data, NM_VPN_STATE_STOPPED);
|
||||
nm_ppp_set_state (data, NM_VPN_SERVICE_STATE_STOPPED);
|
||||
nm_ppp_schedule_quit_timer (data, 10000);
|
||||
}
|
||||
|
||||
|
|
@ -425,7 +425,7 @@ static void pppd_forked_watch_cb (GPid pid, gint status, gpointer user_data)
|
|||
}
|
||||
|
||||
|
||||
nm_ppp_set_state (data, NM_VPN_STATE_STOPPED);
|
||||
nm_ppp_set_state (data, NM_VPN_SERVICE_STATE_STOPPED);
|
||||
nm_ppp_schedule_quit_timer (data, 10000);
|
||||
}
|
||||
|
||||
|
|
@ -1110,7 +1110,7 @@ static gboolean nm_ppp_dbus_handle_start_vpn (DBusMessage *message, NmPPPData *d
|
|||
g_return_val_if_fail (message != NULL, FALSE);
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
nm_ppp_set_state (data, NM_VPN_STATE_STARTING);
|
||||
nm_ppp_set_state (data, NM_VPN_SERVICE_STATE_STARTING);
|
||||
|
||||
dbus_error_init (&error);
|
||||
if (!dbus_message_get_args (message, &error,
|
||||
|
|
@ -1152,7 +1152,7 @@ out:
|
|||
dbus_free_string_array (auth_items);
|
||||
dbus_free_string_array (user_routes);
|
||||
if (!success)
|
||||
nm_ppp_set_state (data, NM_VPN_STATE_STOPPED);
|
||||
nm_ppp_set_state (data, NM_VPN_SERVICE_STATE_STOPPED);
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
@ -1169,13 +1169,13 @@ static gboolean nm_ppp_dbus_handle_stop_vpn (NmPPPData *data)
|
|||
|
||||
if (data->pid > 0)
|
||||
{
|
||||
nm_ppp_set_state (data, NM_VPN_STATE_STOPPING);
|
||||
nm_ppp_set_state (data, NM_VPN_SERVICE_STATE_STOPPING);
|
||||
|
||||
kill (data->pid, SIGTERM);
|
||||
nm_info ("Terminated pppd with PID %d.", data->pid);
|
||||
data->pid = 0;
|
||||
|
||||
nm_ppp_set_state (data, NM_VPN_STATE_STOPPED);
|
||||
nm_ppp_set_state (data, NM_VPN_SERVICE_STATE_STOPPED);
|
||||
nm_ppp_schedule_quit_timer (data, 10000);
|
||||
}
|
||||
|
||||
|
|
@ -1194,13 +1194,13 @@ static gboolean nm_ppp_dbus_handle_stop_vpn (NmPPPData *data)
|
|||
|
||||
if (data->pid > 0)
|
||||
{
|
||||
nm_ppp_set_state (data, NM_VPN_STATE_STOPPING);
|
||||
nm_ppp_set_state (data, NM_VPN_SERVICE_STATE_STOPPING);
|
||||
|
||||
kill (data->pid, SIGTERM);
|
||||
nm_info ("Terminated pppd with PID %d.", data->pid);
|
||||
data->pid = 0;
|
||||
|
||||
nm_ppp_set_state (data, NM_VPN_STATE_STOPPED);
|
||||
nm_ppp_set_state (data, NM_VPN_SERVICE_STATE_STOPPED);
|
||||
nm_ppp_schedule_quit_timer (data, 10000);
|
||||
}
|
||||
|
||||
|
|
@ -1224,22 +1224,22 @@ static DBusMessage *nm_ppp_dbus_start_vpn (DBusConnection *con, DBusMessage *mes
|
|||
|
||||
switch (data->state)
|
||||
{
|
||||
case NM_VPN_STATE_STARTING:
|
||||
case NM_VPN_SERVICE_STATE_STARTING:
|
||||
reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPP_STARTER, NM_DBUS_VPN_STARTING_IN_PROGRESS,
|
||||
"Could not process the request because the VPN connection is already being started.");
|
||||
break;
|
||||
|
||||
case NM_VPN_STATE_STARTED:
|
||||
case NM_VPN_SERVICE_STATE_STARTED:
|
||||
reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPP_STARTER, NM_DBUS_VPN_ALREADY_STARTED,
|
||||
"Could not process the request because a VPN connection was already active.");
|
||||
break;
|
||||
|
||||
case NM_VPN_STATE_STOPPING:
|
||||
case NM_VPN_SERVICE_STATE_STOPPING:
|
||||
reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPP_STARTER, NM_DBUS_VPN_STOPPING_IN_PROGRESS,
|
||||
"Could not process the request because the VPN connection is being stopped.");
|
||||
break;
|
||||
|
||||
case NM_VPN_STATE_STOPPED:
|
||||
case NM_VPN_SERVICE_STATE_STOPPED:
|
||||
nm_ppp_cancel_quit_timer (data);
|
||||
nm_ppp_dbus_handle_start_vpn (message, data);
|
||||
reply = dbus_message_new_method_return (message);
|
||||
|
|
@ -1270,18 +1270,18 @@ static DBusMessage *nm_ppp_dbus_stop_vpn (DBusConnection *con, DBusMessage *mess
|
|||
|
||||
switch (data->state)
|
||||
{
|
||||
case NM_VPN_STATE_STOPPING:
|
||||
case NM_VPN_SERVICE_STATE_STOPPING:
|
||||
reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPP_STARTER, NM_DBUS_VPN_STOPPING_IN_PROGRESS,
|
||||
"Could not process the request because the VPN connection is already being stopped.");
|
||||
break;
|
||||
|
||||
case NM_VPN_STATE_STOPPED:
|
||||
case NM_VPN_SERVICE_STATE_STOPPED:
|
||||
reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPP_STARTER, NM_DBUS_VPN_ALREADY_STOPPED,
|
||||
"Could not process the request because no VPN connection was active.");
|
||||
break;
|
||||
|
||||
case NM_VPN_STATE_STARTING:
|
||||
case NM_VPN_STATE_STARTED:
|
||||
case NM_VPN_SERVICE_STATE_STARTING:
|
||||
case NM_VPN_SERVICE_STATE_STARTED:
|
||||
nm_ppp_dbus_handle_stop_vpn (data);
|
||||
reply = dbus_message_new_method_return (message);
|
||||
break;
|
||||
|
|
@ -1398,7 +1398,7 @@ static void nm_ppp_dbus_process_helper_config_error (DBusConnection *con, DBusMe
|
|||
g_return_if_fail (message != NULL);
|
||||
|
||||
/* Only accept the config info if we're in STARTING state */
|
||||
if (data->state != NM_VPN_STATE_STARTING)
|
||||
if (data->state != NM_VPN_SERVICE_STATE_STARTING)
|
||||
return;
|
||||
|
||||
if (dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &error_item, DBUS_TYPE_INVALID))
|
||||
|
|
@ -1446,7 +1446,7 @@ static void nm_ppp_dbus_process_helper_ip4_config (DBusConnection *con, DBusMess
|
|||
g_return_if_fail (message != NULL);
|
||||
|
||||
/* Only accept the config info if we're in STARTING state */
|
||||
if (data->state != NM_VPN_STATE_STARTING)
|
||||
if (data->state != NM_VPN_SERVICE_STATE_STARTING)
|
||||
return;
|
||||
|
||||
/* If IP is up then we don't need to leave the auth info lying around */
|
||||
|
|
@ -1568,7 +1568,7 @@ static void nm_ppp_dbus_process_helper_ip4_config (DBusConnection *con, DBusMess
|
|||
}
|
||||
|
||||
dbus_message_unref (signal);
|
||||
nm_ppp_set_state (data, NM_VPN_STATE_STARTED);
|
||||
nm_ppp_set_state (data, NM_VPN_SERVICE_STATE_STARTED);
|
||||
success = TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -1608,7 +1608,7 @@ static DBusHandlerResult nm_ppp_dbus_message_handler (DBusConnection *con, DBusM
|
|||
/* nm_info ("nm_ppp_dbus_message_handler() got method '%s' for path '%s'.", method, path); */
|
||||
|
||||
/* If we aren't ready to accept dbus messages, don't */
|
||||
if ((data->state == NM_VPN_STATE_INIT) || (data->state == NM_VPN_STATE_SHUTDOWN))
|
||||
if ((data->state == NM_VPN_SERVICE_STATE_INIT) || (data->state == NM_VPN_SERVICE_STATE_SHUTDOWN))
|
||||
{
|
||||
nm_warning ("Received dbus messages but couldn't handle them due to INIT or SHUTDOWN states.");
|
||||
reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPP_STARTER, NM_DBUS_VPN_WRONG_STATE,
|
||||
|
|
@ -1792,7 +1792,7 @@ int main( int argc, char *argv[] )
|
|||
vpn_data = g_malloc0 (sizeof (NmPPPData));
|
||||
|
||||
vpn_data->debug = FALSE;
|
||||
vpn_data->state = NM_VPN_STATE_INIT;
|
||||
vpn_data->state = NM_VPN_SERVICE_STATE_INIT;
|
||||
|
||||
vpn_data->loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
|
|
@ -1806,7 +1806,7 @@ int main( int argc, char *argv[] )
|
|||
sigaction (SIGINT, &action, NULL);
|
||||
sigaction (SIGTERM, &action, NULL);
|
||||
|
||||
nm_ppp_set_state (vpn_data, NM_VPN_STATE_STOPPED);
|
||||
nm_ppp_set_state (vpn_data, NM_VPN_SERVICE_STATE_STOPPED);
|
||||
g_main_loop_run (vpn_data->loop);
|
||||
|
||||
nm_ppp_dbus_handle_stop_vpn (vpn_data);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue