本文整理汇总了C++中NM_SETTING函数的典型用法代码示例。如果您正苦于以下问题:C++ NM_SETTING函数的具体用法?C++ NM_SETTING怎么用?C++ NM_SETTING使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NM_SETTING函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nm_utils_complete_generic
void
nm_utils_complete_generic (NMConnection *connection,
const char *ctype,
const GSList *existing,
const char *format,
const char *preferred,
gboolean default_enable_ipv6)
{
NMSettingConnection *s_con;
NMSettingIP4Config *s_ip4;
NMSettingIP6Config *s_ip6;
const char *method;
char *id, *uuid;
s_con = nm_connection_get_setting_connection (connection);
if (!s_con) {
s_con = (NMSettingConnection *) nm_setting_connection_new ();
nm_connection_add_setting (connection, NM_SETTING (s_con));
}
g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_TYPE, ctype, NULL);
if (!nm_setting_connection_get_uuid (s_con)) {
uuid = nm_utils_uuid_generate ();
g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_UUID, uuid, NULL);
g_free (uuid);
}
/* Add a connection ID if absent */
if (!nm_setting_connection_get_id (s_con)) {
id = get_new_connection_name (existing, format, preferred);
g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_ID, id, NULL);
g_free (id);
}
/* Add an 'auto' IPv4 connection if present */
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (!s_ip4) {
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
}
method = nm_setting_ip4_config_get_method (s_ip4);
if (!method) {
g_object_set (G_OBJECT (s_ip4),
NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
NULL);
}
/* Add an 'auto' IPv6 setting if allowed and not preset */
s_ip6 = nm_connection_get_setting_ip6_config (connection);
if (!s_ip6 && default_enable_ipv6) {
s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
nm_connection_add_setting (connection, NM_SETTING (s_ip6));
}
if (s_ip6 && !nm_setting_ip6_config_get_method (s_ip6)) {
g_object_set (G_OBJECT (s_ip6),
NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE,
NULL);
}
}
示例2: fill_connection
static void
fill_connection (WirelessSecurity *parent, NMConnection *connection)
{
WirelessSecurityWPAPSK *wpa_psk = (WirelessSecurityWPAPSK *) parent;
GtkWidget *widget, *passwd_entry;
const char *key;
NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec;
NMSettingSecretFlags secret_flags;
const char *mode;
gboolean is_adhoc = FALSE;
s_wireless = nm_connection_get_setting_wireless (connection);
g_assert (s_wireless);
mode = nm_setting_wireless_get_mode (s_wireless);
if (mode && !strcmp (mode, "adhoc"))
is_adhoc = TRUE;
/* Blow away the old security setting by adding a clear one */
s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec);
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_entry"));
passwd_entry = widget;
key = gtk_entry_get_text (GTK_ENTRY (widget));
g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_PSK, key, NULL);
/* Save PSK_FLAGS to the connection */
secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
nm_setting_set_secret_flags (NM_SETTING (s_wireless_sec), NM_SETTING_WIRELESS_SECURITY_PSK,
secret_flags, NULL);
/* Update secret flags and popup when editing the connection */
if (wpa_psk->editing_connection)
nma_utils_update_password_storage (passwd_entry, secret_flags,
NM_SETTING (s_wireless_sec), wpa_psk->password_flags_name);
wireless_security_clear_ciphers (connection);
if (is_adhoc) {
/* Ad-Hoc settings as specified by the supplicant */
g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-none", NULL);
nm_setting_wireless_security_add_proto (s_wireless_sec, "wpa");
nm_setting_wireless_security_add_pairwise (s_wireless_sec, "none");
/* Ad-hoc can only have _one_ group cipher... default to TKIP to be more
* compatible for now. Maybe we'll support selecting CCMP later.
*/
nm_setting_wireless_security_add_group (s_wireless_sec, "tkip");
} else {
g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", NULL);
/* Just leave ciphers and protocol empty, the supplicant will
* figure that out magically based on the AP IEs and card capabilities.
*/
}
}
示例3: add_wireless_secrets
static gboolean
add_wireless_secrets (NMSecretAgentSimpleRequest *request,
GPtrArray *secrets)
{
NMSettingWirelessSecurity *s_wsec = nm_connection_get_setting_wireless_security (request->connection);
const char *key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec);
NMSecretAgentSimpleSecret *secret;
if (!key_mgmt)
return FALSE;
if (!strcmp (key_mgmt, "wpa-none") || !strcmp (key_mgmt, "wpa-psk")) {
secret = nm_secret_agent_simple_secret_new (_("Password"),
NM_SETTING (s_wsec),
NM_SETTING_WIRELESS_SECURITY_PSK,
TRUE);
g_ptr_array_add (secrets, secret);
return TRUE;
}
if (!strcmp (key_mgmt, "none")) {
int index;
char *key;
index = nm_setting_wireless_security_get_wep_tx_keyidx (s_wsec);
key = g_strdup_printf ("wep-key%d", index);
secret = nm_secret_agent_simple_secret_new (_("Key"),
NM_SETTING (s_wsec),
key,
TRUE);
g_free (key);
g_ptr_array_add (secrets, secret);
return TRUE;
}
if (!strcmp (key_mgmt, "iee8021x")) {
if (!g_strcmp0 (nm_setting_wireless_security_get_auth_alg (s_wsec), "leap")) {
secret = nm_secret_agent_simple_secret_new (_("Password"),
NM_SETTING (s_wsec),
NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD,
TRUE);
g_ptr_array_add (secrets, secret);
return TRUE;
} else
return add_8021x_secrets (request, secrets);
}
if (!strcmp (key_mgmt, "wpa-eap"))
return add_8021x_secrets (request, secrets);
return FALSE;
}
示例4: add_8021x_secrets
static gboolean
add_8021x_secrets (NMSecretAgentSimpleRequest *request,
GPtrArray *secrets)
{
NMSetting8021x *s_8021x = nm_connection_get_setting_802_1x (request->connection);
const char *eap_method;
NMSecretAgentSimpleSecret *secret;
eap_method = nm_setting_802_1x_get_eap_method (s_8021x, 0);
if (!eap_method)
return FALSE;
if ( !strcmp (eap_method, "md5")
|| !strcmp (eap_method, "leap")
|| !strcmp (eap_method, "ttls")
|| !strcmp (eap_method, "peap")) {
/* TTLS and PEAP are actually much more complicated, but this complication
* is not visible here since we only care about phase2 authentication
* (and don't even care of which one)
*/
secret = nm_secret_agent_simple_secret_new (_("Username"),
NM_SETTING (s_8021x),
NM_SETTING_802_1X_IDENTITY,
FALSE);
g_ptr_array_add (secrets, secret);
secret = nm_secret_agent_simple_secret_new (_("Password"),
NM_SETTING (s_8021x),
NM_SETTING_802_1X_PASSWORD,
TRUE);
g_ptr_array_add (secrets, secret);
return TRUE;
}
if (!strcmp (eap_method, "tls")) {
secret = nm_secret_agent_simple_secret_new (_("Identity"),
NM_SETTING (s_8021x),
NM_SETTING_802_1X_IDENTITY,
FALSE);
g_ptr_array_add (secrets, secret);
secret = nm_secret_agent_simple_secret_new (_("Private key password"),
NM_SETTING (s_8021x),
NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD,
TRUE);
g_ptr_array_add (secrets, secret);
return TRUE;
}
return FALSE;
}
示例5: real_need_secrets
static gboolean
real_need_secrets (NMVpnServicePlugin *plugin,
NMConnection *connection,
const char **setting_name,
GError **error)
{
NMSettingVpn *s_vpn;
NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
g_return_val_if_fail (NM_IS_VPN_SERVICE_PLUGIN (plugin), FALSE);
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
s_vpn = nm_connection_get_setting_vpn (connection);
nm_setting_get_secret_flags (NM_SETTING (s_vpn), NM_SSTP_KEY_PASSWORD, &flags, NULL);
/* Don't need the password if it's not required */
if (flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED)
return FALSE;
/* Don't need the password if we already have one */
if (nm_setting_vpn_get_secret (NM_SETTING_VPN (s_vpn), NM_SSTP_KEY_PASSWORD))
return FALSE;
/* Otherwise we need a password */
*setting_name = NM_SETTING_VPN_SETTING_NAME;
return TRUE;
}
示例6: validate
static gboolean
validate (CEPage *page, NMConnection *connection, GError **error)
{
CEPageWired *self = CE_PAGE_WIRED (page);
CEPageWiredPrivate *priv = CE_PAGE_WIRED_GET_PRIVATE (self);
gboolean invalid = FALSE;
GByteArray *ignore;
GtkWidget *entry;
entry = gtk_bin_get_child (GTK_BIN (priv->device_mac));
if (entry) {
ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), &invalid);
if (invalid)
return FALSE;
if (ignore)
g_byte_array_free (ignore, TRUE);
}
ignore = ce_page_entry_to_mac (priv->cloned_mac, &invalid);
if (invalid)
return FALSE;
if (ignore)
g_byte_array_free (ignore, TRUE);
ui_to_setting (self);
return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}
示例7: ce_page_validate_v
static gboolean
ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
{
CEPageWifi *self = CE_PAGE_WIFI (page);
CEPageWifiPrivate *priv = CE_PAGE_WIFI_GET_PRIVATE (self);
gboolean success;
GtkWidget *entry;
entry = gtk_bin_get_child (GTK_BIN (priv->bssid));
if (entry) {
if (!ce_page_mac_entry_valid (GTK_ENTRY (entry), ARPHRD_ETHER, _("bssid"), error))
return FALSE;
}
entry = gtk_bin_get_child (GTK_BIN (priv->device_combo));
if (entry) {
if (!ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, TRUE, NULL, NULL, _("Wi-Fi device"), error))
return FALSE;
}
if (!ce_page_mac_entry_valid (priv->cloned_mac, ARPHRD_ETHER, _("cloned MAC"), error))
return FALSE;
ui_to_setting (self);
success = nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
return success;
}
示例8: ce_page_complete_connection
void
ce_page_complete_connection (NMConnection *connection,
const char *format,
const char *ctype,
gboolean autoconnect,
NMClient *client)
{
NMSettingConnection *s_con;
char *id, *uuid;
const GPtrArray *connections;
s_con = nm_connection_get_setting_connection (connection);
if (!s_con) {
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
nm_connection_add_setting (connection, NM_SETTING (s_con));
}
if (!nm_setting_connection_get_id (s_con)) {
connections = nm_client_get_connections (client);
id = ce_page_get_next_available_name (connections, format);
g_object_set (s_con, NM_SETTING_CONNECTION_ID, id, NULL);
g_free (id);
}
uuid = nm_utils_uuid_generate ();
g_object_set (s_con,
NM_SETTING_CONNECTION_UUID, uuid,
NM_SETTING_CONNECTION_TYPE, ctype,
NM_SETTING_CONNECTION_AUTOCONNECT, autoconnect,
NULL);
g_free (uuid);
}
示例9: complete_connection
static gboolean
complete_connection (NMDevice *device,
NMConnection *connection,
const char *specific_object,
const GSList *existing_connections,
GError **error)
{
NMSettingTeam *s_team;
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_TEAM_SETTING_NAME,
existing_connections,
NULL,
_("Team connection"),
"team",
TRUE);
s_team = nm_connection_get_setting_team (connection);
if (!s_team) {
s_team = (NMSettingTeam *) nm_setting_team_new ();
nm_connection_add_setting (connection, NM_SETTING (s_team));
}
return TRUE;
}
示例10: validate
static gboolean
validate (CEPage *page,
NMConnection *connection,
GError **error)
{
GtkWidget *entry;
GByteArray *ignore;
gboolean invalid;
gchar *security;
NMSettingWireless *setting;
gboolean ret = TRUE;
entry = gtk_bin_get_child (GTK_BIN (gtk_builder_get_object (page->builder, "combo_bssid")));
ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, &invalid);
if (invalid) {
widget_set_error (entry);
ret = FALSE;
} else {
if (ignore)
g_byte_array_free (ignore, TRUE);
widget_unset_error (entry);
}
entry = gtk_bin_get_child (GTK_BIN (gtk_builder_get_object (page->builder, "combo_mac")));
ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, &invalid);
if (invalid) {
widget_set_error (entry);
ret = FALSE;
} else {
if (ignore)
g_byte_array_free (ignore, TRUE);
widget_unset_error (entry);
}
entry = GTK_WIDGET (gtk_builder_get_object (page->builder, "entry_cloned_mac"));
ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, &invalid);
if (invalid) {
widget_set_error (entry);
ret = FALSE;
} else {
if (ignore)
g_byte_array_free (ignore, TRUE);
widget_unset_error (entry);
}
if (!ret)
return ret;
ui_to_setting (CE_PAGE_WIFI (page));
/* A hack to not check the wifi security here */
setting = CE_PAGE_WIFI (page)->setting;
security = g_strdup (nm_setting_wireless_get_security (setting));
g_object_set (setting, NM_SETTING_WIRELESS_SEC, NULL, NULL);
ret = nm_setting_verify (NM_SETTING (setting), NULL, error);
g_object_set (setting, NM_SETTING_WIRELESS_SEC, security, NULL);
g_free (security);
return ret;
}
示例11: setup_password_widget
static void
setup_password_widget (OpenswanPluginUiWidget *self,
const char *entry_name,
NMSettingVPN *s_vpn,
const char *secret_name,
gboolean new_connection)
{
OpenswanPluginUiWidgetPrivate *priv = OPENSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
GtkWidget *widget;
const char *value;
if (new_connection)
secret_flags = NM_SETTING_SECRET_FLAG_AGENT_OWNED;
widget = (GtkWidget *) gtk_builder_get_object (priv->builder, entry_name);
g_assert (widget);
gtk_size_group_add_widget (priv->group, widget);
if (s_vpn) {
value = nm_setting_vpn_get_secret (s_vpn, secret_name);
gtk_entry_set_text (GTK_ENTRY (widget), value ? value : "");
nm_setting_get_secret_flags (NM_SETTING (s_vpn), secret_name, &secret_flags, NULL);
}
secret_flags &= ~(NM_SETTING_SECRET_FLAG_NOT_SAVED | NM_SETTING_SECRET_FLAG_NOT_REQUIRED);
g_object_set_data (G_OBJECT (widget), "flags", GUINT_TO_POINTER (secret_flags));
g_signal_connect (widget, "changed", G_CALLBACK (stuff_changed_cb), self);
}
示例12: complete_connection
static gboolean
complete_connection (NMDevice *device,
NMConnection *connection,
const char *specific_object,
const GSList *existing_connections,
GError **error)
{
NMSettingBridge *s_bridge;
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_BRIDGE_SETTING_NAME,
existing_connections,
NULL,
_("Bridge connection"),
"bridge",
TRUE);
s_bridge = nm_connection_get_setting_bridge (connection);
if (!s_bridge) {
s_bridge = (NMSettingBridge *) nm_setting_bridge_new ();
nm_connection_add_setting (connection, NM_SETTING (s_bridge));
}
return TRUE;
}
示例13: validate
static gboolean
validate (CEPage *page, NMConnection *connection, GError **error)
{
CEPageWireless *self = CE_PAGE_WIRELESS (page);
CEPageWirelessPrivate *priv = CE_PAGE_WIRELESS_GET_PRIVATE (self);
char *security;
gboolean success;
gboolean invalid = FALSE;
GByteArray *ignore;
ignore = ce_page_entry_to_mac (priv->bssid, &invalid);
if (invalid)
return FALSE;
ignore = ce_page_entry_to_mac (priv->mac, &invalid);
if (invalid)
return FALSE;
ui_to_setting (self);
/* A hack to not check the wireless security here */
security = g_strdup (nm_setting_wireless_get_security (priv->setting));
g_object_set (priv->setting, NM_SETTING_WIRELESS_SEC, NULL, NULL);
success = nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
g_object_set (priv->setting, NM_SETTING_WIRELESS_SEC, security, NULL);
g_free (security);
return success;
}
示例14: nm_team_update_slave_connection
gboolean
nm_team_update_slave_connection (NMDevice *slave, NMConnection *connection)
{
NMSettingTeamPort *s_port;
const char *iface = nm_device_get_iface (slave);
char *port_config = NULL;
gboolean with_teamdctl = FALSE;
int err = 0;
#if WITH_TEAMDCTL
const char *master_iface;
int master_ifindex;
struct teamdctl *tdc;
const char *team_port_config = NULL;
#endif
g_return_val_if_fail (NM_IS_DEVICE (slave), FALSE);
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
#if WITH_TEAMDCTL
master_ifindex = nm_platform_link_get_master (nm_device_get_ifindex (slave));
g_assert (master_ifindex > 0);
master_iface = nm_platform_link_get_name (master_ifindex);
g_assert (master_iface);
tdc = teamdctl_alloc ();
g_assert (tdc);
err = teamdctl_connect (tdc, master_iface, NULL, NULL);
if (err) {
nm_log_err (LOGD_TEAM, "(%s): failed to connect to teamd for master %s (err=%d)",
iface, master_iface, err);
teamdctl_free (tdc);
return FALSE;
}
err = teamdctl_port_config_get_raw_direct (tdc, iface, (char **)&team_port_config);
port_config = g_strdup (team_port_config);
teamdctl_free (tdc);
with_teamdctl = TRUE;
#endif
s_port = nm_connection_get_setting_team_port (connection);
if (!s_port) {
s_port = (NMSettingTeamPort *) nm_setting_team_port_new ();
nm_connection_add_setting (connection, NM_SETTING (s_port));
}
g_object_set (G_OBJECT (s_port), NM_SETTING_TEAM_PORT_CONFIG, port_config, NULL);
g_free (port_config);
if (!with_teamdctl || err != 0) {
if (!with_teamdctl)
nm_log_err (LOGD_TEAM, "(%s): failed to read teamd port configuration "
" (compiled without libteamdctl support)", iface);
else
nm_log_err (LOGD_TEAM, "(%s): failed to read teamd port configuration (err=%d)",
iface, err);
return FALSE;
}
return TRUE;
}
示例15: ce_page_wired_new
CEPage *
ce_page_wired_new (NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
GError **error)
{
CEPageWired *self;
CEPageWiredPrivate *priv;
self = CE_PAGE_WIRED (ce_page_new (CE_TYPE_PAGE_WIRED,
connection,
parent_window,
client,
UIDIR "/ce-page-wired.ui",
"WiredPage",
_("Wired")));
if (!self) {
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load wired user interface."));
return NULL;
}
wired_private_init (self);
priv = CE_PAGE_WIRED_GET_PRIVATE (self);
priv->setting = nm_connection_get_setting_wired (connection);
if (!priv->setting) {
priv->setting = NM_SETTING_WIRED (nm_setting_wired_new ());
nm_connection_add_setting (connection, NM_SETTING (priv->setting));
}
g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL);
return CE_PAGE (self);
}