Imported Upstream version 1.38
[platform/upstream/connman.git] / include / task.h
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2012  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                                                 int exit_code, void *user_data);
41
42 typedef DBusMessage * (* connman_task_notify_t) (struct connman_task *task,
43                                 DBusMessage *message, void *user_data);
44
45 typedef void (* connman_task_setup_t) (void *setup_data);
46
47 struct connman_task *connman_task_create(const char *program,
48                                 connman_task_setup_t task_setup,
49                                 void *setup_data);
50 void connman_task_destroy(struct connman_task *task);
51
52 const char *connman_task_get_path(struct connman_task *task);
53
54 int connman_task_add_argument(struct connman_task *task,
55                                 const char *name, const char *format, ...);
56 int connman_task_add_variable(struct connman_task *task,
57                                 const char *key, const char *format, ...);
58
59 int connman_task_set_notify(struct connman_task *task, const char *member,
60                         connman_task_notify_t function, void *user_data);
61
62 int connman_task_run(struct connman_task *task,
63                         connman_task_exit_t function, void *user_data,
64                         int *stdin_fd, int *stdout_fd, int *stderr_fd);
65 int connman_task_stop(struct connman_task *task);
66
67 #ifdef __cplusplus
68 }
69 #endif
70
71 #endif /* __CONNMAN_TASK_H */