mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-01-31 01:40:35 +01:00
Fix up the return statuses from coldplug and refresh, as different modules are doing different things
This commit is contained in:
parent
0ff31760f9
commit
70a5fce8a4
5 changed files with 38 additions and 15 deletions
|
|
@ -126,6 +126,8 @@ out:
|
|||
|
||||
/**
|
||||
* dkp_csr_coldplug:
|
||||
*
|
||||
* Return %TRUE on success, %FALSE if we failed to get data and should be removed
|
||||
**/
|
||||
static gboolean
|
||||
dkp_csr_coldplug (DkpDevice *device)
|
||||
|
|
@ -216,14 +218,16 @@ out:
|
|||
|
||||
/**
|
||||
* dkp_csr_refresh:
|
||||
*
|
||||
* Return %TRUE on success, %FALSE if we failed to refresh or no data
|
||||
**/
|
||||
static gboolean
|
||||
dkp_csr_refresh (DkpDevice *device)
|
||||
{
|
||||
gboolean ret = TRUE;
|
||||
gboolean ret = FALSE;
|
||||
GTimeVal time;
|
||||
DkpCsr *csr = DKP_CSR (device);
|
||||
usb_dev_handle *handle;
|
||||
usb_dev_handle *handle = NULL;
|
||||
char buf[80];
|
||||
unsigned int addr;
|
||||
gdouble percentage;
|
||||
|
|
@ -239,14 +243,14 @@ dkp_csr_refresh (DkpDevice *device)
|
|||
|
||||
if (csr->priv->device == NULL) {
|
||||
egg_warning ("no device!");
|
||||
return FALSE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* open USB device */
|
||||
handle = usb_open (csr->priv->device);
|
||||
if (handle == NULL) {
|
||||
egg_warning ("could not open device");
|
||||
return FALSE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* get the charge */
|
||||
|
|
@ -273,7 +277,8 @@ dkp_csr_refresh (DkpDevice *device)
|
|||
}
|
||||
|
||||
out:
|
||||
usb_close (handle);
|
||||
if (handle != NULL)
|
||||
usb_close (handle);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -476,6 +476,8 @@ out:
|
|||
|
||||
/**
|
||||
* dkp_device_coldplug:
|
||||
*
|
||||
* Return %TRUE on success, %FALSE if we failed to get data and should be removed
|
||||
**/
|
||||
gboolean
|
||||
dkp_device_coldplug (DkpDevice *device, DkpDaemon *daemon, DevkitDevice *d)
|
||||
|
|
@ -677,6 +679,8 @@ out:
|
|||
|
||||
/**
|
||||
* dkp_device_refresh:
|
||||
*
|
||||
* Return %TRUE on success, %FALSE if we failed to refresh or no data
|
||||
**/
|
||||
gboolean
|
||||
dkp_device_refresh (DkpDevice *device, DBusGMethodInvocation *context)
|
||||
|
|
@ -697,24 +701,23 @@ dkp_device_refresh (DkpDevice *device, DBusGMethodInvocation *context)
|
|||
gboolean
|
||||
dkp_device_changed (DkpDevice *device, DevkitDevice *d, gboolean synthesized)
|
||||
{
|
||||
gboolean changed;
|
||||
gboolean ret;
|
||||
|
||||
g_return_val_if_fail (DKP_IS_DEVICE (device), FALSE);
|
||||
|
||||
g_object_unref (device->priv->d);
|
||||
device->priv->d = g_object_ref (d);
|
||||
|
||||
changed = dkp_device_refresh_internal (device);
|
||||
ret = dkp_device_refresh_internal (device);
|
||||
|
||||
/* this 'change' event might prompt us to remove the supply */
|
||||
if (!changed)
|
||||
/* we failed to refresh, don't emit changed */
|
||||
if (!ret)
|
||||
goto out;
|
||||
|
||||
/* no, it's good .. keep it */
|
||||
dkp_device_emit_changed (device);
|
||||
|
||||
out:
|
||||
return changed;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -281,6 +281,8 @@ dkp_hid_get_all_data (DkpHid *hid)
|
|||
|
||||
/**
|
||||
* dkp_hid_coldplug:
|
||||
*
|
||||
* Return %TRUE on success, %FALSE if we failed to get data and should be removed
|
||||
**/
|
||||
static gboolean
|
||||
dkp_hid_coldplug (DkpDevice *device)
|
||||
|
|
@ -351,6 +353,8 @@ out:
|
|||
|
||||
/**
|
||||
* dkp_hid_refresh:
|
||||
*
|
||||
* Return %TRUE on success, %FALSE if we failed to refresh or no data
|
||||
**/
|
||||
static gboolean
|
||||
dkp_hid_refresh (DkpDevice *device)
|
||||
|
|
@ -370,7 +374,7 @@ dkp_hid_refresh (DkpDevice *device)
|
|||
/* read any data -- it's okay if there's nothing as we are non-blocking */
|
||||
rd = read (hid->priv->fd, ev, sizeof (ev));
|
||||
if (rd < (int) sizeof (ev[0])) {
|
||||
ret = TRUE;
|
||||
ret = FALSE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ static gboolean dkp_supply_refresh (DkpDevice *device);
|
|||
|
||||
/**
|
||||
* dkp_supply_refresh_line_power:
|
||||
*
|
||||
* Return %TRUE on success, %FALSE if we failed to refresh or no data
|
||||
**/
|
||||
static gboolean
|
||||
dkp_supply_refresh_line_power (DkpSupply *supply)
|
||||
|
|
@ -274,7 +276,7 @@ dkp_supply_convert_device_technology (const gchar *type)
|
|||
/**
|
||||
* dkp_supply_refresh_battery:
|
||||
*
|
||||
* Return value: TRUE if we changed
|
||||
* Return %TRUE on success, %FALSE if we failed to refresh or no data
|
||||
**/
|
||||
static gboolean
|
||||
dkp_supply_refresh_battery (DkpSupply *supply)
|
||||
|
|
@ -522,11 +524,14 @@ dkp_supply_poll_battery (DkpSupply *supply)
|
|||
|
||||
/**
|
||||
* dkp_supply_coldplug:
|
||||
*
|
||||
* Return %TRUE on success, %FALSE if we failed to get data and should be removed
|
||||
**/
|
||||
static gboolean
|
||||
dkp_supply_coldplug (DkpDevice *device)
|
||||
{
|
||||
DkpSupply *supply = DKP_SUPPLY (device);
|
||||
gboolean ret;
|
||||
DevkitDevice *d;
|
||||
const gchar *native_path;
|
||||
|
||||
|
|
@ -549,9 +554,9 @@ dkp_supply_coldplug (DkpDevice *device)
|
|||
}
|
||||
|
||||
/* coldplug values */
|
||||
dkp_supply_refresh (device);
|
||||
ret = dkp_supply_refresh (device);
|
||||
|
||||
return TRUE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -590,6 +595,8 @@ out:
|
|||
|
||||
/**
|
||||
* dkp_supply_refresh:
|
||||
*
|
||||
* Return %TRUE on success, %FALSE if we failed to refresh or no data
|
||||
**/
|
||||
static gboolean
|
||||
dkp_supply_refresh (DkpDevice *device)
|
||||
|
|
|
|||
|
|
@ -291,6 +291,8 @@ out:
|
|||
|
||||
/**
|
||||
* dkp_wup_coldplug:
|
||||
*
|
||||
* Return %TRUE on success, %FALSE if we failed to get data and should be removed
|
||||
**/
|
||||
static gboolean
|
||||
dkp_wup_coldplug (DkpDevice *device)
|
||||
|
|
@ -388,6 +390,8 @@ out:
|
|||
|
||||
/**
|
||||
* dkp_wup_refresh:
|
||||
*
|
||||
* Return %TRUE on success, %FALSE if we failed to refresh or no data
|
||||
**/
|
||||
static gboolean
|
||||
dkp_wup_refresh (DkpDevice *device)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue