const std::string KRATE_CREATE_HOOK_PATH = "/etc/gumd/useradd.d";
const std::string KRATE_REMOVE_HOOK_PATH = "/etc/gumd/userdel.d";
-std::string KRATE_DEFAULT_OWNER = "owner";
+std::string KRATE_DEFAULT_OWNER;
std::list<std::string> createdKrateList;
static std::atomic<bool> isKrateForeground(false);
#define NT_ERROR_NONE NOTIFICATION_ERROR_NONE
-void krateProcessCallback(GDBusConnection *connection,
- const gchar *sender, const gchar *objectPath,
- const gchar *interface, const gchar *signalName,
- GVariant *params, gpointer userData)
-{
- static runtime::User owner(KRATE_DEFAULT_OWNER);
- int pid, status;
-
- notification_h noti = reinterpret_cast<notification_h>(userData);
-
- g_variant_get(params, "(ii)", &status, &pid);
-
- if (status != 5) {
- return;
- }
-
- struct stat st;
- std::string proc("/proc/" + std::to_string(pid));
- if (::stat(proc.c_str(), &st) != 0) {
- return;
- }
-
- if (st.st_uid == owner.getUid() || st.st_uid == 0) {
- if (isKrateForeground) {
- notification_delete_for_uid(noti, owner.getUid());
- isKrateForeground = false;
- }
- } else {
- if (!isKrateForeground) {
- notification_set_text(noti, NT_CONTENT, NT_APPINFO, NULL, NT_NONE);
- notification_post_for_uid(noti, owner.getUid());
- isKrateForeground = true;
- }
- }
-}
-
notification_h createNotification()
{
notification_h noti = notification_create(NOTIFICATION_TYPE_ONGOING);
void krateProcessMonitor()
{
- GError *error = NULL;
- GDBusConnection* connection;
- connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (connection == NULL) {
- ERROR("GBus Connection failed");
- g_error_free(error);
- return;
- }
-
+ dbus::Connection& systemDBus = dbus::Connection::getSystem();
notification_h noti = createNotification();
if (noti == NULL) {
ERROR("Failed to created notification");
return;
}
- g_dbus_connection_signal_subscribe(connection,
- NULL,
- "org.tizen.resourced.process",
- "ProcStatus",
- "/Org/Tizen/ResourceD/Process",
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- krateProcessCallback,
- reinterpret_cast<gpointer>(noti),
- NULL);
+ systemDBus.subscribeSignal("",
+ "org.tizen.resourced.process",
+ "ProcStatus",
+ "/Org/Tizen/ResourceD/Process",
+ [noti] (dbus::Variant param) {
+ static runtime::User owner(KRATE_DEFAULT_OWNER);
+ int pid, status;
+ struct stat st;
+
+ param.get("(ii)", &status, &pid);
+
+ if (status != 5) {
+ return;
+ }
+
+ std::string proc("/proc/" + std::to_string(pid));
+ if (::stat(proc.c_str(), &st) != 0) {
+ return;
+ }
+
+ if (st.st_uid == owner.getUid() || st.st_uid == 0) {
+ if (isKrateForeground) {
+ notification_delete_for_uid(noti, owner.getUid());
+ isKrateForeground = false;
+ }
+ } else {
+ if (!isKrateForeground) {
+ notification_set_text(noti, NT_CONTENT, NT_APPINFO, NULL, NT_NONE);
+ notification_post_for_uid(noti, owner.getUid());
+ isKrateForeground = true;
+ }
+ }
+ });
}
void notiProxyInsert(const runtime::User& owner, const runtime::User& user, int privId, notification_h noti)