Project

General

Profile

Bug #2555 ยป libhal_free.patch

suggested fix - Milan Jurik, 2012-03-30 06:15 PM

View differences:

new/usr/src/lib/hal/libhal/common/libhal.c Thu Mar 29 21:40:16 2012
4 4
 * libhal.c : HAL daemon C convenience library
5 5
 *
6 6
 * Copyright (C) 2003 David Zeuthen, <david@fubar.dk>
7
 * Copyright (C) 2006 Sjoerd Simons, <sjoerd@luon.net>
7 8
 * Copyright (C) 2007 Codethink Ltd. Author Rob Taylor <rob.taylor@codethink.co.uk>
8 9
 *
9 10
 * Licensed under the Academic Free License version 2.1
......
78 79
static dbus_bool_t libhal_property_fill_value_from_variant (LibHalProperty *p, DBusMessageIter *var_iter);
79 80

  
80 81

  
81

  
82
/** 
82
/**
83 83
 * libhal_free_string_array:
84 84
 * @str_array: the array to be freed
85 85
 *
......
161 161

  
162 162
}
163 163

  
164
/** 
164
/**
165 165
 * libhal_free_string:
166 166
 * @str: the nul-terminated sting to free
167 167
 *
......
190 190
				      *	  if there are no properties */
191 191
};
192 192

  
193
/** 
193
/**
194 194
 * LibHalProperty:
195 195
 *
196 196
 * Represents a property. Opaque.
......
217 217
				      *	  the last */
218 218
};
219 219

  
220
/** 
220
/**
221 221
 * LibHalContext:
222 222
 *
223 223
 * Context for connection to the HAL daemon. Opaque, use the
......
432 432
	result = malloc (sizeof (LibHalPropertySet));
433 433
	if (result == NULL) 
434 434
		goto oom;
435

  
435 436
/*
436 437
    result->properties = malloc(sizeof(LibHalProperty)*result->num_properties);
437 438
    if( result->properties==NULL )
......
592 593
LibHalPropertyType
593 594
libhal_ps_get_type (const LibHalPropertySet *set, const char *key)
594 595
{
595
	LibHalProperty *p = property_set_lookup (set, key);
596
	LibHalProperty *p;
596 597

  
597 598
	LIBHAL_CHECK_PARAM_VALID(set, "*set", LIBHAL_PROPERTY_TYPE_INVALID);
598 599
	LIBHAL_CHECK_PARAM_VALID(key, "*key", LIBHAL_PROPERTY_TYPE_INVALID);
......
743 744
}
744 745

  
745 746

  
746
/** 
747
/**
747 748
 * libhal_psi_init:
748 749
 * @iter: iterator object
749 750
 * @set: property set to iterate over
......
777 778
	return iter->idx < iter->set->num_properties;
778 779
}
779 780

  
780
/** 
781
/**
781 782
 * libhal_psi_next:
782 783
 * @iter: iterator object
783 784
 *
......
804 805
	return iter->cur_prop->type;
805 806
}
806 807

  
807
/** 
808
/**
808 809
 * libhal_psi_get_key:
809 810
 * @iter: iterator object
810 811
 *
......
820 821
	return iter->cur_prop->key;
821 822
}
822 823

  
823
/** 
824
/**
824 825
 * libhal_psi_get_string:
825 826
 * @iter: iterator object
826 827
 *
......
836 837
	return iter->cur_prop->v.str_value;
837 838
}
838 839

  
839
/** 
840
/**
840 841
 * libhal_psi_get_int:
841 842
 * @iter: iterator object
842 843
 *
......
864 865
	return iter->cur_prop->v.uint64_value;
865 866
}
866 867

  
867
/** 
868
/**
868 869
 * libhal_psi_get_double:
869 870
 * @iter: iterator object
870 871
 *
......
892 893
	return iter->cur_prop->v.bool_value;
893 894
}
894 895

  
895
/** 
896
/**
896 897
 * libhal_psi_get_strlist:
897 898
 * @iter: iterator object
898 899
 *
......
1015 1016
		}
1016 1017
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
1017 1018
	}
1018
	
1019

  
1019 1020
	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
1020 1021
}
1021 1022

  
......
1023 1024
static dbus_bool_t libhal_already_initialized_once = FALSE;
1024 1025

  
1025 1026

  
1026
/** 
1027
/**
1027 1028
 * libhal_get_all_devices:
1028 1029
 * @ctx: the context for the connection to hald
1029 1030
 * @num_devices: the number of devices will be stored here
......
1060 1061
	dbus_error_init (&_error);
1061 1062
	reply = dbus_connection_send_with_reply_and_block (ctx->connection, message, -1, &_error);
1062 1063

  
1064
	dbus_message_unref (message);
1065

  
1063 1066
	dbus_move_error (&_error, error);
1064 1067
	if (error != NULL && dbus_error_is_set (error)) {
1065
		dbus_message_unref (message);
1066 1068
		return NULL;
1067 1069
	}
1068 1070
	if (reply == NULL) {
1069
		dbus_message_unref (message);
1070 1071
		return NULL;
1071 1072
	}
1072 1073

  
......
1075 1076

  
1076 1077
	if (dbus_message_iter_get_arg_type (&reply_iter) != DBUS_TYPE_ARRAY) {
1077 1078
		fprintf (stderr, "%s %d : wrong reply from hald.  Expecting an array.\n", __FILE__, __LINE__);
1079
		dbus_message_unref (reply);
1078 1080
		return NULL;
1079 1081
	}
1080 1082
	
......
1083 1085
	hal_device_names = libhal_get_string_array_from_iter (&iter_array, num_devices);
1084 1086
		      
1085 1087
	dbus_message_unref (reply);
1086
	dbus_message_unref (message);
1087

  
1088 1088
	return hal_device_names;
1089 1089
}
1090 1090

  
1091
/** 
1091
/**
1092 1092
 * libhal_device_get_property_type:
1093 1093
 * @ctx: the context for the connection to hald
1094 1094
 * @udi: the Unique Device Id
......
1127 1127
							   message, -1,
1128 1128
							   &_error);
1129 1129

  
1130
	dbus_message_unref (message);
1131

  
1130 1132
	dbus_move_error (&_error, error);
1131 1133
	if (error != NULL && dbus_error_is_set (error)) {
1132
		dbus_message_unref (message);
1133 1134
		return LIBHAL_PROPERTY_TYPE_INVALID;
1134 1135
	}
1135 1136
	if (reply == NULL) {
1136
		dbus_message_unref (message);
1137 1137
		return LIBHAL_PROPERTY_TYPE_INVALID;
1138 1138
	}
1139 1139

  
1140 1140
	dbus_message_iter_init (reply, &reply_iter);
1141 1141
	dbus_message_iter_get_basic (&reply_iter, &type);
1142 1142

  
1143
	dbus_message_unref (message);
1144 1143
	dbus_message_unref (reply);
1145

  
1146 1144
	return type;
1147 1145
}
1148 1146

  
1149
/** 
1147
/**
1150 1148
 * libhal_device_get_property_strlist:
1151 1149
 * @ctx: the context for the connection to hald
1152 1150
 * @udi: unique Device Id
......
1189 1187
							   message, -1,
1190 1188
							   &_error);
1191 1189

  
1190
	dbus_message_unref (message);
1191

  
1192 1192
	dbus_move_error (&_error, error);
1193 1193
	if (error != NULL && dbus_error_is_set (error)) {
1194
		dbus_message_unref (message);
1195 1194
		return NULL;
1196 1195
	}
1197 1196
	if (reply == NULL) {
1198
		dbus_message_unref (message);
1199 1197
		return NULL;
1200 1198
	}
1201 1199
	/* now analyse reply */
