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

« back to all changes in this revision

Viewing changes to libtinymail/tny-msg-receive-strategy.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-msg-receive-strategy.h>
 
23
#include <tny-folder.h>
 
24
#include <tny-header.h>
 
25
#include <tny-msg.h>
 
26
 
 
27
/* Possible future API changes:
 
28
 * tny_msg_receive_strategy_perform_get_msg will get a status callback handler.
 
29
 * Also take a look at the possible API changes for TnyFolder's get_msg_async 
 
30
 * as this would affect that API too. */
 
31
 
 
32
/**
 
33
 * tny_msg_receive_strategy_perform_get_msg:
 
34
 * @self: A #TnyMsgReceiveStrategy instance
 
35
 * @folder: The #TnyFolder instance from which the message will be received
 
36
 * @header: The #TnyHeader instance of the message that must be received
 
37
 * @err: A #GError instance or NULL
 
38
 *
 
39
 * Performs the receiving of a message from a folder. If not NULL, the returned
 
40
 * value must be unreferenced after use. If the returned value is NULL and @err
 
41
 * wasn't NULL, then @err will be set.
 
42
 *
 
43
 * Return value: the received message or NULL
 
44
 **/
 
45
TnyMsg *
 
46
tny_msg_receive_strategy_perform_get_msg (TnyMsgReceiveStrategy *self, TnyFolder *folder, TnyHeader *header, GError **err)
 
47
{
 
48
        TnyMsg *retval;
 
49
 
 
50
#ifdef DBC /* require */
 
51
        g_assert (TNY_IS_MSG_RECEIVE_STRATEGY (self));
 
52
        g_assert (folder);
 
53
        g_assert (TNY_IS_FOLDER (folder));
 
54
        g_assert (header);
 
55
        g_assert (TNY_IS_HEADER (header));
 
56
        g_assert (TNY_MSG_RECEIVE_STRATEGY_GET_IFACE (self)->perform_get_msg_func != NULL);
 
57
#endif
 
58
 
 
59
        retval = TNY_MSG_RECEIVE_STRATEGY_GET_IFACE (self)->perform_get_msg_func (self, folder, header, err);
 
60
 
 
61
#ifdef DBC /* ensure */
 
62
        if (retval)
 
63
                g_assert (TNY_IS_MSG (retval));
 
64
#endif
 
65
 
 
66
        return retval;
 
67
}
 
68
 
 
69
static void
 
70
tny_msg_receive_strategy_base_init (gpointer g_class)
 
71
{
 
72
        static gboolean initialized = FALSE;
 
73
 
 
74
        if (!initialized) 
 
75
                initialized = TRUE;
 
76
}
 
77
 
 
78
GType
 
79
tny_msg_receive_strategy_get_type (void)
 
80
{
 
81
        static GType type = 0;
 
82
 
 
83
        if (G_UNLIKELY(type == 0))
 
84
        {
 
85
                static const GTypeInfo info = 
 
86
                {
 
87
                  sizeof (TnyMsgReceiveStrategyIface),
 
88
                  tny_msg_receive_strategy_base_init,   /* base_init */
 
89
                  NULL,   /* base_finalize */
 
90
                  NULL,   /* class_init */
 
91
                  NULL,   /* class_finalize */
 
92
                  NULL,   /* class_data */
 
93
                  0,
 
94
                  0,      /* n_preallocs */
 
95
                  NULL    /* instance_init */
 
96
                };
 
97
                type = g_type_register_static (G_TYPE_INTERFACE, 
 
98
                        "TnyMsgReceiveStrategy", &info, 0);
 
99
        }
 
100
 
 
101
        return type;
 
102
}