~ubuntu-branches/ubuntu/karmic/libtinymail/karmic

« back to all changes in this revision

Viewing changes to libtinymailui/tny-platform-factory.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-10-12 11:21:12 UTC
  • Revision ID: james.westby@ubuntu.com-20071012112112-fod9fs7yrooxjr7i
Tags: upstream-0.0.2
ImportĀ upstreamĀ versionĀ 0.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* libtinymailui - The Tiny Mail user interface library
 
2
 * Copyright (C) 2006-2007 Philip Van Hoof <pvanhoof@gnome.org>
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with self library; if not, write to the
 
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
 * Boston, MA 02111-1307, USA.
 
18
 */
 
19
 
 
20
/* The reason why this type is defined in libtinymailui rather than libtinymail
 
21
   is because the factory also returns types defined in libtinymailui */
 
22
   
 
23
#include <config.h>
 
24
 
 
25
#include <tny-platform-factory.h>
 
26
 
 
27
 
 
28
/**
 
29
 * tny_platform_factory_new_msg:
 
30
 * @self: a TnyPlatformFactory object
 
31
 *
 
32
 * Create a new #TnyMsg instance. The returned instance must be 
 
33
 * unreferenced after use.
 
34
 *
 
35
 * Implementors: when implementing a platform-specific library, return a 
 
36
 * new #TnyMsg instance.
 
37
 *
 
38
 * Return value: a #TnyMsg instance
 
39
 **/
 
40
TnyMsg* 
 
41
tny_platform_factory_new_msg (TnyPlatformFactory *self)
 
42
{
 
43
#ifdef DEBUG
 
44
        if (!TNY_PLATFORM_FACTORY_GET_IFACE (self)->new_msg_func)
 
45
                g_critical ("You must implement tny_platform_factory_new_msg\n");
 
46
#endif
 
47
 
 
48
        return TNY_PLATFORM_FACTORY_GET_IFACE (self)->new_msg_func (self);
 
49
 
 
50
}
 
51
 
 
52
/**
 
53
 * tny_platform_factory_new_password_getter:
 
54
 * @self: a TnyPlatformFactory object
 
55
 *
 
56
 * Create a new #TnyPasswordGetter instance. The returned instance must be 
 
57
 * unreferenced after use.
 
58
 *
 
59
 * Implementors: when implementing a platform-specific library, return a 
 
60
 * new #TnyPasswordGetter instance.
 
61
 *
 
62
 * Return value: a #TnyPasswordGetter instance
 
63
 **/
 
64
TnyPasswordGetter* 
 
65
tny_platform_factory_new_password_getter (TnyPlatformFactory *self)
 
66
{
 
67
#ifdef DEBUG
 
68
        if (!TNY_PLATFORM_FACTORY_GET_IFACE (self)->new_password_getter_func)
 
69
                g_critical ("You must implement tny_platform_factory_new_password_getter\n");
 
70
#endif
 
71
 
 
72
        return TNY_PLATFORM_FACTORY_GET_IFACE (self)->new_password_getter_func (self);
 
73
}
 
74
 
 
75
/**
 
76
 * tny_platform_factory_new_mime_part:
 
77
 * @self: a TnyPlatformFactory object
 
78
 *
 
79
 * Create a new #TnyMimePart instance. The returned instance must be 
 
80
 * unreferenced after use.
 
81
 *
 
82
 * Implementors: when implementing a platform-specific library, return a 
 
83
 * new #TnyMimePart instance.
 
84
 *
 
85
 * Return value: a #TnyMimePart instance
 
86
 **/
 
87
TnyMimePart* 
 
88
tny_platform_factory_new_mime_part (TnyPlatformFactory *self)
 
89
{
 
90
#ifdef DEBUG
 
91
        if (!TNY_PLATFORM_FACTORY_GET_IFACE (self)->new_mime_part_func)
 
92
                g_critical ("You must implement tny_platform_factory_new_mime_part\n");
 
93
#endif
 
94
 
 
95
        return TNY_PLATFORM_FACTORY_GET_IFACE (self)->new_mime_part_func (self);
 
96
}
 