......
1203 1201

  
1204 1202
	if (dbus_message_iter_get_arg_type (&reply_iter) != DBUS_TYPE_ARRAY) {
1205 1203
		fprintf (stderr, "%s %d : wrong reply from hald.  Expecting an array.\n", __FILE__, __LINE__);
1204
		dbus_message_unref (reply);
1206 1205
		return NULL;
1207 1206
	}
1208 1207
	
......
1211 1210
	our_strings = libhal_get_string_array_from_iter (&iter_array, NULL);
1212 1211
		      
1213 1212
	dbus_message_unref (reply);
1214
	dbus_message_unref (message);
1215

  
1216 1213
	return our_strings;
1217 1214
}
1218 1215

  
1219
/** 
1216
/**
1220 1217
 * libhal_device_get_property_string:
1221 1218
 * @ctx: the context for the connection to hald
1222 1219
 * @udi: the Unique Device Id
......
1261 1258
							   message, -1,
1262 1259
							   &_error);
1263 1260

  
1261
	dbus_message_unref (message);
1262

  
1264 1263
	dbus_move_error (&_error, error);
1265 1264
	if (error != NULL && dbus_error_is_set (error)) {
1266
		dbus_message_unref (message);
1267 1265
		return NULL;
1268 1266
	}
1269 1267
	if (reply == NULL) {
1270
		dbus_message_unref (message);
1271 1268
		return NULL;
1272 1269
	}
1273 1270

  
......
1276 1273
	/* now analyze reply */
1277 1274
	if (dbus_message_iter_get_arg_type (&reply_iter) !=
1278 1275
		   DBUS_TYPE_STRING) {
1279
		dbus_message_unref (message);
1280 1276
		dbus_message_unref (reply);
1281 1277
		return NULL;
1282 1278
	}
......
1286 1282
	if (value == NULL) {
1287 1283
		fprintf (stderr, "%s %d : error allocating memory\n",
1288 1284
			 __FILE__, __LINE__);
1289
		/** @todo FIXME cleanup */
1290
		return NULL;
1291 1285
	}
1292 1286

  
1293
	dbus_message_unref (message);
1294 1287
	dbus_message_unref (reply);
1295 1288
	return value;
