421
* pk_backend_package_is_application:
424
pk_backend_package_is_application (ZifPackage *package,
425
gboolean *is_application,
429
const gchar *filename;
434
/* get file lists and see if it installs a desktop file */
435
files = zif_package_get_files (package, state, error);
440
for (i = 0; i < files->len; i++) {
441
filename = g_ptr_array_index (files, i);
442
if (g_str_has_prefix (filename, "/usr/share/applications/") &&
443
g_str_has_suffix (filename, ".desktop")) {
444
*is_application = TRUE;
449
/* not an application */
450
*is_application = FALSE;
453
g_ptr_array_unref (files);
421
458
* pk_backend_filter_package_array:
423
460
static GPtrArray *
424
pk_backend_filter_package_array (GPtrArray *array, PkBitfield filters)
461
pk_backend_filter_package_array (GPtrArray *array,
426
GHashTable *hash_installed;
466
gboolean is_application;
468
GHashTable *hash_application = NULL;
469
GHashTable *hash_installed = NULL;
428
471
GPtrArray *result = NULL;
430
473
ZifPackage *package;
474
ZifState *state_local;
475
ZifState *state_loop;
477
/* get the filelists if the application filter is used */
478
if (pk_bitfield_contain (filters, PK_FILTER_ENUM_APPLICATION) ||
479
pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_APPLICATION)) {
480
hash_application = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
481
state_local = zif_state_get_child (state);
482
zif_state_set_number_steps (state_local, array->len);
483
for (i = 0; i < array->len; i++) {
484
package = g_ptr_array_index (array, i);
485
state_loop = zif_state_get_child (state_local);
486
ret = pk_backend_package_is_application (package,
492
if (is_application) {
493
g_hash_table_insert (hash_application,
494
(gpointer) zif_package_get_name_version_arch (package),
495
GINT_TO_POINTER (1));
432
500
hash_installed = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
433
501
result = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
537
if (pk_bitfield_contain (filters,
538
PK_FILTER_ENUM_APPLICATION)) {
539
found = g_hash_table_lookup (hash_application,
540
zif_package_get_name_version_arch (package));
468
545
/* development */
469
546
if (pk_bitfield_contain (filters,
470
547
PK_FILTER_ENUM_DEVELOPMENT)) {
517
594
if (pk_bitfield_contain (filters, PK_FILTER_ENUM_NEWEST))
518
595
zif_package_array_filter_newest (result);
520
g_hash_table_destroy (hash_installed);
598
if (hash_application != NULL)
599
g_hash_table_destroy (hash_application);
600
if (hash_installed != NULL)
601
g_hash_table_destroy (hash_installed);
1308
result = pk_backend_filter_package_array (array, filters);
1389
state_local = zif_state_get_child (priv->state);
1390
result = pk_backend_filter_package_array (array,
1394
if (result == NULL) {
1395
pk_backend_error_code (backend,
1396
PK_ERROR_ENUM_CANNOT_GET_FILELIST,
1397
"failed to filters: %s",
1399
g_error_free (error);
1310
1403
/* this section done */
1311
1404
ret = zif_state_done (priv->state, &error);
1586
1679
pk_debug_add_log_domain ("Zif");
1588
1681
/* create private area */
1589
priv = g_new0 (PkBackendYumPrivate, 1);
1682
priv = g_new0 (PkBackendZifPrivate, 1);
1591
1684
/* connect to finished, so we can clean up */
1592
1685
priv->signal_finished =
2206
result = pk_backend_filter_package_array (array, filters);
2300
state_local = zif_state_get_child (priv->state);
2301
result = pk_backend_filter_package_array (array,
2305
if (result == NULL) {
2306
pk_backend_error_code (backend,
2307
PK_ERROR_ENUM_CANNOT_GET_FILELIST,
2308
"failed to filter: %s",
2310
g_error_free (error);
2208
2314
/* this section done */
2209
2315
ret = zif_state_done (priv->state, &error);
2419
result = pk_backend_filter_package_array (array, filters);
2525
state_local = zif_state_get_child (priv->state);
2526
result = pk_backend_filter_package_array (array,
2530
if (result == NULL) {
2531
pk_backend_error_code (backend,
2532
PK_ERROR_ENUM_CANNOT_GET_FILELIST,
2533
"failed to filter: %s",
2535
g_error_free (error);
2421
2539
/* this section done */
2422
2540
ret = zif_state_done (priv->state, &error);
3191
result = pk_backend_filter_package_array (updates_available, filters);
3309
state_local = zif_state_get_child (priv->state);
3310
result = pk_backend_filter_package_array (updates_available,
3314
if (result == NULL) {
3315
pk_backend_error_code (backend,
3316
PK_ERROR_ENUM_CANNOT_GET_FILELIST,
3317
"failed to filter: %s",
3319
g_error_free (error);
3194
3324
pk_backend_set_percentage (backend, 100);