| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
#include <config.h> |
|---|
| 20 |
|
|---|
| 21 |
#include <tny-gpe-platform-factory.h> |
|---|
| 22 |
#include <tny-gpe-account-store.h> |
|---|
| 23 |
#include <tny-gpe-device.h> |
|---|
| 24 |
#include <tny-gtk-msg-view.h> |
|---|
| 25 |
#include <tny-gtk-password-dialog.h> |
|---|
| 26 |
#include <tny-camel-mime-part.h> |
|---|
| 27 |
#include <tny-camel-msg.h> |
|---|
| 28 |
|
|---|
| 29 |
static GObjectClass *parent_class = NULL; |
|---|
| 30 |
|
|---|
| 31 |
static void |
|---|
| 32 |
tny_gpe_platform_factory_instance_init (GTypeInstance *instance, gpointer g_class) |
|---|
| 33 |
{ |
|---|
| 34 |
return; |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
static TnyMsg* |
|---|
| 40 |
tny_gpe_platform_factory_new_msg (TnyPlatformFactory *self) |
|---|
| 41 |
{ |
|---|
| 42 |
return tny_camel_msg_new (); |
|---|
| 43 |
} |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
static TnyMimePart* |
|---|
| 47 |
tny_gpe_platform_factory_new_mime_part (TnyPlatformFactory *self) |
|---|
| 48 |
{ |
|---|
| 49 |
return tny_camel_mime_part_new (); |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
static TnyAccountStore* |
|---|
| 54 |
tny_gpe_platform_factory_new_account_store (TnyPlatformFactory *self) |
|---|
| 55 |
{ |
|---|
| 56 |
return tny_gpe_account_store_new (); |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
static TnyDevice* |
|---|
| 60 |
tny_gpe_platform_factory_new_device (TnyPlatformFactory *self) |
|---|
| 61 |
{ |
|---|
| 62 |
return tny_gpe_device_new (); |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
static TnyMsgView* |
|---|
| 66 |
tny_gpe_platform_factory_new_msg_view (TnyPlatformFactory *self) |
|---|
| 67 |
{ |
|---|
| 68 |
return tny_gtk_msg_view_new (); |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|
| 71 |
static TnyPasswordGetter* |
|---|
| 72 |
tny_gpe_platform_factory_new_password_getter (TnyPlatformFactory *self) |
|---|
| 73 |
{ |
|---|
| 74 |
return tny_gtk_password_dialog_new (); |
|---|
| 75 |
} |
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
TnyPlatformFactory* |
|---|
| 84 |
tny_gpe_platform_factory_get_instance (void) |
|---|
| 85 |
{ |
|---|
| 86 |
TnyGpePlatformFactory *self = g_object_new (TNY_TYPE_GPE_PLATFORM_FACTORY, NULL); |
|---|
| 87 |
|
|---|
| 88 |
return TNY_PLATFORM_FACTORY (self); |
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
static void |
|---|
| 93 |
tny_gpe_platform_factory_finalize (GObject *object) |
|---|
| 94 |
{ |
|---|
| 95 |
(*parent_class->finalize) (object); |
|---|
| 96 |
|
|---|
| 97 |
return; |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
static void |
|---|
| 102 |
tny_platform_factory_init (gpointer g, gpointer iface_data) |
|---|
| 103 |
{ |
|---|
| 104 |
TnyPlatformFactoryIface *klass = (TnyPlatformFactoryIface *)g; |
|---|
| 105 |
|
|---|
| 106 |
klass->new_account_store= tny_gpe_platform_factory_new_account_store; |
|---|
| 107 |
klass->new_device= tny_gpe_platform_factory_new_device; |
|---|
| 108 |
klass->new_msg_view= tny_gpe_platform_factory_new_msg_view; |
|---|
| 109 |
klass->new_msg= tny_gpe_platform_factory_new_msg; |
|---|
| 110 |
klass->new_mime_part= tny_gpe_platform_factory_new_mime_part; |
|---|
| 111 |
klass->new_password_getter= tny_gpe_platform_factory_new_password_getter; |
|---|
| 112 |
|
|---|
| 113 |
return; |
|---|
| 114 |
} |
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
static TnyGpePlatformFactory *the_singleton = NULL; |
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
static GObject* |
|---|
| 121 |
tny_gpe_platform_factory_constructor (GType type, guint n_construct_params, |
|---|
| 122 |
GObjectConstructParam *construct_params) |
|---|
| 123 |
{ |
|---|
| 124 |
GObject *object; |
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
if (G_UNLIKELY (!the_singleton)) |
|---|
| 129 |
{ |
|---|
| 130 |
object = G_OBJECT_CLASS (parent_class)->constructor (type, |
|---|
| 131 |
n_construct_params, construct_params); |
|---|
| 132 |
|
|---|
| 133 |
the_singleton = TNY_GPE_PLATFORM_FACTORY (object); |
|---|
| 134 |
} |
|---|
| 135 |
else |
|---|
| 136 |
{ |
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
object = G_OBJECT (the_singleton); |
|---|
| 141 |
g_object_freeze_notify (G_OBJECT(the_singleton)); |
|---|
| 142 |
} |
|---|
| 143 |
|
|---|
| 144 |
return object; |
|---|
| 145 |
} |
|---|
| 146 |
|
|---|
| 147 |
static void |
|---|
| 148 |
tny_gpe_platform_factory_class_init (TnyGpePlatformFactoryClass *class) |
|---|
| 149 |
{ |
|---|
| 150 |
GObjectClass *object_class; |
|---|
| 151 |
|
|---|
| 152 |
parent_class = g_type_class_peek_parent (class); |
|---|
| 153 |
object_class = (GObjectClass*) class; |
|---|
| 154 |
|
|---|
| 155 |
object_class->finalize = tny_gpe_platform_factory_finalize; |
|---|
| 156 |
object_class->constructor = tny_gpe_platform_factory_constructor; |
|---|
| 157 |
|
|---|
| 158 |
return; |
|---|
| 159 |
} |
|---|
| 160 |
|
|---|
| 161 |
static gpointer |
|---|
| 162 |
tny_gpe_platform_factory_register_type (gpointer notused) |
|---|
| 163 |
{ |
|---|
| 164 |
GType type = 0; |
|---|
| 165 |
|
|---|
| 166 |
static const GTypeInfo info = |
|---|
| 167 |
{ |
|---|
| 168 |
sizeof (TnyGpePlatformFactoryClass), |
|---|
| 169 |
NULL, |
|---|
| 170 |
NULL, |
|---|
| 171 |
(GClassInitFunc) tny_gpe_platform_factory_class_init, |
|---|
| 172 |
NULL, |
|---|
| 173 |
NULL, |
|---|
| 174 |
sizeof (TnyGpePlatformFactory), |
|---|
| 175 |
0, |
|---|
| 176 |
tny_gpe_platform_factory_instance_init |
|---|
| 177 |
}; |
|---|
| 178 |
|
|---|
| 179 |
static const GInterfaceInfo tny_platform_factory_info = |
|---|
| 180 |
{ |
|---|
| 181 |
(GInterfaceInitFunc) tny_platform_factory_init, |
|---|
| 182 |
NULL, |
|---|
| 183 |
NULL |
|---|
| 184 |
}; |
|---|
| 185 |
|
|---|
| 186 |
type = g_type_register_static (G_TYPE_OBJECT, |
|---|
| 187 |
"TnyGpePlatformFactory", |
|---|
| 188 |
&info, 0); |
|---|
| 189 |
|
|---|
| 190 |
g_type_add_interface_static (type, TNY_TYPE_PLATFORM_FACTORY, |
|---|
| 191 |
&tny_platform_factory_info); |
|---|
| 192 |
|
|---|
| 193 |
return GUINT_TO_POINTER (type); |
|---|
| 194 |
} |
|---|
| 195 |
|
|---|
| 196 |
GType |
|---|
| 197 |
tny_gpe_platform_factory_get_type (void) |
|---|
| 198 |
{ |
|---|
| 199 |
static GOnce once = G_ONCE_INIT; |
|---|
| 200 |
g_once (&once, tny_gpe_platform_factory_register_type, NULL); |
|---|
| 201 |
return GPOINTER_TO_UINT (once.retval); |
|---|
| 202 |
} |
|---|