1296 1289
}
1297 1290

  
1298
/** 
1291
/**
1299 1292
 * libhal_device_get_property_int:
1300 1293
 * @ctx: the context for the connection to hald
1301 1294
 * @udi: the Unique Device Id
......
1336 1329
							   message, -1,
1337 1330
							   &_error);
1338 1331

  
1332
	dbus_message_unref (message);
1333

  
1339 1334
	dbus_move_error (&_error, error);
1340 1335
	if (error != NULL && dbus_error_is_set (error)) {
1341
		dbus_message_unref (message);
1342 1336
		return -1;
1343 1337
	}
1344 1338
	if (reply == NULL) {
1345
		dbus_message_unref (message);
1346 1339
		return -1;
1347 1340
	}
1348 1341

  
......
1355 1348
			 "%s %d : property '%s' for device '%s' is not "
1356 1349
			 "of type integer\n", __FILE__, __LINE__, key,
1357 1350
			 udi);
1358
		dbus_message_unref (message);
1359 1351
		dbus_message_unref (reply);
1360 1352
		return -1;
1361 1353
	}
1362 1354
	dbus_message_iter_get_basic (&reply_iter, &value);
1363 1355

  
1364
	dbus_message_unref (message);
1365 1356
	dbus_message_unref (reply);
1366 1357
	return value;
1367 1358
}
1368 1359

  
1369
/** 
1360
/**
1370 1361
 * libhal_device_get_property_uint64:
1371 1362
 * @ctx: the context for the connection to hald
1372 1363
 * @udi: the Unique Device Id
......
1406 1397
	reply = dbus_connection_send_with_reply_and_block (ctx->connection,
1407 1398
							   message, -1,
1408 1399
							   &_error);
1409
	
1400

  
1401
	dbus_message_unref (message);
1402

  
1410 1403
	dbus_move_error (&_error, error);
1411 1404
	if (error != NULL && dbus_error_is_set (error)) {
1412
		dbus_message_unref (message);
1413 1405
		return -1;
1414 1406
	}
1415 1407
	if (reply == NULL) {
1416
		dbus_message_unref (message);
1417 1408
		return -1;
1418 1409
	}
1419 1410

  
......
1425 1416
			 "%s %d : property '%s' for device '%s' is not "
1426 1417
			 "of type integer\n", __FILE__, __LINE__, key,
1427 1418
			 udi);
1428
		dbus_message_unref (message);
1429 1419
		dbus_message_unref (reply);
1430 1420
		return -1;
1431 1421
	}
1432 1422
	dbus_message_iter_get_basic (&reply_iter, &value);
1433 1423

  
1434
	dbus_message_unref (message);
1435 1424
	dbus_message_unref (reply);
1436 1425
	return value;
1437 1426
}
1438 1427

  
1439
/** 
1428
/**
1440 1429
 * libhal_device_get_property_double:
1441 1430
 * @ctx: the context for the connection to hald
1442 1431
 * @udi: the Unique Device Id
......
1477 1466
							   message, -1,
1478 1467
							   &_error);
1479 1468

  
1469
	dbus_message_unref (message);
1470

  
1480 1471
	dbus_move_error (&_error, error);
1481 1472
	if (error != NULL && dbus_error_is_set (error)) {
1482
		dbus_message_unref (message);
1483 1473
		return -1.0f;
1484 1474
	}
1485 1475
	if (reply == NULL) {
1486
		dbus_message_unref (message);
1487 1476
		return -1.0f;
1488 1477
	}
1489 1478

  
......
1495 1484
		fprintf (stderr,
1496 1485
			 "%s %d : property '%s' for device '%s' is not "
1497 1486
			 "of type double\n", __FILE__, __LINE__, key, udi);
1498
		dbus_message_unref (message);
1499 1487
		dbus_message_unref (reply);
1500 1488
		return -1.0f;
1501 1489
	}
1502 1490
	dbus_message_iter_get_basic (&reply_iter, &value);
1503 1491

  
1504
	dbus_message_unref (message);
1505 1492
	dbus_message_unref (reply);
1506 1493
	return (double) value;
1507 1494
}
1508 1495

  
1509
/** 
1496
/**
1510 1497
 * libhal_device_get_property_bool:
1511 1498
 * @ctx: the context for the connection to hald
1512 1499
 * @udi: the Unique Device Id
......
1547 1534
							   message, -1,
1548 1535
							   &_error);
1549 1536

  
1537
	dbus_message_unref (message);
1538

  
1550 1539
	dbus_move_error (&_error, error);
1551 1540
	if (error != NULL && dbus_error_is_set (error)) {
1552
		dbus_message_unref (message);
1553 1541
		return FALSE;
1554 1542
	}
1555 1543
	if (reply == NULL) {
1556
		dbus_message_unref (message);
1557 1544
		return FALSE;
1558 1545
	}
1559 1546

  
......
1565 1552
		fprintf (stderr,
1566 1553
			 "%s %d : property '%s' for device '%s' is not "
1567 1554
			 "of type bool\n", __FILE__, __LINE__, key, udi);
1568
		dbus_message_unref (message);
1569 1555
		dbus_message_unref (reply);
1570 1556
		return FALSE;
1571 1557
	}
1572 1558
	dbus_message_iter_get_basic (&reply_iter, &value);
1573 1559

  
1574
	dbus_message_unref (message);
1575 1560
	dbus_message_unref (reply);
1576 1561
	return value;
1577 1562
}
......
1655 1640
	reply = dbus_connection_send_with_reply_and_block (ctx->connection,
1656 1641
							   message, -1,
1657 1642
							   error);
1643

  
1644
	dbus_message_unref (message);
1645

  
1658 1646
	if (error != NULL && dbus_error_is_set (error)) {
1659
		dbus_message_unref (message);
1660 1647
		return FALSE;
1661 1648
	}
1662

  
1663 1649
	if (reply == NULL) {
1664
		dbus_message_unref (message);
1665 1650
		return FALSE;
1666 1651
	}
1667 1652

  
1668
	dbus_message_unref (message);
1669 1653
	dbus_message_unref (reply);
1670 1654

  
1671 1655
	return TRUE;
1672 1656
}
1673 1657

  
1674
/** 
1658
/**
1675 1659
 * libhal_device_set_property_string:
1676 1660
 * @ctx: the context for the connection to hald
1677 1661
 * @udi: the Unique Device Id
......
1696 1680
						  value, 0, 0, 0.0f, FALSE, error);
1697 1681
}
1698 1682

  
1699
/** 
1683
/**
1700 1684
 * libhal_device_set_property_int:
1701 1685
 * @ctx: the context for the connection to hald
1702 1686
 * @udi: the Unique Device Id
......
1718 1702
						  NULL, value, 0, 0.0f, FALSE, error);
1719 1703
}
1720 1704

  
1721
/** 
1705
/**
1722 1706
 * libhal_device_set_property_uint64:
1723 1707
 * @ctx: the context for the connection to hald
1724 1708
 * @udi: the Unique Device Id
......
1740 1724
						  NULL, 0, value, 0.0f, FALSE, error);
1741 1725
}
1742 1726

  
1743
/** 
1727
/**
1744 1728
 * libhal_device_set_property_double:
1745 1729
 * @ctx: the context for the connection to hald
1746 1730
 * @udi: the Unique Device Id
......
1762 1746
						  NULL, 0, 0, value, FALSE, error);
1763 1747
}
1764 1748

  
1765
/** 
1749
/**
1766 1750
 * libhal_device_set_property_bool:
1767 1751
 * @ctx: the context for the connection to hald
1768 1752
 * @udi: the Unique Device Id
......
1785 1769
}
1786 1770

  
1787 1771

  
1788
/** 
1772
/**
1789 1773
 * libhal_device_remove_property:
1790 1774
 * @ctx: the context for the connection to hald
1791 1775
 * @udi: the Unique Device Id
......
1848 1832
	reply = dbus_connection_send_with_reply_and_block (ctx->connection,
1849 1833
							   message, -1,
1850 1834
							   error);
1835

  
1836
	dbus_message_unref (message);
1837

  
1851 1838
	if (error != NULL && dbus_error_is_set (error)) {
1852
		dbus_message_unref (message);
1853 1839
		return FALSE;
1854 1840
	}
1855 1841
	if (reply == NULL) {
1856
		dbus_message_unref (message);
1857 1842
		return FALSE;
1858 1843
	}
1844

  
1845
	dbus_message_unref (reply);
1859 1846
	return TRUE;
1860 1847
}
1861 1848

  
1862
/** 
1849
/**
1863 1850
 * libhal_device_property_strlist_prepend:
1864 1851
 * @ctx: the context for the connection to hald
1865 1852
 * @udi: the Unique Device Id
......
1901 1888
	reply = dbus_connection_send_with_reply_and_block (ctx->connection,
1902 1889
							   message, -1,
1903 1890
							   error);
1891

  
1892
	dbus_message_unref (message);
1893

  
1904 1894
	if (error != NULL && dbus_error_is_set (error)) {
1905
		dbus_message_unref (message);
1906 1895
		return FALSE;
1907 1896
	}
1908 1897
	if (reply == NULL) {
1909
		dbus_message_unref (message);
1910 1898
		return FALSE;
1911 1899
	}
1900

  
1901
	dbus_message_unref (reply);
1912 1902
	return TRUE;
1913 1903
}
1914 1904

  
1915
/** 
1905
/**
1916 1906
 * libhal_device_property_strlist_remove_index:
1917 1907
 * @ctx: the context for the connection to hald
1918 1908
 * @udi: the Unique Device Id
......
1954 1944
	reply = dbus_connection_send_with_reply_and_block (ctx->connection,
1955 1945
							   message, -1,
1956 1946
							   error);
1947

  
1948
	dbus_message_unref (message);
1949

  
1957 1950
	if (error != NULL && dbus_error_is_set (error)) {
1958
		dbus_message_unref (message);
1959 1951
		return FALSE;
1960 1952
	}
1961 1953
	if (reply == NULL) {
1962
		dbus_message_unref (message);
1963 1954
		return FALSE;
1964 1955
	}
1956

  
1957
	dbus_message_unref (reply);
1965 1958
	return TRUE;
1966 1959
}
1967 1960

  
1968
/** 
1961
/**
1969 1962
 * libhal_device_property_strlist_remove:
1970 1963
 * @ctx: the context for the connection to hald
1971 1964
 * @udi: the Unique Device Id
......
2006 1999
	reply = dbus_connection_send_with_reply_and_block (ctx->connection,
2007 2000
							   message, -1,
2008 2001
							   error);
2002

  
2003
	dbus_message_unref (message);
2004

  
2009 2005
	if (error != NULL && dbus_error_is_set (error)) {
2010
		dbus_message_unref (message);
2011 2006
		return FALSE;
2012 2007
	}
2013 2008
	if (reply == NULL) {
2014
		dbus_message_unref (message);
2015 2009
		return FALSE;
2016 2010
	}
2011

  
2012
	dbus_message_unref (reply);
2017 2013
	return TRUE;
2018 2014
}
2019 2015

  
2020 2016

  
2021
/** 
2017
/**
2022 2018
 * libhal_device_lock:
2023 2019
 * @ctx: the context for the connection to hald
2024 2020
 * @udi: the Unique Device Id
......
2065 2061
							   message, -1,
2066 2062
							   error);
2067 2063

  
2064
	dbus_message_unref (message);
2065

  
2068 2066
	if (error != NULL && dbus_error_is_set (error)) {
2069 2067
		if (strcmp (error->name,
2070 2068
			    "org.freedesktop.Hal.DeviceAlreadyLocked") == 0) {
2071 2069
			if (reason_why_locked != NULL) {
2072 2070
				*reason_why_locked =
2073 2071
					dbus_malloc0 (strlen (error->message) + 1);
2072
				if (*reason_why_locked == NULL)
2073
					return FALSE;
2074 2074
				strcpy (*reason_why_locked, error->message);
2075 2075
			}
2076 2076
		}
2077 2077

  
2078
		dbus_message_unref (message);
2079 2078
		return FALSE;
2080 2079
	}
2081

  
2082
	dbus_message_unref (message);
2083

  
2084 2080
	if (reply == NULL)
2085 2081
		return FALSE;
2086 2082

  
......
2089 2085
	return TRUE;
2090 2086
}
2091 2087

  
2092
/** 
2088
/**
2093 2089
 * libhal_device_unlock:
2094 2090
 * @ctx: the context for the connection to hald
2095 2091
 * @udi: the Unique Device Id
......
2126 2122
							   message, -1,
2127 2123
							   error);
2128 2124

  
2125
	dbus_message_unref (message);
2126

  
2129 2127
	if (error != NULL && dbus_error_is_set (error)) {
2130
		dbus_message_unref (message);
2131 2128
		return FALSE;
2132 2129
	}
2133

  
2134
	dbus_message_unref (message);
2135

  
2136 2130
	if (reply == NULL)
2137 2131
		return FALSE;
2138 2132

  
......
2142 2136
}
2143 2137

  
2144 2138

  
2145
/** 
2139
/**
2146 2140
 * libhal_new_device:
2147 2141
 * @ctx: the context for the connection to hald
2148 2142
 * @error: pointer to an initialized dbus error object for returning errors or NULL
......
2181 2175
	reply = dbus_connection_send_with_reply_and_block (ctx->connection,
2182 2176
							   message, -1,
2183 2177
							   error);
2178

  
2179
	dbus_message_unref (message);
2180

  
2184 2181
	if (error != NULL && dbus_error_is_set (error)) {
2185
		dbus_message_unref (message);
2186 2182
		return NULL;
2187 2183
	}
2188 2184
	if (reply == NULL) {
2189
		dbus_message_unref (message);
2190 2185
		return NULL;
2191 2186
	}
2192 2187

  
......
2197 2192
		fprintf (stderr,
2198 2193
			 "%s %d : expected a string in reply to NewDevice\n",
2199 2194
			 __FILE__, __LINE__);
2200
		dbus_message_unref (message);
2201 2195
		dbus_message_unref (reply);
2202 2196
		return NULL;
2203 2197
	}
......
2209 2203
			 __FILE__, __LINE__);
2210 2204
	}
2211 2205

  
2212
	dbus_message_unref (message);
2213 2206
	dbus_message_unref (reply);
2214 2207
	return value;
2215 2208
}
2216 2209

  
2217 2210

  
2218
/** 
2211
/**
2219 2212
 * libhal_device_commit_to_gdl:
2220 2213
 * @ctx: the context for the connection to hald
2221 2214
 * @temp_udi: the temporary unique device id as returned by libhal_new_device()
......
2264 2257
	reply = dbus_connection_send_with_reply_and_block (ctx->connection,
2265 2258
							   message, -1,
2266 2259
							   error);
2260

  
2261
	dbus_message_unref (message);
2262

  
2267 2263
	if (error != NULL && dbus_error_is_set (error)) {
2268
		dbus_message_unref (message);
2269 2264
		return FALSE;
2270 2265
	}
2271 2266
	if (reply == NULL) {
2272
		dbus_message_unref (message);
2273 2267
		return FALSE;
2274 2268
	}
2275 2269

  
2276
	dbus_message_unref (message);
2277 2270
	dbus_message_unref (reply);
2278 2271
	return TRUE;
2279 2272
}
2280 2273

  
2281
/** 
2274
/**
2282 2275
 * libhal_remove_device:
2283 2276
 * @ctx: the context for the connection to hald
2284 2277
 * @udi: the Unique device id.
......
2320 2313
	reply = dbus_connection_send_with_reply_and_block (ctx->connection,
2321 2314
							   message, -1,
2322 2315
							   error);
2316

  
2317
	dbus_message_unref (message);
2318

  
2323 2319
	if (error != NULL && dbus_error_is_set (error)) {
2324
		dbus_message_unref (message);
2325 2320
		return FALSE;
2326 2321
	}
2327 2322
	if (reply == NULL) {
2328
		dbus_message_unref (message);
2329 2323
		return FALSE;
2330 2324
	}
2331 2325

  
2332
	dbus_message_unref (message);
2333 2326
	dbus_message_unref (reply);
2334 2327
	return TRUE;
2335 2328
}
2336 2329

  
2337
/** 
2330
/**
2338 2331
 * libhal_device_exists:
2339 2332
 * @ctx: the context for the connection to hald
2340 2333
 * @udi: the Unique device id.
......
2374 2367
							   message, -1,
2375 2368
							   &_error);
2376 2369

  
2370
	dbus_message_unref (message);
2371

  
2377 2372
	dbus_move_error (&_error, error);
2378 2373
	if (error != NULL && dbus_error_is_set (error)) {
2379
		dbus_message_unref (message);
2380 2374
		return FALSE;
2381 2375
	}
2382 2376
	if (reply == NULL) {
2383
		dbus_message_unref (message);
2384 2377
		return FALSE;
2385 2378
	}
2386 2379

  
......
2391 2384
		fprintf (stderr,
2392 2385
			 "%s %d : expected a bool in reply to DeviceExists\n",
2393 2386
			 __FILE__, __LINE__);
2394
		dbus_message_unref (message);
2395 2387
		dbus_message_unref (reply);
2396 2388
		return FALSE;
2397 2389
	}
2398 2390

  
2399 2391
	dbus_message_iter_get_basic (&reply_iter, &value);
2400 2392

  
2401
	dbus_message_unref (message);
2402 2393
	dbus_message_unref (reply);
2403 2394
	return value;
2404 2395
}
2405 2396

  
2406
/** 
2397
/**
2407 2398
 * libhal_device_property_exists:
2408 2399
 * @ctx: the context for the connection to hald
2409 2400
 * @udi: the Unique device id.
......
2444 2435
							   message, -1,
2445 2436
							   &_error);
2446 2437

  
2438
	dbus_message_unref (message);
2439

  
2447 2440
	dbus_move_error (&_error, error);
2448 2441
	if (error != NULL && dbus_error_is_set (error)) {
2449
		dbus_message_unref (message);
2450 2442
		return FALSE;
2451 2443
	}
2452 2444
	if (reply == NULL) {
2453
		dbus_message_unref (message);
2454 2445
		return FALSE;
2455 2446
	}
2456 2447

  
......
2460 2451
	if (dbus_message_iter_get_arg_type (&reply_iter) != DBUS_TYPE_BOOLEAN) {
2461 2452
		fprintf (stderr, "%s %d : expected a bool in reply to "
2462 2453
			 "PropertyExists\n", __FILE__, __LINE__);
2463
		dbus_message_unref (message);
2464 2454
		dbus_message_unref (reply);
2465 2455
		return FALSE;
2466 2456
	}
2467 2457

  
2468 2458
	dbus_message_iter_get_basic (&reply_iter, &value);
2469 2459

  
2470
	dbus_message_unref (message);
2471 2460
	dbus_message_unref (reply);
2472 2461
	return value;
2473 2462
}
2474 2463

  
2475
/** 
2464
/**
2476 2465
 * libhal_merge_properties:
2477 2466
 * @ctx: the context for the connection to hald
2478 2467
 * @target_udi: the Unique device id of target device to merge to
......
2512 2501
	reply = dbus_connection_send_with_reply_and_block (ctx->connection,
2513 2502
							   message, -1,
2514 2503
							   error);
2504

  
2505
	dbus_message_unref (message);
2506

  
2515 2507
	if (error != NULL && dbus_error_is_set (error)) {
2516
		dbus_message_unref (message);
2517 2508
		return FALSE;
2518 2509
	}
2519 2510
	if (reply == NULL) {
2520
		dbus_message_unref (message);
2521 2511
		return FALSE;
2522 2512
	}
2523 2513

  
2524
	dbus_message_unref (message);
2525 2514
	dbus_message_unref (reply);
2526 2515
	return TRUE;
2527 2516
}
......
2581 2570
							   message, -1,
2582 2571
							   &_error);
2583 2572

  
2573
	dbus_message_unref (message);
2574

  
2584 2575
	dbus_move_error (&_error, error);
2585 2576
	if (error != NULL && dbus_error_is_set (error)) {
2586
		dbus_message_unref (message);
2587 2577
		return FALSE;
2588 2578
	}
2589 2579
	if (reply == NULL) {
2590
		dbus_message_unref (message);
2591 2580
		return FALSE;
2592 2581
	}
2593 2582
	/* now analyse reply */
