Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XdpAppInfo cleanups #1619

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/xdp-app-info-flatpak.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,10 +826,10 @@ xdp_app_info_flatpak_new (int pid,
"engine", FLATPAK_ENGINE_ID,
"id", id,
"instance", instance,
"pidfd", bwrap_pidfd,
NULL);

xdp_app_info_initialize (XDP_APP_INFO (app_info_flatpak),
bwrap_pidfd, gappinfo, flags);
xdp_app_info_initialize (XDP_APP_INFO (app_info_flatpak), gappinfo, flags);

app_info_flatpak->flatpak_info = g_steal_pointer (&metadata);

Expand Down
3 changes: 2 additions & 1 deletion src/xdp-app-info-host.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,11 @@ xdp_app_info_host_new_full (const char *app_id,
error,
"engine", NULL,
"id", app_id,
"pidfd", pidfd,
NULL);

xdp_app_info_initialize (XDP_APP_INFO (app_info_host),
pidfd, gappinfo,
gappinfo,
XDP_APP_INFO_FLAG_HAS_NETWORK |
XDP_APP_INFO_FLAG_SUPPORTS_OPATH);

Expand Down
1 change: 0 additions & 1 deletion src/xdp-app-info-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,5 @@ struct _XdpAppInfoClass
};

void xdp_app_info_initialize (XdpAppInfo *app_info,
int pidfd,
GAppInfo *gappinfo,
XdpAppInfoFlags flags);
4 changes: 2 additions & 2 deletions src/xdp-app-info-snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ xdp_app_info_snap_new (int pid,
error,
"engine", "io.snapcraft",
"id", snap_id,
"pidfd", pidfd,
NULL);

xdp_app_info_initialize (XDP_APP_INFO (app_info_snap),
pidfd, gappinfo, flags);
xdp_app_info_initialize (XDP_APP_INFO (app_info_snap), gappinfo, flags);

return XDP_APP_INFO (g_steal_pointer (&app_info_snap));
}
2 changes: 1 addition & 1 deletion src/xdp-app-info-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ xdp_app_info_test_new (const char *app_id,
NULL);

xdp_app_info_initialize (XDP_APP_INFO (app_info_test),
-1, NULL,
NULL,
XDP_APP_INFO_FLAG_HAS_NETWORK |
XDP_APP_INFO_FLAG_SUPPORTS_OPATH);

Expand Down
19 changes: 17 additions & 2 deletions src/xdp-app-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ enum
PROP_ENGINE,
PROP_ID,
PROP_INSTANCE,
PROP_PIDFD,
N_PROPS
};

Expand Down Expand Up @@ -144,6 +145,10 @@ xdp_app_info_get_property (GObject *object,
g_value_set_string (value, priv->instance);
break;

case PROP_PIDFD:
g_value_set_int (value, priv->pidfd);
break;

default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
Expand Down Expand Up @@ -175,6 +180,11 @@ xdp_app_info_set_property (GObject *object,
priv->instance = g_value_dup_string (value);
break;

case PROP_PIDFD:
g_assert (priv->pidfd == -1);
priv->pidfd = dup (g_value_get_int (value));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typedef enum _XdpAppInfoFlags

tbh, I'm unsure why this even is a pattern in e.g. mutter but at least it makes it easy to grep for the declaration...

break;

default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
Expand Down Expand Up @@ -210,6 +220,13 @@ xdp_app_info_class_init (XdpAppInfoClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);

properties[PROP_PIDFD] =
g_param_spec_int ("pidfd", NULL, NULL,
-1, G_MAXINT, -1,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);

g_object_class_install_properties (object_class, N_PROPS, properties);
}

Expand All @@ -223,13 +240,11 @@ xdp_app_info_init (XdpAppInfo *app_info)

void
xdp_app_info_initialize (XdpAppInfo *app_info,
int pidfd,
GAppInfo *gappinfo,
XdpAppInfoFlags flags)
{
XdpAppInfoPrivate *priv = xdp_app_info_get_instance_private (app_info);

priv->pidfd = dup (pidfd);
g_set_object (&priv->gappinfo, gappinfo);
priv->flags = flags;
}
Expand Down