add these to query session features. #565392.
authorDan Winship <danw@src.gnome.org>
Tue, 23 Dec 2008 19:21:08 +0000 (19:21 +0000)
committerDan Winship <danw@src.gnome.org>
Tue, 23 Dec 2008 19:21:08 +0000 (19:21 +0000)
* libsoup/soup-session.c (soup_session_get_features)
(soup_session_get_feature): add these to query session features.
#565392.

svn path=/trunk/; revision=1223

ChangeLog
libsoup/soup-session.c
libsoup/soup-session.h

index bb3a077..8e92bf8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2008-12-23  Dan Winship  <danw@gnome.org>
 
+       * libsoup/soup-session.c (soup_session_get_features)
+       (soup_session_get_feature): add these to query session features.
+       #565392.
+
+2008-12-23  Dan Winship  <danw@gnome.org>
+
        * configure.in: add some more warning CFLAGS, inspired by Benjamin
        Otte's blog post, although none of them picked out any actual
        bugs. Annoyingly, the most interesting warnings came from
index 7454071..2ea721c 100644 (file)
@@ -1436,6 +1436,62 @@ restart:
        }
 }
 
+/**
+ * soup_session_get_features:
+ * @session: a #SoupSession
+ * @feature_type: the #GType of the class of features to get
+ *
+ * Generates a list of @session's features of type @feature_type. (If
+ * you want to see all features, you can pass %G_TYPE_SESSION_FEATURE
+ * for @feature_type.)
+ *
+ * Return value: a list of features. You must free the list, but not
+ * its contents
+ **/
+GSList *
+soup_session_get_features (SoupSession *session, GType feature_type)
+{
+       SoupSessionPrivate *priv;
+       GSList *f, *ret;
+
+       g_return_val_if_fail (SOUP_IS_SESSION (session), NULL);
+
+       priv = SOUP_SESSION_GET_PRIVATE (session);
+       for (f = priv->features, ret = NULL; f; f = f->next) {
+               if (G_TYPE_CHECK_INSTANCE_TYPE (f->data, feature_type))
+                       ret = g_slist_prepend (ret, f->data);
+       }
+       return g_slist_reverse (ret);
+}
+
+/**
+ * soup_session_get_feature:
+ * @session: a #SoupSession
+ * @feature_type: the #GType of the feature to get
+ *
+ * Gets the first feature in @session of type @feature_type. For
+ * features where there may be more than one feature of a given type,
+ * use soup_session_get_features().
+ *
+ * Return value: a #SoupSessionFeature, or %NULL. The feature is owned
+ * by @session.
+ **/
+SoupSessionFeature *
+soup_session_get_feature (SoupSession *session, GType feature_type)
+{
+       SoupSessionPrivate *priv;
+       GSList *f;
+
+       g_return_val_if_fail (SOUP_IS_SESSION (session), NULL);
+
+       priv = SOUP_SESSION_GET_PRIVATE (session);
+       for (f = priv->features; f; f = f->next) {
+               if (G_TYPE_CHECK_INSTANCE_TYPE (f->data, feature_type))
+                       return f->data;
+       }
+       return NULL;
+}
+
 SoupProxyResolver *
 soup_session_get_proxy_resolver (SoupSession *session)
 {
index d1add92..54ced7d 100644 (file)
@@ -91,14 +91,18 @@ void            soup_session_cancel_message   (SoupSession           *session,
 void            soup_session_abort            (SoupSession           *session);
 
 
-void            soup_session_add_feature            (SoupSession        *session,
-                                                    SoupSessionFeature *feature);
-void            soup_session_add_feature_by_type    (SoupSession        *session,
-                                                    GType               feature_type);
-void            soup_session_remove_feature         (SoupSession        *session,
-                                                    SoupSessionFeature *feature);
-void            soup_session_remove_feature_by_type (SoupSession        *session,
-                                                    GType               feature_type);
+void                soup_session_add_feature            (SoupSession        *session,
+                                                        SoupSessionFeature *feature);
+void                soup_session_add_feature_by_type    (SoupSession        *session,
+                                                        GType               feature_type);
+void                soup_session_remove_feature         (SoupSession        *session,
+                                                        SoupSessionFeature *feature);
+void                soup_session_remove_feature_by_type (SoupSession        *session,
+                                                        GType               feature_type);
+GSList             *soup_session_get_features           (SoupSession        *session,
+                                                        GType               feature_type);
+SoupSessionFeature *soup_session_get_feature            (SoupSession        *session,
+                                                        GType               feature_type);
 
 G_END_DECLS