Blame src/dbus/abrt_problems2_task.h

Packit 8ea169
/*
Packit 8ea169
  Copyright (C) 2015  ABRT team
Packit 8ea169
Packit 8ea169
  This program is free software; you can redistribute it and/or modify
Packit 8ea169
  it under the terms of the GNU General Public License as published by
Packit 8ea169
  the Free Software Foundation; either version 2 of the License, or
Packit 8ea169
  (at your option) any later version.
Packit 8ea169
Packit 8ea169
  This program is distributed in the hope that it will be useful,
Packit 8ea169
  but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 8ea169
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 8ea169
  GNU General Public License for more details.
Packit 8ea169
Packit 8ea169
  You should have received a copy of the GNU General Public License along
Packit 8ea169
  with this program; if not, write to the Free Software Foundation, Inc.,
Packit 8ea169
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Packit 8ea169
Packit 8ea169
  ------------------------------------------------------------------------------
Packit 8ea169
Packit 8ea169
  This file declares functions for org.freedesktop.Problems2.Task interface.
Packit 8ea169
Packit 8ea169
  Base class for tasks.
Packit 8ea169
Packit 8ea169
  Some actions may take too much time and D-Bus connection would simple
Packit 8ea169
  timeout. Thus we need to run those action asynchronously and we have to allow
Packit 8ea169
  users/clients to manage those asynchronous runs.
Packit 8ea169
Packit 8ea169
  This class is rather a wrapper for GTask. A task can have several states.
Packit 8ea169
  It should be possible to stop and start it again. It should also be
Packit 8ea169
  possible to terminate it.
Packit 8ea169
Packit 8ea169
  Offspring can publish details about the task through task 'details' which is
Packit 8ea169
  a string base, key-value structure.
Packit 8ea169
*/
Packit 8ea169
#ifndef ABRT_P2_TASK_H
Packit 8ea169
#define ABRT_P2_TASK_H
Packit 8ea169
Packit 8ea169
#include "libabrt.h"
Packit 8ea169
Packit 8ea169
#include <glib-object.h>
Packit 8ea169
#include <gio/gio.h>
Packit 8ea169
Packit 8ea169
G_BEGIN_DECLS
Packit 8ea169
Packit 8ea169
GType abrt_p2_task_get_type (void);
Packit 8ea169
Packit 8ea169
#define ABRT_TYPE_P2_TASK (abrt_p2_task_get_type ())
Packit 8ea169
#define ABRT_P2_TASK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ABRT_TYPE_P2_TASK, AbrtP2Task))
Packit 8ea169
#define ABRT_P2_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ABRT_TYPE_P2_TASK, AbrtP2TaskClass))
Packit 8ea169
#define ABRT_IS_P2_TASK(obj)(G_TYPE_CHECK_INSTANCE_TYPE ((obj), ABRT_TYPE_P2_TASK))
Packit 8ea169
#define ABRT_IS_P2_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ABRT_TYPE_P2_TASK))
Packit 8ea169
#define ABRT_P2_TASK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ABRT_TYPE_P2_TASK, AbrtP2TaskClass))
Packit 8ea169
Packit 8ea169
typedef struct _AbrtP2Task        AbrtP2Task;
Packit 8ea169
typedef struct _AbrtP2TaskClass   AbrtP2TaskClass;
Packit 8ea169
typedef struct _AbrtP2TaskPrivate AbrtP2TaskPrivate;
Packit 8ea169
Packit 8ea169
static inline void glib_autoptr_cleanup_AbrtP2Task(AbrtP2Task **task)
Packit 8ea169
{
Packit 8ea169
    glib_autoptr_cleanup_GObject((GObject **)task);
Packit 8ea169
}
Packit 8ea169
Packit 8ea169
typedef enum {
Packit 8ea169
    ABRT_P2_TASK_STATUS_NEW,
Packit 8ea169
    ABRT_P2_TASK_STATUS_RUNNING,
Packit 8ea169
    ABRT_P2_TASK_STATUS_STOPPED,
Packit 8ea169
    ABRT_P2_TASK_STATUS_CANCELED,
Packit 8ea169
    ABRT_P2_TASK_STATUS_FAILED,
Packit 8ea169
    ABRT_P2_TASK_STATUS_DONE,
Packit 8ea169
} AbrtP2TaskStatus;
Packit 8ea169
Packit 8ea169
typedef enum {
Packit 8ea169
    ABRT_P2_TASK_CODE_ERROR = -1,
Packit 8ea169
    ABRT_P2_TASK_CODE_STOP,
Packit 8ea169
    ABRT_P2_TASK_CODE_DONE,
Packit 8ea169
    ABRT_P2_TASK_CODE_CANCELLED,
Packit 8ea169
} AbrtP2TaskCode;
Packit 8ea169
Packit 8ea169
struct _AbrtP2TaskClass
Packit 8ea169
{
Packit 8ea169
    GObjectClass parent_class;
Packit 8ea169
Packit 8ea169
    /* Abstract methods */
Packit 8ea169
    AbrtP2TaskCode (* run)(AbrtP2Task *task, GError **error);
Packit 8ea169
Packit 8ea169
    /* Virtual methods */
Packit 8ea169
    void (* start)(AbrtP2Task *task, GVariant *options, GError **error);
Packit 8ea169
Packit 8ea169
    void (* cancel)(AbrtP2Task *task, GError **error);
Packit 8ea169
Packit 8ea169
    void (* finish)(AbrtP2Task *task, GError **error);
Packit 8ea169
Packit 8ea169
    /* Signals */
Packit 8ea169
    void (*status_changed)(AbrtP2Task *task, gint32 status);
Packit 8ea169
Packit 8ea169
    gpointer padding[12];
Packit 8ea169
};
Packit 8ea169
Packit 8ea169
struct _AbrtP2TaskPrivate
Packit 8ea169
{
Packit 8ea169
    gint32 p2t_status;
Packit 8ea169
    GVariant *p2t_details;
Packit 8ea169
    GVariant *p2t_results;
Packit 8ea169
    gint32 p2t_code;
Packit 8ea169
    GCancellable *p2t_cancellable;
Packit 8ea169
};
Packit 8ea169
Packit 8ea169
struct _AbrtP2Task
Packit 8ea169
{
Packit 8ea169
    GObject parent_instance;
Packit 8ea169
    AbrtP2TaskPrivate *pv;
Packit 8ea169
};
Packit 8ea169
Packit 8ea169
AbrtP2TaskStatus abrt_p2_task_status(AbrtP2Task *task);
Packit 8ea169
Packit 8ea169
/* Returns task details in form of key-value entries.
Packit 8ea169
 */
Packit 8ea169
GVariant *abrt_p2_task_details(AbrtP2Task *task);
Packit 8ea169
Packit 8ea169
bool abrt_p2_task_is_cancelled(AbrtP2Task *start);
Packit 8ea169
Packit 8ea169
/* Offspring can provide D-Bus client with information they need to have.
Packit 8ea169
 *
Packit 8ea169
 * For example: a path to the new problem directory of NewProblemTask
Packit 8ea169
 */
Packit 8ea169
void abrt_p2_task_add_detail(AbrtP2Task *task,
Packit 8ea169
            const char *key,
Packit 8ea169
            GVariant *value);
Packit 8ea169
Packit 8ea169
/* Private function for offspring to return their results.
Packit 8ea169
 */
Packit 8ea169
void abrt_p2_task_set_response(AbrtP2Task *task,
Packit 8ea169
            GVariant *response);
Packit 8ea169
Packit 8ea169
void abrt_p2_task_start(AbrtP2Task *start,
Packit 8ea169
            GVariant *options,
Packit 8ea169
            GError **error);
Packit 8ea169
Packit 8ea169
void abrt_p2_task_cancel(AbrtP2Task *start,
Packit 8ea169
            GError **error);
Packit 8ea169
Packit 8ea169
/* Retrieve results of a finished task.
Packit 8ea169
 */
Packit 8ea169
void abrt_p2_task_finish(AbrtP2Task *start,
Packit 8ea169
            GVariant **result,
Packit 8ea169
            gint32 *code,
Packit 8ea169
            GError **error);
Packit 8ea169
Packit 8ea169
/* Runs a task in non-interactive mode.
Packit 8ea169
 *
Packit 8ea169
 * For example, stopped tasks will be automatically canceled.
Packit 8ea169
 */
Packit 8ea169
void abrt_p2_task_autonomous_run(AbrtP2Task *task,
Packit 8ea169
        GError **error);
Packit 8ea169
Packit 8ea169
G_END_DECLS
Packit 8ea169
Packit 8ea169
#endif/*ABRT_P2_TASK_H*/