[-]
[+]
|
Changed |
_service:tar_git:yamui.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:yamui.spec
^
|
|
[-]
[+]
|
Deleted |
_service:tar_git:yamui-1.1.2.tar.gz/main.c
^
|
@@ -1,260 +0,0 @@
-#define _DEFAULT_SOURCE
-
-#include <stdio.h>
-#include <getopt.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <signal.h>
-#include <sys/signalfd.h>
-#include <sys/select.h>
-
-#include "os-update.h"
-#include "minui/minui.h"
-
-#define IMAGES_MAX 30
-
-static struct option options[] = {
- {"animate", required_argument, 0, 'a'},
- {"imagesdir", required_argument, 0, 'i'},
- {"progressbar", required_argument, 0, 'p'},
- {"stopafter", required_argument, 0, 's'},
- {"text", required_argument, 0, 't'},
- {"help", no_argument, 0, 'h'},
- {0, 0, 0, 0},
-};
-
-/* ------------------------------------------------------------------------ */
-
-static int
-wait_signalfd(int sigfd, unsigned long long int msecs)
-{
- int ret;
- fd_set fdset;
- struct timespec ts = {
- .tv_sec = msecs / 1000,
- .tv_nsec = (msecs % 1000) * 1000000
- };
-
- FD_ZERO(&fdset);
- if (sigfd >= 0)
- FD_SET(sigfd, &fdset);
-
- ret = pselect(sigfd + 1, &fdset, NULL, NULL, msecs ? &ts : NULL, NULL);
- if (ret > 0)
- printf("Interrupted, bailing out\n");
- else if (ret == -1)
- printf("An error occured, bailing out\n");
- return ret;
-}
-
-/* ------------------------------------------------------------------------ */
-
-static void
-short_help(void)
-{
- printf(" os-update-minui [OPTIONS] [IMAGE(s)]\n");
-}
-
-/* ------------------------------------------------------------------------ */
-
-static void
-print_help(void)
-{
- printf(" yamui - tool to display progress bar, logo, or small animation on UI\n");
- printf(" Usage:\n");
- short_help();
- printf(" IMAGE(s) - png picture file names in DIR without .png extension\n");
- printf(" NOTE: currently maximum of %d pictures supported\n",
- IMAGES_MAX);
- printf("\n OPTIONS:\n");
- printf(" --animate=PERIOD, -a PERIOD\n");
- printf(" Show IMAGEs (at least 2) in rotation over PERIOD ms\n");
- printf(" --imagesdir=DIR, -i DIR\n");
- printf(" Load IMAGE(s) from DIR, /res/images by default\n");
- printf(" --progressbar=TIME, -p TIME\n");
- printf(" Show a progess bar over TIME milliseconds\n");
- printf(" --stopafter=TIME, -s TIME\n");
- printf(" Stop showing the IMAGE(s) after TIME milliseconds\n");
- printf(" --text=STRING, -t STRING\n");
- printf(" Show STRING on the screen\n");
- printf(" --help, -h\n");
- printf(" Print this help\n");
-}
-
-/* ------------------------------------------------------------------------ */
-
-/* Add text to both sides of the "flip" */
-static void
-add_text(char *text)
-{
- int i = 0;
- if (!text)
- return;
-
- for (i = 0; i < 2; i++) {
- gr_color(255, 255, 255, 255);
- gr_text(20,20, text, 1);
- gr_flip();
- }
-}
-
-/* ------------------------------------------------------------------------ */
-
-int
-main(int argc, char *argv[])
-{
- int c, option_index;
- unsigned long int animate_ms = 0;
- unsigned long long int stop_ms = 0;
- unsigned long long int progress_ms = 0;
- char * text = NULL;
- char * images[IMAGES_MAX];
- char * images_dir = "/res/images";
- int image_count = 0;
- int ret = 0;
- int i = 0;
- int sigfd = -1;
- sigset_t mask;
-
- setlinebuf(stdout);
-
- while (1) {
- c = getopt_long(argc, argv, "a:i:p:s:t:h", options,
- &option_index);
- if (c == -1)
- break;
-
- switch (c) {
- case 'a':
- printf("got animate %s ms\n", optarg);
- animate_ms = strtoul(optarg, (char **)NULL, 10);
- break;
- case 'i':
- printf("got imagesdir \"%s\"\n", optarg);
- images_dir = optarg;
- break;
- case 'p':
- printf("got progressbar %s ms\n", optarg);
- progress_ms = strtoull(optarg, (char **)NULL, 10);
- break;
- case 's':
- printf("got stop at %s ms\n", optarg);
- stop_ms = strtoull(optarg, (char **)NULL, 10);
- break;
- case 't':
- printf("got text \"%s\" to display\n", optarg);
- text = optarg;
- break;
- case 'h':
- print_help();
- goto out;
- break;
- default:
- printf("getopt returned character code 0%o\n", c);
- short_help();
- goto out;
- break;
- }
- }
-
- while (optind < argc && image_count < IMAGES_MAX)
- images[image_count++] = argv[optind++];
-
- if (osUpdateScreenInit())
- return -1;
-
- /* Allow SIGTERM and SIGINT to interrupt pselect() and move to cleanup */
- sigemptyset(&mask);
- sigaddset(&mask, SIGTERM);
- sigaddset(&mask, SIGINT);
- sigfd = signalfd(-1, &mask, 0);
- if (sigfd == -1) {
- printf("Could not create signal fd\n");
- goto cleanup;
- }
- if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1) {
- printf("Could not block signals\n");
- goto cleanup;
- }
-
- /* In case there is text to add, add it to both sides of the "flip" */
- add_text(text);
-
- if (image_count == 1 && !progress_ms) {
- ret = loadLogo(images[0], images_dir);
- if (ret) {
- printf("Image \"%s\" not found in /res/images/\n",
- images[0]);
- goto cleanup;
- }
-
- showLogo();
- wait_signalfd(sigfd, stop_ms);
-
- goto cleanup;
- }
-
- if (image_count <= 1 && progress_ms) {
- if (image_count == 1)
|
[-]
[+]
|
Changed |
_service:tar_git:yamui-1.2.2.tar.gz/Makefile
^
|
@@ -1,39 +1,68 @@
-PROGRAM = yamui
-MINUI_C_FILES := minui/graphics.c minui/graphics_fbdev.c minui/events.c minui/resources.c minui/graphics_drm.c
-C_FILES := main.c os-update.c $(MINUI_C_FILES)
-OBJS := $(patsubst %.c, %.o, $(C_FILES))
-CC = cc
-CFLAGS = -Wall -DOVERSCAN_PERCENT=0 -I/usr/include/ -O2 -W -std=c99 `pkg-config --cflags libdrm`
-LDFLAGS = -lpng -lc -lz -lm `pkg-config --libs libdrm`
-
-OBJS_COMMON := yamui-tools.o
-
-SCREENSAVERD = yamui-screensaverd
-CFLAGS_SCREENSAVERD = -W -Wall -ansi -pedantic -O2
-C_FILES_SCREENSAVERD := yamui-screensaverd.c $(MINUI_C_FILES)
-OBJS_SCREENSAVERD := $(patsubst %.c, %.o, $(C_FILES_SCREENSAVERD))
-
-POWERKEY = yamui-powerkey
-CFLAGS_POWERKEY = -W -Wall -ansi -pedantic -O2
-C_FILES_POWERKEY := yamui-powerkey.c
-OBJS_POWERKEY := $(patsubst %.c, %.o, $(C_FILES_POWERKEY))
-
-all: $(PROGRAM) $(SCREENSAVERD) $(POWERKEY)
-
-$(PROGRAM): $(OBJS)
- $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(PROGRAM)
-
-$(SCREENSAVERD): $(OBJS_SCREENSAVERD) $(OBJS_COMMON)
- $(CC) $(CFLAGS_SCREENSAVERD) $(OBJS_SCREENSAVERD) $(OBJS_COMMON) $(LDFLAGS) -o $(SCREENSAVERD)
-
-$(POWERKEY): $(OBJS_POWERKEY) $(OBJS_COMMON)
- $(CC) $(CFLAGS_POWERKEY) $(OBJS_POWERKEY) $(OBJS_COMMON) -o $(POWERKEY)
-
-install: all
- strip $(PROGRAM) $(SCREENSAVERD)
- install -m 755 -D $(PROGRAM) $(DESTDIR)/usr/bin/$(PROGRAM)
- install -m 755 -D $(SCREENSAVERD) $(DESTDIR)/usr/bin/$(SCREENSAVERD)
- install -m 755 -D $(POWERKEY) $(DESTDIR)/usr/bin/$(POWERKEY)
+PKG_NAMES += libdrm
+PKG_NAMES += libpng
+PKG_NAMES += glib-2.0
+PKG_NAMES += gio-2.0
+PKG_NAMES += libsystemd
-clean:
- rm -f *.o minui/*.o $(PROGRAM) $(SCREENSAVERD) $(POWERKEY)
+PKG_CONFIG := pkg-config
+PKG_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PKG_NAMES))
+PKG_LDLIBS := $(shell $(PKG_CONFIG) --libs $(PKG_NAMES))
+
+CPPFLAGS += -D_GNU_SOURCE
+CPPFLAGS += -DOVERSCAN_PERCENT=0
+
+CFLAGS += -std=c99
+CFLAGS += -O2
+CFLAGS += -Wall
+CFLAGS += -Wextra
+CFLAGS += $(PKG_CFLAGS)
+CFLAGS += -Wno-missing-field-initializers
+
+LDLIBS += -Wl,--as-needed
+LDLIBS += $(PKG_LDLIBS)
+
+TARGETS_BIN += yamui
+TARGETS_BIN += yamui-screensaverd
+TARGETS_BIN += yamui-powerkey
+
+DESTDIR ?= test-install-root # rpm-build overrides this
+
+all:: $(TARGETS_BIN)
+
+install:: all
+ install -m 755 -t $(DESTDIR)/usr/bin -D $(TARGETS_BIN)
+
+distclean:: clean
+
+clean:: mostlyclean
+ $(RM) $(TARGETS_BIN)
+ $(RM) *.o */*.o
+
+mostlyclean::
+ $(RM) *.bak *~ */*.bak */*~
+
+MINUI_SRC += minui/graphics.c
+MINUI_SRC += minui/graphics_fbdev.c
+MINUI_SRC += minui/events.c
+MINUI_SRC += minui/resources.c
+MINUI_SRC += minui/graphics_drm.c
+
+YAMUI_SRC += yamui.c
+YAMUI_SRC += os-update.c
+YAMUI_SRC += $(MINUI_SRC)
+YAMUI_OBJ := $(patsubst %.c, %.o, $(YAMUI_SRC))
+
+yamui: $(YAMUI_OBJ)
+
+SCREENSAVERD_SRC += yamui-screensaverd.c
+SCREENSAVERD_SRC += yamui-tools.c
+SCREENSAVERD_SRC += $(MINUI_SRC)
+SCREENSAVERD_OBJ := $(patsubst %.c, %.o, $(SCREENSAVERD_SRC))
+
+yamui-screensaverd: $(SCREENSAVERD_OBJ)
+
+POWERKEY_SRC += yamui-powerkey.c
+POWERKEY_SRC += yamui-tools.c
+POWERKEY_OBJ := $(patsubst %.c, %.o, $(POWERKEY_SRC))
+
+yamui-powerkey: $(POWERKEY_OBJ)
|
[-]
[+]
|
Changed |
_service:tar_git:yamui-1.2.2.tar.gz/minui/graphics.c
^
|
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2007 The Android Open Source Project
+ * Copyright (c) 2007 The Android Open Source Project
+ * Copyright (c) 2014 - 2023 Jolla Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
+#include <errno.h>
#include <sys/mman.h>
#include <sys/types.h>
@@ -92,7 +94,7 @@
for (i = 0; i < width; i++) {
unsigned char a = *sx++;
- if (gr_current_a < 255)
+ if (gr_current_a < 255) {
a = ((int)a * gr_current_a) / 255;
if (a == 255) {
*px++ = gr_current_r;
@@ -116,6 +118,7 @@
src_p += src_row_bytes;
dst_p += dst_row_bytes;
+ }
}
}
@@ -307,7 +310,11 @@
dx += overscan_offset_x;
dy += overscan_offset_y;
- if (outside(dx, dy) || outside(dx + w - 1, dy + h- 1))
+ if (dx < 0) sx -= dx, w += dx, dx = 0;
+ if (dy < 0) sy -= dy, h += dy, dy = 0;
+ if (dx + w > gr_draw->width) w = gr_draw->width - dx;
+ if (dy + h > gr_draw->height) h = gr_draw->height - dy;
+ if (w <= 0 || h <= 0)
return;
src_p = source->data + sy * source->row_bytes +
@@ -350,20 +357,32 @@
gr_init_font(void)
{
int res;
+ static const char font_path[] = "/res/images/font.png";
/* TODO: Check for error */
gr_font = calloc(sizeof(*gr_font), 1);
- if (!(res = res_create_alpha_surface("font", "/res/images", &(gr_font->texture)))) {
+ bool font_loaded = false;
+
+ if (access(font_path, F_OK) == -1 && errno == ENOENT) {
+ /* Not having a font file is normal, no need
+ * to complain. */
+ }
+ else if (!(res = res_create_alpha_surface(font_path, NULL, &gr_font->texture))) {
/* The font image should be a 96x2 array of character images.
* The columns are the printable ASCII characters 0x20 - 0x7f.
* The top row is regular text; the bottom row is bold. */
gr_font->cwidth = gr_font->texture->width / 96;
gr_font->cheight = gr_font->texture->height / 2;
- } else {
+ font_loaded = true;
+ }
+ else {
+ printf("%s: failed to read font: res=%d\n", font_path, res);
+ }
+
+ if (!font_loaded) {
unsigned char *bits, data, *in = font.rundata;
- printf("failed to read font: res=%d\n", res);
/* fall back to the compiled-in font. */
/* TODO: Check for error */
@@ -397,6 +416,50 @@
/* ------------------------------------------------------------------------ */
+static int gr_init_fbdev(bool blank)
+{
+ gr_backend = open_fbdev();
+ gr_draw = gr_backend->init(gr_backend, blank);
+ if (gr_draw)
+ gr_flip();
+ if (gr_draw)
+ gr_flip();
+ if (!gr_draw)
+ gr_backend->exit(gr_backend);
+ return gr_draw ? 0 : -1;
+}
+
+static int gr_init_drm(bool blank)
+{
+ gr_backend = open_drm();
+
+ /* At least in Xperia 10: the first display open succeeds
+ * without any trace of problems, but nothing is actually
+ * drawn on screen - make sure we get past that...
+ */
+ gr_backend->init(gr_backend, blank);
+ gr_backend->exit(gr_backend);
+
+ /* Assume that failures can happen due to there being
+ * another process that is trying to release display
+ * and allow some slack for that to finish.
+ */
+ for (int failures = 0;;) {
+ gr_draw = gr_backend->init(gr_backend, blank);
+ if (gr_draw)
+ gr_flip();
+ if (gr_draw)
+ gr_flip();
+ if (gr_draw)
+ break;
+ gr_backend->exit(gr_backend);
+ if (++failures >= 5)
+ break;
+ struct timespec ts = { 0, 100 * 1000 * 1000 };
+ nanosleep(&ts, NULL);
+ }
+ return gr_draw ? 0 : -1;
+}
int
gr_init(bool blank)
{
@@ -412,39 +475,13 @@
gr_exit();
return -1;
}
-/*
- gr_backend = open_adf();
- if (gr_backend) {
- gr_draw = gr_backend->init(gr_backend, blank);
- if (!gr_draw)
- gr_backend->exit(gr_backend);
- }
- if (!gr_draw) {
-*/
- gr_backend = open_fbdev();
- gr_draw = gr_backend->init(gr_backend, blank);
- if (!gr_draw) {
- gr_backend->exit(gr_backend);
-
- gr_backend = open_drm();
- gr_draw = gr_backend->init(gr_backend, blank);
- gr_backend->exit(gr_backend);
+ if (gr_init_fbdev(blank) != 0 && gr_init_drm(blank) != 0)
+ return -1;
- gr_backend = open_drm();
- gr_draw = gr_backend->init(gr_backend, blank);
- if (!gr_draw)
- return -1;
- }
-/*
- }
-*/
overscan_offset_x = gr_draw->width * overscan_percent / 100;
overscan_offset_y = gr_draw->height * overscan_percent / 100;
- gr_flip();
- gr_flip();
-
return 0;
}
@@ -453,11 +490,16 @@
void
gr_exit(void)
{
- gr_backend->exit(gr_backend);
+ if (gr_backend) {
+ gr_backend->exit(gr_backend);
+ gr_backend = NULL;
+ }
- ioctl(gr_vt_fd, KDSETMODE, (void *)KD_TEXT);
- close(gr_vt_fd);
- gr_vt_fd = -1;
+ if (gr_vt_fd != -1) {
+ ioctl(gr_vt_fd, KDSETMODE, (void *)KD_TEXT);
+ close(gr_vt_fd);
+ gr_vt_fd = -1;
+ }
}
/* ------------------------------------------------------------------------ */
|
[-]
[+]
|
Changed |
_service:tar_git:yamui-1.2.2.tar.gz/minui/graphics_drm.c
^
|
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (c) 2015 The Android Open Source Project
+ * Copyright (c) 2019 - 2023 Jolla Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -69,6 +70,8 @@
printf("drmModeSetCrtc failed ret=%d\n", ret);
}
static void drm_blank(minui_backend* backend __unused, bool blank) {
+ (void)backend;
+
if (blank)
drm_disable_crtc(drm_fd, main_monitor_crtc);
else
@@ -304,7 +307,10 @@
drmModeFreeCrtc(crtc);
}
}
-static GRSurface* drm_init(minui_backend* backend __unused) {
+static GRSurface* drm_init(minui_backend* backend __unused, bool blank) {
+ (void)backend;
+ (void)blank;
+
drmModeRes *res = NULL;
uint32_t selected_mode;
char *dev_name;
@@ -379,6 +385,8 @@
return &(drm_surfaces[0]->base);
}
static GRSurface* drm_flip(minui_backend* backend __unused) {
+ (void)backend;
+
int ret;
ret = drmModePageFlip(drm_fd, main_monitor_crtc->crtc_id,
drm_surfaces[current_buffer]->fb_id, 0, NULL);
@@ -390,6 +398,8 @@
return &(drm_surfaces[current_buffer]->base);
}
static void drm_exit(minui_backend* backend __unused) {
+ (void)backend;
+
drm_disable_crtc(drm_fd, main_monitor_crtc);
drm_destroy_surface(drm_surfaces[0]);
drm_destroy_surface(drm_surfaces[1]);
|
[-]
[+]
|
Changed |
_service:tar_git:yamui-1.2.2.tar.gz/minui/graphics_fbdev.c
^
|
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2014 The Android Open Source Project
+ * Copyright (c) 2014 The Android Open Source Project
+ * Copyright (c) 2014 - 2023 Jolla Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +21,7 @@
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
+#include <errno.h>
#include <linux/fb.h>
#include <linux/kd.h>
@@ -110,7 +112,8 @@
if (fd < 0) {
fd = open("/dev/fb0", O_RDWR);
if (fd < 0) {
- perror("cannot open fb0");
+ if (errno != ENOENT)
+ perror("cannot open fb0");
return NULL;
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:yamui-1.2.2.tar.gz/minui/resources.c
^
|
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2007 The Android Open Source Project
+ * Copyright (c) 2007 The Android Open Source Project
+ * Copyright (c) 2014 - 2023 Jolla Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -64,11 +65,15 @@
{
char resPath[256];
unsigned char header[8];
- int color_type, bit_depth, result = 0;
+ int color_type, bit_depth;
+ volatile int result = 0;
size_t bytesRead;
- snprintf(resPath, sizeof(resPath) - 1, "%s/%s.png", dir, name);
- resPath[sizeof(resPath)-1] = '\0';
+ if (dir)
+ snprintf(resPath, sizeof resPath, "%s/%s.png", dir, name);
+ else
+ snprintf(resPath, sizeof resPath, "%s", name);
+
*fp = fopen(resPath, "rb");
if (*fp == NULL) {
result = -1;
|
[-]
[+]
|
Changed |
_service:tar_git:yamui-1.2.2.tar.gz/os-update.c
^
|
@@ -1,3 +1,19 @@
+/*
+ * Copyright (c) 2014 - 2023 Jolla Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include <stdio.h>
#include <assert.h>
#include <stdbool.h>
@@ -14,29 +30,11 @@
/* ------------------------------------------------------------------------ */
int
-osUpdateScreenInit(void)
-{
- if (gr_init(true)) {
- printf("Failed gr_init!\n");
- return -1;
- }
-
- /* Clear the screen */
- gr_color(0, 0, 0, 255);
- gr_clear();
-
- return 0;
-}
-
-/* ------------------------------------------------------------------------ */
-
-int
loadLogo(const char *filename, const char *dir)
{
int ret;
- if (logo)
- res_free_surface(logo);
+ freeLogo();
if ((ret = res_create_display_surface(filename, dir, &logo)) < 0) {
printf("Error while trying to load %s, retval: %i.\n",
@@ -63,7 +61,6 @@
int dy = (fbh - logoh) / 2;
gr_blit(logo, 0, 0, logow, logoh, dx, dy);
- gr_flip();
} else {
printf("No logo loaded\n");
return -1;
@@ -122,18 +119,14 @@
gr_blit(logo, 0, 0, logow, logoh, dx, dy);
}
-
- /* And finally draw everything */
- gr_flip();
}
/* ------------------------------------------------------------------------ */
void
-osUpdateScreenExit(void)
+freeLogo(void)
{
if (logo)
- res_free_surface(logo);
+ res_free_surface(logo), logo = 0;
- gr_exit();
}
|
[-]
[+]
|
Changed |
_service:tar_git:yamui-1.2.2.tar.gz/os-update.h
^
|
@@ -1,13 +1,6 @@
#ifndef _OS_UPDATE_H_
#define _OS_UPDATE_H_
-/* Initializes the minui
- *
- * @return 0 when successfull
- * @return -1 when init fails, in this case anything below shouldn't be used.
- */
-int osUpdateScreenInit(void);
-
/*
* Loads logo and overrides the old logo if already loaded.
* @param filename of the file located in dir without extension or
@@ -33,6 +26,6 @@
void osUpdateScreenShowProgress(int percentage);
/* Should be called before ending application, to free memory etc. */
-void osUpdateScreenExit(void);
+void freeLogo(void);
#endif /* _OS_UPDATE_H_ */
|
[-]
[+]
|
Changed |
_service:tar_git:yamui-1.2.2.tar.gz/yamui-powerkey.c
^
|
@@ -6,8 +6,7 @@
* 1 - signal was received,
* 2 - error.
*
- * Copyright (C) 2015 Jolla Ltd.
- * Contact: Igor Zhbanov <igor.zhbanov@jolla.com>
+ * Copyright (c) 2015 - 2023 Jolla Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,9 +21,6 @@
* limitations under the License.
*/
-#define _DEFAULT_SOURCE
-#define _GNU_SOURCE
-
#include <errno.h>
#include <stdio.h>
#include <signal.h>
|
[-]
[+]
|
Changed |
_service:tar_git:yamui-1.2.2.tar.gz/yamui-tools.c
^
|
@@ -1,6 +1,5 @@
/*
- * Copyright (C) 2015 Jolla Ltd.
- * Contact: Igor Zhbanov <igor.zhbanov@jolla.com>
+ * Copyright (c) 2015 - 2023 Jolla Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -96,8 +95,9 @@
if (strncmp(d->d_name, EVENT_PREFIX, strlen(EVENT_PREFIX)))
continue; /* Not /dev/input/event* file */
- snprintf(name, sizeof(name), "%s/%s", DEV_INPUT_DIR,
- d->d_name);
+ if (snprintf(name, sizeof name, "%s/%s", DEV_INPUT_DIR,
+ d->d_name) >= (int)sizeof name)
+ continue;
debugf("Processing input ivents file %s", name);
if ((fds[*num] = open(name, O_RDONLY)) == -1) {
errorf("Can't open input device %s", name);
|
[-]
[+]
|
Added |
_service:tar_git:yamui-1.2.2.tar.gz/yamui.c
^
|
@@ -0,0 +1,1559 @@
+/*
+ * Copyright (c) 2014 - 2023 Jolla Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _DEFAULT_SOURCE
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <poll.h>
+#include <signal.h>
+
+#include <sys/signalfd.h>
+#include <sys/select.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <systemd/sd-daemon.h>
+
+#include "os-update.h"
+#include "minui/minui.h"
+
+#define IMAGES_MAX 30
+
+/* ========================================================================= *
+ * Logging
+ * ========================================================================= */
+
+#define VERBOSE 0
+#define PFIX "yamui: "
+
+#define log_emit(TAG, FMT, ARGS...) do {\
+ fprintf(stderr, PFIX TAG "%s(): " FMT "\n", __func__, ## ARGS);\
+ fflush(stderr);\
+} while (0)
+
+#define log_err( FMT, ARGS...) log_emit("E: ", FMT, ## ARGS)
+
+#if VERBOSE
+# define log_debug(FMT, ARGS...) log_emit("D: ", FMT, ## ARGS)
+#else
+# define log_debug(FMT, ARGS...) do {} while (0)
+#endif
+
+/* ========================================================================= *
+ * Prototypes
+ * ========================================================================= */
+
+/* ------------------------------------------------------------------------- *
+ * DISPLAY
+ * ------------------------------------------------------------------------- */
+
+static void display_acquire (void);
+static void display_release (void);
+static bool display_is_acquired (void);
+static void display_set_updates_enabled(bool enabled);
+static void display_set_blanked (bool blanked);
+static bool display_can_be_drawn (void);
+
+/* ------------------------------------------------------------------------- *
+ * SYSTEMBUS
+ * ------------------------------------------------------------------------- */
+
+static bool systembus_is_available (void);
+static void systembus_probe_socket (void);
+static void systembus_socket_monitor_event_cb(GFileMonitor *mon, GFile *file, GFile *other_file, GFileMonitorEvent event_type, gpointer user_data);
+static void systembus_quit_socket_monitor (void);
+static bool systembus_init_socket_monitor (void);
+
+/* ------------------------------------------------------------------------- *
+ * MAINLOOP
+ * ------------------------------------------------------------------------- */
+
+static void mainloop_run (void);
+static void mainloop_stop(void);
+
+/* ------------------------------------------------------------------------- *
+ * SIGNALS
+ * ------------------------------------------------------------------------- */
+
+static gboolean signals_iowatch_cb(GIOChannel *chn, GIOCondition cnd, gpointer aptr);
+static bool signals_init (void);
+static void signals_quit (void);
+
+/* ------------------------------------------------------------------------- *
+ * UNIX_SERVER
+ * ------------------------------------------------------------------------- */
+
+static bool unix_server_handle_client(void);
+static gboolean unix_server_iowatch_cb (GIOChannel *chn, GIOCondition cnd, gpointer aptr);
+static bool unix_server_addr (struct sockaddr_un *sa, socklen_t *sa_len);
+static bool unix_server_init (void);
+static void unix_server_quit (void);
+
+/* ------------------------------------------------------------------------- *
+ * UNIX_CLIENT
+ * ------------------------------------------------------------------------- */
+
+static bool unix_client_terminate_server(void);
+
+/* ------------------------------------------------------------------------- *
+ * COMPOSITOR
+ * ------------------------------------------------------------------------- */
+
+static void compositor_method_call_cb (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *method_name, GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data);
+static GVariant *compositor_get_property_cb (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *property_name, GError **error, gpointer user_data);
+static gboolean compositor_set_property_cb (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *property_name, GVariant *value, GError **error, gpointer user_data);
+static void compositor_connected_cb (GDBusConnection *connection, const gchar *name, gpointer user_data);
+static void compositor_name_acquired_cb(GDBusConnection *connection, const gchar *name, gpointer user_data);
+static void compositor_name_lost_cb (GDBusConnection *connection, const gchar *name, gpointer user_data);
+static gboolean compositor_connect_cb (gpointer aptr);
+static void compositor_schedule_connect(void);
+static void compositor_cancel_connect (void);
+static void compositor_disconnect (void);
+static bool compositor_init (void);
+static void compositor_quit (void);
+
+/* ------------------------------------------------------------------------- *
+ * APP
+ * ------------------------------------------------------------------------- */
+
+static void app_notify_systemd (void);
+static void app_on_enable_from_dbus (void);
+static void app_add_image (const char *filename);
+static void app_flush_images (void);
+static void app_draw_ui (void);
+static void app_draw_text (void);
+static void app_draw_single_image_cb (void);
+static void app_start_single_image (void);
+static void app_draw_progress_bar_cb (void);
+static gboolean app_update_progress_bar_cb (gpointer aptr);
+static void app_start_progress_bar (void);
+static void app_draw_animate_images_cb (void);
+static gboolean app_update_animate_images_cb(gpointer aptr);
+static void app_start_animate_images (void);
+static gboolean app_start_cb (gpointer aptr);
+static gboolean app_stop_cb (gpointer aptr);
+static void app_print_short_help (void);
+static void app_print_long_help (void);
+
+/* ------------------------------------------------------------------------- *
+ * MAIN
+ * ------------------------------------------------------------------------- */
+
+int main(int argc, char *argv[]);
+
+/* ========================================================================= *
+ * DISPLAY
+ * ========================================================================= */
+
+static bool display_acquired = false;
+static bool display_released = false;
+static bool display_enabled = false;
+static bool display_blanked = false;
+
+/** Acquire display
+ *
+ * Note: Tries for real only once, and only if display_release()
+ * has not been called yet.
+ */
+static void
+display_acquire(void)
+{
+ if (!display_acquired && !display_released) {
+ display_acquired = true;
+ if (gr_init(true) == -1) {
+ log_err("gr_init() failed");
+ display_release();
+ mainloop_stop();
+ }
+ else {
+ gr_color(0, 0, 0, 255);
+ gr_clear();
+ }
+ }
+}
+
+/** Release display
+ *
+ * Note: Blocks future display_acquire() calls
|