We assume that, if we cannot write temporary file to view, it's that
[modest] / src / modest-protocol.h
1 /* Copyright (c) 2008, Nokia Corporation
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  *   notice, this list of conditions and the following disclaimer in the
12  *   documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Nokia Corporation nor the names of its
14  *   contributors may be used to endorse or promote products derived from
15  *   this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30
31 /* modest-account-settings.h */
32
33 #ifndef __MODEST_PROTOCOL_H__
34 #define __MODEST_PROTOCOL_H__
35
36 #include <glib-object.h>
37 #include <glib/gi18n.h>
38
39 G_BEGIN_DECLS
40
41 /* convenience macros */
42 #define MODEST_TYPE_PROTOCOL             (modest_protocol_get_type())
43 #define MODEST_PROTOCOL(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_PROTOCOL,ModestProtocol))
44 #define MODEST_PROTOCOL_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_PROTOCOL,ModestProtocolClass))
45 #define MODEST_IS_PROTOCOL(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_PROTOCOL))
46 #define MODEST_IS_PROTOCOL_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_PROTOCOL))
47 #define MODEST_PROTOCOL_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_PROTOCOL,ModestProtocolClass))
48
49 #define MODEST_PROTOCOL_TYPE_INVALID -1
50
51 typedef gchar * (*TranslationFunc) (gpointer userdata, va_list args);
52
53 typedef struct _ModestProtocol      ModestProtocol;
54 typedef struct _ModestProtocolClass ModestProtocolClass;
55
56 typedef guint ModestProtocolType;
57
58 struct _ModestProtocol {
59         GObject parent;
60 };
61
62 struct _ModestProtocolClass {
63         GObjectClass parent_class;
64 };
65
66 /**
67  * modest_protocol_get_type:
68  *
69  * Returns: GType of the account store
70  */
71 GType  modest_protocol_get_type   (void) G_GNUC_CONST;
72
73 /**
74  * modest_protocol_new:
75  *
76  * creates a new instance of #ModestProtocol
77  *
78  * Returns: a #ModestProtocol
79  */
80 ModestProtocol*    modest_protocol_new (const gchar *name, const gchar *display_name);
81
82 /**
83  * modest_protocol_get_name:
84  * @self: a #ModestProtocol
85  *
86  * get the protocol unique name (used for storing conf and identifying the protocol with a string)
87  *
88  * Returns: a string
89  */
90 const gchar* modest_protocol_get_name (ModestProtocol *self);
91
92 /**
93  * modest_protocol_set_name:
94  * @self: a #ModestProtocol
95  * @name: the protocol unique name.
96  *
97  * set @name as the protocol unique name .
98  */
99 void         modest_protocol_set_name (ModestProtocol *self,
100                                        const gchar *name);
101 /**
102  * modest_protocol_get_display_name:
103  * @self: a #ModestProtocol
104  *
105  * get the display name for the protocol
106  *
107  * Returns: a string
108  */
109 const gchar* modest_protocol_get_display_name (ModestProtocol *self);
110
111 /**
112  * modest_protocol_set_display_name:
113  * @settings: a #ModestProtocol
114  * @display_name: a string.
115  *
116  * set @display_name of the account.
117  */
118 void         modest_protocol_set_display_name (ModestProtocol *protocol,
119                                                 const gchar *display_name);
120 /**
121  * modest_protocol_get_type_id:
122  * @self: a #ModestProtocol
123  *
124  * get the protocol type id.
125  *
126  * Returns: a #ModestProtocolType
127  */
128 ModestProtocolType modest_protocol_get_type_id (ModestProtocol *self);
129
130 /**
131  * modest_protocol_get:
132  * @protocol: a #ModestProtocol
133  * @key: a string
134  *
135  * obtains the value of @key for @protocol
136  *
137  * Returns: a string
138  */
139 const gchar *
140 modest_protocol_get (ModestProtocol *protocol,
141                      const gchar *key);
142
143 /**
144  * modest_protocol_set:
145  * @protocol: a #ModestProtocol
146  * @key: a string
147  * @value: a string
148  *
149  * sets @value as the value for @key in @protocol
150  */
151 void
152 modest_protocol_set (ModestProtocol *protocol,
153                      const gchar *key, const gchar *value);
154
155 /**
156  * modest_protocol_set_translation:
157  * @protocol: a #ModestProtocol
158  * @id: the id for the translation set
159  * @translation_func: the function used to obtain the translation
160  *
161  * sets @translation_func as the way to compose the translation for @id
162  */
163 void
164 modest_protocol_set_translation (ModestProtocol *protocol,
165                                  const gchar *id,
166                                  TranslationFunc translation_func,
167                                  gpointer userdata,
168                                  GDestroyNotify data_destroy_func);
169
170 /**
171  * modest_protocol_get_translation:
172  * @protocol: a @ModestProtocol
173  * @id: the id for the translation set
174  * @...: the parameters for the translation (pritntf style)
175  *
176  * applies the translation with parameters to obtain the full string expected.
177  *
178  * Returns: a newly allocated string
179  */
180 gchar *
181 modest_protocol_get_translation (ModestProtocol *protocol,
182                                  const gchar *id,
183                                  ...);
184
185 /**
186  * modest_protocol_va_get_translation:
187  * @protocol: a @ModestProtocol
188  * @id: the id for the translation set
189  * @args: a @va_list of the parameters for the translation
190  *
191  * applies the translation with parameters to obtain the full string expected.
192  *
193  * Returns: a newly allocated string
194  */
195 gchar *
196 modest_protocol_va_get_translation (ModestProtocol *protocol,
197                                     const gchar *id,
198                                     va_list args);
199
200 G_END_DECLS
201
202 #endif /* __MODEST_PROTOCOL_H__ */