GCC Code Coverage Report


Directory: ./
File: src/ppd-driver.h
Date: 2024-09-13 00:56:02
Exec Total Coverage
Lines: 1 1 100.0%
Functions: 1 1 100.0%
Branches: 13 16 81.2%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2020 Bastien Nocera <hadess@hadess.net>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3 as published by
6 * the Free Software Foundation.
7 *
8 */
9
10 #pragma once
11
12 #include <glib-object.h>
13 #include "ppd-profile.h"
14
15 #define PPD_TYPE_DRIVER (ppd_driver_get_type ())
16
13/16
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
✓ Branch 4 taken 170 times.
✓ Branch 5 taken 706 times.
✓ Branch 6 taken 230 times.
✓ Branch 7 taken 106 times.
✓ Branch 8 taken 504 times.
✓ Branch 9 taken 82 times.
✓ Branch 11 taken 22358 times.
✓ Branch 12 taken 3546 times.
✓ Branch 13 taken 22358 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 22358 times.
✗ Branch 16 not taken.
28836 G_DECLARE_DERIVABLE_TYPE (PpdDriver, ppd_driver, PPD, DRIVER, GObject)
17
18 /**
19 * PpdProfileActivationReason:
20 * @PPD_PROFILE_ACTIVATION_REASON_INTERNAL: the driver profile changed
21 * internally, usually because of a key combination.
22 * @PPD_PROFILE_ACTIVATION_REASON_RESET: setting profile on startup, or
23 * because drivers are getting reprobed.
24 * @PPD_PROFILE_ACTIVATION_REASON_USER: setting profile because the user
25 * requested it.
26 * @PPD_PROFILE_ACTIVATION_REASON_RESUME: setting profile because preference
27 * is lost during suspend.
28 * @PPD_PROFILE_ACTIVATION_REASON_PROGRAM_HOLD: setting profile because a program
29 * requested it through the `HoldProfile` method.
30 *
31 * Those are possible reasons for a profile being activated. Based on those
32 * reasons, drivers can choose whether or not that changes the effective
33 * profile internally.
34 */
35 typedef enum{
36 PPD_PROFILE_ACTIVATION_REASON_INTERNAL = 0,
37 PPD_PROFILE_ACTIVATION_REASON_RESET,
38 PPD_PROFILE_ACTIVATION_REASON_USER,
39 PPD_PROFILE_ACTIVATION_REASON_RESUME,
40 PPD_PROFILE_ACTIVATION_REASON_PROGRAM_HOLD
41 } PpdProfileActivationReason;
42
43 /**
44 * PpdDriverClass:
45 * @parent_class: The parent class.
46 * @probe: Called by the daemon on startup.
47 * @activate_profile: Called by the daemon for every profile change.
48 * @power_changed: Called by the daemon when power adapter status changes
49 * @battery_changed: Called by the daemon when the battery level changes.
50 *
51 * New profile drivers should not derive from #PpdDriver. They should
52 * derive from the child from #PpdDriverCpu or #PpdDriverPlatform drivers
53 * and implement at least one of probe () and @activate_profile.
54 */
55 struct _PpdDriverClass
56 {
57 GObjectClass parent_class;
58
59 PpdProbeResult (* probe) (PpdDriver *driver);
60 gboolean (* activate_profile) (PpdDriver *driver,
61 PpdProfile profile,
62 PpdProfileActivationReason reason,
63 GError **error);
64 gboolean (* power_changed) (PpdDriver *driver,
65 PpdPowerChangedReason reason,
66 GError **error);
67 gboolean (* prepare_to_sleep) (PpdDriver *driver,
68 gboolean start,
69 GError **error);
70 gboolean (* battery_changed) (PpdDriver *driver,
71 gdouble val,
72 GError **error);
73 };
74
75 #ifndef __GTK_DOC_IGNORE__
76 PpdProbeResult ppd_driver_probe (PpdDriver *driver);
77 gboolean ppd_driver_activate_profile (PpdDriver *driver,
78 PpdProfile profile, PpdProfileActivationReason reason, GError **error);
79 gboolean ppd_driver_power_changed (PpdDriver *driver, PpdPowerChangedReason reason, GError **error);
80 gboolean ppd_driver_prepare_to_sleep (PpdDriver *driver, gboolean start, GError **error);
81 gboolean ppd_driver_battery_changed (PpdDriver *driver, gdouble val, GError **error);
82 const char *ppd_driver_get_driver_name (PpdDriver *driver);
83 PpdProfile ppd_driver_get_profiles (PpdDriver *driver);
84 const char *ppd_driver_get_performance_degraded (PpdDriver *driver);
85 gboolean ppd_driver_is_performance_degraded (PpdDriver *driver);
86 void ppd_driver_emit_profile_changed (PpdDriver *driver, PpdProfile profile);
87 const char *ppd_profile_activation_reason_to_str (PpdProfileActivationReason reason);
88 #endif
89