214a3e21b193d8ea85b9fb855f1a37c79badbd87
[modest] / src / modest-default-connection-policy.c
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 #include <config.h>
31 #include <glib.h>
32 #include <glib/gi18n-lib.h>
33
34 #include <modest-default-connection-policy.h>
35 #include <tny-account.h>
36
37 static GObjectClass *parent_class = NULL;
38
39 static void
40 modest_default_connection_policy_set_current (TnyConnectionPolicy *self, TnyAccount *account, TnyFolder *folder)
41 {
42         return;
43 }
44
45 static void
46 modest_default_connection_policy_on_connect (TnyConnectionPolicy *self, TnyAccount *account)
47 {
48         return;
49 }
50
51 static void
52 modest_default_connection_policy_on_connection_broken (TnyConnectionPolicy *self, TnyAccount *account)
53 {
54         return;
55 }
56
57 static void
58 modest_default_connection_policy_on_disconnect (TnyConnectionPolicy *self, TnyAccount *account)
59 {
60         tny_account_cancel (account);
61         return;
62 }
63
64 static void
65 modest_default_connection_policy_finalize (GObject *object)
66 {
67         parent_class->finalize (object);
68 }
69
70 static void
71 modest_default_connection_policy_instance_init (GTypeInstance *instance, gpointer g_class)
72 {
73 }
74
75 static void
76 tny_connection_policy_init (TnyConnectionPolicyIface *klass)
77 {
78         klass->on_connect= modest_default_connection_policy_on_connect;
79         klass->on_connection_broken= modest_default_connection_policy_on_connection_broken;
80         klass->on_disconnect= modest_default_connection_policy_on_disconnect;
81         klass->set_current= modest_default_connection_policy_set_current;
82 }
83
84 static void
85 modest_default_connection_policy_class_init (ModestDefaultConnectionPolicyClass *klass)
86 {
87         GObjectClass *object_class;
88
89         parent_class = g_type_class_peek_parent (klass);
90         object_class = (GObjectClass*) klass;
91         object_class->finalize = modest_default_connection_policy_finalize;
92 }
93
94
95
96 /**
97  * modest_default_connection_policy_new:
98  * 
99  * A connection policy
100  *
101  * Return value: A new #TnyConnectionPolicy instance 
102  **/
103 TnyConnectionPolicy*
104 modest_default_connection_policy_new (void)
105 {
106         return TNY_CONNECTION_POLICY (g_object_new (MODEST_TYPE_DEFAULT_CONNECTION_POLICY, NULL));
107 }
108
109 GType
110 modest_default_connection_policy_get_type (void)
111 {
112         static GType type = 0;
113         if (G_UNLIKELY(type == 0))
114         {
115                 static const GTypeInfo info = 
116                 {
117                         sizeof (ModestDefaultConnectionPolicyClass),
118                         NULL,   /* base_init */
119                         NULL,   /* base_finalize */
120                         (GClassInitFunc) modest_default_connection_policy_class_init,   /* class_init */
121                         NULL,   /* class_finalize */
122                         NULL,   /* class_data */
123                         sizeof (ModestDefaultConnectionPolicy),
124                         0,      /* n_preallocs */
125                         modest_default_connection_policy_instance_init,    /* instance_init */
126                         NULL
127                 };
128
129
130                 static const GInterfaceInfo tny_connection_policy_info = 
131                 {
132                         (GInterfaceInitFunc) tny_connection_policy_init, /* interface_init */
133                         NULL,         /* interface_finalize */
134                         NULL          /* interface_data */
135                 };
136
137                 type = g_type_register_static (G_TYPE_OBJECT,
138                         "ModestDefaultConnectionPolicy",
139                         &info, 0);
140
141                 g_type_add_interface_static (type, TNY_TYPE_CONNECTION_POLICY,
142                         &tny_connection_policy_info);
143
144         }
145         return type;
146 }