......
2597 2586
		fprintf (stderr,
2598 2587
			 "%s %d : expected a bool in reply to DeviceMatches\n",
2599 2588
			 __FILE__, __LINE__);
2600
		dbus_message_unref (message);
2601 2589
		dbus_message_unref (reply);
2602 2590
		return FALSE;
2603 2591
	}
2604 2592

  
2605 2593
	dbus_message_iter_get_basic (&reply_iter, &value);
2606 2594

  
2607
	dbus_message_unref (message);
2608 2595
	dbus_message_unref (reply);
2609 2596
	return value;
2610 2597
}
2611 2598

  
2612
/** 
2599
/**
2613 2600
 * libhal_device_print:
2614 2601
 * @ctx: the context for the connection to hald
2615 2602
 * @udi: the Unique Device Id
......
2690 2677
	return TRUE;
2691 2678
}
2692 2679

  
2693
/** 
2680
/**
2694 2681
 * libhal_manager_find_device_string_match:
2695 2682
 * @ctx: the context for the connection to hald
2696 2683
 * @key: name of the property
......
2736 2723
							   message, -1,
2737 2724
							   &_error);
2738 2725

  
2726
	dbus_message_unref (message);
2727

  
2739 2728
	dbus_move_error (&_error, error);
2740 2729
	if (error != NULL && dbus_error_is_set (error)) {
2741
		dbus_message_unref (message);
2742 2730
		return NULL;
2743 2731
	}
2744 2732
	if (reply == NULL) {
2745
		dbus_message_unref (message);
2746 2733
		return NULL;
2747 2734
	}
2748 2735
	/* now analyse reply */
