SoupMessage *msg, SoupSocket *socket);
static void request_unqueued (SoupSessionFeature *feature,
SoupSession *session, SoupMessage *msg);
+static gboolean add_feature (SoupSessionFeature *feature, GType type);
+static gboolean remove_feature (SoupSessionFeature *feature, GType type);
+static gboolean has_feature (SoupSessionFeature *feature, GType type);
G_DEFINE_TYPE_WITH_CODE (SoupAuthManagerNTLM, soup_auth_manager_ntlm, SOUP_TYPE_AUTH_MANAGER,
G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
soup_auth_manager_ntlm_session_feature_init))
-enum {
- PROP_0,
-
- PROP_USE_NTLM,
-
- LAST_PROP
-};
-
typedef enum {
SOUP_NTLM_NEW,
SOUP_NTLM_SENT_REQUEST,
const char *host,
const char *domain);
-static void set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-
static void
soup_auth_manager_ntlm_init (SoupAuthManagerNTLM *ntlm)
{
g_type_class_add_private (auth_manager_ntlm_class, sizeof (SoupAuthManagerNTLMPrivate));
object_class->finalize = finalize;
- object_class->set_property = set_property;
- object_class->get_property = get_property;
-
- g_object_class_install_property (
- object_class, PROP_USE_NTLM,
- g_param_spec_boolean (SOUP_AUTH_MANAGER_NTLM_USE_NTLM,
- "Use NTLM",
- "Whether or not to use NTLM authentication",
- FALSE,
- G_PARAM_READWRITE));
}
static void
feature_interface->request_queued = request_queued;
feature_interface->request_started = request_started;
feature_interface->request_unqueued = request_unqueued;
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- SoupAuthManagerNTLMPrivate *priv =
- SOUP_AUTH_MANAGER_NTLM_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_USE_NTLM:
- priv->use_ntlm = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- SoupAuthManagerNTLMPrivate *priv =
- SOUP_AUTH_MANAGER_NTLM_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_USE_NTLM:
- g_value_set_boolean (value, priv->use_ntlm);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ feature_interface->add_feature = add_feature;
+ feature_interface->remove_feature = remove_feature;
+ feature_interface->has_feature = has_feature;
}
static void
soup_auth_manager_parent_feature_interface->request_unqueued (ntlm, session, msg);
}
+static gboolean
+add_feature (SoupSessionFeature *feature, GType type)
+{
+ SoupAuthManagerNTLMPrivate *priv =
+ SOUP_AUTH_MANAGER_NTLM_GET_PRIVATE (feature);
+
+ if (type == SOUP_TYPE_AUTH_NTLM) {
+ priv->use_ntlm = TRUE;
+ return TRUE;
+ }
+
+ return soup_auth_manager_parent_feature_interface->add_feature (feature, type);
+}
+
+static gboolean
+remove_feature (SoupSessionFeature *feature, GType type)
+{
+ SoupAuthManagerNTLMPrivate *priv =
+ SOUP_AUTH_MANAGER_NTLM_GET_PRIVATE (feature);
+
+ if (type == SOUP_TYPE_AUTH_NTLM) {
+ priv->use_ntlm = FALSE;
+ return TRUE;
+ }
+
+ return soup_auth_manager_parent_feature_interface->remove_feature (feature, type);
+}
+
+static gboolean
+has_feature (SoupSessionFeature *feature, GType type)
+{
+ SoupAuthManagerNTLMPrivate *priv =
+ SOUP_AUTH_MANAGER_NTLM_GET_PRIVATE (feature);
+
+ if (type == SOUP_TYPE_AUTH_NTLM)
+ return priv->use_ntlm;
+
+ return soup_auth_manager_parent_feature_interface->has_feature (feature, type);
+}
/* NTLM code */
priv->features_cache = g_hash_table_new (NULL, NULL);
- auth_manager = g_object_new (SOUP_TYPE_AUTH_MANAGER_NTLM,
- SOUP_AUTH_MANAGER_NTLM_USE_NTLM, FALSE,
- NULL);
+ auth_manager = g_object_new (SOUP_TYPE_AUTH_MANAGER_NTLM, NULL);
g_signal_connect (auth_manager, "authenticate",
G_CALLBACK (auth_manager_authenticate), session);
soup_session_feature_add_feature (SOUP_SESSION_FEATURE (auth_manager),
0, G_MAXUINT, 0,
G_PARAM_READWRITE));
/**
+ * SoupSession:use-ntlm:
+ *
+ * Whether or not to use NTLM authentication.
+ *
+ * Deprecated: use soup_session_add_feature_by_type() with
+ * #SOUP_TYPE_AUTH_NTLM.
+ **/
+ /**
* SOUP_SESSION_USE_NTLM:
*
* Alias for the #SoupSession:use-ntlm property. (Whether or
case PROP_USE_NTLM:
feature = soup_session_get_feature (session, SOUP_TYPE_AUTH_MANAGER_NTLM);
if (feature) {
- g_object_set_property (G_OBJECT (feature),
- SOUP_AUTH_MANAGER_NTLM_USE_NTLM,
- value);
+ if (g_value_get_boolean (value))
+ soup_session_feature_add_feature (feature, SOUP_TYPE_AUTH_NTLM);
+ else
+ soup_session_feature_remove_feature (feature, SOUP_TYPE_AUTH_NTLM);
} else
g_warning ("Trying to set use-ntlm on session with no auth-manager");
break;
break;
case PROP_USE_NTLM:
feature = soup_session_get_feature (session, SOUP_TYPE_AUTH_MANAGER_NTLM);
- if (feature) {
- g_object_get_property (G_OBJECT (feature),
- SOUP_AUTH_MANAGER_NTLM_USE_NTLM,
- value);
- } else
+ if (feature)
+ g_value_set_boolean (value, soup_session_feature_has_feature (feature, SOUP_TYPE_AUTH_NTLM));
+ else
g_value_set_boolean (value, FALSE);
break;
case PROP_SSL_CA_FILE: