/***************************************************************************
* CVSID: $Id$
*
* device.c : HalDevice methods
*
* Copyright (C) 2003 David Zeuthen, <david@fubar.dk>
* Copyright (C) 2004 Novell, Inc.
*
* Licensed under the Academic Free License version 2.1
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
**************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <string.h>
#include "hald.h"
#include "device.h"
#include "hald_marshal.h"
#include "logger.h"
#include "hald_runner.h"
enum {
};
#ifdef HALD_MEMLEAK_DBG
int dbg_hal_device_object_delta = 0;
#endif
static void
{
#ifdef HALD_MEMLEAK_DBG
#endif
if (parent_class->finalize)
}
static void
{
g_signal_new ("property_changed",
G_TYPE_NONE, 3,
g_signal_new ("capability_added",
G_TYPE_NONE, 1,
g_signal_new ("callouts_finished",
G_TYPE_NONE, 0);
g_signal_new ("cancelled",
G_TYPE_NONE, 0);
}
static void
{
static int temp_device_counter = 0;
device->num_addons = 0;
device->num_addons_ready = 0;
}
hal_device_get_type (void)
{
if (!type) {
sizeof (HalDeviceClass),
sizeof (HalDevice),
0,
};
"HalDevice",
0);
}
return type;
}
hal_device_new (void)
{
#ifdef HALD_MEMLEAK_DBG
#endif
return device;
}
/** Merge all properties from source where the key starts with
* source_namespace and put them onto target replacing source_namespace
* with target_namespace
*
* @param target Device to put properties onto
* @param source Device to retrieve properties from
* @param target_namespace Replace source namespace with this namespace
* @param source_namespace Source namespace that property keys must match
*/
void
const char *target_namespace,
const char *source_namespace)
{
/* doesn't handle info.capabilities */
/* device_property_atomic_update_begin (); */
int type;
const char *key;
int target_type;
key = hal_property_get_key (p);
/* only care about properties that match source namespace */
continue;
type = hal_property_get_type (p);
/* only remove target if it exists with a different type */
switch (type) {
case HAL_PROPERTY_TYPE_STRING:
hal_property_get_string (p));
break;
case HAL_PROPERTY_TYPE_INT32:
hal_property_get_int (p));
break;
case HAL_PROPERTY_TYPE_UINT64:
hal_property_get_uint64 (p));
break;
hal_property_get_bool (p));
break;
case HAL_PROPERTY_TYPE_DOUBLE:
hal_property_get_double (p));
break;
default:
break;
}
g_free (target_key);
}
/* device_property_atomic_update_end (); */
}
void
{
/* device_property_atomic_update_begin (); */
int type;
const char *key;
int target_type;
key = hal_property_get_key (p);
type = hal_property_get_type (p);
/* handle info.capabilities in a special way */
continue;
/* only remove target if it exists with a different type */
switch (type) {
case HAL_PROPERTY_TYPE_STRING:
hal_property_get_string (p));
break;
case HAL_PROPERTY_TYPE_INT32:
hal_property_get_int (p));
break;
case HAL_PROPERTY_TYPE_UINT64:
hal_property_get_uint64 (p));
break;
hal_property_get_bool (p));
break;
case HAL_PROPERTY_TYPE_DOUBLE:
hal_property_get_double (p));
break;
default:
break;
}
}
/* device_property_atomic_update_end (); */
}
}
const char *namespace)
{
int len;
HalProperty *p;
const char *key;
int type;
key = hal_property_get_key (p);
type = hal_property_get_type (p);
continue;
return FALSE;
switch (type) {
case HAL_PROPERTY_TYPE_STRING:
if (strcmp (hal_property_get_string (p),
key)) != 0)
return FALSE;
break;
case HAL_PROPERTY_TYPE_INT32:
if (hal_property_get_int (p) !=
return FALSE;
break;
case HAL_PROPERTY_TYPE_UINT64:
if (hal_property_get_uint64 (p) !=
return FALSE;
break;
if (hal_property_get_bool (p) !=
return FALSE;
break;
case HAL_PROPERTY_TYPE_DOUBLE:
if (hal_property_get_double (p) !=
return FALSE;
break;
default:
break;
}
}
return TRUE;
}
const char *
{
}
void
{
}
void
{
}
{
return FALSE;
break;
}
}
return matched;
}
{
}
int
{
}
{
return p;
}
return NULL;
}
char *
{
if (!prop)
return NULL;
return hal_property_to_string (prop);
}
void
{
return;
}
}
int
{
return hal_property_get_type (prop);
else
return HAL_PROPERTY_TYPE_INVALID;
}
const char *
{
return hal_property_get_string (prop);
else
return NULL;
}
const char *
{
switch (hal_property_get_type (prop)) {
case HAL_PROPERTY_TYPE_STRING:
break;
case HAL_PROPERTY_TYPE_INT32:
break;
case HAL_PROPERTY_TYPE_UINT64:
break;
case HAL_PROPERTY_TYPE_DOUBLE:
break;
break;
/* print out as "\tval1\tval2\val3\t" */
{
guint i;
if (bufsize > 0)
buf[0] = '\t';
i = 1;
const char *str;
i += len;
if (i < bufsize) {
buf[i] = '\t';
i++;
}
}
}
break;
}
return buf;
} else {
buf[0] = '\0';
return NULL;
}
}
{
return hal_property_get_int (prop);
else
return -1;
}
{
return hal_property_get_uint64 (prop);
else
return -1;
}
{
return hal_property_get_bool (prop);
else
return FALSE;
}
double
{
return hal_property_get_double (prop);
else
return -1.0;
}
const char *value)
{
/* check if property already exists */
return FALSE;
/* don't bother setting the same value */
return TRUE;
} else {
}
return TRUE;
}
{
/* check if property already exists */
return FALSE;
/* don't bother setting the same value */
return TRUE;
} else {
}
return TRUE;
}
{
/* check if property already exists */
return FALSE;
/* don't bother setting the same value */
return TRUE;
} else {
}
return TRUE;
}
{
/* check if property already exists */
return FALSE;
/* don't bother setting the same value */
return TRUE;
} else {
}
return TRUE;
}
double value)
{
/* check if property already exists */
return FALSE;
/* don't bother setting the same value */
return TRUE;
} else {
}
return TRUE;
}
hal_device_copy_property (HalDevice *from_device, const char *from, HalDevice *to_device, const char *to)
{
case HAL_PROPERTY_TYPE_STRING:
break;
case HAL_PROPERTY_TYPE_INT32:
break;
case HAL_PROPERTY_TYPE_UINT64:
break;
break;
case HAL_PROPERTY_TYPE_DOUBLE:
break;
}
}
return rc;
}
{
return FALSE;
return TRUE;
}
const char *key,
enum PropertyAttribute attr,
{
return FALSE;
return TRUE;
}
void
{
int type;
const char *key;
key = hal_property_get_key (p);
type = hal_property_get_type (p);
switch (type) {
case HAL_PROPERTY_TYPE_STRING:
hal_property_get_string (p));
break;
case HAL_PROPERTY_TYPE_INT32:
hal_property_get_int (p),
hal_property_get_int (p));
break;
case HAL_PROPERTY_TYPE_UINT64:
(long long unsigned int) hal_property_get_uint64 (p),
(long long unsigned int) hal_property_get_uint64 (p));
break;
case HAL_PROPERTY_TYPE_DOUBLE:
hal_property_get_double (p));
break;
(hal_property_get_bool (p) ? "true" :
"false"));
break;
default:
break;
}
}
}
typedef struct {
char *key;
static void
{
}
static void
{
return;
/* the property is no longer there */
if (removed)
goto cleanup;
}
static gboolean
{
return FALSE;
}
void
const char *key,
int timeout)
{
/* check if property already exists */
return;
}
ai);
}
void
{
}
/** Used when giving up on a device, e.g. if no device file appeared
*/
void
{
}
GSList *
const char *key)
{
return hal_property_get_strlist (prop);
else
return NULL;
}
const char *
const char *key,
{
GSList *i;
return NULL;
if (i == NULL)
return NULL;
return (const char *) i->data;
}
const char *key,
const char *value)
{
/* check if property already exists */
return FALSE;
} else {
}
return TRUE;
}
const char *key,
const char *value)
{
/* check if property already exists */
return FALSE;
} else {
}
return TRUE;
}
const char *key,
{
/* check if property already exists */
return FALSE;
return FALSE;
return TRUE;
}
return FALSE;
}
const char *key)
{
/* check if property already exists */
return TRUE;
}
return FALSE;
if (hal_property_strlist_clear (prop)) {
return TRUE;
}
return FALSE;
}
const char *key,
const char *value)
{
/* check if property already exists */
goto out;
if (res) {
}
} else {
}
out:
return res;
}
const char *key,
const char *value)
{
/* check if property already exists */
return FALSE;
return FALSE;
}
return TRUE;
}
const char *key)
{
return TRUE;
if (g_slist_length (strlist) > 0)
return FALSE;
else
return TRUE;
}
return FALSE;
}
void
{
device->num_addons++;
}
{
if (hal_device_are_all_addons_ready (device)) {
HAL_ERROR (("In hal_device_inc_num_ready_addons for udi=%s but all addons are already ready!",
return FALSE;
}
return TRUE;
}
{
return TRUE;
} else {
return FALSE;
}
}