libpurple/purplescheduledtask.h

Sat, 09 Aug 2025 17:37:27 +0800

author
Gong Zhile <gongzl@stu.hebust.edu.cn>
date
Sat, 09 Aug 2025 17:37:27 +0800
branch
bird-header-fix
changeset 43304
2599d35e9750
parent 43292
03fe500d5aa5
permissions
-rw-r--r--

Fix the birb header path

The birb header referred would only work with birb provided by wrap casuing
build to fail because of system-installed birb dependency. The commit points
it to the correct path <birb.h>.

See: https://keep.imfreedom.org/birb/birb/file/5bf00c7d7f80/birb/meson.build#l77

/*
 * Purple - Internet Messaging Library
 * Copyright (C) Pidgin Developers <devel@pidgin.im>
 *
 * Purple is the legal property of its developers, whose names are too numerous
 * to list here. Please refer to the COPYRIGHT file distributed with this
 * source distribution.
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this library; if not, see <https://www.gnu.org/licenses/>.
 */

#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
# error "only <purple.h> may be included directly"
#endif

#ifndef PURPLE_SCHEDULED_TASK_H
#define PURPLE_SCHEDULED_TASK_H

#include <glib.h>
#include <glib-object.h>

#include "purpletags.h"
#include "purpleversion.h"

G_BEGIN_DECLS

#define PURPLE_SCHEDULED_TASK_ERROR purple_scheduled_task_error_quark()

/**
 * PurpleScheduledTaskError:
 * @PURPLE_SCHEDULED_TASK_ERROR_EXECUTE_AT_IN_PAST: The given time is in the
 *  past.
 * @PURPLE_SCHEDULED_TASK_ERROR_RESCHEDULE_EXECUTING_TASK: A task that is
 *  currently executing can not be cancelled.
 *
 * Error codes returned by scheduled tasks.
 *
 * Since: 3.0
 */
typedef enum {
	PURPLE_SCHEDULED_TASK_ERROR_EXECUTE_AT_IN_PAST PURPLE_AVAILABLE_ENUMERATOR_IN_3_0,
	PURPLE_SCHEDULED_TASK_ERROR_RESCHEDULE_EXECUTING_TASK PURPLE_AVAILABLE_ENUMERATOR_IN_3_0,
} PurpleScheduledTaskError;

/**
 * purple_scheduled_task_error_quark:
 *
 * The error domain to identify errors with scheduled tasks.
 *
 * Returns: The error domain.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
GQuark purple_scheduled_task_error_quark(void);

/**
 * PurpleScheduledTaskState:
 * @PURPLE_SCHEDULED_TASK_STATE_UNSCHEDULED: the task has not yet been
 *                                           scheduled
 * @PURPLE_SCHEDULED_TASK_STATE_SCHEDULED: the task has been scheduled but not
 *                                         yet executed
 * @PURPLE_SCHEDULED_TASK_STATE_CANCELLED: the task has been cancelled
 * @PURPLE_SCHEDULED_TASK_STATE_EXECUTING: the task is currently executing
 * @PURPLE_SCHEDULED_TASK_STATE_EXECUTED: the task has been executed
 *
 *
 * The possible states that a task can be in.
 *
 * Since: 3.0
 */
typedef enum {
	PURPLE_SCHEDULED_TASK_STATE_UNSCHEDULED PURPLE_AVAILABLE_ENUMERATOR_IN_3_0,
	PURPLE_SCHEDULED_TASK_STATE_SCHEDULED PURPLE_AVAILABLE_ENUMERATOR_IN_3_0,
	PURPLE_SCHEDULED_TASK_STATE_CANCELLED PURPLE_AVAILABLE_ENUMERATOR_IN_3_0,
	PURPLE_SCHEDULED_TASK_STATE_EXECUTING PURPLE_AVAILABLE_ENUMERATOR_IN_3_0,
	PURPLE_SCHEDULED_TASK_STATE_EXECUTED PURPLE_AVAILABLE_ENUMERATOR_IN_3_0,
} PurpleScheduledTaskState;

/**
 * PurpleScheduledTask:
 *
 * An object that represents a scheduled task.
 *
 * Since: 3.0
 */

#define PURPLE_TYPE_SCHEDULED_TASK (purple_scheduled_task_get_type())

PURPLE_AVAILABLE_IN_3_0
G_DECLARE_FINAL_TYPE(PurpleScheduledTask, purple_scheduled_task, PURPLE,
                     SCHEDULED_TASK, GObject)

