From 180fa949976b47f54c51c388b8f2a5ea406a66f0 Mon Sep 17 00:00:00 2001 From: koutsie <18449778+koutsie@users.noreply.github.com> Date: Mon, 20 Feb 2023 07:51:40 +0200 Subject: [PATCH] 0.06 - Notifications support ! --- .github/workflows/codeql.yml | 76 ------------------------------------ src/main.c | 20 +++++----- 2 files changed, 10 insertions(+), 86 deletions(-) delete mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index a5a007c..0000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,76 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ "main" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "main" ] - schedule: - - cron: '28 10 * * 1' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'cpp' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Use only 'java' to analyze code written in Java, Kotlin or both - # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - - run: | - echo "Build" - cd src/ && make - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" diff --git a/src/main.c b/src/main.c index 4ac8d5d..a751a2e 100644 --- a/src/main.c +++ b/src/main.c @@ -27,7 +27,7 @@ static GtkStatusIcon *tray_icon; static GtkWidget *window; -char localver[20] = "0.05"; // Current version, update this while building! +char localver[20] = "0.06"; // Current version, update this while building! // Horrible logger void hlog(const char *type, const char *format, ...) @@ -73,13 +73,15 @@ void hlog(const char *type, const char *format, ...) va_end(args); } -// Initial desktop notification crap -void set_notification_permissions(WebKitWebContext *context) +// Notification (permissions) now work! +static void on_permission_request(WebKitWebView *web_view, WebKitPermissionRequest *request, gpointer user_data) { - WebKitSecurityOrigin *origin = webkit_security_origin_new("https", "cinny.the-sauna.icu", 443); - GList *allowed_origins = g_list_append(NULL, origin); - webkit_web_context_initialize_notification_permissions(context, allowed_origins, NULL); - g_list_free(allowed_origins); + if (WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST(request)) + { + hlog("lfc", "Notification permission request allowed.\n"); + WebKitNotificationPermissionRequest *notification_request = WEBKIT_NOTIFICATION_PERMISSION_REQUEST(request); + webkit_permission_request_allow(WEBKIT_PERMISSION_REQUEST(notification_request)); + } } static void on_window_close(GtkWidget *widget, GdkEvent *event, gpointer data) @@ -302,9 +304,6 @@ int main(int argc, char *argv[]) // Use the settings object to configure a WebKitWebView... webkit_web_view_set_settings(web_view, settings); - // Other useless crap like desktop notifications: - set_notification_permissions(context); - webkit_web_view_load_uri(web_view, "https://cinny.the-sauna.icu/"); GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL); @@ -322,6 +321,7 @@ int main(int argc, char *argv[]) g_signal_connect(tray_icon, "activate", G_CALLBACK(on_tray_icon_activate), NULL); g_signal_connect(tray_icon, "popup-menu", G_CALLBACK(on_tray_icon_popup_menu), NULL); g_signal_connect(window, "key-press-event", G_CALLBACK(on_key_press), NULL); + g_signal_connect(web_view, "permission-request", G_CALLBACK(on_permission_request), NULL); // Check updates, set off a fire in GTK & return 0 if everything went to hell! check_update();