......
2758 2745
	hal_device_names = libhal_get_string_array_from_iter (&iter_array, num_devices);
2759 2746
		      
2760 2747
	dbus_message_unref (reply);
2761
	dbus_message_unref (message);
2762

  
2763 2748
	return hal_device_names;
2764 2749
}
2765 2750

  
2766 2751

  
2767
/** 
2752
/**
2768 2753
 * libhal_device_add_capability:
2769 2754
 * @ctx: the context for the connection to hald
2770 2755
 * @udi: the Unique Device Id
......
2802 2787
	reply = dbus_connection_send_with_reply_and_block (ctx->connection,
2803 2788
							   message, -1,
2804 2789
							   error);
2790

  
2791
	dbus_message_unref (message);
2792

  
2805 2793
	if (error != NULL && dbus_error_is_set (error)) {
2806
		dbus_message_unref (message);
2807 2794
		return FALSE;
2808 2795
	}
2809

  
2810 2796
	if (reply == NULL) {
2811
		dbus_message_unref (message);
2812 2797
		return FALSE;
2813 2798
	}
2814 2799

  
2815 2800
	dbus_message_unref (reply);
2816
	dbus_message_unref (message);
2817 2801
	return TRUE;
2818 2802
}
2819 2803

  
2820
/** 
2804
/**
2821 2805
 * libhal_device_query_capability:
2822 2806
 * @ctx: the context for the connection to hald
2823 2807
 * @udi: the Unique Device Id
......
2854 2838
	return ret;
2855 2839
}
2856 2840

  
2857
/** 
2841
/**
2858 2842
 * libhal_find_device_by_capability:
2859 2843
 * @ctx: the context for the connection to hald
2860 2844
 * @capability: the capability name
......
2895 2879
	reply = dbus_connection_send_with_reply_and_block (ctx->connection,
2896 2880
							   message, -1,
2897 2881
							   &_error);
2898
	
2882

  
2883
	dbus_message_unref (message);
2884

  
2899 2885
	dbus_move_error (&_error, error);
2900 2886
	if (error != NULL && dbus_error_is_set (error)) {
2901
		dbus_message_unref (message);
2902 2887
		return NULL;
2903 2888
	}
2904 2889
	if (reply == NULL) {
2905
		dbus_message_unref (message);
2906 2890
		return NULL;
2907 2891
	}
2908 2892
	/* now analyse reply */
