/** * camel_network_settings_get_auth_mechanism: * @settings: a #CamelNetworkSettings * * Returns the mechanism name used to authenticate to a network service. * Often this refers to a SASL mechanism such as "LOGIN" or "GSSAPI". * * Returns: the authentication mechanism name * * Since: 3.4 **/ const gchar * camel_network_settings_get_auth_mechanism (CamelNetworkSettings *settings) { g_return_val_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings), NULL); return g_object_get_data (G_OBJECT (settings), AUTH_MECHANISM_KEY); }
static EGwConnection * get_cnc (GtkWindow *parent_window) { CamelNetworkSettings *network_settings; const gchar *failed_auth; gchar *uri, *key, *prompt, *password = NULL; CamelNetworkSecurityMethod security_method; const gchar *scheme; const gchar *host; const gchar *user; gboolean remember; gchar *soap_port; if (!CAMEL_IS_NETWORK_SETTINGS (settings)) return NULL; network_settings = CAMEL_NETWORK_SETTINGS (settings); host = camel_network_settings_get_host (network_settings); user = camel_network_settings_get_user (network_settings); if (host == NULL || *host == '\0') return NULL; if (user == NULL || *user == '\0') return NULL; g_object_get ( settings, "soap-port", &soap_port, "security-method", &security_method, NULL); if (security_method == CAMEL_NETWORK_SECURITY_METHOD_NONE) scheme = "http"; else scheme = "https"; key = g_strdup_printf ("groupwise://%s@%s/", user, host); uri = g_strdup_printf ("%s://%s:%s/soap", scheme, host, soap_port); failed_auth = ""; prompt = g_strdup_printf (_("%sEnter password for %s (user %s)"), failed_auth, host, user); password = e_passwords_get_password (NULL, key); if (!password) password = e_passwords_ask_password (prompt, NULL, key, prompt, E_PASSWORDS_REMEMBER_FOREVER | E_PASSWORDS_SECRET, &remember, parent_window); g_free (prompt); return e_gw_connection_new (uri, user, password); }
/** * camel_network_settings_dup_auth_mechanism: * @settings: a #CamelNetworkSettings * * Thread-safe variation of camel_network_settings_get_auth_mechanism(). * Use this function when accessing @settings from multiple threads. * * The returned string should be freed with g_free() when no longer needed. * * Returns: a newly-allocated copy of #CamelNetworkSettings:auth-mechanism * * Since: 3.4 **/ gchar * camel_network_settings_dup_auth_mechanism (CamelNetworkSettings *settings) { const gchar *protected; gchar *duplicate; g_return_val_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings), NULL); G_LOCK (property_lock); protected = camel_network_settings_get_auth_mechanism (settings);
static gchar * format_service_name (CamelService *service) { CamelProvider *provider; CamelSettings *settings; gchar *service_name = NULL; const gchar *display_name; gchar *pretty_url = NULL; gchar *host = NULL; gchar *path = NULL; gchar *user = NULL; gchar *cp; gboolean have_host = FALSE; gboolean have_path = FALSE; gboolean have_user = FALSE; provider = camel_service_get_provider (service); display_name = camel_service_get_display_name (service); settings = camel_service_ref_settings (service); if (CAMEL_IS_NETWORK_SETTINGS (settings)) { host = camel_network_settings_dup_host ( CAMEL_NETWORK_SETTINGS (settings)); have_host = (host != NULL) && (*host != '\0'); user = camel_network_settings_dup_user ( CAMEL_NETWORK_SETTINGS (settings)); have_user = (user != NULL) && (*user != '\0'); } if (CAMEL_IS_LOCAL_SETTINGS (settings)) { path = camel_local_settings_dup_path ( CAMEL_LOCAL_SETTINGS (settings)); have_path = (path != NULL) && (*path != '\0'); } g_object_unref (settings); /* Shorten user names with '@', since multiple '@' in a * 'user@host' label look weird. This is just supposed * to be a hint anyway so it doesn't matter if it's not * strictly correct. */ if (have_user && (cp = strchr (user, '@')) != NULL) *cp = '\0'; g_return_val_if_fail (provider != NULL, NULL); /* This should never happen, but if the service has no * display name, fall back to the generic service name. */ if (display_name == NULL || *display_name == '\0') { service_name = camel_service_get_name (service, TRUE); display_name = service_name; } if (have_host && have_user) { pretty_url = g_markup_printf_escaped ( "<b>%s</b> <small>(%s@%s)</small>", display_name, user, host); } else if (have_host) { pretty_url = g_markup_printf_escaped ( "<b>%s</b> <small>(%s)</small>", display_name, host); } else if (have_path) { pretty_url = g_markup_printf_escaped ( "<b>%s</b> <small>(%s)</small>", display_name, path); } else { pretty_url = g_markup_printf_escaped ( "<b>%s</b>", display_name); } g_free (service_name); g_free (host); g_free (path); g_free (user); return pretty_url; }