LCOV - code coverage report
Current view: top level - libmalcontent - session-limits.h (source / functions) Hit Total Coverage
Test: unnamed Lines: 3 3 100.0 %
Date: 2020-12-09 07:02:21 Functions: 5 5 100.0 %
Branches: 4 4 100.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
       2                 :            :  *
       3                 :            :  * Copyright © 2019 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 <gio/gio.h>
      26                 :            : #include <glib.h>
      27                 :            : #include <glib-object.h>
      28                 :            : 
      29                 :            : G_BEGIN_DECLS
      30                 :            : 
      31                 :            : /**
      32                 :            :  * MctSessionLimits:
      33                 :            :  *
      34                 :            :  * #MctSessionLimits is an opaque, immutable structure which contains a snapshot
      35                 :            :  * of the session limits settings for a user at a given time. This includes
      36                 :            :  * whether session limits are being enforced, and the limit policy — for
      37                 :            :  * example, the times of day when a user is allowed to use the computer.
      38                 :            :  *
      39                 :            :  * Typically, session limits settings can only be changed by the administrator,
      40                 :            :  * and are read-only for non-administrative users. The precise policy is set
      41                 :            :  * using polkit.
      42                 :            :  *
      43                 :            :  * Since: 0.5.0
      44                 :            :  */
      45                 :            : typedef struct _MctSessionLimits MctSessionLimits;
      46                 :            : GType mct_session_limits_get_type (void);
      47                 :            : #define MCT_TYPE_SESSION_LIMITS mct_session_limits_get_type ()
      48                 :            : 
      49                 :            : MctSessionLimits *mct_session_limits_ref   (MctSessionLimits *limits);
      50                 :            : void              mct_session_limits_unref (MctSessionLimits *limits);
      51                 :            : 
      52         [ +  + ]:        238 : G_DEFINE_AUTOPTR_CLEANUP_FUNC (MctSessionLimits, mct_session_limits_unref)
      53                 :            : 
      54                 :            : uid_t    mct_session_limits_get_user_id          (MctSessionLimits *limits);
      55                 :            : 
      56                 :            : gboolean mct_session_limits_is_enabled           (MctSessionLimits *limits);
      57                 :            : 
      58                 :            : gboolean mct_session_limits_check_time_remaining (MctSessionLimits *limits,
      59                 :            :                                                   guint64           now_usecs,
      60                 :            :                                                   guint64          *time_remaining_secs_out,
      61                 :            :                                                   gboolean         *time_limit_enabled_out);
      62                 :            : 
      63                 :            : GVariant         *mct_session_limits_serialize   (MctSessionLimits  *limits);
      64                 :            : MctSessionLimits *mct_session_limits_deserialize (GVariant          *variant,
      65                 :            :                                                   uid_t              user_id,
      66                 :            :                                                   GError           **error);
      67                 :            : 
      68                 :            : /**
      69                 :            :  * MctSessionLimitsBuilder:
      70                 :            :  *
      71                 :            :  * #MctSessionLimitsBuilder is a stack-allocated mutable structure used to build
      72                 :            :  * an #MctSessionLimits instance. Use mct_session_limits_builder_init(), various
      73                 :            :  * method calls to set properties of the session limits, and then
      74                 :            :  * mct_session_limits_builder_end(), to construct an #MctSessionLimits.
      75                 :            :  *
      76                 :            :  * Since: 0.5.0
      77                 :            :  */
      78                 :            : typedef struct
      79                 :            : {
      80                 :            :   /*< private >*/
      81                 :            :   guint u0;
      82                 :            :   guint u1;
      83                 :            :   guint u2;
      84                 :            :   gpointer p0[10];
      85                 :            : } MctSessionLimitsBuilder;
      86                 :            : 
      87                 :            : GType mct_session_limits_builder_get_type (void);
      88                 :            : 
      89                 :            : /**
      90                 :            :  * MCT_SESSION_LIMITS_BUILDER_INIT:
      91                 :            :  *
      92                 :            :  * Initialise a stack-allocated #MctSessionLimitsBuilder instance at declaration
      93                 :            :  * time.
      94                 :            :  *
      95                 :            :  * This is typically used with g_auto():
      96                 :            :  * |[
      97                 :            :  * g_auto(MctSessionLimitsBuilder) builder = MCT_SESSION_LIMITS_BUILDER_INIT ();
      98                 :            :  * ]|
      99                 :            :  *
     100                 :            :  * Since: 0.5.0
     101                 :            :  */
     102                 :            : #define MCT_SESSION_LIMITS_BUILDER_INIT() \
     103                 :            :   { \
     104                 :            :     0,  /* MCT_SESSION_LIMITS_TYPE_NONE */ \
     105                 :            :     0, \
     106                 :            :     0, \
     107                 :            :     /* padding: */ \
     108                 :            :     { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } \
     109                 :            :   }
     110                 :            : 
     111                 :            : void mct_session_limits_builder_init  (MctSessionLimitsBuilder *builder);
     112                 :            : void mct_session_limits_builder_clear (MctSessionLimitsBuilder *builder);
     113                 :            : 
     114                 :         13 : G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (MctSessionLimitsBuilder,
     115                 :            :                                   mct_session_limits_builder_clear)
     116                 :            : 
     117                 :            : MctSessionLimitsBuilder *mct_session_limits_builder_new  (void);
     118                 :            : MctSessionLimitsBuilder *mct_session_limits_builder_copy (MctSessionLimitsBuilder *builder);
     119                 :            : void                     mct_session_limits_builder_free (MctSessionLimitsBuilder *builder);
     120                 :            : 
     121         [ +  + ]:         64 : G_DEFINE_AUTOPTR_CLEANUP_FUNC (MctSessionLimitsBuilder, mct_session_limits_builder_free)
     122                 :            : 
     123                 :            : MctSessionLimits *mct_session_limits_builder_end (MctSessionLimitsBuilder *builder);
     124                 :            : 
     125                 :            : void mct_session_limits_builder_set_none (MctSessionLimitsBuilder *builder);
     126                 :            : 
     127                 :            : void mct_session_limits_builder_set_daily_schedule (MctSessionLimitsBuilder *builder,
     128                 :            :                                                     guint                    start_time_secs,
     129                 :            :                                                     guint                    end_time_secs);
     130                 :            : 
     131                 :            : G_END_DECLS

Generated by: LCOV version 1.14