cli/trivial: move code
This commit is contained in:
@@ -41,6 +41,65 @@
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static char *
|
||||
ap_wpa_rsn_flags_to_string (NM80211ApSecurityFlags flags)
|
||||
{
|
||||
char *flags_str[16]; /* Enough space for flags and terminating NULL */
|
||||
char *ret_str;
|
||||
int i = 0;
|
||||
|
||||
if (flags & NM_802_11_AP_SEC_PAIR_WEP40)
|
||||
flags_str[i++] = g_strdup ("pair_wpe40");
|
||||
if (flags & NM_802_11_AP_SEC_PAIR_WEP104)
|
||||
flags_str[i++] = g_strdup ("pair_wpe104");
|
||||
if (flags & NM_802_11_AP_SEC_PAIR_TKIP)
|
||||
flags_str[i++] = g_strdup ("pair_tkip");
|
||||
if (flags & NM_802_11_AP_SEC_PAIR_CCMP)
|
||||
flags_str[i++] = g_strdup ("pair_ccmp");
|
||||
if (flags & NM_802_11_AP_SEC_GROUP_WEP40)
|
||||
flags_str[i++] = g_strdup ("group_wpe40");
|
||||
if (flags & NM_802_11_AP_SEC_GROUP_WEP104)
|
||||
flags_str[i++] = g_strdup ("group_wpe104");
|
||||
if (flags & NM_802_11_AP_SEC_GROUP_TKIP)
|
||||
flags_str[i++] = g_strdup ("group_tkip");
|
||||
if (flags & NM_802_11_AP_SEC_GROUP_CCMP)
|
||||
flags_str[i++] = g_strdup ("group_ccmp");
|
||||
if (flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)
|
||||
flags_str[i++] = g_strdup ("psk");
|
||||
if (flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
|
||||
flags_str[i++] = g_strdup ("802.1X");
|
||||
|
||||
if (i == 0)
|
||||
flags_str[i++] = g_strdup (_("(none)"));
|
||||
|
||||
flags_str[i] = NULL;
|
||||
|
||||
ret_str = g_strjoinv (" ", flags_str);
|
||||
|
||||
i = 0;
|
||||
while (flags_str[i])
|
||||
g_free (flags_str[i++]);
|
||||
|
||||
return ret_str;
|
||||
}
|
||||
|
||||
static NMMetaColor
|
||||
wifi_signal_to_color (guint8 strength)
|
||||
{
|
||||
if (strength > 80)
|
||||
return NM_META_COLOR_WIFI_SIGNAL_EXCELLENT;
|
||||
else if (strength > 55)
|
||||
return NM_META_COLOR_WIFI_SIGNAL_GOOD;
|
||||
else if (strength > 30)
|
||||
return NM_META_COLOR_WIFI_SIGNAL_FAIR;
|
||||
else if (strength > 5)
|
||||
return NM_META_COLOR_WIFI_SIGNAL_POOR;
|
||||
else
|
||||
return NM_META_COLOR_WIFI_SIGNAL_UNKNOWN;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gconstpointer
|
||||
_metagen_device_status_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
||||
{
|
||||
@@ -1066,63 +1125,6 @@ sort_access_points (const GPtrArray *aps)
|
||||
return sorted;
|
||||
}
|
||||
|
||||
static NMMetaColor
|
||||
wifi_signal_to_color (guint8 strength)
|
||||
{
|
||||
if (strength > 80)
|
||||
return NM_META_COLOR_WIFI_SIGNAL_EXCELLENT;
|
||||
else if (strength > 55)
|
||||
return NM_META_COLOR_WIFI_SIGNAL_GOOD;
|
||||
else if (strength > 30)
|
||||
return NM_META_COLOR_WIFI_SIGNAL_FAIR;
|
||||
else if (strength > 5)
|
||||
return NM_META_COLOR_WIFI_SIGNAL_POOR;
|
||||
else
|
||||
return NM_META_COLOR_WIFI_SIGNAL_UNKNOWN;
|
||||
}
|
||||
|
||||
static char *
|
||||
ap_wpa_rsn_flags_to_string (NM80211ApSecurityFlags flags)
|
||||
{
|
||||
char *flags_str[16]; /* Enough space for flags and terminating NULL */
|
||||
char *ret_str;
|
||||
int i = 0;
|
||||
|
||||
if (flags & NM_802_11_AP_SEC_PAIR_WEP40)
|
||||
flags_str[i++] = g_strdup ("pair_wpe40");
|
||||
if (flags & NM_802_11_AP_SEC_PAIR_WEP104)
|
||||
flags_str[i++] = g_strdup ("pair_wpe104");
|
||||
if (flags & NM_802_11_AP_SEC_PAIR_TKIP)
|
||||
flags_str[i++] = g_strdup ("pair_tkip");
|
||||
if (flags & NM_802_11_AP_SEC_PAIR_CCMP)
|
||||
flags_str[i++] = g_strdup ("pair_ccmp");
|
||||
if (flags & NM_802_11_AP_SEC_GROUP_WEP40)
|
||||
flags_str[i++] = g_strdup ("group_wpe40");
|
||||
if (flags & NM_802_11_AP_SEC_GROUP_WEP104)
|
||||
flags_str[i++] = g_strdup ("group_wpe104");
|
||||
if (flags & NM_802_11_AP_SEC_GROUP_TKIP)
|
||||
flags_str[i++] = g_strdup ("group_tkip");
|
||||
if (flags & NM_802_11_AP_SEC_GROUP_CCMP)
|
||||
flags_str[i++] = g_strdup ("group_ccmp");
|
||||
if (flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)
|
||||
flags_str[i++] = g_strdup ("psk");
|
||||
if (flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
|
||||
flags_str[i++] = g_strdup ("802.1X");
|
||||
|
||||
if (i == 0)
|
||||
flags_str[i++] = g_strdup (_("(none)"));
|
||||
|
||||
flags_str[i] = NULL;
|
||||
|
||||
ret_str = g_strjoinv (" ", flags_str);
|
||||
|
||||
i = 0;
|
||||
while (flags_str[i])
|
||||
g_free (flags_str[i++]);
|
||||
|
||||
return ret_str;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
NmCli *nmc;
|
||||
int index;
|
||||
|
Reference in New Issue
Block a user