1a5ca83b6ddf21054f3b09493246c0a113b12c96
[platform/upstream/evolution-data-server.git] / camel / camel-operation.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2  *
3  * Authors: Michael Zucchi <NotZed@Ximian.com>
4  *
5  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of version 2 of the GNU Lesser General Public
9  * License as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19  * USA
20  */
21
22 #if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
23 #error "Only <camel/camel.h> can be included directly."
24 #endif
25
26 #ifndef CAMEL_OPERATION_H
27 #define CAMEL_OPERATION_H
28
29 #include <glib.h>
30
31 G_BEGIN_DECLS
32
33 /* cancellation helper stuff, not yet finalised */
34
35 typedef struct _CamelOperation CamelOperation;
36
37 typedef void (*CamelOperationStatusFunc)(struct _CamelOperation *op, const gchar *what, gint pc, gpointer data);
38
39 typedef enum _camel_operation_status_t {
40         CAMEL_OPERATION_START = -1,
41         CAMEL_OPERATION_END = -2
42 } camel_operation_status_t;
43
44 /* main thread functions */
45 CamelOperation *camel_operation_new(CamelOperationStatusFunc status, gpointer status_data);
46 void camel_operation_mute(CamelOperation *cc);
47 void camel_operation_ref(CamelOperation *cc);
48 void camel_operation_unref(CamelOperation *cc);
49 void camel_operation_cancel(CamelOperation *cc);
50 void camel_operation_uncancel(CamelOperation *cc);
51 /* subthread functions */
52 CamelOperation *camel_operation_register(CamelOperation *cc);
53 void camel_operation_unregister (CamelOperation *cc);
54
55 /* called internally by camel, for the current thread */
56 gint camel_operation_cancel_check(CamelOperation *cc);
57 gint camel_operation_cancel_fd(CamelOperation *cc);
58 #ifdef HAVE_NSS
59 struct PRFileDesc *camel_operation_cancel_prfd(CamelOperation *cc);
60 #endif
61 /* return the registered operation for this thread, if there is one */
62 CamelOperation *camel_operation_registered(void);
63
64 void camel_operation_start(CamelOperation *cc, const gchar *what, ...);
65 void camel_operation_start_transient(CamelOperation *cc, const gchar *what, ...);
66 void camel_operation_progress(CamelOperation *cc, gint pc);
67 void camel_operation_end(CamelOperation *cc);
68
69 G_END_DECLS
70
71 #endif /* CAMEL_OPERATION_H */