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

« back to all changes in this revision

Viewing changes to libtinymail/tny-lockable.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
/* libtinymail - The Tiny Mail base 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
#include <config.h>
 
21
 
 
22
#include <tny-lockable.h>
 
23
 
 
24
/**
 
25
 * tny_lockable_lock:
 
26
 * @self: a #TnyLockable object
 
27
 * 
 
28
 * Lock @self
 
29
 **/
 
30
void 
 
31
tny_lockable_lock (TnyLockable *self)
 
32
{
 
33
#ifdef DBC /* require */
 
34
        g_assert (TNY_IS_LOCKABLE (self));
 
35
        g_assert (TNY_LOCKABLE_GET_IFACE (self)->lock_func != NULL);
 
36
#endif
 
37
 
 
38
        TNY_LOCKABLE_GET_IFACE (self)->lock_func (self);
 
39
        return;
 
40
}
 
41
 
 
42
/**
 
43
 * tny_lockable_unlock:
 
44
 * @self: a #TnyLockable object
 
45
 * 
 
46
 * Unlock @self
 
47
 **/
 
48
void 
 
49
tny_lockable_unlock (TnyLockable *self)
 
50
{
 
51
#ifdef DBC /* require */
 
52
        g_assert (TNY_IS_LOCKABLE (self));
 
53
        g_assert (TNY_LOCKABLE_GET_IFACE (self)->unlock_func != NULL);
 
54
#endif
 
55
 
 
56
        TNY_LOCKABLE_GET_IFACE (self)->unlock_func (self);
 
57
        return;
 
58
}
 
59
 
 
60
 
 
61
 
 
62
static void
 
63
tny_lockable_base_init (gpointer g_class)
 
64
{
 
65
        return;
 
66
}
 
67
 
 
68
GType
 
69
tny_lockable_get_type (void)
 
70
{
 
71
        static GType type = 0;
 
72
 
 
73
        if (G_UNLIKELY(type == 0))
 
74
        {
 
75
                static const GTypeInfo info = 
 
76
                {
 
77
                  sizeof (TnyLockableIface),
 
78
                  tny_lockable_base_init,   /* base_init */
 
79
                  NULL,   /* base_finalize */
 
80
                  NULL,   /* class_init */
 
81
                  NULL,   /* class_finalize */
 
82
                  NULL,   /* class_data */
 
83
                  0,
 
84
                  0,      /* n_preallocs */
 
85
                  NULL,   /* instance_init */
 
86
                  NULL
 
87
                };
 
88
                type = g_type_register_static (G_TYPE_INTERFACE, 
 
89
                        "TnyLockable", &info, 0);
 
90
        }
 
91
 
 
92
        return type;
 
93
}