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 : : #include <libmogwai-tariff/tariff.h> 28 : : 29 : : G_BEGIN_DECLS 30 : : 31 : : /** 32 : : * MwsMetered: 33 : : * @MWS_METERED_UNKNOWN: Metered status is unknown. 34 : : * @MWS_METERED_YES: Definitely metered. 35 : : * @MWS_METERED_NO: Definitely not metered. 36 : : * @MWS_METERED_GUESS_YES: Probably metered. 37 : : * @MWS_METERED_GUESS_NO: Probably not metered. 38 : : * 39 : : * Enum describing whether a connection is metered (the user has to pay per unit 40 : : * of traffic sent over it). This includes a coarse-grained measure of the 41 : : * certainty in whether the connection is metered. 42 : : * 43 : : * This type is identical to #NMMetered, but without pulling in the 44 : : * NetworkManager namespace. 45 : : * 46 : : * Since: 0.1.0 47 : : */ 48 : : typedef enum 49 : : { 50 : : MWS_METERED_UNKNOWN = 0, 51 : : MWS_METERED_YES, 52 : : MWS_METERED_NO, 53 : : MWS_METERED_GUESS_YES, 54 : : MWS_METERED_GUESS_NO, 55 : : } MwsMetered; 56 : : 57 : : MwsMetered mws_metered_combine_pessimistic (MwsMetered a, 58 : : MwsMetered b); 59 : : const gchar *mws_metered_to_string (MwsMetered metered); 60 : : 61 : : /** 62 : : * MwsConnectionDetails: 63 : : * @metered: Whether the connection is metered. 64 : : * @allow_downloads_when_metered: %TRUE to download even if the connection is 65 : : * metered, %FALSE otherwise 66 : : * @allow_downloads: %TRUE to allow downloads on this connection (regardless of 67 : : * its metered status), %FALSE otherwise 68 : : * @tariff: (nullable) (owned): Tariff information for this connection. 69 : : * 70 : : * Information about the configuration and current state of a given connection. 71 : : * This struct may be expanded in future to add new fields. 72 : : * 73 : : * Since: 0.1.0 74 : : */ 75 : : typedef struct 76 : : { 77 : : MwsMetered metered; 78 : : gboolean allow_downloads_when_metered; 79 : : gboolean allow_downloads; 80 : : MwtTariff *tariff; 81 : : } MwsConnectionDetails; 82 : : 83 : : void mws_connection_details_clear (MwsConnectionDetails *details); 84 : : 85 : : #define MWS_TYPE_CONNECTION_MONITOR mws_connection_monitor_get_type () 86 [ + + + - : 975 : G_DECLARE_INTERFACE (MwsConnectionMonitor, mws_connection_monitor, MWS, CONNECTION_MONITOR, GObject) - + ] 87 : : 88 : : /** 89 : : * MwsConnectionMonitorInterface: 90 : : * @g_iface: parent interface 91 : : * @get_connection_ids: Get the IDs of the currently active network connections. 92 : : * The format of an ID is defined by the interface implementation, but it 93 : : * must be non-%NULL, non-empty, and valid UTF-8. 94 : : * @get_connection_details: Get the current details of the given connection, 95 : : * returning them in @out_details. If the connection is found, %TRUE is 96 : : * returned; otherwise, @out_details is undefined and %FALSE is returned. 97 : : * 98 : : * An interface which exposes the currently active network connections and their 99 : : * properties which are useful to the #MwsScheduler for working out scheduling 100 : : * of downloads. 101 : : * 102 : : * All virtual methods in this interface are mandatory to implement if the 103 : : * interface is implemented. 104 : : * 105 : : * Since: 0.1.0 106 : : */ 107 : : struct _MwsConnectionMonitorInterface 108 : : { 109 : : GTypeInterface g_iface; 110 : : 111 : : const gchar * const *(*get_connection_ids) (MwsConnectionMonitor *monitor); 112 : : gboolean (*get_connection_details) (MwsConnectionMonitor *monitor, 113 : : const gchar *id, 114 : : MwsConnectionDetails *out_details); 115 : : }; 116 : : 117 : : const gchar * const *mws_connection_monitor_get_connection_ids (MwsConnectionMonitor *self); 118 : : gboolean mws_connection_monitor_get_connection_details (MwsConnectionMonitor *self, 119 : : const gchar *id, 120 : : MwsConnectionDetails *out_details); 121 : : 122 : : G_END_DECLS