core: Nullability fixes
[platform/upstream/folks.git] / folks / web-service-details.vala
1 /*
2  * Copyright (C) 2011 Collabora Ltd.
3  * Copyright (C) 2011 Philip Withnall
4  *
5  * This library is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 2.1 of the License, or
8  * (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Authors:
19  *       Alban Crequy <alban.crequy@collabora.co.uk>
20  *       Philip Withnall <philip@tecnocode.co.uk>
21  */
22
23 using Gee;
24
25 /**
26  * Object representing a web service contact that can have some parameters
27  * associated with it.
28  *
29  * See {@link Folks.AbstractFieldDetails}.
30  *
31  * @since 0.6.0
32  */
33 public class Folks.WebServiceFieldDetails : AbstractFieldDetails<string>
34 {
35   /**
36    * Create a new WebServiceFieldDetails.
37    *
38    * @param value the value of the field, a non-empty web service address
39    * @param parameters initial parameters. See
40    * {@link AbstractFieldDetails.parameters}. A `null` value is equivalent to an
41    * empty map of parameters.
42    *
43    * @return a new WebServiceFieldDetails
44    *
45    * @since 0.6.0
46    */
47   public WebServiceFieldDetails (string value,
48       MultiMap<string, string>? parameters = null)
49     {
50       if (value == "")
51         {
52           warning ("Empty web service address passed to " +
53               "WebServiceFieldDetails.");
54         }
55
56       Object (value: value,
57               parameters: parameters);
58     }
59
60   /**
61    * {@inheritDoc}
62    *
63    * @since 0.6.0
64    */
65   public override bool equal (AbstractFieldDetails<string> that)
66     {
67       return base.equal (that);
68     }
69
70   /**
71    * {@inheritDoc}
72    *
73    * @since 0.6.0
74    */
75   public override uint hash ()
76     {
77       return base.hash ();
78     }
79 }
80
81 /**
82  * Web service contact details.
83  *
84  * @since 0.5.0
85  */
86 public interface Folks.WebServiceDetails : Object
87 {
88   /**
89    * A mapping of web service to an (unordered) set of web service addresses.
90    *
91    * Each mapping is from an arbitrary web service identifier to a set of web
92    * service addresses for the contact, listed in no particular order.
93    *
94    * Web service addresses are guaranteed to be unique per web service, but
95    * not necessarily unique amongst all web services.
96    *
97    * @since 0.6.0
98    */
99   public abstract
100     Gee.MultiMap<string, WebServiceFieldDetails> web_service_addresses
101     {
102       get; set;
103     }
104
105   /**
106    * Change the contact's web service addresses.
107    *
108    * It's preferred to call this rather than setting
109    * {@link WebServiceDetails.web_service_addresses} directly, as this method
110    * gives error notification and will only return once the addresses have been
111    * written to the relevant backing store (or the operation's failed).
112    *
113    * @param web_service_addresses the set of addresses
114    * @throws PropertyError if setting the addresses failed
115    * @since 0.6.2
116    */
117   public virtual async void change_web_service_addresses (
118       MultiMap<string, WebServiceFieldDetails> web_service_addresses)
119           throws PropertyError
120     {
121       /* Default implementation. */
122       throw new PropertyError.NOT_WRITEABLE (
123           _("Web service addresses are not writeable on this contact."));
124     }
125 }