Add fully flexible task handling framework
[platform/upstream/connman.git] / include / task.h
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2009  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  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 General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #ifndef __CONNMAN_TASK_H
23 #define __CONNMAN_TASK_H
24
25 #include <dbus/dbus.h>
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /**
32  * SECTION:task
33  * @title: Task premitives
34  * @short_description: Functions for handling tasks
35  */
36
37 struct connman_task;
38
39 typedef void (* connman_task_exit_t) (struct connman_task *task,
40                                                         void *user_data);
41
42 typedef void (* connman_task_notify_t) (struct connman_task *task,
43                                 DBusMessage *message, void *user_data);
44
45 struct connman_task *connman_task_create(const char *program);
46 void connman_task_destroy(struct connman_task *task);
47
48 int connman_task_add_argument(struct connman_task *task,
49                                 const char *argument, const char *value);
50 int connman_task_add_variable(struct connman_task *task,
51                                 const char *key, const char *value);
52
53 int connman_task_set_notify(struct connman_task *task, const char *member,
54                         connman_task_notify_t function, void *user_data);
55
56 int connman_task_run(struct connman_task *task,
57                         connman_task_exit_t function, void *user_data);
58 int connman_task_stop(struct connman_task *task);
59
60 #ifdef __cplusplus
61 }
62 #endif
63
64 #endif /* __CONNMAN_TASK_H */