mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-07 07:50:17 +01:00
ppp-manager/trivial: rename variables holding self pointers
We usually structure our code in a (pseudo) object oriented way. It makes sense to call the variable for the target object "self", it is more familiar and usually done.
This commit is contained in:
parent
515663519f
commit
53d04a1dfa
1 changed files with 64 additions and 64 deletions
|
|
@ -134,8 +134,8 @@ G_DEFINE_TYPE (NMPPPManager, nm_ppp_manager, NM_TYPE_DBUS_OBJECT)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void _ppp_cleanup (NMPPPManager *manager);
|
||||
static gboolean _ppp_kill (NMPPPManager *manager,
|
||||
static void _ppp_cleanup (NMPPPManager *self);
|
||||
static gboolean _ppp_kill (NMPPPManager *self,
|
||||
NMUtilsKillChildAsyncCb callback,
|
||||
void *user_data);
|
||||
|
||||
|
|
@ -175,8 +175,8 @@ _ppp_manager_set_route_parameters (NMPPPManager *self,
|
|||
static gboolean
|
||||
monitor_cb (gpointer user_data)
|
||||
{
|
||||
NMPPPManager *manager = NM_PPP_MANAGER (user_data);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
NMPPPManager *self = NM_PPP_MANAGER (user_data);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
|
||||
const char *ifname;
|
||||
|
||||
ifname = nm_platform_link_get_name (NM_PLATFORM_GET, priv->ifindex);
|
||||
|
|
@ -192,7 +192,7 @@ monitor_cb (gpointer user_data)
|
|||
if (errno != ENODEV)
|
||||
_LOGW ("could not read ppp stats: %s", strerror (errno));
|
||||
} else {
|
||||
g_signal_emit (manager, signals[STATS], 0,
|
||||
g_signal_emit (self, signals[STATS], 0,
|
||||
(guint) stats.p.ppp_ibytes,
|
||||
(guint) stats.p.ppp_obytes);
|
||||
}
|
||||
|
|
@ -202,9 +202,9 @@ monitor_cb (gpointer user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
monitor_stats (NMPPPManager *manager)
|
||||
monitor_stats (NMPPPManager *self)
|
||||
{
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
/* already monitoring */
|
||||
if (priv->monitor_fd >= 0)
|
||||
|
|
@ -215,7 +215,7 @@ monitor_stats (NMPPPManager *manager)
|
|||
g_warn_if_fail (priv->monitor_id == 0);
|
||||
if (priv->monitor_id)
|
||||
g_source_remove (priv->monitor_id);
|
||||
priv->monitor_id = g_timeout_add_seconds (5, monitor_cb, manager);
|
||||
priv->monitor_id = g_timeout_add_seconds (5, monitor_cb, self);
|
||||
} else
|
||||
_LOGW ("could not monitor PPP stats: %s", strerror (errno));
|
||||
}
|
||||
|
|
@ -353,8 +353,8 @@ impl_ppp_manager_need_secrets (NMDBusObject *obj,
|
|||
GDBusMethodInvocation *invocation,
|
||||
GVariant *parameters)
|
||||
{
|
||||
NMPPPManager *manager = NM_PPP_MANAGER (obj);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
NMPPPManager *self = NM_PPP_MANAGER (obj);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
|
||||
NMConnection *applied_connection;
|
||||
const char *username = NULL;
|
||||
const char *password = NULL;
|
||||
|
|
@ -373,7 +373,7 @@ impl_ppp_manager_need_secrets (NMDBusObject *obj,
|
|||
if (extract_details_from_connection (applied_connection, NULL, &username, &password, &error)) {
|
||||
/* Send existing secrets to the PPP plugin */
|
||||
priv->pending_secrets_context = invocation;
|
||||
ppp_secrets_cb (priv->act_req, priv->secrets_id, NULL, NULL, manager);
|
||||
ppp_secrets_cb (priv->act_req, priv->secrets_id, NULL, NULL, self);
|
||||
} else {
|
||||
_LOGW ("%s", error->message);
|
||||
g_dbus_method_invocation_take_error (priv->pending_secrets_context, error);
|
||||
|
|
@ -395,7 +395,7 @@ impl_ppp_manager_need_secrets (NMDBusObject *obj,
|
|||
flags,
|
||||
hints ? g_ptr_array_index (hints, 0) : NULL,
|
||||
ppp_secrets_cb,
|
||||
manager);
|
||||
self);
|
||||
g_object_set_qdata (G_OBJECT (applied_connection), ppp_manager_secret_tries_quark (), GUINT_TO_POINTER (++tries));
|
||||
priv->pending_secrets_context = invocation;
|
||||
|
||||
|
|
@ -412,11 +412,11 @@ impl_ppp_manager_set_state (NMDBusObject *obj,
|
|||
GDBusMethodInvocation *invocation,
|
||||
GVariant *parameters)
|
||||
{
|
||||
NMPPPManager *manager = NM_PPP_MANAGER (obj);
|
||||
NMPPPManager *self = NM_PPP_MANAGER (obj);
|
||||
guint32 state;
|
||||
|
||||
g_variant_get (parameters, "(u)", &state);
|
||||
g_signal_emit (manager, signals[STATE_CHANGED], 0, (guint) state);
|
||||
g_signal_emit (self, signals[STATE_CHANGED], 0, (guint) state);
|
||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||
}
|
||||
|
||||
|
|
@ -429,8 +429,8 @@ impl_ppp_manager_set_ifindex (NMDBusObject *obj,
|
|||
GDBusMethodInvocation *invocation,
|
||||
GVariant *parameters)
|
||||
{
|
||||
NMPPPManager *manager = NM_PPP_MANAGER (obj);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
NMPPPManager *self = NM_PPP_MANAGER (obj);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
|
||||
const NMPlatformLink *plink = NULL;
|
||||
nm_auto_nmpobj const NMPObject *obj_keep_alive = NULL;
|
||||
gint32 ifindex;
|
||||
|
|
@ -461,7 +461,7 @@ impl_ppp_manager_set_ifindex (NMDBusObject *obj,
|
|||
|
||||
obj_keep_alive = nmp_object_ref (NMP_OBJECT_UP_CAST (plink));
|
||||
|
||||
g_signal_emit (manager, signals[IFINDEX_SET], 0, ifindex, plink->name);
|
||||
g_signal_emit (self, signals[IFINDEX_SET], 0, ifindex, plink->name);
|
||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||
}
|
||||
|
||||
|
|
@ -500,8 +500,8 @@ impl_ppp_manager_set_ip4_config (NMDBusObject *obj,
|
|||
GDBusMethodInvocation *invocation,
|
||||
GVariant *parameters)
|
||||
{
|
||||
NMPPPManager *manager = NM_PPP_MANAGER (obj);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
NMPPPManager *self = NM_PPP_MANAGER (obj);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
|
||||
gs_unref_object NMIP4Config *config = NULL;
|
||||
NMPlatformIP4Address address;
|
||||
guint32 u32, mtu;
|
||||
|
|
@ -514,7 +514,7 @@ impl_ppp_manager_set_ip4_config (NMDBusObject *obj,
|
|||
|
||||
nm_clear_g_source (&priv->ppp_timeout_handler);
|
||||
|
||||
if (!set_ip_config_common (manager, config_dict, &mtu))
|
||||
if (!set_ip_config_common (self, config_dict, &mtu))
|
||||
goto out;
|
||||
|
||||
config = nm_ip4_config_new (nm_platform_get_multi_idx (NM_PLATFORM_GET), priv->ifindex);
|
||||
|
|
@ -566,7 +566,7 @@ impl_ppp_manager_set_ip4_config (NMDBusObject *obj,
|
|||
}
|
||||
|
||||
/* Push the IP4 config up to the device */
|
||||
g_signal_emit (manager, signals[IP4_CONFIG], 0, config);
|
||||
g_signal_emit (self, signals[IP4_CONFIG], 0, config);
|
||||
|
||||
out:
|
||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||
|
|
@ -610,8 +610,8 @@ impl_ppp_manager_set_ip6_config (NMDBusObject *obj,
|
|||
GDBusMethodInvocation *invocation,
|
||||
GVariant *parameters)
|
||||
{
|
||||
NMPPPManager *manager = NM_PPP_MANAGER (obj);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
NMPPPManager *self = NM_PPP_MANAGER (obj);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
|
||||
gs_unref_object NMIP6Config *config = NULL;
|
||||
NMPlatformIP6Address addr;
|
||||
struct in6_addr a;
|
||||
|
|
@ -625,7 +625,7 @@ impl_ppp_manager_set_ip6_config (NMDBusObject *obj,
|
|||
|
||||
nm_clear_g_source (&priv->ppp_timeout_handler);
|
||||
|
||||
if (!set_ip_config_common (manager, config_dict, NULL))
|
||||
if (!set_ip_config_common (self, config_dict, NULL))
|
||||
goto out;
|
||||
|
||||
config = nm_ip6_config_new (nm_platform_get_multi_idx (NM_PLATFORM_GET), priv->ifindex);
|
||||
|
|
@ -653,7 +653,7 @@ impl_ppp_manager_set_ip6_config (NMDBusObject *obj,
|
|||
nm_ip6_config_add_address (config, &addr);
|
||||
|
||||
/* Push the IPv6 config and interface identifier up to the device */
|
||||
g_signal_emit (manager, signals[IP6_CONFIG], 0, &iid, config);
|
||||
g_signal_emit (self, signals[IP6_CONFIG], 0, &iid, config);
|
||||
} else
|
||||
_LOGE ("invalid IPv6 address received!");
|
||||
|
||||
|
|
@ -746,8 +746,8 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (pppd_exit_code_to_str, int,
|
|||
static void
|
||||
ppp_watch_cb (GPid pid, int status, gpointer user_data)
|
||||
{
|
||||
NMPPPManager *manager = NM_PPP_MANAGER (user_data);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
NMPPPManager *self = NM_PPP_MANAGER (user_data);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
|
||||
int err;
|
||||
const long long lpid = (long long) pid;
|
||||
|
||||
|
|
@ -772,20 +772,20 @@ ppp_watch_cb (GPid pid, int status, gpointer user_data)
|
|||
|
||||
priv->pid = 0;
|
||||
priv->ppp_watch_id = 0;
|
||||
_ppp_cleanup (manager);
|
||||
g_signal_emit (manager, signals[STATE_CHANGED], 0, (guint) NM_PPP_STATUS_DEAD);
|
||||
_ppp_cleanup (self);
|
||||
g_signal_emit (self, signals[STATE_CHANGED], 0, (guint) NM_PPP_STATUS_DEAD);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
pppd_timed_out (gpointer data)
|
||||
{
|
||||
NMPPPManager *manager = NM_PPP_MANAGER (data);
|
||||
NMPPPManager *self = NM_PPP_MANAGER (data);
|
||||
|
||||
_LOGW ("pppd timed out or didn't initialize our dbus module");
|
||||
_ppp_cleanup (manager);
|
||||
_ppp_kill (manager, NULL, NULL);
|
||||
_ppp_cleanup (self);
|
||||
_ppp_kill (self, NULL, NULL);
|
||||
|
||||
g_signal_emit (manager, signals[STATE_CHANGED], 0, (guint) NM_PPP_STATUS_DEAD);
|
||||
g_signal_emit (self, signals[STATE_CHANGED], 0, (guint) NM_PPP_STATUS_DEAD);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -1010,7 +1010,7 @@ pppoe_fill_defaults (NMSettingPpp *setting)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
_ppp_manager_start (NMPPPManager *manager,
|
||||
_ppp_manager_start (NMPPPManager *self,
|
||||
NMActRequest *req,
|
||||
const char *ppp_name,
|
||||
guint32 timeout_secs,
|
||||
|
|
@ -1030,10 +1030,10 @@ _ppp_manager_start (NMPPPManager *manager,
|
|||
gboolean ip6_enabled = FALSE;
|
||||
gboolean ip4_enabled = FALSE;
|
||||
|
||||
g_return_val_if_fail (NM_IS_PPP_MANAGER (manager), FALSE);
|
||||
g_return_val_if_fail (NM_IS_PPP_MANAGER (self), FALSE);
|
||||
g_return_val_if_fail (NM_IS_ACT_REQUEST (req), FALSE);
|
||||
|
||||
priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
priv = NM_PPP_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
#if !WITH_PPP
|
||||
/* PPP support disabled */
|
||||
|
|
@ -1044,7 +1044,7 @@ _ppp_manager_start (NMPPPManager *manager,
|
|||
return FALSE;
|
||||
#endif
|
||||
|
||||
nm_dbus_object_export (NM_DBUS_OBJECT (manager));
|
||||
nm_dbus_object_export (NM_DBUS_OBJECT (self));
|
||||
|
||||
priv->pid = 0;
|
||||
|
||||
|
|
@ -1079,7 +1079,7 @@ _ppp_manager_start (NMPPPManager *manager,
|
|||
ip6_method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG);
|
||||
ip6_enabled = g_strcmp0 (ip6_method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0;
|
||||
|
||||
ppp_cmd = create_pppd_cmd_line (manager,
|
||||
ppp_cmd = create_pppd_cmd_line (self,
|
||||
s_ppp,
|
||||
pppoe_setting,
|
||||
adsl_setting,
|
||||
|
|
@ -1109,8 +1109,8 @@ _ppp_manager_start (NMPPPManager *manager,
|
|||
|
||||
_LOGI ("pppd started with pid %lld", (long long) priv->pid);
|
||||
|
||||
priv->ppp_watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) ppp_watch_cb, manager);
|
||||
priv->ppp_timeout_handler = g_timeout_add_seconds (timeout_secs, pppd_timed_out, manager);
|
||||
priv->ppp_watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) ppp_watch_cb, self);
|
||||
priv->ppp_timeout_handler = g_timeout_add_seconds (timeout_secs, pppd_timed_out, self);
|
||||
priv->act_req = g_object_ref (req);
|
||||
|
||||
out:
|
||||
|
|
@ -1118,17 +1118,17 @@ out:
|
|||
nm_cmd_line_destroy (ppp_cmd);
|
||||
|
||||
if (priv->pid <= 0)
|
||||
nm_dbus_object_unexport (NM_DBUS_OBJECT (manager));
|
||||
nm_dbus_object_unexport (NM_DBUS_OBJECT (self));
|
||||
|
||||
return priv->pid > 0;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_ppp_kill (NMPPPManager *manager,
|
||||
_ppp_kill (NMPPPManager *self,
|
||||
NMUtilsKillChildAsyncCb callback,
|
||||
void *user_data)
|
||||
{
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
if (!priv->pid) {
|
||||
/* not PID. Signal that there was nothing to kill, which consequently
|
||||
|
|
@ -1143,21 +1143,21 @@ _ppp_kill (NMPPPManager *manager,
|
|||
}
|
||||
|
||||
static void
|
||||
_ppp_cleanup (NMPPPManager *manager)
|
||||
_ppp_cleanup (NMPPPManager *self)
|
||||
{
|
||||
NMPPPManagerPrivate *priv;
|
||||
|
||||
g_return_if_fail (NM_IS_PPP_MANAGER (manager));
|
||||
g_return_if_fail (NM_IS_PPP_MANAGER (self));
|
||||
|
||||
priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
priv = NM_PPP_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
cancel_get_secrets (manager);
|
||||
cancel_get_secrets (self);
|
||||
|
||||
nm_clear_g_source (&priv->monitor_id);
|
||||
|
||||
if (priv->monitor_fd >= 0) {
|
||||
/* Get the stats one last time */
|
||||
monitor_cb (manager);
|
||||
monitor_cb (self);
|
||||
nm_close (priv->monitor_fd);
|
||||
priv->monitor_fd = -1;
|
||||
}
|
||||
|
|
@ -1169,7 +1169,7 @@ _ppp_cleanup (NMPPPManager *manager)
|
|||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
NMPPPManager *manager;
|
||||
NMPPPManager *self;
|
||||
GSimpleAsyncResult *result;
|
||||
GCancellable *cancellable;
|
||||
} StopContext;
|
||||
|
|
@ -1181,7 +1181,7 @@ stop_context_complete (StopContext *ctx)
|
|||
g_object_unref (ctx->cancellable);
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->manager);
|
||||
g_object_unref (ctx->self);
|
||||
g_slice_free (StopContext, ctx);
|
||||
}
|
||||
|
||||
|
|
@ -1199,7 +1199,7 @@ stop_context_complete_if_cancelled (StopContext *ctx)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
_ppp_manager_stop_finish (NMPPPManager *manager,
|
||||
_ppp_manager_stop_finish (NMPPPManager *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
|
|
@ -1220,19 +1220,19 @@ kill_child_ready (pid_t pid,
|
|||
}
|
||||
|
||||
static void
|
||||
_ppp_manager_stop_async (NMPPPManager *manager,
|
||||
_ppp_manager_stop_async (NMPPPManager *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
|
||||
StopContext *ctx;
|
||||
|
||||
nm_dbus_object_unexport (NM_DBUS_OBJECT (manager));
|
||||
nm_dbus_object_unexport (NM_DBUS_OBJECT (self));
|
||||
|
||||
ctx = g_slice_new0 (StopContext);
|
||||
ctx->manager = g_object_ref (manager);
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (manager),
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
_ppp_manager_stop_async);
|
||||
|
|
@ -1243,7 +1243,7 @@ _ppp_manager_stop_async (NMPPPManager *manager,
|
|||
return;
|
||||
|
||||
/* Cleanup internals */
|
||||
_ppp_cleanup (manager);
|
||||
_ppp_cleanup (self);
|
||||
|
||||
/* If no pppd running, we're done */
|
||||
if (!priv->pid) {
|
||||
|
|
@ -1251,20 +1251,20 @@ _ppp_manager_stop_async (NMPPPManager *manager,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!_ppp_kill (manager, kill_child_ready, ctx))
|
||||
if (!_ppp_kill (self, kill_child_ready, ctx))
|
||||
nm_assert_not_reached ();
|
||||
}
|
||||
|
||||
static void
|
||||
_ppp_manager_stop_sync (NMPPPManager *manager)
|
||||
_ppp_manager_stop_sync (NMPPPManager *self)
|
||||
{
|
||||
NMDBusObject *dbus = NM_DBUS_OBJECT (manager);
|
||||
NMDBusObject *dbus = NM_DBUS_OBJECT (self);
|
||||
|
||||
if (nm_dbus_object_is_exported (dbus))
|
||||
nm_dbus_object_unexport (dbus);
|
||||
|
||||
_ppp_cleanup (manager);
|
||||
_ppp_kill (manager, NULL, NULL);
|
||||
_ppp_cleanup (self);
|
||||
_ppp_kill (self, NULL, NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -1305,9 +1305,9 @@ set_property (GObject *object, guint prop_id,
|
|||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_ppp_manager_init (NMPPPManager *manager)
|
||||
nm_ppp_manager_init (NMPPPManager *self)
|
||||
{
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
priv->ifindex = -1;
|
||||
priv->monitor_fd = -1;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue