// SPDX-License-Identifier: GPL-3.0-or-later
/*
 * dbus.h - D-Bus interface for GNUtrition
 *
 * Copyright (C) 2026 Free Software Foundation, Inc.
 *
 * Author: Jason Self <jself@gnu.org>
 */

#ifndef DBUS_H
#define DBUS_H

#include <gio/gio.h>
#include <sqlite3.h>

/* Context for the D-Bus service, holding database handles.  */
struct dbus_context
{
  sqlite3 *food_db;
  sqlite3 *log_db;
  int calories;
};

/* Start the D-Bus service on the session bus.  CTX holds the
   database handles used by method implementations.  Returns the
   owner ID (> 0) on success, 0 on failure.  The caller must call
   dbus_service_stop to release resources.  */
guint dbus_service_start (struct dbus_context *ctx);

/* Stop the D-Bus service and release the bus name.  */
void dbus_service_stop (guint owner_id);

#endif /* DBUS_H */
