1 module soup.SessionFeatureT;
2 
3 public  import soup.Session;
4 public  import soup.c.functions;
5 public  import soup.c.types;
6 
7 
8 /**
9  * #SoupSessionFeature is the interface used by classes that extend
10  * the functionality of a #SoupSession. Some features like HTTP
11  * authentication handling are implemented internally via
12  * #SoupSessionFeature<!-- -->s. Other features can be added to the session
13  * by the application. (Eg, #SoupLogger, #SoupCookieJar.)
14  * 
15  * See soup_session_add_feature(), etc, to add a feature to a session.
16  *
17  * Since: 2.24
18  */
19 public template SessionFeatureT(TStruct)
20 {
21 	/** Get the main Gtk struct */
22 	public SoupSessionFeature* getSessionFeatureStruct(bool transferOwnership = false)
23 	{
24 		if (transferOwnership)
25 			ownedRef = false;
26 		return cast(SoupSessionFeature*)getStruct();
27 	}
28 
29 
30 	/**
31 	 * Adds a "sub-feature" of type @type to the base feature @feature.
32 	 * This is used for features that can be extended with multiple
33 	 * different types. Eg, the authentication manager can be extended
34 	 * with subtypes of #SoupAuth.
35 	 *
36 	 * Params:
37 	 *     type = the #GType of a "sub-feature"
38 	 *
39 	 * Returns: %TRUE if @feature accepted @type as a subfeature.
40 	 *
41 	 * Since: 2.34
42 	 */
43 	public bool addFeature(GType type)
44 	{
45 		return soup_session_feature_add_feature(getSessionFeatureStruct(), type) != 0;
46 	}
47 
48 	/** */
49 	public void attach(Session session)
50 	{
51 		soup_session_feature_attach(getSessionFeatureStruct(), (session is null) ? null : session.getSessionStruct());
52 	}
53 
54 	/** */
55 	public void detach(Session session)
56 	{
57 		soup_session_feature_detach(getSessionFeatureStruct(), (session is null) ? null : session.getSessionStruct());
58 	}
59 
60 	/**
61 	 * Tests if @feature has a "sub-feature" of type @type. See
62 	 * soup_session_feature_add_feature().
63 	 *
64 	 * Params:
65 	 *     type = the #GType of a "sub-feature"
66 	 *
67 	 * Returns: %TRUE if @feature has a subfeature of type @type
68 	 *
69 	 * Since: 2.34
70 	 */
71 	public bool hasFeature(GType type)
72 	{
73 		return soup_session_feature_has_feature(getSessionFeatureStruct(), type) != 0;
74 	}
75 
76 	/**
77 	 * Removes the "sub-feature" of type @type from the base feature
78 	 * @feature. See soup_session_feature_add_feature().
79 	 *
80 	 * Params:
81 	 *     type = the #GType of a "sub-feature"
82 	 *
83 	 * Returns: %TRUE if @type was removed from @feature
84 	 *
85 	 * Since: 2.34
86 	 */
87 	public bool removeFeature(GType type)
88 	{
89 		return soup_session_feature_remove_feature(getSessionFeatureStruct(), type) != 0;
90 	}
91 }