/**
 * purple_scheduled_task_cancel:
 *
 * Cancels the task.
 *
 * If the task is not scheduled, this does nothing.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
void purple_scheduled_task_cancel(PurpleScheduledTask *task);

/**
 * purple_scheduled_task_get_cancellable:
 *
 * Gets whether or not the task can be cancelled by the user.
 *
 * Returns: true if the task can be cancelled.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gboolean purple_scheduled_task_get_cancellable(PurpleScheduledTask *task);

/**
 * purple_scheduled_task_get_execute_at:
 *
 * Gets the date time when the task will execute.
 *
 * Returns: (transfer none) (nullable): The date time of when the task will
 *          execute.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
GDateTime *purple_scheduled_task_get_execute_at(PurpleScheduledTask *task);

/**
 * purple_scheduled_task_get_id:
 *
 * Gets the id of the task.
 *
 * Returns: (transfer none) (nullable): The id of the task.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
const char *purple_scheduled_task_get_id(PurpleScheduledTask *task);

/**
 * purple_scheduled_task_get_persistent:
 *
 * Gets whether or not the task will be remembered across invocations of the
 * program.
 *
 * Returns: true if the task will be remembered.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gboolean purple_scheduled_task_get_persistent(PurpleScheduledTask *task);

/**
 * purple_scheduled_task_get_state:
 *
 * Gets the current state of the task.
 *
 * Returns: The state of the task.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleScheduledTaskState purple_scheduled_task_get_state(PurpleScheduledTask *task);

/**
 * purple_scheduled_task_get_subtitle:
 *
 * Gets the subtitle of the task.
 *
 * Returns: (nullable): The subtitle of the task.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
const char *purple_scheduled_task_get_subtitle(PurpleScheduledTask *task);

/**
 * purple_scheduled_task_get_tags:
 *
 * Gets the tags for the task.
 *
 * Returns: (transfer none): The tags.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleTags *purple_scheduled_task_get_tags(PurpleScheduledTask *task);

/**
 * purple_scheduled_task_get_task_type:
 *
 * Gets the type of the task.
 *
 * Returns: The type of the task.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
const char *purple_scheduled_task_get_task_type(PurpleScheduledTask *task);

/**
 * purple_scheduled_task_get_title:
 *
 * Gets the title of the task.
 *
 * Returns: The title.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
const char *purple_scheduled_task_get_title(PurpleScheduledTask *task);

/**
 * purple_scheduled_task_new:
 * @task_type: a well-known type name
 * @title: a title that can be displayed to users
 * @cancellable: true if the task can be cancelled by the user; false
 *               otherwise
 *
 * Creates a new scheduled task.
 *
 * Returns: (transfer full) (nullable): The new scheduled task.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleScheduledTask *purple_scheduled_task_new(const char *task_type, const char *title, gboolean cancellable);

/**
 * purple_scheduled_task_schedule:
 * @execute_at: the date time for when the task should be executed
 * @error: (out) (nullable): a return address for a #GError
 *
 * Schedules the task.
 *
 * If the task has already been scheduled it will be cancelled and rescheduled
 * for the new time.
 *
 * If the @execute_at is in the past an error will be returned.
 *
 * Returns: true if the task was scheduled successfully.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gboolean purple_scheduled_task_schedule(PurpleScheduledTask *task, GDateTime *execute_at, GError **error);

/**
 * purple_scheduled_task_schedule_relative:
 * @when: a relative time span when to execute
 * @error: (out) (nullable): a return address for a #GError
 *
 * Schedules the task with a relative time.
 *
 * This is a wrapper around [method@ScheduledTask.schedule] that will add @when
 * to the current time for you.
 *
 * If the task has already been scheduled it will be cancelled and rescheduled
 * for the new time.
 *
 * If the @when is in the past an error will be returned.
 *
 * Returns: true if the task was scheduled successfully.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gboolean purple_scheduled_task_schedule_relative(PurpleScheduledTask *task, GTimeSpan when, GError **error);

/**
 * purple_scheduled_task_set_persistent:
 * @persistent: the new value
 *
 * Sets whether the task should be remembered across invocations or not.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
void purple_scheduled_task_set_persistent(PurpleScheduledTask *task, gboolean persistent);

/**
 * purple_scheduled_task_set_subtitle:
 * @subtitle: the new subtitle
 *
 * Sets the subtitle for the task.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
void purple_scheduled_task_set_subtitle(PurpleScheduledTask *task, const char *subtitle);

G_END_DECLS

#endif /* PURPLE_SCHEDULED_TASK_H */

mercurial