Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
updates.c File Reference
#include "config.h"
#include "common/updates.h"
#include "common/conf.h"
#include "common/logging.h"
#include <curl/curl.h>
#include <json-glib/json-glib.h>
#include <string.h>
#include <time.h>
+ Include dependency graph for updates.c:

Go to the source code of this file.

Data Structures

struct  _found_t
 

Macros

#define DT_UPDATES_ENABLED_KEY   "updates/enabled"
 
#define DT_UPDATES_LAST_CHECK_KEY   "updates/last_check"
 
#define DT_UPDATES_MANIFEST_KEY   "updates/manifest_url"
 
#define DT_UPDATES_INTERVAL   (24 * 60 * 60)
 
#define DT_UPDATES_MAX_BODY   (1 << 20)
 

Typedefs

typedef struct _found_t _found_t
 

Functions

const char * dt_updates_runtime_format (void)
 
const char * dt_updates_get_download_url (void)
 
const char * dt_updates_get_available_version (void)
 
static size_t _write_cb (char *data, size_t size, size_t nmemb, void *user)
 
static gboolean _announce (gpointer data)
 
static _found_t_evaluate (const char *body, gsize len)
 
static gpointer _updates_worker (gpointer data)
 
void dt_updates_init (const gboolean have_gui, dt_updates_notify_fn notify)
 
void dt_updates_shutdown (void)
 

Variables

static GThread * _worker = NULL
 
static gint _shutting_down = 0
 
static dt_updates_notify_fn _notify = NULL
 
static char * _download_url = NULL
 
static char * _available_version = NULL
 

Macro Definition Documentation

◆ DT_UPDATES_ENABLED_KEY

#define DT_UPDATES_ENABLED_KEY   "updates/enabled"

Definition at line 31 of file updates.c.

◆ DT_UPDATES_INTERVAL

#define DT_UPDATES_INTERVAL   (24 * 60 * 60)

Definition at line 34 of file updates.c.

◆ DT_UPDATES_LAST_CHECK_KEY

#define DT_UPDATES_LAST_CHECK_KEY   "updates/last_check"

Definition at line 32 of file updates.c.

◆ DT_UPDATES_MANIFEST_KEY

#define DT_UPDATES_MANIFEST_KEY   "updates/manifest_url"

Definition at line 33 of file updates.c.

◆ DT_UPDATES_MAX_BODY

#define DT_UPDATES_MAX_BODY   (1 << 20)

Definition at line 36 of file updates.c.

Typedef Documentation

◆ _found_t

typedef struct _found_t _found_t

Function Documentation

◆ _announce()

static gboolean _announce ( gpointer  data)
static

Definition at line 89 of file updates.c.

References _available_version, _download_url, _notify, _shutting_down, _found_t::url, and _found_t::version.

Referenced by _updates_worker().

◆ _evaluate()

static _found_t * _evaluate ( const char *  body,
gsize  len 
)
static

◆ _updates_worker()

◆ _write_cb()

static size_t _write_cb ( char *  data,
size_t  size,
size_t  nmemb,
void user 
)
static

Definition at line 73 of file updates.c.

References DT_UPDATES_MAX_BODY, n, and size.

Referenced by _updates_worker().

◆ dt_updates_get_available_version()

const char * dt_updates_get_available_version ( void  )

The version string of the newer build found by the last check, or NULL.

Definition at line 68 of file updates.c.

References _available_version.

◆ dt_updates_get_download_url()

const char * dt_updates_get_download_url ( void  )

The download URL of the newer build found by the last check, or NULL when none was found (or the check did not run). The string is owned by the module.

Definition at line 63 of file updates.c.

References _download_url.

Referenced by update_nightly_callback().

◆ dt_updates_init()

void dt_updates_init ( const gboolean  have_gui,
dt_updates_notify_fn  notify 
)

Start the check if it is due. Returns immediately; the fetch runs on its own thread. notify may be NULL, in which case a result is only queryable through the getters.

Definition at line 199 of file updates.c.

References _notify, _shutting_down, _updates_worker(), _worker, DT_BUILD_CHANNEL, dt_conf_get_bool(), dt_conf_get_int64(), dt_conf_set_int64(), DT_DEBUG_CONTROL, dt_print(), DT_UPDATES_ENABLED_KEY, DT_UPDATES_INTERVAL, DT_UPDATES_LAST_CHECK_KEY, and dt_updates_runtime_format().

Referenced by dt_init().

◆ dt_updates_runtime_format()

const char * dt_updates_runtime_format ( void  )

Where the running binary came from, as a key of the manifest's "formats" object ("appimage", "flatpak", "dmg-arm64", "dmg-i386", "exe"), or NULL when it cannot tell. Exposed for the consent dialog and for diagnostics.

Definition at line 44 of file updates.c.

Referenced by _evaluate(), and dt_updates_init().

◆ dt_updates_shutdown()

void dt_updates_shutdown ( void  )

Stop the worker. Bounded by the request timeout.

Definition at line 223 of file updates.c.

References _available_version, _download_url, _shutting_down, and _worker.

Referenced by dt_cleanup().

Variable Documentation

◆ _available_version

char* _available_version = NULL
static

Definition at line 42 of file updates.c.

Referenced by _announce(), dt_updates_get_available_version(), and dt_updates_shutdown().

◆ _download_url

char* _download_url = NULL
static

Definition at line 41 of file updates.c.

Referenced by _announce(), dt_updates_get_download_url(), and dt_updates_shutdown().

◆ _notify

dt_updates_notify_fn _notify = NULL
static

Definition at line 40 of file updates.c.

Referenced by _announce(), and dt_updates_init().

◆ _shutting_down

gint _shutting_down = 0
static

Definition at line 39 of file updates.c.

Referenced by _announce(), _updates_worker(), dt_updates_init(), and dt_updates_shutdown().

◆ _worker

GThread* _worker = NULL
static

Definition at line 38 of file updates.c.

Referenced by dt_updates_init(), and dt_updates_shutdown().