......
2918 2902
	hal_device_names = libhal_get_string_array_from_iter (&iter_array, num_devices);
2919 2903
		      
2920 2904
	dbus_message_unref (reply);
2921
	dbus_message_unref (message);
2922

  
2923 2905
	return hal_device_names;
2924 2906
}
2925 2907

  
2926
/** 
2908
/**
2927 2909
 * libhal_device_property_watch_all:
2928 2910
 * @ctx: the context for the connection to hald
2929 2911
 * @error: pointer to an initialized dbus error object for returning errors or NULL
......
2949 2931
}
2950 2932

  
2951 2933

  
2952
/** 
2934
/**
2953 2935
 * libhal_device_add_property_watch:
2954 2936
 * @ctx: the context for the connection to hald
2955 2937
 * @udi: the Unique Device Id
......
2983 2965
}
2984 2966

  
2985 2967

  
2986
/** 
2968
/**
2987 2969
 * libhal_device_remove_property_watch:
2988 2970
 * @ctx: the context for the connection to hald
2989 2971
 * @udi: the Unique Device Id
......
3013 2995
}
3014 2996

  
3015 2997

  
3016
/** 
2998
/**
3017 2999
 * libhal_ctx_new:
3018 3000
 *
3019 3001
 * Create a new LibHalContext
......
3035 3017
	ctx = calloc (1, sizeof (LibHalContext));
3036 3018
	if (ctx == NULL) {
3037 3019
		fprintf (stderr, 
3038
			 "%s %d : Failed to allocate %d bytes\n",
3039
			 __FILE__, __LINE__, sizeof (LibHalContext));
3020
			 "%s %d : Failed to allocate %lu bytes\n",
3021
			 __FILE__, __LINE__, (unsigned long) sizeof (LibHalContext));
3040 3022
		return NULL;
3041 3023
	}
3042 3024

  
......
3048 3030
	return ctx;
3049 3031
}
3050 3032

  
3051
/** 
3033
/**
3052 3034
 * libhal_ctx_set_cache:
3053 3035
 * @ctx: context to enable/disable cache for
3054 3036
 * @use_cache: whether or not to use cache
......
3067 3049
	return TRUE;
3068 3050
}
3069 3051

  
3070
/** 
3052
/**
3071 3053
 * libhal_ctx_set_dbus_connection:
3072 3054
 * @ctx: context to set connection for
3073 3055
 * @conn: DBus connection to use
......
3088 3070
	return TRUE;
3089 3071
}
3090 3072

  
3091
/** 
3073
/**
3092 3074
 * libhal_ctx_get_dbus_connection:
3093 3075
 * @ctx: context to get connection for
3094 3076
 *
......
3099 3081
DBusConnection *
3100 3082
libhal_ctx_get_dbus_connection (LibHalContext *ctx)
3101 3083
{
3102
	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
3084
	LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL);
3103 3085

  
3104 3086
	return ctx->connection;
3105 3087
}
3106 3088

  
3107 3089

  
3108
/** 
3090
/**
3109 3091
 * libhal_ctx_init:
3110 3092
 * @ctx: Context for connection to hald (D-BUS connection should be set with libhal_ctx_set_dbus_connection)
3111 3093
 * @error: pointer to an initialized dbus error object for returning errors or NULL
......
3156 3138
	return TRUE;
3157 3139
}
3158 3140

  
3159
/** 
3141
/**
3160 3142
 * libhal_ctx_init_direct:
3161 3143
 * @error: pointer to an initialized dbus error object for returning errors or NULL
3162 3144
 *
......
3197 3179
	return ctx;
3198 3180
}
3199 3181

  
3200
/** 
3182
/**
3201 3183
 * libhal_ctx_shutdown:
3202 3184
 * @ctx: the context for the connection to hald
3203 3185
 * @error: pointer to an initialized dbus error object for returning errors or NULL
......
3223 3205
				       "interface='org.freedesktop.Hal.Manager',"
3224 3206
				       "sender='org.freedesktop.Hal',"
3225 3207
				       "path='/org/freedesktop/Hal/Manager'", &myerror);
3226
		dbus_move_error(&myerror, error);
3227
		if (error != NULL && dbus_error_is_set(error)) {
3208
		dbus_move_error (&myerror, error);
3209
		if (error != NULL && dbus_error_is_set (error)) {
3228 3210
			fprintf (stderr, "%s %d : Error unsubscribing to signals, error=%s\n", 
3229 3211
				 __FILE__, __LINE__, error->message);
3230 3212
			/** @todo  clean up */
