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

Remove unnecessary "id" member of TrNotification in gtk/notify.c #851

Merged
merged 3 commits into from
Aug 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions gtk/notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ static gboolean server_supports_actions = FALSE;

typedef struct TrNotification
{
guint id;
TrCore* core;
int torrent_id;
}
Expand Down Expand Up @@ -89,7 +88,7 @@ static void g_signal_callback(GDBusProxy const* dbus_proxy, char const* sender_n
g_return_if_fail(g_variant_is_of_type(params, G_VARIANT_TYPE("(u*)")));

g_variant_get(params, "(u*)", &id, NULL);
n = g_hash_table_lookup(active_notifications, GINT_TO_POINTER((int*)&id));
n = g_hash_table_lookup(active_notifications, GUINT_TO_POINTER(id));

if (n == NULL)
{
Expand All @@ -98,7 +97,7 @@ static void g_signal_callback(GDBusProxy const* dbus_proxy, char const* sender_n

if (g_strcmp0(signal_name, "NotificationClosed") == 0)
{
g_hash_table_remove(active_notifications, GINT_TO_POINTER((int*)&n->id));
g_hash_table_remove(active_notifications, GUINT_TO_POINTER(id));
}
else if (g_strcmp0(signal_name, "ActionInvoked") == 0 && g_variant_is_of_type(params, G_VARIANT_TYPE("(us)")))
{
Expand Down Expand Up @@ -146,7 +145,7 @@ static void dbus_proxy_ready_callback(GObject* source, GAsyncResult* res, gpoint

void gtr_notify_init(void)
{
active_notifications = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, tr_notification_free);
active_notifications = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, tr_notification_free);
g_dbus_proxy_new_for_bus(G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL, NOTIFICATIONS_DBUS_NAME,
NOTIFICATIONS_DBUS_CORE_OBJECT, NOTIFICATIONS_DBUS_CORE_INTERFACE, NULL, dbus_proxy_ready_callback, NULL);
}
Expand All @@ -169,8 +168,9 @@ static void notify_callback(GObject* source, GAsyncResult* res, gpointer user_da
return;
}

g_variant_get(result, "(u)", &n->id);
g_hash_table_insert(active_notifications, GINT_TO_POINTER((int*)&n->id), n);
guint id;
g_variant_get(result, "(u)", &id);
g_hash_table_insert(active_notifications, GUINT_TO_POINTER(id), n);

g_variant_unref(result);
}
Expand Down Expand Up @@ -227,7 +227,7 @@ void gtr_notify_torrent_completed(TrCore* core, int torrent_id)
g_variant_builder_init(&hints_builder, G_VARIANT_TYPE("a{sv}"));
g_variant_builder_add(&hints_builder, "{sv}", "category", g_variant_new_string("transfer.complete"));

g_dbus_proxy_call(proxy, "Notify", g_variant_new("(susssasa{sv}i)", "Transmission", n->id, "transmission",
g_dbus_proxy_call(proxy, "Notify", g_variant_new("(susssasa{sv}i)", "Transmission", 0, "transmission",
_("Torrent Complete"), tr_torrentName(tor), &actions_builder, &hints_builder, -1), G_DBUS_CALL_FLAGS_NONE, -1, NULL,
notify_callback, n);
}
Expand Down