diff -Nru freshplayerplugin-0.3.5/3rdparty/angle/src/compiler/translator/InfoSink.cpp freshplayerplugin-0.3.6/3rdparty/angle/src/compiler/translator/InfoSink.cpp --- freshplayerplugin-0.3.5/3rdparty/angle/src/compiler/translator/InfoSink.cpp 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/3rdparty/angle/src/compiler/translator/InfoSink.cpp 2016-10-04 22:44:50.000000000 +0000 @@ -26,7 +26,7 @@ sink.append("NOTE: "); break; default: - sink.append("UNKOWN ERROR: "); + sink.append("UNKNOWN ERROR: "); break; } } diff -Nru freshplayerplugin-0.3.5/3rdparty/angle/src/compiler/translator/InitializeDll.cpp freshplayerplugin-0.3.6/3rdparty/angle/src/compiler/translator/InitializeDll.cpp --- freshplayerplugin-0.3.5/3rdparty/angle/src/compiler/translator/InitializeDll.cpp 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/3rdparty/angle/src/compiler/translator/InitializeDll.cpp 2016-10-04 22:44:50.000000000 +0000 @@ -16,12 +16,12 @@ bool InitProcess() { if (!InitializePoolIndex()) { - assert(0 && "InitProcess(): Failed to initalize global pool"); + assert(0 && "InitProcess(): Failed to initialize global pool"); return false; } if (!InitializeParseContextIndex()) { - assert(0 && "InitProcess(): Failed to initalize parse context"); + assert(0 && "InitProcess(): Failed to initialize parse context"); return false; } diff -Nru freshplayerplugin-0.3.5/ChangeLog freshplayerplugin-0.3.6/ChangeLog --- freshplayerplugin-0.3.5/ChangeLog 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/ChangeLog 2016-10-04 22:44:50.000000000 +0000 @@ -1,3 +1,13 @@ +2016-10-05 Rinat Ibragimov + + * release: v0.3.6 + * graphics: fix off-by-one pixel issue in fullscreen scaling mode + * graphics: try to flicker less + * misc: use ICU for character set conversion, use WhatWG canonical + encoding name conversion + * misc: guess default character encoding from locale name + * misc: guess GTK+ major version at run time + 2016-04-12 Rinat Ibragimov * release v0.3.5 diff -Nru freshplayerplugin-0.3.5/CMakeLists.txt freshplayerplugin-0.3.6/CMakeLists.txt --- freshplayerplugin-0.3.5/CMakeLists.txt 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/CMakeLists.txt 2016-10-04 22:44:50.000000000 +0000 @@ -4,7 +4,7 @@ # version set(VER_MAJOR 0) set(VER_MINOR 3) -set(VER_MICRO 5) +set(VER_MICRO 6) # setup compiler flags set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -fPIC -pthread") @@ -59,6 +59,7 @@ pangoft2 freetype2 openssl + icu-uc REQUIRED) # merge glib-2.0 @@ -69,19 +70,6 @@ # libdl.so, librt.so, and libm.so list(APPEND REQ_LIBRARIES dl rt m) -# select GTK+ version -set(WITH_GTK 2 CACHE INTEGER "select GTK+ major version to link with (2 or 3)") -if (WITH_GTK EQUAL 2) - pkg_check_modules(GTK gtk+-2.0 REQUIRED) -elseif (WITH_GTK EQUAL 3) - pkg_check_modules(GTK gtk+-3.0 REQUIRED) -else() - message(FATAL_ERROR "Unsupported GTK+ version ${GTK_VERSION}") -endif() -list(APPEND REQ_LIBRARY_DIRS ${GTK_LIBRARY_DIRS}) -list(APPEND REQ_INCLUDE_DIRS ${GTK_INCLUDE_DIRS}) -list(APPEND REQ_LIBRARIES ${GTK_LIBRARIES}) - # OpenGL ES 2 set(WITH_GLES2 FALSE CACHE BOOLEAN "use system libGLESv2") if (WITH_GLES2) diff -Nru freshplayerplugin-0.3.5/debian/changelog freshplayerplugin-0.3.6/debian/changelog --- freshplayerplugin-0.3.5/debian/changelog 2016-05-03 08:25:09.000000000 +0000 +++ freshplayerplugin-0.3.6/debian/changelog 2016-10-13 12:54:19.000000000 +0000 @@ -1,3 +1,12 @@ +freshplayerplugin (0.3.6-1~webupd8~xenial1) xenial; urgency=medium + + * New upstream release + * No longer depends on gtk at build time, but it does at run time + * New build-dependency: libicu-dev + * New undocumented build-dependencies: libxrandr-dev, libxcursor-dev + + -- Alin Andrei Thu, 13 Oct 2016 14:54:19 +0200 + freshplayerplugin (0.3.5-1~webupd8~xenial~3) xenial; urgency=medium * Recommend pepperflashplugin-nonfree | adobe-flashplugin instead diff -Nru freshplayerplugin-0.3.5/debian/control freshplayerplugin-0.3.6/debian/control --- freshplayerplugin-0.3.5/debian/control 2016-05-03 08:22:30.000000000 +0000 +++ freshplayerplugin-0.3.6/debian/control 2016-10-13 12:54:19.000000000 +0000 @@ -16,7 +16,6 @@ libpangocairo-1.0-0, libpangoft2-1.0-0, libfreetype6-dev, - libgtk2.0-dev, libxinerama-dev, libconfig-dev, libevent-dev, @@ -29,7 +28,10 @@ libavcodec-dev, libavutil-dev, libva-dev, - libvdpau-dev + libvdpau-dev, + libicu-dev, + libxrandr-dev, + libxcursor-dev Standards-Version: 3.9.7 Vcs-Browser: https://anonscm.debian.org/gitweb/?p=collab-maint/freshplayerplugin.git Vcs-Git: https://anonscm.debian.org/collab-maint/freshplayerplugin.git @@ -38,7 +40,8 @@ Package: browser-plugin-freshplayer-pepperflash Architecture: any Depends: ${shlibs:Depends}, - ${misc:Depends} + ${misc:Depends}, + libgtk2.0-0 Recommends: pepperflashplugin-nonfree | adobe-flashplugin Description: PPAPI-host NPAPI-plugin adapter for pepperflash The main goal of the project is to get PPAPI (Chrome) plugins @@ -62,7 +65,8 @@ Package: browser-plugin-freshplayer-libpdf Architecture: any Depends: ${shlibs:Depends}, - ${misc:Depends} + ${misc:Depends}, + libgtk2.0-0 Description: PPAPI-host NPAPI-plugin adapter for libpdf.so from Chrome The main goal of the project is to get PPAPI (Chrome) plugins working in Firefox (and any other web-browser supporting NPAPI plugins). @@ -81,7 +85,8 @@ Package: browser-plugin-freshplayer-nacl Architecture: any Depends: ${shlibs:Depends}, - ${misc:Depends} + ${misc:Depends}, + libgtk2.0-0 Description: PPAPI-host NPAPI-plugin adapter for Native Client from Chrome The main goal of the project is to get PPAPI (Chrome) plugins working in Firefox (and any other web-browser supporting NPAPI plugins). diff -Nru freshplayerplugin-0.3.5/README.md freshplayerplugin-0.3.6/README.md --- freshplayerplugin-0.3.5/README.md 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/README.md 2016-10-04 22:44:50.000000000 +0000 @@ -69,13 +69,13 @@ libssl-dev libglib2.0-dev libpango1.0-dev libgl1-mesa-dev \ libevent-dev libgtk2.0-dev libxrandr-dev libxrender-dev \ libxcursor-dev libv4l-dev libgles2-mesa-dev libavcodec-dev \ - libva-dev libvdpau-dev libdrm-dev + libva-dev libvdpau-dev libdrm-dev libicu-dev Fedora: $ sudo dnf install cmake gcc gcc-c++ pkgconfig ragel alsa-lib-devel openssl-devel \ glib2-devel pango-devel mesa-libGL-devel libevent-devel gtk2-devel \ libXrandr-devel libXrender-devel libXcursor-devel libv4l-devel \ mesa-libGLES-devel ffmpeg-devel libva-devel libvdpau-devel libdrm-devel \ - pulseaudio-libs-devel + pulseaudio-libs-devel libicu-devel ``` * (optional) To enable PulseAudio support, install `libpulse-dev`. diff -Nru freshplayerplugin-0.3.5/src/async_network.c freshplayerplugin-0.3.6/src/async_network.c --- freshplayerplugin-0.3.5/src/async_network.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/async_network.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/async_network.h freshplayerplugin-0.3.6/src/async_network.h --- freshplayerplugin-0.3.5/src/async_network.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/async_network.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/audio_thread_alsa.c freshplayerplugin-0.3.6/src/audio_thread_alsa.c --- freshplayerplugin-0.3.5/src/audio_thread_alsa.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/audio_thread_alsa.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/audio_thread.c freshplayerplugin-0.3.6/src/audio_thread.c --- freshplayerplugin-0.3.5/src/audio_thread.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/audio_thread.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/audio_thread.h freshplayerplugin-0.3.6/src/audio_thread.h --- freshplayerplugin-0.3.5/src/audio_thread.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/audio_thread.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/audio_thread_jack.c freshplayerplugin-0.3.6/src/audio_thread_jack.c --- freshplayerplugin-0.3.5/src/audio_thread_jack.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/audio_thread_jack.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/audio_thread_noaudio.c freshplayerplugin-0.3.6/src/audio_thread_noaudio.c --- freshplayerplugin-0.3.5/src/audio_thread_noaudio.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/audio_thread_noaudio.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/audio_thread_pulseaudio.c freshplayerplugin-0.3.6/src/audio_thread_pulseaudio.c --- freshplayerplugin-0.3.5/src/audio_thread_pulseaudio.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/audio_thread_pulseaudio.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/CMakeLists.txt freshplayerplugin-0.3.6/src/CMakeLists.txt --- freshplayerplugin-0.3.5/src/CMakeLists.txt 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/CMakeLists.txt 2016-10-04 22:44:50.000000000 +0000 @@ -19,7 +19,9 @@ audio_thread_noaudio.c config.c compat.c + encoding_alias.c font.c + gtk_wrapper.c header_parser.c keycodeconvert.c np_entry.c diff -Nru freshplayerplugin-0.3.5/src/compat.c freshplayerplugin-0.3.6/src/compat.c --- freshplayerplugin-0.3.5/src/compat.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/compat.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * @@ -66,17 +66,3 @@ g_list_free(list); } #endif - -#if (GTK_MAJOR_VERSION * 1000 + GTK_MINOR_VERSION < 2 * 1000 + 24) -GdkWindow * -gdk_x11_window_lookup_for_display(GdkDisplay *gdpy, Window wnd) -{ - return gdk_window_lookup_for_display(gdpy, wnd); -} - -GdkWindow * -gdk_x11_window_foreign_new_for_display(GdkDisplay *gdpy, Window wnd) -{ - return gdk_window_foreign_new_for_display(gdpy, wnd); -} -#endif diff -Nru freshplayerplugin-0.3.5/src/compat_glx_defines.h freshplayerplugin-0.3.6/src/compat_glx_defines.h --- freshplayerplugin-0.3.5/src/compat_glx_defines.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/compat_glx_defines.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/compat.h freshplayerplugin-0.3.6/src/compat.h --- freshplayerplugin-0.3.5/src/compat.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/compat.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * @@ -26,9 +26,8 @@ #define FPP_COMPAT_H #include -#include -#include #include +#include "gtk_wrapper.h" #ifdef VER #error macro name collision @@ -55,14 +54,6 @@ g_list_free_full(GList *list, GDestroyNotify free_func); #endif -#if (GTK_MAJOR_VERSION * 1000 + GTK_MINOR_VERSION < 2 * 1000 + 24) -GdkWindow * -gdk_x11_window_lookup_for_display(GdkDisplay *gdpy, Window wnd); - -GdkWindow * -gdk_x11_window_foreign_new_for_display(GdkDisplay *gdpy, Window wnd); -#endif - #undef VER #endif // FPP_COMPAT_H diff -Nru freshplayerplugin-0.3.5/src/config.c freshplayerplugin-0.3.6/src/config.c --- freshplayerplugin-0.3.5/src/config.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/config.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/config.h freshplayerplugin-0.3.6/src/config.h --- freshplayerplugin-0.3.5/src/config.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/config.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/config_libpdf_backend.c freshplayerplugin-0.3.6/src/config_libpdf_backend.c --- freshplayerplugin-0.3.5/src/config_libpdf_backend.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/config_libpdf_backend.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/config_libpdf_frontend.c freshplayerplugin-0.3.6/src/config_libpdf_frontend.c --- freshplayerplugin-0.3.5/src/config_libpdf_frontend.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/config_libpdf_frontend.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/config_nacl.c freshplayerplugin-0.3.6/src/config_nacl.c --- freshplayerplugin-0.3.5/src/config_nacl.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/config_nacl.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/config_parser/config_parser.c freshplayerplugin-0.3.6/src/config_parser/config_parser.c --- freshplayerplugin-0.3.5/src/config_parser/config_parser.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/config_parser/config_parser.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/config_parser/config_parser_fsm.rl.c freshplayerplugin-0.3.6/src/config_parser/config_parser_fsm.rl.c --- freshplayerplugin-0.3.5/src/config_parser/config_parser_fsm.rl.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/config_parser/config_parser_fsm.rl.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/config_parser/config_parser.h freshplayerplugin-0.3.6/src/config_parser/config_parser.h --- freshplayerplugin-0.3.5/src/config_parser/config_parser.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/config_parser/config_parser.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/config_pepperflash.c freshplayerplugin-0.3.6/src/config_pepperflash.c --- freshplayerplugin-0.3.5/src/config_pepperflash.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/config_pepperflash.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/dep_check.c freshplayerplugin-0.3.6/src/dep_check.c --- freshplayerplugin-0.3.5/src/dep_check.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/dep_check.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/eintr_retry.h freshplayerplugin-0.3.6/src/eintr_retry.h --- freshplayerplugin-0.3.5/src/eintr_retry.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/eintr_retry.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/encoding_alias.c freshplayerplugin-0.3.6/src/encoding_alias.c --- freshplayerplugin-0.3.5/src/encoding_alias.c 1970-01-01 00:00:00.000000000 +0000 +++ freshplayerplugin-0.3.6/src/encoding_alias.c 2016-10-04 22:44:50.000000000 +0000 @@ -0,0 +1,148 @@ +/* + * Copyright © 2013-2016 Rinat Ibragimov + * + * This file is part of FreshPlayerPlugin. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "encoding_alias.h" +#include +#include +#include +#include + + +enum { + UIGNORE = 0, + ZERO = 1, + NONZ = 2, +}; + +static const uint8_t char_types[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ZERO, NONZ, NONZ, NONZ, NONZ, NONZ, NONZ, NONZ, NONZ, NONZ, 0, 0, 0, 0, 0, 0, + 0, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0, 0, 0, 0, 0, + 0, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0, 0, 0, 0, 0, + + /* remaining 128-255 are 0 */ +}; + +// maps an alias to the canonical encoding name +static GHashTable *ce_ht; // char * -> char * + + +static +char * +strip_enc_name(const char *name) +{ + if (!name) + return NULL; + + char *dst = strdup(name); + if (!dst) + return NULL; + + char *p = dst; + int after_digit = 0; + + while (1) { + char c = *name++; + if (c == '\0') + break; + + const uint8_t type = char_types[(uint8_t)c]; + switch (type) { + case UIGNORE: + after_digit = 0; + // ignore all but letter and digits + continue; + + case ZERO: + if (!after_digit) { + const uint8_t next_type = char_types[(uint8_t)(*name)]; + if (next_type == ZERO || next_type == NONZ) { + // ignore leading zero before another digit + continue; + } + } + break; + + case NONZ: + after_digit = 1; + break; + + default: + c = type; // lowercased letter + after_digit = 0; + break; + } + + *p++ = c; + } + + *p = 0; + return dst; +} + +__attribute__((constructor)) +static +void +constructor_encoding_alias(void) +{ + ce_ht = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); + + struct { + const char *dst; + const char *src; + } encs[] = { +#include "encoding_alias_list.inc.c" + }; + + for (uint32_t k = 0; k < sizeof(encs) / sizeof(encs[0]); k ++) { + char *stripped_src_name = strip_enc_name(encs[k].src); + g_hash_table_insert(ce_ht, stripped_src_name, strdup(encs[k].dst)); + } +} + +__attribute__((destructor)) +static +void +destructor_encoding_alias(void) +{ + g_hash_table_destroy(ce_ht); +} + +const char * +encoding_alias_get_canonical_name(const char *name) +{ + const char *res = name; + char *stripped_name = strip_enc_name(name); + + res = g_hash_table_lookup(ce_ht, stripped_name); + if (!res) + res = name; + + g_free(stripped_name); + return res; +} diff -Nru freshplayerplugin-0.3.5/src/encoding_alias.h freshplayerplugin-0.3.6/src/encoding_alias.h --- freshplayerplugin-0.3.5/src/encoding_alias.h 1970-01-01 00:00:00.000000000 +0000 +++ freshplayerplugin-0.3.6/src/encoding_alias.h 2016-10-04 22:44:50.000000000 +0000 @@ -0,0 +1,29 @@ +/* + * Copyright © 2013-2016 Rinat Ibragimov + * + * This file is part of FreshPlayerPlugin. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + + +const char * +encoding_alias_get_canonical_name(const char *name); diff -Nru freshplayerplugin-0.3.5/src/encoding_alias_list.inc.c freshplayerplugin-0.3.6/src/encoding_alias_list.inc.c --- freshplayerplugin-0.3.5/src/encoding_alias_list.inc.c 1970-01-01 00:00:00.000000000 +0000 +++ freshplayerplugin-0.3.6/src/encoding_alias_list.inc.c 2016-10-04 22:44:50.000000000 +0000 @@ -0,0 +1,273 @@ +// autogenerated by /tools/encodings/gen-encoding-aliases.py + +// The Encoding +{ "UTF-8", "UTF-8" }, +{ "UTF-8", "unicode-1-1-utf-8" }, +{ "UTF-8", "utf-8" }, +{ "UTF-8", "utf8" }, + +// Legacy single-byte encodings +{ "IBM866", "IBM866" }, +{ "IBM866", "866" }, +{ "IBM866", "cp866" }, +{ "IBM866", "csibm866" }, +{ "IBM866", "ibm866" }, +{ "ISO-8859-2", "ISO-8859-2" }, +{ "ISO-8859-2", "csisolatin2" }, +{ "ISO-8859-2", "iso-8859-2" }, +{ "ISO-8859-2", "iso-ir-101" }, +{ "ISO-8859-2", "iso8859-2" }, +{ "ISO-8859-2", "iso88592" }, +{ "ISO-8859-2", "iso_8859-2" }, +{ "ISO-8859-2", "iso_8859-2:1987" }, +{ "ISO-8859-2", "l2" }, +{ "ISO-8859-2", "latin2" }, +{ "ISO-8859-3", "ISO-8859-3" }, +{ "ISO-8859-3", "csisolatin3" }, +{ "ISO-8859-3", "iso-8859-3" }, +{ "ISO-8859-3", "iso-ir-109" }, +{ "ISO-8859-3", "iso8859-3" }, +{ "ISO-8859-3", "iso88593" }, +{ "ISO-8859-3", "iso_8859-3" }, +{ "ISO-8859-3", "iso_8859-3:1988" }, +{ "ISO-8859-3", "l3" }, +{ "ISO-8859-3", "latin3" }, +{ "ISO-8859-4", "ISO-8859-4" }, +{ "ISO-8859-4", "csisolatin4" }, +{ "ISO-8859-4", "iso-8859-4" }, +{ "ISO-8859-4", "iso-ir-110" }, +{ "ISO-8859-4", "iso8859-4" }, +{ "ISO-8859-4", "iso88594" }, +{ "ISO-8859-4", "iso_8859-4" }, +{ "ISO-8859-4", "iso_8859-4:1988" }, +{ "ISO-8859-4", "l4" }, +{ "ISO-8859-4", "latin4" }, +{ "ISO-8859-5", "ISO-8859-5" }, +{ "ISO-8859-5", "csisolatincyrillic" }, +{ "ISO-8859-5", "cyrillic" }, +{ "ISO-8859-5", "iso-8859-5" }, +{ "ISO-8859-5", "iso-ir-144" }, +{ "ISO-8859-5", "iso8859-5" }, +{ "ISO-8859-5", "iso88595" }, +{ "ISO-8859-5", "iso_8859-5" }, +{ "ISO-8859-5", "iso_8859-5:1988" }, +{ "ISO-8859-6", "ISO-8859-6" }, +{ "ISO-8859-6", "arabic" }, +{ "ISO-8859-6", "asmo-708" }, +{ "ISO-8859-6", "csiso88596e" }, +{ "ISO-8859-6", "csiso88596i" }, +{ "ISO-8859-6", "csisolatinarabic" }, +{ "ISO-8859-6", "ecma-114" }, +{ "ISO-8859-6", "iso-8859-6" }, +{ "ISO-8859-6", "iso-8859-6-e" }, +{ "ISO-8859-6", "iso-8859-6-i" }, +{ "ISO-8859-6", "iso-ir-127" }, +{ "ISO-8859-6", "iso8859-6" }, +{ "ISO-8859-6", "iso88596" }, +{ "ISO-8859-6", "iso_8859-6" }, +{ "ISO-8859-6", "iso_8859-6:1987" }, +{ "ISO-8859-7", "ISO-8859-7" }, +{ "ISO-8859-7", "csisolatingreek" }, +{ "ISO-8859-7", "ecma-118" }, +{ "ISO-8859-7", "elot_928" }, +{ "ISO-8859-7", "greek" }, +{ "ISO-8859-7", "greek8" }, +{ "ISO-8859-7", "iso-8859-7" }, +{ "ISO-8859-7", "iso-ir-126" }, +{ "ISO-8859-7", "iso8859-7" }, +{ "ISO-8859-7", "iso88597" }, +{ "ISO-8859-7", "iso_8859-7" }, +{ "ISO-8859-7", "iso_8859-7:1987" }, +{ "ISO-8859-7", "sun_eu_greek" }, +{ "ISO-8859-8", "ISO-8859-8" }, +{ "ISO-8859-8", "csiso88598e" }, +{ "ISO-8859-8", "csisolatinhebrew" }, +{ "ISO-8859-8", "hebrew" }, +{ "ISO-8859-8", "iso-8859-8" }, +{ "ISO-8859-8", "iso-8859-8-e" }, +{ "ISO-8859-8", "iso-ir-138" }, +{ "ISO-8859-8", "iso8859-8" }, +{ "ISO-8859-8", "iso88598" }, +{ "ISO-8859-8", "iso_8859-8" }, +{ "ISO-8859-8", "iso_8859-8:1988" }, +{ "ISO-8859-8", "visual" }, +{ "ISO-8859-8-I", "ISO-8859-8-I" }, +{ "ISO-8859-8-I", "csiso88598i" }, +{ "ISO-8859-8-I", "iso-8859-8-i" }, +{ "ISO-8859-8-I", "logical" }, +{ "ISO-8859-10", "ISO-8859-10" }, +{ "ISO-8859-10", "csisolatin6" }, +{ "ISO-8859-10", "iso-8859-10" }, +{ "ISO-8859-10", "iso-ir-157" }, +{ "ISO-8859-10", "iso8859-10" }, +{ "ISO-8859-10", "iso885910" }, +{ "ISO-8859-10", "l6" }, +{ "ISO-8859-10", "latin6" }, +{ "ISO-8859-13", "ISO-8859-13" }, +{ "ISO-8859-13", "iso-8859-13" }, +{ "ISO-8859-13", "iso8859-13" }, +{ "ISO-8859-13", "iso885913" }, +{ "ISO-8859-14", "ISO-8859-14" }, +{ "ISO-8859-14", "iso-8859-14" }, +{ "ISO-8859-14", "iso8859-14" }, +{ "ISO-8859-14", "iso885914" }, +{ "ISO-8859-15", "ISO-8859-15" }, +{ "ISO-8859-15", "csisolatin9" }, +{ "ISO-8859-15", "iso-8859-15" }, +{ "ISO-8859-15", "iso8859-15" }, +{ "ISO-8859-15", "iso885915" }, +{ "ISO-8859-15", "iso_8859-15" }, +{ "ISO-8859-15", "l9" }, +{ "ISO-8859-16", "ISO-8859-16" }, +{ "ISO-8859-16", "iso-8859-16" }, +{ "KOI8-R", "KOI8-R" }, +{ "KOI8-R", "cskoi8r" }, +{ "KOI8-R", "koi" }, +{ "KOI8-R", "koi8" }, +{ "KOI8-R", "koi8-r" }, +{ "KOI8-R", "koi8_r" }, +{ "KOI8-U", "KOI8-U" }, +{ "KOI8-U", "koi8-ru" }, +{ "KOI8-U", "koi8-u" }, +{ "macintosh", "macintosh" }, +{ "macintosh", "csmacintosh" }, +{ "macintosh", "mac" }, +{ "macintosh", "macintosh" }, +{ "macintosh", "x-mac-roman" }, +{ "windows-874", "windows-874" }, +{ "windows-874", "dos-874" }, +{ "windows-874", "iso-8859-11" }, +{ "windows-874", "iso8859-11" }, +{ "windows-874", "iso885911" }, +{ "windows-874", "tis-620" }, +{ "windows-874", "windows-874" }, +{ "windows-1250", "windows-1250" }, +{ "windows-1250", "cp1250" }, +{ "windows-1250", "windows-1250" }, +{ "windows-1250", "x-cp1250" }, +{ "windows-1251", "windows-1251" }, +{ "windows-1251", "cp1251" }, +{ "windows-1251", "windows-1251" }, +{ "windows-1251", "x-cp1251" }, +{ "windows-1252", "windows-1252" }, +{ "windows-1252", "ansi_x3.4-1968" }, +{ "windows-1252", "ascii" }, +{ "windows-1252", "cp1252" }, +{ "windows-1252", "cp819" }, +{ "windows-1252", "csisolatin1" }, +{ "windows-1252", "ibm819" }, +{ "windows-1252", "iso-8859-1" }, +{ "windows-1252", "iso-ir-100" }, +{ "windows-1252", "iso8859-1" }, +{ "windows-1252", "iso88591" }, +{ "windows-1252", "iso_8859-1" }, +{ "windows-1252", "iso_8859-1:1987" }, +{ "windows-1252", "l1" }, +{ "windows-1252", "latin1" }, +{ "windows-1252", "us-ascii" }, +{ "windows-1252", "windows-1252" }, +{ "windows-1252", "x-cp1252" }, +{ "windows-1253", "windows-1253" }, +{ "windows-1253", "cp1253" }, +{ "windows-1253", "windows-1253" }, +{ "windows-1253", "x-cp1253" }, +{ "windows-1254", "windows-1254" }, +{ "windows-1254", "cp1254" }, +{ "windows-1254", "csisolatin5" }, +{ "windows-1254", "iso-8859-9" }, +{ "windows-1254", "iso-ir-148" }, +{ "windows-1254", "iso8859-9" }, +{ "windows-1254", "iso88599" }, +{ "windows-1254", "iso_8859-9" }, +{ "windows-1254", "iso_8859-9:1989" }, +{ "windows-1254", "l5" }, +{ "windows-1254", "latin5" }, +{ "windows-1254", "windows-1254" }, +{ "windows-1254", "x-cp1254" }, +{ "windows-1255", "windows-1255" }, +{ "windows-1255", "cp1255" }, +{ "windows-1255", "windows-1255" }, +{ "windows-1255", "x-cp1255" }, +{ "windows-1256", "windows-1256" }, +{ "windows-1256", "cp1256" }, +{ "windows-1256", "windows-1256" }, +{ "windows-1256", "x-cp1256" }, +{ "windows-1257", "windows-1257" }, +{ "windows-1257", "cp1257" }, +{ "windows-1257", "windows-1257" }, +{ "windows-1257", "x-cp1257" }, +{ "windows-1258", "windows-1258" }, +{ "windows-1258", "cp1258" }, +{ "windows-1258", "windows-1258" }, +{ "windows-1258", "x-cp1258" }, +{ "x-mac-cyrillic", "x-mac-cyrillic" }, +{ "x-mac-cyrillic", "x-mac-cyrillic" }, +{ "x-mac-cyrillic", "x-mac-ukrainian" }, + +// Legacy multi-byte Chinese (simplified) encodings +{ "GBK", "GBK" }, +{ "GBK", "chinese" }, +{ "GBK", "csgb2312" }, +{ "GBK", "csiso58gb231280" }, +{ "GBK", "gb2312" }, +{ "GBK", "gb_2312" }, +{ "GBK", "gb_2312-80" }, +{ "GBK", "gbk" }, +{ "GBK", "iso-ir-58" }, +{ "GBK", "x-gbk" }, +{ "gb18030", "gb18030" }, +{ "gb18030", "gb18030" }, + +// Legacy multi-byte Chinese (traditional) encodings +{ "Big5", "Big5" }, +{ "Big5", "big5" }, +{ "Big5", "big5-hkscs" }, +{ "Big5", "cn-big5" }, +{ "Big5", "csbig5" }, +{ "Big5", "x-x-big5" }, + +// Legacy multi-byte Japanese encodings +{ "EUC-JP", "EUC-JP" }, +{ "EUC-JP", "cseucpkdfmtjapanese" }, +{ "EUC-JP", "euc-jp" }, +{ "EUC-JP", "x-euc-jp" }, +{ "ISO-2022-JP", "ISO-2022-JP" }, +{ "ISO-2022-JP", "csiso2022jp" }, +{ "ISO-2022-JP", "iso-2022-jp" }, +{ "Shift_JIS", "Shift_JIS" }, +{ "Shift_JIS", "csshiftjis" }, +{ "Shift_JIS", "ms932" }, +{ "Shift_JIS", "ms_kanji" }, +{ "Shift_JIS", "shift-jis" }, +{ "Shift_JIS", "shift_jis" }, +{ "Shift_JIS", "sjis" }, +{ "Shift_JIS", "windows-31j" }, +{ "Shift_JIS", "x-sjis" }, + +// Legacy multi-byte Korean encodings +{ "EUC-KR", "EUC-KR" }, +{ "EUC-KR", "cseuckr" }, +{ "EUC-KR", "csksc56011987" }, +{ "EUC-KR", "euc-kr" }, +{ "EUC-KR", "iso-ir-149" }, +{ "EUC-KR", "korean" }, +{ "EUC-KR", "ks_c_5601-1987" }, +{ "EUC-KR", "ks_c_5601-1989" }, +{ "EUC-KR", "ksc5601" }, +{ "EUC-KR", "ksc_5601" }, +{ "EUC-KR", "windows-949" }, + +// Legacy miscellaneous encodings +{ "replacement", "replacement" }, +{ "replacement", "csiso2022kr" }, +{ "replacement", "hz-gb-2312" }, +{ "replacement", "iso-2022-cn" }, +{ "replacement", "iso-2022-cn-ext" }, +{ "replacement", "iso-2022-kr" }, +{ "UTF-16BE", "UTF-16BE" }, +{ "UTF-16BE", "utf-16be" }, +{ "UTF-16LE", "UTF-16LE" }, +{ "UTF-16LE", "utf-16" }, +{ "UTF-16LE", "utf-16le" }, +{ "x-user-defined", "x-user-defined" }, +{ "x-user-defined", "x-user-defined" }, diff -Nru freshplayerplugin-0.3.5/src/font.c freshplayerplugin-0.3.6/src/font.c --- freshplayerplugin-0.3.5/src/font.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/font.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/font.h freshplayerplugin-0.3.6/src/font.h --- freshplayerplugin-0.3.5/src/font.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/font.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/gtk_wrapper.c freshplayerplugin-0.3.6/src/gtk_wrapper.c --- freshplayerplugin-0.3.5/src/gtk_wrapper.c 1970-01-01 00:00:00.000000000 +0000 +++ freshplayerplugin-0.3.6/src/gtk_wrapper.c 2016-10-04 22:44:50.000000000 +0000 @@ -0,0 +1,398 @@ +/* + * Copyright © 2013-2016 Rinat Ibragimov + * + * This file is part of FreshPlayerPlugin. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define _GNU_SOURCE + +#include "gtk_wrapper.h" +#include +#include +#include +#include "trace_core.h" + + +static struct { + int major_version; + int minor_version; + int available_flag; + void *dl_handler; +} gw = {}; + +GdkAtom +(*gw_gdk_atom_intern)(const gchar *atom_name, gboolean only_if_exists); + +GdkAtom +(*gw_gdk_atom_intern_static_string)(const gchar *atom_name); + +gchar * +(*gw_gdk_atom_name)(GdkAtom atom); + +GdkDisplay * +(*gw_gdk_display_get_default)(void); + +void +(*gw_gdk_event_free)(GdkEvent *event); + +GdkEvent * +(*gw_gdk_event_new)(GdkEventType type); + +gboolean +(*gw_gdk_keymap_get_entries_for_keycode)(GdkKeymap *keymap, guint hardware_keycode, + GdkKeymapKey **keys, guint **keyvals, gint *n_entries); + +GdkKeymap * +(*gw_gdk_keymap_get_for_display)(GdkDisplay *display); + +GdkDisplay * +(*gw_gdk_window_get_display)(GdkWindow *window); + +void +(*gw_gdk_window_set_user_data)(GdkWindow *window, gpointer user_data); + +Display * +(*gw_gdk_x11_display_get_xdisplay)(GdkDisplay *display); + +Window +(*gw_gdk_x11_drawable_get_xid)(GdkWindow *window); + +GdkDisplay * +(*gw_gdk_x11_lookup_xdisplay)(Display *xdisplay); + +GdkWindow * +(*gw_gdk_x11_window_foreign_new_for_display)(GdkDisplay *display, Window window); + +GdkWindow * +(*gw_gdk_x11_window_lookup_for_display)(GdkDisplay *display, Window window); + +GType +(*gw_gtk_check_menu_item_get_type)(void); + +GtkWidget * +(*gw_gtk_check_menu_item_new_with_label)(const gchar *label); + +void +(*gw_gtk_check_menu_item_set_active)(GtkCheckMenuItem *check_menu_item, gboolean is_active); + +void +(*gw_gtk_clipboard_clear)(GtkClipboard *clipboard); + +GtkClipboard * +(*gw_gtk_clipboard_get)(GdkAtom selection); + +void +(*gw_gtk_clipboard_set_can_store)(GtkClipboard *clipboard, const GtkTargetEntry *targets, + gint n_targets); +gboolean +(*gw_gtk_clipboard_set_with_data)(GtkClipboard *clipboard, const GtkTargetEntry *targets, + guint n_targets, GtkClipboardGetFunc get_func, + GtkClipboardClearFunc clear_func, gpointer user_data); +GtkSelectionData * +(*gw_gtk_clipboard_wait_for_contents)(GtkClipboard *clipboard, GdkAtom target); + +gboolean +(*gw_gtk_clipboard_wait_is_target_available)(GtkClipboard *clipboard, GdkAtom target); + +GtkWidget * +(*gw_gtk_file_chooser_dialog_new)(const gchar *title, GtkWindow *parent, + GtkFileChooserAction action, const gchar *first_button_text, ...); + +GSList * +(*gw_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser); + +GType +(*gw_gtk_file_chooser_get_type)(void); + +void +(*gw_gtk_file_chooser_set_select_multiple)(GtkFileChooser *chooser, gboolean select_multiple); + +guint32 +(*gw_gtk_get_current_event_time)(void); + +gboolean +(*gw_gtk_im_context_filter_keypress)(GtkIMContext *context, GdkEventKey *event); + +void +(*gw_gtk_im_context_focus_in)(GtkIMContext *context); + +void +(*gw_gtk_im_context_focus_out)(GtkIMContext *context); + +void +(*gw_gtk_im_context_get_preedit_string)(GtkIMContext *context, gchar **str, PangoAttrList **attrs, + gint *cursor_pos); + +void +(*gw_gtk_im_context_reset)(GtkIMContext *context); + +void +(*gw_gtk_im_context_set_client_window)(GtkIMContext *context, GdkWindow *window); + +void +(*gw_gtk_im_context_set_cursor_location)(GtkIMContext *context, const GdkRectangle *area); + +void +(*gw_gtk_im_context_set_surrounding)(GtkIMContext *context, const gchar *text, gint len, + gint cursor_index); + +GtkIMContext * +(*gw_gtk_im_context_simple_new)(void); + +GtkIMContext * +(*gw_gtk_im_multicontext_new)(void); + +GtkWidget * +(*gw_gtk_label_new)(const gchar *str); + +GType +(*gw_gtk_menu_get_type)(void); + +GType +(*gw_gtk_menu_item_get_type)(void); + +GtkWidget * +(*gw_gtk_menu_item_new_with_label)(const gchar *label); + +void +(*gw_gtk_menu_item_set_submenu)(GtkMenuItem *menu_item, GtkWidget *submenu); + +GtkWidget * +(*gw_gtk_menu_new)(void); + +void +(*gw_gtk_menu_popup)(GtkMenu *menu, GtkWidget *parent_menu_shell, GtkWidget *parent_menu_item, + GtkMenuPositionFunc func, gpointer data, guint button, guint32 activate_time); + +void +(*gw_gtk_menu_shell_append)(GtkMenuShell *menu_shell, GtkWidget *child); + +GType +(*gw_gtk_menu_shell_get_type)(void); + +void +(*gw_gtk_selection_data_free)(GtkSelectionData *data); + +const guchar * +(*gw_gtk_selection_data_get_data)(const GtkSelectionData *selection_data); + +gint +(*gw_gtk_selection_data_get_length)(const GtkSelectionData *selection_data); + +void +(*gw_gtk_selection_data_set)(GtkSelectionData *selection_data, GdkAtom type, gint format, + const guchar *data, gint length); + +GtkWidget * +(*gw_gtk_separator_menu_item_new)(void); + +void +(*gw_gtk_widget_destroy)(GtkWidget *widget); + +GType +(*gw_gtk_widget_get_type)(void); + +GdkWindow * +(*gw_gtk_widget_get_window)(GtkWidget *widget); + +void +(*gw_gtk_widget_realize)(GtkWidget *widget); + +void +(*gw_gtk_widget_set_realized)(GtkWidget *widget, gboolean realized); + +void +(*gw_gtk_widget_set_sensitive)(GtkWidget *widget, gboolean sensitive); + +void +(*gw_gtk_widget_show)(GtkWidget *widget); + +static +int +find_gtk_cb(struct dl_phdr_info *info, size_t size, void *data) +{ + if (!info->dlpi_name) + return 0; + + // try GTK+ 2 + if (strstr(info->dlpi_name, "/libgtk-x11-2.0")) { + gw.dl_handler = dlopen(info->dlpi_name, RTLD_NOW); + gw.major_version = 2; + } + + // try GTK+ 3 + if (strstr(info->dlpi_name, "/libgtk-3.so")) { + gw.dl_handler = dlopen(info->dlpi_name, RTLD_NOW); + gw.major_version = 3; + } + + // don't care if both versions are loaded. + // In that case we're in a buggy state anyway. + + return 0; +} + +void +gtk_wrapper_initialize(void) +{ + static int initialize_was_called = 0; + + if (initialize_was_called) + return; + + initialize_was_called = 1; + + dl_iterate_phdr(find_gtk_cb, NULL); + + if (gw.major_version == 0) + return; + + gw.available_flag = 1; + + uint32_t *minor_version; + uint32_t (*gw_gtk_get_minor_version)(void); + + switch (gw.major_version) { + case 2: + minor_version = dlsym(RTLD_DEFAULT, "gtk_minor_version"); + if (minor_version) + memcpy(&gw.minor_version, minor_version, sizeof(uint32_t)); + break; + + case 3: + gw_gtk_get_minor_version = dlsym(RTLD_DEFAULT, "gtk_get_minor_version"); + if (gw_gtk_get_minor_version) + gw.minor_version = gw_gtk_get_minor_version(); + break; + + default: + // do nothing + break; + } + +#define GET_SYMBOL2(symname, libname) \ +do { \ + gw_ ## symname = dlsym(gw.dl_handler, #libname); \ + if (gw_ ## symname == NULL) \ + trace_error("can't resolve " #libname "\n"); \ +} while (0) + +#define GET_SYMBOL(symname) \ +do { \ + GET_SYMBOL2(symname, symname); \ +} while (0) + + GET_SYMBOL(gtk_check_menu_item_get_type); + GET_SYMBOL(gtk_check_menu_item_new_with_label); + GET_SYMBOL(gtk_check_menu_item_set_active); + GET_SYMBOL(gtk_clipboard_clear); + GET_SYMBOL(gtk_clipboard_get); + GET_SYMBOL(gtk_clipboard_set_can_store); + GET_SYMBOL(gtk_clipboard_set_with_data); + GET_SYMBOL(gtk_clipboard_wait_for_contents); + GET_SYMBOL(gtk_clipboard_wait_is_target_available); + GET_SYMBOL(gtk_file_chooser_dialog_new); + GET_SYMBOL(gtk_file_chooser_get_filenames); + GET_SYMBOL(gtk_file_chooser_get_type); + GET_SYMBOL(gtk_file_chooser_set_select_multiple); + GET_SYMBOL(gtk_get_current_event_time); + GET_SYMBOL(gtk_im_context_filter_keypress); + GET_SYMBOL(gtk_im_context_focus_in); + GET_SYMBOL(gtk_im_context_focus_out); + GET_SYMBOL(gtk_im_context_get_preedit_string); + GET_SYMBOL(gtk_im_context_reset); + GET_SYMBOL(gtk_im_context_set_client_window); + GET_SYMBOL(gtk_im_context_set_cursor_location); + GET_SYMBOL(gtk_im_context_set_surrounding); + GET_SYMBOL(gtk_im_context_simple_new); + GET_SYMBOL(gtk_im_multicontext_new); + GET_SYMBOL(gtk_label_new); + GET_SYMBOL(gtk_menu_get_type); + GET_SYMBOL(gtk_menu_item_get_type); + GET_SYMBOL(gtk_menu_item_new_with_label); + GET_SYMBOL(gtk_menu_item_set_submenu); + GET_SYMBOL(gtk_menu_new); + GET_SYMBOL(gtk_menu_popup); + GET_SYMBOL(gtk_menu_shell_append); + GET_SYMBOL(gtk_menu_shell_get_type); + GET_SYMBOL(gtk_selection_data_free); + GET_SYMBOL(gtk_selection_data_get_data); + GET_SYMBOL(gtk_selection_data_get_length); + GET_SYMBOL(gtk_selection_data_set); + GET_SYMBOL(gtk_separator_menu_item_new); + GET_SYMBOL(gtk_widget_destroy); + GET_SYMBOL(gtk_widget_get_type); + GET_SYMBOL(gtk_widget_get_window); + GET_SYMBOL(gtk_widget_realize); + GET_SYMBOL(gtk_widget_set_realized); + GET_SYMBOL(gtk_widget_set_sensitive); + GET_SYMBOL(gtk_widget_show); + + GET_SYMBOL(gdk_atom_intern); + GET_SYMBOL(gdk_atom_intern_static_string); + GET_SYMBOL(gdk_atom_name); + GET_SYMBOL(gdk_display_get_default); + GET_SYMBOL(gdk_event_free); + GET_SYMBOL(gdk_event_new); + GET_SYMBOL(gdk_keymap_get_entries_for_keycode); + GET_SYMBOL(gdk_keymap_get_for_display); + GET_SYMBOL(gdk_window_get_display); + GET_SYMBOL(gdk_window_set_user_data); + GET_SYMBOL(gdk_x11_display_get_xdisplay); + GET_SYMBOL(gdk_x11_lookup_xdisplay); + + if (gw.major_version == 2) { + GET_SYMBOL(gdk_x11_drawable_get_xid); + + } else { + GET_SYMBOL2(gdk_x11_drawable_get_xid, gdk_x11_window_get_xid); + } + + if (gw.major_version == 2 && gw.minor_version < 24) { + // Those functions didn't exists before 2.24. + // They appear in 2.24, while previous names become deprecated. + GET_SYMBOL2(gdk_x11_window_foreign_new_for_display, gdk_window_foreign_new_for_display); + GET_SYMBOL2(gdk_x11_window_lookup_for_display, gdk_window_lookup_for_display); + + } else { + // in 2.24, or in 3.* + GET_SYMBOL(gdk_x11_window_foreign_new_for_display); + GET_SYMBOL(gdk_x11_window_lookup_for_display); + } +} + +int +gw_major_version(void) +{ + return gw.major_version; +} + +int +gw_minor_version(void) +{ + return gw.minor_version; +} + +int +gw_gtk_available(void) +{ + return gw.available_flag; +} diff -Nru freshplayerplugin-0.3.5/src/gtk_wrapper.h freshplayerplugin-0.3.6/src/gtk_wrapper.h --- freshplayerplugin-0.3.5/src/gtk_wrapper.h 1970-01-01 00:00:00.000000000 +0000 +++ freshplayerplugin-0.3.6/src/gtk_wrapper.h 2016-10-04 22:44:50.000000000 +0000 @@ -0,0 +1,743 @@ +/* + * Copyright © 2013-2016 Rinat Ibragimov + * + * This file is part of FreshPlayerPlugin. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include +#include +#include +#include + + +// GTK+ type mockups + +#define GDK_WINDOW_XDISPLAY(win) \ + (gw_gdk_x11_display_get_xdisplay(gw_gdk_window_get_display(win))) + +#define GDK_WINDOW_XID(win) (gw_gdk_x11_drawable_get_xid(win)) + +#define GTK_TYPE_CHECK_MENU_ITEM (gw_gtk_check_menu_item_get_type()) +#define GTK_TYPE_FILE_CHOOSER (gw_gtk_file_chooser_get_type()) +#define GTK_TYPE_MENU (gw_gtk_menu_get_type()) +#define GTK_TYPE_MENU_ITEM (gw_gtk_menu_item_get_type()) +#define GTK_TYPE_MENU_SHELL (gw_gtk_menu_shell_get_type()) +#define GTK_TYPE_WIDGET (gw_gtk_widget_get_type()) + +#define GTK_FILE_CHOOSER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_FILE_CHOOSER, GtkFileChooser)) + +#define GTK_WIDGET(widget) \ + (G_TYPE_CHECK_INSTANCE_CAST((widget), GTK_TYPE_WIDGET, GtkWidget)) + +#define GTK_CHECK_MENU_ITEM(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_CHECK_MENU_ITEM, GtkCheckMenuItem)) + +#define GTK_MENU_SHELL(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_MENU_SHELL, GtkMenuShell)) + +#define GTK_MENU_ITEM(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_MENU_ITEM, GtkMenuItem)) + +#define GTK_MENU(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_MENU, GtkMenu)) + +#define _GDK_MAKE_ATOM(val) ((GdkAtom)GUINT_TO_POINTER(val)) + +#define GDK_NONE _GDK_MAKE_ATOM(0) +#define GDK_SELECTION_PRIMARY _GDK_MAKE_ATOM(1) +#define GDK_SELECTION_CLIPBOARD _GDK_MAKE_ATOM(69) + + +typedef cairo_rectangle_int_t GdkRectangle; +typedef struct _GdkAtom *GdkAtom; +typedef struct _GdkDevice GdkDevice; +typedef struct _GdkDisplay GdkDisplay; +typedef struct _GdkDragContext GdkDragContext; +typedef struct _GdkDrawable GdkWindow; +typedef struct _GdkEventSequence GdkEventSequence; +typedef struct _GdkKeymap GdkKeymap; +typedef struct _GtkCheckMenuItem GtkCheckMenuItem; +typedef struct _GtkClipboard GtkClipboard; +typedef struct _GtkDialog GtkDialog; +typedef struct _GtkFileChooser GtkFileChooser; +typedef struct _GtkIMContext GtkIMContext; +typedef struct _GtkMenu GtkMenu; +typedef struct _GtkMenuItem GtkMenuItem; +typedef struct _GtkMenuShell GtkMenuShell; +typedef struct _GtkSelectionData GtkSelectionData; +typedef struct _GtkWidget GtkWidget; +typedef struct _GtkWindow GtkWindow; + + +typedef enum { + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, + GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, +} GtkFileChooserAction; + +typedef enum { + GDK_VISIBILITY_UNOBSCURED, + GDK_VISIBILITY_PARTIAL, + GDK_VISIBILITY_FULLY_OBSCURED, +} GdkVisibilityState; + +typedef enum { + GDK_SCROLL_UP, + GDK_SCROLL_DOWN, + GDK_SCROLL_LEFT, + GDK_SCROLL_RIGHT, + GDK_SCROLL_SMOOTH, +} GdkScrollDirection; + +typedef enum { + GDK_CROSSING_NORMAL, + GDK_CROSSING_GRAB, + GDK_CROSSING_UNGRAB, + GDK_CROSSING_GTK_GRAB, + GDK_CROSSING_GTK_UNGRAB, + GDK_CROSSING_STATE_CHANGED, + GDK_CROSSING_TOUCH_BEGIN, + GDK_CROSSING_TOUCH_END, + GDK_CROSSING_DEVICE_SWITCH, +} GdkCrossingMode; + +typedef enum { + GDK_NOTIFY_ANCESTOR = 0, + GDK_NOTIFY_VIRTUAL = 1, + GDK_NOTIFY_INFERIOR = 2, + GDK_NOTIFY_NONLINEAR = 3, + GDK_NOTIFY_NONLINEAR_VIRTUAL = 4, + GDK_NOTIFY_UNKNOWN = 5, +} GdkNotifyType; + +typedef enum { + GDK_OWNER_CHANGE_NEW_OWNER, + GDK_OWNER_CHANGE_DESTROY, + GDK_OWNER_CHANGE_CLOSE, +} GdkOwnerChange; + +typedef enum { + GDK_SETTING_ACTION_NEW, + GDK_SETTING_ACTION_CHANGED, + GDK_SETTING_ACTION_DELETED, +} GdkSettingAction; + +typedef enum { + GDK_WINDOW_STATE_WITHDRAWN = 1 << 0, + GDK_WINDOW_STATE_ICONIFIED = 1 << 1, + GDK_WINDOW_STATE_MAXIMIZED = 1 << 2, + GDK_WINDOW_STATE_STICKY = 1 << 3, + GDK_WINDOW_STATE_FULLSCREEN = 1 << 4, + GDK_WINDOW_STATE_ABOVE = 1 << 5, + GDK_WINDOW_STATE_BELOW = 1 << 6, + GDK_WINDOW_STATE_FOCUSED = 1 << 7, + GDK_WINDOW_STATE_TILED = 1 << 8, +} GdkWindowState; + +typedef enum { + GDK_NOTHING = -1, + GDK_DELETE = 0, + GDK_DESTROY = 1, + GDK_EXPOSE = 2, + GDK_MOTION_NOTIFY = 3, + GDK_BUTTON_PRESS = 4, + GDK_2BUTTON_PRESS = 5, + GDK_3BUTTON_PRESS = 6, + GDK_BUTTON_RELEASE = 7, + GDK_KEY_PRESS = 8, + GDK_KEY_RELEASE = 9, + GDK_ENTER_NOTIFY = 10, + GDK_LEAVE_NOTIFY = 11, + GDK_FOCUS_CHANGE = 12, + GDK_CONFIGURE = 13, + GDK_MAP = 14, + GDK_UNMAP = 15, + GDK_PROPERTY_NOTIFY = 16, + GDK_SELECTION_CLEAR = 17, + GDK_SELECTION_REQUEST = 18, + GDK_SELECTION_NOTIFY = 19, + GDK_PROXIMITY_IN = 20, + GDK_PROXIMITY_OUT = 21, + GDK_DRAG_ENTER = 22, + GDK_DRAG_LEAVE = 23, + GDK_DRAG_MOTION = 24, + GDK_DRAG_STATUS = 25, + GDK_DROP_START = 26, + GDK_DROP_FINISHED = 27, + GDK_CLIENT_EVENT = 28, + GDK_VISIBILITY_NOTIFY = 29, + GDK_NO_EXPOSE = 30, + GDK_SCROLL = 31, + GDK_WINDOW_STATE = 32, + GDK_SETTING = 33, + GDK_OWNER_CHANGE = 34, + GDK_GRAB_BROKEN = 35, + GDK_DAMAGE = 36, + GDK_EVENT_LAST, +} GdkEventType; + +typedef enum { + GTK_RESPONSE_NONE = -1, + GTK_RESPONSE_REJECT = -2, + GTK_RESPONSE_ACCEPT = -3, + GTK_RESPONSE_DELETE_EVENT = -4, + GTK_RESPONSE_OK = -5, + GTK_RESPONSE_CANCEL = -6, + GTK_RESPONSE_CLOSE = -7, + GTK_RESPONSE_YES = -8, + GTK_RESPONSE_NO = -9, + GTK_RESPONSE_APPLY = -10, + GTK_RESPONSE_HELP = -11, +} GtkResponseType; + +typedef struct _GdkEventAny { + GdkEventType type; + GdkWindow *window; + gint8 send_event; +} GdkEventAny; + +typedef struct _GdkEventExpose { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + GdkRectangle area; + cairo_region_t *region; + gint count; +} GdkEventExpose; + +typedef struct _GdkEventVisibility { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + GdkVisibilityState state; +} GdkEventVisibility; + +typedef struct _GdkEventMotion { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + guint32 time; + gdouble x, y; + gdouble *axes; + guint state; + gint16 is_hint; + GdkDevice *device; + gdouble x_root, y_root; +} GdkEventMotion; + +typedef struct _GdkEventButton { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + guint32 time; + gdouble x, y; + gdouble *axes; + guint state; + guint button; + GdkDevice *device; + gdouble x_root, y_root; +} GdkEventButton; + +typedef struct _GdkEventTouch { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + guint32 time; + gdouble x, y; + gdouble *axes; + guint state; + GdkEventSequence *sequence; + gboolean emulating_pointer; + GdkDevice *device; + gdouble x_root, y_root; +} GdkEventTouch; + +typedef struct _GdkEventScroll { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + guint32 time; + gdouble x, y; + guint state; + GdkScrollDirection direction; + GdkDevice *device; + gdouble x_root, y_root; + gdouble delta_x, delta_y; + guint is_stop:1; +} GdkEventScroll; + +typedef struct _GdkEventKey { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + guint32 time; + guint state; + guint keyval; + gint length; + gchar *string; + guint16 hardware_keycode; + guint8 group; + guint is_modifier:1; +} GdkEventKey; + +typedef struct _GdkEventCrossing { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + GdkWindow *subwindow; + guint32 time; + gdouble x, y; + gdouble x_root, y_root; + GdkCrossingMode mode; + GdkNotifyType detail; + gboolean focus; + guint state; +} GdkEventCrossing; + +typedef struct _GdkEventFocus { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + gint16 in; +} GdkEventFocus; + +typedef struct _GdkEventConfigure { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + gint x, y; + gint width; + gint height; +} GdkEventConfigure; + +typedef struct _GdkEventProperty { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + GdkAtom atom; + guint32 time; + guint state; +} GdkEventProperty; + +typedef struct _GdkEventSelection { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + GdkAtom selection; + GdkAtom target; + GdkAtom property; + guint32 time; + GdkWindow *requestor; +} GdkEventSelection; + +typedef struct _GdkEventOwnerChange { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + GdkWindow *owner; + GdkOwnerChange reason; + GdkAtom selection; + guint32 time; + guint32 selection_time; +} GdkEventOwnerChange; + +typedef struct _GdkEventProximity { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + guint32 time; + GdkDevice *device; +} GdkEventProximity; + +typedef struct _GdkEventSetting { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + GdkSettingAction action; + char *name; +} GdkEventSetting; + +typedef struct _GdkEventWindowState { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + GdkWindowState changed_mask; + GdkWindowState new_window_state; +} GdkEventWindowState; + +typedef struct _GdkEventGrabBroken { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + gboolean keyboard; + gboolean implicit; + GdkWindow *grab_window; +} GdkEventGrabBroken; + +typedef struct _GdkEventDND { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + GdkDragContext *context; + guint32 time; + gshort x_root, y_root; +} GdkEventDND; + +typedef struct _GdkEventTouchpadSwipe { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + gint8 phase; + gint8 n_fingers; + guint32 time; + gdouble x, y; + gdouble dx, dy; + gdouble x_root, y_root; + guint state; +} GdkEventTouchpadSwipe; + +typedef struct _GdkEventTouchpadPinch { + GdkEventType type; + GdkWindow *window; + gint8 send_event; + gint8 phase; + gint8 n_fingers; + guint32 time; + gdouble x, y; + gdouble dx, dy; + gdouble angle_delta; + gdouble scale; + gdouble x_root, y_root; + guint state; +} GdkEventTouchpadPinch; + +typedef union _GdkEvent { + GdkEventType type; + GdkEventAny any; + GdkEventExpose expose; + GdkEventVisibility visibility; + GdkEventMotion motion; + GdkEventButton button; + GdkEventTouch touch; + GdkEventScroll scroll; + GdkEventKey key; + GdkEventCrossing crossing; + GdkEventFocus focus_change; + GdkEventConfigure configure; + GdkEventProperty property; + GdkEventSelection selection; + GdkEventOwnerChange owner_change; + GdkEventProximity proximity; + GdkEventDND dnd; + GdkEventWindowState window_state; + GdkEventSetting setting; + GdkEventGrabBroken grab_broken; + GdkEventTouchpadSwipe touchpad_swipe; + GdkEventTouchpadPinch touchpad_pinch; +} GdkEvent; + +typedef struct _GdkKeymapKey { + guint keycode; + gint group; + gint level; +} GdkKeymapKey; + +typedef struct _GtkTargetEntry { + gchar *target; + guint flags; + guint info; +} GtkTargetEntry; + + +typedef void (*GtkClipboardGetFunc)(GtkClipboard *clipboard, GtkSelectionData *selection_data, + guint info, gpointer user_data_or_owner); + +typedef void (*GtkClipboardClearFunc)(GtkClipboard *clipboard, gpointer user_data_or_owner); + +typedef void (*GtkMenuPositionFunc)(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, + gpointer user_data); + +// list of pointers to GTK+ functions + +extern +GdkAtom +(*gw_gdk_atom_intern)(const gchar *atom_name, gboolean only_if_exists); + +extern +GdkAtom +(*gw_gdk_atom_intern_static_string)(const gchar *atom_name); + +extern +gchar * +(*gw_gdk_atom_name)(GdkAtom atom); + +extern +GdkDisplay * +(*gw_gdk_display_get_default)(void); + +extern +void +(*gw_gdk_event_free)(GdkEvent *event); + +extern +GdkEvent * +(*gw_gdk_event_new)(GdkEventType type); + +extern +gboolean +(*gw_gdk_keymap_get_entries_for_keycode)(GdkKeymap *keymap, guint hardware_keycode, + GdkKeymapKey **keys, guint **keyvals, gint *n_entries); + +extern +GdkKeymap * +(*gw_gdk_keymap_get_for_display)(GdkDisplay *display); + +extern +GdkDisplay * +(*gw_gdk_window_get_display)(GdkWindow *window); + +extern +void +(*gw_gdk_window_set_user_data)(GdkWindow *window, gpointer user_data); + +extern +Display * +(*gw_gdk_x11_display_get_xdisplay)(GdkDisplay *display); + +extern +Window +(*gw_gdk_x11_drawable_get_xid)(GdkWindow *window); + +extern +GdkDisplay * +(*gw_gdk_x11_lookup_xdisplay)(Display *xdisplay); + +extern +GdkWindow * +(*gw_gdk_x11_window_foreign_new_for_display)(GdkDisplay *display, Window window); + +extern +GdkWindow * +(*gw_gdk_x11_window_lookup_for_display)(GdkDisplay *display, Window window); + +extern +GType +(*gw_gtk_check_menu_item_get_type)(void); + +extern +GtkWidget * +(*gw_gtk_check_menu_item_new_with_label)(const gchar *label); + +extern +void +(*gw_gtk_check_menu_item_set_active)(GtkCheckMenuItem *check_menu_item, gboolean is_active); + +extern +void +(*gw_gtk_clipboard_clear)(GtkClipboard *clipboard); + +extern +GtkClipboard * +(*gw_gtk_clipboard_get)(GdkAtom selection); + +extern +void +(*gw_gtk_clipboard_set_can_store)(GtkClipboard *clipboard, const GtkTargetEntry *targets, + gint n_targets); +extern +gboolean +(*gw_gtk_clipboard_set_with_data)(GtkClipboard *clipboard, const GtkTargetEntry *targets, + guint n_targets, GtkClipboardGetFunc get_func, + GtkClipboardClearFunc clear_func, gpointer user_data); +extern +GtkSelectionData * +(*gw_gtk_clipboard_wait_for_contents)(GtkClipboard *clipboard, GdkAtom target); + +extern +gboolean +(*gw_gtk_clipboard_wait_is_target_available)(GtkClipboard *clipboard, GdkAtom target); + +extern +GtkWidget * +(*gw_gtk_file_chooser_dialog_new)(const gchar *title, GtkWindow *parent, + GtkFileChooserAction action, const gchar *first_button_text, ...); + +extern +GSList * +(*gw_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser); + +extern +GType +(*gw_gtk_file_chooser_get_type)(void); + +extern +void +(*gw_gtk_file_chooser_set_select_multiple)(GtkFileChooser *chooser, gboolean select_multiple); + +extern +guint32 +(*gw_gtk_get_current_event_time)(void); + +extern +gboolean +(*gw_gtk_im_context_filter_keypress)(GtkIMContext *context, GdkEventKey *event); + +extern +void +(*gw_gtk_im_context_focus_in)(GtkIMContext *context); + +extern +void +(*gw_gtk_im_context_focus_out)(GtkIMContext *context); + +extern +void +(*gw_gtk_im_context_get_preedit_string)(GtkIMContext *context, gchar **str, PangoAttrList **attrs, + gint *cursor_pos); + +extern +void +(*gw_gtk_im_context_reset)(GtkIMContext *context); + +extern +void +(*gw_gtk_im_context_set_client_window)(GtkIMContext *context, GdkWindow *window); + +extern +void +(*gw_gtk_im_context_set_cursor_location)(GtkIMContext *context, const GdkRectangle *area); + +extern +void +(*gw_gtk_im_context_set_surrounding)(GtkIMContext *context, const gchar *text, gint len, + gint cursor_index); + +extern +GtkIMContext * +(*gw_gtk_im_context_simple_new)(void); + +extern +GtkIMContext * +(*gw_gtk_im_multicontext_new)(void); + +extern +GtkWidget * +(*gw_gtk_label_new)(const gchar *str); + +extern +GType +(*gw_gtk_menu_get_type)(void); + +extern +GType +(*gw_gtk_menu_item_get_type)(void); + +extern +GtkWidget * +(*gw_gtk_menu_item_new_with_label)(const gchar *label); + +extern +void +(*gw_gtk_menu_item_set_submenu)(GtkMenuItem *menu_item, GtkWidget *submenu); + +extern +GtkWidget * +(*gw_gtk_menu_new)(void); + +extern +void +(*gw_gtk_menu_popup)(GtkMenu *menu, GtkWidget *parent_menu_shell, GtkWidget *parent_menu_item, + GtkMenuPositionFunc func, gpointer data, guint button, guint32 activate_time); + +extern +void +(*gw_gtk_menu_shell_append)(GtkMenuShell *menu_shell, GtkWidget *child); + +extern +GType +(*gw_gtk_menu_shell_get_type)(void); + +extern +void +(*gw_gtk_selection_data_free)(GtkSelectionData *data); + +extern +const guchar * +(*gw_gtk_selection_data_get_data)(const GtkSelectionData *selection_data); + +extern +gint +(*gw_gtk_selection_data_get_length)(const GtkSelectionData *selection_data); + +extern +void +(*gw_gtk_selection_data_set)(GtkSelectionData *selection_data, GdkAtom type, gint format, + const guchar *data, gint length); + +extern +GtkWidget * +(*gw_gtk_separator_menu_item_new)(void); + +extern +void +(*gw_gtk_widget_destroy)(GtkWidget *widget); + +extern +GType +(*gw_gtk_widget_get_type)(void); + +extern +GdkWindow * +(*gw_gtk_widget_get_window)(GtkWidget *widget); + +extern +void +(*gw_gtk_widget_realize)(GtkWidget *widget); + +extern +void +(*gw_gtk_widget_set_realized)(GtkWidget *widget, gboolean realized); + +extern +void +(*gw_gtk_widget_set_sensitive)(GtkWidget *widget, gboolean sensitive); + +extern +void +(*gw_gtk_widget_show)(GtkWidget *widget); + +// end of function pointers list + +void +gtk_wrapper_initialize(void); + +int +gw_major_version(void); + +int +gw_minor_version(void); + +int +gw_gtk_available(void); diff -Nru freshplayerplugin-0.3.5/src/header_parser.c freshplayerplugin-0.3.6/src/header_parser.c --- freshplayerplugin-0.3.5/src/header_parser.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/header_parser.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/header_parser.h freshplayerplugin-0.3.6/src/header_parser.h --- freshplayerplugin-0.3.5/src/header_parser.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/header_parser.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/keycodeconvert.c freshplayerplugin-0.3.6/src/keycodeconvert.c --- freshplayerplugin-0.3.5/src/keycodeconvert.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/keycodeconvert.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/keycodeconvert.h freshplayerplugin-0.3.6/src/keycodeconvert.h --- freshplayerplugin-0.3.5/src/keycodeconvert.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/keycodeconvert.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/keycodepp.h freshplayerplugin-0.3.6/src/keycodepp.h --- freshplayerplugin-0.3.5/src/keycodepp.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/keycodepp.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/link_check.c freshplayerplugin-0.3.6/src/link_check.c --- freshplayerplugin-0.3.5/src/link_check.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/link_check.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/main_thread.c freshplayerplugin-0.3.6/src/main_thread.c --- freshplayerplugin-0.3.5/src/main_thread.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/main_thread.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/main_thread.h freshplayerplugin-0.3.6/src/main_thread.h --- freshplayerplugin-0.3.5/src/main_thread.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/main_thread.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/n2p_proxy_class.c freshplayerplugin-0.3.6/src/n2p_proxy_class.c --- freshplayerplugin-0.3.5/src/n2p_proxy_class.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/n2p_proxy_class.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/n2p_proxy_class.h freshplayerplugin-0.3.6/src/n2p_proxy_class.h --- freshplayerplugin-0.3.5/src/n2p_proxy_class.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/n2p_proxy_class.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/np_entry.c freshplayerplugin-0.3.6/src/np_entry.c --- freshplayerplugin-0.3.5/src/np_entry.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/np_entry.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * @@ -43,6 +43,7 @@ #include "tables.h" #include "main_thread.h" #include "ppb_core.h" +#include "gtk_wrapper.h" static void *module_dl_handler; @@ -523,6 +524,14 @@ np_initialize_was_called = 1; setup_sig_handlers(); + gtk_wrapper_initialize(); + + if (!gw_gtk_available()) { + trace_error("no GTK+ loaded\n"); + return NPERR_NO_ERROR; + } + + trace_info_f("found GTK+ %d.%d\n", gw_major_version(), gw_minor_version()); // set logging-only error handler. // Ignore a previous one, we have no plans to restore it diff -Nru freshplayerplugin-0.3.5/src/np_entry.h freshplayerplugin-0.3.6/src/np_entry.h --- freshplayerplugin-0.3.5/src/np_entry.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/np_entry.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/np_functions.c freshplayerplugin-0.3.6/src/np_functions.c --- freshplayerplugin-0.3.5/src/np_functions.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/np_functions.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * @@ -34,8 +34,6 @@ #include #include #include -#include -#include #include "trace.h" #include "reverse_constant.h" #include "pp_interface.h" @@ -93,8 +91,8 @@ pthread_mutex_lock(&display.lock); v->rect.point.x = 0; v->rect.point.y = 0; - v->rect.size.width = pp_i->width / config.device_scale; - v->rect.size.height = pp_i->height / config.device_scale; + v->rect.size.width = pp_i->width / config.device_scale + 0.5; + v->rect.size.height = pp_i->height / config.device_scale + 0.5; pp_resource_release(view); pthread_mutex_unlock(&display.lock); @@ -340,7 +338,7 @@ struct PP_Var text; uint32_t offsets[2]; - gtk_im_context_get_preedit_string(im_context, &preedit_string, NULL, &cursor_pos); + gw_gtk_im_context_get_preedit_string(im_context, &preedit_string, NULL, &cursor_pos); ptr = preedit_string; for (int k = 0; k < cursor_pos; k ++) @@ -412,7 +410,7 @@ }; // untie GdkWindow from auxiliary widget - gdk_window_set_user_data(event->key.window, NULL); + gw_gdk_window_set_user_data(event->key.window, NULL); handle_key_press_release_event(pp_i->npp, &ev); return TRUE; @@ -541,13 +539,13 @@ } // prepare GTK+ widget for catching keypress events returned by IME - pp_i->catcher_widget = gtk_label_new(""); - gtk_widget_set_realized(pp_i->catcher_widget, TRUE); + pp_i->catcher_widget = gw_gtk_label_new(""); + gw_gtk_widget_set_realized(pp_i->catcher_widget, TRUE); g_signal_connect(pp_i->catcher_widget, "key-press-event", G_CALLBACK(catcher_key_press), pp_i); pp_i->textinput_type = PP_TEXTINPUT_TYPE_DEV_NONE; - pp_i->im_context_multi = gtk_im_multicontext_new(); - pp_i->im_context_simple = gtk_im_context_simple_new(); + pp_i->im_context_multi = gw_gtk_im_multicontext_new(); + pp_i->im_context_simple = gw_gtk_im_context_simple_new(); pp_i->im_context = NULL; g_signal_connect(pp_i->im_context_multi, "commit", G_CALLBACK(im_commit), pp_i); @@ -1134,14 +1132,14 @@ Picture dst_pict = XRenderCreatePicture(dpy, drawable, display.pictfmt_rgb24, 0, 0); XRenderComposite(dpy, pp_i->is_transparent ? PictOpOver : PictOpSrc, - g3d->xr_pict, None, dst_pict, + g3d->xr_pict[1], None, dst_pict, ev->x, ev->y, 0, 0, ev->x, ev->y, ev->width, ev->height); XRenderFreePicture(dpy, dst_pict); XFlush(dpy); } else { // software compositing fallback - draw_drawable_on_drawable(dpy, screen, pp_i->is_transparent, g3d->pixmap, source_x, + draw_drawable_on_drawable(dpy, screen, pp_i->is_transparent, g3d->pixmap[1], source_x, source_y, drawable, ev->x, ev->y, ev->width, ev->height); } } else { @@ -1330,8 +1328,8 @@ if (!(PP_INPUTEVENT_CLASS_MOUSE & combined_mask)) return 0; - struct PP_Point mouse_position = {.x = ev->x / config.device_scale, - .y = ev->y / config.device_scale }; + struct PP_Point mouse_position = {.x = ev->x / config.device_scale + 0.5, + .y = ev->y / config.device_scale + 0.5 }; struct PP_Point zero_point = {.x = 0, .y = 0}; unsigned int mod = x_state_mask_to_pp_inputevent_modifier(ev->state); PP_InputEvent_Type event_type = (ev->type == EnterNotify) ? PP_INPUTEVENT_TYPE_MOUSEENTER @@ -1360,8 +1358,8 @@ if (!(PP_INPUTEVENT_CLASS_MOUSE & combined_mask)) return 0; - struct PP_Point mouse_position = {.x = ev->x / config.device_scale, - .y = ev->y / config.device_scale}; + struct PP_Point mouse_position = {.x = ev->x / config.device_scale + 0.5, + .y = ev->y / config.device_scale + 0.5 }; struct PP_Point zero_point = {.x = 0, .y = 0}; unsigned int mod = x_state_mask_to_pp_inputevent_modifier(ev->state); PP_Resource pp_event; @@ -1386,8 +1384,8 @@ if (!pp_i->ppp_input_event) return 0; - struct PP_Point mouse_position = {.x = ev->x / config.device_scale, - .y = ev->y / config.device_scale }; + struct PP_Point mouse_position = {.x = ev->x / config.device_scale + 0.5, + .y = ev->y / config.device_scale + 0.5 }; struct PP_Point zero_point = {.x = 0, .y = 0}; unsigned int mod = x_state_mask_to_pp_inputevent_modifier(ev->state); float wheel_x = 0.0, wheel_y = 0.0; @@ -1476,9 +1474,9 @@ static GdkEvent * make_gdk_key_event_from_x_key(XKeyEvent *ev) { - GdkDisplay *gdpy = gdk_x11_lookup_xdisplay(ev->display); + GdkDisplay *gdpy = gw_gdk_x11_lookup_xdisplay(ev->display); if (!gdpy) - gdpy = gdk_display_get_default(); + gdpy = gw_gdk_display_get_default(); if (!gdpy) { trace_error("%s, gdpy is NULL\n", __func__); @@ -1488,12 +1486,12 @@ KeySym keysym = NoSymbol; guint8 keyboard_group = 0; XLookupString(ev, NULL, 0, &keysym, NULL); - GdkKeymap *keymap = gdk_keymap_get_for_display(gdpy); + GdkKeymap *keymap = gw_gdk_keymap_get_for_display(gdpy); GdkKeymapKey *keys = NULL; guint *keyvals = NULL; gint n_entries = 0; if (keymap && - gdk_keymap_get_entries_for_keycode(keymap, ev->keycode, &keys, &keyvals, &n_entries)) + gw_gdk_keymap_get_entries_for_keycode(keymap, ev->keycode, &keys, &keyvals, &n_entries)) { for (gint i = 0; i < n_entries; ++i) { if (keyvals[i] == keysym) { @@ -1506,11 +1504,11 @@ g_free(keyvals); keyvals = NULL; // Get a GdkWindow. - GdkWindow *gwnd = gdk_x11_window_lookup_for_display(gdpy, ev->window); + GdkWindow *gwnd = gw_gdk_x11_window_lookup_for_display(gdpy, ev->window); if (gwnd) g_object_ref(gwnd); else - gwnd = gdk_x11_window_foreign_new_for_display(gdpy, ev->window); + gwnd = gw_gdk_x11_window_foreign_new_for_display(gdpy, ev->window); if (!gwnd) { trace_error("%s, gdpy is NULL (2)\n", __func__); return NULL; @@ -1518,7 +1516,7 @@ // Create a GdkEvent. GdkEventType event_type = ev->type == KeyPress ? GDK_KEY_PRESS : GDK_KEY_RELEASE; - GdkEvent *event = gdk_event_new(event_type); + GdkEvent *event = gw_gdk_event_new(event_type); event->key.type = event_type; event->key.window = gwnd; @@ -1559,18 +1557,18 @@ GdkEvent *gev = make_gdk_key_event_from_x_key(ev); if (gev) { // tie catcher_widget to GdkWindow - gdk_window_set_user_data(gev->key.window, pp_i->catcher_widget); + gw_gdk_window_set_user_data(gev->key.window, pp_i->catcher_widget); - gtk_im_context_set_client_window(pp_i->im_context, gev->key.window); - gboolean stop = gtk_im_context_filter_keypress(pp_i->im_context, &gev->key); + gw_gtk_im_context_set_client_window(pp_i->im_context, gev->key.window); + gboolean stop = gw_gtk_im_context_filter_keypress(pp_i->im_context, &gev->key); if (!stop) { // stop == 0 means gev and its GdkWindow is no longer needed and will be freed // by subsequent gdk_event_free, therefore we untie auxiliary widget, just in case. - gdk_window_set_user_data(gev->key.window, NULL); + gw_gdk_window_set_user_data(gev->key.window, NULL); } - gdk_event_free(gev); + gw_gdk_event_free(gev); if (stop) { pthread_mutex_unlock(&display.lock); return 1; @@ -1652,9 +1650,9 @@ PP_Bool has_focus = (ev->type == FocusIn) ? PP_TRUE : PP_FALSE; if (pp_i->im_context) { if (ev->type == FocusIn) - gtk_im_context_focus_in(pp_i->im_context); + gw_gtk_im_context_focus_in(pp_i->im_context); else - gtk_im_context_focus_out(pp_i->im_context); + gw_gtk_im_context_focus_out(pp_i->im_context); } ppb_core_call_on_main_thread2(0, PP_MakeCCB(call_ppp_did_change_focus_comt, diff -Nru freshplayerplugin-0.3.5/src/np_libpdf_frontend.c freshplayerplugin-0.3.6/src/np_libpdf_frontend.c --- freshplayerplugin-0.3.5/src/np_libpdf_frontend.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/np_libpdf_frontend.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/p2n_proxy_class.c freshplayerplugin-0.3.6/src/p2n_proxy_class.c --- freshplayerplugin-0.3.5/src/p2n_proxy_class.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/p2n_proxy_class.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/p2n_proxy_class.h freshplayerplugin-0.3.6/src/p2n_proxy_class.h --- freshplayerplugin-0.3.5/src/p2n_proxy_class.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/p2n_proxy_class.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_audio.c freshplayerplugin-0.3.6/src/ppb_audio.c --- freshplayerplugin-0.3.5/src/ppb_audio.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_audio.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_audio_config.c freshplayerplugin-0.3.6/src/ppb_audio_config.c --- freshplayerplugin-0.3.5/src/ppb_audio_config.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_audio_config.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_audio_config.h freshplayerplugin-0.3.6/src/ppb_audio_config.h --- freshplayerplugin-0.3.5/src/ppb_audio_config.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_audio_config.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_audio.h freshplayerplugin-0.3.6/src/ppb_audio.h --- freshplayerplugin-0.3.5/src/ppb_audio.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_audio.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_audio_input.c freshplayerplugin-0.3.6/src/ppb_audio_input.c --- freshplayerplugin-0.3.5/src/ppb_audio_input.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_audio_input.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_audio_input.h freshplayerplugin-0.3.6/src/ppb_audio_input.h --- freshplayerplugin-0.3.5/src/ppb_audio_input.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_audio_input.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_browser_font.c freshplayerplugin-0.3.6/src/ppb_browser_font.c --- freshplayerplugin-0.3.5/src/ppb_browser_font.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_browser_font.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_browser_font.h freshplayerplugin-0.3.6/src/ppb_browser_font.h --- freshplayerplugin-0.3.5/src/ppb_browser_font.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_browser_font.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_buffer.c freshplayerplugin-0.3.6/src/ppb_buffer.c --- freshplayerplugin-0.3.5/src/ppb_buffer.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_buffer.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_buffer.h freshplayerplugin-0.3.6/src/ppb_buffer.h --- freshplayerplugin-0.3.5/src/ppb_buffer.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_buffer.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_char_set.c freshplayerplugin-0.3.6/src/ppb_char_set.c --- freshplayerplugin-0.3.5/src/ppb_char_set.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_char_set.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * @@ -24,86 +24,80 @@ #include "ppb_char_set.h" #include "ppb_memory.h" +#include "encoding_alias.h" #include #include #include -#include #include "trace.h" #include "tables.h" #include "reverse_constant.h" #include "ppb_var.h" #include "pp_interface.h" +#include +#include +#include +#include -static -const char * -get_supported_charset_alias(const char *charset) -{ - if (strcasecmp(charset, "gb2312-80") == 0) { - return "gb2312"; - } else { - return charset; - } -} - char * ppb_char_set_utf16_to_char_set(PP_Instance instance, const uint16_t *utf16, uint32_t utf16_len, const char *output_char_set, enum PP_CharSet_ConversionError on_error, uint32_t *output_length) { + // each character could take up to 4 bytes in UTF-8; with additional zero-terminator byte const uint32_t output_buffer_length = (utf16_len + 1) * 4 + 1; char *output = ppb_memory_mem_alloc(output_buffer_length); - char *inbuf = (char*)utf16; - char *outbuf = (char*)output; - size_t inbytesleft = utf16_len * 2; - size_t outbytesleft = output_buffer_length - 1; - iconv_t cd; - char *tmp; - output_char_set = get_supported_charset_alias(output_char_set); + if (!output) { + trace_error("%s, can't allocate memory, %u bytes\n", __func__, output_buffer_length); + goto err; + } + + const char *charset = encoding_alias_get_canonical_name(output_char_set); + + const UChar subst = '?'; + UErrorCode st = U_ZERO_ERROR; + UConverter *u = ucnv_open(charset, &st); + if (!U_SUCCESS(st)) { + trace_error("%s, wrong charset %s\n", __func__, output_char_set); + goto err; + } switch (on_error) { default: case PP_CHARSET_CONVERSIONERROR_FAIL: - cd = iconv_open(output_char_set, "UTF16LE"); + st = U_ZERO_ERROR; + ucnv_setFromUCallBack(u, UCNV_FROM_U_CALLBACK_STOP, NULL, NULL, NULL, &st); break; + case PP_CHARSET_CONVERSIONERROR_SKIP: - tmp = g_strdup_printf("%s//IGNORE", output_char_set); - cd = iconv_open(tmp, "UTF16LE"); - g_free(tmp); + st = U_ZERO_ERROR; + ucnv_setFromUCallBack(u, UCNV_FROM_U_CALLBACK_SKIP, NULL, NULL, NULL, &st); break; + case PP_CHARSET_CONVERSIONERROR_SUBSTITUTE: - tmp = g_strdup_printf("%s//TRANSLIT", output_char_set); - cd = iconv_open(tmp, "UTF16LE"); - g_free(tmp); + st = U_ZERO_ERROR; + ucnv_setFromUCallBack(u, UCNV_FROM_U_CALLBACK_SUBSTITUTE, NULL, NULL, NULL, &st); + + st = U_ZERO_ERROR; + ucnv_setSubstString(u, &subst, 1, &st); break; } - if (cd == (iconv_t)-1) { - trace_error("%s, wrong charset %s\n", __func__, output_char_set); - memcpy(output, utf16, inbytesleft); - *output_length = inbytesleft; - return output; - } - - size_t ret = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); - if (ret == (size_t) -1) { - if (errno == E2BIG) { - trace_warning("%s, this should never happen\n", __func__); - } else { - if (on_error == PP_CHARSET_CONVERSIONERROR_FAIL) { - ppb_memory_mem_free(output); - *output_length = 0; - iconv_close(cd); - return NULL; - } - } - } + *output_length = ucnv_fromUChars(u, output, output_buffer_length, utf16, utf16_len, &st); + + if (st != U_BUFFER_OVERFLOW_ERROR && !U_SUCCESS(st)) + goto err; - *output_length = output_buffer_length - 1 - outbytesleft; - output[*output_length] = 0; - iconv_close(cd); + ucnv_close(u); return output; + +err: + *output_length = 0; + ppb_memory_mem_free(output); + if (u) + ucnv_close(u); + return NULL; } uint16_t * @@ -111,61 +105,168 @@ const char *input_char_set, enum PP_CharSet_ConversionError on_error, uint32_t *output_length) { - const uint32_t output_buffer_length = (input_len + 2) * sizeof(uint16_t); + // each character could be converted into a surrogate pair + const uint32_t output_buffer_length = (input_len + 2) * 2 * sizeof(uint16_t); uint16_t *output = ppb_memory_mem_alloc(output_buffer_length); - char *inbuf = (char *)input; - char *outbuf = (char *)output; - size_t inbytesleft = input_len; - size_t outbytesleft = output_buffer_length - 2; - iconv_t cd; - input_char_set = get_supported_charset_alias(input_char_set); + if (!output) { + trace_error("%s, can't allocate memory, %u bytes\n", __func__, output_buffer_length); + goto err; + } + + const char *charset = encoding_alias_get_canonical_name(input_char_set); + + const UChar subst = '?'; + UErrorCode st = U_ZERO_ERROR; + UConverter *u = ucnv_open(charset, &st); + if (!U_SUCCESS(st)) { + trace_error("%s, wrong charset %s\n", __func__, input_char_set); + goto err; + } switch (on_error) { default: case PP_CHARSET_CONVERSIONERROR_FAIL: - cd = iconv_open("UTF16LE", input_char_set); + st = U_ZERO_ERROR; + ucnv_setToUCallBack(u, UCNV_TO_U_CALLBACK_STOP, NULL, NULL, NULL, &st); break; + case PP_CHARSET_CONVERSIONERROR_SKIP: - cd = iconv_open("UTF16LE//IGNORE", input_char_set); + st = U_ZERO_ERROR; + ucnv_setToUCallBack(u, UCNV_TO_U_CALLBACK_SKIP, NULL, NULL, NULL, &st); break; + case PP_CHARSET_CONVERSIONERROR_SUBSTITUTE: - cd = iconv_open("UTF16LE//TRANSLIT", input_char_set); + st = U_ZERO_ERROR; + ucnv_setToUCallBack(u, UCNV_TO_U_CALLBACK_SUBSTITUTE, NULL, NULL, NULL, &st); + + st = U_ZERO_ERROR; + ucnv_setSubstString(u, &subst, 1, &st); break; } - if (cd == (iconv_t)-1) { - trace_error("%s, wrong charset %s\n", __func__, input_char_set); - memcpy(output, input, inbytesleft); - *output_length = inbytesleft / 2; - return output; - } - - size_t ret = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); - if (ret == (size_t) -1) { - if (errno == E2BIG) { - trace_warning("%s, this should never happen\n", __func__); - } else { - if (on_error == PP_CHARSET_CONVERSIONERROR_FAIL) { - ppb_memory_mem_free(output); - *output_length = 0; - iconv_close(cd); - return NULL; - } - } - } + st = U_ZERO_ERROR; + *output_length = ucnv_toUChars(u, output, output_buffer_length / sizeof(uint16_t), + input, input_len, &st); - *output_length = (output_buffer_length - 2 - outbytesleft) / sizeof(uint16_t); - output[*output_length] = 0; - iconv_close(cd); + if (st != U_BUFFER_OVERFLOW_ERROR && !U_SUCCESS(st)) + goto err; + + ucnv_close(u); return output; + +err: + *output_length = 0; + ppb_memory_mem_free(output); + if (u) + ucnv_close(u); + return NULL; +} + +static +char * +extract_relevant_part_from_locale_name(const char *locale_name) +{ + char *lang = strdup(locale_name ? locale_name : "en"); + + if (strncmp(lang, "zh", 2) == 0) { + // starts with zh. For Chinese languages country is required too + + // replace "_" by "-". That way "zh_CN.utf8" becomes "zh-CN.utf8" + char *ptr = strchr(lang, '_'); + if (ptr) + *ptr = '-'; + + // cut at ".". That way "zh-CN.utf8" becomes "zh-CN" + ptr = strchr(lang, '.'); + if (ptr) + *ptr = '\0'; + + return lang; + } + + // otherwise, leave only language. Cut at "_". That makes "ru" from "ru_RU.utf8" + char *ptr = strchr(lang, '_'); + if (ptr) + *ptr = '\0'; + + return lang; } struct PP_Var ppb_char_set_get_default_char_set(PP_Instance instance) { - setlocale(LC_ALL, ""); - return ppb_var_var_from_utf8_z(nl_langinfo(CODESET)); + char *lang = extract_relevant_part_from_locale_name(getenv("LANG")); + + struct lang_encoding { + const char *lang; + const char *encoding; + }; + + static const struct lang_encoding pairs[] = { + {"am", "windows-1252"}, + {"ar", "windows-1256"}, + {"bg", "windows-1251"}, + {"bn", "windows-1252"}, + {"ca", "windows-1252"}, + {"cs", "windows-1250"}, + {"da", "windows-1252"}, + {"de", "windows-1252"}, + {"el", "ISO-8859-7"}, + {"en", "windows-1252"}, + {"es", "windows-1252"}, + {"et", "windows-1257"}, + {"fa", "windows-1256"}, + {"fil", "windows-1252"}, + {"fi", "windows-1252"}, + {"fr", "windows-1252"}, + {"gu", "windows-1252"}, + {"he", "windows-1255"}, + {"hi", "windows-1252"}, + {"hr", "windows-1250"}, + {"hu", "ISO-8859-2"}, + {"id", "windows-1252"}, + {"it", "windows-1252"}, + {"ja", "Shift_JIS"}, + {"kn", "windows-1252"}, + {"ko", "windows-949"}, + {"lt", "windows-1257"}, + {"lv", "windows-1257"}, + {"ml", "windows-1252"}, + {"mr", "windows-1252"}, + {"nb", "windows-1252"}, + {"nl", "windows-1252"}, + {"pl", "ISO-8859-2"}, + {"pt", "windows-1252"}, + {"pt", "windows-1252"}, + {"ro", "ISO-8859-2"}, + {"ru", "windows-1251"}, + {"sk", "windows-1250"}, + {"sl", "ISO-8859-2"}, + {"sr", "windows-1251"}, + {"sv", "windows-1252"}, + {"sw", "windows-1252"}, + {"ta", "windows-1252"}, + {"te", "windows-1252"}, + {"th", "windows-874"}, + {"tr", "ISO-8859-9"}, + {"uk", "windows-1251"}, + {"vi", "windows-1258"}, + {"zh-CN", "GBK"}, + {"zh-TW", "Big5"}, + }; + + const char *enc = "windows-1252"; + for (uint32_t k = 0; k < sizeof(pairs)/sizeof(pairs[0]); k ++) { + if (strcasecmp(pairs[k].lang, lang) == 0) { + enc = pairs[k].encoding; + break; + } + } + + struct PP_Var ret = ppb_var_var_from_utf8_z(enc); + free(lang); + return ret; } diff -Nru freshplayerplugin-0.3.5/src/ppb_char_set.h freshplayerplugin-0.3.6/src/ppb_char_set.h --- freshplayerplugin-0.3.5/src/ppb_char_set.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_char_set.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_core.c freshplayerplugin-0.3.6/src/ppb_core.c --- freshplayerplugin-0.3.5/src/ppb_core.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_core.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_core.h freshplayerplugin-0.3.6/src/ppb_core.h --- freshplayerplugin-0.3.5/src/ppb_core.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_core.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_crypto.c freshplayerplugin-0.3.6/src/ppb_crypto.c --- freshplayerplugin-0.3.5/src/ppb_crypto.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_crypto.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_crypto.h freshplayerplugin-0.3.6/src/ppb_crypto.h --- freshplayerplugin-0.3.5/src/ppb_crypto.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_crypto.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_cursor_control.c freshplayerplugin-0.3.6/src/ppb_cursor_control.c --- freshplayerplugin-0.3.5/src/ppb_cursor_control.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_cursor_control.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_cursor_control.h freshplayerplugin-0.3.6/src/ppb_cursor_control.h --- freshplayerplugin-0.3.5/src/ppb_cursor_control.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_cursor_control.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_device_ref.c freshplayerplugin-0.3.6/src/ppb_device_ref.c --- freshplayerplugin-0.3.5/src/ppb_device_ref.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_device_ref.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_device_ref.h freshplayerplugin-0.3.6/src/ppb_device_ref.h --- freshplayerplugin-0.3.5/src/ppb_device_ref.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_device_ref.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_file_chooser.c freshplayerplugin-0.3.6/src/ppb_file_chooser.c --- freshplayerplugin-0.3.5/src/ppb_file_chooser.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_file_chooser.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * @@ -33,7 +33,6 @@ #include "ppb_file_ref.h" #include "reverse_constant.h" #include -#include #include "pp_interface.h" @@ -106,7 +105,7 @@ if (response_id == GTK_RESPONSE_OK) { PP_Resource *file_refs, *file_ref; - GSList *fname_lst = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)); + GSList *fname_lst = gw_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)); guint cnt = g_slist_length(fname_lst); callback_result = PP_OK; @@ -125,7 +124,7 @@ } if (!p->dialog_closed) - gtk_widget_destroy(GTK_WIDGET(dialog)); + gw_gtk_widget_destroy(GTK_WIDGET(dialog)); ppb_message_loop_post_work_with_result(p->message_loop, p->ccb, 0, callback_result, 0, __func__); @@ -158,30 +157,27 @@ dialog_title = "Open file"; } -#if GTK_MAJOR_VERSION == 3 - void *open_button_title = "_Open"; - void *close_button_title = "_Close"; -#elif GTK_MAJOR_VERSION == 2 - void *open_button_title = GTK_STOCK_OPEN; - void *close_button_title = GTK_STOCK_CANCEL; -#else -#error Unknown GTK version -#endif - - fcd = gtk_file_chooser_dialog_new(dialog_title, NULL, - p->save_as ? GTK_FILE_CHOOSER_ACTION_SAVE - : GTK_FILE_CHOOSER_ACTION_OPEN, - close_button_title, GTK_RESPONSE_CANCEL, - open_button_title, GTK_RESPONSE_OK, NULL); + const int gtk_version = gw_major_version(); + + void *open_button_title = gtk_version == 2 ? "gtk-open" + : "_Open"; + void *close_button_title = gtk_version == 2 ? "gtk-close" + : "_Close"; + + fcd = gw_gtk_file_chooser_dialog_new(dialog_title, NULL, + p->save_as ? GTK_FILE_CHOOSER_ACTION_SAVE + : GTK_FILE_CHOOSER_ACTION_OPEN, + close_button_title, GTK_RESPONSE_CANCEL, + open_button_title, GTK_RESPONSE_OK, NULL); if (p->mode == PP_FILECHOOSERMODE_OPENMULTIPLE) - gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(fcd), 1); + gw_gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(fcd), 1); - gtk_widget_realize(fcd); + gw_gtk_widget_realize(fcd); Window parent_wnd; if (npn.getvalue(p->pp_i->npp, NPNVnetscapeWindow, &parent_wnd) == NPERR_NO_ERROR) { - GdkWindow *fcd_wnd = gtk_widget_get_window(fcd); + GdkWindow *fcd_wnd = gw_gtk_widget_get_window(fcd); XSetTransientForHint(GDK_WINDOW_XDISPLAY(fcd_wnd), GDK_WINDOW_XID(fcd_wnd), @@ -193,7 +189,7 @@ g_signal_connect(G_OBJECT(fcd), "response", G_CALLBACK(fcd_response_handler), p); g_signal_connect(G_OBJECT(fcd), "close", G_CALLBACK(fcd_close_handler), p); - gtk_widget_show(fcd); + gw_gtk_widget_show(fcd); } int32_t diff -Nru freshplayerplugin-0.3.5/src/ppb_file_chooser.h freshplayerplugin-0.3.6/src/ppb_file_chooser.h --- freshplayerplugin-0.3.5/src/ppb_file_chooser.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_file_chooser.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_file_io.c freshplayerplugin-0.3.6/src/ppb_file_io.c --- freshplayerplugin-0.3.5/src/ppb_file_io.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_file_io.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_file_io.h freshplayerplugin-0.3.6/src/ppb_file_io.h --- freshplayerplugin-0.3.5/src/ppb_file_io.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_file_io.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_file_ref.c freshplayerplugin-0.3.6/src/ppb_file_ref.c --- freshplayerplugin-0.3.5/src/ppb_file_ref.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_file_ref.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_file_ref.h freshplayerplugin-0.3.6/src/ppb_file_ref.h --- freshplayerplugin-0.3.5/src/ppb_file_ref.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_file_ref.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_flash.c freshplayerplugin-0.3.6/src/ppb_flash.c --- freshplayerplugin-0.3.5/src/ppb_flash.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_flash_clipboard.c freshplayerplugin-0.3.6/src/ppb_flash_clipboard.c --- freshplayerplugin-0.3.5/src/ppb_flash_clipboard.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash_clipboard.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * @@ -117,9 +117,9 @@ { switch (clipboard_type) { case PP_FLASH_CLIPBOARD_TYPE_STANDARD: - return gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); + return gw_gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); case PP_FLASH_CLIPBOARD_TYPE_SELECTION: - return gtk_clipboard_get(GDK_SELECTION_PRIMARY); + return gw_gtk_clipboard_get(GDK_SELECTION_PRIMARY); default: return NULL; } @@ -131,11 +131,11 @@ { switch (format) { case PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT: - return gdk_atom_intern_static_string("UTF8_STRING"); + return gw_gdk_atom_intern_static_string("UTF8_STRING"); case PP_FLASH_CLIPBOARD_FORMAT_HTML: - return gdk_atom_intern("text/html", FALSE); + return gw_gdk_atom_intern("text/html", FALSE); case PP_FLASH_CLIPBOARD_FORMAT_RTF: - return gdk_atom_intern("text/rtf", FALSE); + return gw_gdk_atom_intern("text/rtf", FALSE); default: break; } @@ -144,7 +144,7 @@ gchar *custom_format_name = g_hash_table_lookup(format_name_ht, GINT_TO_POINTER(format)); pthread_mutex_unlock(&lock); if (custom_format_name) - return gdk_atom_intern(custom_format_name, FALSE); + return gw_gdk_atom_intern(custom_format_name, FALSE); return GDK_NONE; } @@ -172,7 +172,7 @@ if (target == GDK_NONE) goto quit; - p->result = gtk_clipboard_wait_is_target_available(clipboard, target); + p->result = gw_gtk_clipboard_wait_is_target_available(clipboard, target); quit: ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); @@ -232,10 +232,10 @@ if (target == GDK_NONE) goto quit; - GtkSelectionData *sd = gtk_clipboard_wait_for_contents(clipboard, target); + GtkSelectionData *sd = gw_gtk_clipboard_wait_for_contents(clipboard, target); if (sd) { - const guchar *sd_data = gtk_selection_data_get_data(sd); - const gint sd_length = gtk_selection_data_get_length(sd); + const guchar *sd_data = gw_gtk_selection_data_get_data(sd); + const gint sd_length = gw_gtk_selection_data_get_length(sd); switch (p->format) { case PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT: case PP_FLASH_CLIPBOARD_FORMAT_HTML: @@ -248,7 +248,7 @@ break; } - gtk_selection_data_free(sd); + gw_gtk_selection_data_free(sd); } quit: @@ -321,7 +321,7 @@ len = 0; } - gtk_selection_data_set(selection_data, item->type, 8, (const guchar *)data, len); + gw_gtk_selection_data_set(selection_data, item->type, 8, (const guchar *)data, len); if (item->var.type == PP_VARTYPE_ARRAY_BUFFER) ppb_var_array_buffer_unmap(item->var); @@ -355,7 +355,7 @@ if (p->data_item_count == 0) { // one can pass zero items to clear clipboard - gtk_clipboard_clear(clipboard); + gw_gtk_clipboard_clear(clipboard); goto quit; } @@ -369,23 +369,23 @@ trace_error("%s, plaintext format, var is not a string\n", __func__); break; } - item.type = gdk_atom_intern("text/html", FALSE); + item.type = gw_gdk_atom_intern("text/html", FALSE); ppb_var_add_ref(item.var); g_array_append_val(items, item); - item.type = gdk_atom_intern("TEXT", FALSE); + item.type = gw_gdk_atom_intern("TEXT", FALSE); ppb_var_add_ref(item.var); g_array_append_val(items, item); - item.type = gdk_atom_intern("STRING", FALSE); + item.type = gw_gdk_atom_intern("STRING", FALSE); ppb_var_add_ref(item.var); g_array_append_val(items, item); - item.type = gdk_atom_intern("UTF8_STRING", FALSE); + item.type = gw_gdk_atom_intern("UTF8_STRING", FALSE); ppb_var_add_ref(item.var); g_array_append_val(items, item); - item.type = gdk_atom_intern("COMPOUND_TEXT", FALSE); + item.type = gw_gdk_atom_intern("COMPOUND_TEXT", FALSE); ppb_var_add_ref(item.var); g_array_append_val(items, item); break; @@ -394,7 +394,7 @@ trace_error("%s, html format, var is not a string\n", __func__); break; } - item.type = gdk_atom_intern("text/html", FALSE); + item.type = gw_gdk_atom_intern("text/html", FALSE); ppb_var_add_ref(item.var); g_array_append_val(items, item); break; @@ -403,7 +403,7 @@ trace_error("%s, rtf, var is not an array buffer\n", __func__); break; } - item.type = gdk_atom_intern("text/rtf", FALSE); + item.type = gw_gdk_atom_intern("text/rtf", FALSE); ppb_var_add_ref(item.var); g_array_append_val(items, item); break; @@ -423,14 +423,15 @@ GtkTargetEntry *targets = g_new0(GtkTargetEntry, items->len); for (uint32_t k = 0; k < items->len; k ++) { - targets[k].target = gdk_atom_name(g_array_index(items, struct selection_entry_s, k).type); + targets[k].target = + gw_gdk_atom_name(g_array_index(items, struct selection_entry_s, k).type); targets[k].info = k; } - if (gtk_clipboard_set_with_data(clipboard, targets, items->len, clipboard_get_func, - clipboard_clear_func, items)) + if (gw_gtk_clipboard_set_with_data(clipboard, targets, items->len, clipboard_get_func, + clipboard_clear_func, items)) { - gtk_clipboard_set_can_store(clipboard, targets, items->len); + gw_gtk_clipboard_set_can_store(clipboard, targets, items->len); } else { p->result = PP_ERROR_FAILED; } diff -Nru freshplayerplugin-0.3.5/src/ppb_flash_clipboard.h freshplayerplugin-0.3.6/src/ppb_flash_clipboard.h --- freshplayerplugin-0.3.5/src/ppb_flash_clipboard.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash_clipboard.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_flash_drm.c freshplayerplugin-0.3.6/src/ppb_flash_drm.c --- freshplayerplugin-0.3.5/src/ppb_flash_drm.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash_drm.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_flash_drm.h freshplayerplugin-0.3.6/src/ppb_flash_drm.h --- freshplayerplugin-0.3.5/src/ppb_flash_drm.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash_drm.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_flash_file.c freshplayerplugin-0.3.6/src/ppb_flash_file.c --- freshplayerplugin-0.3.5/src/ppb_flash_file.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash_file.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_flash_file.h freshplayerplugin-0.3.6/src/ppb_flash_file.h --- freshplayerplugin-0.3.5/src/ppb_flash_file.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash_file.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_flash_font_file.c freshplayerplugin-0.3.6/src/ppb_flash_font_file.c --- freshplayerplugin-0.3.5/src/ppb_flash_font_file.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash_font_file.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_flash_font_file.h freshplayerplugin-0.3.6/src/ppb_flash_font_file.h --- freshplayerplugin-0.3.5/src/ppb_flash_font_file.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash_font_file.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_flash_fullscreen.c freshplayerplugin-0.3.6/src/ppb_flash_fullscreen.c --- freshplayerplugin-0.3.5/src/ppb_flash_fullscreen.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash_fullscreen.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * @@ -121,11 +121,11 @@ v->rect.point.x = 0; v->rect.point.y = 0; if (is_fullscreen) { - v->rect.size.width = pp_i->fs_width / config.device_scale; - v->rect.size.height = pp_i->fs_height / config.device_scale; + v->rect.size.width = pp_i->fs_width / config.device_scale + 0.5; + v->rect.size.height = pp_i->fs_height / config.device_scale + 0.5; } else { - v->rect.size.width = pp_i->width / config.device_scale; - v->rect.size.height = pp_i->height / config.device_scale; + v->rect.size.width = pp_i->width / config.device_scale + 0.5; + v->rect.size.height = pp_i->height / config.device_scale + 0.5; } pp_resource_release(view); @@ -653,6 +653,8 @@ size->width = pp_i->fs_width > 0 ? pp_i->fs_width : display.min_width; size->height = pp_i->fs_height > 0 ? pp_i->fs_height : display.min_height; + size->width /= config.device_scale; + size->height /= config.device_scale; return PP_TRUE; } diff -Nru freshplayerplugin-0.3.5/src/ppb_flash_fullscreen.h freshplayerplugin-0.3.6/src/ppb_flash_fullscreen.h --- freshplayerplugin-0.3.5/src/ppb_flash_fullscreen.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash_fullscreen.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_flash.h freshplayerplugin-0.3.6/src/ppb_flash.h --- freshplayerplugin-0.3.5/src/ppb_flash.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_flash_menu.c freshplayerplugin-0.3.6/src/ppb_flash_menu.c --- freshplayerplugin-0.3.5/src/ppb_flash_menu.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash_menu.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * @@ -31,10 +31,10 @@ #include "tables.h" #include "pp_resource.h" #include -#include #include "pp_interface.h" #include "autogenerated_version_info.h" #include "config.h" +#include "gtk_wrapper.h" static int32_t *popup_menu_result = NULL; @@ -85,7 +85,7 @@ GtkWidget * convert_menu(const struct PP_Flash_Menu *pp_menu) { - GtkWidget *menu = gtk_menu_new(); + GtkWidget *menu = gw_gtk_menu_new(); for (uintptr_t k = 0; k < pp_menu->count; k ++) { const struct PP_Flash_MenuItem pp_mi = pp_menu->items[k]; @@ -93,29 +93,29 @@ switch (pp_mi.type) { case PP_FLASH_MENUITEM_TYPE_NORMAL: - mi = gtk_menu_item_new_with_label(pp_mi.name); + mi = gw_gtk_menu_item_new_with_label(pp_mi.name); break; case PP_FLASH_MENUITEM_TYPE_CHECKBOX: - mi = gtk_check_menu_item_new_with_label(pp_mi.name); - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi), pp_mi.checked != PP_FALSE); + mi = gw_gtk_check_menu_item_new_with_label(pp_mi.name); + gw_gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi), pp_mi.checked != PP_FALSE); break; case PP_FLASH_MENUITEM_TYPE_SEPARATOR: - mi = gtk_separator_menu_item_new(); + mi = gw_gtk_separator_menu_item_new(); break; case PP_FLASH_MENUITEM_TYPE_SUBMENU: - mi = gtk_menu_item_new_with_label(pp_mi.name); + mi = gw_gtk_menu_item_new_with_label(pp_mi.name); break; } if (!mi) continue; - gtk_widget_set_sensitive(mi, pp_mi.enabled != PP_FALSE); - gtk_widget_show(mi); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); + gw_gtk_widget_set_sensitive(mi, pp_mi.enabled != PP_FALSE); + gw_gtk_widget_show(mi); + gw_gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); if (pp_mi.type == PP_FLASH_MENUITEM_TYPE_SUBMENU) { - gtk_menu_item_set_submenu(GTK_MENU_ITEM(mi), convert_menu(pp_mi.submenu)); + gw_gtk_menu_item_set_submenu(GTK_MENU_ITEM(mi), convert_menu(pp_mi.submenu)); } else { // each menu item have specific id associated g_signal_connect(G_OBJECT(mi), "activate", G_CALLBACK(menu_item_activated), @@ -135,16 +135,16 @@ { GtkWidget *mi; - mi = gtk_separator_menu_item_new(); - gtk_widget_show(mi); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); + mi = gw_gtk_separator_menu_item_new(); + gw_gtk_widget_show(mi); + gw_gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); gchar *s = g_strdup_printf("freshwrapper, %s", g_version_info); - mi = gtk_menu_item_new_with_label(s); + mi = gw_gtk_menu_item_new_with_label(s); g_free(s); - gtk_widget_set_sensitive(mi, FALSE); - gtk_widget_show(mi); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); + gw_gtk_widget_set_sensitive(mi, FALSE); + gw_gtk_widget_show(mi); + gw_gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); } struct flash_menu_create_param_s { @@ -246,7 +246,7 @@ menu_popup_ptac(void *p) { GtkWidget *menu = p; - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, gtk_get_current_event_time()); + gw_gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, gw_gtk_get_current_event_time()); } int32_t diff -Nru freshplayerplugin-0.3.5/src/ppb_flash_menu.h freshplayerplugin-0.3.6/src/ppb_flash_menu.h --- freshplayerplugin-0.3.5/src/ppb_flash_menu.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash_menu.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_flash_message_loop.c freshplayerplugin-0.3.6/src/ppb_flash_message_loop.c --- freshplayerplugin-0.3.5/src/ppb_flash_message_loop.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash_message_loop.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_flash_message_loop.h freshplayerplugin-0.3.6/src/ppb_flash_message_loop.h --- freshplayerplugin-0.3.5/src/ppb_flash_message_loop.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_flash_message_loop.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_font.c freshplayerplugin-0.3.6/src/ppb_font.c --- freshplayerplugin-0.3.5/src/ppb_font.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_font.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_font.h freshplayerplugin-0.3.6/src/ppb_font.h --- freshplayerplugin-0.3.5/src/ppb_font.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_font.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_graphics2d.c freshplayerplugin-0.3.6/src/ppb_graphics2d.c --- freshplayerplugin-0.3.5/src/ppb_graphics2d.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_graphics2d.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * @@ -63,6 +63,7 @@ g2d->is_always_opaque = is_always_opaque; g2d->scale = config.device_scale; + g2d->external_scale = 1.0; g2d->width = size->width; g2d->height = size->height; g2d->stride = 4 * size->width; @@ -347,7 +348,9 @@ return PP_ERROR_BADRESOURCE; } + g2d->external_scale = scale; g2d->scale = scale * config.device_scale; + g2d->scaled_width = g2d->width * g2d->scale + 0.5; g2d->scaled_height = g2d->height * g2d->scale + 0.5; g2d->scaled_stride = 4 * g2d->scaled_width; @@ -369,7 +372,7 @@ return PP_ERROR_BADRESOURCE; } - float scale = g2d->scale / config.device_scale; + float scale = g2d->external_scale; pp_resource_release(resource); return scale; } diff -Nru freshplayerplugin-0.3.5/src/ppb_graphics2d.h freshplayerplugin-0.3.6/src/ppb_graphics2d.h --- freshplayerplugin-0.3.5/src/ppb_graphics2d.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_graphics2d.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_graphics3d.c freshplayerplugin-0.3.6/src/ppb_graphics3d.c --- freshplayerplugin-0.3.5/src/ppb_graphics3d.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_graphics3d.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * @@ -101,7 +101,8 @@ } attrib_len ++; - int *cfg_attrs = calloc(attrib_len + 3 * 2, sizeof(int)); + const int max_attrib_count = attrib_len + 3 * 2; + int *cfg_attrs = calloc(max_attrib_count, sizeof(int)); int k2 = 0; cfg_attrs[k2++] = GLX_X_RENDERABLE; cfg_attrs[k2++] = True; @@ -187,6 +188,8 @@ } } + assert(k2 <= max_attrib_count); + pthread_mutex_lock(&display.lock); int screen = DefaultScreen(display.x); int nconfigs = 0; @@ -256,17 +259,23 @@ goto err; } - g3d->pixmap = XCreatePixmap(display.x, DefaultRootWindow(display.x), g3d->width, g3d->height, - g3d->depth); - g3d->glx_pixmap = glXCreatePixmap(display.x, g3d->fb_config, g3d->pixmap, NULL); + // Creating two X pixmaps. First one is for drawing into, with a GLX Pixmap associated. + // Second one is for double buffering. + g3d->pixmap[0] = XCreatePixmap(display.x, DefaultRootWindow(display.x), g3d->width, g3d->height, + g3d->depth); + g3d->pixmap[1] = XCreatePixmap(display.x, DefaultRootWindow(display.x), g3d->width, g3d->height, + g3d->depth); + g3d->glx_pixmap = glXCreatePixmap(display.x, g3d->fb_config, g3d->pixmap[0], NULL); if (g3d->glx_pixmap == None) { trace_error("%s, failed to create GLX pixmap\n", __func__); goto err; } XFlush(display.x); - if (display.have_xrender) - g3d->xr_pict = XRenderCreatePicture(display.x, g3d->pixmap, g3d->xr_pictfmt, 0, 0); + if (display.have_xrender) { + g3d->xr_pict[0] = XRenderCreatePicture(display.x, g3d->pixmap[0], g3d->xr_pictfmt, 0, 0); + g3d->xr_pict[1] = XRenderCreatePicture(display.x, g3d->pixmap[1], g3d->xr_pictfmt, 0, 0); + } int ret = glXMakeCurrent(display.x, g3d->glx_pixmap, g3d->glc); if (!ret) { @@ -307,9 +316,14 @@ glXMakeCurrent(display.x, None, NULL); glXDestroyPixmap(display.x, g3d->glx_pixmap); - if (display.have_xrender) - XRenderFreePicture(display.x, g3d->xr_pict); - XFreePixmap(display.x, g3d->pixmap); + + if (display.have_xrender) { + XRenderFreePicture(display.x, g3d->xr_pict[0]); + XRenderFreePicture(display.x, g3d->xr_pict[1]); + } + + XFreePixmap(display.x, g3d->pixmap[0]); + XFreePixmap(display.x, g3d->pixmap[1]); glXDestroyContext(display.x, g3d->glc); pthread_mutex_unlock(&display.lock); @@ -357,18 +371,22 @@ g3d->height = height; GLXPixmap old_glx_pixmap = g3d->glx_pixmap; - Pixmap old_pixmap = g3d->pixmap; - Picture old_pict = g3d->xr_pict; + Pixmap old_pixmap[2] = { g3d->pixmap[0], g3d->pixmap[1] }; + Picture old_pict[2] = { g3d->xr_pict[0], g3d->xr_pict[1] }; // release possibly bound to other thread g3d->glx_pixmap and bind it to the current one pthread_mutex_lock(&display.lock); glXMakeCurrent(display.x, g3d->glx_pixmap, g3d->glc); - g3d->pixmap = XCreatePixmap(display.x, DefaultRootWindow(display.x), g3d->width, g3d->height, - g3d->depth); - g3d->glx_pixmap = glXCreatePixmap(display.x, g3d->fb_config, g3d->pixmap, NULL); + g3d->pixmap[0] = XCreatePixmap(display.x, DefaultRootWindow(display.x), g3d->width, g3d->height, + g3d->depth); + g3d->pixmap[1] = XCreatePixmap(display.x, DefaultRootWindow(display.x), g3d->width, g3d->height, + g3d->depth); + g3d->glx_pixmap = glXCreatePixmap(display.x, g3d->fb_config, g3d->pixmap[0], NULL); XFlush(display.x); - if (display.have_xrender) - g3d->xr_pict = XRenderCreatePicture(display.x, g3d->pixmap, g3d->xr_pictfmt, 0, 0); + if (display.have_xrender) { + g3d->xr_pict[0] = XRenderCreatePicture(display.x, g3d->pixmap[0], g3d->xr_pictfmt, 0, 0); + g3d->xr_pict[1] = XRenderCreatePicture(display.x, g3d->pixmap[1], g3d->xr_pictfmt, 0, 0); + } // make new g3d->glx_pixmap current to the current thread to allow releasing old_glx_pixmap glXMakeCurrent(display.x, g3d->glx_pixmap, g3d->glc); @@ -379,9 +397,14 @@ // destroy previous glx and x pixmaps glXDestroyPixmap(display.x, old_glx_pixmap); - if (display.have_xrender) - XRenderFreePicture(display.x, old_pict); - XFreePixmap(display.x, old_pixmap); + + if (display.have_xrender) { + XRenderFreePicture(display.x, old_pict[0]); + XRenderFreePicture(display.x, old_pict[1]); + } + + XFreePixmap(display.x, old_pixmap[0]); + XFreePixmap(display.x, old_pixmap[1]); pthread_mutex_unlock(&display.lock); pp_resource_release(context); @@ -449,6 +472,26 @@ glFinish(); // ensure painting is done glXMakeCurrent(display.x, None, NULL); + // a round-trip to an X server is required here to be sure that drawing is completed + XSync(display.x, False); + + // copy from pixmap[0] to pixmap[1] + if (display.have_xrender) { + XRenderComposite(display.x, PictOpSrc, g3d->xr_pict[0], None, g3d->xr_pict[1], + 0, 0, 0, 0, 0, 0, g3d->width, g3d->height); + + } else { + const int screen = DefaultScreen(display.x); + const GC gc = DefaultGC(display.x, screen); + XCopyArea(display.x, g3d->pixmap[0], g3d->pixmap[1], gc, 0, 0, g3d->width, g3d->height, + 0, 0); + } + + // a round-trip to an X server is required here to ensure that copying is completed, and further + // GL drawing in this thread into pixmap[0] will not affect pixmap[1] which will be used in + // another, browser thread + XSync(display.x, False); + pp_resource_release(context); pp_i->graphics_ccb = callback; diff -Nru freshplayerplugin-0.3.5/src/ppb_graphics3d.h freshplayerplugin-0.3.6/src/ppb_graphics3d.h --- freshplayerplugin-0.3.5/src/ppb_graphics3d.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_graphics3d.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_host_resolver.c freshplayerplugin-0.3.6/src/ppb_host_resolver.c --- freshplayerplugin-0.3.5/src/ppb_host_resolver.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_host_resolver.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_host_resolver.h freshplayerplugin-0.3.6/src/ppb_host_resolver.h --- freshplayerplugin-0.3.5/src/ppb_host_resolver.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_host_resolver.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_image_data.c freshplayerplugin-0.3.6/src/ppb_image_data.c --- freshplayerplugin-0.3.5/src/ppb_image_data.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_image_data.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_image_data.h freshplayerplugin-0.3.6/src/ppb_image_data.h --- freshplayerplugin-0.3.5/src/ppb_image_data.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_image_data.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_input_event.c freshplayerplugin-0.3.6/src/ppb_input_event.c --- freshplayerplugin-0.3.5/src/ppb_input_event.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_input_event.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_input_event.h freshplayerplugin-0.3.6/src/ppb_input_event.h --- freshplayerplugin-0.3.5/src/ppb_input_event.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_input_event.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_instance.c freshplayerplugin-0.3.6/src/ppb_instance.c --- freshplayerplugin-0.3.5/src/ppb_instance.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_instance.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_instance.h freshplayerplugin-0.3.6/src/ppb_instance.h --- freshplayerplugin-0.3.5/src/ppb_instance.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_instance.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_memory.c freshplayerplugin-0.3.6/src/ppb_memory.c --- freshplayerplugin-0.3.5/src/ppb_memory.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_memory.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_memory.h freshplayerplugin-0.3.6/src/ppb_memory.h --- freshplayerplugin-0.3.5/src/ppb_memory.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_memory.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_message_loop.c freshplayerplugin-0.3.6/src/ppb_message_loop.c --- freshplayerplugin-0.3.5/src/ppb_message_loop.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_message_loop.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_message_loop.h freshplayerplugin-0.3.6/src/ppb_message_loop.h --- freshplayerplugin-0.3.5/src/ppb_message_loop.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_message_loop.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_messaging.c freshplayerplugin-0.3.6/src/ppb_messaging.c --- freshplayerplugin-0.3.5/src/ppb_messaging.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_messaging.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_messaging.h freshplayerplugin-0.3.6/src/ppb_messaging.h --- freshplayerplugin-0.3.5/src/ppb_messaging.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_messaging.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_net_address.c freshplayerplugin-0.3.6/src/ppb_net_address.c --- freshplayerplugin-0.3.5/src/ppb_net_address.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_net_address.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_net_address.h freshplayerplugin-0.3.6/src/ppb_net_address.h --- freshplayerplugin-0.3.5/src/ppb_net_address.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_net_address.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_network_monitor.c freshplayerplugin-0.3.6/src/ppb_network_monitor.c --- freshplayerplugin-0.3.5/src/ppb_network_monitor.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_network_monitor.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_network_monitor.h freshplayerplugin-0.3.6/src/ppb_network_monitor.h --- freshplayerplugin-0.3.5/src/ppb_network_monitor.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_network_monitor.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_opengles2.c freshplayerplugin-0.3.6/src/ppb_opengles2.c --- freshplayerplugin-0.3.5/src/ppb_opengles2.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_opengles2.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_opengles2.h freshplayerplugin-0.3.6/src/ppb_opengles2.h --- freshplayerplugin-0.3.5/src/ppb_opengles2.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_opengles2.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_pdf.c freshplayerplugin-0.3.6/src/ppb_pdf.c --- freshplayerplugin-0.3.5/src/ppb_pdf.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_pdf.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_pdf.h freshplayerplugin-0.3.6/src/ppb_pdf.h --- freshplayerplugin-0.3.5/src/ppb_pdf.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_pdf.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_printing.c freshplayerplugin-0.3.6/src/ppb_printing.c --- freshplayerplugin-0.3.5/src/ppb_printing.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_printing.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_printing.h freshplayerplugin-0.3.6/src/ppb_printing.h --- freshplayerplugin-0.3.5/src/ppb_printing.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_printing.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_tcp_socket.c freshplayerplugin-0.3.6/src/ppb_tcp_socket.c --- freshplayerplugin-0.3.5/src/ppb_tcp_socket.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_tcp_socket.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_tcp_socket.h freshplayerplugin-0.3.6/src/ppb_tcp_socket.h --- freshplayerplugin-0.3.5/src/ppb_tcp_socket.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_tcp_socket.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_text_input.c freshplayerplugin-0.3.6/src/ppb_text_input.c --- freshplayerplugin-0.3.5/src/ppb_text_input.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_text_input.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * @@ -29,10 +29,10 @@ #include "tables.h" #include "pp_resource.h" #include "reverse_constant.h" -#include #include "ppb_core.h" #include #include "pp_interface.h" +#include "gtk_wrapper.h" struct set_text_input_type_param_s { @@ -52,7 +52,7 @@ } if (pp_i->im_context) - gtk_im_context_focus_out(pp_i->im_context); + gw_gtk_im_context_focus_out(pp_i->im_context); switch (p->type) { case PP_TEXTINPUT_TYPE_DEV_NONE: @@ -69,7 +69,7 @@ pp_i->textinput_type = p->type; if (pp_i->im_context) - gtk_im_context_focus_in(pp_i->im_context); + gw_gtk_im_context_focus_in(pp_i->im_context); g_slice_free1(sizeof(*p), p); } @@ -104,7 +104,7 @@ p->caret.y += pp_i->offset_y; if (pp_i->im_context) - gtk_im_context_set_cursor_location(pp_i->im_context, &p->caret); + gw_gtk_im_context_set_cursor_location(pp_i->im_context, &p->caret); g_slice_free1(sizeof(*p), p); } @@ -137,7 +137,7 @@ } if (pp_i->im_context) - gtk_im_context_reset(pp_i->im_context); + gw_gtk_im_context_reset(pp_i->im_context); } void @@ -166,7 +166,7 @@ if (pp_i->im_context) { const size_t len = p->text ? strlen(p->text) : 0; - gtk_im_context_set_surrounding(pp_i->im_context, p->text, len, p->caret); + gw_gtk_im_context_set_surrounding(pp_i->im_context, p->text, len, p->caret); } done: diff -Nru freshplayerplugin-0.3.5/src/ppb_text_input_controller.c freshplayerplugin-0.3.6/src/ppb_text_input_controller.c --- freshplayerplugin-0.3.5/src/ppb_text_input_controller.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_text_input_controller.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_text_input_controller.h freshplayerplugin-0.3.6/src/ppb_text_input_controller.h --- freshplayerplugin-0.3.5/src/ppb_text_input_controller.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_text_input_controller.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_text_input.h freshplayerplugin-0.3.6/src/ppb_text_input.h --- freshplayerplugin-0.3.5/src/ppb_text_input.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_text_input.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_udp_socket.c freshplayerplugin-0.3.6/src/ppb_udp_socket.c --- freshplayerplugin-0.3.5/src/ppb_udp_socket.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_udp_socket.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_udp_socket.h freshplayerplugin-0.3.6/src/ppb_udp_socket.h --- freshplayerplugin-0.3.5/src/ppb_udp_socket.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_udp_socket.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_uma.c freshplayerplugin-0.3.6/src/ppb_uma.c --- freshplayerplugin-0.3.5/src/ppb_uma.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_uma.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_uma.h freshplayerplugin-0.3.6/src/ppb_uma.h --- freshplayerplugin-0.3.5/src/ppb_uma.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_uma.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_url_loader.c freshplayerplugin-0.3.6/src/ppb_url_loader.c --- freshplayerplugin-0.3.5/src/ppb_url_loader.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_url_loader.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_url_loader.h freshplayerplugin-0.3.6/src/ppb_url_loader.h --- freshplayerplugin-0.3.5/src/ppb_url_loader.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_url_loader.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_url_request_info.c freshplayerplugin-0.3.6/src/ppb_url_request_info.c --- freshplayerplugin-0.3.5/src/ppb_url_request_info.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_url_request_info.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_url_request_info.h freshplayerplugin-0.3.6/src/ppb_url_request_info.h --- freshplayerplugin-0.3.5/src/ppb_url_request_info.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_url_request_info.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_url_response_info.c freshplayerplugin-0.3.6/src/ppb_url_response_info.c --- freshplayerplugin-0.3.5/src/ppb_url_response_info.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_url_response_info.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_url_response_info.h freshplayerplugin-0.3.6/src/ppb_url_response_info.h --- freshplayerplugin-0.3.5/src/ppb_url_response_info.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_url_response_info.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_url_util.c freshplayerplugin-0.3.6/src/ppb_url_util.c --- freshplayerplugin-0.3.5/src/ppb_url_util.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_url_util.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_url_util.h freshplayerplugin-0.3.6/src/ppb_url_util.h --- freshplayerplugin-0.3.5/src/ppb_url_util.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_url_util.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_var.c freshplayerplugin-0.3.6/src/ppb_var.c --- freshplayerplugin-0.3.5/src/ppb_var.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_var.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_var.h freshplayerplugin-0.3.6/src/ppb_var.h --- freshplayerplugin-0.3.5/src/ppb_var.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_var.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_video_capture.c freshplayerplugin-0.3.6/src/ppb_video_capture.c --- freshplayerplugin-0.3.5/src/ppb_video_capture.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_video_capture.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_video_capture.h freshplayerplugin-0.3.6/src/ppb_video_capture.h --- freshplayerplugin-0.3.5/src/ppb_video_capture.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_video_capture.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_video_decoder.c freshplayerplugin-0.3.6/src/ppb_video_decoder.c --- freshplayerplugin-0.3.5/src/ppb_video_decoder.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_video_decoder.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_video_decoder.h freshplayerplugin-0.3.6/src/ppb_video_decoder.h --- freshplayerplugin-0.3.5/src/ppb_video_decoder.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_video_decoder.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_view.c freshplayerplugin-0.3.6/src/ppb_view.c --- freshplayerplugin-0.3.5/src/ppb_view.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_view.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_view.h freshplayerplugin-0.3.6/src/ppb_view.h --- freshplayerplugin-0.3.5/src/ppb_view.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_view.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/ppb_x509_certificate.c freshplayerplugin-0.3.6/src/ppb_x509_certificate.c --- freshplayerplugin-0.3.5/src/ppb_x509_certificate.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_x509_certificate.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * @@ -50,10 +50,13 @@ ppb_x509_certificate_destroy(void *ptr) { struct pp_x509_certificate_s *xc = ptr; + if (xc->cert) { X509_free(xc->cert); xc->cert = NULL; } + + free(xc->raw_data); } PP_Bool @@ -65,14 +68,14 @@ PP_Bool ppb_x509_certificate_initialize(PP_Resource resource, const char *bytes, uint32_t length) { - const unsigned char **in = (const unsigned char **)&bytes; + const unsigned char *in = (const unsigned char *)bytes; struct pp_x509_certificate_s *xc = pp_resource_acquire(resource, PP_RESOURCE_X509_CERTIFICATE); if (!xc) { return PP_FALSE; } PP_Bool retval = PP_TRUE; - if (d2i_X509(&xc->cert, in, length) == NULL) { + if (d2i_X509(&xc->cert, &in, length) == NULL) { retval = PP_FALSE; goto done; } diff -Nru freshplayerplugin-0.3.5/src/ppb_x509_certificate.h freshplayerplugin-0.3.6/src/ppb_x509_certificate.h --- freshplayerplugin-0.3.5/src/ppb_x509_certificate.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/ppb_x509_certificate.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/pp_interface.c freshplayerplugin-0.3.6/src/pp_interface.c --- freshplayerplugin-0.3.5/src/pp_interface.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/pp_interface.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/pp_interface.h freshplayerplugin-0.3.6/src/pp_interface.h --- freshplayerplugin-0.3.5/src/pp_interface.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/pp_interface.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/pp_resource.c freshplayerplugin-0.3.6/src/pp_resource.c --- freshplayerplugin-0.3.5/src/pp_resource.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/pp_resource.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/pp_resource.h freshplayerplugin-0.3.6/src/pp_resource.h --- freshplayerplugin-0.3.5/src/pp_resource.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/pp_resource.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * @@ -59,10 +59,10 @@ #include #include #include -#include #include "audio_thread.h" #include #include "font.h" +#include "gtk_wrapper.h" #if HAVE_HWDEC #include @@ -321,9 +321,9 @@ GLXContext glc; GLXFBConfig fb_config; int32_t depth; ///< depth of the pixmap, 32 for transparent, 24 otherwise - Pixmap pixmap; GLXPixmap glx_pixmap; - Picture xr_pict; + Pixmap pixmap[2]; ///< first for immediate drawing, second - to store copy + Picture xr_pict[2]; ///< XRender pictures for X pixmaps XRenderPictFormat *xr_pictfmt; int32_t width; int32_t height; @@ -347,6 +347,7 @@ int32_t height; int32_t stride; double scale; + double external_scale; int32_t scaled_width; int32_t scaled_height; int32_t scaled_stride; diff -Nru freshplayerplugin-0.3.5/src/reverse_constant.c freshplayerplugin-0.3.6/src/reverse_constant.c --- freshplayerplugin-0.3.5/src/reverse_constant.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/reverse_constant.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/reverse_constant.h freshplayerplugin-0.3.6/src/reverse_constant.h --- freshplayerplugin-0.3.5/src/reverse_constant.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/reverse_constant.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/screensaver_control.c freshplayerplugin-0.3.6/src/screensaver_control.c --- freshplayerplugin-0.3.5/src/screensaver_control.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/screensaver_control.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/screensaver_control.h freshplayerplugin-0.3.6/src/screensaver_control.h --- freshplayerplugin-0.3.5/src/screensaver_control.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/screensaver_control.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/shader_translator.cc freshplayerplugin-0.3.6/src/shader_translator.cc --- freshplayerplugin-0.3.5/src/shader_translator.cc 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/shader_translator.cc 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/shader_translator.h freshplayerplugin-0.3.6/src/shader_translator.h --- freshplayerplugin-0.3.5/src/shader_translator.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/shader_translator.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/static_assert.h freshplayerplugin-0.3.6/src/static_assert.h --- freshplayerplugin-0.3.5/src/static_assert.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/static_assert.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/tables.c freshplayerplugin-0.3.6/src/tables.c --- freshplayerplugin-0.3.5/src/tables.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/tables.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/tables.h freshplayerplugin-0.3.6/src/tables.h --- freshplayerplugin-0.3.5/src/tables.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/tables.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/trace.c freshplayerplugin-0.3.6/src/trace.c --- freshplayerplugin-0.3.5/src/trace.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/trace.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/trace_core.c freshplayerplugin-0.3.6/src/trace_core.c --- freshplayerplugin-0.3.5/src/trace_core.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/trace_core.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/trace_core.h freshplayerplugin-0.3.6/src/trace_core.h --- freshplayerplugin-0.3.5/src/trace_core.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/trace_core.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/trace.h freshplayerplugin-0.3.6/src/trace.h --- freshplayerplugin-0.3.5/src/trace.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/trace.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/uri_parser/uri_parser.c freshplayerplugin-0.3.6/src/uri_parser/uri_parser.c --- freshplayerplugin-0.3.5/src/uri_parser/uri_parser.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/uri_parser/uri_parser.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/uri_parser/uri_parser_fsm.rl freshplayerplugin-0.3.6/src/uri_parser/uri_parser_fsm.rl --- freshplayerplugin-0.3.5/src/uri_parser/uri_parser_fsm.rl 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/uri_parser/uri_parser_fsm.rl 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/uri_parser/uri_parser.h freshplayerplugin-0.3.6/src/uri_parser/uri_parser.h --- freshplayerplugin-0.3.5/src/uri_parser/uri_parser.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/uri_parser/uri_parser.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/utils.h freshplayerplugin-0.3.6/src/utils.h --- freshplayerplugin-0.3.5/src/utils.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/utils.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/x11_event_thread.c freshplayerplugin-0.3.6/src/x11_event_thread.c --- freshplayerplugin-0.3.5/src/x11_event_thread.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/x11_event_thread.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/src/x11_event_thread.h freshplayerplugin-0.3.6/src/x11_event_thread.h --- freshplayerplugin-0.3.5/src/x11_event_thread.h 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/src/x11_event_thread.h 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2015 Rinat Ibragimov + * Copyright © 2013-2016 Rinat Ibragimov * * This file is part of FreshPlayerPlugin. * diff -Nru freshplayerplugin-0.3.5/tests/CMakeLists.txt freshplayerplugin-0.3.6/tests/CMakeLists.txt --- freshplayerplugin-0.3.5/tests/CMakeLists.txt 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/tests/CMakeLists.txt 2016-10-04 22:44:50.000000000 +0000 @@ -4,6 +4,7 @@ add_definitions(-DTEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data") set(test_list + test_encoding_alias test_header_parser test_ppb_char_set test_ppb_flash_file @@ -30,6 +31,7 @@ $ $ ../src/config_pepperflash.c + test.c common.c) target_link_libraries(${item} "-Wl,-z,muldefs" diff -Nru freshplayerplugin-0.3.5/tests/test.c freshplayerplugin-0.3.6/tests/test.c --- freshplayerplugin-0.3.5/tests/test.c 1970-01-01 00:00:00.000000000 +0000 +++ freshplayerplugin-0.3.6/tests/test.c 2016-10-04 22:44:50.000000000 +0000 @@ -0,0 +1,74 @@ +#include +#include "test.h" + + +struct testcase { + char *name; + void (*f)(void); + struct testcase *next; +}; + +static +struct testcase head = {}; + +static +struct testcase **next = &head.next; + +static +void (*test_constructor)(void) = NULL; + +void +test_add_func(const char *name, void (*f)(void)) +{ + struct testcase *t = malloc(sizeof(*t)); + + if (t == NULL) { + printf("memory allocation failure\n"); + abort(); + } + + t->name = strdup(name); + t->f = f; + t->next = NULL; + + *next = t; + next = &t->next; +} + +void +test_run_all(void) +{ + // call all tests, one by one + for (struct testcase *t = head.next; t != NULL; t = t->next) { + printf("running %s\n", t->name); + t->f(); + } + + // cleanup memory + while (head.next) { + struct testcase *t = head.next; + + head.next = t->next; + free(t->name); + free(t); + } +} + +void +test_set_constructor(void (*f)(void)) +{ + test_constructor = f; +} + +// provides a main() function for test that doesn't have any. +__attribute__((weak)) +int +main(void) +{ + if (test_constructor) + test_constructor(); + + test_run_all(); + printf("pass\n"); + return 0; +} diff -Nru freshplayerplugin-0.3.5/tests/test_config_parser.c freshplayerplugin-0.3.6/tests/test_config_parser.c --- freshplayerplugin-0.3.5/tests/test_config_parser.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/tests/test_config_parser.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,15 +1,15 @@ -#undef NDEBUG -#include +#include "test.h" #include #include #include #include #include -static -void -test_1(void) + +TEST(config_parser, test_1) { + ASSERT_TRUE((void*)1); + const char *s = "param1= value\n" // simple key-value "param2 = 123\r\n" // number value; different line ending @@ -30,13 +30,14 @@ }; cfg_t *cfg = cfg_init(opts, 0); - assert(cfg); + ASSERT_NE(cfg, NULL); cfg_parse_string(cfg, s); - assert(strcmp(value1, "value") == 0); - assert(value2 == 123); - assert(strcmp(value3, "qwe") == 0); - assert(strcmp(value4, "defaultvalue") == 0); + + ASSERT_TRUE(strcmp(value1, "value") == 0); + ASSERT_TRUE(value2 == 123); + ASSERT_TRUE(strcmp(value3, "qwe") == 0); + ASSERT_TRUE(strcmp(value4, "defaultvalue") == 0); cfg_free(cfg); @@ -45,9 +46,7 @@ free(value4); } -static -void -test_2(void) +TEST(config_parser, test_2) { const char *s = "param1_float = qwe\n" // invalid float value @@ -66,21 +65,19 @@ }; cfg_t *cfg = cfg_init(opts, 0); - assert(cfg); + ASSERT_NE(cfg, NULL); cfg_parse_string(cfg, s); - assert(fabs(value1 - 0) < 1e-5); - assert(fabs(value2 - 3.45) < 1e-5); - assert(strcmp(value3, "value3") == 0); + ASSERT_TRUE(fabs(value1 - 0) < 1e-5); + ASSERT_TRUE(fabs(value2 - 3.45) < 1e-5); + ASSERT_TRUE(strcmp(value3, "value3") == 0); cfg_free(cfg); free(value3); } -static -void -test_3(void) +TEST(config_parser, test_3) { const char *s = "# commented line\n" // comment @@ -97,22 +94,11 @@ }; cfg_t *cfg = cfg_init(opts, 0); - assert(cfg); + ASSERT_NE(cfg, NULL); cfg_parse_string(cfg, s); - assert(strcmp(value1, "var2") == 0); + ASSERT_TRUE(strcmp(value1, "var2") == 0); cfg_free(cfg); free(value1); } - -int -main(void) -{ - test_1(); - test_2(); - test_3(); - - printf("pass\n"); - return 0; -} diff -Nru freshplayerplugin-0.3.5/tests/test_encoding_alias.c freshplayerplugin-0.3.6/tests/test_encoding_alias.c --- freshplayerplugin-0.3.5/tests/test_encoding_alias.c 1970-01-01 00:00:00.000000000 +0000 +++ freshplayerplugin-0.3.6/tests/test_encoding_alias.c 2016-10-04 22:44:50.000000000 +0000 @@ -0,0 +1,49 @@ +#include "test.h" +#include + + +TEST(encoding_alias, utf8) +{ + // UTF-8 + ASSERT_STREQ(encoding_alias_get_canonical_name("utf8"), "UTF-8"); // plain + ASSERT_STREQ(encoding_alias_get_canonical_name("uTF8"), "UTF-8"); // partial uppercase + ASSERT_STREQ(encoding_alias_get_canonical_name("uTF-8"), "UTF-8"); +} + +TEST(encoding_alias, cp1251) +{ + // cp1251 + ASSERT_STREQ(encoding_alias_get_canonical_name("cp1251"), "windows-1251"); + ASSERT_STREQ(encoding_alias_get_canonical_name("windows-1251"), "windows-1251"); +} + +TEST(encoding_alias, GBK) +{ + // GBK + ASSERT_STREQ(encoding_alias_get_canonical_name("GBK"), "GBK"); + ASSERT_STREQ(encoding_alias_get_canonical_name("gb2312"), "GBK"); + ASSERT_STREQ(encoding_alias_get_canonical_name("gb2312-80"), "GBK"); +} + +static +void +strip_enc_name_tst(const char *a, const char *b) +{ + char *s = strip_enc_name(a); + ASSERT_STREQ(s, b); + free(s); +} + +TEST(encoding_alias, strip_enc_name) +{ + strip_enc_name_tst("UTF-8", "utf8"); + strip_enc_name_tst(" U_t_F_8 ", "utf8"); + strip_enc_name_tst("utf08", "utf8"); + strip_enc_name_tst("utf0008", "utf8"); + strip_enc_name_tst("0", "0"); + strip_enc_name_tst("", ""); + strip_enc_name_tst("00", "0"); + strip_enc_name_tst("000", "0"); + strip_enc_name_tst("0010", "10"); + strip_enc_name_tst("asd0", "asd0"); +} diff -Nru freshplayerplugin-0.3.5/tests/test.h freshplayerplugin-0.3.6/tests/test.h --- freshplayerplugin-0.3.5/tests/test.h 1970-01-01 00:00:00.000000000 +0000 +++ freshplayerplugin-0.3.6/tests/test.h 2016-10-04 22:44:50.000000000 +0000 @@ -0,0 +1,97 @@ +#pragma once + +#include +#include +#include + + +// ---------------------------------------------------------------------- +#define TEST(suite_name, test_name) \ +static \ +void \ +test_ ## suite_name ## _ ## test_name(void); \ + \ +__attribute__((constructor)) \ +static \ +void \ +constructor_test_ ## suite_name ## _ ## test_name(void) \ +{ \ + const char *testname = #suite_name ":" #test_name; \ + test_add_func(testname, test_ ## suite_name ## _ ## test_name); \ +} \ + \ +static \ +void \ +test_ ## suite_name ## _ ## test_name(void) +// ====================================================================== + +// ---------------------------------------------------------------------- +#define TEST_CONSTRUCTOR(func) \ +__attribute__((constructor)) \ +static \ +void \ +constructor_test_constructor(void) \ +{ \ + test_set_constructor(func); \ +} +// ====================================================================== + +// ---------------------------------------------------------------------- +#define ASSERT_OP(expr1, operation, expr2, name) \ +do { \ + __typeof(expr1) ____value1 = (expr1); \ + __typeof(expr2) ____value2 = (expr2); \ + int ____result = (____value1 operation ____value2); \ + \ + if (!____result) { \ + printf("%s(%s, %s) failed\n", #name, #expr1, #expr2); \ + abort(); \ + } \ +} while (0) +// ====================================================================== + +// ---------------------------------------------------------------------- +#define ASSERT_BOOL_OP(expr1, expr2, name) \ +do { \ + int ____value1 = !!(expr1); \ + int ____value2 = !!(expr2); \ + int ____result = (____value1 == ____value2); \ + \ + if (!____result) { \ + printf("%s(%s) failed\n", #name, #expr1); \ + abort(); \ + } \ +} while (0) +// ====================================================================== + +#define ASSERT_TRUE(e) ASSERT_BOOL_OP(e, 1, ASSERT_TRUE) +#define ASSERT_FALSE(e) ASSERT_BOOL_OP(e, 0, ASSERT_FALSE) + +#define ASSERT_EQ(e1, e2) ASSERT_OP(e1, ==, e2, ASSERT_EQ) +#define ASSERT_NE(e1, e2) ASSERT_OP(e1, !=, e2, ASSERT_NE) +#define ASSERT_LT(e1, e2) ASSERT_OP(e1, <, e2, ASSERT_LT) +#define ASSERT_LE(e1, e2) ASSERT_OP(e1, <=, e2, ASSERT_LE) +#define ASSERT_GT(e1, e2) ASSERT_OP(e1, >, e2, ASSERT_GT) +#define ASSERT_GE(e1, e2) ASSERT_OP(e1, >=, e2, ASSERT_GE) + +// ---------------------------------------------------------------------- +#define ASSERT_STREQ(expr1, expr2) \ +do { \ + int ____result = (strcmp((expr1), (expr2)) == 0); \ + \ + if (!____result) { \ + printf("ASSERT_STREQ(%s, %s) failed\n", #expr1, #expr2); \ + abort(); \ + } \ +} while (0) +// ====================================================================== + + +void +test_add_func(const char *name, void (*f)(void)); + +void +test_set_constructor(void (*f)(void)); + +void +test_run_all(void); diff -Nru freshplayerplugin-0.3.5/tests/test_header_parser.c freshplayerplugin-0.3.6/tests/test_header_parser.c --- freshplayerplugin-0.3.5/tests/test_header_parser.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/tests/test_header_parser.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,13 +1,10 @@ -#undef NDEBUG -#include +#include "test.h" #include #include #include -int -main(void) +TEST(header_parser, test_1) { - // === struct parsed_headers_s *ph = hp_parse_headers( "HTTP/1.1 200 OK\r\n" "Date: Sat, 19 Apr 2014 15:53:34 GMT\r\n" @@ -21,49 +18,52 @@ "Content-Type: application/x-shockwave-flash\r\n" ); - assert(ph); - assert(ph->http_code == 200); - assert(hp_header_exists(ph, "Date") == 1); - assert(hp_header_exists(ph, "date") == 1); - assert(hp_header_exists(ph, "Date2") == 0); - assert(hp_header_exists(ph, "Content-Type") == 1); - assert(hp_header_exists(ph, "bytes") == 0); + ASSERT_TRUE(ph); + ASSERT_EQ(ph->http_code, 200); + ASSERT_TRUE(hp_header_exists(ph, "Date")); + ASSERT_TRUE(hp_header_exists(ph, "date")); + ASSERT_FALSE(hp_header_exists(ph, "Date2")); + ASSERT_TRUE(hp_header_exists(ph, "Content-Type")); + ASSERT_FALSE(hp_header_exists(ph, "bytes")); - assert(0 == strcmp(hp_get_header_value(ph, "Date"), "Sat, 19 Apr 2014 15:53:34 GMT")); - assert(0 == strcmp(ph->status_line, "HTTP/1.1 200 OK")); + ASSERT_STREQ(hp_get_header_value(ph, "Date"), "Sat, 19 Apr 2014 15:53:34 GMT"); + ASSERT_STREQ(ph->status_line, "HTTP/1.1 200 OK"); hp_free_parsed_headers(ph); +} - // === - ph = hp_parse_headers( +TEST(header_parser, test_2) +{ + struct parsed_headers_s *ph = hp_parse_headers( "HTTP/1.0 301 Moved Permanently\r\n" "Location: http://example.org\r\n" "Connection: Keep-Alive\r\n" ); - assert(ph->http_code == 301); - assert(0 == strcmp(hp_get_header_value(ph, "Location"), "http://example.org")); - assert(0 == strcmp(ph->status_line, "HTTP/1.0 301 Moved Permanently")); + ASSERT_EQ(ph->http_code, 301); + ASSERT_STREQ(hp_get_header_value(ph, "Location"), "http://example.org"); + ASSERT_STREQ(ph->status_line, "HTTP/1.0 301 Moved Permanently"); hp_free_parsed_headers(ph); +} + +TEST(header_parser, test_3) +{ + struct parsed_headers_s *ph = hp_parse_headers(NULL); - // === - ph = hp_parse_headers(NULL); - assert(0 == ph->cnt); + ASSERT_EQ(ph->cnt, 0); hp_free_parsed_headers(ph); +} - // === +TEST(header_parser, test_4) +{ // no \r\n at the end of last header line - ph = hp_parse_headers( + struct parsed_headers_s *ph = hp_parse_headers( "HTTP/1.0 301 Moved Permanently\r\n" "Location: http://example.org\r\n" "Connection: Keep-Alive" ); - assert(hp_header_exists(ph, "Location") == 1); - assert(hp_header_exists(ph, "Connection") == 1); - assert(0 == strcmp(hp_get_header_value(ph, "Connection"), "Keep-Alive")); + ASSERT_TRUE(hp_header_exists(ph, "Location")); + ASSERT_TRUE(hp_header_exists(ph, "Connection")); + ASSERT_STREQ(hp_get_header_value(ph, "Connection"), "Keep-Alive"); hp_free_parsed_headers(ph); - - // === - printf("pass\n"); - return 0; } diff -Nru freshplayerplugin-0.3.5/tests/test_ppb_char_set.c freshplayerplugin-0.3.6/tests/test_ppb_char_set.c --- freshplayerplugin-0.3.5/tests/test_ppb_char_set.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/tests/test_ppb_char_set.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,14 +1,11 @@ -#undef NDEBUG -#include +#include "test.h" #include #include #include #include #include -static PP_Instance instance = 0; -// npn.memalloc static void * t_memalloc(uint32_t sz) @@ -16,168 +13,170 @@ return malloc(sz); } -// npn.memfree static void -t_memfree(void *ptr) +initializer(void) { - free(ptr); -} - -static -void -test_default_charset(void) -{ - // silly test actually. Both test and implementation contains almost the same code - setlocale(LC_ALL, ""); - char *current_charset = nl_langinfo(CODESET); - struct PP_Var cs = ppb_char_set_get_default_char_set(instance); - assert(strcmp(ppb_var_var_to_utf8(cs, NULL), current_charset) == 0); - printf("default charset = %s\n", current_charset); - ppb_var_release(cs); -} - -static -void -test_to_utf16(void) -{ - uint16_t *res; - uint32_t res_len; - - printf("to utf16: all ASCII\n"); - { - const char *in = "Hello, world!"; - const uint8_t out[] = {'H', 0, 'e', 0, 'l', 0, 'l', 0, 'o', 0, ',', 0, ' ', 0, 'w', 0, - 'o', 0, 'r', 0, 'l', 0, 'd', 0, '!', 0}; - res_len = 7777; - res = ppb_char_set_char_set_to_utf16(instance, in, strlen(in), "UTF-8", - PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); - assert(res_len == sizeof(out) / sizeof(uint16_t)); - assert(memcmp(res, out, sizeof(out)) == 0); - free(res); - } - - printf("to utf16: basic UTF-8\n"); - { - const char *in = "Привет, мир!"; - const uint8_t out[] = {0x1f, 0x04, 0x40, 0x04, 0x38, 0x04, 0x32, 0x04, 0x35, 0x04, - 0x42, 0x04, 0x2c, 0x00, 0x20, 0x00, 0x3c, 0x04, 0x38, 0x04, - 0x40, 0x04, 0x21, 0x00}; - res_len = 7777; - res = ppb_char_set_char_set_to_utf16(instance, in, strlen(in), "UTF-8", - PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); - assert(res_len == sizeof(out) / sizeof(uint16_t)); - assert(memcmp(res, out, sizeof(out)) == 0); - free(res); - } - - printf("to utf16: wrong UTF-8 with error\n"); - { - const char *in = "Hel\x80lo"; - res_len = 7777; - res = ppb_char_set_char_set_to_utf16(instance, in, strlen(in), "UTF-8", - PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); - assert(res_len == 0); - assert(res == NULL); - free(res); - } - - // testing PP_CHARSET_CONVERSIONERROR_SKIP or PP_CHARSET_CONVERSIONERROR_SUBSTITUTE - // have no much sense since every unicode character can be represented in UTF-16 + // npn is globally visible struct + npn.memalloc = t_memalloc; + npn.memfree = free; } -static -void -test_from_utf16(void) -{ - char *res; - uint32_t res_len; - - printf("from utf16: all ASCII\n"); - { - const uint8_t in[] = {'H', 0, 'e', 0, 'l', 0, 'l', 0, 'o', 0, ',', 0, ' ', 0, 'w', 0, - 'o', 0, 'r', 0, 'l', 0, 'd', 0, '!', 0}; - const char *out = "Hello, world!"; - res_len = 7777; - res = ppb_char_set_utf16_to_char_set(instance, (const uint16_t *)in, - sizeof(in) / sizeof(uint16_t), "cp1251", - PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); - assert(res_len == strlen(out)); - assert(memcmp(res, out, res_len) == 0); - free(res); - } - - printf("to utf16: non-ASCII all correct\n"); - { - const uint8_t in[] = {0x1f, 0x04, 0x40, 0x04, 0x38, 0x04, 0x32, 0x04, 0x35, 0x04, - 0x42, 0x04, 0x2c, 0x00, 0x20, 0x00, 0x3c, 0x04, 0x38, 0x04, - 0x40, 0x04, 0x21, 0x00}; // "Привет, мир!" - const char *out = "\xcf\xf0\xe8\xe2\xe5\xf2\x2c\x20\xec\xe8\xf0\x21"; // "Привет, мир!" - res_len = 7777; - res = ppb_char_set_utf16_to_char_set(instance, (const uint16_t *)in, - sizeof(in) / sizeof(uint16_t), "cp1251", - PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); - assert(res_len == strlen(out)); - assert(memcmp(res, out, res_len) == 0); - free(res); - } - - printf("to utf16: non-ASCII PP_CHARSET_CONVERSIONERROR_FAIL\n"); - { - const uint8_t in[] = {0x1f, 0x04, 0x40, 0x04, 0x38, 0x04, 0x32, 0x04, 0x35, 0x04, - 0x42, 0x04, 0x2c, 0x00, 0x20, 0x00, 0x6b, 0x26, 0x3c, 0x04, - 0x38, 0x04, 0x40, 0x04, 0x21, 0x00}; // "Привет, ♫мир!" - // const char *out = "\xcf\xf0\xe8\xe2\xe5\xf2\x2c\x20\xec\xe8\xf0\x21"; // "Привет, мир!" - res_len = 7777; - res = ppb_char_set_utf16_to_char_set(instance, (const uint16_t *)in, - sizeof(in) / sizeof(uint16_t), "cp1251", - PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); - assert(res_len == 0); - assert(res == NULL); - free(res); - } - - printf("to utf16: non-ASCII PP_CHARSET_CONVERSIONERROR_SKIP\n"); - { - const uint8_t in[] = {0x1f, 0x04, 0x40, 0x04, 0x38, 0x04, 0x32, 0x04, 0x35, 0x04, - 0x42, 0x04, 0x2c, 0x00, 0x20, 0x00, 0x6b, 0x26, 0x3c, 0x04, - 0x38, 0x04, 0x40, 0x04, 0x21, 0x00}; // "Привет, ♫мир!" - const char *out = "\xcf\xf0\xe8\xe2\xe5\xf2\x2c\x20\xec\xe8\xf0\x21"; // "Привет, мир!" - res_len = 7777; - res = ppb_char_set_utf16_to_char_set(instance, (const uint16_t *)in, - sizeof(in) / sizeof(uint16_t), "cp1251", - PP_CHARSET_CONVERSIONERROR_SKIP, &res_len); - assert(res_len == strlen(out)); - assert(memcmp(res, out, res_len) == 0); - free(res); - } - - printf("to utf16: non-ASCII PP_CHARSET_CONVERSIONERROR_SUBSTITUTE\n"); - { - const uint8_t in[] = {0x1f, 0x04, 0x40, 0x04, 0x38, 0x04, 0x32, 0x04, 0x35, 0x04, - 0x42, 0x04, 0x2c, 0x00, 0x20, 0x00, 0x6b, 0x26, 0x3c, 0x04, - 0x38, 0x04, 0x40, 0x04, 0x21, 0x00}; // "Привет, ♫мир!" - const char *out = "\xcf\xf0\xe8\xe2\xe5\xf2\x2c\x20\x3f\xec\xe8\xf0\x21";// "Привет, ?мир!" - res_len = 7777; - res = ppb_char_set_utf16_to_char_set(instance, (const uint16_t *)in, - sizeof(in) / sizeof(uint16_t), "cp1251", - PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &res_len); - assert(res_len == strlen(out)); - assert(memcmp(res, out, res_len) == 0); - free(res); - } -} +TEST_CONSTRUCTOR(initializer); -int -main(void) +TEST(ppb_char_set, extract_relevant_part_from_locale_name) { - npn.memalloc = t_memalloc; - npn.memfree = t_memfree; - - test_default_charset(); - test_to_utf16(); - test_from_utf16(); + char *s; - printf("pass\n"); - return 0; + s = extract_relevant_part_from_locale_name("ru_RU.UTF-8"); + ASSERT_STREQ(s, "ru"); + free(s); + + s = extract_relevant_part_from_locale_name("en_US"); + ASSERT_STREQ(s, "en"); + free(s); + + s = extract_relevant_part_from_locale_name("zh_CN.utf8"); + ASSERT_STREQ(s, "zh-CN"); + free(s); + + s = extract_relevant_part_from_locale_name("zh_TW.utf8"); + ASSERT_STREQ(s, "zh-TW"); + free(s); +} + +TEST(ppb_char_set, to_utf16_all_ASCII) +{ + const char *in = "Hello, world!"; + const uint8_t out[] = {'H', 0, 'e', 0, 'l', 0, 'l', 0, 'o', 0, ',', 0, ' ', 0, 'w', 0, + 'o', 0, 'r', 0, 'l', 0, 'd', 0, '!', 0}; + uint32_t res_len = 7777; + uint16_t *res = ppb_char_set_char_set_to_utf16(0, in, strlen(in), "UTF-8", + PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); + ASSERT_EQ(sizeof(out) / sizeof(uint16_t), res_len); + ASSERT_EQ(memcmp(res, out, sizeof(out)), 0); + free(res); +} + +TEST(ppb_char_set, to_utf16_basic_UTF_8) +{ + const char *in = "Привет, мир!"; + const uint8_t out[] = {0x1f, 0x04, 0x40, 0x04, 0x38, 0x04, 0x32, 0x04, 0x35, 0x04, + 0x42, 0x04, 0x2c, 0x00, 0x20, 0x00, 0x3c, 0x04, 0x38, 0x04, + 0x40, 0x04, 0x21, 0x00}; + uint32_t res_len = 7777; + uint16_t *res = ppb_char_set_char_set_to_utf16(0, in, strlen(in), "UTF-8", + PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); + ASSERT_EQ(sizeof(out) / sizeof(uint16_t), res_len); + ASSERT_EQ(memcmp(res, out, sizeof(out)), 0); + free(res); +} + +TEST(ppb_char_set, to_utf16_wrong_UTF_8_with_error) +{ + const char *in = "Hel\x80lo"; + uint32_t res_len = 7777; + uint16_t *res = ppb_char_set_char_set_to_utf16(0, in, strlen(in), "UTF-8", + PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); + ASSERT_EQ(res_len, 0); + ASSERT_EQ(res, NULL); + free(res); +} + +// testing PP_CHARSET_CONVERSIONERROR_SKIP or PP_CHARSET_CONVERSIONERROR_SUBSTITUTE +// have no much sense since every unicode character can be represented in UTF-16 + +TEST(ppb_char_set, from_utf16_all_ASCII) +{ + const uint8_t in[] = {'H', 0, 'e', 0, 'l', 0, 'l', 0, 'o', 0, ',', 0, ' ', 0, 'w', 0, + 'o', 0, 'r', 0, 'l', 0, 'd', 0, '!', 0}; + const char *out = "Hello, world!"; + uint32_t res_len = 7777; + char *res = ppb_char_set_utf16_to_char_set(0, (const uint16_t *)in, + sizeof(in) / sizeof(uint16_t), "cp1251", + PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); + ASSERT_EQ(strlen(out), res_len); + ASSERT_EQ(memcmp(res, out, res_len), 0); + free(res); +} + +TEST(ppb_char_set, to_utf16_non_ASCII_all_correct) +{ + const uint8_t in[] = {0x1f, 0x04, 0x40, 0x04, 0x38, 0x04, 0x32, 0x04, 0x35, 0x04, + 0x42, 0x04, 0x2c, 0x00, 0x20, 0x00, 0x3c, 0x04, 0x38, 0x04, + 0x40, 0x04, 0x21, 0x00}; // "Привет, мир!" + const char *out = "\xcf\xf0\xe8\xe2\xe5\xf2\x2c\x20\xec\xe8\xf0\x21"; // "Привет, мир!" + uint32_t res_len = 7777; + char *res = ppb_char_set_utf16_to_char_set(0, (const uint16_t *)in, + sizeof(in) / sizeof(uint16_t), "cp1251", + PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); + ASSERT_EQ(strlen(out), res_len); + ASSERT_EQ(memcmp(res, out, res_len), 0); + free(res); +} + +TEST(ppb_char_set, to_utf16_non_ASCII_PP_CHARSET_CONVERSIONERROR_FAIL) +{ + const uint8_t in[] = {0x1f, 0x04, 0x40, 0x04, 0x38, 0x04, 0x32, 0x04, 0x35, 0x04, + 0x42, 0x04, 0x2c, 0x00, 0x20, 0x00, 0x6b, 0x26, 0x3c, 0x04, + 0x38, 0x04, 0x40, 0x04, 0x21, 0x00}; // "Привет, ♫мир!" + // const char *out = "\xcf\xf0\xe8\xe2\xe5\xf2\x2c\x20\xec\xe8\xf0\x21"; // "Привет, мир!" + uint32_t res_len = 7777; + char *res = ppb_char_set_utf16_to_char_set(0, (const uint16_t *)in, + sizeof(in) / sizeof(uint16_t), "cp1251", + PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); + ASSERT_EQ(res_len, 0); + ASSERT_EQ(res, NULL); + free(res); +} + +TEST(ppb_char_set, to_utf16_non_ASCII_PP_CHARSET_CONVERSIONERROR_SKIP) +{ + const uint8_t in[] = {0x1f, 0x04, 0x40, 0x04, 0x38, 0x04, 0x32, 0x04, 0x35, 0x04, + 0x42, 0x04, 0x2c, 0x00, 0x20, 0x00, 0x6b, 0x26, 0x3c, 0x04, + 0x38, 0x04, 0x40, 0x04, 0x21, 0x00}; // "Привет, ♫мир!" + const char *out = "\xcf\xf0\xe8\xe2\xe5\xf2\x2c\x20\xec\xe8\xf0\x21"; // "Привет, мир!" + uint32_t res_len = 7777; + char *res = ppb_char_set_utf16_to_char_set(0, (const uint16_t *)in, + sizeof(in) / sizeof(uint16_t), "cp1251", + PP_CHARSET_CONVERSIONERROR_SKIP, &res_len); + ASSERT_EQ(strlen(out), res_len); + ASSERT_EQ(memcmp(res, out, res_len), 0); + free(res); +} + +TEST(ppb_char_set, to_utf16_non_ASCII_PP_CHARSET_CONVERSIONERROR_SUBSTITUTE) +{ + const uint8_t in[] = {0x1f, 0x04, 0x40, 0x04, 0x38, 0x04, 0x32, 0x04, 0x35, 0x04, + 0x42, 0x04, 0x2c, 0x00, 0x20, 0x00, 0x6b, 0x26, 0x3c, 0x04, + 0x38, 0x04, 0x40, 0x04, 0x21, 0x00}; // "Привет, ♫мир!" + const char *out = "\xcf\xf0\xe8\xe2\xe5\xf2\x2c\x20\x3f\xec\xe8\xf0\x21";// "Привет, ?мир!" + uint32_t res_len = 7777; + char *res = ppb_char_set_utf16_to_char_set(0, (const uint16_t *)in, + sizeof(in) / sizeof(uint16_t), "cp1251", + PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &res_len); + ASSERT_EQ(strlen(out), res_len); + ASSERT_EQ(memcmp(res, out, res_len), 0); + free(res); +} + +TEST(ppb_char_set, gb2312_ASCII_to_utf16) +{ + // gb2312 is a variable-length encoding, with ASCII encoded as is + + // "Hello, world!" in ASCII + const uint8_t in[] = {0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, + 0x6c, 0x64, 0x21}; + + // "Hello, world!" in UTF16-LE + const uint8_t out[] = {0x48, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00, + 0x2c, 0x00, 0x20, 0x00, 0x77, 0x00, 0x6f, 0x00, 0x72, 0x00, + 0x6c, 0x00, 0x64, 0x00, 0x21, 0x00}; + + uint32_t res_len = 7777; + uint16_t *res = ppb_char_set_char_set_to_utf16(0, (const char *)in, sizeof(in), "gb2312", + PP_CHARSET_CONVERSIONERROR_FAIL, &res_len); + ASSERT_EQ(res_len, sizeof(out) / sizeof(uint16_t)); + ASSERT_EQ(memcmp(res, out, sizeof(out)), 0); + free(res); } diff -Nru freshplayerplugin-0.3.5/tests/test_ppb_flash_file.c freshplayerplugin-0.3.6/tests/test_ppb_flash_file.c --- freshplayerplugin-0.3.5/tests/test_ppb_flash_file.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/tests/test_ppb_flash_file.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,4 @@ -#undef NDEBUG -#include +#include "test.h" #include #include #include @@ -9,14 +8,13 @@ void test_case(const char *s, const char *res) { - printf("/%s -> %s\n", s, res); + printf(" /%s -> %s\n", s, res); char *got = to_abs_path("/start", s); - assert(strcmp(got, res) == 0); + ASSERT_STREQ(got, res); free(got); } -int -main(void) +TEST(ppb_flash_file, to_abs_path) { test_case("WritableRoot/#SharedObjects/4TVF7XJR/macromedia.com/support/flashplayer/sys/#127.0.0.1", "/start/WritableRoot/#SharedObjects/4TVF7XJR/macromedia.com/support/flashplayer/sys/#127.0.0.1"); @@ -36,7 +34,4 @@ test_case("g.", "/start/g."); test_case("g../a", "/start/g../a"); test_case("g./a", "/start/g./a"); - - printf("pass\n"); - return 0; } diff -Nru freshplayerplugin-0.3.5/tests/test_ppb_net_address.c freshplayerplugin-0.3.6/tests/test_ppb_net_address.c --- freshplayerplugin-0.3.5/tests/test_ppb_net_address.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/tests/test_ppb_net_address.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,4 @@ -#undef NDEBUG -#include +#include "test.h" #include #include #include @@ -8,291 +7,263 @@ #include "src/ppb_core.h" -static PP_Instance instance; +TEST(ppb_net_address_private, ipv4_compose_decompose) +{ + const uint8_t ip[4] = {192, 168, 1, 2}; + const uint16_t port = 1234; + uint8_t ip_out[sizeof(ip)] = {}; + struct PP_NetAddress_Private addr; + + ppb_net_address_private_create_from_ipv4_address(ip, port, &addr); + + ppb_net_address_private_get_address(&addr, ip_out, sizeof(ip_out)); + ASSERT_EQ(memcmp(ip, ip_out, sizeof(ip)), 0); + + ASSERT_EQ(ppb_net_address_private_get_port(&addr), port); + ASSERT_EQ(ppb_net_address_private_get_family(&addr), PP_NETADDRESSFAMILY_PRIVATE_IPV4); + ASSERT_EQ(ppb_net_address_private_get_scope_id(&addr), 0); +} + +TEST(ppb_net_address_private, ipv4_equality) +{ + const uint8_t ip[4] = {192, 168, 1, 2}; + const uint16_t port1 = 1234; + const uint16_t port2 = 5678; + + struct PP_NetAddress_Private addr1; + struct PP_NetAddress_Private addr2; + + ppb_net_address_private_create_from_ipv4_address(ip, port1, &addr1); + ppb_net_address_private_create_from_ipv4_address(ip, port2, &addr2); + + // different ports, hence are different + ASSERT_EQ(ppb_net_address_private_are_equal(&addr1, &addr2), PP_FALSE); + ASSERT_EQ(ppb_net_address_private_are_hosts_equal(&addr1, &addr2), PP_TRUE); + + ppb_net_address_private_create_from_ipv4_address(ip, port2, &addr1); + ppb_net_address_private_create_from_ipv4_address(ip, port2, &addr2); + + // should be equal + ASSERT_EQ(ppb_net_address_private_are_equal(&addr1, &addr2), PP_TRUE); + ASSERT_EQ(ppb_net_address_private_are_hosts_equal(&addr1, &addr2), PP_TRUE); +} + +TEST(ppb_net_address_private, ipv4_replace_port) +{ + const uint8_t ip[4] = {192, 168, 1, 2}; + const uint16_t port1 = 1234; + const uint16_t port2 = 1234; + + struct PP_NetAddress_Private addr1; + struct PP_NetAddress_Private addr2; + + ppb_net_address_private_create_from_ipv4_address(ip, port1, &addr1); + ASSERT_EQ(ppb_net_address_private_get_port(&addr1), port1); + + ppb_net_address_private_replace_port(&addr1, port2, &addr2); + ASSERT_EQ(ppb_net_address_private_get_port(&addr2), port2); +} + +TEST(ppb_net_address_private, ipv4_describe) +{ + const uint8_t ip[4] = {192, 168, 1, 2}; + const uint16_t port = 1234; + + struct PP_NetAddress_Private addr; + struct PP_Var s; + + ppb_net_address_private_create_from_ipv4_address(ip, port, &addr); + s = ppb_net_address_private_describe(0, &addr, PP_TRUE); + ASSERT_STREQ(ppb_var_var_to_utf8(s, NULL), "192.168.1.2:1234"); + ppb_var_release(s); + + s = ppb_net_address_private_describe(0, &addr, PP_FALSE); + ASSERT_STREQ(ppb_var_var_to_utf8(s, NULL), "192.168.1.2"); + ppb_var_release(s); +} + +TEST(ppb_net_address_private, ipv6_compose_decompose) +{ + const uint8_t ip[16] = { 0x01, 0x23, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, + 0xef, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; + const uint16_t port = 3333; + const uint32_t scope_id = 555; + + struct PP_NetAddress_Private addr; + uint8_t ip_out[sizeof(ip)] = {}; + + ppb_net_address_private_create_from_ipv6_address(ip, scope_id, port, &addr); + + ppb_net_address_private_get_address(&addr, ip_out, sizeof(ip_out)); + ASSERT_EQ(memcmp(ip, ip_out, sizeof(ip)), 0); + + ASSERT_EQ(ppb_net_address_private_get_port(&addr), port); + ASSERT_EQ(ppb_net_address_private_get_family(&addr), PP_NETADDRESSFAMILY_PRIVATE_IPV6); + ASSERT_EQ(ppb_net_address_private_get_scope_id(&addr), scope_id); +} + +TEST(ppb_net_address_private, ipv6_equality) +{ + const uint8_t ip[16] = { 0x01, 0x23, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, + 0xef, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; + const uint16_t port1 = 3333; + const uint16_t port2 = 5555; + + struct PP_NetAddress_Private addr1; + struct PP_NetAddress_Private addr2; + + // different ports + ppb_net_address_private_create_from_ipv6_address(ip, 0, port1, &addr1); + ppb_net_address_private_create_from_ipv6_address(ip, 0, port2, &addr2); + + // different, but hosts are the same + ASSERT_EQ(ppb_net_address_private_are_equal(&addr1, &addr2), PP_FALSE); + ASSERT_EQ(ppb_net_address_private_are_hosts_equal(&addr1, &addr2), PP_TRUE); + + // same ports + ppb_net_address_private_create_from_ipv6_address(ip, 0, port2, &addr1); + ppb_net_address_private_create_from_ipv6_address(ip, 0, port2, &addr2); + + // should be equal + ASSERT_EQ(ppb_net_address_private_are_equal(&addr1, &addr2), PP_TRUE); + ASSERT_EQ(ppb_net_address_private_are_hosts_equal(&addr1, &addr2), PP_TRUE); +} + +TEST(ppb_net_address_private, ipv6_replace_port) +{ + const uint8_t ip[16] = { 0x01, 0x23, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, + 0xef, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; + const uint16_t port1 = 1234; + const uint16_t port2 = 1234; + + struct PP_NetAddress_Private addr1; + struct PP_NetAddress_Private addr2; + + ppb_net_address_private_create_from_ipv6_address(ip, 0, port1, &addr1); + ASSERT_EQ(ppb_net_address_private_get_port(&addr1), port1); + + ppb_net_address_private_replace_port(&addr1, port2, &addr2); + ASSERT_EQ(ppb_net_address_private_get_port(&addr2), port2); +} + +TEST(ppb_net_address_private, ipv6_describe) +{ + const uint8_t ip[16] = { 0x01, 0x23, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, + 0xef, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; + const uint16_t port = 1234; + + struct PP_NetAddress_Private addr; + struct PP_Var s; + + ppb_net_address_private_create_from_ipv6_address(ip, 0, port, &addr); + s = ppb_net_address_private_describe(0, &addr, PP_TRUE); + ASSERT_STREQ(ppb_var_var_to_utf8(s, NULL), "[123:3456:789a:bcde:ef11:2233:4455:6677]:1234"); + ppb_var_release(s); + + s = ppb_net_address_private_describe(0, &addr, PP_FALSE); + ASSERT_STREQ(ppb_var_var_to_utf8(s, NULL), "123:3456:789a:bcde:ef11:2233:4455:6677"); + ppb_var_release(s); +} + +TEST(ppb_net_address_private, ill_formed_PP_NetAddress_Private) +{ + const uint8_t ip[4] = {192, 168, 1, 2}; + const uint16_t port = 1234; + + struct PP_NetAddress_Private addr1; + struct PP_NetAddress_Private addr2 = {}; + struct PP_NetAddress_Private addr3 = {}; + struct PP_Var s; + uint8_t ip_out[4]; + + ppb_net_address_private_create_from_ipv4_address(ip, port, &addr1); + + ASSERT_EQ(ppb_net_address_private_are_equal(&addr1, &addr2), PP_FALSE); + ASSERT_EQ(ppb_net_address_private_are_hosts_equal(&addr1, &addr2), PP_FALSE); + ASSERT_EQ(ppb_net_address_private_get_family(&addr2), PP_NETADDRESSFAMILY_PRIVATE_UNSPECIFIED); + ASSERT_EQ(ppb_net_address_private_get_port(&addr2), 0); + ASSERT_EQ(ppb_net_address_private_get_address(&addr2, ip_out, sizeof(ip_out)), PP_FALSE); + ASSERT_EQ(ppb_net_address_private_replace_port(&addr2, port, &addr3), PP_FALSE); -static -void -test_ppb_net_address_private(void) -{ - printf("%s\n", __func__); - - printf(" ipv4, compose/decompose\n"); - { - const uint8_t ip[4] = {192, 168, 1, 2}; - const uint16_t port = 1234; - uint8_t ip_out[sizeof(ip)] = {}; - struct PP_NetAddress_Private addr; - - ppb_net_address_private_create_from_ipv4_address(ip, port, &addr); - - ppb_net_address_private_get_address(&addr, ip_out, sizeof(ip_out)); - assert(memcmp(ip, ip_out, sizeof(ip)) == 0); - - assert(ppb_net_address_private_get_port(&addr) == port); - assert(ppb_net_address_private_get_family(&addr) == PP_NETADDRESSFAMILY_PRIVATE_IPV4); - assert(ppb_net_address_private_get_scope_id(&addr) == 0); - } - - printf(" ipv4, equality\n"); - { - const uint8_t ip[4] = {192, 168, 1, 2}; - const uint16_t port1 = 1234; - const uint16_t port2 = 5678; - - struct PP_NetAddress_Private addr1; - struct PP_NetAddress_Private addr2; - - ppb_net_address_private_create_from_ipv4_address(ip, port1, &addr1); - ppb_net_address_private_create_from_ipv4_address(ip, port2, &addr2); - - // different ports, hence are different - assert(ppb_net_address_private_are_equal(&addr1, &addr2) == PP_FALSE); - assert(ppb_net_address_private_are_hosts_equal(&addr1, &addr2) == PP_TRUE); - - ppb_net_address_private_create_from_ipv4_address(ip, port2, &addr1); - ppb_net_address_private_create_from_ipv4_address(ip, port2, &addr2); - - // should be equal - assert(ppb_net_address_private_are_equal(&addr1, &addr2) == PP_TRUE); - assert(ppb_net_address_private_are_hosts_equal(&addr1, &addr2) == PP_TRUE); - } - - printf(" ipv4, replace port\n"); - { - const uint8_t ip[4] = {192, 168, 1, 2}; - const uint16_t port1 = 1234; - const uint16_t port2 = 1234; - - struct PP_NetAddress_Private addr1; - struct PP_NetAddress_Private addr2; - - ppb_net_address_private_create_from_ipv4_address(ip, port1, &addr1); - assert(ppb_net_address_private_get_port(&addr1) == port1); - - ppb_net_address_private_replace_port(&addr1, port2, &addr2); - assert(ppb_net_address_private_get_port(&addr2) == port2); - } - - printf(" ipv4, describe\n"); - { - const uint8_t ip[4] = {192, 168, 1, 2}; - const uint16_t port = 1234; - - struct PP_NetAddress_Private addr; - struct PP_Var s; - - ppb_net_address_private_create_from_ipv4_address(ip, port, &addr); - s = ppb_net_address_private_describe(0, &addr, PP_TRUE); - assert(strcmp(ppb_var_var_to_utf8(s, NULL), "192.168.1.2:1234") == 0); - ppb_var_release(s); - - s = ppb_net_address_private_describe(0, &addr, PP_FALSE); - assert(strcmp(ppb_var_var_to_utf8(s, NULL), "192.168.1.2") == 0); - ppb_var_release(s); - } - - printf(" ipv6, compose/decompose\n"); - { - const uint8_t ip[16] = { 0x01, 0x23, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, - 0xef, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; - const uint16_t port = 3333; - const uint32_t scope_id = 555; - - struct PP_NetAddress_Private addr; - uint8_t ip_out[sizeof(ip)] = {}; - - ppb_net_address_private_create_from_ipv6_address(ip, scope_id, port, &addr); - - ppb_net_address_private_get_address(&addr, ip_out, sizeof(ip_out)); - assert(memcmp(ip, ip_out, sizeof(ip)) == 0); - - assert(ppb_net_address_private_get_port(&addr) == port); - assert(ppb_net_address_private_get_family(&addr) == PP_NETADDRESSFAMILY_PRIVATE_IPV6); - assert(ppb_net_address_private_get_scope_id(&addr) == scope_id); - } - - printf(" ipv6, equality\n"); - { - const uint8_t ip[16] = { 0x01, 0x23, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, - 0xef, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; - const uint16_t port1 = 3333; - const uint16_t port2 = 5555; - - struct PP_NetAddress_Private addr1; - struct PP_NetAddress_Private addr2; - - // different ports - ppb_net_address_private_create_from_ipv6_address(ip, 0, port1, &addr1); - ppb_net_address_private_create_from_ipv6_address(ip, 0, port2, &addr2); - - // different, but hosts are the same - assert(ppb_net_address_private_are_equal(&addr1, &addr2) == PP_FALSE); - assert(ppb_net_address_private_are_hosts_equal(&addr1, &addr2) == PP_TRUE); - - // same ports - ppb_net_address_private_create_from_ipv6_address(ip, 0, port2, &addr1); - ppb_net_address_private_create_from_ipv6_address(ip, 0, port2, &addr2); - - // should be equal - assert(ppb_net_address_private_are_equal(&addr1, &addr2) == PP_TRUE); - assert(ppb_net_address_private_are_hosts_equal(&addr1, &addr2) == PP_TRUE); - } - - printf(" ipv6, replace port\n"); - { - const uint8_t ip[16] = { 0x01, 0x23, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, - 0xef, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; - const uint16_t port1 = 1234; - const uint16_t port2 = 1234; - - struct PP_NetAddress_Private addr1; - struct PP_NetAddress_Private addr2; - - ppb_net_address_private_create_from_ipv6_address(ip, 0, port1, &addr1); - assert(ppb_net_address_private_get_port(&addr1) == port1); - - ppb_net_address_private_replace_port(&addr1, port2, &addr2); - assert(ppb_net_address_private_get_port(&addr2) == port2); - } - - printf(" ipv6, describe\n"); - { - const uint8_t ip[16] = { 0x01, 0x23, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, - 0xef, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; - const uint16_t port = 1234; - - struct PP_NetAddress_Private addr; - struct PP_Var s; - - ppb_net_address_private_create_from_ipv6_address(ip, 0, port, &addr); - s = ppb_net_address_private_describe(0, &addr, PP_TRUE); - assert(strcmp(ppb_var_var_to_utf8(s, NULL), - "[123:3456:789a:bcde:ef11:2233:4455:6677]:1234") == 0); - ppb_var_release(s); - - s = ppb_net_address_private_describe(0, &addr, PP_FALSE); - assert(strcmp(ppb_var_var_to_utf8(s, NULL), - "123:3456:789a:bcde:ef11:2233:4455:6677") == 0); - ppb_var_release(s); - } - - printf(" ill-formed PP_NetAddress_Private\n"); - { - const uint8_t ip[4] = {192, 168, 1, 2}; - const uint16_t port = 1234; - - struct PP_NetAddress_Private addr1; - struct PP_NetAddress_Private addr2 = {}; - struct PP_NetAddress_Private addr3 = {}; - struct PP_Var s; - uint8_t ip_out[4]; - - ppb_net_address_private_create_from_ipv4_address(ip, port, &addr1); - - assert(ppb_net_address_private_are_equal(&addr1, &addr2) == PP_FALSE); - assert(ppb_net_address_private_are_hosts_equal(&addr1, &addr2) == PP_FALSE); - assert(ppb_net_address_private_get_family(&addr2)==PP_NETADDRESSFAMILY_PRIVATE_UNSPECIFIED); - assert(ppb_net_address_private_get_port(&addr2) == 0); - - assert(ppb_net_address_private_get_address(&addr2, ip_out, sizeof(ip_out)) == PP_FALSE); - assert(ppb_net_address_private_replace_port(&addr2, port, &addr3) == PP_FALSE); - - s = ppb_net_address_private_describe(0, &addr2, PP_TRUE); - assert(s.type == PP_VARTYPE_UNDEFINED); - } - - printf(" ipv4, get any address\n"); - { - const uint8_t all_zeroes[4] = {}; - uint8_t ip[4]; - struct PP_NetAddress_Private addr; - - memset(&addr, 5, sizeof(addr)); // overwrite with something - ppb_net_address_private_get_any_address(PP_FALSE, &addr); - assert(ppb_net_address_private_get_family(&addr) == PP_NETADDRESSFAMILY_PRIVATE_IPV4); - - ppb_net_address_private_get_address(&addr, ip, sizeof(ip)); - assert(memcmp(ip, all_zeroes, sizeof(ip)) == 0); - } - - printf(" ipv6, get any address\n"); - { - const uint8_t all_zeroes[16] = {}; - uint8_t ip[16]; - struct PP_NetAddress_Private addr; - - memset(&addr, 5, sizeof(addr)); // overwrite with something - ppb_net_address_private_get_any_address(PP_TRUE, &addr); - assert(ppb_net_address_private_get_family(&addr) == PP_NETADDRESSFAMILY_PRIVATE_IPV6); - - ppb_net_address_private_get_address(&addr, ip, sizeof(ip)); - assert(memcmp(ip, all_zeroes, sizeof(ip)) == 0); - } -} - -static -void -test_ppb_net_address(void) -{ - printf("%s\n", __func__); - - printf(" ipv4, compose/decompose\n"); - { - const struct PP_NetAddress_IPv4 ipv4 = { .addr = {192, 168, 1, 2}, - .port = htons(3456) }; - struct PP_NetAddress_IPv4 ipv4_a = {}; - struct PP_NetAddress_IPv6 ipv6 = {}; - - PP_Resource addr = ppb_net_address_create_from_ipv4_address(instance, &ipv4); - assert(ppb_net_address_is_net_address(addr) == PP_TRUE); - assert(ppb_net_address_get_family(addr) == PP_NETADDRESS_FAMILY_IPV4); - assert(ppb_net_address_describe_as_ipv6_address(addr, &ipv6) == PP_FALSE); - assert(ppb_net_address_describe_as_ipv4_address(addr, &ipv4_a) == PP_TRUE); - - assert(memcmp(&ipv4, &ipv4_a, sizeof(ipv4_a)) == 0); - - struct PP_Var s = ppb_net_address_describe_as_string(addr, PP_TRUE); - assert(strcmp(ppb_var_var_to_utf8(s, NULL), "192.168.1.2:3456") == 0); - ppb_var_release(s); - - ppb_core_release_resource(addr); - } - - printf(" ipv6, compose/decompose\n"); - { - const struct PP_NetAddress_IPv6 ipv6 = { .addr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16}, - .port = htons(3456) }; - struct PP_NetAddress_IPv6 ipv6_a = {}; - struct PP_NetAddress_IPv4 ipv4 = {}; - - PP_Resource addr = ppb_net_address_create_from_ipv6_address(instance, &ipv6); - assert(ppb_net_address_is_net_address(addr) == PP_TRUE); - assert(ppb_net_address_get_family(addr) == PP_NETADDRESS_FAMILY_IPV6); - assert(ppb_net_address_describe_as_ipv4_address(addr, &ipv4) == PP_FALSE); - - assert(ppb_net_address_describe_as_ipv6_address(addr, &ipv6_a) == PP_TRUE); - assert(memcmp(&ipv6, &ipv6_a, sizeof(ipv6_a)) == 0); - - struct PP_Var s = ppb_net_address_describe_as_string(addr, PP_TRUE); - assert(strcmp(ppb_var_var_to_utf8(s, NULL), "[102:304:506:708:90a:b0c:d0e:f10]:3456") == 0); - ppb_var_release(s); - - ppb_core_release_resource(addr); - } + s = ppb_net_address_private_describe(0, &addr2, PP_TRUE); + ASSERT_EQ(s.type, PP_VARTYPE_UNDEFINED); } -int -main(void) +TEST(ppb_net_address_private, ipv4_get_any_address) { - instance = create_instance(); + const uint8_t all_zeroes[4] = {}; + uint8_t ip[4]; + struct PP_NetAddress_Private addr; + + memset(&addr, 5, sizeof(addr)); // overwrite with something + ppb_net_address_private_get_any_address(PP_FALSE, &addr); + ASSERT_EQ(ppb_net_address_private_get_family(&addr), PP_NETADDRESSFAMILY_PRIVATE_IPV4); - test_ppb_net_address_private(); - test_ppb_net_address(); + ppb_net_address_private_get_address(&addr, ip, sizeof(ip)); + ASSERT_EQ(memcmp(ip, all_zeroes, sizeof(ip)), 0); +} +TEST(ppb_net_address, ipv6_get_any_address) +{ + const uint8_t all_zeroes[16] = {}; + uint8_t ip[16]; + struct PP_NetAddress_Private addr; + + memset(&addr, 5, sizeof(addr)); // overwrite with something + ppb_net_address_private_get_any_address(PP_TRUE, &addr); + ASSERT_EQ(ppb_net_address_private_get_family(&addr), PP_NETADDRESSFAMILY_PRIVATE_IPV6); + + ppb_net_address_private_get_address(&addr, ip, sizeof(ip)); + ASSERT_EQ(memcmp(ip, all_zeroes, sizeof(ip)), 0); +} + +TEST(ppb_net_address, ipv4_compose_decompose) +{ + PP_Instance instance = create_instance(); + + const struct PP_NetAddress_IPv4 ipv4 = { .addr = {192, 168, 1, 2}, + .port = htons(3456) }; + struct PP_NetAddress_IPv4 ipv4_a = {}; + struct PP_NetAddress_IPv6 ipv6 = {}; + + PP_Resource addr = ppb_net_address_create_from_ipv4_address(instance, &ipv4); + ASSERT_EQ(ppb_net_address_is_net_address(addr), PP_TRUE); + ASSERT_EQ(ppb_net_address_get_family(addr), PP_NETADDRESS_FAMILY_IPV4); + ASSERT_EQ(ppb_net_address_describe_as_ipv6_address(addr, &ipv6), PP_FALSE); + ASSERT_EQ(ppb_net_address_describe_as_ipv4_address(addr, &ipv4_a), PP_TRUE); + + ASSERT_EQ(memcmp(&ipv4, &ipv4_a, sizeof(ipv4_a)), 0); + + struct PP_Var s = ppb_net_address_describe_as_string(addr, PP_TRUE); + ASSERT_STREQ(ppb_var_var_to_utf8(s, NULL), "192.168.1.2:3456"); + ppb_var_release(s); + + ppb_core_release_resource(addr); destroy_instance(instance); +} - printf("pass\n"); - return 0; +TEST(ppb_net_address, ipv6_compose_decompose) +{ + PP_Instance instance = create_instance(); + const struct PP_NetAddress_IPv6 ipv6 = { .addr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16}, + .port = htons(3456) }; + struct PP_NetAddress_IPv6 ipv6_a = {}; + struct PP_NetAddress_IPv4 ipv4 = {}; + + PP_Resource addr = ppb_net_address_create_from_ipv6_address(instance, &ipv6); + ASSERT_EQ(ppb_net_address_is_net_address(addr), PP_TRUE); + ASSERT_EQ(ppb_net_address_get_family(addr), PP_NETADDRESS_FAMILY_IPV6); + ASSERT_EQ(ppb_net_address_describe_as_ipv4_address(addr, &ipv4), PP_FALSE); + + ASSERT_EQ(ppb_net_address_describe_as_ipv6_address(addr, &ipv6_a), PP_TRUE); + ASSERT_EQ(memcmp(&ipv6, &ipv6_a, sizeof(ipv6_a)), 0); + + struct PP_Var s = ppb_net_address_describe_as_string(addr, PP_TRUE); + ASSERT_STREQ(ppb_var_var_to_utf8(s, NULL), "[102:304:506:708:90a:b0c:d0e:f10]:3456"); + ppb_var_release(s); + + ppb_core_release_resource(addr); + destroy_instance(instance); } diff -Nru freshplayerplugin-0.3.5/tests/test_ppb_url_request_info.c freshplayerplugin-0.3.6/tests/test_ppb_url_request_info.c --- freshplayerplugin-0.3.5/tests/test_ppb_url_request_info.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/tests/test_ppb_url_request_info.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,24 +1,18 @@ -#undef NDEBUG -#include -#include +#include "test.h" #include #include #define test_ltrim(in, out) \ do { \ const char *s = ltrim(in); \ - assert(strcmp(s, out) == 0); \ + ASSERT_TRUE(strcmp(s, out) == 0); \ } while (0) -int -main(void) +TEST(ppb_url_request_info, ltrim) { test_ltrim("", ""); test_ltrim("hello", "hello"); test_ltrim(" hello", "hello"); test_ltrim(" \t hello", "hello"); test_ltrim("\n\nhello", "hello"); - - printf("pass\n"); - return 0; } diff -Nru freshplayerplugin-0.3.5/tests/test_ppb_x509_certificate.c freshplayerplugin-0.3.6/tests/test_ppb_x509_certificate.c --- freshplayerplugin-0.3.5/tests/test_ppb_x509_certificate.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/tests/test_ppb_x509_certificate.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,5 +1,4 @@ -#undef NDEBUG -#include +#include "test.h" #include #include #include @@ -20,17 +19,15 @@ if (target > 0) { // expecting success - assert(var.type == PP_VARTYPE_DOUBLE); - assert(fabs(var.value.as_double - target) < eps); + ASSERT_EQ(var.type, PP_VARTYPE_DOUBLE); + ASSERT_TRUE(fabs(var.value.as_double - target) < eps); } else { // expecting failure - assert(var.type = PP_VARTYPE_NULL); + ASSERT_EQ(var.type, PP_VARTYPE_NULL); } } -static -void -test_convert_asn1_time_to_pp_var(void) +TEST(ppb_x509_certificate, convert_asn1_time_to_pp_var) { printf("V_ASN1_UTCTIME\n"); test_hlp("9912312359Z", V_ASN1_UTCTIME, 946684740, 1e-3); @@ -41,24 +38,23 @@ test_hlp("20001231235959.999+0300", V_ASN1_GENERALIZEDTIME, 978307199.999 - 3600 * 3, 1e-3); } -static -void -test_ppb_x509_certificate(PP_Instance instance) +TEST(ppb_x509_certificate, main) { struct PP_Var var; const char *s; PP_Resource x509; + PP_Instance instance = create_instance(); x509 = ppb_x509_certificate_create(instance); - assert(x509); + ASSERT_TRUE(x509); gchar *buf; gsize len; gboolean ret1 = g_file_get_contents(TEST_DATA_DIR "/wikipedia.org.der", &buf, &len, NULL); - assert(ret1 == TRUE); + ASSERT_TRUE(ret1); PP_Bool ret2 = ppb_x509_certificate_initialize(x509, buf, len); - assert(ret2 == PP_TRUE); + ASSERT_EQ(ret2, PP_TRUE); g_free(buf); #define TST_GET_FIELD(fname) \ @@ -68,55 +64,46 @@ // ======== TST_GET_FIELD(PP_X509CERTIFICATE_PRIVATE_ISSUER_COMMON_NAME); s = ppb_var_var_to_utf8(var, NULL); - assert(strcmp(s, "GlobalSign Organization Validation CA - SHA256 - G2") == 0); + ASSERT_TRUE(strcmp(s, "GlobalSign Organization Validation CA - SHA256 - G2") == 0); ppb_var_release(var); // ======== TST_GET_FIELD(PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_NAME); s = ppb_var_var_to_utf8(var, NULL); - assert(strcmp(s, "GlobalSign nv-sa") == 0); + ASSERT_TRUE(strcmp(s, "GlobalSign nv-sa") == 0); ppb_var_release(var); // ======== TST_GET_FIELD(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COMMON_NAME); s = ppb_var_var_to_utf8(var, NULL); - assert(strcmp(s, "*.wikipedia.org") == 0); + ASSERT_TRUE(strcmp(s, "*.wikipedia.org") == 0); ppb_var_release(var); // ======== TST_GET_FIELD(PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_NAME); s = ppb_var_var_to_utf8(var, NULL); - assert(strcmp(s, "Wikimedia Foundation, Inc.") == 0); + ASSERT_TRUE(strcmp(s, "Wikimedia Foundation, Inc.") == 0); ppb_var_release(var); // ======== TST_GET_FIELD(PP_X509CERTIFICATE_PRIVATE_SUBJECT_LOCALITY_NAME); s = ppb_var_var_to_utf8(var, NULL); - assert(strcmp(s, "San Francisco") == 0); + ASSERT_TRUE(strcmp(s, "San Francisco") == 0); ppb_var_release(var); // ======== TST_GET_FIELD(PP_X509CERTIFICATE_PRIVATE_SUBJECT_STATE_OR_PROVINCE_NAME); s = ppb_var_var_to_utf8(var, NULL); - assert(strcmp(s, "California") == 0); + ASSERT_TRUE(strcmp(s, "California") == 0); ppb_var_release(var); // ======== TST_GET_FIELD(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COUNTRY_NAME); s = ppb_var_var_to_utf8(var, NULL); - assert(strcmp(s, "US") == 0); + ASSERT_TRUE(strcmp(s, "US") == 0); ppb_var_release(var); ppb_core_release_resource(x509); -} -int -main(void) -{ - PP_Instance instance = create_instance(); - test_ppb_x509_certificate(instance); - test_convert_asn1_time_to_pp_var(); destroy_instance(instance); - printf("pass\n"); - return 0; } diff -Nru freshplayerplugin-0.3.5/tests/test_thread_specifier.c freshplayerplugin-0.3.6/tests/test_thread_specifier.c --- freshplayerplugin-0.3.5/tests/test_thread_specifier.c 2016-04-12 21:02:49.000000000 +0000 +++ freshplayerplugin-0.3.6/tests/test_thread_specifier.c 2016-10-04 22:44:50.000000000 +0000 @@ -1,7 +1,6 @@ // testing that "__thread" specifier works -#undef NDEBUG -#include +#include "test.h" #include #include @@ -25,43 +24,29 @@ return NULL; } -int -main(void) +TEST(thread_specifier, test_1) { - int ret; - - ret = pthread_barrier_init(&b1, NULL, 2); - assert(ret == 0); - ret = pthread_barrier_init(&b2, NULL, 2); - assert(ret == 0); + ASSERT_EQ(0, pthread_barrier_init(&b1, NULL, 2)); + ASSERT_EQ(0, pthread_barrier_init(&b2, NULL, 2)); vaddr1 = &v; v = 1; // assign thread local variable a value - ret = pthread_create(&t, NULL, thread_func, NULL); - assert(ret == 0); + ASSERT_EQ(0, pthread_create(&t, NULL, thread_func, NULL)); // wait for thread to set "v" - ret = pthread_barrier_wait(&b1); - assert(ret == 0); + ASSERT_EQ(0, pthread_barrier_wait(&b1)); // ensure this "v" is not affected by other thread - assert(v == 1); + ASSERT_EQ(v, 1); // allow other thread to continue pthread_barrier_wait(&b2); pthread_join(t, NULL); - ret = pthread_barrier_destroy(&b1); - assert(ret == 0); - ret = pthread_barrier_destroy(&b2); - assert(ret == 0); + ASSERT_EQ(0, pthread_barrier_destroy(&b1)); + ASSERT_EQ(0, pthread_barrier_destroy(&b2)); printf("vaddr1 = %p\n", vaddr1); printf("vaddr2 = %p\n", vaddr2); - - printf("pass\n"); - return 0; } - - diff -Nru freshplayerplugin-0.3.5/tools/encodings/encodings.json freshplayerplugin-0.3.6/tools/encodings/encodings.json --- freshplayerplugin-0.3.5/tools/encodings/encodings.json 1970-01-01 00:00:00.000000000 +0000 +++ freshplayerplugin-0.3.6/tools/encodings/encodings.json 2016-10-04 22:44:50.000000000 +0000 @@ -0,0 +1,455 @@ +[ + { + "encodings": [ + { + "labels": [ + "unicode-1-1-utf-8", + "utf-8", + "utf8" + ], + "name": "UTF-8" + } + ], + "heading": "The Encoding" + }, + { + "encodings": [ + { + "labels": [ + "866", + "cp866", + "csibm866", + "ibm866" + ], + "name": "IBM866" + }, + { + "labels": [ + "csisolatin2", + "iso-8859-2", + "iso-ir-101", + "iso8859-2", + "iso88592", + "iso_8859-2", + "iso_8859-2:1987", + "l2", + "latin2" + ], + "name": "ISO-8859-2" + }, + { + "labels": [ + "csisolatin3", + "iso-8859-3", + "iso-ir-109", + "iso8859-3", + "iso88593", + "iso_8859-3", + "iso_8859-3:1988", + "l3", + "latin3" + ], + "name": "ISO-8859-3" + }, + { + "labels": [ + "csisolatin4", + "iso-8859-4", + "iso-ir-110", + "iso8859-4", + "iso88594", + "iso_8859-4", + "iso_8859-4:1988", + "l4", + "latin4" + ], + "name": "ISO-8859-4" + }, + { + "labels": [ + "csisolatincyrillic", + "cyrillic", + "iso-8859-5", + "iso-ir-144", + "iso8859-5", + "iso88595", + "iso_8859-5", + "iso_8859-5:1988" + ], + "name": "ISO-8859-5" + }, + { + "labels": [ + "arabic", + "asmo-708", + "csiso88596e", + "csiso88596i", + "csisolatinarabic", + "ecma-114", + "iso-8859-6", + "iso-8859-6-e", + "iso-8859-6-i", + "iso-ir-127", + "iso8859-6", + "iso88596", + "iso_8859-6", + "iso_8859-6:1987" + ], + "name": "ISO-8859-6" + }, + { + "labels": [ + "csisolatingreek", + "ecma-118", + "elot_928", + "greek", + "greek8", + "iso-8859-7", + "iso-ir-126", + "iso8859-7", + "iso88597", + "iso_8859-7", + "iso_8859-7:1987", + "sun_eu_greek" + ], + "name": "ISO-8859-7" + }, + { + "labels": [ + "csiso88598e", + "csisolatinhebrew", + "hebrew", + "iso-8859-8", + "iso-8859-8-e", + "iso-ir-138", + "iso8859-8", + "iso88598", + "iso_8859-8", + "iso_8859-8:1988", + "visual" + ], + "name": "ISO-8859-8" + }, + { + "labels": [ + "csiso88598i", + "iso-8859-8-i", + "logical" + ], + "name": "ISO-8859-8-I" + }, + { + "labels": [ + "csisolatin6", + "iso-8859-10", + "iso-ir-157", + "iso8859-10", + "iso885910", + "l6", + "latin6" + ], + "name": "ISO-8859-10" + }, + { + "labels": [ + "iso-8859-13", + "iso8859-13", + "iso885913" + ], + "name": "ISO-8859-13" + }, + { + "labels": [ + "iso-8859-14", + "iso8859-14", + "iso885914" + ], + "name": "ISO-8859-14" + }, + { + "labels": [ + "csisolatin9", + "iso-8859-15", + "iso8859-15", + "iso885915", + "iso_8859-15", + "l9" + ], + "name": "ISO-8859-15" + }, + { + "labels": [ + "iso-8859-16" + ], + "name": "ISO-8859-16" + }, + { + "labels": [ + "cskoi8r", + "koi", + "koi8", + "koi8-r", + "koi8_r" + ], + "name": "KOI8-R" + }, + { + "labels": [ + "koi8-ru", + "koi8-u" + ], + "name": "KOI8-U" + }, + { + "labels": [ + "csmacintosh", + "mac", + "macintosh", + "x-mac-roman" + ], + "name": "macintosh" + }, + { + "labels": [ + "dos-874", + "iso-8859-11", + "iso8859-11", + "iso885911", + "tis-620", + "windows-874" + ], + "name": "windows-874" + }, + { + "labels": [ + "cp1250", + "windows-1250", + "x-cp1250" + ], + "name": "windows-1250" + }, + { + "labels": [ + "cp1251", + "windows-1251", + "x-cp1251" + ], + "name": "windows-1251" + }, + { + "labels": [ + "ansi_x3.4-1968", + "ascii", + "cp1252", + "cp819", + "csisolatin1", + "ibm819", + "iso-8859-1", + "iso-ir-100", + "iso8859-1", + "iso88591", + "iso_8859-1", + "iso_8859-1:1987", + "l1", + "latin1", + "us-ascii", + "windows-1252", + "x-cp1252" + ], + "name": "windows-1252" + }, + { + "labels": [ + "cp1253", + "windows-1253", + "x-cp1253" + ], + "name": "windows-1253" + }, + { + "labels": [ + "cp1254", + "csisolatin5", + "iso-8859-9", + "iso-ir-148", + "iso8859-9", + "iso88599", + "iso_8859-9", + "iso_8859-9:1989", + "l5", + "latin5", + "windows-1254", + "x-cp1254" + ], + "name": "windows-1254" + }, + { + "labels": [ + "cp1255", + "windows-1255", + "x-cp1255" + ], + "name": "windows-1255" + }, + { + "labels": [ + "cp1256", + "windows-1256", + "x-cp1256" + ], + "name": "windows-1256" + }, + { + "labels": [ + "cp1257", + "windows-1257", + "x-cp1257" + ], + "name": "windows-1257" + }, + { + "labels": [ + "cp1258", + "windows-1258", + "x-cp1258" + ], + "name": "windows-1258" + }, + { + "labels": [ + "x-mac-cyrillic", + "x-mac-ukrainian" + ], + "name": "x-mac-cyrillic" + } + ], + "heading": "Legacy single-byte encodings" + }, + { + "encodings": [ + { + "labels": [ + "chinese", + "csgb2312", + "csiso58gb231280", + "gb2312", + "gb_2312", + "gb_2312-80", + "gbk", + "iso-ir-58", + "x-gbk" + ], + "name": "GBK" + }, + { + "labels": [ + "gb18030" + ], + "name": "gb18030" + } + ], + "heading": "Legacy multi-byte Chinese (simplified) encodings" + }, + { + "encodings": [ + { + "labels": [ + "big5", + "big5-hkscs", + "cn-big5", + "csbig5", + "x-x-big5" + ], + "name": "Big5" + } + ], + "heading": "Legacy multi-byte Chinese (traditional) encodings" + }, + { + "encodings": [ + { + "labels": [ + "cseucpkdfmtjapanese", + "euc-jp", + "x-euc-jp" + ], + "name": "EUC-JP" + }, + { + "labels": [ + "csiso2022jp", + "iso-2022-jp" + ], + "name": "ISO-2022-JP" + }, + { + "labels": [ + "csshiftjis", + "ms932", + "ms_kanji", + "shift-jis", + "shift_jis", + "sjis", + "windows-31j", + "x-sjis" + ], + "name": "Shift_JIS" + } + ], + "heading": "Legacy multi-byte Japanese encodings" + }, + { + "encodings": [ + { + "labels": [ + "cseuckr", + "csksc56011987", + "euc-kr", + "iso-ir-149", + "korean", + "ks_c_5601-1987", + "ks_c_5601-1989", + "ksc5601", + "ksc_5601", + "windows-949" + ], + "name": "EUC-KR" + } + ], + "heading": "Legacy multi-byte Korean encodings" + }, + { + "encodings": [ + { + "labels": [ + "csiso2022kr", + "hz-gb-2312", + "iso-2022-cn", + "iso-2022-cn-ext", + "iso-2022-kr" + ], + "name": "replacement" + }, + { + "labels": [ + "utf-16be" + ], + "name": "UTF-16BE" + }, + { + "labels": [ + "utf-16", + "utf-16le" + ], + "name": "UTF-16LE" + }, + { + "labels": [ + "x-user-defined" + ], + "name": "x-user-defined" + } + ], + "heading": "Legacy miscellaneous encodings" + } +] diff -Nru freshplayerplugin-0.3.5/tools/encodings/gen-encoding-aliases.py freshplayerplugin-0.3.6/tools/encodings/gen-encoding-aliases.py --- freshplayerplugin-0.3.5/tools/encodings/gen-encoding-aliases.py 1970-01-01 00:00:00.000000000 +0000 +++ freshplayerplugin-0.3.6/tools/encodings/gen-encoding-aliases.py 2016-10-04 22:44:50.000000000 +0000 @@ -0,0 +1,19 @@ +import json + +# https://raw.githubusercontent.com/whatwg/encoding/master/encodings.json +with open("encodings.json") as f: + s = json.loads(f.read()) + +print "// autogenerated by /tools/encodings/gen-encoding-aliases.py\n" + +for gr in s: + print "// {}".format((gr["heading"])) + + for dst in gr["encodings"]: + dst_enc = dst["name"] + + print '{{ "{}", "{}" }},'.format(dst_enc, dst_enc) + for src_enc in dst["labels"]: + print '{{ "{}", "{}" }},'.format(dst_enc, src_enc) + + print ""