2007-05-15 Murray Cumming <murrayc@murrayc.com>
[modest] / src / maemo / easysetup / modest-presets.h
1 /* Copyright (c) 2006, 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 #ifndef __MODEST_PRESETS_H__
31 #define __MODEST_PRESETS_H__
32
33 #include <glib.h>
34
35 struct _ModestPresets {
36 /* private data: don't touch */
37         GKeyFile *keyfile;
38 };
39 typedef struct _ModestPresets ModestPresets;
40
41 typedef enum _ModestPresetsServerType {
42         MODEST_PRESETS_SERVER_TYPE_NONE,
43         MODEST_PRESETS_SERVER_TYPE_IMAP,
44         MODEST_PRESETS_SERVER_TYPE_POP,
45         MODEST_PRESETS_SERVER_TYPE_SMTP
46 } ModestPresetsServerType;
47
48 /** These are flags, which should be ORed.
49  */
50 typedef enum _ModestPresetsSecurity {
51         MODEST_PRESETS_SECURITY_NONE = 0,
52         MODEST_PRESETS_SECURITY_APOP = 1 << 0,
53         MODEST_PRESETS_SECURITY_SECURE_SMTP = 1 << 1,
54         MODEST_PRESETS_SECURITY_SECURE_INCOMING = 1 << 2
55 } ModestPresetsSecurity;
56
57 /* typedef enum _ModestPresetsInfo ModestPresetsInfo; */
58
59
60 /**
61  * modest_presets_new:
62  * @presetfile: the full path to the file with presets (in GKeyFile format)
63  * 
64  * make a new ModestPresets instance
65  *
66  * Returns: a new ModestPresets instance, or NULL in case of error.
67  */
68 ModestPresets*            modest_presets_new             (const gchar *presetfile);
69
70
71 /**
72  * modest_presets_get_providers:
73  * @self: a valid ModestPresets instance
74  * @mcc: limit the search to providers with this mcc (Mobile Country Code),
75  *       or 0  to get all
76  * @include_globals: include (global) providers without MCC (such as GMail, Yahoo)
77  * @provider_ids: Output parameter, which will be set to a newly allocated array of strings, or NULL in case of error.
78  * 
79  * get a list of providers matching certian criteria
80  *
81  * Returns: The provider names, as a newly allocated array of strings, or NULL in case of error
82  * should be freed with g_strfreev
83  * 
84  **/
85 gchar **         modest_presets_get_providers   (ModestPresets *self, guint mcc, 
86                                                  gboolean include_globals, gchar ***provider_ids);
87
88 /**
89  * modest_presets_get_server:
90  * @self: a valid ModestPresets instance
91  * @provider_id: ID of the provider 
92  * @incoming_server: get the incoming mailserver if TRUE, get the
93  * outgoing server otherwise
94  *
95  * get the name of a incoming or outgoing mailserver
96  * 
97  * Returns: a newly allocated string with the servername, or NULL in case
98  * of error, or server not found. (FIXME). Note that if the (incoming) server uses a
99  * non-standard port, the port number is appended to the name, eg. pop.foo.fi:995
100  */
101 gchar *                   modest_presets_get_server      (ModestPresets *self,
102                                                           const gchar *provider_id,
103                                                           gboolean incoming_server);
104                                                           
105 /**
106  * modest_presets_get_domain:
107  * @self: a valid ModestPresets instance
108  * @provider_id: ID of the provider 
109  *
110  * Get the name of the most-used domain for theis provider. For instance. hotmail.com
111  * 
112  * Returns: a newly allocated string with the domain name, or NULL in case
113  * of error.
114  */
115 gchar *                   modest_presets_get_domain      (ModestPresets *self,
116                                                           const gchar *provider_id);
117                                                           
118 /**
119  * modest_presets_get_info_server_type:
120  * @self: a valid ModestPresets instance
121  * @provider_id: ID of the provider 
122  * @incoming_server: get the incoming mailserver if TRUE, get the
123  * outgoing server otherwise
124  *
125  * get information about some incoming or outgoing mailserver
126  *
127  * Returns: a ModestPresetsServerType with the required information
128  */
129 ModestPresetsServerType          modest_presets_get_info_server_type (ModestPresets *self,
130                                                     const gchar *provider_id,
131                                                     gboolean incoming_server);
132
133 /**
134  * modest_presets_get_info_server_security:
135  * @self: a valid ModestPresets instance
136  * @provider_id: ID of the provider 
137  * @incoming_server: get the incoming mailserver if TRUE, get the
138  * outgoing server otherwise
139  *
140  * get information about some incoming or outgoing mailserver
141  *
142  * Returns: ModestPresetsSecurity ORable flags with the required information
143  */                                         
144 ModestPresetsSecurity          modest_presets_get_info_server_security (ModestPresets *self,
145                                                     const gchar *provider_id,
146                                                     gboolean incoming_server);
147
148 /**
149  * modest_presets_destroy:
150  * @self: a valid ModestPresets instance (ie. must not be NULL)
151  *
152  * destroy ModestPresets instance; this is required after you're done with it.
153  */
154 void                      modest_presets_destroy         (ModestPresets *self);
155
156
157 #endif /*__MODEST_PRESETS__*/
158
159