Branch data Line data Source code
1 : : /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 : : * 3 : : * Copyright © 2018 Endless Mobile, Inc. 4 : : * 5 : : * This library is free software; you can redistribute it and/or 6 : : * modify it under the terms of the GNU Lesser General Public 7 : : * License as published by the Free Software Foundation; either 8 : : * version 2.1 of the License, or (at your option) any later version. 9 : : * 10 : : * This library is distributed in the hope that it will be useful, 11 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 : : * Lesser General Public License for more details. 14 : : * 15 : : * You should have received a copy of the GNU Lesser General Public 16 : : * License along with this library; if not, write to the Free Software 17 : : * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 : : * 19 : : * Authors: 20 : : * - Philip Withnall <withnall@endlessm.com> 21 : : */ 22 : : 23 : : #pragma once 24 : : 25 : : #include <glib.h> 26 : : #include <glib-object.h> 27 : : 28 : : G_BEGIN_DECLS 29 : : 30 : : #define MWS_TYPE_CLOCK mws_clock_get_type () 31 [ + + + - : 597 : G_DECLARE_INTERFACE (MwsClock, mws_clock, MWS, CLOCK, GObject) - + ] 32 : : 33 : : /** 34 : : * MwsClockInterface: 35 : : * @g_iface: parent interface 36 : : * @get_now_local: (not nullable): Get the current time, in the local timezone. 37 : : * This method must be implemented. 38 : : * @add_alarm: (not nullable): Add a callback to be invoked when @alarm_time is 39 : : * reached. If @alarm_time is now or in the past, the callback must be 40 : : * invoked immediately. This method must be implemented. 41 : : * @remove_alarm: (not nullable): Remove a pending alarm using the ID returned 42 : : * by @add_alarm. If the alarm callback has already been invoked, this should 43 : : * emit a critical warning. This method must be implemented. 44 : : * 45 : : * An interface which provides wall clock timing and alarm functions to callers. 46 : : * The standard implementation is #MwsClockSystem, which uses the system clock. 47 : : * Other implementations may be available, which use mock data for testing. 48 : : * 49 : : * All virtual methods in this interface are mandatory to implement if the 50 : : * interface is implemented. 51 : : * 52 : : * Since: 0.1.0 53 : : */ 54 : : struct _MwsClockInterface 55 : : { 56 : : GTypeInterface g_iface; 57 : : 58 : : GDateTime *(*get_now_local) (MwsClock *clock); 59 : : guint (*add_alarm) (MwsClock *clock, 60 : : GDateTime *alarm_time, 61 : : GSourceFunc alarm_func, 62 : : gpointer user_data, 63 : : GDestroyNotify destroy_func); 64 : : void (*remove_alarm) (MwsClock *clock, 65 : : guint id); 66 : : }; 67 : : 68 : : GDateTime *mws_clock_get_now_local (MwsClock *self); 69 : : guint mws_clock_add_alarm (MwsClock *self, 70 : : GDateTime *alarm_time, 71 : : GSourceFunc alarm_func, 72 : : gpointer user_data, 73 : : GDestroyNotify destroy_func); 74 : : void mws_clock_remove_alarm (MwsClock *self, 75 : : guint id); 76 : : 77 : : G_END_DECLS