......
3240 3222
	return TRUE;
3241 3223
}
3242 3224

  
3243
/** 
3225
/**
3244 3226
 * libhal_ctx_free:
3245 3227
 * @ctx: pointer to a LibHalContext
3246 3228
 *
......
3255 3237
	return TRUE;
3256 3238
}
3257 3239

  
3258
/** 
3240
/**
3259 3241
 * libhal_ctx_set_device_added:
3260 3242
 * @ctx: the context for the connection to hald
3261 3243
 * @callback: the function to call when a device is added
......
3273 3255
	return TRUE;
3274 3256
}
3275 3257

  
3276
/** 
3258
/**
3277 3259
 * libhal_ctx_set_device_removed:
3278 3260
 * @ctx: the context for the connection to hald
3279 3261
 * @callback: the function to call when a device is removed
......
3291 3273
	return TRUE;
3292 3274
}
3293 3275

  
3294
/** 
3276
/**
3295 3277
 * libhal_ctx_set_device_new_capability:
3296 3278
 * @ctx: the context for the connection to hald
3297 3279
 * @callback: the function to call when a device gains a new capability
......
3309 3291
	return TRUE;
3310 3292
}
3311 3293

  
3312
/** 
3294
/**
3313 3295
 * libhal_ctx_set_device_lost_capability:
3314 3296
 * @ctx: the context for the connection to hald
3315 3297
 * @callback: the function to call when a device loses a capability
......
3327 3309
	return TRUE;
3328 3310
}
3329 3311

  
3330
/** 
3312
/**
3331 3313
 * libhal_ctx_set_device_property_modified:
3332 3314
 * @ctx: the context for the connection to hald
3333 3315
 * @callback: the function to call when a property is modified on a device
......
3345 3327
	return TRUE;
3346 3328
}
3347 3329

  
3348
/** 
3330
/**
3349 3331
 * libhal_ctx_set_device_condition:
3350 3332
 * @ctx: the context for the connection to hald
3351 3333
 * @callback: the function to call when a device emits a condition
......
3363 3345
	return TRUE;
3364 3346
}
3365 3347

  
3366
/** 
3348
/**
3367 3349
 * libhal_string_array_length:
3368 3350
 * @str_array: array of strings to consider
3369 3351
 *
......
3386 3368
}
3387 3369

  
3388 3370

  
3389
/** 
3371
/**
3390 3372
 * libhal_device_rescan:
3391 3373
 * @ctx: the context for the connection to hald
3392 3374
 * @udi: the Unique id of device
......
3421 3403
							   message, -1,
3422 3404
							   error);
3423 3405

  
3406
	dbus_message_unref (message);
3407

  
3424 3408
	if (error != NULL && dbus_error_is_set (error)) {
3425
		dbus_message_unref (message);
3426 3409
		return FALSE;
3427 3410
	}
3428

  
3429
	dbus_message_unref (message);
3430

  
3431 3411
	if (reply == NULL)
3432 3412
		return FALSE;
3433 3413

  
3434 3414
	dbus_message_iter_init (reply, &reply_iter);
3435 3415
	if (dbus_message_iter_get_arg_type (&reply_iter) !=
3436 3416
		   DBUS_TYPE_BOOLEAN) {
3437
		dbus_message_unref (message);
3438 3417
		dbus_message_unref (reply);
3439 3418
		return FALSE;
3440 3419
	}
......
3445 3424
	return result;
3446 3425
}
3447 3426

  
3448
/** 
3427
/**
3449 3428
 * libhal_device_reprobe:
3450 3429
 * @ctx: the context for the connection to hald
3451 3430
 * @udi: the Unique id of device
......
3481 3460
							   message, -1,
3482 3461
							   error);
3483 3462

  
3463
	dbus_message_unref (message);
3464

  
3484 3465
	if (error != NULL && dbus_error_is_set (error)) {
3485
		dbus_message_unref (message);
3486 3466
		return FALSE;
3487 3467
	}
3488

  
3489
	dbus_message_unref (message);
3490

  
3491 3468
	if (reply == NULL)
3492 3469
		return FALSE;
3493 3470

  
3494 3471
	dbus_message_iter_init (reply, &reply_iter);
3495 3472
	if (dbus_message_iter_get_arg_type (&reply_iter) !=
3496 3473
		   DBUS_TYPE_BOOLEAN) {
3497
		dbus_message_unref (message);
3498 3474
		dbus_message_unref (reply);
3499 3475
		return FALSE;
3500 3476
	}
......
3505 3481
	return result;
3506 3482
}
3507 3483

  
3508
/** 
3484
/**
3509 3485
 * libhal_device_emit_condition:
3510 3486
 * @ctx: the context for the connection to hald
3511 3487
 * @udi: the Unique Device Id
......
3552 3528
							   message, -1,
3553 3529
							   error);
3554 3530

  
3531
	dbus_message_unref (message);
3532

  
3555 3533
	if (error != NULL && dbus_error_is_set (error)) {
3556
		dbus_message_unref (message);
3534
		fprintf (stderr,
3535
			 "%s %d : Failure sending D-BUS message: %s: %s\n",
3536
			 __FILE__, __LINE__, error->name, error->message);
3557 3537
		return FALSE;
3558 3538
	}
3559 3539

  
3560
	dbus_message_unref (message);
3561

  
3562
	if (reply == NULL)
3540
	if (reply == NULL) {
3541
		fprintf (stderr,
3542
			 "%s %d : Got no reply\n",
3543
			 __FILE__, __LINE__);
3563 3544
		return FALSE;
3545
	}
3564 3546

  
3565 3547
	dbus_message_iter_init (reply, &reply_iter);
3566 3548
	if (dbus_message_iter_get_arg_type (&reply_iter) !=
3567 3549
		   DBUS_TYPE_BOOLEAN) {
3568
		dbus_message_unref (message);
3569 3550
		dbus_message_unref (reply);
3551
		fprintf (stderr,
3552
			 "%s %d : Malformed reply\n",
3553
			 __FILE__, __LINE__);
3570 3554
		return FALSE;
3571 3555
	}
3572 3556
	dbus_message_iter_get_basic (&reply_iter, &result);
......
3618 3602
							   message, -1,
3619 3603
							   error);
3620 3604

  
3605
	dbus_message_unref (message);
3606

  
3621 3607
	if (error != NULL && dbus_error_is_set (error)) {
3622
		dbus_message_unref (message);
3623 3608
		return FALSE;
3624 3609
	}
3625

  
3626
	dbus_message_unref (message);
3627

  
3628 3610
	if (reply == NULL)
3629 3611
		return FALSE;
3630 3612

  
3631 3613
	dbus_message_iter_init (reply, &reply_iter);
3632 3614
	if (dbus_message_iter_get_arg_type (&reply_iter) != DBUS_TYPE_BOOLEAN) {
3633
		dbus_message_unref (message);
3634 3615
		dbus_message_unref (reply);
3635 3616
		return FALSE;
3636 3617
	}
......
3640 3621
	return result;	
3641 3622
}
3642 3623

  
3643
/** 
3624
/**
3644 3625
 * libhal_device_claim_interface:
3645 3626
 * @ctx: the context for the connection to hald
3646 3627
 * @udi: the Unique Device Id
......
3689 3670
							   message, -1,
3690 3671
							   error);
3691 3672

  
3673
	dbus_message_unref (message);
3674

  
3692 3675
	if (error != NULL && dbus_error_is_set (error)) {
3693
		dbus_message_unref (message);
3694 3676
		return FALSE;
3695 3677
	}
3696

  
3697
	dbus_message_unref (message);
3698

  
3699 3678
	if (reply == NULL)
3700 3679
		return FALSE;
3701 3680

  
3702 3681
	dbus_message_iter_init (reply, &reply_iter);
3703 3682
	if (dbus_message_iter_get_arg_type (&reply_iter) !=
3704 3683
		   DBUS_TYPE_BOOLEAN) {
3705
		dbus_message_unref (message);
3706 3684
		dbus_message_unref (reply);
3707 3685
		return FALSE;
3708 3686
	}
......
3790 3768

  
3791 3769

  
3792 3770
/**
3793
 * libhal_device_set_property_string:
3771
 * libhal_changeset_set_property_string:
3794 3772
 * @changeset: the changeset
3795 3773
 * @key: key of property 
3796 3774
 * @value: the value to set
......
3829 3807
}
3830 3808

  
3831 3809
/**
3832
 * libhal_device_set_property_int:
3810
 * libhal_changeset_set_property_int:
3833 3811
 * @changeset: the changeset
3834 3812
 * @key: key of property 
3835 3813
 * @value: the value to set
......
3862 3840
}
3863 3841

  
3864 3842
/**
3865
 * libhal_device_set_property_uint64:
3843
 * libhal_changeset_set_property_uint64:
3866 3844
 * @changeset: the changeset
3867 3845
 * @key: key of property 
3868 3846
 * @value: the value to set
......
3895 3873
}
3896 3874

  
3897 3875
/**
3898
 * libhal_device_set_property_double:
3876
 * libhal_changeset_set_property_double:
3899 3877
 * @changeset: the changeset
3900 3878
 * @key: key of property 
3901 3879
 * @value: the value to set
......
3928 3906
}
3929 3907

  
3930 3908
/**
3931
 * libhal_device_set_property_bool:
3909
 * libhal_changeset_set_property_bool:
3932 3910
 * @changeset: the changeset
3933 3911
 * @key: key of property 
3934 3912
 * @value: the value to set
......
3961 3939
}
3962 3940

  
3963 3941
/**
3964
 * libhal_device_set_property_strlist:
3942
 * libhal_changeset_set_property_strlist:
3965 3943
 * @changeset: the changeset
3966 3944
 * @key: key of property 
3967 3945
 * @value: the value to set - NULL terminated array of strings
......
4132 4110
							   message, -1,
4133 4111
							   &_error);
4134 4112

  
4113
	dbus_message_unref (message);
4114

  
4135 4115
	dbus_move_error (&_error, error);
4136 4116
	if (error != NULL && dbus_error_is_set (error)) {
4137 4117
		fprintf (stderr,
4138 4118
			 "%s %d : %s\n",
4139 4119
			 __FILE__, __LINE__, error->message);
4140 4120

  
4141
		dbus_message_unref (message);
4142 4121
		return FALSE;
4143 4122
	}
4144

  
4145 4123
	if (reply == NULL) {
4146
		dbus_message_unref (message);
4147 4124
		return FALSE;
4148 4125
	}
4149 4126

  
4127
	dbus_message_unref (reply);
4150 4128
	return TRUE;
4151 4129
}
4152 4130

  
    (1-1/1)