| 168 | } |
| 169 | |
| 170 | static void |
| 171 | upower_status_cb (GDBusProxy *proxy, GVariant *changed_properties, |
| 172 | GStrv invalidated_properties, signal_user_data_t *ud) |
| 173 | { |
| 174 | gboolean on_battery; |
| 175 | int queue_state; |
| 176 | |
| 177 | if (!ghb_dict_get_bool(ud->prefs, "PauseEncodingOnBatteryPower") || |
| 178 | !g_variant_lookup(changed_properties, "OnBattery", "b", &on_battery)) |
| 179 | return; |
| 180 | |
| 181 | queue_state = ghb_get_queue_state(); |
| 182 | |
| 183 | if (on_battery && (queue_state & GHB_STATE_WORKING) |
| 184 | && !(queue_state & GHB_STATE_PAUSED)) |
| 185 | { |
| 186 | power_state = GHB_POWER_PAUSED_ON_BATTERY; |
| 187 | ghb_log("Charger disconnected: pausing encode"); |
| 188 | ghb_send_notification(GHB_NOTIFY_PAUSED_ON_BATTERY, 0, ud); |
| 189 | ghb_pause_queue(); |
| 190 | } |
| 191 | else if (!on_battery && (power_state == GHB_POWER_PAUSED_ON_BATTERY)) |
| 192 | { |
| 193 | if (queue_state & GHB_STATE_PAUSED) |
| 194 | { |
| 195 | ghb_resume_queue(); |
| 196 | ghb_log("Charger connected: resuming encode"); |
| 197 | ghb_withdraw_notification(GHB_NOTIFY_PAUSED_ON_BATTERY); |
| 198 | } |
| 199 | power_state = GHB_POWER_OK; |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | static void |
| 204 | upower_proxy_new_cb (GObject *source, GAsyncResult *result, |
nothing calls this directly
no test coverage detected