diff options
author | Jacki <jacki@thejackimonster.de> | 2024-02-14 13:44:06 +0100 |
---|---|---|
committer | Jacki <jacki@thejackimonster.de> | 2024-02-14 13:44:06 +0100 |
commit | 17392fe6169d39a75645728f44aa117f67b5331d (patch) | |
tree | cd9df10fc8a58c8104a494dcc6e1e44c09ccf8ca /src/ui | |
parent | 9ff0f0e2e8d554f465d7aad51ce7fb33e61a749c (diff) | |
download | messenger-gtk-17392fe6169d39a75645728f44aa117f67b5331d.tar.gz messenger-gtk-17392fe6169d39a75645728f44aa117f67b5331d.zip |
Add asserts to verify reliability
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat (limited to 'src/ui')
42 files changed, 1090 insertions, 653 deletions
diff --git a/src/ui/about.c b/src/ui/about.c index 70b2cd0..6306a74 100644 --- a/src/ui/about.c +++ b/src/ui/about.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2022 GNUnet e.V. | 3 | Copyright (C) 2022--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -28,73 +28,81 @@ | |||
28 | 28 | ||
29 | static void | 29 | static void |
30 | handle_close_button_click(UNUSED GtkButton *button, | 30 | handle_close_button_click(UNUSED GtkButton *button, |
31 | gpointer user_data) | 31 | gpointer user_data) |
32 | { | 32 | { |
33 | g_assert(user_data); | ||
34 | |||
33 | GtkAboutDialog *dialog = GTK_ABOUT_DIALOG(user_data); | 35 | GtkAboutDialog *dialog = GTK_ABOUT_DIALOG(user_data); |
34 | gtk_window_close(GTK_WINDOW(dialog)); | 36 | gtk_window_close(GTK_WINDOW(dialog)); |
35 | } | 37 | } |
36 | 38 | ||
37 | static void | 39 | static void |
38 | handle_dialog_destroy(UNUSED GtkWidget *window, | 40 | handle_dialog_destroy(UNUSED GtkWidget *window, |
39 | gpointer user_data) | 41 | gpointer user_data) |
40 | { | 42 | { |
43 | g_assert(user_data); | ||
44 | |||
41 | ui_about_dialog_cleanup((UI_ABOUT_Handle*) user_data); | 45 | ui_about_dialog_cleanup((UI_ABOUT_Handle*) user_data); |
42 | } | 46 | } |
43 | 47 | ||
44 | void | 48 | void |
45 | ui_about_dialog_init(MESSENGER_Application *app, | 49 | ui_about_dialog_init(MESSENGER_Application *app, |
46 | UI_ABOUT_Handle *handle) | 50 | UI_ABOUT_Handle *handle) |
47 | { | 51 | { |
52 | g_assert((app) && (handle)); | ||
53 | |||
48 | handle->builder = gtk_builder_new_from_resource( | 54 | handle->builder = gtk_builder_new_from_resource( |
49 | application_get_resource_path(app, "ui/about.ui") | 55 | application_get_resource_path(app, "ui/about.ui") |
50 | ); | 56 | ); |
51 | 57 | ||
52 | handle->dialog = GTK_ABOUT_DIALOG( | 58 | handle->dialog = GTK_ABOUT_DIALOG( |
53 | gtk_builder_get_object(handle->builder, "about_dialog") | 59 | gtk_builder_get_object(handle->builder, "about_dialog") |
54 | ); | 60 | ); |
55 | 61 | ||
56 | gtk_window_set_transient_for( | 62 | gtk_window_set_transient_for( |
57 | GTK_WINDOW(handle->dialog), | 63 | GTK_WINDOW(handle->dialog), |
58 | GTK_WINDOW(app->ui.messenger.main_window) | 64 | GTK_WINDOW(app->ui.messenger.main_window) |
59 | ); | 65 | ); |
60 | 66 | ||
61 | gtk_about_dialog_set_program_name( | 67 | gtk_about_dialog_set_program_name( |
62 | handle->dialog, | 68 | handle->dialog, |
63 | MESSENGER_APPLICATION_APPNAME | 69 | MESSENGER_APPLICATION_APPNAME |
64 | ); | 70 | ); |
65 | 71 | ||
66 | gtk_about_dialog_set_version( | 72 | gtk_about_dialog_set_version( |
67 | handle->dialog, | 73 | handle->dialog, |
68 | MESSENGER_APPLICATION_VERSION | 74 | MESSENGER_APPLICATION_VERSION |
69 | ); | 75 | ); |
70 | 76 | ||
71 | gtk_about_dialog_set_logo_icon_name( | 77 | gtk_about_dialog_set_logo_icon_name( |
72 | handle->dialog, | 78 | handle->dialog, |
73 | MESSENGER_APPLICATION_ID | 79 | MESSENGER_APPLICATION_ID |
74 | ); | 80 | ); |
75 | 81 | ||
76 | handle->close_button = GTK_BUTTON( | 82 | handle->close_button = GTK_BUTTON( |
77 | gtk_builder_get_object(handle->builder, "close_button") | 83 | gtk_builder_get_object(handle->builder, "close_button") |
78 | ); | 84 | ); |
79 | 85 | ||
80 | g_signal_connect( | 86 | g_signal_connect( |
81 | handle->close_button, | 87 | handle->close_button, |
82 | "clicked", | 88 | "clicked", |
83 | G_CALLBACK(handle_close_button_click), | 89 | G_CALLBACK(handle_close_button_click), |
84 | handle->dialog | 90 | handle->dialog |
85 | ); | 91 | ); |
86 | 92 | ||
87 | g_signal_connect( | 93 | g_signal_connect( |
88 | handle->dialog, | 94 | handle->dialog, |
89 | "destroy", | 95 | "destroy", |
90 | G_CALLBACK(handle_dialog_destroy), | 96 | G_CALLBACK(handle_dialog_destroy), |
91 | handle | 97 | handle |
92 | ); | 98 | ); |
93 | } | 99 | } |
94 | 100 | ||
95 | void | 101 | void |
96 | ui_about_dialog_cleanup(UI_ABOUT_Handle *handle) | 102 | ui_about_dialog_cleanup(UI_ABOUT_Handle *handle) |
97 | { | 103 | { |
104 | g_assert(handle); | ||
105 | |||
98 | g_object_unref(handle->builder); | 106 | g_object_unref(handle->builder); |
99 | 107 | ||
100 | memset(handle, 0, sizeof(*handle)); | 108 | memset(handle, 0, sizeof(*handle)); |
diff --git a/src/ui/about.h b/src/ui/about.h index e96641a..56ecc12 100644 --- a/src/ui/about.h +++ b/src/ui/about.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2022 GNUnet e.V. | 3 | Copyright (C) 2022--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -44,7 +44,7 @@ typedef struct UI_ABOUT_Handle | |||
44 | */ | 44 | */ |
45 | void | 45 | void |
46 | ui_about_dialog_init(MESSENGER_Application *app, | 46 | ui_about_dialog_init(MESSENGER_Application *app, |
47 | UI_ABOUT_Handle *handle); | 47 | UI_ABOUT_Handle *handle); |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * Cleans up the allocated resources and resets the | 50 | * Cleans up the allocated resources and resets the |
diff --git a/src/ui/account_entry.c b/src/ui/account_entry.c index 7a9ccdb..89c7c7a 100644 --- a/src/ui/account_entry.c +++ b/src/ui/account_entry.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -30,22 +30,24 @@ | |||
30 | UI_ACCOUNT_ENTRY_Handle* | 30 | UI_ACCOUNT_ENTRY_Handle* |
31 | ui_account_entry_new(MESSENGER_Application *app) | 31 | ui_account_entry_new(MESSENGER_Application *app) |
32 | { | 32 | { |
33 | g_assert(app); | ||
34 | |||
33 | UI_ACCOUNT_ENTRY_Handle* handle = g_malloc(sizeof(UI_ACCOUNT_ENTRY_Handle)); | 35 | UI_ACCOUNT_ENTRY_Handle* handle = g_malloc(sizeof(UI_ACCOUNT_ENTRY_Handle)); |
34 | 36 | ||
35 | handle->builder = gtk_builder_new_from_resource( | 37 | handle->builder = gtk_builder_new_from_resource( |
36 | application_get_resource_path(app, "ui/account_entry.ui") | 38 | application_get_resource_path(app, "ui/account_entry.ui") |
37 | ); | 39 | ); |
38 | 40 | ||
39 | handle->entry_box = GTK_WIDGET( | 41 | handle->entry_box = GTK_WIDGET( |
40 | gtk_builder_get_object(handle->builder, "entry_box") | 42 | gtk_builder_get_object(handle->builder, "entry_box") |
41 | ); | 43 | ); |
42 | 44 | ||
43 | handle->entry_avatar = HDY_AVATAR( | 45 | handle->entry_avatar = HDY_AVATAR( |
44 | gtk_builder_get_object(handle->builder, "entry_avatar") | 46 | gtk_builder_get_object(handle->builder, "entry_avatar") |
45 | ); | 47 | ); |
46 | 48 | ||
47 | handle->entry_label = GTK_LABEL( | 49 | handle->entry_label = GTK_LABEL( |
48 | gtk_builder_get_object(handle->builder, "entry_label") | 50 | gtk_builder_get_object(handle->builder, "entry_label") |
49 | ); | 51 | ); |
50 | 52 | ||
51 | return handle; | 53 | return handle; |
@@ -53,8 +55,10 @@ ui_account_entry_new(MESSENGER_Application *app) | |||
53 | 55 | ||
54 | void | 56 | void |
55 | ui_account_entry_set_account(UI_ACCOUNT_ENTRY_Handle* handle, | 57 | ui_account_entry_set_account(UI_ACCOUNT_ENTRY_Handle* handle, |
56 | const struct GNUNET_CHAT_Account *account) | 58 | const struct GNUNET_CHAT_Account *account) |
57 | { | 59 | { |
60 | g_assert((handle) && (account)); | ||
61 | |||
58 | const char *name = GNUNET_CHAT_account_get_name(account); | 62 | const char *name = GNUNET_CHAT_account_get_name(account); |
59 | 63 | ||
60 | ui_avatar_set_text(handle->entry_avatar, name); | 64 | ui_avatar_set_text(handle->entry_avatar, name); |
@@ -63,8 +67,10 @@ ui_account_entry_set_account(UI_ACCOUNT_ENTRY_Handle* handle, | |||
63 | 67 | ||
64 | void | 68 | void |
65 | ui_account_entry_set_contact(UI_ACCOUNT_ENTRY_Handle* handle, | 69 | ui_account_entry_set_contact(UI_ACCOUNT_ENTRY_Handle* handle, |
66 | const struct GNUNET_CHAT_Contact *contact) | 70 | const struct GNUNET_CHAT_Contact *contact) |
67 | { | 71 | { |
72 | g_assert((handle) && (contact)); | ||
73 | |||
68 | const char *name = GNUNET_CHAT_contact_get_name(contact); | 74 | const char *name = GNUNET_CHAT_contact_get_name(contact); |
69 | 75 | ||
70 | ui_avatar_set_text(handle->entry_avatar, name); | 76 | ui_avatar_set_text(handle->entry_avatar, name); |
@@ -74,6 +80,8 @@ ui_account_entry_set_contact(UI_ACCOUNT_ENTRY_Handle* handle, | |||
74 | void | 80 | void |
75 | ui_account_entry_delete(UI_ACCOUNT_ENTRY_Handle *handle) | 81 | ui_account_entry_delete(UI_ACCOUNT_ENTRY_Handle *handle) |
76 | { | 82 | { |
83 | g_assert(handle); | ||
84 | |||
77 | g_object_unref(handle->builder); | 85 | g_object_unref(handle->builder); |
78 | 86 | ||
79 | g_free(handle); | 87 | g_free(handle); |
diff --git a/src/ui/account_entry.h b/src/ui/account_entry.h index ef79fb2..d628fd0 100644 --- a/src/ui/account_entry.h +++ b/src/ui/account_entry.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -58,7 +58,7 @@ ui_account_entry_new(MESSENGER_Application *app); | |||
58 | */ | 58 | */ |
59 | void | 59 | void |
60 | ui_account_entry_set_account(UI_ACCOUNT_ENTRY_Handle* handle, | 60 | ui_account_entry_set_account(UI_ACCOUNT_ENTRY_Handle* handle, |
61 | const struct GNUNET_CHAT_Account *account); | 61 | const struct GNUNET_CHAT_Account *account); |
62 | 62 | ||
63 | /** | 63 | /** |
64 | * Sets the content of the given account entry | 64 | * Sets the content of the given account entry |
@@ -70,7 +70,7 @@ ui_account_entry_set_account(UI_ACCOUNT_ENTRY_Handle* handle, | |||
70 | */ | 70 | */ |
71 | void | 71 | void |
72 | ui_account_entry_set_contact(UI_ACCOUNT_ENTRY_Handle* handle, | 72 | ui_account_entry_set_contact(UI_ACCOUNT_ENTRY_Handle* handle, |
73 | const struct GNUNET_CHAT_Contact *contact); | 73 | const struct GNUNET_CHAT_Contact *contact); |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Frees its resources and destroys a given | 76 | * Frees its resources and destroys a given |
diff --git a/src/ui/accounts.c b/src/ui/accounts.c index cd6e2f5..2e99d0f 100644 --- a/src/ui/accounts.c +++ b/src/ui/accounts.c | |||
@@ -31,6 +31,8 @@ static void | |||
31 | handle_close_button_click(UNUSED GtkButton *button, | 31 | handle_close_button_click(UNUSED GtkButton *button, |
32 | gpointer user_data) | 32 | gpointer user_data) |
33 | { | 33 | { |
34 | g_assert(user_data); | ||
35 | |||
34 | GtkDialog *dialog = GTK_DIALOG(user_data); | 36 | GtkDialog *dialog = GTK_DIALOG(user_data); |
35 | gtk_window_close(GTK_WINDOW(dialog)); | 37 | gtk_window_close(GTK_WINDOW(dialog)); |
36 | } | 38 | } |
@@ -38,6 +40,8 @@ handle_close_button_click(UNUSED GtkButton *button, | |||
38 | static gboolean | 40 | static gboolean |
39 | _open_new_account_dialog(gpointer user_data) | 41 | _open_new_account_dialog(gpointer user_data) |
40 | { | 42 | { |
43 | g_assert(user_data); | ||
44 | |||
41 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 45 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
42 | 46 | ||
43 | ui_new_account_dialog_init(app, &(app->ui.new_account)); | 47 | ui_new_account_dialog_init(app, &(app->ui.new_account)); |
@@ -49,6 +53,8 @@ _open_new_account_dialog(gpointer user_data) | |||
49 | static gboolean | 53 | static gboolean |
50 | _show_messenger_main_window(gpointer user_data) | 54 | _show_messenger_main_window(gpointer user_data) |
51 | { | 55 | { |
56 | g_assert(user_data); | ||
57 | |||
52 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 58 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
53 | 59 | ||
54 | // Refresh the account list | 60 | // Refresh the account list |
@@ -63,6 +69,8 @@ handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
63 | GtkListBoxRow* row, | 69 | GtkListBoxRow* row, |
64 | gpointer user_data) | 70 | gpointer user_data) |
65 | { | 71 | { |
72 | g_assert((row) && (user_data)); | ||
73 | |||
66 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 74 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
67 | 75 | ||
68 | // Drop activations of rows which do not contain accounts | 76 | // Drop activations of rows which do not contain accounts |
@@ -98,6 +106,8 @@ static void | |||
98 | handle_dialog_destroy(UNUSED GtkWidget *window, | 106 | handle_dialog_destroy(UNUSED GtkWidget *window, |
99 | gpointer user_data) | 107 | gpointer user_data) |
100 | { | 108 | { |
109 | g_assert(user_data); | ||
110 | |||
101 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 111 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
102 | 112 | ||
103 | if ((app->ui.accounts.show_queued) || | 113 | if ((app->ui.accounts.show_queued) || |
@@ -112,6 +122,8 @@ _iterate_accounts(void *cls, | |||
112 | UNUSED const struct GNUNET_CHAT_Handle *handle, | 122 | UNUSED const struct GNUNET_CHAT_Handle *handle, |
113 | struct GNUNET_CHAT_Account *account) | 123 | struct GNUNET_CHAT_Account *account) |
114 | { | 124 | { |
125 | g_assert((cls) && (account)); | ||
126 | |||
115 | MESSENGER_Application *app = (MESSENGER_Application*) cls; | 127 | MESSENGER_Application *app = (MESSENGER_Application*) cls; |
116 | 128 | ||
117 | UI_ACCOUNT_ENTRY_Handle *entry = ui_account_entry_new(app); | 129 | UI_ACCOUNT_ENTRY_Handle *entry = ui_account_entry_new(app); |
@@ -140,6 +152,8 @@ void | |||
140 | ui_accounts_dialog_init(MESSENGER_Application *app, | 152 | ui_accounts_dialog_init(MESSENGER_Application *app, |
141 | UI_ACCOUNTS_Handle *handle) | 153 | UI_ACCOUNTS_Handle *handle) |
142 | { | 154 | { |
155 | g_assert((app) && (handle)); | ||
156 | |||
143 | handle->show_queued = 0; | 157 | handle->show_queued = 0; |
144 | 158 | ||
145 | handle->builder = gtk_builder_new_from_resource( | 159 | handle->builder = gtk_builder_new_from_resource( |
@@ -189,6 +203,8 @@ void | |||
189 | ui_accounts_dialog_refresh(MESSENGER_Application *app, | 203 | ui_accounts_dialog_refresh(MESSENGER_Application *app, |
190 | UI_ACCOUNTS_Handle *handle) | 204 | UI_ACCOUNTS_Handle *handle) |
191 | { | 205 | { |
206 | g_assert((app) && (handle)); | ||
207 | |||
192 | if (!(handle->accounts_listbox)) | 208 | if (!(handle->accounts_listbox)) |
193 | return; | 209 | return; |
194 | 210 | ||
@@ -226,6 +242,8 @@ ui_accounts_dialog_refresh(MESSENGER_Application *app, | |||
226 | void | 242 | void |
227 | ui_accounts_dialog_cleanup(UI_ACCOUNTS_Handle *handle) | 243 | ui_accounts_dialog_cleanup(UI_ACCOUNTS_Handle *handle) |
228 | { | 244 | { |
245 | g_assert(handle); | ||
246 | |||
229 | g_object_unref(handle->builder); | 247 | g_object_unref(handle->builder); |
230 | 248 | ||
231 | guint show = handle->show_queued; | 249 | guint show = handle->show_queued; |
diff --git a/src/ui/chat.c b/src/ui/chat.c index a7eddeb..97a30ab 100644 --- a/src/ui/chat.c +++ b/src/ui/chat.c | |||
@@ -38,13 +38,14 @@ | |||
38 | #include "delete_messages.h" | 38 | #include "delete_messages.h" |
39 | 39 | ||
40 | #include "../application.h" | 40 | #include "../application.h" |
41 | #include "../contact.h" | ||
42 | #include "../file.h" | 41 | #include "../file.h" |
43 | #include "../ui.h" | 42 | #include "../ui.h" |
44 | 43 | ||
45 | static gboolean | 44 | static gboolean |
46 | _flap_chat_details_reveal_switch(gpointer user_data) | 45 | _flap_chat_details_reveal_switch(gpointer user_data) |
47 | { | 46 | { |
47 | g_assert(user_data); | ||
48 | |||
48 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 49 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
49 | HdyFlap* flap = handle->flap_chat_details; | 50 | HdyFlap* flap = handle->flap_chat_details; |
50 | 51 | ||
@@ -62,6 +63,8 @@ static void | |||
62 | handle_chat_details_via_button_click(UNUSED GtkButton* button, | 63 | handle_chat_details_via_button_click(UNUSED GtkButton* button, |
63 | gpointer user_data) | 64 | gpointer user_data) |
64 | { | 65 | { |
66 | g_assert(user_data); | ||
67 | |||
65 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 68 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
66 | 69 | ||
67 | gtk_widget_set_sensitive(GTK_WIDGET(handle->messages_listbox), FALSE); | 70 | gtk_widget_set_sensitive(GTK_WIDGET(handle->messages_listbox), FALSE); |
@@ -75,6 +78,8 @@ static void | |||
75 | handle_popover_via_button_click(UNUSED GtkButton *button, | 78 | handle_popover_via_button_click(UNUSED GtkButton *button, |
76 | gpointer user_data) | 79 | gpointer user_data) |
77 | { | 80 | { |
81 | g_assert(user_data); | ||
82 | |||
78 | GtkPopover *popover = GTK_POPOVER(user_data); | 83 | GtkPopover *popover = GTK_POPOVER(user_data); |
79 | 84 | ||
80 | if (gtk_widget_is_visible(GTK_WIDGET(popover))) | 85 | if (gtk_widget_is_visible(GTK_WIDGET(popover))) |
@@ -88,6 +93,8 @@ handle_chat_contacts_listbox_row_activated(GtkListBox *listbox, | |||
88 | GtkListBoxRow *row, | 93 | GtkListBoxRow *row, |
89 | gpointer user_data) | 94 | gpointer user_data) |
90 | { | 95 | { |
96 | g_assert((listbox) && (row) && (user_data)); | ||
97 | |||
91 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 98 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
92 | MESSENGER_Application *app = handle->app; | 99 | MESSENGER_Application *app = handle->app; |
93 | 100 | ||
@@ -132,6 +139,8 @@ handle_chat_messages_listbox_size_allocate(UNUSED GtkWidget *widget, | |||
132 | UNUSED GdkRectangle *allocation, | 139 | UNUSED GdkRectangle *allocation, |
133 | gpointer user_data) | 140 | gpointer user_data) |
134 | { | 141 | { |
142 | g_assert(user_data); | ||
143 | |||
135 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 144 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
136 | 145 | ||
137 | GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment( | 146 | GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment( |
@@ -154,6 +163,8 @@ static void | |||
154 | handle_back_button_click(UNUSED GtkButton *button, | 163 | handle_back_button_click(UNUSED GtkButton *button, |
155 | gpointer user_data) | 164 | gpointer user_data) |
156 | { | 165 | { |
166 | g_assert(user_data); | ||
167 | |||
157 | HdyLeaflet *leaflet = HDY_LEAFLET(user_data); | 168 | HdyLeaflet *leaflet = HDY_LEAFLET(user_data); |
158 | 169 | ||
159 | GList *children = gtk_container_get_children(GTK_CONTAINER(leaflet)); | 170 | GList *children = gtk_container_get_children(GTK_CONTAINER(leaflet)); |
@@ -168,6 +179,8 @@ static void | |||
168 | handle_reveal_identity_button_click(GtkButton *button, | 179 | handle_reveal_identity_button_click(GtkButton *button, |
169 | gpointer user_data) | 180 | gpointer user_data) |
170 | { | 181 | { |
182 | g_assert((button) && (user_data)); | ||
183 | |||
171 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 184 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
172 | MESSENGER_Application *app = handle->app; | 185 | MESSENGER_Application *app = handle->app; |
173 | 186 | ||
@@ -190,6 +203,8 @@ static void | |||
190 | handle_block_button_click(UNUSED GtkButton *button, | 203 | handle_block_button_click(UNUSED GtkButton *button, |
191 | gpointer user_data) | 204 | gpointer user_data) |
192 | { | 205 | { |
206 | g_assert(user_data); | ||
207 | |||
193 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 208 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
194 | 209 | ||
195 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( | 210 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( |
@@ -208,6 +223,8 @@ static void | |||
208 | handle_unblock_button_click(UNUSED GtkButton *button, | 223 | handle_unblock_button_click(UNUSED GtkButton *button, |
209 | gpointer user_data) | 224 | gpointer user_data) |
210 | { | 225 | { |
226 | g_assert(user_data); | ||
227 | |||
211 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 228 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
212 | 229 | ||
213 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( | 230 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( |
@@ -226,6 +243,8 @@ static void | |||
226 | handle_leave_chat_button_click(UNUSED GtkButton *button, | 243 | handle_leave_chat_button_click(UNUSED GtkButton *button, |
227 | gpointer user_data) | 244 | gpointer user_data) |
228 | { | 245 | { |
246 | g_assert(user_data); | ||
247 | |||
229 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 248 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
230 | 249 | ||
231 | if ((!handle) || (!(handle->send_text_view))) | 250 | if ((!handle) || (!(handle->send_text_view))) |
@@ -267,6 +286,8 @@ handle_chat_messages_sort(GtkListBoxRow* row0, | |||
267 | GtkListBoxRow* row1, | 286 | GtkListBoxRow* row1, |
268 | gpointer user_data) | 287 | gpointer user_data) |
269 | { | 288 | { |
289 | g_assert((row0) && (row1) && (user_data)); | ||
290 | |||
270 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 291 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
271 | 292 | ||
272 | UI_MESSAGE_Handle *message0 = (UI_MESSAGE_Handle*) ( | 293 | UI_MESSAGE_Handle *message0 = (UI_MESSAGE_Handle*) ( |
@@ -295,6 +316,8 @@ static void | |||
295 | handle_chat_messages_selected_rows_changed(GtkListBox *listbox, | 316 | handle_chat_messages_selected_rows_changed(GtkListBox *listbox, |
296 | gpointer user_data) | 317 | gpointer user_data) |
297 | { | 318 | { |
319 | g_assert((listbox) && (user_data)); | ||
320 | |||
298 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 321 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
299 | 322 | ||
300 | GList *selected = gtk_list_box_get_selected_rows(listbox); | 323 | GList *selected = gtk_list_box_get_selected_rows(listbox); |
@@ -325,6 +348,8 @@ static void | |||
325 | handle_chat_selection_close_button_click(UNUSED GtkButton *button, | 348 | handle_chat_selection_close_button_click(UNUSED GtkButton *button, |
326 | gpointer user_data) | 349 | gpointer user_data) |
327 | { | 350 | { |
351 | g_assert(user_data); | ||
352 | |||
328 | GtkListBox *listbox = GTK_LIST_BOX(user_data); | 353 | GtkListBox *listbox = GTK_LIST_BOX(user_data); |
329 | 354 | ||
330 | gtk_list_box_unselect_all(listbox); | 355 | gtk_list_box_unselect_all(listbox); |
@@ -335,6 +360,8 @@ _delete_messages_callback(MESSENGER_Application *app, | |||
335 | GList *selected, | 360 | GList *selected, |
336 | gulong delay) | 361 | gulong delay) |
337 | { | 362 | { |
363 | g_assert(app); | ||
364 | |||
338 | UI_MESSAGE_Handle *message; | 365 | UI_MESSAGE_Handle *message; |
339 | 366 | ||
340 | while (selected) | 367 | while (selected) |
@@ -369,6 +396,8 @@ static void | |||
369 | handle_chat_selection_delete_button_click(UNUSED GtkButton *button, | 396 | handle_chat_selection_delete_button_click(UNUSED GtkButton *button, |
370 | gpointer user_data) | 397 | gpointer user_data) |
371 | { | 398 | { |
399 | g_assert(user_data); | ||
400 | |||
372 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 401 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
373 | 402 | ||
374 | MESSENGER_Application *app = handle->app; | 403 | MESSENGER_Application *app = handle->app; |
@@ -400,6 +429,8 @@ static void | |||
400 | handle_attach_file_button_click(GtkButton *button, | 429 | handle_attach_file_button_click(GtkButton *button, |
401 | gpointer user_data) | 430 | gpointer user_data) |
402 | { | 431 | { |
432 | g_assert((button) && (user_data)); | ||
433 | |||
403 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 434 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
404 | 435 | ||
405 | GtkTextView *text_view = GTK_TEXT_VIEW( | 436 | GtkTextView *text_view = GTK_TEXT_VIEW( |
@@ -452,6 +483,8 @@ _update_send_record_symbol(GtkTextBuffer *buffer, | |||
452 | GtkImage *symbol, | 483 | GtkImage *symbol, |
453 | gboolean picker_revealed) | 484 | gboolean picker_revealed) |
454 | { | 485 | { |
486 | g_assert((buffer) && (symbol)); | ||
487 | |||
455 | GtkTextIter start, end; | 488 | GtkTextIter start, end; |
456 | gtk_text_buffer_get_start_iter(buffer, &start); | 489 | gtk_text_buffer_get_start_iter(buffer, &start); |
457 | gtk_text_buffer_get_end_iter(buffer, &end); | 490 | gtk_text_buffer_get_end_iter(buffer, &end); |
@@ -473,6 +506,8 @@ static void | |||
473 | handle_send_text_buffer_changed(GtkTextBuffer *buffer, | 506 | handle_send_text_buffer_changed(GtkTextBuffer *buffer, |
474 | gpointer user_data) | 507 | gpointer user_data) |
475 | { | 508 | { |
509 | g_assert((buffer) && (user_data)); | ||
510 | |||
476 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 511 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
477 | 512 | ||
478 | _update_send_record_symbol( | 513 | _update_send_record_symbol( |
@@ -488,6 +523,8 @@ _send_text_from_view(MESSENGER_Application *app, | |||
488 | GtkTextView *text_view, | 523 | GtkTextView *text_view, |
489 | gint64 action_time) | 524 | gint64 action_time) |
490 | { | 525 | { |
526 | g_assert((app) && (handle) && (text_view)); | ||
527 | |||
491 | GtkTextBuffer *buffer = gtk_text_view_get_buffer(text_view); | 528 | GtkTextBuffer *buffer = gtk_text_view_get_buffer(text_view); |
492 | 529 | ||
493 | GtkTextIter start, end; | 530 | GtkTextIter start, end; |
@@ -523,6 +560,8 @@ _send_text_from_view(MESSENGER_Application *app, | |||
523 | static void | 560 | static void |
524 | _drop_any_recording(UI_CHAT_Handle *handle) | 561 | _drop_any_recording(UI_CHAT_Handle *handle) |
525 | { | 562 | { |
563 | g_assert(handle); | ||
564 | |||
526 | if ((handle->play_pipeline) && (handle->playing)) | 565 | if ((handle->play_pipeline) && (handle->playing)) |
527 | { | 566 | { |
528 | gst_element_set_state(handle->play_pipeline, GST_STATE_NULL); | 567 | gst_element_set_state(handle->play_pipeline, GST_STATE_NULL); |
@@ -550,6 +589,8 @@ handle_sending_recording_upload_file(UNUSED void *cls, | |||
550 | uint64_t completed, | 589 | uint64_t completed, |
551 | uint64_t size) | 590 | uint64_t size) |
552 | { | 591 | { |
592 | g_assert(file); | ||
593 | |||
553 | UI_FILE_LOAD_ENTRY_Handle *file_load = cls; | 594 | UI_FILE_LOAD_ENTRY_Handle *file_load = cls; |
554 | 595 | ||
555 | gtk_progress_bar_set_fraction( | 596 | gtk_progress_bar_set_fraction( |
@@ -567,6 +608,8 @@ static void | |||
567 | handle_send_record_button_click(GtkButton *button, | 608 | handle_send_record_button_click(GtkButton *button, |
568 | gpointer user_data) | 609 | gpointer user_data) |
569 | { | 610 | { |
611 | g_assert((button) && (user_data)); | ||
612 | |||
570 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 613 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
571 | 614 | ||
572 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) ( | 615 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) ( |
@@ -620,6 +663,8 @@ static void | |||
620 | handle_send_later_button_click(GtkButton *button, | 663 | handle_send_later_button_click(GtkButton *button, |
621 | gpointer user_data) | 664 | gpointer user_data) |
622 | { | 665 | { |
666 | g_assert((button) && (user_data)); | ||
667 | |||
623 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 668 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
624 | 669 | ||
625 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) ( | 670 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) ( |
@@ -641,6 +686,8 @@ static void | |||
641 | handle_send_now_button_click(GtkButton *button, | 686 | handle_send_now_button_click(GtkButton *button, |
642 | gpointer user_data) | 687 | gpointer user_data) |
643 | { | 688 | { |
689 | g_assert((button) && (user_data)); | ||
690 | |||
644 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 691 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
645 | 692 | ||
646 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) ( | 693 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) ( |
@@ -665,6 +712,8 @@ handle_send_record_button_pressed(GtkWidget *widget, | |||
665 | UNUSED GdkEvent *event, | 712 | UNUSED GdkEvent *event, |
666 | gpointer user_data) | 713 | gpointer user_data) |
667 | { | 714 | { |
715 | g_assert((widget) && (user_data)); | ||
716 | |||
668 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 717 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
669 | 718 | ||
670 | GtkTextView *text_view = GTK_TEXT_VIEW( | 719 | GtkTextView *text_view = GTK_TEXT_VIEW( |
@@ -747,6 +796,8 @@ handle_send_record_button_released(GtkWidget *widget, | |||
747 | UNUSED GdkEvent *event, | 796 | UNUSED GdkEvent *event, |
748 | gpointer user_data) | 797 | gpointer user_data) |
749 | { | 798 | { |
799 | g_assert((widget) && (user_data)); | ||
800 | |||
750 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 801 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
751 | 802 | ||
752 | GtkTextView *text_view = GTK_TEXT_VIEW( | 803 | GtkTextView *text_view = GTK_TEXT_VIEW( |
@@ -799,6 +850,8 @@ handle_send_text_key_press (GtkWidget *widget, | |||
799 | GdkEventKey *event, | 850 | GdkEventKey *event, |
800 | gpointer user_data) | 851 | gpointer user_data) |
801 | { | 852 | { |
853 | g_assert((widget) && (event) && (user_data)); | ||
854 | |||
802 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 855 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
803 | 856 | ||
804 | if ((app->settings.mobile_design) || | 857 | if ((app->settings.mobile_design) || |
@@ -818,6 +871,8 @@ static void | |||
818 | handle_recording_close_button_click(UNUSED GtkButton *button, | 871 | handle_recording_close_button_click(UNUSED GtkButton *button, |
819 | gpointer user_data) | 872 | gpointer user_data) |
820 | { | 873 | { |
874 | g_assert(user_data); | ||
875 | |||
821 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 876 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
822 | 877 | ||
823 | _drop_any_recording(handle); | 878 | _drop_any_recording(handle); |
@@ -827,6 +882,8 @@ static void | |||
827 | _stop_playing_recording(UI_CHAT_Handle *handle, | 882 | _stop_playing_recording(UI_CHAT_Handle *handle, |
828 | gboolean reset_bar) | 883 | gboolean reset_bar) |
829 | { | 884 | { |
885 | g_assert(handle); | ||
886 | |||
830 | gst_element_set_state(handle->play_pipeline, GST_STATE_NULL); | 887 | gst_element_set_state(handle->play_pipeline, GST_STATE_NULL); |
831 | handle->playing = FALSE; | 888 | handle->playing = FALSE; |
832 | 889 | ||
@@ -852,6 +909,8 @@ static void | |||
852 | handle_recording_play_button_click(UNUSED GtkButton *button, | 909 | handle_recording_play_button_click(UNUSED GtkButton *button, |
853 | gpointer user_data) | 910 | gpointer user_data) |
854 | { | 911 | { |
912 | g_assert(user_data); | ||
913 | |||
855 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 914 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
856 | 915 | ||
857 | if ((!(handle->recorded)) || (!(handle->play_pipeline))) | 916 | if ((!(handle->recorded)) || (!(handle->play_pipeline))) |
@@ -883,6 +942,8 @@ static void | |||
883 | handle_picker_button_click(UNUSED GtkButton *button, | 942 | handle_picker_button_click(UNUSED GtkButton *button, |
884 | gpointer user_data) | 943 | gpointer user_data) |
885 | { | 944 | { |
945 | g_assert(user_data); | ||
946 | |||
886 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 947 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
887 | 948 | ||
888 | gboolean reveal = !gtk_revealer_get_child_revealed(handle->picker_revealer); | 949 | gboolean reveal = !gtk_revealer_get_child_revealed(handle->picker_revealer); |
@@ -899,6 +960,8 @@ handle_picker_button_click(UNUSED GtkButton *button, | |||
899 | static gboolean | 960 | static gboolean |
900 | _record_timer_func(gpointer user_data) | 961 | _record_timer_func(gpointer user_data) |
901 | { | 962 | { |
963 | g_assert(user_data); | ||
964 | |||
902 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 965 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
903 | 966 | ||
904 | GString *time_string = g_string_new(NULL); | 967 | GString *time_string = g_string_new(NULL); |
@@ -932,6 +995,8 @@ _record_timer_func(gpointer user_data) | |||
932 | static gboolean | 995 | static gboolean |
933 | _play_timer_func(gpointer user_data) | 996 | _play_timer_func(gpointer user_data) |
934 | { | 997 | { |
998 | g_assert(user_data); | ||
999 | |||
935 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; | 1000 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data; |
936 | 1001 | ||
937 | if (handle->play_time < handle->record_time * 100) | 1002 | if (handle->play_time < handle->record_time * 100) |
@@ -965,6 +1030,8 @@ handle_record_bus_watch(UNUSED GstBus *bus, | |||
965 | GstMessage *msg, | 1030 | GstMessage *msg, |
966 | gpointer data) | 1031 | gpointer data) |
967 | { | 1032 | { |
1033 | g_assert((msg) && (data)); | ||
1034 | |||
968 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) data; | 1035 | UI_CHAT_Handle *handle = (UI_CHAT_Handle*) data; |
969 | GstMessageType type = GST_MESSAGE_TYPE(msg); | 1036 | GstMessageType type = GST_MESSAGE_TYPE(msg); |
970 | 1037 | ||
@@ -1019,6 +1086,8 @@ handle_play_bus_watch(UNUSED GstBus *bus, | |||
1019 | static void | 1086 | static void |
1020 | _setup_gst_pipelines(UI_CHAT_Handle *handle) | 1087 | _setup_gst_pipelines(UI_CHAT_Handle *handle) |
1021 | { | 1088 | { |
1089 | g_assert(handle); | ||
1090 | |||
1022 | handle->record_pipeline = gst_parse_launch( | 1091 | handle->record_pipeline = gst_parse_launch( |
1023 | "autoaudiosrc ! audioconvert ! vorbisenc ! oggmux ! filesink name=sink", | 1092 | "autoaudiosrc ! audioconvert ! vorbisenc ! oggmux ! filesink name=sink", |
1024 | NULL | 1093 | NULL |
@@ -1065,7 +1134,7 @@ _setup_gst_pipelines(UI_CHAT_Handle *handle) | |||
1065 | UI_CHAT_Handle* | 1134 | UI_CHAT_Handle* |
1066 | ui_chat_new(MESSENGER_Application *app) | 1135 | ui_chat_new(MESSENGER_Application *app) |
1067 | { | 1136 | { |
1068 | GNUNET_assert(app); | 1137 | g_assert(app); |
1069 | 1138 | ||
1070 | UI_CHAT_Handle *handle = g_malloc(sizeof(UI_CHAT_Handle)); | 1139 | UI_CHAT_Handle *handle = g_malloc(sizeof(UI_CHAT_Handle)); |
1071 | UI_MESSENGER_Handle *messenger = &(app->ui.messenger); | 1140 | UI_MESSENGER_Handle *messenger = &(app->ui.messenger); |
@@ -1554,7 +1623,7 @@ ui_chat_update(UI_CHAT_Handle *handle, | |||
1554 | MESSENGER_Application *app, | 1623 | MESSENGER_Application *app, |
1555 | struct GNUNET_CHAT_Context* context) | 1624 | struct GNUNET_CHAT_Context* context) |
1556 | { | 1625 | { |
1557 | GNUNET_assert((handle) && (app) && (context)); | 1626 | g_assert((handle) && (app) && (context)); |
1558 | 1627 | ||
1559 | struct GNUNET_CHAT_Contact* contact; | 1628 | struct GNUNET_CHAT_Contact* contact; |
1560 | struct GNUNET_CHAT_Group* group; | 1629 | struct GNUNET_CHAT_Group* group; |
@@ -1715,7 +1784,7 @@ ui_chat_update(UI_CHAT_Handle *handle, | |||
1715 | void | 1784 | void |
1716 | ui_chat_delete(UI_CHAT_Handle *handle) | 1785 | ui_chat_delete(UI_CHAT_Handle *handle) |
1717 | { | 1786 | { |
1718 | GNUNET_assert(handle); | 1787 | g_assert(handle); |
1719 | 1788 | ||
1720 | ui_picker_delete(handle->picker); | 1789 | ui_picker_delete(handle->picker); |
1721 | 1790 | ||
@@ -1753,7 +1822,7 @@ ui_chat_add_message(UI_CHAT_Handle *handle, | |||
1753 | MESSENGER_Application *app, | 1822 | MESSENGER_Application *app, |
1754 | UI_MESSAGE_Handle *message) | 1823 | UI_MESSAGE_Handle *message) |
1755 | { | 1824 | { |
1756 | GNUNET_assert((handle) && (message) && (message->message_box)); | 1825 | g_assert((handle) && (message) && (message->message_box)); |
1757 | 1826 | ||
1758 | gtk_container_add( | 1827 | gtk_container_add( |
1759 | GTK_CONTAINER(handle->messages_listbox), | 1828 | GTK_CONTAINER(handle->messages_listbox), |
@@ -1771,7 +1840,7 @@ ui_chat_remove_message(UI_CHAT_Handle *handle, | |||
1771 | UNUSED MESSENGER_Application *app, | 1840 | UNUSED MESSENGER_Application *app, |
1772 | UI_MESSAGE_Handle *message) | 1841 | UI_MESSAGE_Handle *message) |
1773 | { | 1842 | { |
1774 | GNUNET_assert((handle) && (message) && (message->message_box)); | 1843 | g_assert((handle) && (message) && (message->message_box)); |
1775 | 1844 | ||
1776 | GtkWidget *row = gtk_widget_get_parent(message->message_box); | 1845 | GtkWidget *row = gtk_widget_get_parent(message->message_box); |
1777 | g_object_set_qdata(G_OBJECT(row), app->quarks.ui, NULL); | 1846 | g_object_set_qdata(G_OBJECT(row), app->quarks.ui, NULL); |
@@ -1788,7 +1857,7 @@ void | |||
1788 | ui_chat_add_file_load(UI_CHAT_Handle *handle, | 1857 | ui_chat_add_file_load(UI_CHAT_Handle *handle, |
1789 | UI_FILE_LOAD_ENTRY_Handle *file_load) | 1858 | UI_FILE_LOAD_ENTRY_Handle *file_load) |
1790 | { | 1859 | { |
1791 | GNUNET_assert((handle) && (file_load)); | 1860 | g_assert((handle) && (file_load)); |
1792 | 1861 | ||
1793 | gtk_container_add( | 1862 | gtk_container_add( |
1794 | GTK_CONTAINER(handle->chat_load_listbox), | 1863 | GTK_CONTAINER(handle->chat_load_listbox), |
@@ -1806,7 +1875,7 @@ void | |||
1806 | ui_chat_remove_file_load(UI_CHAT_Handle *handle, | 1875 | ui_chat_remove_file_load(UI_CHAT_Handle *handle, |
1807 | UI_FILE_LOAD_ENTRY_Handle *file_load) | 1876 | UI_FILE_LOAD_ENTRY_Handle *file_load) |
1808 | { | 1877 | { |
1809 | GNUNET_assert((handle) && (file_load) && (handle == file_load->chat) && | 1878 | g_assert((handle) && (file_load) && (handle == file_load->chat) && |
1810 | (file_load->entry_box)); | 1879 | (file_load->entry_box)); |
1811 | 1880 | ||
1812 | handle->loads = g_list_remove(handle->loads, file_load); | 1881 | handle->loads = g_list_remove(handle->loads, file_load); |
diff --git a/src/ui/chat.h b/src/ui/chat.h index dc6464d..6f53fb9 100644 --- a/src/ui/chat.h +++ b/src/ui/chat.h | |||
@@ -161,8 +161,8 @@ ui_chat_new(MESSENGER_Application *app); | |||
161 | */ | 161 | */ |
162 | void | 162 | void |
163 | ui_chat_update(UI_CHAT_Handle *handle, | 163 | ui_chat_update(UI_CHAT_Handle *handle, |
164 | MESSENGER_Application *app, | 164 | MESSENGER_Application *app, |
165 | struct GNUNET_CHAT_Context* context); | 165 | struct GNUNET_CHAT_Context* context); |
166 | 166 | ||
167 | /** | 167 | /** |
168 | * Frees its resources and destroys a given | 168 | * Frees its resources and destroys a given |
@@ -184,8 +184,8 @@ ui_chat_delete(UI_CHAT_Handle *handle); | |||
184 | */ | 184 | */ |
185 | void | 185 | void |
186 | ui_chat_add_message(UI_CHAT_Handle *handle, | 186 | ui_chat_add_message(UI_CHAT_Handle *handle, |
187 | MESSENGER_Application *app, | 187 | MESSENGER_Application *app, |
188 | UI_MESSAGE_Handle *message); | 188 | UI_MESSAGE_Handle *message); |
189 | 189 | ||
190 | /** | 190 | /** |
191 | * Removes a message handle from a given chat | 191 | * Removes a message handle from a given chat |
@@ -198,8 +198,8 @@ ui_chat_add_message(UI_CHAT_Handle *handle, | |||
198 | */ | 198 | */ |
199 | void | 199 | void |
200 | ui_chat_remove_message(UI_CHAT_Handle *handle, | 200 | ui_chat_remove_message(UI_CHAT_Handle *handle, |
201 | MESSENGER_Application *app, | 201 | MESSENGER_Application *app, |
202 | UI_MESSAGE_Handle *message); | 202 | UI_MESSAGE_Handle *message); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | * Add a file load entry handle to a given chat | 205 | * Add a file load entry handle to a given chat |
@@ -210,7 +210,7 @@ ui_chat_remove_message(UI_CHAT_Handle *handle, | |||
210 | */ | 210 | */ |
211 | void | 211 | void |
212 | ui_chat_add_file_load(UI_CHAT_Handle *handle, | 212 | ui_chat_add_file_load(UI_CHAT_Handle *handle, |
213 | UI_FILE_LOAD_ENTRY_Handle *file_load); | 213 | UI_FILE_LOAD_ENTRY_Handle *file_load); |
214 | 214 | ||
215 | /** | 215 | /** |
216 | * Removes a file load entry handle from a given | 216 | * Removes a file load entry handle from a given |
@@ -221,6 +221,6 @@ ui_chat_add_file_load(UI_CHAT_Handle *handle, | |||
221 | */ | 221 | */ |
222 | void | 222 | void |
223 | ui_chat_remove_file_load(UI_CHAT_Handle *handle, | 223 | ui_chat_remove_file_load(UI_CHAT_Handle *handle, |
224 | UI_FILE_LOAD_ENTRY_Handle *file_load); | 224 | UI_FILE_LOAD_ENTRY_Handle *file_load); |
225 | 225 | ||
226 | #endif /* UI_CHAT_H_ */ | 226 | #endif /* UI_CHAT_H_ */ |
diff --git a/src/ui/chat_entry.c b/src/ui/chat_entry.c index ebef4de..8201e43 100644 --- a/src/ui/chat_entry.c +++ b/src/ui/chat_entry.c | |||
@@ -34,6 +34,8 @@ | |||
34 | UI_CHAT_ENTRY_Handle* | 34 | UI_CHAT_ENTRY_Handle* |
35 | ui_chat_entry_new(MESSENGER_Application *app) | 35 | ui_chat_entry_new(MESSENGER_Application *app) |
36 | { | 36 | { |
37 | g_assert(app); | ||
38 | |||
37 | UI_CHAT_ENTRY_Handle* handle = g_malloc(sizeof(UI_CHAT_ENTRY_Handle)); | 39 | UI_CHAT_ENTRY_Handle* handle = g_malloc(sizeof(UI_CHAT_ENTRY_Handle)); |
38 | 40 | ||
39 | memset(handle, 0, sizeof(*handle)); | 41 | memset(handle, 0, sizeof(*handle)); |
@@ -77,6 +79,8 @@ ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle, | |||
77 | MESSENGER_Application *app, | 79 | MESSENGER_Application *app, |
78 | struct GNUNET_CHAT_Context *context) | 80 | struct GNUNET_CHAT_Context *context) |
79 | { | 81 | { |
82 | g_assert((handle) && (app)); | ||
83 | |||
80 | const struct GNUNET_CHAT_Contact* contact; | 84 | const struct GNUNET_CHAT_Contact* contact; |
81 | const struct GNUNET_CHAT_Group* group; | 85 | const struct GNUNET_CHAT_Group* group; |
82 | 86 | ||
@@ -173,6 +177,8 @@ ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle, | |||
173 | void | 177 | void |
174 | ui_chat_entry_delete(UI_CHAT_ENTRY_Handle *handle) | 178 | ui_chat_entry_delete(UI_CHAT_ENTRY_Handle *handle) |
175 | { | 179 | { |
180 | g_assert(handle); | ||
181 | |||
176 | ui_chat_delete(handle->chat); | 182 | ui_chat_delete(handle->chat); |
177 | 183 | ||
178 | g_object_unref(handle->builder); | 184 | g_object_unref(handle->builder); |
@@ -187,7 +193,7 @@ void | |||
187 | ui_chat_entry_dispose(UI_CHAT_ENTRY_Handle *handle, | 193 | ui_chat_entry_dispose(UI_CHAT_ENTRY_Handle *handle, |
188 | MESSENGER_Application *app) | 194 | MESSENGER_Application *app) |
189 | { | 195 | { |
190 | GNUNET_assert((handle) && (handle->entry_box)); | 196 | g_assert((handle) && (handle->entry_box)); |
191 | 197 | ||
192 | UI_MESSENGER_Handle *ui = &(app->ui.messenger); | 198 | UI_MESSENGER_Handle *ui = &(app->ui.messenger); |
193 | 199 | ||
diff --git a/src/ui/chat_entry.h b/src/ui/chat_entry.h index 4eb5431..2cdbd76 100644 --- a/src/ui/chat_entry.h +++ b/src/ui/chat_entry.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -70,8 +70,8 @@ ui_chat_entry_new(MESSENGER_Application *app); | |||
70 | */ | 70 | */ |
71 | void | 71 | void |
72 | ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle, | 72 | ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle, |
73 | MESSENGER_Application *app, | 73 | MESSENGER_Application *app, |
74 | struct GNUNET_CHAT_Context *context); | 74 | struct GNUNET_CHAT_Context *context); |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * Frees its resources and destroys a given | 77 | * Frees its resources and destroys a given |
@@ -93,6 +93,6 @@ ui_chat_entry_delete(UI_CHAT_ENTRY_Handle *handle); | |||
93 | */ | 93 | */ |
94 | void | 94 | void |
95 | ui_chat_entry_dispose(UI_CHAT_ENTRY_Handle *handle, | 95 | ui_chat_entry_dispose(UI_CHAT_ENTRY_Handle *handle, |
96 | MESSENGER_Application *app); | 96 | MESSENGER_Application *app); |
97 | 97 | ||
98 | #endif /* UI_CHAT_ENTRY_H_ */ | 98 | #endif /* UI_CHAT_ENTRY_H_ */ |
diff --git a/src/ui/contact_entry.c b/src/ui/contact_entry.c index b9789da..5c39df2 100644 --- a/src/ui/contact_entry.c +++ b/src/ui/contact_entry.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -30,26 +30,28 @@ | |||
30 | UI_CONTACT_ENTRY_Handle* | 30 | UI_CONTACT_ENTRY_Handle* |
31 | ui_contact_entry_new(MESSENGER_Application *app) | 31 | ui_contact_entry_new(MESSENGER_Application *app) |
32 | { | 32 | { |
33 | g_assert(app); | ||
34 | |||
33 | UI_CONTACT_ENTRY_Handle* handle = g_malloc(sizeof(UI_CONTACT_ENTRY_Handle)); | 35 | UI_CONTACT_ENTRY_Handle* handle = g_malloc(sizeof(UI_CONTACT_ENTRY_Handle)); |
34 | 36 | ||
35 | handle->builder = gtk_builder_new_from_resource( | 37 | handle->builder = gtk_builder_new_from_resource( |
36 | application_get_resource_path(app, "ui/contact_entry.ui") | 38 | application_get_resource_path(app, "ui/contact_entry.ui") |
37 | ); | 39 | ); |
38 | 40 | ||
39 | handle->entry_box = GTK_WIDGET( | 41 | handle->entry_box = GTK_WIDGET( |
40 | gtk_builder_get_object(handle->builder, "entry_box") | 42 | gtk_builder_get_object(handle->builder, "entry_box") |
41 | ); | 43 | ); |
42 | 44 | ||
43 | handle->entry_avatar = HDY_AVATAR( | 45 | handle->entry_avatar = HDY_AVATAR( |
44 | gtk_builder_get_object(handle->builder, "entry_avatar") | 46 | gtk_builder_get_object(handle->builder, "entry_avatar") |
45 | ); | 47 | ); |
46 | 48 | ||
47 | handle->title_label = GTK_LABEL( | 49 | handle->title_label = GTK_LABEL( |
48 | gtk_builder_get_object(handle->builder, "title_label") | 50 | gtk_builder_get_object(handle->builder, "title_label") |
49 | ); | 51 | ); |
50 | 52 | ||
51 | handle->subtitle_label = GTK_LABEL( | 53 | handle->subtitle_label = GTK_LABEL( |
52 | gtk_builder_get_object(handle->builder, "subtitle_label") | 54 | gtk_builder_get_object(handle->builder, "subtitle_label") |
53 | ); | 55 | ); |
54 | 56 | ||
55 | return handle; | 57 | return handle; |
@@ -57,8 +59,9 @@ ui_contact_entry_new(MESSENGER_Application *app) | |||
57 | 59 | ||
58 | void | 60 | void |
59 | ui_contact_entry_set_contact(UI_CONTACT_ENTRY_Handle* handle, | 61 | ui_contact_entry_set_contact(UI_CONTACT_ENTRY_Handle* handle, |
60 | const struct GNUNET_CHAT_Contact *contact) | 62 | const struct GNUNET_CHAT_Contact *contact) |
61 | { | 63 | { |
64 | g_assert((handle) && (contact)); | ||
62 | 65 | ||
63 | const char *name = GNUNET_CHAT_contact_get_name(contact); | 66 | const char *name = GNUNET_CHAT_contact_get_name(contact); |
64 | const char *key = GNUNET_CHAT_contact_get_key(contact); | 67 | const char *key = GNUNET_CHAT_contact_get_key(contact); |
@@ -71,6 +74,8 @@ ui_contact_entry_set_contact(UI_CONTACT_ENTRY_Handle* handle, | |||
71 | void | 74 | void |
72 | ui_contact_entry_delete(UI_CONTACT_ENTRY_Handle *handle) | 75 | ui_contact_entry_delete(UI_CONTACT_ENTRY_Handle *handle) |
73 | { | 76 | { |
77 | g_assert(handle); | ||
78 | |||
74 | g_object_unref(handle->builder); | 79 | g_object_unref(handle->builder); |
75 | 80 | ||
76 | g_free(handle); | 81 | g_free(handle); |
diff --git a/src/ui/contact_entry.h b/src/ui/contact_entry.h index dc692de..b8e6943 100644 --- a/src/ui/contact_entry.h +++ b/src/ui/contact_entry.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -60,7 +60,7 @@ ui_contact_entry_new(MESSENGER_Application *app); | |||
60 | */ | 60 | */ |
61 | void | 61 | void |
62 | ui_contact_entry_set_contact(UI_CONTACT_ENTRY_Handle* handle, | 62 | ui_contact_entry_set_contact(UI_CONTACT_ENTRY_Handle* handle, |
63 | const struct GNUNET_CHAT_Contact *contact); | 63 | const struct GNUNET_CHAT_Contact *contact); |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * Frees its resources and destroys a given | 66 | * Frees its resources and destroys a given |
diff --git a/src/ui/contact_info.c b/src/ui/contact_info.c index da03802..874c4e4 100644 --- a/src/ui/contact_info.c +++ b/src/ui/contact_info.c | |||
@@ -34,6 +34,8 @@ static void | |||
34 | handle_contact_edit_button_click(UNUSED GtkButton *button, | 34 | handle_contact_edit_button_click(UNUSED GtkButton *button, |
35 | gpointer user_data) | 35 | gpointer user_data) |
36 | { | 36 | { |
37 | g_assert(user_data); | ||
38 | |||
37 | UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) user_data; | 39 | UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) user_data; |
38 | 40 | ||
39 | gboolean editable = gtk_widget_is_sensitive( | 41 | gboolean editable = gtk_widget_is_sensitive( |
@@ -85,6 +87,8 @@ static void | |||
85 | handle_contact_name_entry_activate(UNUSED GtkEntry *entry, | 87 | handle_contact_name_entry_activate(UNUSED GtkEntry *entry, |
86 | gpointer user_data) | 88 | gpointer user_data) |
87 | { | 89 | { |
90 | g_assert(user_data); | ||
91 | |||
88 | UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) user_data; | 92 | UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) user_data; |
89 | 93 | ||
90 | handle_contact_edit_button_click(handle->contact_edit_button, handle); | 94 | handle_contact_edit_button_click(handle->contact_edit_button, handle); |
@@ -93,6 +97,8 @@ handle_contact_name_entry_activate(UNUSED GtkEntry *entry, | |||
93 | static void | 97 | static void |
94 | _contact_info_reveal_identity(UI_CONTACT_INFO_Handle *handle) | 98 | _contact_info_reveal_identity(UI_CONTACT_INFO_Handle *handle) |
95 | { | 99 | { |
100 | g_assert(handle); | ||
101 | |||
96 | gtk_widget_set_visible(GTK_WIDGET(handle->back_button), TRUE); | 102 | gtk_widget_set_visible(GTK_WIDGET(handle->back_button), TRUE); |
97 | 103 | ||
98 | gtk_stack_set_visible_child( | 104 | gtk_stack_set_visible_child( |
@@ -105,6 +111,8 @@ static void | |||
105 | handle_reveal_identity_button_click(UNUSED GtkButton *button, | 111 | handle_reveal_identity_button_click(UNUSED GtkButton *button, |
106 | gpointer user_data) | 112 | gpointer user_data) |
107 | { | 113 | { |
114 | g_assert(user_data); | ||
115 | |||
108 | _contact_info_reveal_identity((UI_CONTACT_INFO_Handle*) user_data); | 116 | _contact_info_reveal_identity((UI_CONTACT_INFO_Handle*) user_data); |
109 | } | 117 | } |
110 | 118 | ||
@@ -112,6 +120,8 @@ static void | |||
112 | handle_block_button_click(UNUSED GtkButton *button, | 120 | handle_block_button_click(UNUSED GtkButton *button, |
113 | gpointer user_data) | 121 | gpointer user_data) |
114 | { | 122 | { |
123 | g_assert(user_data); | ||
124 | |||
115 | UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) user_data; | 125 | UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) user_data; |
116 | 126 | ||
117 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( | 127 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( |
@@ -136,6 +146,8 @@ static void | |||
136 | handle_unblock_button_click(UNUSED GtkButton *button, | 146 | handle_unblock_button_click(UNUSED GtkButton *button, |
137 | gpointer user_data) | 147 | gpointer user_data) |
138 | { | 148 | { |
149 | g_assert(user_data); | ||
150 | |||
139 | UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) user_data; | 151 | UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) user_data; |
140 | 152 | ||
141 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( | 153 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( |
@@ -160,6 +172,8 @@ static void | |||
160 | handle_open_chat_button_click(UNUSED GtkButton *button, | 172 | handle_open_chat_button_click(UNUSED GtkButton *button, |
161 | gpointer user_data) | 173 | gpointer user_data) |
162 | { | 174 | { |
175 | g_assert(user_data); | ||
176 | |||
163 | UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) user_data; | 177 | UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) user_data; |
164 | 178 | ||
165 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( | 179 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( |
@@ -210,6 +224,8 @@ static void | |||
210 | handle_back_button_click(UNUSED GtkButton *button, | 224 | handle_back_button_click(UNUSED GtkButton *button, |
211 | gpointer user_data) | 225 | gpointer user_data) |
212 | { | 226 | { |
227 | g_assert(user_data); | ||
228 | |||
213 | UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) user_data; | 229 | UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) user_data; |
214 | 230 | ||
215 | gtk_widget_set_visible(GTK_WIDGET(handle->back_button), FALSE); | 231 | gtk_widget_set_visible(GTK_WIDGET(handle->back_button), FALSE); |
@@ -222,24 +238,30 @@ handle_back_button_click(UNUSED GtkButton *button, | |||
222 | 238 | ||
223 | static void | 239 | static void |
224 | handle_close_button_click(UNUSED GtkButton *button, | 240 | handle_close_button_click(UNUSED GtkButton *button, |
225 | gpointer user_data) | 241 | gpointer user_data) |
226 | { | 242 | { |
243 | g_assert(user_data); | ||
244 | |||
227 | GtkDialog *dialog = GTK_DIALOG(user_data); | 245 | GtkDialog *dialog = GTK_DIALOG(user_data); |
228 | gtk_window_close(GTK_WINDOW(dialog)); | 246 | gtk_window_close(GTK_WINDOW(dialog)); |
229 | } | 247 | } |
230 | 248 | ||
231 | static void | 249 | static void |
232 | handle_dialog_destroy(UNUSED GtkWidget *window, | 250 | handle_dialog_destroy(UNUSED GtkWidget *window, |
233 | gpointer user_data) | 251 | gpointer user_data) |
234 | { | 252 | { |
253 | g_assert(user_data); | ||
254 | |||
235 | ui_contact_info_dialog_cleanup((UI_CONTACT_INFO_Handle*) user_data); | 255 | ui_contact_info_dialog_cleanup((UI_CONTACT_INFO_Handle*) user_data); |
236 | } | 256 | } |
237 | 257 | ||
238 | static gboolean | 258 | static gboolean |
239 | handle_id_drawing_area_draw(GtkWidget* drawing_area, | 259 | handle_id_drawing_area_draw(GtkWidget* drawing_area, |
240 | cairo_t* cairo, | 260 | cairo_t* cairo, |
241 | gpointer user_data) | 261 | gpointer user_data) |
242 | { | 262 | { |
263 | g_assert((drawing_area) && (cairo) && (user_data)); | ||
264 | |||
243 | UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) user_data; | 265 | UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) user_data; |
244 | 266 | ||
245 | GtkStyleContext* context = gtk_widget_get_style_context(drawing_area); | 267 | GtkStyleContext* context = gtk_widget_get_style_context(drawing_area); |
@@ -331,8 +353,10 @@ handle_id_drawing_area_draw(GtkWidget* drawing_area, | |||
331 | 353 | ||
332 | void | 354 | void |
333 | ui_contact_info_dialog_init(MESSENGER_Application *app, | 355 | ui_contact_info_dialog_init(MESSENGER_Application *app, |
334 | UI_CONTACT_INFO_Handle *handle) | 356 | UI_CONTACT_INFO_Handle *handle) |
335 | { | 357 | { |
358 | g_assert((app) && (handle)); | ||
359 | |||
336 | handle->app = app; | 360 | handle->app = app; |
337 | 361 | ||
338 | handle->builder = gtk_builder_new_from_resource( | 362 | handle->builder = gtk_builder_new_from_resource( |
@@ -492,6 +516,8 @@ ui_contact_info_dialog_update(UI_CONTACT_INFO_Handle *handle, | |||
492 | struct GNUNET_CHAT_Contact *contact, | 516 | struct GNUNET_CHAT_Contact *contact, |
493 | gboolean reveal) | 517 | gboolean reveal) |
494 | { | 518 | { |
519 | g_assert((handle) && (contact)); | ||
520 | |||
495 | const char *name = GNUNET_CHAT_contact_get_name(contact); | 521 | const char *name = GNUNET_CHAT_contact_get_name(contact); |
496 | 522 | ||
497 | ui_avatar_set_text(handle->contact_avatar, name); | 523 | ui_avatar_set_text(handle->contact_avatar, name); |
@@ -565,6 +591,8 @@ ui_contact_info_dialog_update(UI_CONTACT_INFO_Handle *handle, | |||
565 | void | 591 | void |
566 | ui_contact_info_dialog_cleanup(UI_CONTACT_INFO_Handle *handle) | 592 | ui_contact_info_dialog_cleanup(UI_CONTACT_INFO_Handle *handle) |
567 | { | 593 | { |
594 | g_assert(handle); | ||
595 | |||
568 | g_signal_handler_disconnect( | 596 | g_signal_handler_disconnect( |
569 | handle->id_drawing_area, | 597 | handle->id_drawing_area, |
570 | handle->id_draw_signal | 598 | handle->id_draw_signal |
diff --git a/src/ui/contact_info.h b/src/ui/contact_info.h index 32a3366..ff61bdf 100644 --- a/src/ui/contact_info.h +++ b/src/ui/contact_info.h | |||
@@ -75,7 +75,7 @@ typedef struct UI_CONTACT_INFO_Handle | |||
75 | */ | 75 | */ |
76 | void | 76 | void |
77 | ui_contact_info_dialog_init(MESSENGER_Application *app, | 77 | ui_contact_info_dialog_init(MESSENGER_Application *app, |
78 | UI_CONTACT_INFO_Handle *handle); | 78 | UI_CONTACT_INFO_Handle *handle); |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * Updates a given contact info dialog handle with | 81 | * Updates a given contact info dialog handle with |
@@ -89,8 +89,8 @@ ui_contact_info_dialog_init(MESSENGER_Application *app, | |||
89 | */ | 89 | */ |
90 | void | 90 | void |
91 | ui_contact_info_dialog_update(UI_CONTACT_INFO_Handle *handle, | 91 | ui_contact_info_dialog_update(UI_CONTACT_INFO_Handle *handle, |
92 | struct GNUNET_CHAT_Contact *contact, | 92 | struct GNUNET_CHAT_Contact *contact, |
93 | gboolean reveal); | 93 | gboolean reveal); |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * Cleans up the allocated resources and resets the | 96 | * Cleans up the allocated resources and resets the |
diff --git a/src/ui/contacts.c b/src/ui/contacts.c index 5898fde..75b1870 100644 --- a/src/ui/contacts.c +++ b/src/ui/contacts.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -24,14 +24,15 @@ | |||
24 | 24 | ||
25 | #include "contacts.h" | 25 | #include "contacts.h" |
26 | 26 | ||
27 | #include "chat_entry.h" | ||
28 | #include "contact_entry.h" | 27 | #include "contact_entry.h" |
29 | #include "../application.h" | 28 | #include "../application.h" |
30 | 29 | ||
31 | static void | 30 | static void |
32 | handle_close_button_click(UNUSED GtkButton *button, | 31 | handle_close_button_click(UNUSED GtkButton *button, |
33 | gpointer user_data) | 32 | gpointer user_data) |
34 | { | 33 | { |
34 | g_assert(user_data); | ||
35 | |||
35 | GtkDialog *dialog = GTK_DIALOG(user_data); | 36 | GtkDialog *dialog = GTK_DIALOG(user_data); |
36 | gtk_window_close(GTK_WINDOW(dialog)); | 37 | gtk_window_close(GTK_WINDOW(dialog)); |
37 | } | 38 | } |
@@ -39,6 +40,8 @@ handle_close_button_click(UNUSED GtkButton *button, | |||
39 | static gboolean | 40 | static gboolean |
40 | _open_new_contact_dialog(gpointer user_data) | 41 | _open_new_contact_dialog(gpointer user_data) |
41 | { | 42 | { |
43 | g_assert(user_data); | ||
44 | |||
42 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 45 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
43 | 46 | ||
44 | ui_new_contact_dialog_init(app, &(app->ui.new_contact)); | 47 | ui_new_contact_dialog_init(app, &(app->ui.new_contact)); |
@@ -49,9 +52,11 @@ _open_new_contact_dialog(gpointer user_data) | |||
49 | 52 | ||
50 | static void | 53 | static void |
51 | handle_contacts_listbox_row_activated(UNUSED GtkListBox* listbox, | 54 | handle_contacts_listbox_row_activated(UNUSED GtkListBox* listbox, |
52 | GtkListBoxRow* row, | 55 | GtkListBoxRow* row, |
53 | gpointer user_data) | 56 | gpointer user_data) |
54 | { | 57 | { |
58 | g_assert((row) && (user_data)); | ||
59 | |||
55 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 60 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
56 | 61 | ||
57 | if (!gtk_list_box_row_get_selectable(row)) | 62 | if (!gtk_list_box_row_get_selectable(row)) |
@@ -84,11 +89,13 @@ close_dialog: | |||
84 | 89 | ||
85 | static gboolean | 90 | static gboolean |
86 | handle_contacts_listbox_filter_func(GtkListBoxRow *row, | 91 | handle_contacts_listbox_filter_func(GtkListBoxRow *row, |
87 | gpointer user_data) | 92 | gpointer user_data) |
88 | { | 93 | { |
94 | g_assert((row) && (user_data)); | ||
95 | |||
89 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 96 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
90 | 97 | ||
91 | if ((!row) || (!gtk_list_box_row_get_selectable(row))) | 98 | if (!gtk_list_box_row_get_selectable(row)) |
92 | return TRUE; | 99 | return TRUE; |
93 | 100 | ||
94 | const gchar *filter = gtk_entry_get_text( | 101 | const gchar *filter = gtk_entry_get_text( |
@@ -115,8 +122,10 @@ handle_contacts_listbox_filter_func(GtkListBoxRow *row, | |||
115 | 122 | ||
116 | static void | 123 | static void |
117 | handle_contact_search_entry_search_changed(UNUSED GtkSearchEntry* search_entry, | 124 | handle_contact_search_entry_search_changed(UNUSED GtkSearchEntry* search_entry, |
118 | gpointer user_data) | 125 | gpointer user_data) |
119 | { | 126 | { |
127 | g_assert(user_data); | ||
128 | |||
120 | GtkListBox *listbox = GTK_LIST_BOX(user_data); | 129 | GtkListBox *listbox = GTK_LIST_BOX(user_data); |
121 | 130 | ||
122 | gtk_list_box_invalidate_filter(listbox); | 131 | gtk_list_box_invalidate_filter(listbox); |
@@ -124,16 +133,20 @@ handle_contact_search_entry_search_changed(UNUSED GtkSearchEntry* search_entry, | |||
124 | 133 | ||
125 | static void | 134 | static void |
126 | handle_dialog_destroy(UNUSED GtkWidget *window, | 135 | handle_dialog_destroy(UNUSED GtkWidget *window, |
127 | gpointer user_data) | 136 | gpointer user_data) |
128 | { | 137 | { |
138 | g_assert(user_data); | ||
139 | |||
129 | ui_contacts_dialog_cleanup((UI_CONTACTS_Handle*) user_data); | 140 | ui_contacts_dialog_cleanup((UI_CONTACTS_Handle*) user_data); |
130 | } | 141 | } |
131 | 142 | ||
132 | static int | 143 | static int |
133 | _iterate_contacts(void *cls, | 144 | _iterate_contacts(void *cls, |
134 | UNUSED struct GNUNET_CHAT_Handle *handle, | 145 | UNUSED struct GNUNET_CHAT_Handle *handle, |
135 | struct GNUNET_CHAT_Contact *contact) | 146 | struct GNUNET_CHAT_Contact *contact) |
136 | { | 147 | { |
148 | g_assert((cls) && (contact)); | ||
149 | |||
137 | if (GNUNET_YES == GNUNET_CHAT_contact_is_owned(contact)) | 150 | if (GNUNET_YES == GNUNET_CHAT_contact_is_owned(contact)) |
138 | return GNUNET_YES; | 151 | return GNUNET_YES; |
139 | 152 | ||
@@ -165,72 +178,74 @@ _iterate_contacts(void *cls, | |||
165 | 178 | ||
166 | void | 179 | void |
167 | ui_contacts_dialog_init(MESSENGER_Application *app, | 180 | ui_contacts_dialog_init(MESSENGER_Application *app, |
168 | UI_CONTACTS_Handle *handle) | 181 | UI_CONTACTS_Handle *handle) |
169 | { | 182 | { |
183 | g_assert((app) && (handle)); | ||
184 | |||
170 | handle->builder = gtk_builder_new_from_resource( | 185 | handle->builder = gtk_builder_new_from_resource( |
171 | application_get_resource_path(app, "ui/contacts.ui") | 186 | application_get_resource_path(app, "ui/contacts.ui") |
172 | ); | 187 | ); |
173 | 188 | ||
174 | handle->dialog = GTK_DIALOG( | 189 | handle->dialog = GTK_DIALOG( |
175 | gtk_builder_get_object(handle->builder, "contacts_dialog") | 190 | gtk_builder_get_object(handle->builder, "contacts_dialog") |
176 | ); | 191 | ); |
177 | 192 | ||
178 | gtk_window_set_transient_for( | 193 | gtk_window_set_transient_for( |
179 | GTK_WINDOW(handle->dialog), | 194 | GTK_WINDOW(handle->dialog), |
180 | GTK_WINDOW(app->ui.messenger.main_window) | 195 | GTK_WINDOW(app->ui.messenger.main_window) |
181 | ); | 196 | ); |
182 | 197 | ||
183 | handle->contact_search_entry = GTK_SEARCH_ENTRY( | 198 | handle->contact_search_entry = GTK_SEARCH_ENTRY( |
184 | gtk_builder_get_object(handle->builder, "contact_search_entry") | 199 | gtk_builder_get_object(handle->builder, "contact_search_entry") |
185 | ); | 200 | ); |
186 | 201 | ||
187 | handle->contacts_listbox = GTK_LIST_BOX( | 202 | handle->contacts_listbox = GTK_LIST_BOX( |
188 | gtk_builder_get_object(handle->builder, "contacts_listbox") | 203 | gtk_builder_get_object(handle->builder, "contacts_listbox") |
189 | ); | 204 | ); |
190 | 205 | ||
191 | gtk_list_box_set_filter_func( | 206 | gtk_list_box_set_filter_func( |
192 | handle->contacts_listbox, | 207 | handle->contacts_listbox, |
193 | handle_contacts_listbox_filter_func, | 208 | handle_contacts_listbox_filter_func, |
194 | app, | 209 | app, |
195 | NULL | 210 | NULL |
196 | ); | 211 | ); |
197 | 212 | ||
198 | g_signal_connect( | 213 | g_signal_connect( |
199 | handle->contact_search_entry, | 214 | handle->contact_search_entry, |
200 | "search-changed", | 215 | "search-changed", |
201 | G_CALLBACK(handle_contact_search_entry_search_changed), | 216 | G_CALLBACK(handle_contact_search_entry_search_changed), |
202 | handle->contacts_listbox | 217 | handle->contacts_listbox |
203 | ); | 218 | ); |
204 | 219 | ||
205 | g_signal_connect( | 220 | g_signal_connect( |
206 | handle->contacts_listbox, | 221 | handle->contacts_listbox, |
207 | "row-activated", | 222 | "row-activated", |
208 | G_CALLBACK(handle_contacts_listbox_row_activated), | 223 | G_CALLBACK(handle_contacts_listbox_row_activated), |
209 | app | 224 | app |
210 | ); | 225 | ); |
211 | 226 | ||
212 | handle->close_button = GTK_BUTTON( | 227 | handle->close_button = GTK_BUTTON( |
213 | gtk_builder_get_object(handle->builder, "close_button") | 228 | gtk_builder_get_object(handle->builder, "close_button") |
214 | ); | 229 | ); |
215 | 230 | ||
216 | g_signal_connect( | 231 | g_signal_connect( |
217 | handle->close_button, | 232 | handle->close_button, |
218 | "clicked", | 233 | "clicked", |
219 | G_CALLBACK(handle_close_button_click), | 234 | G_CALLBACK(handle_close_button_click), |
220 | handle->dialog | 235 | handle->dialog |
221 | ); | 236 | ); |
222 | 237 | ||
223 | g_signal_connect( | 238 | g_signal_connect( |
224 | handle->dialog, | 239 | handle->dialog, |
225 | "destroy", | 240 | "destroy", |
226 | G_CALLBACK(handle_dialog_destroy), | 241 | G_CALLBACK(handle_dialog_destroy), |
227 | handle | 242 | handle |
228 | ); | 243 | ); |
229 | 244 | ||
230 | GNUNET_CHAT_iterate_contacts( | 245 | GNUNET_CHAT_iterate_contacts( |
231 | app->chat.messenger.handle, | 246 | app->chat.messenger.handle, |
232 | _iterate_contacts, | 247 | _iterate_contacts, |
233 | app | 248 | app |
234 | ); | 249 | ); |
235 | 250 | ||
236 | gtk_list_box_invalidate_filter(handle->contacts_listbox); | 251 | gtk_list_box_invalidate_filter(handle->contacts_listbox); |
@@ -239,6 +254,8 @@ ui_contacts_dialog_init(MESSENGER_Application *app, | |||
239 | void | 254 | void |
240 | ui_contacts_dialog_cleanup(UI_CONTACTS_Handle *handle) | 255 | ui_contacts_dialog_cleanup(UI_CONTACTS_Handle *handle) |
241 | { | 256 | { |
257 | g_assert(handle); | ||
258 | |||
242 | g_object_unref(handle->builder); | 259 | g_object_unref(handle->builder); |
243 | 260 | ||
244 | memset(handle, 0, sizeof(*handle)); | 261 | memset(handle, 0, sizeof(*handle)); |
diff --git a/src/ui/contacts.h b/src/ui/contacts.h index f63b554..5d126e7 100644 --- a/src/ui/contacts.h +++ b/src/ui/contacts.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -48,7 +48,7 @@ typedef struct UI_CONTACTS_Handle | |||
48 | */ | 48 | */ |
49 | void | 49 | void |
50 | ui_contacts_dialog_init(MESSENGER_Application *app, | 50 | ui_contacts_dialog_init(MESSENGER_Application *app, |
51 | UI_CONTACTS_Handle *handle); | 51 | UI_CONTACTS_Handle *handle); |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Cleans up the allocated resources and resets the | 54 | * Cleans up the allocated resources and resets the |
diff --git a/src/ui/delete_messages.c b/src/ui/delete_messages.c index 67172a6..1f4d28f 100644 --- a/src/ui/delete_messages.c +++ b/src/ui/delete_messages.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2022 GNUnet e.V. | 3 | Copyright (C) 2022--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -28,16 +28,20 @@ | |||
28 | 28 | ||
29 | static void | 29 | static void |
30 | handle_cancel_button_click(UNUSED GtkButton *button, | 30 | handle_cancel_button_click(UNUSED GtkButton *button, |
31 | gpointer user_data) | 31 | gpointer user_data) |
32 | { | 32 | { |
33 | g_assert(user_data); | ||
34 | |||
33 | GtkDialog *dialog = GTK_DIALOG(user_data); | 35 | GtkDialog *dialog = GTK_DIALOG(user_data); |
34 | gtk_window_close(GTK_WINDOW(dialog)); | 36 | gtk_window_close(GTK_WINDOW(dialog)); |
35 | } | 37 | } |
36 | 38 | ||
37 | static void | 39 | static void |
38 | handle_confirm_button_click(UNUSED GtkButton *button, | 40 | handle_confirm_button_click(UNUSED GtkButton *button, |
39 | gpointer user_data) | 41 | gpointer user_data) |
40 | { | 42 | { |
43 | g_assert(user_data); | ||
44 | |||
41 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 45 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
42 | 46 | ||
43 | app->settings.hide_delete_dialog = gtk_toggle_button_get_active( | 47 | app->settings.hide_delete_dialog = gtk_toggle_button_get_active( |
@@ -51,8 +55,7 @@ handle_confirm_button_click(UNUSED GtkButton *button, | |||
51 | gulong delay = 0; | 55 | gulong delay = 0; |
52 | 56 | ||
53 | GtkTreeIter iter; | 57 | GtkTreeIter iter; |
54 | if (gtk_combo_box_get_active_iter(app->ui.delete_messages.delay_combobox, | 58 | if (gtk_combo_box_get_active_iter(app->ui.delete_messages.delay_combobox, &iter)) |
55 | &iter)) | ||
56 | gtk_tree_model_get(model, &iter, 1, &delay, -1); | 59 | gtk_tree_model_get(model, &iter, 1, &delay, -1); |
57 | 60 | ||
58 | if (app->ui.delete_messages.callback) | 61 | if (app->ui.delete_messages.callback) |
@@ -67,8 +70,10 @@ handle_confirm_button_click(UNUSED GtkButton *button, | |||
67 | 70 | ||
68 | static void | 71 | static void |
69 | handle_dialog_destroy(UNUSED GtkWidget *window, | 72 | handle_dialog_destroy(UNUSED GtkWidget *window, |
70 | gpointer user_data) | 73 | gpointer user_data) |
71 | { | 74 | { |
75 | g_assert(user_data); | ||
76 | |||
72 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 77 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
73 | 78 | ||
74 | ui_delete_messages_dialog_cleanup(&(app->ui.delete_messages)); | 79 | ui_delete_messages_dialog_cleanup(&(app->ui.delete_messages)); |
@@ -76,63 +81,65 @@ handle_dialog_destroy(UNUSED GtkWidget *window, | |||
76 | 81 | ||
77 | void | 82 | void |
78 | ui_delete_messages_dialog_init(MESSENGER_Application *app, | 83 | ui_delete_messages_dialog_init(MESSENGER_Application *app, |
79 | UI_DELETE_MESSAGES_Handle *handle) | 84 | UI_DELETE_MESSAGES_Handle *handle) |
80 | { | 85 | { |
86 | g_assert((app) && (handle)); | ||
87 | |||
81 | handle->selected = NULL; | 88 | handle->selected = NULL; |
82 | handle->callback = NULL; | 89 | handle->callback = NULL; |
83 | 90 | ||
84 | handle->builder = gtk_builder_new_from_resource( | 91 | handle->builder = gtk_builder_new_from_resource( |
85 | application_get_resource_path(app, "ui/delete_messages.ui") | 92 | application_get_resource_path(app, "ui/delete_messages.ui") |
86 | ); | 93 | ); |
87 | 94 | ||
88 | handle->dialog = GTK_DIALOG( | 95 | handle->dialog = GTK_DIALOG( |
89 | gtk_builder_get_object(handle->builder, "delete_messages_dialog") | 96 | gtk_builder_get_object(handle->builder, "delete_messages_dialog") |
90 | ); | 97 | ); |
91 | 98 | ||
92 | gtk_window_set_transient_for( | 99 | gtk_window_set_transient_for( |
93 | GTK_WINDOW(handle->dialog), | 100 | GTK_WINDOW(handle->dialog), |
94 | GTK_WINDOW(app->ui.messenger.main_window) | 101 | GTK_WINDOW(app->ui.messenger.main_window) |
95 | ); | 102 | ); |
96 | 103 | ||
97 | handle->delay_store = GTK_LIST_STORE( | 104 | handle->delay_store = GTK_LIST_STORE( |
98 | gtk_builder_get_object(handle->builder, "delay_store") | 105 | gtk_builder_get_object(handle->builder, "delay_store") |
99 | ); | 106 | ); |
100 | 107 | ||
101 | handle->delay_combobox = GTK_COMBO_BOX( | 108 | handle->delay_combobox = GTK_COMBO_BOX( |
102 | gtk_builder_get_object(handle->builder, "delay_combobox") | 109 | gtk_builder_get_object(handle->builder, "delay_combobox") |
103 | ); | 110 | ); |
104 | 111 | ||
105 | handle->hide_checkbox = GTK_CHECK_BUTTON( | 112 | handle->hide_checkbox = GTK_CHECK_BUTTON( |
106 | gtk_builder_get_object(handle->builder, "hide_checkbox") | 113 | gtk_builder_get_object(handle->builder, "hide_checkbox") |
107 | ); | 114 | ); |
108 | 115 | ||
109 | handle->cancel_button = GTK_BUTTON( | 116 | handle->cancel_button = GTK_BUTTON( |
110 | gtk_builder_get_object(handle->builder, "cancel_button") | 117 | gtk_builder_get_object(handle->builder, "cancel_button") |
111 | ); | 118 | ); |
112 | 119 | ||
113 | g_signal_connect( | 120 | g_signal_connect( |
114 | handle->cancel_button, | 121 | handle->cancel_button, |
115 | "clicked", | 122 | "clicked", |
116 | G_CALLBACK(handle_cancel_button_click), | 123 | G_CALLBACK(handle_cancel_button_click), |
117 | handle->dialog | 124 | handle->dialog |
118 | ); | 125 | ); |
119 | 126 | ||
120 | handle->confirm_button = GTK_BUTTON( | 127 | handle->confirm_button = GTK_BUTTON( |
121 | gtk_builder_get_object(handle->builder, "confirm_button") | 128 | gtk_builder_get_object(handle->builder, "confirm_button") |
122 | ); | 129 | ); |
123 | 130 | ||
124 | g_signal_connect( | 131 | g_signal_connect( |
125 | handle->confirm_button, | 132 | handle->confirm_button, |
126 | "clicked", | 133 | "clicked", |
127 | G_CALLBACK(handle_confirm_button_click), | 134 | G_CALLBACK(handle_confirm_button_click), |
128 | app | 135 | app |
129 | ); | 136 | ); |
130 | 137 | ||
131 | g_signal_connect( | 138 | g_signal_connect( |
132 | handle->dialog, | 139 | handle->dialog, |
133 | "destroy", | 140 | "destroy", |
134 | G_CALLBACK(handle_dialog_destroy), | 141 | G_CALLBACK(handle_dialog_destroy), |
135 | app | 142 | app |
136 | ); | 143 | ); |
137 | } | 144 | } |
138 | 145 | ||
@@ -141,6 +148,8 @@ ui_delete_messages_dialog_link(UI_DELETE_MESSAGES_Handle *handle, | |||
141 | UI_DELETE_MESSAGES_Callback callback, | 148 | UI_DELETE_MESSAGES_Callback callback, |
142 | GList *selected) | 149 | GList *selected) |
143 | { | 150 | { |
151 | g_assert((handle) && (callback)); | ||
152 | |||
144 | handle->selected = selected; | 153 | handle->selected = selected; |
145 | handle->callback = callback; | 154 | handle->callback = callback; |
146 | } | 155 | } |
@@ -148,6 +157,8 @@ ui_delete_messages_dialog_link(UI_DELETE_MESSAGES_Handle *handle, | |||
148 | void | 157 | void |
149 | ui_delete_messages_dialog_cleanup(UI_DELETE_MESSAGES_Handle *handle) | 158 | ui_delete_messages_dialog_cleanup(UI_DELETE_MESSAGES_Handle *handle) |
150 | { | 159 | { |
160 | g_assert(handle); | ||
161 | |||
151 | g_object_unref(handle->builder); | 162 | g_object_unref(handle->builder); |
152 | 163 | ||
153 | if (handle->selected) | 164 | if (handle->selected) |
diff --git a/src/ui/delete_messages.h b/src/ui/delete_messages.h index 4f5474c..23ce055 100644 --- a/src/ui/delete_messages.h +++ b/src/ui/delete_messages.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2022 GNUnet e.V. | 3 | Copyright (C) 2022--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -28,9 +28,11 @@ | |||
28 | #include "messenger.h" | 28 | #include "messenger.h" |
29 | 29 | ||
30 | typedef void | 30 | typedef void |
31 | (*UI_DELETE_MESSAGES_Callback) (MESSENGER_Application *app, | 31 | (*UI_DELETE_MESSAGES_Callback) ( |
32 | GList *selected, | 32 | MESSENGER_Application *app, |
33 | gulong delay); | 33 | GList *selected, |
34 | gulong delay | ||
35 | ); | ||
34 | 36 | ||
35 | typedef struct UI_DELETE_MESSAGES_Handle | 37 | typedef struct UI_DELETE_MESSAGES_Handle |
36 | { | 38 | { |
@@ -59,7 +61,7 @@ typedef struct UI_DELETE_MESSAGES_Handle | |||
59 | */ | 61 | */ |
60 | void | 62 | void |
61 | ui_delete_messages_dialog_init(MESSENGER_Application *app, | 63 | ui_delete_messages_dialog_init(MESSENGER_Application *app, |
62 | UI_DELETE_MESSAGES_Handle *handle); | 64 | UI_DELETE_MESSAGES_Handle *handle); |
63 | 65 | ||
64 | /** | 66 | /** |
65 | * Links a custom list and a callback to a | 67 | * Links a custom list and a callback to a |
@@ -72,8 +74,8 @@ ui_delete_messages_dialog_init(MESSENGER_Application *app, | |||
72 | */ | 74 | */ |
73 | void | 75 | void |
74 | ui_delete_messages_dialog_link(UI_DELETE_MESSAGES_Handle *handle, | 76 | ui_delete_messages_dialog_link(UI_DELETE_MESSAGES_Handle *handle, |
75 | UI_DELETE_MESSAGES_Callback callback, | 77 | UI_DELETE_MESSAGES_Callback callback, |
76 | GList *selected); | 78 | GList *selected); |
77 | 79 | ||
78 | /** | 80 | /** |
79 | * Cleans up the allocated resources and resets the | 81 | * Cleans up the allocated resources and resets the |
diff --git a/src/ui/file_load_entry.c b/src/ui/file_load_entry.c index a722787..1c0f175 100644 --- a/src/ui/file_load_entry.c +++ b/src/ui/file_load_entry.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2022 GNUnet e.V. | 3 | Copyright (C) 2022--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -30,8 +30,10 @@ | |||
30 | 30 | ||
31 | static void | 31 | static void |
32 | handle_cancel_button_click(GNUNET_UNUSED GtkButton *button, | 32 | handle_cancel_button_click(GNUNET_UNUSED GtkButton *button, |
33 | gpointer user_data) | 33 | gpointer user_data) |
34 | { | 34 | { |
35 | g_assert(user_data); | ||
36 | |||
35 | UI_FILE_LOAD_ENTRY_Handle* handle = (UI_FILE_LOAD_ENTRY_Handle*) user_data; | 37 | UI_FILE_LOAD_ENTRY_Handle* handle = (UI_FILE_LOAD_ENTRY_Handle*) user_data; |
36 | 38 | ||
37 | if (handle->chat) | 39 | if (handle->chat) |
@@ -43,6 +45,8 @@ handle_cancel_button_click(GNUNET_UNUSED GtkButton *button, | |||
43 | UI_FILE_LOAD_ENTRY_Handle* | 45 | UI_FILE_LOAD_ENTRY_Handle* |
44 | ui_file_load_entry_new(MESSENGER_Application *app) | 46 | ui_file_load_entry_new(MESSENGER_Application *app) |
45 | { | 47 | { |
48 | g_assert(app); | ||
49 | |||
46 | UI_FILE_LOAD_ENTRY_Handle* handle = g_malloc(sizeof(UI_FILE_LOAD_ENTRY_Handle)); | 50 | UI_FILE_LOAD_ENTRY_Handle* handle = g_malloc(sizeof(UI_FILE_LOAD_ENTRY_Handle)); |
47 | 51 | ||
48 | handle->chat = NULL; | 52 | handle->chat = NULL; |
@@ -84,6 +88,8 @@ ui_file_load_entry_new(MESSENGER_Application *app) | |||
84 | void | 88 | void |
85 | ui_file_load_entry_delete(UI_FILE_LOAD_ENTRY_Handle *handle) | 89 | ui_file_load_entry_delete(UI_FILE_LOAD_ENTRY_Handle *handle) |
86 | { | 90 | { |
91 | g_assert(handle); | ||
92 | |||
87 | g_object_unref(handle->builder); | 93 | g_object_unref(handle->builder); |
88 | 94 | ||
89 | g_free(handle); | 95 | g_free(handle); |
diff --git a/src/ui/invite_contact.c b/src/ui/invite_contact.c index 8d410bc..7ebf03e 100644 --- a/src/ui/invite_contact.c +++ b/src/ui/invite_contact.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -24,31 +24,34 @@ | |||
24 | 24 | ||
25 | #include "invite_contact.h" | 25 | #include "invite_contact.h" |
26 | 26 | ||
27 | #include "chat_entry.h" | ||
28 | #include "contact_entry.h" | 27 | #include "contact_entry.h" |
29 | #include "../application.h" | 28 | #include "../application.h" |
30 | 29 | ||
31 | static void | 30 | static void |
32 | handle_close_button_click(UNUSED GtkButton *button, | 31 | handle_close_button_click(UNUSED GtkButton *button, |
33 | gpointer user_data) | 32 | gpointer user_data) |
34 | { | 33 | { |
34 | g_assert(user_data); | ||
35 | |||
35 | GtkDialog *dialog = GTK_DIALOG(user_data); | 36 | GtkDialog *dialog = GTK_DIALOG(user_data); |
36 | gtk_window_close(GTK_WINDOW(dialog)); | 37 | gtk_window_close(GTK_WINDOW(dialog)); |
37 | } | 38 | } |
38 | 39 | ||
39 | static void | 40 | static void |
40 | handle_contacts_listbox_row_activated(GtkListBox* listbox, | 41 | handle_contacts_listbox_row_activated(GtkListBox* listbox, |
41 | GtkListBoxRow* row, | 42 | GtkListBoxRow* row, |
42 | gpointer user_data) | 43 | gpointer user_data) |
43 | { | 44 | { |
45 | g_assert((listbox) && (row) && (user_data)); | ||
46 | |||
44 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 47 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
45 | 48 | ||
46 | GtkTextView *text_view = GTK_TEXT_VIEW( | 49 | GtkTextView *text_view = GTK_TEXT_VIEW( |
47 | g_object_get_qdata(G_OBJECT(listbox), app->quarks.widget) | 50 | g_object_get_qdata(G_OBJECT(listbox), app->quarks.widget) |
48 | ); | 51 | ); |
49 | 52 | ||
50 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( | 53 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( |
51 | g_object_get_qdata(G_OBJECT(row), app->quarks.data) | 54 | g_object_get_qdata(G_OBJECT(row), app->quarks.data) |
52 | ); | 55 | ); |
53 | 56 | ||
54 | if ((!contact) || (!GNUNET_CHAT_contact_get_key(contact)) || | 57 | if ((!contact) || (!GNUNET_CHAT_contact_get_key(contact)) || |
@@ -57,14 +60,14 @@ handle_contacts_listbox_row_activated(GtkListBox* listbox, | |||
57 | goto close_dialog; | 60 | goto close_dialog; |
58 | 61 | ||
59 | struct GNUNET_CHAT_Context *context = (struct GNUNET_CHAT_Context*) ( | 62 | struct GNUNET_CHAT_Context *context = (struct GNUNET_CHAT_Context*) ( |
60 | g_object_get_qdata(G_OBJECT(text_view), app->quarks.data) | 63 | g_object_get_qdata(G_OBJECT(text_view), app->quarks.data) |
61 | ); | 64 | ); |
62 | 65 | ||
63 | if (!context) | 66 | if (!context) |
64 | goto close_dialog; | 67 | goto close_dialog; |
65 | 68 | ||
66 | const struct GNUNET_CHAT_Group *group = GNUNET_CHAT_context_get_group( | 69 | const struct GNUNET_CHAT_Group *group = GNUNET_CHAT_context_get_group( |
67 | context | 70 | context |
68 | ); | 71 | ); |
69 | 72 | ||
70 | if (group) | 73 | if (group) |
@@ -76,22 +79,24 @@ close_dialog: | |||
76 | 79 | ||
77 | static gboolean | 80 | static gboolean |
78 | handle_contacts_listbox_filter_func(GtkListBoxRow *row, | 81 | handle_contacts_listbox_filter_func(GtkListBoxRow *row, |
79 | gpointer user_data) | 82 | gpointer user_data) |
80 | { | 83 | { |
84 | g_assert((row) && (user_data)); | ||
85 | |||
81 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 86 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
82 | 87 | ||
83 | if ((!row) || (!gtk_list_box_row_get_selectable(row))) | 88 | if (!gtk_list_box_row_get_selectable(row)) |
84 | return TRUE; | 89 | return TRUE; |
85 | 90 | ||
86 | const gchar *filter = gtk_entry_get_text( | 91 | const gchar *filter = gtk_entry_get_text( |
87 | GTK_ENTRY(app->ui.invite_contact.contact_search_entry) | 92 | GTK_ENTRY(app->ui.invite_contact.contact_search_entry) |
88 | ); | 93 | ); |
89 | 94 | ||
90 | if (!filter) | 95 | if (!filter) |
91 | return TRUE; | 96 | return TRUE; |
92 | 97 | ||
93 | UI_CONTACT_ENTRY_Handle *entry = (UI_CONTACT_ENTRY_Handle*) ( | 98 | UI_CONTACT_ENTRY_Handle *entry = (UI_CONTACT_ENTRY_Handle*) ( |
94 | g_object_get_qdata(G_OBJECT(row), app->quarks.ui) | 99 | g_object_get_qdata(G_OBJECT(row), app->quarks.ui) |
95 | ); | 100 | ); |
96 | 101 | ||
97 | if (!entry) | 102 | if (!entry) |
@@ -107,8 +112,10 @@ handle_contacts_listbox_filter_func(GtkListBoxRow *row, | |||
107 | 112 | ||
108 | static void | 113 | static void |
109 | handle_contact_search_entry_search_changed(UNUSED GtkSearchEntry* search_entry, | 114 | handle_contact_search_entry_search_changed(UNUSED GtkSearchEntry* search_entry, |
110 | gpointer user_data) | 115 | gpointer user_data) |
111 | { | 116 | { |
117 | g_assert(user_data); | ||
118 | |||
112 | GtkListBox *listbox = GTK_LIST_BOX(user_data); | 119 | GtkListBox *listbox = GTK_LIST_BOX(user_data); |
113 | 120 | ||
114 | gtk_list_box_invalidate_filter(listbox); | 121 | gtk_list_box_invalidate_filter(listbox); |
@@ -116,16 +123,20 @@ handle_contact_search_entry_search_changed(UNUSED GtkSearchEntry* search_entry, | |||
116 | 123 | ||
117 | static void | 124 | static void |
118 | handle_dialog_destroy(UNUSED GtkWidget *window, | 125 | handle_dialog_destroy(UNUSED GtkWidget *window, |
119 | gpointer user_data) | 126 | gpointer user_data) |
120 | { | 127 | { |
128 | g_assert(user_data); | ||
129 | |||
121 | ui_contacts_dialog_cleanup((UI_CONTACTS_Handle*) user_data); | 130 | ui_contacts_dialog_cleanup((UI_CONTACTS_Handle*) user_data); |
122 | } | 131 | } |
123 | 132 | ||
124 | static int | 133 | static int |
125 | _iterate_contacts(void *cls, | 134 | _iterate_contacts(void *cls, |
126 | UNUSED struct GNUNET_CHAT_Handle *handle, | 135 | UNUSED struct GNUNET_CHAT_Handle *handle, |
127 | struct GNUNET_CHAT_Contact *contact) | 136 | struct GNUNET_CHAT_Contact *contact) |
128 | { | 137 | { |
138 | g_assert((cls) && (contact)); | ||
139 | |||
129 | if (GNUNET_YES == GNUNET_CHAT_contact_is_owned(contact)) | 140 | if (GNUNET_YES == GNUNET_CHAT_contact_is_owned(contact)) |
130 | return GNUNET_YES; | 141 | return GNUNET_YES; |
131 | 142 | ||
@@ -135,21 +146,21 @@ _iterate_contacts(void *cls, | |||
135 | ui_contact_entry_set_contact(entry, contact); | 146 | ui_contact_entry_set_contact(entry, contact); |
136 | 147 | ||
137 | gtk_list_box_prepend( | 148 | gtk_list_box_prepend( |
138 | app->ui.invite_contact.contacts_listbox, | 149 | app->ui.invite_contact.contacts_listbox, |
139 | entry->entry_box | 150 | entry->entry_box |
140 | ); | 151 | ); |
141 | 152 | ||
142 | GtkListBoxRow *row = GTK_LIST_BOX_ROW( | 153 | GtkListBoxRow *row = GTK_LIST_BOX_ROW( |
143 | gtk_widget_get_parent(entry->entry_box) | 154 | gtk_widget_get_parent(entry->entry_box) |
144 | ); | 155 | ); |
145 | 156 | ||
146 | g_object_set_qdata(G_OBJECT(row), app->quarks.data, contact); | 157 | g_object_set_qdata(G_OBJECT(row), app->quarks.data, contact); |
147 | 158 | ||
148 | g_object_set_qdata_full( | 159 | g_object_set_qdata_full( |
149 | G_OBJECT(row), | 160 | G_OBJECT(row), |
150 | app->quarks.ui, | 161 | app->quarks.ui, |
151 | entry, | 162 | entry, |
152 | (GDestroyNotify) ui_contact_entry_delete | 163 | (GDestroyNotify) ui_contact_entry_delete |
153 | ); | 164 | ); |
154 | 165 | ||
155 | return GNUNET_YES; | 166 | return GNUNET_YES; |
@@ -157,72 +168,74 @@ _iterate_contacts(void *cls, | |||
157 | 168 | ||
158 | void | 169 | void |
159 | ui_invite_contact_dialog_init(MESSENGER_Application *app, | 170 | ui_invite_contact_dialog_init(MESSENGER_Application *app, |
160 | UI_INVITE_CONTACT_Handle *handle) | 171 | UI_INVITE_CONTACT_Handle *handle) |
161 | { | 172 | { |
173 | g_assert((app) && (handle)); | ||
174 | |||
162 | handle->builder = gtk_builder_new_from_resource( | 175 | handle->builder = gtk_builder_new_from_resource( |
163 | application_get_resource_path(app, "ui/invite_contact.ui") | 176 | application_get_resource_path(app, "ui/invite_contact.ui") |
164 | ); | 177 | ); |
165 | 178 | ||
166 | handle->dialog = GTK_DIALOG( | 179 | handle->dialog = GTK_DIALOG( |
167 | gtk_builder_get_object(handle->builder, "invite_contact_dialog") | 180 | gtk_builder_get_object(handle->builder, "invite_contact_dialog") |
168 | ); | 181 | ); |
169 | 182 | ||
170 | gtk_window_set_transient_for( | 183 | gtk_window_set_transient_for( |
171 | GTK_WINDOW(handle->dialog), | 184 | GTK_WINDOW(handle->dialog), |
172 | GTK_WINDOW(app->ui.messenger.main_window) | 185 | GTK_WINDOW(app->ui.messenger.main_window) |
173 | ); | 186 | ); |
174 | 187 | ||
175 | handle->contact_search_entry = GTK_SEARCH_ENTRY( | 188 | handle->contact_search_entry = GTK_SEARCH_ENTRY( |
176 | gtk_builder_get_object(handle->builder, "contact_search_entry") | 189 | gtk_builder_get_object(handle->builder, "contact_search_entry") |
177 | ); | 190 | ); |
178 | 191 | ||
179 | handle->contacts_listbox = GTK_LIST_BOX( | 192 | handle->contacts_listbox = GTK_LIST_BOX( |
180 | gtk_builder_get_object(handle->builder, "contacts_listbox") | 193 | gtk_builder_get_object(handle->builder, "contacts_listbox") |
181 | ); | 194 | ); |
182 | 195 | ||
183 | gtk_list_box_set_filter_func( | 196 | gtk_list_box_set_filter_func( |
184 | handle->contacts_listbox, | 197 | handle->contacts_listbox, |
185 | handle_contacts_listbox_filter_func, | 198 | handle_contacts_listbox_filter_func, |
186 | app, | 199 | app, |
187 | NULL | 200 | NULL |
188 | ); | 201 | ); |
189 | 202 | ||
190 | g_signal_connect( | 203 | g_signal_connect( |
191 | handle->contact_search_entry, | 204 | handle->contact_search_entry, |
192 | "search-changed", | 205 | "search-changed", |
193 | G_CALLBACK(handle_contact_search_entry_search_changed), | 206 | G_CALLBACK(handle_contact_search_entry_search_changed), |
194 | handle->contacts_listbox | 207 | handle->contacts_listbox |
195 | ); | 208 | ); |
196 | 209 | ||
197 | g_signal_connect( | 210 | g_signal_connect( |
198 | handle->contacts_listbox, | 211 | handle->contacts_listbox, |
199 | "row-activated", | 212 | "row-activated", |
200 | G_CALLBACK(handle_contacts_listbox_row_activated), | 213 | G_CALLBACK(handle_contacts_listbox_row_activated), |
201 | app | 214 | app |
202 | ); | 215 | ); |
203 | 216 | ||
204 | handle->close_button = GTK_BUTTON( | 217 | handle->close_button = GTK_BUTTON( |
205 | gtk_builder_get_object(handle->builder, "close_button") | 218 | gtk_builder_get_object(handle->builder, "close_button") |
206 | ); | 219 | ); |
207 | 220 | ||
208 | g_signal_connect( | 221 | g_signal_connect( |
209 | handle->close_button, | 222 | handle->close_button, |
210 | "clicked", | 223 | "clicked", |
211 | G_CALLBACK(handle_close_button_click), | 224 | G_CALLBACK(handle_close_button_click), |
212 | handle->dialog | 225 | handle->dialog |
213 | ); | 226 | ); |
214 | 227 | ||
215 | g_signal_connect( | 228 | g_signal_connect( |
216 | handle->dialog, | 229 | handle->dialog, |
217 | "destroy", | 230 | "destroy", |
218 | G_CALLBACK(handle_dialog_destroy), | 231 | G_CALLBACK(handle_dialog_destroy), |
219 | handle | 232 | handle |
220 | ); | 233 | ); |
221 | 234 | ||
222 | GNUNET_CHAT_iterate_contacts( | 235 | GNUNET_CHAT_iterate_contacts( |
223 | app->chat.messenger.handle, | 236 | app->chat.messenger.handle, |
224 | _iterate_contacts, | 237 | _iterate_contacts, |
225 | app | 238 | app |
226 | ); | 239 | ); |
227 | 240 | ||
228 | gtk_list_box_invalidate_filter(handle->contacts_listbox); | 241 | gtk_list_box_invalidate_filter(handle->contacts_listbox); |
@@ -231,6 +244,8 @@ ui_invite_contact_dialog_init(MESSENGER_Application *app, | |||
231 | void | 244 | void |
232 | ui_invite_contact_dialog_cleanup(UI_INVITE_CONTACT_Handle *handle) | 245 | ui_invite_contact_dialog_cleanup(UI_INVITE_CONTACT_Handle *handle) |
233 | { | 246 | { |
247 | g_assert(handle); | ||
248 | |||
234 | g_object_unref(handle->builder); | 249 | g_object_unref(handle->builder); |
235 | 250 | ||
236 | memset(handle, 0, sizeof(*handle)); | 251 | memset(handle, 0, sizeof(*handle)); |
diff --git a/src/ui/invite_contact.h b/src/ui/invite_contact.h index 2630c84..d415112 100644 --- a/src/ui/invite_contact.h +++ b/src/ui/invite_contact.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -48,7 +48,7 @@ typedef struct UI_INVITE_CONTACT_Handle | |||
48 | */ | 48 | */ |
49 | void | 49 | void |
50 | ui_invite_contact_dialog_init(MESSENGER_Application *app, | 50 | ui_invite_contact_dialog_init(MESSENGER_Application *app, |
51 | UI_INVITE_CONTACT_Handle *handle); | 51 | UI_INVITE_CONTACT_Handle *handle); |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Cleans up the allocated resources and resets the | 54 | * Cleans up the allocated resources and resets the |
diff --git a/src/ui/message.c b/src/ui/message.c index fac0f61..57668dc 100644 --- a/src/ui/message.c +++ b/src/ui/message.c | |||
@@ -38,7 +38,7 @@ handle_downloading_file(void *cls, | |||
38 | uint64_t completed, | 38 | uint64_t completed, |
39 | uint64_t size) | 39 | uint64_t size) |
40 | { | 40 | { |
41 | GNUNET_assert((cls) && (file)); | 41 | g_assert((cls) && (file)); |
42 | 42 | ||
43 | MESSENGER_Application *app = (MESSENGER_Application*) cls; | 43 | MESSENGER_Application *app = (MESSENGER_Application*) cls; |
44 | 44 | ||
@@ -52,7 +52,7 @@ static void | |||
52 | handle_file_button_click(GtkButton *button, | 52 | handle_file_button_click(GtkButton *button, |
53 | gpointer user_data) | 53 | gpointer user_data) |
54 | { | 54 | { |
55 | GNUNET_assert((button) && (user_data)); | 55 | g_assert((button) && (user_data)); |
56 | 56 | ||
57 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 57 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
58 | 58 | ||
@@ -118,7 +118,7 @@ static void | |||
118 | handle_media_button_click(GtkButton *button, | 118 | handle_media_button_click(GtkButton *button, |
119 | gpointer user_data) | 119 | gpointer user_data) |
120 | { | 120 | { |
121 | GNUNET_assert((button) && (user_data)); | 121 | g_assert((button) && (user_data)); |
122 | 122 | ||
123 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 123 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
124 | 124 | ||
@@ -159,7 +159,7 @@ handle_media_button_click(GtkButton *button, | |||
159 | static int | 159 | static int |
160 | handle_message_redraw_animation(gpointer user_data) | 160 | handle_message_redraw_animation(gpointer user_data) |
161 | { | 161 | { |
162 | GNUNET_assert(user_data); | 162 | g_assert(user_data); |
163 | 163 | ||
164 | UI_MESSAGE_Handle *handle = (UI_MESSAGE_Handle*) user_data; | 164 | UI_MESSAGE_Handle *handle = (UI_MESSAGE_Handle*) user_data; |
165 | 165 | ||
@@ -179,7 +179,7 @@ handle_preview_drawing_area_draw(GtkWidget* drawing_area, | |||
179 | cairo_t* cairo, | 179 | cairo_t* cairo, |
180 | gpointer user_data) | 180 | gpointer user_data) |
181 | { | 181 | { |
182 | GNUNET_assert((drawing_area) && (cairo) && (user_data)); | 182 | g_assert((drawing_area) && (cairo) && (user_data)); |
183 | 183 | ||
184 | UI_MESSAGE_Handle *handle = (UI_MESSAGE_Handle*) user_data; | 184 | UI_MESSAGE_Handle *handle = (UI_MESSAGE_Handle*) user_data; |
185 | 185 | ||
@@ -261,7 +261,7 @@ render_image: | |||
261 | static void | 261 | static void |
262 | _clear_message_preview_data(UI_MESSAGE_Handle *handle) | 262 | _clear_message_preview_data(UI_MESSAGE_Handle *handle) |
263 | { | 263 | { |
264 | GNUNET_assert(handle); | 264 | g_assert(handle); |
265 | 265 | ||
266 | if (handle->preview_image) | 266 | if (handle->preview_image) |
267 | { | 267 | { |
@@ -299,7 +299,7 @@ UI_MESSAGE_Handle* | |||
299 | ui_message_new(MESSENGER_Application *app, | 299 | ui_message_new(MESSENGER_Application *app, |
300 | UI_MESSAGE_Type type) | 300 | UI_MESSAGE_Type type) |
301 | { | 301 | { |
302 | GNUNET_assert(app); | 302 | g_assert(app); |
303 | 303 | ||
304 | UI_MESSAGE_Handle* handle = g_malloc(sizeof(UI_MESSAGE_Handle)); | 304 | UI_MESSAGE_Handle* handle = g_malloc(sizeof(UI_MESSAGE_Handle)); |
305 | 305 | ||
@@ -492,7 +492,7 @@ _iterate_read_receipts(void *cls, | |||
492 | const struct GNUNET_CHAT_Contact *contact, | 492 | const struct GNUNET_CHAT_Contact *contact, |
493 | int read_receipt) | 493 | int read_receipt) |
494 | { | 494 | { |
495 | GNUNET_assert((cls) && (message) && (contact)); | 495 | g_assert((cls) && (message) && (contact)); |
496 | 496 | ||
497 | int *count_read_receipts = (int*) cls; | 497 | int *count_read_receipts = (int*) cls; |
498 | 498 | ||
@@ -506,7 +506,7 @@ _iterate_read_receipts(void *cls, | |||
506 | void | 506 | void |
507 | ui_message_refresh(UI_MESSAGE_Handle *handle) | 507 | ui_message_refresh(UI_MESSAGE_Handle *handle) |
508 | { | 508 | { |
509 | GNUNET_assert(handle); | 509 | g_assert(handle); |
510 | 510 | ||
511 | if ((!(handle->msg)) || | 511 | if ((!(handle->msg)) || |
512 | (GNUNET_YES != GNUNET_CHAT_message_is_sent(handle->msg))) | 512 | (GNUNET_YES != GNUNET_CHAT_message_is_sent(handle->msg))) |
@@ -549,7 +549,7 @@ _update_invitation_message(UI_MESSAGE_Handle *handle, | |||
549 | MESSENGER_Application *app, | 549 | MESSENGER_Application *app, |
550 | struct GNUNET_CHAT_Invitation *invitation) | 550 | struct GNUNET_CHAT_Invitation *invitation) |
551 | { | 551 | { |
552 | GNUNET_assert((handle) && (app) && (invitation)); | 552 | g_assert((handle) && (app) && (invitation)); |
553 | 553 | ||
554 | enum GNUNET_GenericReturnValue accepted, rejected; | 554 | enum GNUNET_GenericReturnValue accepted, rejected; |
555 | accepted = GNUNET_CHAT_invitation_is_accepted(invitation); | 555 | accepted = GNUNET_CHAT_invitation_is_accepted(invitation); |
@@ -589,7 +589,7 @@ _update_file_message(UI_MESSAGE_Handle *handle, | |||
589 | MESSENGER_Application *app, | 589 | MESSENGER_Application *app, |
590 | struct GNUNET_CHAT_File *file) | 590 | struct GNUNET_CHAT_File *file) |
591 | { | 591 | { |
592 | GNUNET_assert((handle) && (app) && (file)); | 592 | g_assert((handle) && (app) && (file)); |
593 | 593 | ||
594 | const char *filename = GNUNET_CHAT_file_get_name(file); | 594 | const char *filename = GNUNET_CHAT_file_get_name(file); |
595 | 595 | ||
@@ -713,7 +713,7 @@ ui_message_update(UI_MESSAGE_Handle *handle, | |||
713 | MESSENGER_Application *app, | 713 | MESSENGER_Application *app, |
714 | const struct GNUNET_CHAT_Message *msg) | 714 | const struct GNUNET_CHAT_Message *msg) |
715 | { | 715 | { |
716 | GNUNET_assert((handle) && (app) && (msg)); | 716 | g_assert((handle) && (app) && (msg)); |
717 | 717 | ||
718 | struct GNUNET_CHAT_File *file = NULL; | 718 | struct GNUNET_CHAT_File *file = NULL; |
719 | struct GNUNET_CHAT_Invitation *invitation = NULL; | 719 | struct GNUNET_CHAT_Invitation *invitation = NULL; |
@@ -760,7 +760,7 @@ void | |||
760 | ui_message_set_contact(UI_MESSAGE_Handle *handle, | 760 | ui_message_set_contact(UI_MESSAGE_Handle *handle, |
761 | const struct GNUNET_CHAT_Contact *contact) | 761 | const struct GNUNET_CHAT_Contact *contact) |
762 | { | 762 | { |
763 | GNUNET_assert(handle); | 763 | g_assert(handle); |
764 | 764 | ||
765 | if (handle->contact) | 765 | if (handle->contact) |
766 | { | 766 | { |
@@ -780,7 +780,7 @@ ui_message_set_contact(UI_MESSAGE_Handle *handle, | |||
780 | void | 780 | void |
781 | ui_message_delete(UI_MESSAGE_Handle *handle) | 781 | ui_message_delete(UI_MESSAGE_Handle *handle) |
782 | { | 782 | { |
783 | GNUNET_assert(handle); | 783 | g_assert(handle); |
784 | 784 | ||
785 | ui_message_set_contact(handle, NULL); | 785 | ui_message_set_contact(handle, NULL); |
786 | 786 | ||
diff --git a/src/ui/message.h b/src/ui/message.h index 8b51952..60ee203 100644 --- a/src/ui/message.h +++ b/src/ui/message.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -101,7 +101,7 @@ typedef struct UI_MESSAGE_Handle | |||
101 | */ | 101 | */ |
102 | UI_MESSAGE_Handle* | 102 | UI_MESSAGE_Handle* |
103 | ui_message_new(MESSENGER_Application *app, | 103 | ui_message_new(MESSENGER_Application *app, |
104 | UI_MESSAGE_Type type); | 104 | UI_MESSAGE_Type type); |
105 | 105 | ||
106 | /** | 106 | /** |
107 | * Refreshes the visual state of the read receipt | 107 | * Refreshes the visual state of the read receipt |
@@ -123,8 +123,8 @@ ui_message_refresh(UI_MESSAGE_Handle *handle); | |||
123 | */ | 123 | */ |
124 | void | 124 | void |
125 | ui_message_update(UI_MESSAGE_Handle *handle, | 125 | ui_message_update(UI_MESSAGE_Handle *handle, |
126 | MESSENGER_Application *app, | 126 | MESSENGER_Application *app, |
127 | const struct GNUNET_CHAT_Message *message); | 127 | const struct GNUNET_CHAT_Message *message); |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * Sets the contact of a given message handle | 130 | * Sets the contact of a given message handle |
diff --git a/src/ui/messenger.c b/src/ui/messenger.c index fe47fcd..84c7ea3 100644 --- a/src/ui/messenger.c +++ b/src/ui/messenger.c | |||
@@ -42,6 +42,8 @@ | |||
42 | static gboolean | 42 | static gboolean |
43 | _flap_user_details_reveal_switch(gpointer user_data) | 43 | _flap_user_details_reveal_switch(gpointer user_data) |
44 | { | 44 | { |
45 | g_assert(user_data); | ||
46 | |||
45 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; | 47 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; |
46 | HdyFlap* flap = handle->flap_user_details; | 48 | HdyFlap* flap = handle->flap_user_details; |
47 | 49 | ||
@@ -60,6 +62,8 @@ static void | |||
60 | handle_user_details_via_button_click(UNUSED GtkButton* button, | 62 | handle_user_details_via_button_click(UNUSED GtkButton* button, |
61 | gpointer user_data) | 63 | gpointer user_data) |
62 | { | 64 | { |
65 | g_assert(user_data); | ||
66 | |||
63 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; | 67 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; |
64 | 68 | ||
65 | gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_search), FALSE); | 69 | gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_search), FALSE); |
@@ -74,6 +78,8 @@ static void | |||
74 | handle_lobby_button_click(UNUSED GtkButton* button, | 78 | handle_lobby_button_click(UNUSED GtkButton* button, |
75 | gpointer user_data) | 79 | gpointer user_data) |
76 | { | 80 | { |
81 | g_assert(user_data); | ||
82 | |||
77 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 83 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
78 | 84 | ||
79 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); | 85 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); |
@@ -87,6 +93,8 @@ static void | |||
87 | _switch_details_revealer_visibility(UI_MESSENGER_Handle *handle, | 93 | _switch_details_revealer_visibility(UI_MESSENGER_Handle *handle, |
88 | gboolean state) | 94 | gboolean state) |
89 | { | 95 | { |
96 | g_assert(handle); | ||
97 | |||
90 | GtkRevealer *revealer = handle->account_details_revealer; | 98 | GtkRevealer *revealer = handle->account_details_revealer; |
91 | GtkImage *symbol = handle->account_details_symbol; | 99 | GtkImage *symbol = handle->account_details_symbol; |
92 | 100 | ||
@@ -104,6 +112,8 @@ static void | |||
104 | handle_account_details_button_click(UNUSED GtkButton* button, | 112 | handle_account_details_button_click(UNUSED GtkButton* button, |
105 | gpointer user_data) | 113 | gpointer user_data) |
106 | { | 114 | { |
115 | g_assert(user_data); | ||
116 | |||
107 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; | 117 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; |
108 | 118 | ||
109 | GtkRevealer *revealer = handle->account_details_revealer; | 119 | GtkRevealer *revealer = handle->account_details_revealer; |
@@ -118,6 +128,8 @@ handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
118 | GtkListBoxRow* row, | 128 | GtkListBoxRow* row, |
119 | gpointer user_data) | 129 | gpointer user_data) |
120 | { | 130 | { |
131 | g_assert((row) && (user_data)); | ||
132 | |||
121 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 133 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
122 | 134 | ||
123 | if (row == app->ui.messenger.add_account_listbox_row) | 135 | if (row == app->ui.messenger.add_account_listbox_row) |
@@ -155,6 +167,8 @@ static void | |||
155 | handle_new_contact_button_click(UNUSED GtkButton* button, | 167 | handle_new_contact_button_click(UNUSED GtkButton* button, |
156 | gpointer user_data) | 168 | gpointer user_data) |
157 | { | 169 | { |
170 | g_assert(user_data); | ||
171 | |||
158 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 172 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
159 | 173 | ||
160 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); | 174 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); |
@@ -166,6 +180,8 @@ static void | |||
166 | handle_new_group_button_click(UNUSED GtkButton* button, | 180 | handle_new_group_button_click(UNUSED GtkButton* button, |
167 | gpointer user_data) | 181 | gpointer user_data) |
168 | { | 182 | { |
183 | g_assert(user_data); | ||
184 | |||
169 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 185 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
170 | 186 | ||
171 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); | 187 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); |
@@ -177,6 +193,8 @@ static void | |||
177 | handle_new_platform_button_click(UNUSED GtkButton* button, | 193 | handle_new_platform_button_click(UNUSED GtkButton* button, |
178 | gpointer user_data) | 194 | gpointer user_data) |
179 | { | 195 | { |
196 | g_assert(user_data); | ||
197 | |||
180 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 198 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
181 | 199 | ||
182 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); | 200 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); |
@@ -188,6 +206,8 @@ static void | |||
188 | handle_contacts_button_click(UNUSED GtkButton* button, | 206 | handle_contacts_button_click(UNUSED GtkButton* button, |
189 | gpointer user_data) | 207 | gpointer user_data) |
190 | { | 208 | { |
209 | g_assert(user_data); | ||
210 | |||
191 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 211 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
192 | 212 | ||
193 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); | 213 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); |
@@ -199,6 +219,8 @@ static void | |||
199 | handle_settings_button_click(UNUSED GtkButton* button, | 219 | handle_settings_button_click(UNUSED GtkButton* button, |
200 | gpointer user_data) | 220 | gpointer user_data) |
201 | { | 221 | { |
222 | g_assert(user_data); | ||
223 | |||
202 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 224 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
203 | 225 | ||
204 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); | 226 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); |
@@ -210,6 +232,8 @@ static void | |||
210 | handle_about_button_click(UNUSED GtkButton* button, | 232 | handle_about_button_click(UNUSED GtkButton* button, |
211 | gpointer user_data) | 233 | gpointer user_data) |
212 | { | 234 | { |
235 | g_assert(user_data); | ||
236 | |||
213 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 237 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
214 | 238 | ||
215 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); | 239 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); |
@@ -222,6 +246,8 @@ handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
222 | GtkListBoxRow* row, | 246 | GtkListBoxRow* row, |
223 | gpointer user_data) | 247 | gpointer user_data) |
224 | { | 248 | { |
249 | g_assert((row) && (user_data)); | ||
250 | |||
225 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 251 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
226 | 252 | ||
227 | if (!gtk_list_box_row_get_selectable(row)) | 253 | if (!gtk_list_box_row_get_selectable(row)) |
@@ -253,10 +279,11 @@ handle_chats_listbox_sort_func(GtkListBoxRow* row0, | |||
253 | GtkListBoxRow* row1, | 279 | GtkListBoxRow* row1, |
254 | gpointer user_data) | 280 | gpointer user_data) |
255 | { | 281 | { |
282 | g_assert((row0) && (row1) && (user_data)); | ||
283 | |||
256 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 284 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
257 | 285 | ||
258 | if ((!row0) || (!row1) || | 286 | if ((!gtk_list_box_row_get_selectable(row0)) || |
259 | (!gtk_list_box_row_get_selectable(row0)) || | ||
260 | (!gtk_list_box_row_get_selectable(row1))) | 287 | (!gtk_list_box_row_get_selectable(row1))) |
261 | return 0; | 288 | return 0; |
262 | 289 | ||
@@ -286,9 +313,11 @@ static gboolean | |||
286 | handle_chats_listbox_filter_func(GtkListBoxRow *row, | 313 | handle_chats_listbox_filter_func(GtkListBoxRow *row, |
287 | gpointer user_data) | 314 | gpointer user_data) |
288 | { | 315 | { |
316 | g_assert((row) && (user_data)); | ||
317 | |||
289 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 318 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
290 | 319 | ||
291 | if ((!row) || (!gtk_list_box_row_get_selectable(row)) || | 320 | if ((!gtk_list_box_row_get_selectable(row)) || |
292 | (gtk_list_box_row_is_selected(row))) | 321 | (gtk_list_box_row_is_selected(row))) |
293 | return TRUE; | 322 | return TRUE; |
294 | 323 | ||
@@ -318,6 +347,8 @@ static void | |||
318 | handle_chats_search_changed(UNUSED GtkSearchEntry *search, | 347 | handle_chats_search_changed(UNUSED GtkSearchEntry *search, |
319 | gpointer user_data) | 348 | gpointer user_data) |
320 | { | 349 | { |
350 | g_assert(user_data); | ||
351 | |||
321 | GtkListBox *listbox = GTK_LIST_BOX(user_data); | 352 | GtkListBox *listbox = GTK_LIST_BOX(user_data); |
322 | 353 | ||
323 | gtk_list_box_invalidate_filter(listbox); | 354 | gtk_list_box_invalidate_filter(listbox); |
@@ -327,6 +358,8 @@ static void | |||
327 | handle_main_window_destroy(UNUSED GtkWidget *window, | 358 | handle_main_window_destroy(UNUSED GtkWidget *window, |
328 | gpointer user_data) | 359 | gpointer user_data) |
329 | { | 360 | { |
361 | g_assert(user_data); | ||
362 | |||
330 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 363 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
331 | 364 | ||
332 | if (app->parent) | 365 | if (app->parent) |
@@ -344,6 +377,8 @@ void | |||
344 | ui_messenger_init(MESSENGER_Application *app, | 377 | ui_messenger_init(MESSENGER_Application *app, |
345 | UI_MESSENGER_Handle *handle) | 378 | UI_MESSENGER_Handle *handle) |
346 | { | 379 | { |
380 | g_assert((app) && (handle)); | ||
381 | |||
347 | memset(handle, 0, sizeof(*handle)); | 382 | memset(handle, 0, sizeof(*handle)); |
348 | handle->app = app; | 383 | handle->app = app; |
349 | 384 | ||
@@ -635,6 +670,8 @@ _messenger_iterate_accounts(void *cls, | |||
635 | const struct GNUNET_CHAT_Handle *handle, | 670 | const struct GNUNET_CHAT_Handle *handle, |
636 | struct GNUNET_CHAT_Account *account) | 671 | struct GNUNET_CHAT_Account *account) |
637 | { | 672 | { |
673 | g_assert((cls) && (handle) && (account)); | ||
674 | |||
638 | MESSENGER_Application *app = (MESSENGER_Application*) cls; | 675 | MESSENGER_Application *app = (MESSENGER_Application*) cls; |
639 | UI_MESSENGER_Handle *ui = &(app->ui.messenger); | 676 | UI_MESSENGER_Handle *ui = &(app->ui.messenger); |
640 | 677 | ||
@@ -663,10 +700,12 @@ static void | |||
663 | _clear_accounts_listbox(GtkWidget *widget, | 700 | _clear_accounts_listbox(GtkWidget *widget, |
664 | gpointer data) | 701 | gpointer data) |
665 | { | 702 | { |
703 | g_assert((widget) && (data)); | ||
704 | |||
666 | GtkListBoxRow *row = GTK_LIST_BOX_ROW(widget); | 705 | GtkListBoxRow *row = GTK_LIST_BOX_ROW(widget); |
667 | GtkListBox *listbox = GTK_LIST_BOX(data); | 706 | GtkListBox *listbox = GTK_LIST_BOX(data); |
668 | 707 | ||
669 | if ((!row) || (!listbox) || (!gtk_list_box_row_get_selectable(row))) | 708 | if (!gtk_list_box_row_get_selectable(row)) |
670 | return; | 709 | return; |
671 | 710 | ||
672 | gtk_container_remove( | 711 | gtk_container_remove( |
@@ -679,6 +718,8 @@ void | |||
679 | ui_messenger_refresh(MESSENGER_Application *app, | 718 | ui_messenger_refresh(MESSENGER_Application *app, |
680 | UI_MESSENGER_Handle *handle) | 719 | UI_MESSENGER_Handle *handle) |
681 | { | 720 | { |
721 | g_assert((app) && (handle)); | ||
722 | |||
682 | if (!(handle->accounts_listbox)) | 723 | if (!(handle->accounts_listbox)) |
683 | return; | 724 | return; |
684 | 725 | ||
@@ -699,6 +740,8 @@ gboolean | |||
699 | ui_messenger_is_context_active(UI_MESSENGER_Handle *handle, | 740 | ui_messenger_is_context_active(UI_MESSENGER_Handle *handle, |
700 | struct GNUNET_CHAT_Context *context) | 741 | struct GNUNET_CHAT_Context *context) |
701 | { | 742 | { |
743 | g_assert((handle) && (context)); | ||
744 | |||
702 | if (!gtk_window_is_active(GTK_WINDOW(handle->main_window))) | 745 | if (!gtk_window_is_active(GTK_WINDOW(handle->main_window))) |
703 | return FALSE; | 746 | return FALSE; |
704 | 747 | ||
@@ -720,6 +763,8 @@ ui_messenger_is_context_active(UI_MESSENGER_Handle *handle, | |||
720 | void | 763 | void |
721 | ui_messenger_cleanup(UI_MESSENGER_Handle *handle) | 764 | ui_messenger_cleanup(UI_MESSENGER_Handle *handle) |
722 | { | 765 | { |
766 | g_assert(handle); | ||
767 | |||
723 | g_object_unref(handle->builder); | 768 | g_object_unref(handle->builder); |
724 | 769 | ||
725 | if (handle->chat_entries) | 770 | if (handle->chat_entries) |
diff --git a/src/ui/messenger.h b/src/ui/messenger.h index 5088947..e702e20 100644 --- a/src/ui/messenger.h +++ b/src/ui/messenger.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -86,7 +86,7 @@ typedef struct UI_MESSENGER_Handle | |||
86 | */ | 86 | */ |
87 | void | 87 | void |
88 | ui_messenger_init(MESSENGER_Application *app, | 88 | ui_messenger_init(MESSENGER_Application *app, |
89 | UI_MESSENGER_Handle *handle); | 89 | UI_MESSENGER_Handle *handle); |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * Refreshes a given messenger window handle with | 92 | * Refreshes a given messenger window handle with |
@@ -98,7 +98,7 @@ ui_messenger_init(MESSENGER_Application *app, | |||
98 | */ | 98 | */ |
99 | void | 99 | void |
100 | ui_messenger_refresh(MESSENGER_Application *app, | 100 | ui_messenger_refresh(MESSENGER_Application *app, |
101 | UI_MESSENGER_Handle *handle); | 101 | UI_MESSENGER_Handle *handle); |
102 | 102 | ||
103 | /** | 103 | /** |
104 | * Returns whether a certain chat context is currently | 104 | * Returns whether a certain chat context is currently |
@@ -110,7 +110,7 @@ ui_messenger_refresh(MESSENGER_Application *app, | |||
110 | */ | 110 | */ |
111 | gboolean | 111 | gboolean |
112 | ui_messenger_is_context_active(UI_MESSENGER_Handle *handle, | 112 | ui_messenger_is_context_active(UI_MESSENGER_Handle *handle, |
113 | struct GNUNET_CHAT_Context *context); | 113 | struct GNUNET_CHAT_Context *context); |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * Cleans up the allocated resources and resets the | 116 | * Cleans up the allocated resources and resets the |
diff --git a/src/ui/new_account.c b/src/ui/new_account.c index 452000b..997d482 100644 --- a/src/ui/new_account.c +++ b/src/ui/new_account.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -29,6 +29,8 @@ | |||
29 | static gboolean | 29 | static gboolean |
30 | _show_messenger_main_window(gpointer user_data) | 30 | _show_messenger_main_window(gpointer user_data) |
31 | { | 31 | { |
32 | g_assert(user_data); | ||
33 | |||
32 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 34 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
33 | 35 | ||
34 | gtk_widget_show(GTK_WIDGET(app->ui.messenger.main_window)); | 36 | gtk_widget_show(GTK_WIDGET(app->ui.messenger.main_window)); |
@@ -36,8 +38,11 @@ _show_messenger_main_window(gpointer user_data) | |||
36 | } | 38 | } |
37 | 39 | ||
38 | static void | 40 | static void |
39 | _open_new_account(GtkEntry *entry, MESSENGER_Application *app) | 41 | _open_new_account(GtkEntry *entry, |
42 | MESSENGER_Application *app) | ||
40 | { | 43 | { |
44 | g_assert((entry) && (app)); | ||
45 | |||
41 | const gchar *name = gtk_entry_get_text(entry); | 46 | const gchar *name = gtk_entry_get_text(entry); |
42 | 47 | ||
43 | if (GNUNET_OK != GNUNET_CHAT_account_create(app->chat.messenger.handle, name)) | 48 | if (GNUNET_OK != GNUNET_CHAT_account_create(app->chat.messenger.handle, name)) |
@@ -58,8 +63,10 @@ _open_new_account(GtkEntry *entry, MESSENGER_Application *app) | |||
58 | 63 | ||
59 | static void | 64 | static void |
60 | handle_account_entry_changed(GtkEditable *editable, | 65 | handle_account_entry_changed(GtkEditable *editable, |
61 | gpointer user_data) | 66 | gpointer user_data) |
62 | { | 67 | { |
68 | g_assert((editable) && (user_data)); | ||
69 | |||
63 | HdyAvatar *avatar = HDY_AVATAR(user_data); | 70 | HdyAvatar *avatar = HDY_AVATAR(user_data); |
64 | GtkEntry *entry = GTK_ENTRY(editable); | 71 | GtkEntry *entry = GTK_ENTRY(editable); |
65 | 72 | ||
@@ -70,8 +77,10 @@ handle_account_entry_changed(GtkEditable *editable, | |||
70 | 77 | ||
71 | static void | 78 | static void |
72 | handle_account_entry_activate(UNUSED GtkEntry *entry, | 79 | handle_account_entry_activate(UNUSED GtkEntry *entry, |
73 | gpointer user_data) | 80 | gpointer user_data) |
74 | { | 81 | { |
82 | g_assert(user_data); | ||
83 | |||
75 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 84 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
76 | 85 | ||
77 | _open_new_account(app->ui.new_account.account_entry, app); | 86 | _open_new_account(app->ui.new_account.account_entry, app); |
@@ -81,16 +90,20 @@ handle_account_entry_activate(UNUSED GtkEntry *entry, | |||
81 | 90 | ||
82 | static void | 91 | static void |
83 | handle_cancel_button_click(UNUSED GtkButton *button, | 92 | handle_cancel_button_click(UNUSED GtkButton *button, |
84 | gpointer user_data) | 93 | gpointer user_data) |
85 | { | 94 | { |
95 | g_assert(user_data); | ||
96 | |||
86 | GtkDialog *dialog = GTK_DIALOG(user_data); | 97 | GtkDialog *dialog = GTK_DIALOG(user_data); |
87 | gtk_window_close(GTK_WINDOW(dialog)); | 98 | gtk_window_close(GTK_WINDOW(dialog)); |
88 | } | 99 | } |
89 | 100 | ||
90 | static void | 101 | static void |
91 | handle_confirm_button_click(UNUSED GtkButton *button, | 102 | handle_confirm_button_click(UNUSED GtkButton *button, |
92 | gpointer user_data) | 103 | gpointer user_data) |
93 | { | 104 | { |
105 | g_assert(user_data); | ||
106 | |||
94 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 107 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
95 | 108 | ||
96 | _open_new_account(app->ui.new_account.account_entry, app); | 109 | _open_new_account(app->ui.new_account.account_entry, app); |
@@ -100,8 +113,10 @@ handle_confirm_button_click(UNUSED GtkButton *button, | |||
100 | 113 | ||
101 | static void | 114 | static void |
102 | handle_dialog_destroy(UNUSED GtkWidget *window, | 115 | handle_dialog_destroy(UNUSED GtkWidget *window, |
103 | gpointer user_data) | 116 | gpointer user_data) |
104 | { | 117 | { |
118 | g_assert(user_data); | ||
119 | |||
105 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 120 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
106 | 121 | ||
107 | ui_new_account_dialog_cleanup(&(app->ui.new_account)); | 122 | ui_new_account_dialog_cleanup(&(app->ui.new_account)); |
@@ -113,82 +128,86 @@ handle_dialog_destroy(UNUSED GtkWidget *window, | |||
113 | 128 | ||
114 | void | 129 | void |
115 | ui_new_account_dialog_init(MESSENGER_Application *app, | 130 | ui_new_account_dialog_init(MESSENGER_Application *app, |
116 | UI_NEW_ACCOUNT_Handle *handle) | 131 | UI_NEW_ACCOUNT_Handle *handle) |
117 | { | 132 | { |
133 | g_assert((app) && (handle)); | ||
134 | |||
118 | handle->show_queued = 0; | 135 | handle->show_queued = 0; |
119 | 136 | ||
120 | handle->builder = gtk_builder_new_from_resource( | 137 | handle->builder = gtk_builder_new_from_resource( |
121 | application_get_resource_path(app, "ui/new_account.ui") | 138 | application_get_resource_path(app, "ui/new_account.ui") |
122 | ); | 139 | ); |
123 | 140 | ||
124 | handle->dialog = GTK_DIALOG( | 141 | handle->dialog = GTK_DIALOG( |
125 | gtk_builder_get_object(handle->builder, "new_account_dialog") | 142 | gtk_builder_get_object(handle->builder, "new_account_dialog") |
126 | ); | 143 | ); |
127 | 144 | ||
128 | gtk_window_set_transient_for( | 145 | gtk_window_set_transient_for( |
129 | GTK_WINDOW(handle->dialog), | 146 | GTK_WINDOW(handle->dialog), |
130 | GTK_WINDOW(app->ui.messenger.main_window) | 147 | GTK_WINDOW(app->ui.messenger.main_window) |
131 | ); | 148 | ); |
132 | 149 | ||
133 | handle->account_avatar = HDY_AVATAR( | 150 | handle->account_avatar = HDY_AVATAR( |
134 | gtk_builder_get_object(handle->builder, "account_avatar") | 151 | gtk_builder_get_object(handle->builder, "account_avatar") |
135 | ); | 152 | ); |
136 | 153 | ||
137 | handle->account_avatar_file = GTK_FILE_CHOOSER_BUTTON( | 154 | handle->account_avatar_file = GTK_FILE_CHOOSER_BUTTON( |
138 | gtk_builder_get_object(handle->builder, "account_avatar_file") | 155 | gtk_builder_get_object(handle->builder, "account_avatar_file") |
139 | ); | 156 | ); |
140 | 157 | ||
141 | handle->account_entry = GTK_ENTRY( | 158 | handle->account_entry = GTK_ENTRY( |
142 | gtk_builder_get_object(handle->builder, "account_entry") | 159 | gtk_builder_get_object(handle->builder, "account_entry") |
143 | ); | 160 | ); |
144 | 161 | ||
145 | g_signal_connect( | 162 | g_signal_connect( |
146 | handle->account_entry, | 163 | handle->account_entry, |
147 | "changed", | 164 | "changed", |
148 | G_CALLBACK(handle_account_entry_changed), | 165 | G_CALLBACK(handle_account_entry_changed), |
149 | handle->account_avatar | 166 | handle->account_avatar |
150 | ); | 167 | ); |
151 | 168 | ||
152 | g_signal_connect( | 169 | g_signal_connect( |
153 | handle->account_entry, | 170 | handle->account_entry, |
154 | "activate", | 171 | "activate", |
155 | G_CALLBACK(handle_account_entry_activate), | 172 | G_CALLBACK(handle_account_entry_activate), |
156 | app | 173 | app |
157 | ); | 174 | ); |
158 | 175 | ||
159 | handle->cancel_button = GTK_BUTTON( | 176 | handle->cancel_button = GTK_BUTTON( |
160 | gtk_builder_get_object(handle->builder, "cancel_button") | 177 | gtk_builder_get_object(handle->builder, "cancel_button") |
161 | ); | 178 | ); |
162 | 179 | ||
163 | g_signal_connect( | 180 | g_signal_connect( |
164 | handle->cancel_button, | 181 | handle->cancel_button, |
165 | "clicked", | 182 | "clicked", |
166 | G_CALLBACK(handle_cancel_button_click), | 183 | G_CALLBACK(handle_cancel_button_click), |
167 | handle->dialog | 184 | handle->dialog |
168 | ); | 185 | ); |
169 | 186 | ||
170 | handle->confirm_button = GTK_BUTTON( | 187 | handle->confirm_button = GTK_BUTTON( |
171 | gtk_builder_get_object(handle->builder, "confirm_button") | 188 | gtk_builder_get_object(handle->builder, "confirm_button") |
172 | ); | 189 | ); |
173 | 190 | ||
174 | g_signal_connect( | 191 | g_signal_connect( |
175 | handle->confirm_button, | 192 | handle->confirm_button, |
176 | "clicked", | 193 | "clicked", |
177 | G_CALLBACK(handle_confirm_button_click), | 194 | G_CALLBACK(handle_confirm_button_click), |
178 | app | 195 | app |
179 | ); | 196 | ); |
180 | 197 | ||
181 | g_signal_connect( | 198 | g_signal_connect( |
182 | handle->dialog, | 199 | handle->dialog, |
183 | "destroy", | 200 | "destroy", |
184 | G_CALLBACK(handle_dialog_destroy), | 201 | G_CALLBACK(handle_dialog_destroy), |
185 | app | 202 | app |
186 | ); | 203 | ); |
187 | } | 204 | } |
188 | 205 | ||
189 | void | 206 | void |
190 | ui_new_account_dialog_cleanup(UI_NEW_ACCOUNT_Handle *handle) | 207 | ui_new_account_dialog_cleanup(UI_NEW_ACCOUNT_Handle *handle) |
191 | { | 208 | { |
209 | g_assert(handle); | ||
210 | |||
192 | g_object_unref(handle->builder); | 211 | g_object_unref(handle->builder); |
193 | 212 | ||
194 | guint show = handle->show_queued; | 213 | guint show = handle->show_queued; |
diff --git a/src/ui/new_account.h b/src/ui/new_account.h index 917bf24..749d44c 100644 --- a/src/ui/new_account.h +++ b/src/ui/new_account.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -52,7 +52,7 @@ typedef struct UI_NEW_ACCOUNT_Handle | |||
52 | */ | 52 | */ |
53 | void | 53 | void |
54 | ui_new_account_dialog_init(MESSENGER_Application *app, | 54 | ui_new_account_dialog_init(MESSENGER_Application *app, |
55 | UI_NEW_ACCOUNT_Handle *handle); | 55 | UI_NEW_ACCOUNT_Handle *handle); |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Cleans up the allocated resources and resets the | 58 | * Cleans up the allocated resources and resets the |
diff --git a/src/ui/new_contact.c b/src/ui/new_contact.c index 61eb121..8b73f89 100644 --- a/src/ui/new_contact.c +++ b/src/ui/new_contact.c | |||
@@ -33,6 +33,8 @@ static void | |||
33 | handle_cancel_button_click(UNUSED GtkButton *button, | 33 | handle_cancel_button_click(UNUSED GtkButton *button, |
34 | gpointer user_data) | 34 | gpointer user_data) |
35 | { | 35 | { |
36 | g_assert(user_data); | ||
37 | |||
36 | GtkDialog *dialog = GTK_DIALOG(user_data); | 38 | GtkDialog *dialog = GTK_DIALOG(user_data); |
37 | gtk_window_close(GTK_WINDOW(dialog)); | 39 | gtk_window_close(GTK_WINDOW(dialog)); |
38 | } | 40 | } |
@@ -41,6 +43,8 @@ static void | |||
41 | handle_confirm_button_click(UNUSED GtkButton *button, | 43 | handle_confirm_button_click(UNUSED GtkButton *button, |
42 | gpointer user_data) | 44 | gpointer user_data) |
43 | { | 45 | { |
46 | g_assert(user_data); | ||
47 | |||
44 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 48 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
45 | 49 | ||
46 | const gint id_length = gtk_entry_get_text_length(app->ui.new_contact.id_entry); | 50 | const gint id_length = gtk_entry_get_text_length(app->ui.new_contact.id_entry); |
@@ -72,6 +76,8 @@ static void | |||
72 | handle_dialog_destroy(UNUSED GtkWidget *window, | 76 | handle_dialog_destroy(UNUSED GtkWidget *window, |
73 | gpointer user_data) | 77 | gpointer user_data) |
74 | { | 78 | { |
79 | g_assert(user_data); | ||
80 | |||
75 | ui_new_contact_dialog_cleanup((UI_NEW_CONTACT_Handle*) user_data); | 81 | ui_new_contact_dialog_cleanup((UI_NEW_CONTACT_Handle*) user_data); |
76 | } | 82 | } |
77 | 83 | ||
@@ -79,6 +85,8 @@ static void | |||
79 | handle_camera_combo_box_change(GtkComboBox *widget, | 85 | handle_camera_combo_box_change(GtkComboBox *widget, |
80 | gpointer user_data) | 86 | gpointer user_data) |
81 | { | 87 | { |
88 | g_assert((widget) && (user_data)); | ||
89 | |||
82 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) user_data; | 90 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) user_data; |
83 | gchar *name = NULL; | 91 | gchar *name = NULL; |
84 | 92 | ||
@@ -116,7 +124,7 @@ static void | |||
116 | _disable_video_processing(UI_NEW_CONTACT_Handle *handle, | 124 | _disable_video_processing(UI_NEW_CONTACT_Handle *handle, |
117 | gboolean drop_pipeline) | 125 | gboolean drop_pipeline) |
118 | { | 126 | { |
119 | GNUNET_assert(handle); | 127 | g_assert(handle); |
120 | 128 | ||
121 | if (handle->preview_stack) | 129 | if (handle->preview_stack) |
122 | goto skip_stack; | 130 | goto skip_stack; |
@@ -138,6 +146,8 @@ msg_error_cb(UNUSED GstBus *bus, | |||
138 | GstMessage *msg, | 146 | GstMessage *msg, |
139 | gpointer data) | 147 | gpointer data) |
140 | { | 148 | { |
149 | g_assert((msg) && (data)); | ||
150 | |||
141 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) data; | 151 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) data; |
142 | 152 | ||
143 | GError* error; | 153 | GError* error; |
@@ -158,6 +168,8 @@ msg_eos_cb(UNUSED GstBus *bus, | |||
158 | UNUSED GstMessage *msg, | 168 | UNUSED GstMessage *msg, |
159 | gpointer data) | 169 | gpointer data) |
160 | { | 170 | { |
171 | g_assert(data); | ||
172 | |||
161 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) data; | 173 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) data; |
162 | 174 | ||
163 | if (GST_MESSAGE_SRC(msg) == GST_OBJECT(handle->pipeline)) | 175 | if (GST_MESSAGE_SRC(msg) == GST_OBJECT(handle->pipeline)) |
@@ -169,6 +181,8 @@ msg_state_changed_cb(UNUSED GstBus *bus, | |||
169 | GstMessage *msg, | 181 | GstMessage *msg, |
170 | gpointer data) | 182 | gpointer data) |
171 | { | 183 | { |
184 | g_assert((msg) && (data)); | ||
185 | |||
172 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) data; | 186 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) data; |
173 | 187 | ||
174 | GstState old_state, new_state, pending_state; | 188 | GstState old_state, new_state, pending_state; |
@@ -192,6 +206,8 @@ msg_barcode_cb(UNUSED GstBus *bus, | |||
192 | GstMessage *msg, | 206 | GstMessage *msg, |
193 | gpointer data) | 207 | gpointer data) |
194 | { | 208 | { |
209 | g_assert((msg) && (data)); | ||
210 | |||
195 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) data; | 211 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) data; |
196 | GstMessageType msg_type = GST_MESSAGE_TYPE(msg); | 212 | GstMessageType msg_type = GST_MESSAGE_TYPE(msg); |
197 | 213 | ||
@@ -217,6 +233,8 @@ msg_barcode_cb(UNUSED GstBus *bus, | |||
217 | static void | 233 | static void |
218 | _setup_gst_pipeline(UI_NEW_CONTACT_Handle *handle) | 234 | _setup_gst_pipeline(UI_NEW_CONTACT_Handle *handle) |
219 | { | 235 | { |
236 | g_assert(handle); | ||
237 | |||
220 | handle->pipeline = gst_parse_launch( | 238 | handle->pipeline = gst_parse_launch( |
221 | "pipewiresrc name=source ! videoconvert ! zbar name=scanner" | 239 | "pipewiresrc name=source ! videoconvert ! zbar name=scanner" |
222 | " ! videoconvert ! aspectratiocrop aspect-ratio=1/1" | 240 | " ! videoconvert ! aspectratiocrop aspect-ratio=1/1" |
@@ -281,6 +299,8 @@ _setup_gst_pipeline(UI_NEW_CONTACT_Handle *handle) | |||
281 | static void* | 299 | static void* |
282 | _ui_new_contact_video_thread(void *args) | 300 | _ui_new_contact_video_thread(void *args) |
283 | { | 301 | { |
302 | g_assert(args); | ||
303 | |||
284 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) args; | 304 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) args; |
285 | 305 | ||
286 | if (!(handle->pipeline)) | 306 | if (!(handle->pipeline)) |
@@ -301,6 +321,8 @@ static int | |||
301 | iterate_global(void *obj, | 321 | iterate_global(void *obj, |
302 | void *data) | 322 | void *data) |
303 | { | 323 | { |
324 | g_assert(data); | ||
325 | |||
304 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) data; | 326 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) data; |
305 | struct pw_properties *properties = (struct pw_properties*) obj; | 327 | struct pw_properties *properties = (struct pw_properties*) obj; |
306 | 328 | ||
@@ -356,6 +378,8 @@ _init_camera_pipeline(MESSENGER_Application *app, | |||
356 | UI_NEW_CONTACT_Handle *handle, | 378 | UI_NEW_CONTACT_Handle *handle, |
357 | gboolean access) | 379 | gboolean access) |
358 | { | 380 | { |
381 | g_assert((app) && (handle)); | ||
382 | |||
359 | handle->camera_count = 0; | 383 | handle->camera_count = 0; |
360 | 384 | ||
361 | if ((app->portal) && ((access) || xdp_portal_is_camera_present(app->portal))) | 385 | if ((app->portal) && ((access) || xdp_portal_is_camera_present(app->portal))) |
@@ -384,9 +408,11 @@ _init_camera_pipeline(MESSENGER_Application *app, | |||
384 | 408 | ||
385 | static void | 409 | static void |
386 | _request_camera_callback(GObject *source_object, | 410 | _request_camera_callback(GObject *source_object, |
387 | GAsyncResult *result, | 411 | GAsyncResult *result, |
388 | gpointer user_data) | 412 | gpointer user_data) |
389 | { | 413 | { |
414 | g_assert((source_object) && (result) && (user_data)); | ||
415 | |||
390 | XdpPortal *portal = (XdpPortal*) source_object; | 416 | XdpPortal *portal = (XdpPortal*) source_object; |
391 | MESSENGER_Request *request = (MESSENGER_Request*) user_data; | 417 | MESSENGER_Request *request = (MESSENGER_Request*) user_data; |
392 | 418 | ||
@@ -414,7 +440,7 @@ void | |||
414 | ui_new_contact_dialog_init(MESSENGER_Application *app, | 440 | ui_new_contact_dialog_init(MESSENGER_Application *app, |
415 | UI_NEW_CONTACT_Handle *handle) | 441 | UI_NEW_CONTACT_Handle *handle) |
416 | { | 442 | { |
417 | GNUNET_assert((app) && (handle)); | 443 | g_assert((app) && (handle)); |
418 | 444 | ||
419 | handle->camera_count = 0; | 445 | handle->camera_count = 0; |
420 | 446 | ||
@@ -545,7 +571,7 @@ ui_new_contact_dialog_init(MESSENGER_Application *app, | |||
545 | void | 571 | void |
546 | ui_new_contact_dialog_cleanup(UI_NEW_CONTACT_Handle *handle) | 572 | ui_new_contact_dialog_cleanup(UI_NEW_CONTACT_Handle *handle) |
547 | { | 573 | { |
548 | GNUNET_assert(handle); | 574 | g_assert(handle); |
549 | 575 | ||
550 | pthread_join(handle->video_tid, NULL); | 576 | pthread_join(handle->video_tid, NULL); |
551 | 577 | ||
diff --git a/src/ui/new_contact.h b/src/ui/new_contact.h index 1dbb755..52c6ba9 100644 --- a/src/ui/new_contact.h +++ b/src/ui/new_contact.h | |||
@@ -71,7 +71,7 @@ typedef struct UI_NEW_CONTACT_Handle | |||
71 | */ | 71 | */ |
72 | void | 72 | void |
73 | ui_new_contact_dialog_init(MESSENGER_Application *app, | 73 | ui_new_contact_dialog_init(MESSENGER_Application *app, |
74 | UI_NEW_CONTACT_Handle *handle); | 74 | UI_NEW_CONTACT_Handle *handle); |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * Cleans up the allocated resources and resets the | 77 | * Cleans up the allocated resources and resets the |
diff --git a/src/ui/new_group.c b/src/ui/new_group.c index bb56b6a..c4b6fe3 100644 --- a/src/ui/new_group.c +++ b/src/ui/new_group.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -29,9 +29,11 @@ | |||
29 | 29 | ||
30 | static void | 30 | static void |
31 | _open_new_group(GtkEntry *entry, | 31 | _open_new_group(GtkEntry *entry, |
32 | GtkListBox *listbox, | 32 | GtkListBox *listbox, |
33 | MESSENGER_Application *app) | 33 | MESSENGER_Application *app) |
34 | { | 34 | { |
35 | g_assert((entry) && (listbox) && (app)); | ||
36 | |||
35 | const gchar *name = gtk_entry_get_text(entry); | 37 | const gchar *name = gtk_entry_get_text(entry); |
36 | 38 | ||
37 | struct GNUNET_CHAT_Group *group = GNUNET_CHAT_group_create( | 39 | struct GNUNET_CHAT_Group *group = GNUNET_CHAT_group_create( |
@@ -67,8 +69,10 @@ _open_new_group(GtkEntry *entry, | |||
67 | 69 | ||
68 | static void | 70 | static void |
69 | handle_group_entry_changed(GtkEditable *editable, | 71 | handle_group_entry_changed(GtkEditable *editable, |
70 | gpointer user_data) | 72 | gpointer user_data) |
71 | { | 73 | { |
74 | g_assert((editable) && (user_data)); | ||
75 | |||
72 | HdyAvatar *avatar = HDY_AVATAR(user_data); | 76 | HdyAvatar *avatar = HDY_AVATAR(user_data); |
73 | GtkEntry *entry = GTK_ENTRY(editable); | 77 | GtkEntry *entry = GTK_ENTRY(editable); |
74 | 78 | ||
@@ -80,6 +84,8 @@ handle_group_entry_changed(GtkEditable *editable, | |||
80 | static void | 84 | static void |
81 | _go_page_details(UI_NEW_GROUP_Handle *handle) | 85 | _go_page_details(UI_NEW_GROUP_Handle *handle) |
82 | { | 86 | { |
87 | g_assert(handle); | ||
88 | |||
83 | gtk_stack_set_visible_child(handle->stack, handle->details_box); | 89 | gtk_stack_set_visible_child(handle->stack, handle->details_box); |
84 | 90 | ||
85 | gtk_widget_hide(GTK_WIDGET(handle->previous_button)); | 91 | gtk_widget_hide(GTK_WIDGET(handle->previous_button)); |
@@ -92,6 +98,8 @@ _go_page_details(UI_NEW_GROUP_Handle *handle) | |||
92 | static void | 98 | static void |
93 | _go_page_contacts(UI_NEW_GROUP_Handle *handle) | 99 | _go_page_contacts(UI_NEW_GROUP_Handle *handle) |
94 | { | 100 | { |
101 | g_assert(handle); | ||
102 | |||
95 | gtk_stack_set_visible_child(handle->stack, handle->contacts_box); | 103 | gtk_stack_set_visible_child(handle->stack, handle->contacts_box); |
96 | 104 | ||
97 | gtk_widget_hide(GTK_WIDGET(handle->cancel_button)); | 105 | gtk_widget_hide(GTK_WIDGET(handle->cancel_button)); |
@@ -103,8 +111,10 @@ _go_page_contacts(UI_NEW_GROUP_Handle *handle) | |||
103 | 111 | ||
104 | static void | 112 | static void |
105 | handle_group_entry_activate(UNUSED GtkEntry *entry, | 113 | handle_group_entry_activate(UNUSED GtkEntry *entry, |
106 | gpointer user_data) | 114 | gpointer user_data) |
107 | { | 115 | { |
116 | g_assert(user_data); | ||
117 | |||
108 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 118 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
109 | 119 | ||
110 | _go_page_contacts(&(app->ui.new_group)); | 120 | _go_page_contacts(&(app->ui.new_group)); |
@@ -112,30 +122,38 @@ handle_group_entry_activate(UNUSED GtkEntry *entry, | |||
112 | 122 | ||
113 | static void | 123 | static void |
114 | handle_cancel_button_click(UNUSED GtkButton *button, | 124 | handle_cancel_button_click(UNUSED GtkButton *button, |
115 | gpointer user_data) | 125 | gpointer user_data) |
116 | { | 126 | { |
127 | g_assert(user_data); | ||
128 | |||
117 | GtkDialog *dialog = GTK_DIALOG(user_data); | 129 | GtkDialog *dialog = GTK_DIALOG(user_data); |
118 | gtk_window_close(GTK_WINDOW(dialog)); | 130 | gtk_window_close(GTK_WINDOW(dialog)); |
119 | } | 131 | } |
120 | 132 | ||
121 | static void | 133 | static void |
122 | handle_previous_button_click(UNUSED GtkButton *button, | 134 | handle_previous_button_click(UNUSED GtkButton *button, |
123 | gpointer user_data) | 135 | gpointer user_data) |
124 | { | 136 | { |
137 | g_assert(user_data); | ||
138 | |||
125 | _go_page_details((UI_NEW_GROUP_Handle*) user_data); | 139 | _go_page_details((UI_NEW_GROUP_Handle*) user_data); |
126 | } | 140 | } |
127 | 141 | ||
128 | static void | 142 | static void |
129 | handle_next_button_click(UNUSED GtkButton *button, | 143 | handle_next_button_click(UNUSED GtkButton *button, |
130 | gpointer user_data) | 144 | gpointer user_data) |
131 | { | 145 | { |
146 | g_assert(user_data); | ||
147 | |||
132 | _go_page_contacts((UI_NEW_GROUP_Handle*) user_data); | 148 | _go_page_contacts((UI_NEW_GROUP_Handle*) user_data); |
133 | } | 149 | } |
134 | 150 | ||
135 | static void | 151 | static void |
136 | handle_confirm_button_click(UNUSED GtkButton *button, | 152 | handle_confirm_button_click(UNUSED GtkButton *button, |
137 | gpointer user_data) | 153 | gpointer user_data) |
138 | { | 154 | { |
155 | g_assert(user_data); | ||
156 | |||
139 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 157 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
140 | 158 | ||
141 | _open_new_group( | 159 | _open_new_group( |
@@ -149,16 +167,20 @@ handle_confirm_button_click(UNUSED GtkButton *button, | |||
149 | 167 | ||
150 | static void | 168 | static void |
151 | handle_dialog_destroy(UNUSED GtkWidget *window, | 169 | handle_dialog_destroy(UNUSED GtkWidget *window, |
152 | gpointer user_data) | 170 | gpointer user_data) |
153 | { | 171 | { |
172 | g_assert(user_data); | ||
173 | |||
154 | ui_new_group_dialog_cleanup((UI_NEW_GROUP_Handle*) user_data); | 174 | ui_new_group_dialog_cleanup((UI_NEW_GROUP_Handle*) user_data); |
155 | } | 175 | } |
156 | 176 | ||
157 | static int | 177 | static int |
158 | _iterate_contacts(void *cls, | 178 | _iterate_contacts(void *cls, |
159 | UNUSED struct GNUNET_CHAT_Handle *handle, | 179 | UNUSED struct GNUNET_CHAT_Handle *handle, |
160 | struct GNUNET_CHAT_Contact *contact) | 180 | struct GNUNET_CHAT_Contact *contact) |
161 | { | 181 | { |
182 | g_assert((cls) && (contact)); | ||
183 | |||
162 | if (GNUNET_YES == GNUNET_CHAT_contact_is_owned(contact)) | 184 | if (GNUNET_YES == GNUNET_CHAT_contact_is_owned(contact)) |
163 | return GNUNET_YES; | 185 | return GNUNET_YES; |
164 | 186 | ||
@@ -168,16 +190,16 @@ _iterate_contacts(void *cls, | |||
168 | ui_contact_entry_set_contact(entry, contact); | 190 | ui_contact_entry_set_contact(entry, contact); |
169 | 191 | ||
170 | gtk_list_box_prepend( | 192 | gtk_list_box_prepend( |
171 | app->ui.new_group.contacts_listbox, | 193 | app->ui.new_group.contacts_listbox, |
172 | entry->entry_box | 194 | entry->entry_box |
173 | ); | 195 | ); |
174 | 196 | ||
175 | GtkWidget *row = gtk_widget_get_parent(entry->entry_box); | 197 | GtkWidget *row = gtk_widget_get_parent(entry->entry_box); |
176 | g_object_set_qdata(G_OBJECT(row), app->quarks.data, contact); | 198 | g_object_set_qdata(G_OBJECT(row), app->quarks.data, contact); |
177 | 199 | ||
178 | app->ui.new_group.contact_entries = g_list_append( | 200 | app->ui.new_group.contact_entries = g_list_append( |
179 | app->ui.new_group.contact_entries, | 201 | app->ui.new_group.contact_entries, |
180 | entry | 202 | entry |
181 | ); | 203 | ); |
182 | 204 | ||
183 | return GNUNET_YES; | 205 | return GNUNET_YES; |
@@ -185,130 +207,134 @@ _iterate_contacts(void *cls, | |||
185 | 207 | ||
186 | void | 208 | void |
187 | ui_new_group_dialog_init(MESSENGER_Application *app, | 209 | ui_new_group_dialog_init(MESSENGER_Application *app, |
188 | UI_NEW_GROUP_Handle *handle) | 210 | UI_NEW_GROUP_Handle *handle) |
189 | { | 211 | { |
212 | g_assert((app) && (handle)); | ||
213 | |||
190 | handle->contact_entries = NULL; | 214 | handle->contact_entries = NULL; |
191 | 215 | ||
192 | handle->builder = gtk_builder_new_from_resource( | 216 | handle->builder = gtk_builder_new_from_resource( |
193 | application_get_resource_path(app, "ui/new_group.ui") | 217 | application_get_resource_path(app, "ui/new_group.ui") |
194 | ); | 218 | ); |
195 | 219 | ||
196 | handle->dialog = GTK_DIALOG( | 220 | handle->dialog = GTK_DIALOG( |
197 | gtk_builder_get_object(handle->builder, "new_group_dialog") | 221 | gtk_builder_get_object(handle->builder, "new_group_dialog") |
198 | ); | 222 | ); |
199 | 223 | ||
200 | gtk_window_set_transient_for( | 224 | gtk_window_set_transient_for( |
201 | GTK_WINDOW(handle->dialog), | 225 | GTK_WINDOW(handle->dialog), |
202 | GTK_WINDOW(app->ui.messenger.main_window) | 226 | GTK_WINDOW(app->ui.messenger.main_window) |
203 | ); | 227 | ); |
204 | 228 | ||
205 | handle->stack = GTK_STACK( | 229 | handle->stack = GTK_STACK( |
206 | gtk_builder_get_object(handle->builder, "new_group_stack") | 230 | gtk_builder_get_object(handle->builder, "new_group_stack") |
207 | ); | 231 | ); |
208 | 232 | ||
209 | handle->details_box = GTK_WIDGET( | 233 | handle->details_box = GTK_WIDGET( |
210 | gtk_builder_get_object(handle->builder, "details_box") | 234 | gtk_builder_get_object(handle->builder, "details_box") |
211 | ); | 235 | ); |
212 | 236 | ||
213 | handle->contacts_box = GTK_WIDGET( | 237 | handle->contacts_box = GTK_WIDGET( |
214 | gtk_builder_get_object(handle->builder, "contacts_box") | 238 | gtk_builder_get_object(handle->builder, "contacts_box") |
215 | ); | 239 | ); |
216 | 240 | ||
217 | handle->group_avatar = HDY_AVATAR( | 241 | handle->group_avatar = HDY_AVATAR( |
218 | gtk_builder_get_object(handle->builder, "group_avatar") | 242 | gtk_builder_get_object(handle->builder, "group_avatar") |
219 | ); | 243 | ); |
220 | 244 | ||
221 | handle->group_avatar_file = GTK_FILE_CHOOSER_BUTTON( | 245 | handle->group_avatar_file = GTK_FILE_CHOOSER_BUTTON( |
222 | gtk_builder_get_object(handle->builder, "group_avatar_file") | 246 | gtk_builder_get_object(handle->builder, "group_avatar_file") |
223 | ); | 247 | ); |
224 | 248 | ||
225 | handle->group_entry = GTK_ENTRY( | 249 | handle->group_entry = GTK_ENTRY( |
226 | gtk_builder_get_object(handle->builder, "group_entry") | 250 | gtk_builder_get_object(handle->builder, "group_entry") |
227 | ); | 251 | ); |
228 | 252 | ||
229 | g_signal_connect( | 253 | g_signal_connect( |
230 | handle->group_entry, | 254 | handle->group_entry, |
231 | "changed", | 255 | "changed", |
232 | G_CALLBACK(handle_group_entry_changed), | 256 | G_CALLBACK(handle_group_entry_changed), |
233 | handle->group_avatar | 257 | handle->group_avatar |
234 | ); | 258 | ); |
235 | 259 | ||
236 | g_signal_connect( | 260 | g_signal_connect( |
237 | handle->group_entry, | 261 | handle->group_entry, |
238 | "activate", | 262 | "activate", |
239 | G_CALLBACK(handle_group_entry_activate), | 263 | G_CALLBACK(handle_group_entry_activate), |
240 | app | 264 | app |
241 | ); | 265 | ); |
242 | 266 | ||
243 | handle->contact_search_entry = GTK_SEARCH_ENTRY( | 267 | handle->contact_search_entry = GTK_SEARCH_ENTRY( |
244 | gtk_builder_get_object(handle->builder, "contact_search_entry") | 268 | gtk_builder_get_object(handle->builder, "contact_search_entry") |
245 | ); | 269 | ); |
246 | 270 | ||
247 | handle->contacts_listbox = GTK_LIST_BOX( | 271 | handle->contacts_listbox = GTK_LIST_BOX( |
248 | gtk_builder_get_object(handle->builder, "contacts_listbox") | 272 | gtk_builder_get_object(handle->builder, "contacts_listbox") |
249 | ); | 273 | ); |
250 | 274 | ||
251 | handle->cancel_button = GTK_BUTTON( | 275 | handle->cancel_button = GTK_BUTTON( |
252 | gtk_builder_get_object(handle->builder, "cancel_button") | 276 | gtk_builder_get_object(handle->builder, "cancel_button") |
253 | ); | 277 | ); |
254 | 278 | ||
255 | g_signal_connect( | 279 | g_signal_connect( |
256 | handle->cancel_button, | 280 | handle->cancel_button, |
257 | "clicked", | 281 | "clicked", |
258 | G_CALLBACK(handle_cancel_button_click), | 282 | G_CALLBACK(handle_cancel_button_click), |
259 | handle->dialog | 283 | handle->dialog |
260 | ); | 284 | ); |
261 | 285 | ||
262 | handle->previous_button = GTK_BUTTON( | 286 | handle->previous_button = GTK_BUTTON( |
263 | gtk_builder_get_object(handle->builder, "previous_button") | 287 | gtk_builder_get_object(handle->builder, "previous_button") |
264 | ); | 288 | ); |
265 | 289 | ||
266 | g_signal_connect( | 290 | g_signal_connect( |
267 | handle->previous_button, | 291 | handle->previous_button, |
268 | "clicked", | 292 | "clicked", |
269 | G_CALLBACK(handle_previous_button_click), | 293 | G_CALLBACK(handle_previous_button_click), |
270 | handle | 294 | handle |
271 | ); | 295 | ); |
272 | 296 | ||
273 | handle->next_button = GTK_BUTTON( | 297 | handle->next_button = GTK_BUTTON( |
274 | gtk_builder_get_object(handle->builder, "next_button") | 298 | gtk_builder_get_object(handle->builder, "next_button") |
275 | ); | 299 | ); |
276 | 300 | ||
277 | g_signal_connect( | 301 | g_signal_connect( |
278 | handle->next_button, | 302 | handle->next_button, |
279 | "clicked", | 303 | "clicked", |
280 | G_CALLBACK(handle_next_button_click), | 304 | G_CALLBACK(handle_next_button_click), |
281 | handle | 305 | handle |
282 | ); | 306 | ); |
283 | 307 | ||
284 | handle->confirm_button = GTK_BUTTON( | 308 | handle->confirm_button = GTK_BUTTON( |
285 | gtk_builder_get_object(handle->builder, "confirm_button") | 309 | gtk_builder_get_object(handle->builder, "confirm_button") |
286 | ); | 310 | ); |
287 | 311 | ||
288 | g_signal_connect( | 312 | g_signal_connect( |
289 | handle->confirm_button, | 313 | handle->confirm_button, |
290 | "clicked", | 314 | "clicked", |
291 | G_CALLBACK(handle_confirm_button_click), | 315 | G_CALLBACK(handle_confirm_button_click), |
292 | app | 316 | app |
293 | ); | 317 | ); |
294 | 318 | ||
295 | g_signal_connect( | 319 | g_signal_connect( |
296 | handle->dialog, | 320 | handle->dialog, |
297 | "destroy", | 321 | "destroy", |
298 | G_CALLBACK(handle_dialog_destroy), | 322 | G_CALLBACK(handle_dialog_destroy), |
299 | handle | 323 | handle |
300 | ); | 324 | ); |
301 | 325 | ||
302 | GNUNET_CHAT_iterate_contacts( | 326 | GNUNET_CHAT_iterate_contacts( |
303 | app->chat.messenger.handle, | 327 | app->chat.messenger.handle, |
304 | _iterate_contacts, | 328 | _iterate_contacts, |
305 | app | 329 | app |
306 | ); | 330 | ); |
307 | } | 331 | } |
308 | 332 | ||
309 | void | 333 | void |
310 | ui_new_group_dialog_cleanup(UI_NEW_GROUP_Handle *handle) | 334 | ui_new_group_dialog_cleanup(UI_NEW_GROUP_Handle *handle) |
311 | { | 335 | { |
336 | g_assert(handle); | ||
337 | |||
312 | g_object_unref(handle->builder); | 338 | g_object_unref(handle->builder); |
313 | 339 | ||
314 | for (GList *list = handle->contact_entries; list; list = list->next) | 340 | for (GList *list = handle->contact_entries; list; list = list->next) |
diff --git a/src/ui/new_group.h b/src/ui/new_group.h index dbf6797..6bfff74 100644 --- a/src/ui/new_group.h +++ b/src/ui/new_group.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -62,7 +62,7 @@ typedef struct UI_NEW_GROUP_Handle | |||
62 | */ | 62 | */ |
63 | void | 63 | void |
64 | ui_new_group_dialog_init(MESSENGER_Application *app, | 64 | ui_new_group_dialog_init(MESSENGER_Application *app, |
65 | UI_NEW_GROUP_Handle *handle); | 65 | UI_NEW_GROUP_Handle *handle); |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Cleans up the allocated resources and resets the | 68 | * Cleans up the allocated resources and resets the |
diff --git a/src/ui/new_lobby.c b/src/ui/new_lobby.c index e75c371..5e5102d 100644 --- a/src/ui/new_lobby.c +++ b/src/ui/new_lobby.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2022 GNUnet e.V. | 3 | Copyright (C) 2022--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -28,31 +28,39 @@ | |||
28 | 28 | ||
29 | static void | 29 | static void |
30 | handle_warning_info_bar_close(GtkInfoBar *info_bar, | 30 | handle_warning_info_bar_close(GtkInfoBar *info_bar, |
31 | UNUSED gpointer user_data) | 31 | UNUSED gpointer user_data) |
32 | { | 32 | { |
33 | g_assert(info_bar); | ||
34 | |||
33 | gtk_info_bar_set_revealed(info_bar, FALSE); | 35 | gtk_info_bar_set_revealed(info_bar, FALSE); |
34 | } | 36 | } |
35 | 37 | ||
36 | static void | 38 | static void |
37 | handle_warning_info_bar_response(GtkInfoBar *info_bar, | 39 | handle_warning_info_bar_response(GtkInfoBar *info_bar, |
38 | UNUSED int response_id, | 40 | UNUSED int response_id, |
39 | UNUSED gpointer user_data) | 41 | UNUSED gpointer user_data) |
40 | { | 42 | { |
43 | g_assert(info_bar); | ||
44 | |||
41 | gtk_info_bar_set_revealed(info_bar, FALSE); | 45 | gtk_info_bar_set_revealed(info_bar, FALSE); |
42 | } | 46 | } |
43 | 47 | ||
44 | static void | 48 | static void |
45 | handle_cancel_button_click(UNUSED GtkButton *button, | 49 | handle_cancel_button_click(UNUSED GtkButton *button, |
46 | gpointer user_data) | 50 | gpointer user_data) |
47 | { | 51 | { |
52 | g_assert(user_data); | ||
53 | |||
48 | GtkDialog *dialog = GTK_DIALOG(user_data); | 54 | GtkDialog *dialog = GTK_DIALOG(user_data); |
49 | gtk_window_close(GTK_WINDOW(dialog)); | 55 | gtk_window_close(GTK_WINDOW(dialog)); |
50 | } | 56 | } |
51 | 57 | ||
52 | void | 58 | void |
53 | handle_lobby_opened_and_uri_generated(void *cls, | 59 | handle_lobby_opened_and_uri_generated(void *cls, |
54 | const struct GNUNET_CHAT_Uri *uri) | 60 | const struct GNUNET_CHAT_Uri *uri) |
55 | { | 61 | { |
62 | g_assert(cls); | ||
63 | |||
56 | MESSENGER_Application *app = (MESSENGER_Application*) cls; | 64 | MESSENGER_Application *app = (MESSENGER_Application*) cls; |
57 | 65 | ||
58 | if (app->ui.new_lobby.qr) | 66 | if (app->ui.new_lobby.qr) |
@@ -62,8 +70,8 @@ handle_lobby_opened_and_uri_generated(void *cls, | |||
62 | { | 70 | { |
63 | if (app->ui.new_lobby.preview_stack) | 71 | if (app->ui.new_lobby.preview_stack) |
64 | gtk_stack_set_visible_child( | 72 | gtk_stack_set_visible_child( |
65 | app->ui.new_lobby.preview_stack, | 73 | app->ui.new_lobby.preview_stack, |
66 | app->ui.new_lobby.fail_box | 74 | app->ui.new_lobby.fail_box |
67 | ); | 75 | ); |
68 | 76 | ||
69 | app->ui.new_lobby.qr = NULL; | 77 | app->ui.new_lobby.qr = NULL; |
@@ -73,11 +81,11 @@ handle_lobby_opened_and_uri_generated(void *cls, | |||
73 | gchar *uri_string = GNUNET_CHAT_uri_to_string(uri); | 81 | gchar *uri_string = GNUNET_CHAT_uri_to_string(uri); |
74 | 82 | ||
75 | app->ui.new_lobby.qr = QRcode_encodeString( | 83 | app->ui.new_lobby.qr = QRcode_encodeString( |
76 | uri_string, | 84 | uri_string, |
77 | 0, | 85 | 0, |
78 | QR_ECLEVEL_L, | 86 | QR_ECLEVEL_L, |
79 | QR_MODE_8, | 87 | QR_MODE_8, |
80 | 0 | 88 | 0 |
81 | ); | 89 | ); |
82 | 90 | ||
83 | if (app->ui.new_lobby.id_drawing_area) | 91 | if (app->ui.new_lobby.id_drawing_area) |
@@ -85,8 +93,8 @@ handle_lobby_opened_and_uri_generated(void *cls, | |||
85 | 93 | ||
86 | if (app->ui.new_lobby.preview_stack) | 94 | if (app->ui.new_lobby.preview_stack) |
87 | gtk_stack_set_visible_child( | 95 | gtk_stack_set_visible_child( |
88 | app->ui.new_lobby.preview_stack, | 96 | app->ui.new_lobby.preview_stack, |
89 | GTK_WIDGET(app->ui.new_lobby.id_drawing_area) | 97 | GTK_WIDGET(app->ui.new_lobby.id_drawing_area) |
90 | ); | 98 | ); |
91 | 99 | ||
92 | if (app->ui.new_lobby.id_entry) | 100 | if (app->ui.new_lobby.id_entry) |
@@ -100,41 +108,42 @@ handle_lobby_opened_and_uri_generated(void *cls, | |||
100 | const gint id_length = gtk_entry_get_text_length(app->ui.new_lobby.id_entry); | 108 | const gint id_length = gtk_entry_get_text_length(app->ui.new_lobby.id_entry); |
101 | 109 | ||
102 | gtk_widget_set_sensitive( | 110 | gtk_widget_set_sensitive( |
103 | GTK_WIDGET(app->ui.new_lobby.copy_button), | 111 | GTK_WIDGET(app->ui.new_lobby.copy_button), |
104 | id_length > 0? TRUE : FALSE | 112 | id_length > 0? TRUE : FALSE |
105 | ); | 113 | ); |
106 | } | 114 | } |
107 | 115 | ||
108 | static void | 116 | static void |
109 | handle_generate_button_click(UNUSED GtkButton *button, | 117 | handle_generate_button_click(UNUSED GtkButton *button, |
110 | gpointer user_data) | 118 | gpointer user_data) |
111 | { | 119 | { |
120 | g_assert(user_data); | ||
121 | |||
112 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 122 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
113 | 123 | ||
114 | GtkTreeModel *model = gtk_combo_box_get_model( | 124 | GtkTreeModel *model = gtk_combo_box_get_model( |
115 | app->ui.new_lobby.expiration_combo_box | 125 | app->ui.new_lobby.expiration_combo_box |
116 | ); | 126 | ); |
117 | 127 | ||
118 | gulong delay = 0; | 128 | gulong delay = 0; |
119 | 129 | ||
120 | GtkTreeIter iter; | 130 | GtkTreeIter iter; |
121 | if (gtk_combo_box_get_active_iter(app->ui.new_lobby.expiration_combo_box, | 131 | if (gtk_combo_box_get_active_iter(app->ui.new_lobby.expiration_combo_box, &iter)) |
122 | &iter)) | ||
123 | gtk_tree_model_get(model, &iter, 1, &delay, -1); | 132 | gtk_tree_model_get(model, &iter, 1, &delay, -1); |
124 | 133 | ||
125 | struct GNUNET_TIME_Relative expiration = GNUNET_TIME_relative_multiply( | 134 | struct GNUNET_TIME_Relative expiration = GNUNET_TIME_relative_multiply( |
126 | GNUNET_TIME_relative_get_second_(), | 135 | GNUNET_TIME_relative_get_second_(), |
127 | delay | 136 | delay |
128 | ); | 137 | ); |
129 | 138 | ||
130 | gtk_stack_set_visible_child( | 139 | gtk_stack_set_visible_child( |
131 | app->ui.new_lobby.preview_stack, | 140 | app->ui.new_lobby.preview_stack, |
132 | GTK_WIDGET(app->ui.new_lobby.loading_spinner) | 141 | GTK_WIDGET(app->ui.new_lobby.loading_spinner) |
133 | ); | 142 | ); |
134 | 143 | ||
135 | gtk_stack_set_visible_child( | 144 | gtk_stack_set_visible_child( |
136 | app->ui.new_lobby.stack, | 145 | app->ui.new_lobby.stack, |
137 | app->ui.new_lobby.copy_box | 146 | app->ui.new_lobby.copy_box |
138 | ); | 147 | ); |
139 | 148 | ||
140 | gtk_widget_set_sensitive(GTK_WIDGET(app->ui.new_lobby.copy_button), FALSE); | 149 | gtk_widget_set_sensitive(GTK_WIDGET(app->ui.new_lobby.copy_button), FALSE); |
@@ -143,17 +152,19 @@ handle_generate_button_click(UNUSED GtkButton *button, | |||
143 | gtk_widget_set_visible(GTK_WIDGET(app->ui.new_lobby.copy_button), TRUE); | 152 | gtk_widget_set_visible(GTK_WIDGET(app->ui.new_lobby.copy_button), TRUE); |
144 | 153 | ||
145 | GNUNET_CHAT_lobby_open( | 154 | GNUNET_CHAT_lobby_open( |
146 | app->chat.messenger.handle, | 155 | app->chat.messenger.handle, |
147 | expiration, | 156 | expiration, |
148 | handle_lobby_opened_and_uri_generated, | 157 | handle_lobby_opened_and_uri_generated, |
149 | app | 158 | app |
150 | ); | 159 | ); |
151 | } | 160 | } |
152 | 161 | ||
153 | static void | 162 | static void |
154 | handle_copy_button_click(UNUSED GtkButton *button, | 163 | handle_copy_button_click(UNUSED GtkButton *button, |
155 | gpointer user_data) | 164 | gpointer user_data) |
156 | { | 165 | { |
166 | g_assert(user_data); | ||
167 | |||
157 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 168 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
158 | 169 | ||
159 | const gint id_length = gtk_entry_get_text_length(app->ui.new_lobby.id_entry); | 170 | const gint id_length = gtk_entry_get_text_length(app->ui.new_lobby.id_entry); |
@@ -169,16 +180,20 @@ handle_copy_button_click(UNUSED GtkButton *button, | |||
169 | 180 | ||
170 | static void | 181 | static void |
171 | handle_dialog_destroy(UNUSED GtkWidget *window, | 182 | handle_dialog_destroy(UNUSED GtkWidget *window, |
172 | gpointer user_data) | 183 | gpointer user_data) |
173 | { | 184 | { |
185 | g_assert(user_data); | ||
186 | |||
174 | ui_new_lobby_dialog_cleanup((UI_NEW_LOBBY_Handle*) user_data); | 187 | ui_new_lobby_dialog_cleanup((UI_NEW_LOBBY_Handle*) user_data); |
175 | } | 188 | } |
176 | 189 | ||
177 | static gboolean | 190 | static gboolean |
178 | handle_id_drawing_area_draw(GtkWidget* drawing_area, | 191 | handle_id_drawing_area_draw(GtkWidget* drawing_area, |
179 | cairo_t* cairo, | 192 | cairo_t* cairo, |
180 | gpointer user_data) | 193 | gpointer user_data) |
181 | { | 194 | { |
195 | g_assert((drawing_area) && (cairo) && (user_data)); | ||
196 | |||
182 | UI_NEW_LOBBY_Handle *handle = (UI_NEW_LOBBY_Handle*) user_data; | 197 | UI_NEW_LOBBY_Handle *handle = (UI_NEW_LOBBY_Handle*) user_data; |
183 | 198 | ||
184 | GtkStyleContext* context = gtk_widget_get_style_context(drawing_area); | 199 | GtkStyleContext* context = gtk_widget_get_style_context(drawing_area); |
@@ -207,24 +222,24 @@ handle_id_drawing_area_draw(GtkWidget* drawing_area, | |||
207 | guchar value; | 222 | guchar value; |
208 | 223 | ||
209 | if ((x >= m) && (y >= m) && (x - m < w) && (y - m < w)) | 224 | if ((x >= m) && (y >= m) && (x - m < w) && (y - m < w)) |
210 | value = ((handle->qr->data[(y - m) * w + x - m]) & 1); | 225 | value = ((handle->qr->data[(y - m) * w + x - m]) & 1); |
211 | else | 226 | else |
212 | value = 0; | 227 | value = 0; |
213 | 228 | ||
214 | for (z = 0; z < 3; z++) | 229 | for (z = 0; z < 3; z++) |
215 | pixels[(y * w2 + x) * 3 + z] = value? 0x00 : 0xff; | 230 | pixels[(y * w2 + x) * 3 + z] = value? 0x00 : 0xff; |
216 | } | 231 | } |
217 | 232 | ||
218 | GdkPixbuf *image = gdk_pixbuf_new_from_data( | 233 | GdkPixbuf *image = gdk_pixbuf_new_from_data( |
219 | pixels, | 234 | pixels, |
220 | GDK_COLORSPACE_RGB, | 235 | GDK_COLORSPACE_RGB, |
221 | FALSE, | 236 | FALSE, |
222 | 8, | 237 | 8, |
223 | w2, | 238 | w2, |
224 | w2, | 239 | w2, |
225 | w2 * 3, | 240 | w2 * 3, |
226 | NULL, | 241 | NULL, |
227 | NULL | 242 | NULL |
228 | ); | 243 | ); |
229 | 244 | ||
230 | if (!image) | 245 | if (!image) |
@@ -245,15 +260,15 @@ handle_id_drawing_area_draw(GtkWidget* drawing_area, | |||
245 | double dy = (height - dheight) * 0.5; | 260 | double dy = (height - dheight) * 0.5; |
246 | 261 | ||
247 | const int interp_type = (ratio >= 1.0? | 262 | const int interp_type = (ratio >= 1.0? |
248 | GDK_INTERP_NEAREST : | 263 | GDK_INTERP_NEAREST : |
249 | GDK_INTERP_BILINEAR | 264 | GDK_INTERP_BILINEAR |
250 | ); | 265 | ); |
251 | 266 | ||
252 | GdkPixbuf* scaled = gdk_pixbuf_scale_simple( | 267 | GdkPixbuf* scaled = gdk_pixbuf_scale_simple( |
253 | image, | 268 | image, |
254 | dwidth, | 269 | dwidth, |
255 | dheight, | 270 | dheight, |
256 | interp_type | 271 | interp_type |
257 | ); | 272 | ); |
258 | 273 | ||
259 | gtk_render_icon(context, cairo, scaled, dx, dy); | 274 | gtk_render_icon(context, cairo, scaled, dx, dy); |
@@ -270,129 +285,133 @@ handle_id_drawing_area_draw(GtkWidget* drawing_area, | |||
270 | 285 | ||
271 | void | 286 | void |
272 | ui_new_lobby_dialog_init(MESSENGER_Application *app, | 287 | ui_new_lobby_dialog_init(MESSENGER_Application *app, |
273 | UI_NEW_LOBBY_Handle *handle) | 288 | UI_NEW_LOBBY_Handle *handle) |
274 | { | 289 | { |
290 | g_assert((app) && (handle)); | ||
291 | |||
275 | handle->builder = gtk_builder_new_from_resource( | 292 | handle->builder = gtk_builder_new_from_resource( |
276 | application_get_resource_path(app, "ui/new_lobby.ui") | 293 | application_get_resource_path(app, "ui/new_lobby.ui") |
277 | ); | 294 | ); |
278 | 295 | ||
279 | handle->dialog = GTK_DIALOG( | 296 | handle->dialog = GTK_DIALOG( |
280 | gtk_builder_get_object(handle->builder, "new_lobby_dialog") | 297 | gtk_builder_get_object(handle->builder, "new_lobby_dialog") |
281 | ); | 298 | ); |
282 | 299 | ||
283 | gtk_window_set_transient_for( | 300 | gtk_window_set_transient_for( |
284 | GTK_WINDOW(handle->dialog), | 301 | GTK_WINDOW(handle->dialog), |
285 | GTK_WINDOW(app->ui.messenger.main_window) | 302 | GTK_WINDOW(app->ui.messenger.main_window) |
286 | ); | 303 | ); |
287 | 304 | ||
288 | handle->warning_info_bar = GTK_INFO_BAR( | 305 | handle->warning_info_bar = GTK_INFO_BAR( |
289 | gtk_builder_get_object(handle->builder, "warning_info_bar") | 306 | gtk_builder_get_object(handle->builder, "warning_info_bar") |
290 | ); | 307 | ); |
291 | 308 | ||
292 | g_signal_connect( | 309 | g_signal_connect( |
293 | handle->warning_info_bar, | 310 | handle->warning_info_bar, |
294 | "close", | 311 | "close", |
295 | G_CALLBACK(handle_warning_info_bar_close), | 312 | G_CALLBACK(handle_warning_info_bar_close), |
296 | NULL | 313 | NULL |
297 | ); | 314 | ); |
298 | 315 | ||
299 | g_signal_connect( | 316 | g_signal_connect( |
300 | handle->warning_info_bar, | 317 | handle->warning_info_bar, |
301 | "response", | 318 | "response", |
302 | G_CALLBACK(handle_warning_info_bar_response), | 319 | G_CALLBACK(handle_warning_info_bar_response), |
303 | NULL | 320 | NULL |
304 | ); | 321 | ); |
305 | 322 | ||
306 | handle->stack = GTK_STACK( | 323 | handle->stack = GTK_STACK( |
307 | gtk_builder_get_object(handle->builder, "new_lobby_stack") | 324 | gtk_builder_get_object(handle->builder, "new_lobby_stack") |
308 | ); | 325 | ); |
309 | 326 | ||
310 | handle->generate_box = GTK_WIDGET( | 327 | handle->generate_box = GTK_WIDGET( |
311 | gtk_builder_get_object(handle->builder, "generate_box") | 328 | gtk_builder_get_object(handle->builder, "generate_box") |
312 | ); | 329 | ); |
313 | 330 | ||
314 | handle->copy_box = GTK_WIDGET( | 331 | handle->copy_box = GTK_WIDGET( |
315 | gtk_builder_get_object(handle->builder, "copy_box") | 332 | gtk_builder_get_object(handle->builder, "copy_box") |
316 | ); | 333 | ); |
317 | 334 | ||
318 | handle->expiration_combo_box = GTK_COMBO_BOX( | 335 | handle->expiration_combo_box = GTK_COMBO_BOX( |
319 | gtk_builder_get_object(handle->builder, "expiration_combo_box") | 336 | gtk_builder_get_object(handle->builder, "expiration_combo_box") |
320 | ); | 337 | ); |
321 | 338 | ||
322 | handle->preview_stack = GTK_STACK( | 339 | handle->preview_stack = GTK_STACK( |
323 | gtk_builder_get_object(handle->builder, "preview_stack") | 340 | gtk_builder_get_object(handle->builder, "preview_stack") |
324 | ); | 341 | ); |
325 | 342 | ||
326 | handle->fail_box = GTK_WIDGET( | 343 | handle->fail_box = GTK_WIDGET( |
327 | gtk_builder_get_object(handle->builder, "fail_box") | 344 | gtk_builder_get_object(handle->builder, "fail_box") |
328 | ); | 345 | ); |
329 | 346 | ||
330 | handle->loading_spinner = GTK_SPINNER( | 347 | handle->loading_spinner = GTK_SPINNER( |
331 | gtk_builder_get_object(handle->builder, "loading_spinner") | 348 | gtk_builder_get_object(handle->builder, "loading_spinner") |
332 | ); | 349 | ); |
333 | 350 | ||
334 | handle->id_drawing_area = GTK_DRAWING_AREA( | 351 | handle->id_drawing_area = GTK_DRAWING_AREA( |
335 | gtk_builder_get_object(handle->builder, "id_drawing_area") | 352 | gtk_builder_get_object(handle->builder, "id_drawing_area") |
336 | ); | 353 | ); |
337 | 354 | ||
338 | handle->id_draw_signal = g_signal_connect( | 355 | handle->id_draw_signal = g_signal_connect( |
339 | handle->id_drawing_area, | 356 | handle->id_drawing_area, |
340 | "draw", | 357 | "draw", |
341 | G_CALLBACK(handle_id_drawing_area_draw), | 358 | G_CALLBACK(handle_id_drawing_area_draw), |
342 | handle | 359 | handle |
343 | ); | 360 | ); |
344 | 361 | ||
345 | handle->id_entry = GTK_ENTRY( | 362 | handle->id_entry = GTK_ENTRY( |
346 | gtk_builder_get_object(handle->builder, "id_entry") | 363 | gtk_builder_get_object(handle->builder, "id_entry") |
347 | ); | 364 | ); |
348 | 365 | ||
349 | handle->cancel_button = GTK_BUTTON( | 366 | handle->cancel_button = GTK_BUTTON( |
350 | gtk_builder_get_object(handle->builder, "cancel_button") | 367 | gtk_builder_get_object(handle->builder, "cancel_button") |
351 | ); | 368 | ); |
352 | 369 | ||
353 | g_signal_connect( | 370 | g_signal_connect( |
354 | handle->cancel_button, | 371 | handle->cancel_button, |
355 | "clicked", | 372 | "clicked", |
356 | G_CALLBACK(handle_cancel_button_click), | 373 | G_CALLBACK(handle_cancel_button_click), |
357 | handle->dialog | 374 | handle->dialog |
358 | ); | 375 | ); |
359 | 376 | ||
360 | handle->generate_button = GTK_BUTTON( | 377 | handle->generate_button = GTK_BUTTON( |
361 | gtk_builder_get_object(handle->builder, "generate_button") | 378 | gtk_builder_get_object(handle->builder, "generate_button") |
362 | ); | 379 | ); |
363 | 380 | ||
364 | g_signal_connect( | 381 | g_signal_connect( |
365 | handle->generate_button, | 382 | handle->generate_button, |
366 | "clicked", | 383 | "clicked", |
367 | G_CALLBACK(handle_generate_button_click), | 384 | G_CALLBACK(handle_generate_button_click), |
368 | app | 385 | app |
369 | ); | 386 | ); |
370 | 387 | ||
371 | handle->copy_button = GTK_BUTTON( | 388 | handle->copy_button = GTK_BUTTON( |
372 | gtk_builder_get_object(handle->builder, "copy_button") | 389 | gtk_builder_get_object(handle->builder, "copy_button") |
373 | ); | 390 | ); |
374 | 391 | ||
375 | g_signal_connect( | 392 | g_signal_connect( |
376 | handle->copy_button, | 393 | handle->copy_button, |
377 | "clicked", | 394 | "clicked", |
378 | G_CALLBACK(handle_copy_button_click), | 395 | G_CALLBACK(handle_copy_button_click), |
379 | app | 396 | app |
380 | ); | 397 | ); |
381 | 398 | ||
382 | g_signal_connect( | 399 | g_signal_connect( |
383 | handle->dialog, | 400 | handle->dialog, |
384 | "destroy", | 401 | "destroy", |
385 | G_CALLBACK(handle_dialog_destroy), | 402 | G_CALLBACK(handle_dialog_destroy), |
386 | handle | 403 | handle |
387 | ); | 404 | ); |
388 | } | 405 | } |
389 | 406 | ||
390 | void | 407 | void |
391 | ui_new_lobby_dialog_cleanup(UI_NEW_LOBBY_Handle *handle) | 408 | ui_new_lobby_dialog_cleanup(UI_NEW_LOBBY_Handle *handle) |
392 | { | 409 | { |
410 | g_assert(handle); | ||
411 | |||
393 | g_signal_handler_disconnect( | 412 | g_signal_handler_disconnect( |
394 | handle->id_drawing_area, | 413 | handle->id_drawing_area, |
395 | handle->id_draw_signal | 414 | handle->id_draw_signal |
396 | ); | 415 | ); |
397 | 416 | ||
398 | g_object_unref(handle->builder); | 417 | g_object_unref(handle->builder); |
diff --git a/src/ui/new_lobby.h b/src/ui/new_lobby.h index ea2e09c..4b62652 100644 --- a/src/ui/new_lobby.h +++ b/src/ui/new_lobby.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2022 GNUnet e.V. | 3 | Copyright (C) 2022--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -70,7 +70,7 @@ typedef struct UI_NEW_LOBBY_Handle | |||
70 | */ | 70 | */ |
71 | void | 71 | void |
72 | ui_new_lobby_dialog_init(MESSENGER_Application *app, | 72 | ui_new_lobby_dialog_init(MESSENGER_Application *app, |
73 | UI_NEW_LOBBY_Handle *handle); | 73 | UI_NEW_LOBBY_Handle *handle); |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Cleans up the allocated resources and resets the | 76 | * Cleans up the allocated resources and resets the |
diff --git a/src/ui/new_platform.c b/src/ui/new_platform.c index 1216239..ac7da16 100644 --- a/src/ui/new_platform.c +++ b/src/ui/new_platform.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -27,15 +27,18 @@ | |||
27 | #include "../application.h" | 27 | #include "../application.h" |
28 | 28 | ||
29 | static void | 29 | static void |
30 | _open_new_platform(GtkEntry *entry, MESSENGER_Application *app) | 30 | _open_new_platform(GtkEntry *entry, |
31 | MESSENGER_Application *app) | ||
31 | { | 32 | { |
33 | g_assert((entry) && (app)); | ||
34 | |||
32 | const gchar *topic = gtk_entry_get_text(entry); | 35 | const gchar *topic = gtk_entry_get_text(entry); |
33 | 36 | ||
34 | GString *topic_string = g_string_new(topic); | 37 | GString *topic_string = g_string_new(topic); |
35 | 38 | ||
36 | struct GNUNET_CHAT_Group *group = GNUNET_CHAT_group_create( | 39 | struct GNUNET_CHAT_Group *group = GNUNET_CHAT_group_create( |
37 | app->chat.messenger.handle, | 40 | app->chat.messenger.handle, |
38 | topic_string->str | 41 | topic_string->str |
39 | ); | 42 | ); |
40 | 43 | ||
41 | g_string_prepend_c(topic_string, '#'); | 44 | g_string_prepend_c(topic_string, '#'); |
@@ -46,8 +49,10 @@ _open_new_platform(GtkEntry *entry, MESSENGER_Application *app) | |||
46 | 49 | ||
47 | static void | 50 | static void |
48 | handle_platform_entry_changed(GtkEditable *editable, | 51 | handle_platform_entry_changed(GtkEditable *editable, |
49 | gpointer user_data) | 52 | gpointer user_data) |
50 | { | 53 | { |
54 | g_assert((editable) && (user_data)); | ||
55 | |||
51 | HdyAvatar *avatar = HDY_AVATAR(user_data); | 56 | HdyAvatar *avatar = HDY_AVATAR(user_data); |
52 | GtkEntry *entry = GTK_ENTRY(editable); | 57 | GtkEntry *entry = GTK_ENTRY(editable); |
53 | 58 | ||
@@ -65,8 +70,10 @@ handle_platform_entry_changed(GtkEditable *editable, | |||
65 | 70 | ||
66 | static void | 71 | static void |
67 | handle_platform_entry_activate(GtkEntry *entry, | 72 | handle_platform_entry_activate(GtkEntry *entry, |
68 | gpointer user_data) | 73 | gpointer user_data) |
69 | { | 74 | { |
75 | g_assert((entry) && (user_data)); | ||
76 | |||
70 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 77 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
71 | 78 | ||
72 | _open_new_platform(entry, app); | 79 | _open_new_platform(entry, app); |
@@ -76,16 +83,20 @@ handle_platform_entry_activate(GtkEntry *entry, | |||
76 | 83 | ||
77 | static void | 84 | static void |
78 | handle_cancel_button_click(UNUSED GtkButton *button, | 85 | handle_cancel_button_click(UNUSED GtkButton *button, |
79 | gpointer user_data) | 86 | gpointer user_data) |
80 | { | 87 | { |
88 | g_assert(user_data); | ||
89 | |||
81 | GtkDialog *dialog = GTK_DIALOG(user_data); | 90 | GtkDialog *dialog = GTK_DIALOG(user_data); |
82 | gtk_window_close(GTK_WINDOW(dialog)); | 91 | gtk_window_close(GTK_WINDOW(dialog)); |
83 | } | 92 | } |
84 | 93 | ||
85 | static void | 94 | static void |
86 | handle_confirm_button_click(UNUSED GtkButton *button, | 95 | handle_confirm_button_click(UNUSED GtkButton *button, |
87 | gpointer user_data) | 96 | gpointer user_data) |
88 | { | 97 | { |
98 | g_assert(user_data); | ||
99 | |||
89 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 100 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
90 | 101 | ||
91 | _open_new_platform(app->ui.new_platform.platform_entry, app); | 102 | _open_new_platform(app->ui.new_platform.platform_entry, app); |
@@ -95,87 +106,93 @@ handle_confirm_button_click(UNUSED GtkButton *button, | |||
95 | 106 | ||
96 | static void | 107 | static void |
97 | handle_dialog_destroy(UNUSED GtkWidget *window, | 108 | handle_dialog_destroy(UNUSED GtkWidget *window, |
98 | gpointer user_data) | 109 | gpointer user_data) |
99 | { | 110 | { |
111 | g_assert(user_data); | ||
112 | |||
100 | ui_new_platform_dialog_cleanup((UI_NEW_PLATFORM_Handle*) user_data); | 113 | ui_new_platform_dialog_cleanup((UI_NEW_PLATFORM_Handle*) user_data); |
101 | } | 114 | } |
102 | 115 | ||
103 | void | 116 | void |
104 | ui_new_platform_dialog_init(MESSENGER_Application *app, | 117 | ui_new_platform_dialog_init(MESSENGER_Application *app, |
105 | UI_NEW_PLATFORM_Handle *handle) | 118 | UI_NEW_PLATFORM_Handle *handle) |
106 | { | 119 | { |
120 | g_assert((app) && (handle)); | ||
121 | |||
107 | handle->builder = gtk_builder_new_from_resource( | 122 | handle->builder = gtk_builder_new_from_resource( |
108 | application_get_resource_path(app, "ui/new_platform.ui") | 123 | application_get_resource_path(app, "ui/new_platform.ui") |
109 | ); | 124 | ); |
110 | 125 | ||
111 | handle->dialog = GTK_DIALOG( | 126 | handle->dialog = GTK_DIALOG( |
112 | gtk_builder_get_object(handle->builder, "new_platform_dialog") | 127 | gtk_builder_get_object(handle->builder, "new_platform_dialog") |
113 | ); | 128 | ); |
114 | 129 | ||
115 | gtk_window_set_transient_for( | 130 | gtk_window_set_transient_for( |
116 | GTK_WINDOW(handle->dialog), | 131 | GTK_WINDOW(handle->dialog), |
117 | GTK_WINDOW(app->ui.messenger.main_window) | 132 | GTK_WINDOW(app->ui.messenger.main_window) |
118 | ); | 133 | ); |
119 | 134 | ||
120 | handle->platform_avatar = HDY_AVATAR( | 135 | handle->platform_avatar = HDY_AVATAR( |
121 | gtk_builder_get_object(handle->builder, "platform_avatar") | 136 | gtk_builder_get_object(handle->builder, "platform_avatar") |
122 | ); | 137 | ); |
123 | 138 | ||
124 | handle->platform_avatar_file = GTK_FILE_CHOOSER_BUTTON( | 139 | handle->platform_avatar_file = GTK_FILE_CHOOSER_BUTTON( |
125 | gtk_builder_get_object(handle->builder, "platform_avatar_file") | 140 | gtk_builder_get_object(handle->builder, "platform_avatar_file") |
126 | ); | 141 | ); |
127 | 142 | ||
128 | handle->platform_entry = GTK_ENTRY( | 143 | handle->platform_entry = GTK_ENTRY( |
129 | gtk_builder_get_object(handle->builder, "platform_entry") | 144 | gtk_builder_get_object(handle->builder, "platform_entry") |
130 | ); | 145 | ); |
131 | 146 | ||
132 | g_signal_connect( | 147 | g_signal_connect( |
133 | handle->platform_entry, | 148 | handle->platform_entry, |
134 | "changed", | 149 | "changed", |
135 | G_CALLBACK(handle_platform_entry_changed), | 150 | G_CALLBACK(handle_platform_entry_changed), |
136 | handle->platform_avatar | 151 | handle->platform_avatar |
137 | ); | 152 | ); |
138 | 153 | ||
139 | g_signal_connect( | 154 | g_signal_connect( |
140 | handle->platform_entry, | 155 | handle->platform_entry, |
141 | "activate", | 156 | "activate", |
142 | G_CALLBACK(handle_platform_entry_activate), | 157 | G_CALLBACK(handle_platform_entry_activate), |
143 | app | 158 | app |
144 | ); | 159 | ); |
145 | 160 | ||
146 | handle->cancel_button = GTK_BUTTON( | 161 | handle->cancel_button = GTK_BUTTON( |
147 | gtk_builder_get_object(handle->builder, "cancel_button") | 162 | gtk_builder_get_object(handle->builder, "cancel_button") |
148 | ); | 163 | ); |
149 | 164 | ||
150 | g_signal_connect( | 165 | g_signal_connect( |
151 | handle->cancel_button, | 166 | handle->cancel_button, |
152 | "clicked", | 167 | "clicked", |
153 | G_CALLBACK(handle_cancel_button_click), | 168 | G_CALLBACK(handle_cancel_button_click), |
154 | handle->dialog | 169 | handle->dialog |
155 | ); | 170 | ); |
156 | 171 | ||
157 | handle->confirm_button = GTK_BUTTON( | 172 | handle->confirm_button = GTK_BUTTON( |
158 | gtk_builder_get_object(handle->builder, "confirm_button") | 173 | gtk_builder_get_object(handle->builder, "confirm_button") |
159 | ); | 174 | ); |
160 | 175 | ||
161 | g_signal_connect( | 176 | g_signal_connect( |
162 | handle->confirm_button, | 177 | handle->confirm_button, |
163 | "clicked", | 178 | "clicked", |
164 | G_CALLBACK(handle_confirm_button_click), | 179 | G_CALLBACK(handle_confirm_button_click), |
165 | app | 180 | app |
166 | ); | 181 | ); |
167 | 182 | ||
168 | g_signal_connect( | 183 | g_signal_connect( |
169 | handle->dialog, | 184 | handle->dialog, |
170 | "destroy", | 185 | "destroy", |
171 | G_CALLBACK(handle_dialog_destroy), | 186 | G_CALLBACK(handle_dialog_destroy), |
172 | handle | 187 | handle |
173 | ); | 188 | ); |
174 | } | 189 | } |
175 | 190 | ||
176 | void | 191 | void |
177 | ui_new_platform_dialog_cleanup(UI_NEW_PLATFORM_Handle *handle) | 192 | ui_new_platform_dialog_cleanup(UI_NEW_PLATFORM_Handle *handle) |
178 | { | 193 | { |
194 | g_assert(handle); | ||
195 | |||
179 | g_object_unref(handle->builder); | 196 | g_object_unref(handle->builder); |
180 | 197 | ||
181 | memset(handle, 0, sizeof(*handle)); | 198 | memset(handle, 0, sizeof(*handle)); |
diff --git a/src/ui/new_platform.h b/src/ui/new_platform.h index be2d481..73ae82a 100644 --- a/src/ui/new_platform.h +++ b/src/ui/new_platform.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -50,7 +50,7 @@ typedef struct UI_NEW_PLATFORM_Handle | |||
50 | */ | 50 | */ |
51 | void | 51 | void |
52 | ui_new_platform_dialog_init(MESSENGER_Application *app, | 52 | ui_new_platform_dialog_init(MESSENGER_Application *app, |
53 | UI_NEW_PLATFORM_Handle *handle); | 53 | UI_NEW_PLATFORM_Handle *handle); |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Cleans up the allocated resources and resets the | 56 | * Cleans up the allocated resources and resets the |
diff --git a/src/ui/picker.c b/src/ui/picker.c index 83c61ef..615a1bd 100644 --- a/src/ui/picker.c +++ b/src/ui/picker.c | |||
@@ -34,6 +34,8 @@ static void | |||
34 | handle_emoji_button_click(GtkButton *button, | 34 | handle_emoji_button_click(GtkButton *button, |
35 | gpointer user_data) | 35 | gpointer user_data) |
36 | { | 36 | { |
37 | g_assert((button) && (user_data)); | ||
38 | |||
37 | GtkTextView *text_view = GTK_TEXT_VIEW(user_data); | 39 | GtkTextView *text_view = GTK_TEXT_VIEW(user_data); |
38 | GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(text_view); | 40 | GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(text_view); |
39 | 41 | ||
@@ -49,6 +51,8 @@ _add_emoji_buttons(GtkFlowBox *flow_box, | |||
49 | size_t characters_count, | 51 | size_t characters_count, |
50 | const uint32_t *characters) | 52 | const uint32_t *characters) |
51 | { | 53 | { |
54 | g_assert((flow_box) && (text_view) && (characters)); | ||
55 | |||
52 | glong items_written; | 56 | glong items_written; |
53 | GError *error; | 57 | GError *error; |
54 | gchar *utf8; | 58 | gchar *utf8; |
@@ -87,6 +91,8 @@ static void | |||
87 | _filter_emoji_buttons(GtkWidget* widget, | 91 | _filter_emoji_buttons(GtkWidget* widget, |
88 | gpointer user_data) | 92 | gpointer user_data) |
89 | { | 93 | { |
94 | g_assert((widget) && (user_data)); | ||
95 | |||
90 | GtkSearchEntry *entry = GTK_SEARCH_ENTRY(user_data); | 96 | GtkSearchEntry *entry = GTK_SEARCH_ENTRY(user_data); |
91 | 97 | ||
92 | const gchar *filter = gtk_entry_get_text(GTK_ENTRY(entry)); | 98 | const gchar *filter = gtk_entry_get_text(GTK_ENTRY(entry)); |
@@ -152,6 +158,8 @@ static void | |||
152 | handle_emoji_search_entry_search_changed(GtkSearchEntry *entry, | 158 | handle_emoji_search_entry_search_changed(GtkSearchEntry *entry, |
153 | gpointer user_data) | 159 | gpointer user_data) |
154 | { | 160 | { |
161 | g_assert((entry) && (user_data)); | ||
162 | |||
155 | UI_PICKER_Handle *handle = (UI_PICKER_Handle*) user_data; | 163 | UI_PICKER_Handle *handle = (UI_PICKER_Handle*) user_data; |
156 | 164 | ||
157 | gtk_container_foreach( | 165 | gtk_container_foreach( |
@@ -213,6 +221,8 @@ static void | |||
213 | handle_search_button_click(UNUSED GtkButton *button, | 221 | handle_search_button_click(UNUSED GtkButton *button, |
214 | gpointer user_data) | 222 | gpointer user_data) |
215 | { | 223 | { |
224 | g_assert(user_data); | ||
225 | |||
216 | UI_PICKER_Handle *handle = (UI_PICKER_Handle*) user_data; | 226 | UI_PICKER_Handle *handle = (UI_PICKER_Handle*) user_data; |
217 | 227 | ||
218 | const gchar* picked = gtk_stack_get_visible_child_name(handle->picker_stack); | 228 | const gchar* picked = gtk_stack_get_visible_child_name(handle->picker_stack); |
@@ -233,6 +243,8 @@ static void | |||
233 | handle_settings_button_click(UNUSED GtkButton *button, | 243 | handle_settings_button_click(UNUSED GtkButton *button, |
234 | UNUSED gpointer user_data) | 244 | UNUSED gpointer user_data) |
235 | { | 245 | { |
246 | // g_assert(user_data); | ||
247 | |||
236 | // MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 248 | // MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
237 | // TODO | 249 | // TODO |
238 | } | 250 | } |
@@ -241,6 +253,8 @@ UI_PICKER_Handle* | |||
241 | ui_picker_new(MESSENGER_Application *app, | 253 | ui_picker_new(MESSENGER_Application *app, |
242 | UI_CHAT_Handle *chat) | 254 | UI_CHAT_Handle *chat) |
243 | { | 255 | { |
256 | g_assert((app) && (chat)); | ||
257 | |||
244 | UI_PICKER_Handle *handle = g_malloc(sizeof(UI_PICKER_Handle)); | 258 | UI_PICKER_Handle *handle = g_malloc(sizeof(UI_PICKER_Handle)); |
245 | 259 | ||
246 | handle->builder = gtk_builder_new_from_resource( | 260 | handle->builder = gtk_builder_new_from_resource( |
@@ -406,6 +420,8 @@ ui_picker_new(MESSENGER_Application *app, | |||
406 | void | 420 | void |
407 | ui_picker_delete(UI_PICKER_Handle *handle) | 421 | ui_picker_delete(UI_PICKER_Handle *handle) |
408 | { | 422 | { |
423 | g_assert(handle); | ||
424 | |||
409 | hdy_view_switcher_bar_set_stack(handle->picker_switcher_bar, NULL); | 425 | hdy_view_switcher_bar_set_stack(handle->picker_switcher_bar, NULL); |
410 | hdy_view_switcher_bar_set_stack(handle->emoji_switcher_bar, NULL); | 426 | hdy_view_switcher_bar_set_stack(handle->emoji_switcher_bar, NULL); |
411 | 427 | ||
diff --git a/src/ui/picker.h b/src/ui/picker.h index 9c21bc9..f9dd1c3 100644 --- a/src/ui/picker.h +++ b/src/ui/picker.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -68,7 +68,7 @@ typedef struct UI_PICKER_Handle | |||
68 | */ | 68 | */ |
69 | UI_PICKER_Handle* | 69 | UI_PICKER_Handle* |
70 | ui_picker_new(MESSENGER_Application *app, | 70 | ui_picker_new(MESSENGER_Application *app, |
71 | UI_CHAT_Handle *chat); | 71 | UI_CHAT_Handle *chat); |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * Frees its resources and destroys a given picker | 74 | * Frees its resources and destroys a given picker |
diff --git a/src/ui/play_media.c b/src/ui/play_media.c index a2841a4..e8f44b7 100644 --- a/src/ui/play_media.c +++ b/src/ui/play_media.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2022 GNUnet e.V. | 3 | Copyright (C) 2022--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -26,6 +26,7 @@ | |||
26 | 26 | ||
27 | #include "../application.h" | 27 | #include "../application.h" |
28 | #include "../ui.h" | 28 | #include "../ui.h" |
29 | #include "../util.h" | ||
29 | 30 | ||
30 | gboolean | 31 | gboolean |
31 | ui_play_media_window_supports_file_extension(const gchar *filename) | 32 | ui_play_media_window_supports_file_extension(const gchar *filename) |
@@ -49,17 +50,21 @@ ui_play_media_window_supports_file_extension(const gchar *filename) | |||
49 | } | 50 | } |
50 | 51 | ||
51 | static void | 52 | static void |
52 | handle_back_button_click(GtkButton *button, | 53 | handle_back_button_click(UNUSED GtkButton *button, |
53 | gpointer user_data) | 54 | gpointer user_data) |
54 | { | 55 | { |
56 | g_assert(user_data); | ||
57 | |||
55 | GtkWindow *window = GTK_WINDOW(user_data); | 58 | GtkWindow *window = GTK_WINDOW(user_data); |
56 | gtk_window_close(window); | 59 | gtk_window_close(window); |
57 | } | 60 | } |
58 | 61 | ||
59 | static void | 62 | static void |
60 | _set_media_controls_sensivity(UI_PLAY_MEDIA_Handle *handle, | 63 | _set_media_controls_sensivity(UI_PLAY_MEDIA_Handle *handle, |
61 | gboolean sensitive) | 64 | gboolean sensitive) |
62 | { | 65 | { |
66 | g_assert(handle); | ||
67 | |||
63 | if (handle->play_pause_button) | 68 | if (handle->play_pause_button) |
64 | gtk_widget_set_sensitive( | 69 | gtk_widget_set_sensitive( |
65 | GTK_WIDGET(handle->play_pause_button), | 70 | GTK_WIDGET(handle->play_pause_button), |
@@ -81,12 +86,14 @@ _set_media_controls_sensivity(UI_PLAY_MEDIA_Handle *handle, | |||
81 | 86 | ||
82 | static void | 87 | static void |
83 | handle_timeline_scale_value_changed(GtkRange *range, | 88 | handle_timeline_scale_value_changed(GtkRange *range, |
84 | gpointer user_data); | 89 | gpointer user_data); |
85 | 90 | ||
86 | static void | 91 | static void |
87 | _set_signal_connection_of_timeline(UI_PLAY_MEDIA_Handle *handle, | 92 | _set_signal_connection_of_timeline(UI_PLAY_MEDIA_Handle *handle, |
88 | gboolean connected) | 93 | gboolean connected) |
89 | { | 94 | { |
95 | g_assert(handle); | ||
96 | |||
90 | if (!(handle->timeline_scale)) | 97 | if (!(handle->timeline_scale)) |
91 | return; | 98 | return; |
92 | 99 | ||
@@ -95,7 +102,7 @@ _set_signal_connection_of_timeline(UI_PLAY_MEDIA_Handle *handle, | |||
95 | 102 | ||
96 | if (connected) | 103 | if (connected) |
97 | handle->timeline_signal = g_signal_connect( | 104 | handle->timeline_signal = g_signal_connect( |
98 | handle->timeline_scale, | 105 | handle->timeline_scale, |
99 | "value-changed", | 106 | "value-changed", |
100 | G_CALLBACK(handle_timeline_scale_value_changed), | 107 | G_CALLBACK(handle_timeline_scale_value_changed), |
101 | handle | 108 | handle |
@@ -103,8 +110,8 @@ _set_signal_connection_of_timeline(UI_PLAY_MEDIA_Handle *handle, | |||
103 | else | 110 | else |
104 | { | 111 | { |
105 | g_signal_handler_disconnect( | 112 | g_signal_handler_disconnect( |
106 | handle->timeline_scale, | 113 | handle->timeline_scale, |
107 | handle->timeline_signal | 114 | handle->timeline_signal |
108 | ); | 115 | ); |
109 | 116 | ||
110 | handle->timeline_signal = 0; | 117 | handle->timeline_signal = 0; |
@@ -113,10 +120,12 @@ _set_signal_connection_of_timeline(UI_PLAY_MEDIA_Handle *handle, | |||
113 | 120 | ||
114 | static void | 121 | static void |
115 | _set_media_position(UI_PLAY_MEDIA_Handle *handle, | 122 | _set_media_position(UI_PLAY_MEDIA_Handle *handle, |
116 | gint64 pos, | 123 | gint64 pos, |
117 | gint64 len, | 124 | gint64 len, |
118 | gboolean include_scale) | 125 | gboolean include_scale) |
119 | { | 126 | { |
127 | g_assert(handle); | ||
128 | |||
120 | const gdouble position = ( | 129 | const gdouble position = ( |
121 | len > 0? 1.0 * pos / len : 0.0 | 130 | len > 0? 1.0 * pos / len : 0.0 |
122 | ); | 131 | ); |
@@ -163,6 +172,8 @@ _set_media_position(UI_PLAY_MEDIA_Handle *handle, | |||
163 | static gboolean | 172 | static gboolean |
164 | _adjust_playing_media_position(UI_PLAY_MEDIA_Handle *handle) | 173 | _adjust_playing_media_position(UI_PLAY_MEDIA_Handle *handle) |
165 | { | 174 | { |
175 | g_assert(handle); | ||
176 | |||
166 | gint64 pos, len; | 177 | gint64 pos, len; |
167 | 178 | ||
168 | if (!(handle->pipeline)) | 179 | if (!(handle->pipeline)) |
@@ -180,8 +191,10 @@ _adjust_playing_media_position(UI_PLAY_MEDIA_Handle *handle) | |||
180 | 191 | ||
181 | static void | 192 | static void |
182 | _set_timeout_callback_of_timeline(UI_PLAY_MEDIA_Handle *handle, | 193 | _set_timeout_callback_of_timeline(UI_PLAY_MEDIA_Handle *handle, |
183 | gboolean connected) | 194 | gboolean connected) |
184 | { | 195 | { |
196 | g_assert(handle); | ||
197 | |||
185 | if (handle->timeline) | 198 | if (handle->timeline) |
186 | g_source_remove(handle->timeline); | 199 | g_source_remove(handle->timeline); |
187 | 200 | ||
@@ -197,8 +210,10 @@ _set_timeout_callback_of_timeline(UI_PLAY_MEDIA_Handle *handle, | |||
197 | 210 | ||
198 | static void | 211 | static void |
199 | _set_media_state(UI_PLAY_MEDIA_Handle *handle, | 212 | _set_media_state(UI_PLAY_MEDIA_Handle *handle, |
200 | gboolean playing) | 213 | gboolean playing) |
201 | { | 214 | { |
215 | g_assert(handle); | ||
216 | |||
202 | if (handle->play_symbol_stack) | 217 | if (handle->play_symbol_stack) |
203 | gtk_stack_set_visible_child_name( | 218 | gtk_stack_set_visible_child_name( |
204 | handle->play_symbol_stack, | 219 | handle->play_symbol_stack, |
@@ -210,9 +225,9 @@ _set_media_state(UI_PLAY_MEDIA_Handle *handle, | |||
210 | 225 | ||
211 | static void | 226 | static void |
212 | _disable_video_processing(UI_PLAY_MEDIA_Handle *handle, | 227 | _disable_video_processing(UI_PLAY_MEDIA_Handle *handle, |
213 | gboolean drop_pipeline) | 228 | gboolean drop_pipeline) |
214 | { | 229 | { |
215 | GNUNET_assert(handle); | 230 | g_assert(handle); |
216 | 231 | ||
217 | if (handle->preview_stack) | 232 | if (handle->preview_stack) |
218 | gtk_stack_set_visible_child(handle->preview_stack, handle->fail_box); | 233 | gtk_stack_set_visible_child(handle->preview_stack, handle->fail_box); |
@@ -437,16 +452,20 @@ handle_media_motion_notify(GtkWidget *widget, | |||
437 | 452 | ||
438 | static void | 453 | static void |
439 | handle_window_destroy(UNUSED GtkWidget *window, | 454 | handle_window_destroy(UNUSED GtkWidget *window, |
440 | gpointer user_data) | 455 | gpointer user_data) |
441 | { | 456 | { |
457 | g_assert(user_data); | ||
458 | |||
442 | ui_play_media_window_cleanup((UI_PLAY_MEDIA_Handle*) user_data); | 459 | ui_play_media_window_cleanup((UI_PLAY_MEDIA_Handle*) user_data); |
443 | } | 460 | } |
444 | 461 | ||
445 | static void | 462 | static void |
446 | msg_error_cb(UNUSED GstBus *bus, | 463 | msg_error_cb(UNUSED GstBus *bus, |
447 | GstMessage *msg, | 464 | GstMessage *msg, |
448 | gpointer data) | 465 | gpointer data) |
449 | { | 466 | { |
467 | g_assert((msg) && (data)); | ||
468 | |||
450 | UI_PLAY_MEDIA_Handle *handle = (UI_PLAY_MEDIA_Handle*) data; | 469 | UI_PLAY_MEDIA_Handle *handle = (UI_PLAY_MEDIA_Handle*) data; |
451 | 470 | ||
452 | GError* error; | 471 | GError* error; |
@@ -464,9 +483,11 @@ msg_error_cb(UNUSED GstBus *bus, | |||
464 | 483 | ||
465 | static void | 484 | static void |
466 | msg_eos_cb(UNUSED GstBus *bus, | 485 | msg_eos_cb(UNUSED GstBus *bus, |
467 | UNUSED GstMessage *msg, | 486 | UNUSED GstMessage *msg, |
468 | gpointer data) | 487 | gpointer data) |
469 | { | 488 | { |
489 | g_assert(data); | ||
490 | |||
470 | UI_PLAY_MEDIA_Handle *handle = (UI_PLAY_MEDIA_Handle*) data; | 491 | UI_PLAY_MEDIA_Handle *handle = (UI_PLAY_MEDIA_Handle*) data; |
471 | 492 | ||
472 | if (GST_MESSAGE_SRC(msg) != GST_OBJECT(handle->pipeline)) | 493 | if (GST_MESSAGE_SRC(msg) != GST_OBJECT(handle->pipeline)) |
@@ -480,9 +501,11 @@ msg_eos_cb(UNUSED GstBus *bus, | |||
480 | 501 | ||
481 | static void | 502 | static void |
482 | msg_state_changed_cb(UNUSED GstBus *bus, | 503 | msg_state_changed_cb(UNUSED GstBus *bus, |
483 | GstMessage *msg, | 504 | GstMessage *msg, |
484 | gpointer data) | 505 | gpointer data) |
485 | { | 506 | { |
507 | g_assert((msg) && (data)); | ||
508 | |||
486 | UI_PLAY_MEDIA_Handle *handle = (UI_PLAY_MEDIA_Handle*) data; | 509 | UI_PLAY_MEDIA_Handle *handle = (UI_PLAY_MEDIA_Handle*) data; |
487 | 510 | ||
488 | GstState old_state, new_state, pending_state; | 511 | GstState old_state, new_state, pending_state; |
@@ -508,9 +531,11 @@ msg_state_changed_cb(UNUSED GstBus *bus, | |||
508 | 531 | ||
509 | static void | 532 | static void |
510 | msg_buffering_cb(UNUSED GstBus *bus, | 533 | msg_buffering_cb(UNUSED GstBus *bus, |
511 | GstMessage *msg, | 534 | GstMessage *msg, |
512 | gpointer data) | 535 | gpointer data) |
513 | { | 536 | { |
537 | g_assert((msg) && (data)); | ||
538 | |||
514 | UI_PLAY_MEDIA_Handle *handle = (UI_PLAY_MEDIA_Handle*) data; | 539 | UI_PLAY_MEDIA_Handle *handle = (UI_PLAY_MEDIA_Handle*) data; |
515 | 540 | ||
516 | gint percent = 0; | 541 | gint percent = 0; |
@@ -528,6 +553,8 @@ msg_buffering_cb(UNUSED GstBus *bus, | |||
528 | static void | 553 | static void |
529 | _setup_gst_pipeline(UI_PLAY_MEDIA_Handle *handle) | 554 | _setup_gst_pipeline(UI_PLAY_MEDIA_Handle *handle) |
530 | { | 555 | { |
556 | g_assert(handle); | ||
557 | |||
531 | handle->pipeline = gst_element_factory_make("playbin", NULL); | 558 | handle->pipeline = gst_element_factory_make("playbin", NULL); |
532 | 559 | ||
533 | if (!(handle->pipeline)) | 560 | if (!(handle->pipeline)) |
@@ -586,6 +613,8 @@ _setup_gst_pipeline(UI_PLAY_MEDIA_Handle *handle) | |||
586 | static void* | 613 | static void* |
587 | _ui_play_media_video_thread(void *args) | 614 | _ui_play_media_video_thread(void *args) |
588 | { | 615 | { |
616 | g_assert(args); | ||
617 | |||
589 | UI_PLAY_MEDIA_Handle *handle = (UI_PLAY_MEDIA_Handle*) args; | 618 | UI_PLAY_MEDIA_Handle *handle = (UI_PLAY_MEDIA_Handle*) args; |
590 | _continue_playing_media(handle); | 619 | _continue_playing_media(handle); |
591 | return NULL; | 620 | return NULL; |
@@ -593,67 +622,67 @@ _ui_play_media_video_thread(void *args) | |||
593 | 622 | ||
594 | void | 623 | void |
595 | ui_play_media_window_init(MESSENGER_Application *app, | 624 | ui_play_media_window_init(MESSENGER_Application *app, |
596 | UI_PLAY_MEDIA_Handle *handle) | 625 | UI_PLAY_MEDIA_Handle *handle) |
597 | { | 626 | { |
598 | GNUNET_assert((app) && (handle)); | 627 | g_assert((app) && (handle)); |
599 | 628 | ||
600 | _setup_gst_pipeline(handle); | 629 | _setup_gst_pipeline(handle); |
601 | 630 | ||
602 | handle->parent = GTK_WINDOW(app->ui.messenger.main_window); | 631 | handle->parent = GTK_WINDOW(app->ui.messenger.main_window); |
603 | 632 | ||
604 | handle->builder = gtk_builder_new_from_resource( | 633 | handle->builder = gtk_builder_new_from_resource( |
605 | application_get_resource_path(app, "ui/play_media.ui") | 634 | application_get_resource_path(app, "ui/play_media.ui") |
606 | ); | 635 | ); |
607 | 636 | ||
608 | handle->window = HDY_WINDOW( | 637 | handle->window = HDY_WINDOW( |
609 | gtk_builder_get_object(handle->builder, "play_media_window") | 638 | gtk_builder_get_object(handle->builder, "play_media_window") |
610 | ); | 639 | ); |
611 | 640 | ||
612 | gtk_window_set_position( | 641 | gtk_window_set_position( |
613 | GTK_WINDOW(handle->window), | 642 | GTK_WINDOW(handle->window), |
614 | GTK_WIN_POS_CENTER_ON_PARENT | 643 | GTK_WIN_POS_CENTER_ON_PARENT |
615 | ); | 644 | ); |
616 | 645 | ||
617 | gtk_window_set_transient_for( | 646 | gtk_window_set_transient_for( |
618 | GTK_WINDOW(handle->window), | 647 | GTK_WINDOW(handle->window), |
619 | handle->parent | 648 | handle->parent |
620 | ); | 649 | ); |
621 | 650 | ||
622 | handle->header_revealer = GTK_REVEALER( | 651 | handle->header_revealer = GTK_REVEALER( |
623 | gtk_builder_get_object(handle->builder, "header_revealer") | 652 | gtk_builder_get_object(handle->builder, "header_revealer") |
624 | ); | 653 | ); |
625 | 654 | ||
626 | handle->title_bar = HDY_HEADER_BAR( | 655 | handle->title_bar = HDY_HEADER_BAR( |
627 | gtk_builder_get_object(handle->builder, "title_bar") | 656 | gtk_builder_get_object(handle->builder, "title_bar") |
628 | ); | 657 | ); |
629 | 658 | ||
630 | hdy_header_bar_set_title(handle->title_bar, _("Play Media")); | 659 | hdy_header_bar_set_title(handle->title_bar, _("Play Media")); |
631 | 660 | ||
632 | handle->back_button = GTK_BUTTON( | 661 | handle->back_button = GTK_BUTTON( |
633 | gtk_builder_get_object(handle->builder, "back_button") | 662 | gtk_builder_get_object(handle->builder, "back_button") |
634 | ); | 663 | ); |
635 | 664 | ||
636 | g_signal_connect( | 665 | g_signal_connect( |
637 | handle->back_button, | 666 | handle->back_button, |
638 | "clicked", | 667 | "clicked", |
639 | G_CALLBACK(handle_back_button_click), | 668 | G_CALLBACK(handle_back_button_click), |
640 | handle->window | 669 | handle->window |
641 | ); | 670 | ); |
642 | 671 | ||
643 | handle->controls_flap = HDY_FLAP( | 672 | handle->controls_flap = HDY_FLAP( |
644 | gtk_builder_get_object(handle->builder, "controls_flap") | 673 | gtk_builder_get_object(handle->builder, "controls_flap") |
645 | ); | 674 | ); |
646 | 675 | ||
647 | handle->preview_stack = GTK_STACK( | 676 | handle->preview_stack = GTK_STACK( |
648 | gtk_builder_get_object(handle->builder, "preview_stack") | 677 | gtk_builder_get_object(handle->builder, "preview_stack") |
649 | ); | 678 | ); |
650 | 679 | ||
651 | handle->fail_box = GTK_WIDGET( | 680 | handle->fail_box = GTK_WIDGET( |
652 | gtk_builder_get_object(handle->builder, "fail_box") | 681 | gtk_builder_get_object(handle->builder, "fail_box") |
653 | ); | 682 | ); |
654 | 683 | ||
655 | handle->video_box = GTK_WIDGET( | 684 | handle->video_box = GTK_WIDGET( |
656 | gtk_builder_get_object(handle->builder, "video_box") | 685 | gtk_builder_get_object(handle->builder, "video_box") |
657 | ); | 686 | ); |
658 | 687 | ||
659 | GtkWidget *widget; | 688 | GtkWidget *widget; |
@@ -679,87 +708,87 @@ ui_play_media_window_init(MESSENGER_Application *app, | |||
679 | } | 708 | } |
680 | 709 | ||
681 | handle->play_pause_button = GTK_BUTTON( | 710 | handle->play_pause_button = GTK_BUTTON( |
682 | gtk_builder_get_object(handle->builder, "play_pause_button") | 711 | gtk_builder_get_object(handle->builder, "play_pause_button") |
683 | ); | 712 | ); |
684 | 713 | ||
685 | handle->play_symbol_stack = GTK_STACK( | 714 | handle->play_symbol_stack = GTK_STACK( |
686 | gtk_builder_get_object(handle->builder, "play_symbol_stack") | 715 | gtk_builder_get_object(handle->builder, "play_symbol_stack") |
687 | ); | 716 | ); |
688 | 717 | ||
689 | g_signal_connect( | 718 | g_signal_connect( |
690 | handle->play_pause_button, | 719 | handle->play_pause_button, |
691 | "clicked", | 720 | "clicked", |
692 | G_CALLBACK(handle_play_pause_button_click), | 721 | G_CALLBACK(handle_play_pause_button_click), |
693 | handle | 722 | handle |
694 | ); | 723 | ); |
695 | 724 | ||
696 | handle->volume_button = GTK_VOLUME_BUTTON( | 725 | handle->volume_button = GTK_VOLUME_BUTTON( |
697 | gtk_builder_get_object(handle->builder, "volume_button") | 726 | gtk_builder_get_object(handle->builder, "volume_button") |
698 | ); | 727 | ); |
699 | 728 | ||
700 | g_signal_connect( | 729 | g_signal_connect( |
701 | handle->volume_button, | 730 | handle->volume_button, |
702 | "value-changed", | 731 | "value-changed", |
703 | G_CALLBACK(handle_volume_button_value_changed), | 732 | G_CALLBACK(handle_volume_button_value_changed), |
704 | handle | 733 | handle |
705 | ); | 734 | ); |
706 | 735 | ||
707 | handle->timeline_label = GTK_LABEL( | 736 | handle->timeline_label = GTK_LABEL( |
708 | gtk_builder_get_object(handle->builder, "timeline_label") | 737 | gtk_builder_get_object(handle->builder, "timeline_label") |
709 | ); | 738 | ); |
710 | 739 | ||
711 | handle->timeline_progress_bar = GTK_PROGRESS_BAR( | 740 | handle->timeline_progress_bar = GTK_PROGRESS_BAR( |
712 | gtk_builder_get_object(handle->builder, "timeline_progress_bar") | 741 | gtk_builder_get_object(handle->builder, "timeline_progress_bar") |
713 | ); | 742 | ); |
714 | 743 | ||
715 | handle->timeline_scale = GTK_SCALE( | 744 | handle->timeline_scale = GTK_SCALE( |
716 | gtk_builder_get_object(handle->builder, "timeline_scale") | 745 | gtk_builder_get_object(handle->builder, "timeline_scale") |
717 | ); | 746 | ); |
718 | 747 | ||
719 | _set_signal_connection_of_timeline(handle, handle->sink? TRUE : FALSE); | 748 | _set_signal_connection_of_timeline(handle, handle->sink? TRUE : FALSE); |
720 | 749 | ||
721 | handle->settings_button = GTK_BUTTON( | 750 | handle->settings_button = GTK_BUTTON( |
722 | gtk_builder_get_object(handle->builder, "settings_button") | 751 | gtk_builder_get_object(handle->builder, "settings_button") |
723 | ); | 752 | ); |
724 | 753 | ||
725 | handle->fullscreen_button = GTK_BUTTON( | 754 | handle->fullscreen_button = GTK_BUTTON( |
726 | gtk_builder_get_object(handle->builder, "fullscreen_button") | 755 | gtk_builder_get_object(handle->builder, "fullscreen_button") |
727 | ); | 756 | ); |
728 | 757 | ||
729 | handle->fullscreen_symbol_stack = GTK_STACK( | 758 | handle->fullscreen_symbol_stack = GTK_STACK( |
730 | gtk_builder_get_object(handle->builder, "fullscreen_symbol_stack") | 759 | gtk_builder_get_object(handle->builder, "fullscreen_symbol_stack") |
731 | ); | 760 | ); |
732 | 761 | ||
733 | g_signal_connect( | 762 | g_signal_connect( |
734 | handle->fullscreen_button, | 763 | handle->fullscreen_button, |
735 | "clicked", | 764 | "clicked", |
736 | G_CALLBACK(handle_fullscreen_button_click), | 765 | G_CALLBACK(handle_fullscreen_button_click), |
737 | handle | 766 | handle |
738 | ); | 767 | ); |
739 | 768 | ||
740 | g_signal_connect( | 769 | g_signal_connect( |
741 | handle->window, | 770 | handle->window, |
742 | "motion-notify-event", | 771 | "motion-notify-event", |
743 | G_CALLBACK(handle_media_motion_notify), | 772 | G_CALLBACK(handle_media_motion_notify), |
744 | handle | 773 | handle |
745 | ); | 774 | ); |
746 | 775 | ||
747 | gtk_widget_add_events( | 776 | gtk_widget_add_events( |
748 | GTK_WIDGET(handle->window), | 777 | GTK_WIDGET(handle->window), |
749 | GDK_POINTER_MOTION_HINT_MASK | | 778 | GDK_POINTER_MOTION_HINT_MASK | |
750 | GDK_POINTER_MOTION_MASK | 779 | GDK_POINTER_MOTION_MASK |
751 | ); | 780 | ); |
752 | 781 | ||
753 | g_signal_connect( | 782 | g_signal_connect( |
754 | handle->window, | 783 | handle->window, |
755 | "destroy", | 784 | "destroy", |
756 | G_CALLBACK(handle_window_destroy), | 785 | G_CALLBACK(handle_window_destroy), |
757 | handle | 786 | handle |
758 | ); | 787 | ); |
759 | 788 | ||
760 | gtk_scale_button_set_value( | 789 | gtk_scale_button_set_value( |
761 | GTK_SCALE_BUTTON(handle->volume_button), | 790 | GTK_SCALE_BUTTON(handle->volume_button), |
762 | 1.0 | 791 | 1.0 |
763 | ); | 792 | ); |
764 | 793 | ||
765 | gtk_widget_show_all(GTK_WIDGET(handle->window)); | 794 | gtk_widget_show_all(GTK_WIDGET(handle->window)); |
@@ -770,7 +799,7 @@ ui_play_media_window_update(UI_PLAY_MEDIA_Handle *handle, | |||
770 | const gchar *uri, | 799 | const gchar *uri, |
771 | const struct GNUNET_CHAT_File *file) | 800 | const struct GNUNET_CHAT_File *file) |
772 | { | 801 | { |
773 | GNUNET_assert((handle) && (uri)); | 802 | g_assert((handle) && (uri)); |
774 | 803 | ||
775 | if (handle->video_tid) | 804 | if (handle->video_tid) |
776 | pthread_join(handle->video_tid, NULL); | 805 | pthread_join(handle->video_tid, NULL); |
@@ -789,22 +818,22 @@ ui_play_media_window_update(UI_PLAY_MEDIA_Handle *handle, | |||
789 | filename = uri; | 818 | filename = uri; |
790 | 819 | ||
791 | hdy_header_bar_set_subtitle( | 820 | hdy_header_bar_set_subtitle( |
792 | handle->title_bar, | 821 | handle->title_bar, |
793 | filename? filename : "" | 822 | filename? filename : "" |
794 | ); | 823 | ); |
795 | 824 | ||
796 | pthread_create( | 825 | pthread_create( |
797 | &(handle->video_tid), | 826 | &(handle->video_tid), |
798 | NULL, | 827 | NULL, |
799 | _ui_play_media_video_thread, | 828 | _ui_play_media_video_thread, |
800 | handle | 829 | handle |
801 | ); | 830 | ); |
802 | } | 831 | } |
803 | 832 | ||
804 | void | 833 | void |
805 | ui_play_media_window_cleanup(UI_PLAY_MEDIA_Handle *handle) | 834 | ui_play_media_window_cleanup(UI_PLAY_MEDIA_Handle *handle) |
806 | { | 835 | { |
807 | GNUNET_assert(handle); | 836 | g_assert(handle); |
808 | 837 | ||
809 | if (handle->video_tid) | 838 | if (handle->video_tid) |
810 | pthread_join(handle->video_tid, NULL); | 839 | pthread_join(handle->video_tid, NULL); |
diff --git a/src/ui/play_media.h b/src/ui/play_media.h index 0efb78d..2b4b919 100644 --- a/src/ui/play_media.h +++ b/src/ui/play_media.h | |||
@@ -94,7 +94,7 @@ ui_play_media_window_supports_file_extension(const gchar *filename); | |||
94 | */ | 94 | */ |
95 | void | 95 | void |
96 | ui_play_media_window_init(MESSENGER_Application *app, | 96 | ui_play_media_window_init(MESSENGER_Application *app, |
97 | UI_PLAY_MEDIA_Handle *handle); | 97 | UI_PLAY_MEDIA_Handle *handle); |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * Updates a handle for the play media window with | 100 | * Updates a handle for the play media window with |
@@ -106,8 +106,8 @@ ui_play_media_window_init(MESSENGER_Application *app, | |||
106 | */ | 106 | */ |
107 | void | 107 | void |
108 | ui_play_media_window_update(UI_PLAY_MEDIA_Handle *handle, | 108 | ui_play_media_window_update(UI_PLAY_MEDIA_Handle *handle, |
109 | const gchar *uri, | 109 | const gchar *uri, |
110 | const struct GNUNET_CHAT_File *file); | 110 | const struct GNUNET_CHAT_File *file); |
111 | 111 | ||
112 | /** | 112 | /** |
113 | * Cleans up the allocated resources and resets the | 113 | * Cleans up the allocated resources and resets the |
diff --git a/src/ui/send_file.c b/src/ui/send_file.c index 52fee25..632201b 100644 --- a/src/ui/send_file.c +++ b/src/ui/send_file.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -30,22 +30,25 @@ | |||
30 | 30 | ||
31 | #include "../application.h" | 31 | #include "../application.h" |
32 | #include "../file.h" | 32 | #include "../file.h" |
33 | #include "../ui.h" | ||
34 | 33 | ||
35 | static void | 34 | static void |
36 | handle_cancel_button_click(UNUSED GtkButton *button, | 35 | handle_cancel_button_click(UNUSED GtkButton *button, |
37 | gpointer user_data) | 36 | gpointer user_data) |
38 | { | 37 | { |
38 | g_assert(user_data); | ||
39 | |||
39 | GtkDialog *dialog = GTK_DIALOG(user_data); | 40 | GtkDialog *dialog = GTK_DIALOG(user_data); |
40 | gtk_window_close(GTK_WINDOW(dialog)); | 41 | gtk_window_close(GTK_WINDOW(dialog)); |
41 | } | 42 | } |
42 | 43 | ||
43 | static void | 44 | static void |
44 | handle_sending_upload_file(UNUSED void *cls, | 45 | handle_sending_upload_file(UNUSED void *cls, |
45 | const struct GNUNET_CHAT_File *file, | 46 | const struct GNUNET_CHAT_File *file, |
46 | uint64_t completed, | 47 | uint64_t completed, |
47 | uint64_t size) | 48 | uint64_t size) |
48 | { | 49 | { |
50 | g_assert(file); | ||
51 | |||
49 | UI_FILE_LOAD_ENTRY_Handle *file_load = cls; | 52 | UI_FILE_LOAD_ENTRY_Handle *file_load = cls; |
50 | 53 | ||
51 | gtk_progress_bar_set_fraction( | 54 | gtk_progress_bar_set_fraction( |
@@ -61,26 +64,28 @@ handle_sending_upload_file(UNUSED void *cls, | |||
61 | 64 | ||
62 | static void | 65 | static void |
63 | handle_send_button_click(GtkButton *button, | 66 | handle_send_button_click(GtkButton *button, |
64 | gpointer user_data) | 67 | gpointer user_data) |
65 | { | 68 | { |
69 | g_assert((button) && (user_data)); | ||
70 | |||
66 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 71 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
67 | 72 | ||
68 | GtkTextView *text_view = GTK_TEXT_VIEW( | 73 | GtkTextView *text_view = GTK_TEXT_VIEW( |
69 | g_object_get_qdata(G_OBJECT(button), app->quarks.widget) | 74 | g_object_get_qdata(G_OBJECT(button), app->quarks.widget) |
70 | ); | 75 | ); |
71 | 76 | ||
72 | if (!text_view) | 77 | if (!text_view) |
73 | return; | 78 | return; |
74 | 79 | ||
75 | gchar *filename = gtk_file_chooser_get_filename( | 80 | gchar *filename = gtk_file_chooser_get_filename( |
76 | GTK_FILE_CHOOSER(app->ui.send_file.file_chooser_button) | 81 | GTK_FILE_CHOOSER(app->ui.send_file.file_chooser_button) |
77 | ); | 82 | ); |
78 | 83 | ||
79 | if (!filename) | 84 | if (!filename) |
80 | return; | 85 | return; |
81 | 86 | ||
82 | struct GNUNET_CHAT_Context *context = (struct GNUNET_CHAT_Context*) ( | 87 | struct GNUNET_CHAT_Context *context = (struct GNUNET_CHAT_Context*) ( |
83 | g_object_get_qdata(G_OBJECT(text_view), app->quarks.data) | 88 | g_object_get_qdata(G_OBJECT(text_view), app->quarks.data) |
84 | ); | 89 | ); |
85 | 90 | ||
86 | UI_CHAT_ENTRY_Handle *entry = GNUNET_CHAT_context_get_user_pointer(context); | 91 | UI_CHAT_ENTRY_Handle *entry = GNUNET_CHAT_context_get_user_pointer(context); |
@@ -97,10 +102,10 @@ handle_send_button_click(GtkButton *button, | |||
97 | gtk_progress_bar_set_fraction(file_load->load_progress_bar, 0.0); | 102 | gtk_progress_bar_set_fraction(file_load->load_progress_bar, 0.0); |
98 | 103 | ||
99 | file = GNUNET_CHAT_context_send_file( | 104 | file = GNUNET_CHAT_context_send_file( |
100 | context, | 105 | context, |
101 | filename, | 106 | filename, |
102 | handle_sending_upload_file, | 107 | handle_sending_upload_file, |
103 | file_load | 108 | file_load |
104 | ); | 109 | ); |
105 | } | 110 | } |
106 | 111 | ||
@@ -123,14 +128,18 @@ handle_send_button_click(GtkButton *button, | |||
123 | 128 | ||
124 | static void | 129 | static void |
125 | handle_dialog_destroy(UNUSED GtkWidget *window, | 130 | handle_dialog_destroy(UNUSED GtkWidget *window, |
126 | gpointer user_data) | 131 | gpointer user_data) |
127 | { | 132 | { |
133 | g_assert(user_data); | ||
134 | |||
128 | ui_send_file_dialog_cleanup((UI_SEND_FILE_Handle*) user_data); | 135 | ui_send_file_dialog_cleanup((UI_SEND_FILE_Handle*) user_data); |
129 | } | 136 | } |
130 | 137 | ||
131 | static int | 138 | static int |
132 | handle_file_redraw_animation(gpointer user_data) | 139 | handle_file_redraw_animation(gpointer user_data) |
133 | { | 140 | { |
141 | g_assert(user_data); | ||
142 | |||
134 | UI_SEND_FILE_Handle *handle = (UI_SEND_FILE_Handle*) user_data; | 143 | UI_SEND_FILE_Handle *handle = (UI_SEND_FILE_Handle*) user_data; |
135 | 144 | ||
136 | handle->redraw_animation = 0; | 145 | handle->redraw_animation = 0; |
@@ -144,9 +153,11 @@ handle_file_redraw_animation(gpointer user_data) | |||
144 | 153 | ||
145 | static gboolean | 154 | static gboolean |
146 | handle_file_drawing_area_draw(GtkWidget* drawing_area, | 155 | handle_file_drawing_area_draw(GtkWidget* drawing_area, |
147 | cairo_t* cairo, | 156 | cairo_t* cairo, |
148 | gpointer user_data) | 157 | gpointer user_data) |
149 | { | 158 | { |
159 | g_assert((drawing_area) && (cairo) && (user_data)); | ||
160 | |||
150 | UI_SEND_FILE_Handle *handle = (UI_SEND_FILE_Handle*) user_data; | 161 | UI_SEND_FILE_Handle *handle = (UI_SEND_FILE_Handle*) user_data; |
151 | 162 | ||
152 | GtkStyleContext* context = gtk_widget_get_style_context(drawing_area); | 163 | GtkStyleContext* context = gtk_widget_get_style_context(drawing_area); |
@@ -165,17 +176,17 @@ handle_file_drawing_area_draw(GtkWidget* drawing_area, | |||
165 | gdk_pixbuf_animation_iter_advance(handle->animation_iter, NULL); | 176 | gdk_pixbuf_animation_iter_advance(handle->animation_iter, NULL); |
166 | else | 177 | else |
167 | handle->animation_iter = gdk_pixbuf_animation_get_iter( | 178 | handle->animation_iter = gdk_pixbuf_animation_get_iter( |
168 | handle->animation, NULL | 179 | handle->animation, NULL |
169 | ); | 180 | ); |
170 | 181 | ||
171 | image = gdk_pixbuf_animation_iter_get_pixbuf(handle->animation_iter); | 182 | image = gdk_pixbuf_animation_iter_get_pixbuf(handle->animation_iter); |
172 | 183 | ||
173 | const int delay = gdk_pixbuf_animation_iter_get_delay_time( | 184 | const int delay = gdk_pixbuf_animation_iter_get_delay_time( |
174 | handle->animation_iter | 185 | handle->animation_iter |
175 | ); | 186 | ); |
176 | 187 | ||
177 | handle->redraw_animation = g_timeout_add( | 188 | handle->redraw_animation = g_timeout_add( |
178 | delay, handle_file_redraw_animation, handle | 189 | delay, handle_file_redraw_animation, handle |
179 | ); | 190 | ); |
180 | 191 | ||
181 | render_image: | 192 | render_image: |
@@ -197,15 +208,15 @@ render_image: | |||
197 | double dy = (height - dheight) * 0.5; | 208 | double dy = (height - dheight) * 0.5; |
198 | 209 | ||
199 | const int interp_type = (ratio >= 1.0? | 210 | const int interp_type = (ratio >= 1.0? |
200 | GDK_INTERP_NEAREST : | 211 | GDK_INTERP_NEAREST : |
201 | GDK_INTERP_BILINEAR | 212 | GDK_INTERP_BILINEAR |
202 | ); | 213 | ); |
203 | 214 | ||
204 | GdkPixbuf* scaled = gdk_pixbuf_scale_simple( | 215 | GdkPixbuf* scaled = gdk_pixbuf_scale_simple( |
205 | image, | 216 | image, |
206 | dwidth, | 217 | dwidth, |
207 | dheight, | 218 | dheight, |
208 | interp_type | 219 | interp_type |
209 | ); | 220 | ); |
210 | 221 | ||
211 | gtk_render_icon(context, cairo, scaled, dx, dy); | 222 | gtk_render_icon(context, cairo, scaled, dx, dy); |
@@ -219,6 +230,8 @@ render_image: | |||
219 | static void | 230 | static void |
220 | _clear_file_preview_data(UI_SEND_FILE_Handle *handle) | 231 | _clear_file_preview_data(UI_SEND_FILE_Handle *handle) |
221 | { | 232 | { |
233 | g_assert(handle); | ||
234 | |||
222 | if (handle->image) | 235 | if (handle->image) |
223 | { | 236 | { |
224 | g_object_unref(handle->image); | 237 | g_object_unref(handle->image); |
@@ -246,8 +259,10 @@ _clear_file_preview_data(UI_SEND_FILE_Handle *handle) | |||
246 | 259 | ||
247 | static void | 260 | static void |
248 | handle_file_chooser_button_file_set(GtkFileChooserButton *file_chooser_button, | 261 | handle_file_chooser_button_file_set(GtkFileChooserButton *file_chooser_button, |
249 | gpointer user_data) | 262 | gpointer user_data) |
250 | { | 263 | { |
264 | g_assert((file_chooser_button) && (user_data)); | ||
265 | |||
251 | UI_SEND_FILE_Handle *handle = (UI_SEND_FILE_Handle*) user_data; | 266 | UI_SEND_FILE_Handle *handle = (UI_SEND_FILE_Handle*) user_data; |
252 | 267 | ||
253 | _clear_file_preview_data(handle); | 268 | _clear_file_preview_data(handle); |
@@ -272,75 +287,77 @@ handle_file_chooser_button_file_set(GtkFileChooserButton *file_chooser_button, | |||
272 | 287 | ||
273 | void | 288 | void |
274 | ui_send_file_dialog_init(MESSENGER_Application *app, | 289 | ui_send_file_dialog_init(MESSENGER_Application *app, |
275 | UI_SEND_FILE_Handle *handle) | 290 | UI_SEND_FILE_Handle *handle) |
276 | { | 291 | { |
292 | g_assert((app) && (handle)); | ||
293 | |||
277 | handle->builder = gtk_builder_new_from_resource( | 294 | handle->builder = gtk_builder_new_from_resource( |
278 | application_get_resource_path(app, "ui/send_file.ui") | 295 | application_get_resource_path(app, "ui/send_file.ui") |
279 | ); | 296 | ); |
280 | 297 | ||
281 | handle->dialog = GTK_DIALOG( | 298 | handle->dialog = GTK_DIALOG( |
282 | gtk_builder_get_object(handle->builder, "send_file_dialog") | 299 | gtk_builder_get_object(handle->builder, "send_file_dialog") |
283 | ); | 300 | ); |
284 | 301 | ||
285 | gtk_window_set_title( | 302 | gtk_window_set_title( |
286 | GTK_WINDOW(handle->dialog), | 303 | GTK_WINDOW(handle->dialog), |
287 | _("Send File") | 304 | _("Send File") |
288 | ); | 305 | ); |
289 | 306 | ||
290 | gtk_window_set_transient_for( | 307 | gtk_window_set_transient_for( |
291 | GTK_WINDOW(handle->dialog), | 308 | GTK_WINDOW(handle->dialog), |
292 | GTK_WINDOW(app->ui.messenger.main_window) | 309 | GTK_WINDOW(app->ui.messenger.main_window) |
293 | ); | 310 | ); |
294 | 311 | ||
295 | handle->file_drawing_area = GTK_DRAWING_AREA( | 312 | handle->file_drawing_area = GTK_DRAWING_AREA( |
296 | gtk_builder_get_object(handle->builder, "file_drawing_area") | 313 | gtk_builder_get_object(handle->builder, "file_drawing_area") |
297 | ); | 314 | ); |
298 | 315 | ||
299 | handle->file_chooser_button = GTK_FILE_CHOOSER_BUTTON( | 316 | handle->file_chooser_button = GTK_FILE_CHOOSER_BUTTON( |
300 | gtk_builder_get_object(handle->builder, "file_chooser_button") | 317 | gtk_builder_get_object(handle->builder, "file_chooser_button") |
301 | ); | 318 | ); |
302 | 319 | ||
303 | handle->file_draw_signal = g_signal_connect( | 320 | handle->file_draw_signal = g_signal_connect( |
304 | handle->file_drawing_area, | 321 | handle->file_drawing_area, |
305 | "draw", | 322 | "draw", |
306 | G_CALLBACK(handle_file_drawing_area_draw), | 323 | G_CALLBACK(handle_file_drawing_area_draw), |
307 | handle | 324 | handle |
308 | ); | 325 | ); |
309 | 326 | ||
310 | g_signal_connect( | 327 | g_signal_connect( |
311 | handle->file_chooser_button, | 328 | handle->file_chooser_button, |
312 | "file-set", | 329 | "file-set", |
313 | G_CALLBACK(handle_file_chooser_button_file_set), | 330 | G_CALLBACK(handle_file_chooser_button_file_set), |
314 | handle | 331 | handle |
315 | ); | 332 | ); |
316 | 333 | ||
317 | handle->cancel_button = GTK_BUTTON( | 334 | handle->cancel_button = GTK_BUTTON( |
318 | gtk_builder_get_object(handle->builder, "cancel_button") | 335 | gtk_builder_get_object(handle->builder, "cancel_button") |
319 | ); | 336 | ); |
320 | 337 | ||
321 | g_signal_connect( | 338 | g_signal_connect( |
322 | handle->cancel_button, | 339 | handle->cancel_button, |
323 | "clicked", | 340 | "clicked", |
324 | G_CALLBACK(handle_cancel_button_click), | 341 | G_CALLBACK(handle_cancel_button_click), |
325 | handle->dialog | 342 | handle->dialog |
326 | ); | 343 | ); |
327 | 344 | ||
328 | handle->send_button = GTK_BUTTON( | 345 | handle->send_button = GTK_BUTTON( |
329 | gtk_builder_get_object(handle->builder, "send_button") | 346 | gtk_builder_get_object(handle->builder, "send_button") |
330 | ); | 347 | ); |
331 | 348 | ||
332 | g_signal_connect( | 349 | g_signal_connect( |
333 | handle->send_button, | 350 | handle->send_button, |
334 | "clicked", | 351 | "clicked", |
335 | G_CALLBACK(handle_send_button_click), | 352 | G_CALLBACK(handle_send_button_click), |
336 | app | 353 | app |
337 | ); | 354 | ); |
338 | 355 | ||
339 | g_signal_connect( | 356 | g_signal_connect( |
340 | handle->dialog, | 357 | handle->dialog, |
341 | "destroy", | 358 | "destroy", |
342 | G_CALLBACK(handle_dialog_destroy), | 359 | G_CALLBACK(handle_dialog_destroy), |
343 | handle | 360 | handle |
344 | ); | 361 | ); |
345 | 362 | ||
346 | handle->image = NULL; | 363 | handle->image = NULL; |
@@ -352,25 +369,29 @@ ui_send_file_dialog_init(MESSENGER_Application *app, | |||
352 | 369 | ||
353 | void | 370 | void |
354 | ui_send_file_dialog_update(UI_SEND_FILE_Handle *handle, | 371 | ui_send_file_dialog_update(UI_SEND_FILE_Handle *handle, |
355 | const gchar *filename) | 372 | const gchar *filename) |
356 | { | 373 | { |
374 | g_assert((handle) && (filename)); | ||
375 | |||
357 | if (!(handle->file_chooser_button)) | 376 | if (!(handle->file_chooser_button)) |
358 | return; | 377 | return; |
359 | 378 | ||
360 | gtk_file_chooser_set_filename( | 379 | gtk_file_chooser_set_filename( |
361 | GTK_FILE_CHOOSER(handle->file_chooser_button), | 380 | GTK_FILE_CHOOSER(handle->file_chooser_button), |
362 | filename | 381 | filename |
363 | ); | 382 | ); |
364 | 383 | ||
365 | handle_file_chooser_button_file_set( | 384 | handle_file_chooser_button_file_set( |
366 | handle->file_chooser_button, | 385 | handle->file_chooser_button, |
367 | handle | 386 | handle |
368 | ); | 387 | ); |
369 | } | 388 | } |
370 | 389 | ||
371 | void | 390 | void |
372 | ui_send_file_dialog_cleanup(UI_SEND_FILE_Handle *handle) | 391 | ui_send_file_dialog_cleanup(UI_SEND_FILE_Handle *handle) |
373 | { | 392 | { |
393 | g_assert(handle); | ||
394 | |||
374 | _clear_file_preview_data(handle); | 395 | _clear_file_preview_data(handle); |
375 | 396 | ||
376 | g_signal_handler_disconnect( | 397 | g_signal_handler_disconnect( |
diff --git a/src/ui/send_file.h b/src/ui/send_file.h index a4cad4f..dd41f29 100644 --- a/src/ui/send_file.h +++ b/src/ui/send_file.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -58,7 +58,7 @@ typedef struct UI_SEND_FILE_Handle | |||
58 | */ | 58 | */ |
59 | void | 59 | void |
60 | ui_send_file_dialog_init(MESSENGER_Application *app, | 60 | ui_send_file_dialog_init(MESSENGER_Application *app, |
61 | UI_SEND_FILE_Handle *handle); | 61 | UI_SEND_FILE_Handle *handle); |
62 | 62 | ||
63 | /** | 63 | /** |
64 | * Updates a given send file dialog handle with | 64 | * Updates a given send file dialog handle with |
@@ -70,7 +70,7 @@ ui_send_file_dialog_init(MESSENGER_Application *app, | |||
70 | */ | 70 | */ |
71 | void | 71 | void |
72 | ui_send_file_dialog_update(UI_SEND_FILE_Handle *handle, | 72 | ui_send_file_dialog_update(UI_SEND_FILE_Handle *handle, |
73 | const gchar *filename); | 73 | const gchar *filename); |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Cleans up the allocated resources and resets the | 76 | * Cleans up the allocated resources and resets the |
diff --git a/src/ui/settings.c b/src/ui/settings.c index 25514eb..6589778 100644 --- a/src/ui/settings.c +++ b/src/ui/settings.c | |||
@@ -36,6 +36,8 @@ handle_general_switch_state(UNUSED GtkSwitch *widget, | |||
36 | gboolean state, | 36 | gboolean state, |
37 | gpointer user_data) | 37 | gpointer user_data) |
38 | { | 38 | { |
39 | g_assert(user_data); | ||
40 | |||
39 | gboolean *setting = (gboolean*) user_data; | 41 | gboolean *setting = (gboolean*) user_data; |
40 | *setting = state; | 42 | *setting = state; |
41 | return FALSE; | 43 | return FALSE; |
@@ -46,6 +48,8 @@ _request_background_callback(GObject *source_object, | |||
46 | GAsyncResult *result, | 48 | GAsyncResult *result, |
47 | gpointer user_data) | 49 | gpointer user_data) |
48 | { | 50 | { |
51 | g_assert((source_object) && (result) && (user_data)); | ||
52 | |||
49 | XdpPortal *portal = XDP_PORTAL(source_object); | 53 | XdpPortal *portal = XDP_PORTAL(source_object); |
50 | MESSENGER_Request *request = (MESSENGER_Request*) user_data; | 54 | MESSENGER_Request *request = (MESSENGER_Request*) user_data; |
51 | 55 | ||
@@ -82,6 +86,8 @@ handle_background_switch_state(GtkSwitch *widget, | |||
82 | gboolean state, | 86 | gboolean state, |
83 | gpointer user_data) | 87 | gpointer user_data) |
84 | { | 88 | { |
89 | g_assert((widget) && (user_data)); | ||
90 | |||
85 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 91 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
86 | 92 | ||
87 | gboolean *setting = (gboolean*) ( | 93 | gboolean *setting = (gboolean*) ( |
@@ -114,6 +120,8 @@ handle_inverted_switch_state(GtkSwitch *widget, | |||
114 | gboolean state, | 120 | gboolean state, |
115 | gpointer user_data) | 121 | gpointer user_data) |
116 | { | 122 | { |
123 | g_assert((widget) && (user_data)); | ||
124 | |||
117 | return handle_general_switch_state(widget, !state, user_data); | 125 | return handle_general_switch_state(widget, !state, user_data); |
118 | } | 126 | } |
119 | 127 | ||
@@ -121,6 +129,8 @@ static void | |||
121 | handle_general_combo_box_change(GtkComboBox *widget, | 129 | handle_general_combo_box_change(GtkComboBox *widget, |
122 | gpointer user_data) | 130 | gpointer user_data) |
123 | { | 131 | { |
132 | g_assert((widget) && (user_data)); | ||
133 | |||
124 | gulong *delay = (gulong*) user_data; | 134 | gulong *delay = (gulong*) user_data; |
125 | GtkTreeModel *model = gtk_combo_box_get_model(widget); | 135 | GtkTreeModel *model = gtk_combo_box_get_model(widget); |
126 | 136 | ||
@@ -134,6 +144,8 @@ _leave_group_iteration(UNUSED void *cls, | |||
134 | UNUSED struct GNUNET_CHAT_Handle *handle, | 144 | UNUSED struct GNUNET_CHAT_Handle *handle, |
135 | struct GNUNET_CHAT_Group *group) | 145 | struct GNUNET_CHAT_Group *group) |
136 | { | 146 | { |
147 | g_assert(group); | ||
148 | |||
137 | GNUNET_CHAT_group_leave(group); | 149 | GNUNET_CHAT_group_leave(group); |
138 | return GNUNET_YES; | 150 | return GNUNET_YES; |
139 | } | 151 | } |
@@ -143,6 +155,8 @@ _delete_contact_iteration(UNUSED void *cls, | |||
143 | UNUSED struct GNUNET_CHAT_Handle *handle, | 155 | UNUSED struct GNUNET_CHAT_Handle *handle, |
144 | struct GNUNET_CHAT_Contact *contact) | 156 | struct GNUNET_CHAT_Contact *contact) |
145 | { | 157 | { |
158 | g_assert(contact); | ||
159 | |||
146 | GNUNET_CHAT_contact_delete(contact); | 160 | GNUNET_CHAT_contact_delete(contact); |
147 | return GNUNET_YES; | 161 | return GNUNET_YES; |
148 | } | 162 | } |
@@ -151,6 +165,8 @@ static void | |||
151 | handle_leave_chats_button_click(UNUSED GtkButton* button, | 165 | handle_leave_chats_button_click(UNUSED GtkButton* button, |
152 | gpointer user_data) | 166 | gpointer user_data) |
153 | { | 167 | { |
168 | g_assert(user_data); | ||
169 | |||
154 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 170 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
155 | 171 | ||
156 | GNUNET_CHAT_iterate_groups( | 172 | GNUNET_CHAT_iterate_groups( |
@@ -168,15 +184,19 @@ handle_leave_chats_button_click(UNUSED GtkButton* button, | |||
168 | 184 | ||
169 | static void | 185 | static void |
170 | handle_dialog_destroy(UNUSED GtkWidget *window, | 186 | handle_dialog_destroy(UNUSED GtkWidget *window, |
171 | gpointer user_data) | 187 | gpointer user_data) |
172 | { | 188 | { |
189 | g_assert(user_data); | ||
190 | |||
173 | ui_settings_dialog_cleanup((UI_SETTINGS_Handle*) user_data); | 191 | ui_settings_dialog_cleanup((UI_SETTINGS_Handle*) user_data); |
174 | } | 192 | } |
175 | 193 | ||
176 | static void | 194 | static void |
177 | _set_combobox_to_active_by_delay(GtkComboBox *widget, | 195 | _set_combobox_to_active_by_delay(GtkComboBox *widget, |
178 | gulong delay) | 196 | gulong delay) |
179 | { | 197 | { |
198 | g_assert(widget); | ||
199 | |||
180 | GtkTreeModel *model = gtk_combo_box_get_model(widget); | 200 | GtkTreeModel *model = gtk_combo_box_get_model(widget); |
181 | 201 | ||
182 | GtkTreeIter iter; | 202 | GtkTreeIter iter; |
@@ -200,9 +220,11 @@ set_active: | |||
200 | 220 | ||
201 | static enum GNUNET_GenericReturnValue | 221 | static enum GNUNET_GenericReturnValue |
202 | _count_blocked_contacts(void *cls, | 222 | _count_blocked_contacts(void *cls, |
203 | struct GNUNET_CHAT_Handle *handle, | 223 | UNUSED struct GNUNET_CHAT_Handle *handle, |
204 | struct GNUNET_CHAT_Contact *contact) | 224 | struct GNUNET_CHAT_Contact *contact) |
205 | { | 225 | { |
226 | g_assert((cls) && (contact)); | ||
227 | |||
206 | guint *count = (guint*) cls; | 228 | guint *count = (guint*) cls; |
207 | 229 | ||
208 | if (GNUNET_YES == GNUNET_CHAT_contact_is_blocked(contact)) | 230 | if (GNUNET_YES == GNUNET_CHAT_contact_is_blocked(contact)) |
@@ -215,6 +237,8 @@ void | |||
215 | ui_settings_dialog_init(MESSENGER_Application *app, | 237 | ui_settings_dialog_init(MESSENGER_Application *app, |
216 | UI_SETTINGS_Handle *handle) | 238 | UI_SETTINGS_Handle *handle) |
217 | { | 239 | { |
240 | g_assert((app) && (handle)); | ||
241 | |||
218 | handle->builder = gtk_builder_new_from_resource( | 242 | handle->builder = gtk_builder_new_from_resource( |
219 | application_get_resource_path(app, "ui/settings.ui") | 243 | application_get_resource_path(app, "ui/settings.ui") |
220 | ); | 244 | ); |
@@ -472,6 +496,8 @@ ui_settings_dialog_init(MESSENGER_Application *app, | |||
472 | void | 496 | void |
473 | ui_settings_dialog_cleanup(UI_SETTINGS_Handle *handle) | 497 | ui_settings_dialog_cleanup(UI_SETTINGS_Handle *handle) |
474 | { | 498 | { |
499 | g_assert(handle); | ||
500 | |||
475 | g_object_unref(handle->builder); | 501 | g_object_unref(handle->builder); |
476 | 502 | ||
477 | memset(handle, 0, sizeof(*handle)); | 503 | memset(handle, 0, sizeof(*handle)); |
diff --git a/src/ui/settings.h b/src/ui/settings.h index e932376..17af4e4 100644 --- a/src/ui/settings.h +++ b/src/ui/settings.h | |||
@@ -64,7 +64,7 @@ typedef struct UI_SETTINGS_Handle | |||
64 | */ | 64 | */ |
65 | void | 65 | void |
66 | ui_settings_dialog_init(MESSENGER_Application *app, | 66 | ui_settings_dialog_init(MESSENGER_Application *app, |
67 | UI_SETTINGS_Handle *handle); | 67 | UI_SETTINGS_Handle *handle); |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * Cleans up the allocated resources and resets the | 70 | * Cleans up the allocated resources and resets the |