97
 
 
98
 
 
99
/**
 
100
 * tny_platform_factory_new_account_store:
 
101
 * @self: a TnyPlatformFactory object
 
102
 *
 
103
 * Create a new #TnyAccountStore instance. The returned instance must be 
 
104
 * unreferenced after use.
 
105
 *
 
106
 * Implementors: when implementing a platform-specific library, return a 
 
107
 * new #TnyAccountStore instance. It's allowed to reuse one instance, just
 
108
 * make sure that you add a reference then.
 
109
 *
 
110
 * Return value: a #TnyAccountStore instance
 
111
 **/
 
112
TnyAccountStore*
 
113
tny_platform_factory_new_account_store (TnyPlatformFactory *self)
 
114
{
 
115
#ifdef DEBUG
 
116
        if (!TNY_PLATFORM_FACTORY_GET_IFACE (self)->new_account_store_func)
 
117
                g_critical ("You must implement tny_platform_factory_new_account_store\n");
 
118
#endif
 
119
 
 
120
        return TNY_PLATFORM_FACTORY_GET_IFACE (self)->new_account_store_func (self);
 
121
}
 
122
 
 
123
/**
 
124
 * tny_platform_factory_new_device:
 
125
 * @self: a TnyPlatformFactory object
 
126
 *
 
127
 * Create a new #TnyDevice instance. The returned instance must be 
 
128
 * unreferenced after use.
 
129
 *
 
130
 * Implementors: when implementing a platform-specific library, return a 
 
131
 * new #TnyDevice instance. It's allowed to reuse one instance, just
 
132
 * make sure that you add a reference then.
 
133
 *
 
134
 * Return value: a #TnyDevice instance
 
135
 *
 
136
 **/
 
137
TnyDevice*
 
138
tny_platform_factory_new_device (TnyPlatformFactory *self)
 
139
{
 
140
#ifdef DEBUG
 
141
        if (!TNY_PLATFORM_FACTORY_GET_IFACE (self)->new_device_func)
 
142
                g_critical ("You must implement tny_platform_factory_new_device\n");
 
143
#endif
 
144
 
 
145
        return TNY_PLATFORM_FACTORY_GET_IFACE (self)->new_device_func (self);
 
146
}
 
147
 
 
148
/**
 
149
 * tny_platform_factory_new_msg_view:
 
150
 * @self: a TnyPlatformFactory object
 
151
 *
 
152
 * Create a new #TnyMsgView instance. The returned instance must be 
 
153
 * unreferenced after use.
 
154
 *
 
155
 * Implementors: when implementing a platform-specific library, return a 
 
156
 * new #TnyMsgView instance. It's allowed to reuse one instance, just
 
157
 * make sure that you add a reference then.
 
158
 *
 
159
 * Return value: a #TnyMsgView instance
 
160
 **/
 
161
TnyMsgView*
 
162
tny_platform_factory_new_msg_view (TnyPlatformFactory *self)
 
163
{
 
164
#ifdef DEBUG
 
165
        if (!TNY_PLATFORM_FACTORY_GET_IFACE (self)->new_msg_view_func)
 
166
                g_warning ("You must implement tny_platform_factory_new_msg_view\n");
 
167
#endif
 
168
 
 
169
        return TNY_PLATFORM_FACTORY_GET_IFACE (self)->new_msg_view_func (self);
 
170
}
 
171
 
 
172
 
 
173
static void
 
174
tny_platform_factory_base_init (gpointer g_class)
 
175
{
 
176
        static gboolean initialized = FALSE;
 
177
 
 
178
        if (!initialized) 
 
179
                initialized = TRUE;
 
180
}
 
181
 
 
182
GType
 
183
tny_platform_factory_get_type (void)
 
184
{
 
185
        static GType type = 0;
 
186
 
 
187
        if (G_UNLIKELY(type == 0))
 
188
        {
 
189
                static const GTypeInfo info = 
 
190
                {
 
191
                  sizeof (TnyPlatformFactoryIface),
 
192
                  tny_platform_factory_base_init,   /* base_init */
 
193
                  NULL,   /* base_finalize */
 
194
                  NULL,   /* class_init */
 
195
                  NULL,   /* class_finalize */
 
196
                  NULL,   /* class_data */
 
197
                  0,
 
198
                  0,      /* n_preallocs */
 
199
                  NULL    /* instance_init */
 
200
                };
 
201
                type = g_type_register_static (G_TYPE_INTERFACE, 
 
202
                        "TnyPlatformFactory", &info, 0);
 
203
 
 
204
                g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
 
205
        }
 
206
 
 
207
        return type;
 
208
}