summaryrefslogtreecommitdiff
path: root/src/portal
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2024-12-24 14:52:51 -0500
committerAndrew Opalach <andrew@akon.city> 2024-12-24 14:52:51 -0500
commit5206f05fdf77bb65c125ddb133cf46a59608c671 (patch)
tree69707685b0245f1db508a6bce98d8ab5399a932c /src/portal
parent3d55d2722a3129449ab1418e73abd97caa7fd2ae (diff)
downloadcamu-5206f05fdf77bb65c125ddb133cf46a59608c671.tar.gz
camu-5206f05fdf77bb65c125ddb133cf46a59608c671.tar.bz2
camu-5206f05fdf77bb65c125ddb133cf46a59608c671.zip
Bring in line with dependency changes
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/portal')
-rw-r--r--src/portal/meson.build2
-rw-r--r--src/portal/py/modules/__init__.py8
-rw-r--r--src/portal/py/modules/youtube.py5
-rw-r--r--src/portal/py/tests/archive_query.py26
-rw-r--r--src/portal/requirements.txt1
-rwxr-xr-xsrc/portal/scripts/create_vendor.sh14
-rwxr-xr-xsrc/portal/scripts/run_py.sh1
-rw-r--r--src/portal/src/packet_ext.c140
-rw-r--r--src/portal/src/packet_ext.h7
-rw-r--r--src/portal/src/search.c75
-rw-r--r--src/portal/src/search.h14
11 files changed, 160 insertions, 133 deletions
diff --git a/src/portal/meson.build b/src/portal/meson.build
index d3904ea..e87b588 100644
--- a/src/portal/meson.build
+++ b/src/portal/meson.build
@@ -10,7 +10,7 @@ portal_args = ['-DCAMU_HAVE_PORTAL']
cpy_dir = join_paths(meson.current_source_dir(), 'cpy')
run_command('sh', join_paths(cpy_dir, 'build.sh'), cpy_dir, check: false)
-python3_embed = import('python').find_installation('python3.12').dependency(embed: true)
+python3_embed = import('python').find_installation('python3').dependency(embed: true)
portal_deps += [python3_embed]
portal = declare_dependency(sources: portal_src, dependencies: portal_deps, compile_args: portal_args)
diff --git a/src/portal/py/modules/__init__.py b/src/portal/py/modules/__init__.py
index c44e571..cc34b82 100644
--- a/src/portal/py/modules/__init__.py
+++ b/src/portal/py/modules/__init__.py
@@ -14,11 +14,11 @@ ALL_MODULES = {
# config.TWITTER_ACCESS_TOKEN, config.TWITTER_ACCESS_TOKEN_SECRET,
# config.TWITTER_CONSUMER_TOKEN, config.TWITTER_CONSUMER_TOKEN_SECRET), []),
# 'twitter': (TwitterScrapeModule(config.TWITTER_COOKIES_PATH), []),
- 'pixiv_web': (PixivWebModule(config.PIXIV_SESSID, config.PIXIV_USERID), []),
+# 'pixiv_web': (PixivWebModule(config.PIXIV_SESSID, config.PIXIV_USERID), []),
# 'pixiv_app': (PixivAppModule(config.PIXIV_REFRESH_TOKEN), []),
'fanbox': (FanboxModule(config.FANBOX_SESSID, config.FANBOX_CF_CLEARANCE), []),
- 'instagram': (InstagramModule(
- config.INSTAGRAM_USER_AGENT, config.INSTAGRAM_SETTINGS_PATH,
- config.INSTAGRAM_SESSION_ID), []),
+# 'instagram': (InstagramModule(
+# config.INSTAGRAM_USER_AGENT, config.INSTAGRAM_SETTINGS_PATH,
+# config.INSTAGRAM_SESSION_ID), []),
# 'patreon': (PatreonModule(config.PATREON_SESSION_ID, config.PATREON_UUID, config.PATREON_USER_ID), [])
}
diff --git a/src/portal/py/modules/youtube.py b/src/portal/py/modules/youtube.py
index 5125f85..582a16c 100644
--- a/src/portal/py/modules/youtube.py
+++ b/src/portal/py/modules/youtube.py
@@ -26,7 +26,8 @@ ydl_opts = {
'quiet': False,
'logger': YDLLogger(),
'cachedir': False,
- 'socket_timeout': 10
+ 'socket_timeout': 10,
+ 'extractor_args': {'youtube': {'skip': ['hls'], 'player_client': ['android_vr']}}
# 'cookiefile': ''
}
@@ -94,7 +95,7 @@ class YoutubeBase(Search):
if info.get('direct'):
url = info['url']
else:
- url = get_playback_url(info, video=True)
+ url = get_playback_url(info, video=False)
if not url:
return False
unique_id = f'youtube:v:{info['id']}'
diff --git a/src/portal/py/tests/archive_query.py b/src/portal/py/tests/archive_query.py
index cff5e5d..1ed9db4 100644
--- a/src/portal/py/tests/archive_query.py
+++ b/src/portal/py/tests/archive_query.py
@@ -9,10 +9,12 @@ sys.path.append('../')
from base import Method
from post import PostEncoder, PostType, DateType, User
from modules import ALL_MODULES
-from logger import Logger
+from tests.logger import Logger
+#mode = 'pixiv_web'
mode = 'fanbox'
cmd = 'user'
+#cmd = 'bookmarks'
module = ALL_MODULES[mode][0]
if not module.init():
sys.exit(1)
@@ -170,8 +172,8 @@ class QueryDownloadThread(threading.Thread):
#RUNTIME_PATH = "./run"
RUNTIME_PATH = "/mnt/store/files/tmp/run"
-LOG_FILE = f'{RUNTIME_PATH}/archive3.log'
-ARG_FILE = f'{RUNTIME_PATH}/completed_args3.log'
+LOG_FILE = f'{RUNTIME_PATH}/archive4.log'
+ARG_FILE = f'{RUNTIME_PATH}/completed_args4.log'
def read_completed_args(path):
args = []
@@ -204,7 +206,23 @@ def download_args():
os.mkdir(output_dir)
#args = module.search(f'following:{22781328}')
- args = ['anoh223']
+ #args = ['22781328']
+ #args = ['anoh223']
+ #args = ['532891', '1324074',]
+ #args = ['6600030', '163436']
+ #args = ['85117546', '29506', '3298353', '21674944', '2034628', '3085731']
+ #args = ['6827013', '11742', '4671', '36323560', '5128785', '30970895']
+ #args = ['mugi49']
+ #args = ['71598064', '9204502', '689283', '19956185', '42987864', '103682732', '4675776', '7780', '160755', '250142', '3444594', '1995476', '357647']
+ #args = ['10473280']
+ #args = ['178217', '106414', '882896', '3040749']
+ #args = ['21245269']
+ #args = ['1969907', '292644', '746841']
+ #args = ['1319954', '43718238', '2721319', '53459337']
+ # TODO:
+ args = ['yzr']
+ #args = ['11187954']
+ # twitter test: butcha_u, sep__rina
threads = []
start = True
diff --git a/src/portal/requirements.txt b/src/portal/requirements.txt
index f4982dc..c2e2915 100644
--- a/src/portal/requirements.txt
+++ b/src/portal/requirements.txt
@@ -1,4 +1,3 @@
httpx[http2,brotli,zstd]
blake3
pillow
-notcurses
diff --git a/src/portal/scripts/create_vendor.sh b/src/portal/scripts/create_vendor.sh
index 414a4c2..833d143 100755
--- a/src/portal/scripts/create_vendor.sh
+++ b/src/portal/scripts/create_vendor.sh
@@ -24,13 +24,13 @@ cd instagrapi/
pip3 install . --upgrade --target=../vendor
cd ../
-cd CyberDropDownloader/
-pip3 install . --upgrade --target=../vendor
-cd ../
-
-cd gallery-dl/
-pip3 install . --upgrade --target=../vendor
-cd ../
+#cd CyberDropDownloader/
+#pip3 install . --upgrade --target=../vendor
+#cd ../
+#
+#cd gallery-dl/
+#pip3 install . --upgrade --target=../vendor
+#cd ../
cd ../
rm -r venv
diff --git a/src/portal/scripts/run_py.sh b/src/portal/scripts/run_py.sh
index 4414f93..e745a72 100755
--- a/src/portal/scripts/run_py.sh
+++ b/src/portal/scripts/run_py.sh
@@ -1,5 +1,6 @@
#! /usr/bin/env sh
export CURL_CA_BUNDLE=/etc/ssl/certs/ca-bundle.crt
export PYTHONDONTWRITEBYTECODE=1
+export PYTHONOPTIMIZE=2
export PYTHONPATH=$HOME/c/camu/src/portal/vendor/vendor
$@
diff --git a/src/portal/src/packet_ext.c b/src/portal/src/packet_ext.c
index 833e7d9..9b6d6be 100644
--- a/src/portal/src/packet_ext.c
+++ b/src/portal/src/packet_ext.c
@@ -1,102 +1,102 @@
#include "packet_ext.h"
-static void aki_packet_write_optional_int(struct aki_packet *packet, optional_int *o)
+static void nn_packet_write_optional_int(struct nn_packet *packet, optional_int *o)
{
- AKI_PACKET_WRITE_TYPE(packet, s64, o->i);
- AKI_PACKET_WRITE_TYPE(packet, bool, o->set);
+ NNWT_PACKET_WRITE_TYPE(packet, s64, o->i);
+ NNWT_PACKET_WRITE_TYPE(packet, bool, o->set);
}
-void aki_packet_write_post(struct aki_packet *packet, struct camu_post *post)
+void nn_packet_write_post(struct nn_packet *packet, struct camu_post *post)
{
- AKI_PACKET_WRITE_TYPE(packet, u16, post->version);
- AKI_PACKET_WRITE_TYPE(packet, u8, post->type);
- aki_packet_write_str(packet, &post->unique_id);
- aki_packet_write_str(packet, &post->url);
- AKI_PACKET_WRITE_TYPE(packet, u32, post->dates.size);
+ NNWT_PACKET_WRITE_TYPE(packet, u16, post->version);
+ NNWT_PACKET_WRITE_TYPE(packet, u8, post->type);
+ nn_packet_write_str(packet, &post->unique_id);
+ nn_packet_write_str(packet, &post->url);
+ NNWT_PACKET_WRITE_TYPE(packet, u32, post->dates.size);
struct camu_post_date *date;
al_array_foreach_ptr(post->dates, i, date) {
- AKI_PACKET_WRITE_TYPE(packet, u8, date->type);
- AKI_PACKET_WRITE_TYPE(packet, f32, date->range_start);
- AKI_PACKET_WRITE_TYPE(packet, f32, date->range_end);
- AKI_PACKET_WRITE_TYPE(packet, u32, date->meta);
+ NNWT_PACKET_WRITE_TYPE(packet, u8, date->type);
+ NNWT_PACKET_WRITE_TYPE(packet, f32, date->range_start);
+ NNWT_PACKET_WRITE_TYPE(packet, f32, date->range_end);
+ NNWT_PACKET_WRITE_TYPE(packet, u32, date->meta);
}
- aki_packet_write_str(packet, &post->author.unique_id);
- aki_packet_write_wstr(packet, &post->author.username);
- aki_packet_write_wstr(packet, &post->author.display_name);
- aki_packet_write_str(packet, &post->author.profile_picture_url);
- aki_packet_write_wstr(packet, &post->title);
- aki_packet_write_wstr(packet, &post->text);
- aki_packet_write_optional_int(packet, &post->likes);
- aki_packet_write_optional_int(packet, &post->bookmarks);
- aki_packet_write_optional_int(packet, &post->reposts);
- aki_packet_write_optional_int(packet, &post->quotes);
- aki_packet_write_optional_int(packet, &post->comments);
- aki_packet_write_optional_int(packet, &post->views);
- AKI_PACKET_WRITE_TYPE(packet, u32, post->media.size);
+ nn_packet_write_str(packet, &post->author.unique_id);
+ nn_packet_write_wstr(packet, &post->author.username);
+ nn_packet_write_wstr(packet, &post->author.display_name);
+ nn_packet_write_str(packet, &post->author.profile_picture_url);
+ nn_packet_write_wstr(packet, &post->title);
+ nn_packet_write_wstr(packet, &post->text);
+ nn_packet_write_optional_int(packet, &post->likes);
+ nn_packet_write_optional_int(packet, &post->bookmarks);
+ nn_packet_write_optional_int(packet, &post->reposts);
+ nn_packet_write_optional_int(packet, &post->quotes);
+ nn_packet_write_optional_int(packet, &post->comments);
+ nn_packet_write_optional_int(packet, &post->views);
+ NNWT_PACKET_WRITE_TYPE(packet, u32, post->media.size);
struct camu_post_media *media;
al_array_foreach_ptr(post->media, i, media) {
- AKI_PACKET_WRITE_TYPE(packet, u8, media->type);
- aki_packet_write_str(packet, &media->key);
- aki_packet_write_str(packet, &media->url);
- aki_packet_write_str(packet, &media->ext);
- aki_packet_write_str(packet, &media->thumbnail_url);
- aki_packet_write_str(packet, &media->thumbnail_ext);
+ NNWT_PACKET_WRITE_TYPE(packet, u8, media->type);
+ nn_packet_write_str(packet, &media->key);
+ nn_packet_write_str(packet, &media->url);
+ nn_packet_write_str(packet, &media->ext);
+ nn_packet_write_str(packet, &media->thumbnail_url);
+ nn_packet_write_str(packet, &media->thumbnail_ext);
}
- aki_packet_write_str(packet, &post->post.unique_id);
- aki_packet_write_str(packet, &post->quoted.unique_id);
- aki_packet_write_str(packet, &post->in_reply_to.unique_id);
+ nn_packet_write_str(packet, &post->post.unique_id);
+ nn_packet_write_str(packet, &post->quoted.unique_id);
+ nn_packet_write_str(packet, &post->in_reply_to.unique_id);
}
-static void aki_packet_read_optional_int(struct aki_packet *packet, optional_int *o)
+static void nn_packet_read_optional_int(struct nn_packet *packet, optional_int *o)
{
- AKI_PACKET_READ_TYPE(packet, s64, o->i);
- AKI_PACKET_READ_TYPE(packet, bool, o->set);
+ NNWT_PACKET_READ_TYPE(packet, s64, o->i);
+ NNWT_PACKET_READ_TYPE(packet, bool, o->set);
}
-void aki_packet_read_post(struct aki_packet *packet, struct camu_post *post)
+void nn_packet_read_post(struct nn_packet *packet, struct camu_post *post)
{
camu_post_reset(post);
- AKI_PACKET_READ_TYPE(packet, u16, post->version);
- AKI_PACKET_READ_TYPE(packet, u8, post->type);
- aki_packet_read_str(packet, &post->unique_id);
- aki_packet_read_str(packet, &post->url);
+ NNWT_PACKET_READ_TYPE(packet, u16, post->version);
+ NNWT_PACKET_READ_TYPE(packet, u8, post->type);
+ nn_packet_read_str(packet, &post->unique_id);
+ nn_packet_read_str(packet, &post->url);
u32 dates_size;
- AKI_PACKET_READ_TYPE(packet, u32, dates_size);
+ NNWT_PACKET_READ_TYPE(packet, u32, dates_size);
al_array_reserve(post->dates, dates_size);
for (u32 i = 0; i < dates_size; i++) {
struct camu_post_date date;
- AKI_PACKET_READ_TYPE(packet, u8, date.type);
- AKI_PACKET_READ_TYPE(packet, f32, date.range_start);
- AKI_PACKET_READ_TYPE(packet, f32, date.range_end);
- AKI_PACKET_READ_TYPE(packet, u32, date.meta);
+ NNWT_PACKET_READ_TYPE(packet, u8, date.type);
+ NNWT_PACKET_READ_TYPE(packet, f32, date.range_start);
+ NNWT_PACKET_READ_TYPE(packet, f32, date.range_end);
+ NNWT_PACKET_READ_TYPE(packet, u32, date.meta);
al_array_push(post->dates, date);
}
- aki_packet_read_str(packet, &post->author.unique_id);
- aki_packet_read_wstr(packet, &post->author.username);
- aki_packet_read_wstr(packet, &post->author.display_name);
- aki_packet_read_str(packet, &post->author.profile_picture_url);
- aki_packet_read_wstr(packet, &post->title);
- aki_packet_read_wstr(packet, &post->text);
- aki_packet_read_optional_int(packet, &post->likes);
- aki_packet_read_optional_int(packet, &post->bookmarks);
- aki_packet_read_optional_int(packet, &post->reposts);
- aki_packet_read_optional_int(packet, &post->quotes);
- aki_packet_read_optional_int(packet, &post->comments);
- aki_packet_read_optional_int(packet, &post->views);
+ nn_packet_read_str(packet, &post->author.unique_id);
+ nn_packet_read_wstr(packet, &post->author.username);
+ nn_packet_read_wstr(packet, &post->author.display_name);
+ nn_packet_read_str(packet, &post->author.profile_picture_url);
+ nn_packet_read_wstr(packet, &post->title);
+ nn_packet_read_wstr(packet, &post->text);
+ nn_packet_read_optional_int(packet, &post->likes);
+ nn_packet_read_optional_int(packet, &post->bookmarks);
+ nn_packet_read_optional_int(packet, &post->reposts);
+ nn_packet_read_optional_int(packet, &post->quotes);
+ nn_packet_read_optional_int(packet, &post->comments);
+ nn_packet_read_optional_int(packet, &post->views);
u32 media_size;
- AKI_PACKET_READ_TYPE(packet, u32, media_size);
+ NNWT_PACKET_READ_TYPE(packet, u32, media_size);
al_array_reserve(post->media, media_size);
for (u32 i = 0; i < media_size; i++) {
struct camu_post_media media;
- AKI_PACKET_READ_TYPE(packet, u8, media.type);
- aki_packet_read_str(packet, &media.key);
- aki_packet_read_str(packet, &media.url);
- aki_packet_read_str(packet, &media.ext);
- aki_packet_read_str(packet, &media.thumbnail_url);
- aki_packet_read_str(packet, &media.thumbnail_ext);
+ NNWT_PACKET_READ_TYPE(packet, u8, media.type);
+ nn_packet_read_str(packet, &media.key);
+ nn_packet_read_str(packet, &media.url);
+ nn_packet_read_str(packet, &media.ext);
+ nn_packet_read_str(packet, &media.thumbnail_url);
+ nn_packet_read_str(packet, &media.thumbnail_ext);
al_array_push(post->media, media);
}
- aki_packet_read_str(packet, &post->post.unique_id);
- aki_packet_read_str(packet, &post->quoted.unique_id);
- aki_packet_read_str(packet, &post->in_reply_to.unique_id);
+ nn_packet_read_str(packet, &post->post.unique_id);
+ nn_packet_read_str(packet, &post->quoted.unique_id);
+ nn_packet_read_str(packet, &post->in_reply_to.unique_id);
}
diff --git a/src/portal/src/packet_ext.h b/src/portal/src/packet_ext.h
index eae1e07..6da61fc 100644
--- a/src/portal/src/packet_ext.h
+++ b/src/portal/src/packet_ext.h
@@ -1,10 +1,9 @@
#pragma once
#include <al/types.h>
-#include <aki/common.h>
-#include <aki/event_loop.h>
+#include <nnwt/packet.h>
#include "post.h"
-void aki_packet_write_post(struct aki_packet *packet, struct camu_post *post);
-void aki_packet_read_post(struct aki_packet *packet, struct camu_post *post);
+void nn_packet_write_post(struct nn_packet *packet, struct camu_post *post);
+void nn_packet_read_post(struct nn_packet *packet, struct camu_post *post);
diff --git a/src/portal/src/search.c b/src/portal/src/search.c
index e8f30c0..88cf1f1 100644
--- a/src/portal/src/search.c
+++ b/src/portal/src/search.c
@@ -8,26 +8,35 @@
bool camu_python_init(void)
{
- PyPreConfig config;
- PyPreConfig_InitPythonConfig(&config);
- config.dev_mode = 0;
- config.utf8_mode = 1;
- PyStatus status = Py_PreInitialize(&config);
+ PyPreConfig pre_config;
+ PyPreConfig_InitPythonConfig(&pre_config);
+
+ pre_config.dev_mode = 0;
+ pre_config.utf8_mode = 1;
+ pre_config.isolated = 0;
+ pre_config.parse_argv = 0;
+ pre_config.use_environment = 1;
+
+ PyStatus status = Py_PreInitialize(&pre_config);
if (PyStatus_Exception(status)) {
al_log_error("portal", "Preinitialization failed.");
return false;
}
+
if (PyImport_AppendInittab("portal", PyInit_portal) == -1) {
al_log_error("portal", "Could not extend in-built modules table.");
return false;
}
+
Py_Initialize();
+
PyObject *module = PyImport_ImportModule("portal");
if (!module) {
PyErr_Print();
al_log_error("portal", "Could not import module.");
goto err;
}
+
return true;
err:
Py_Finalize();
@@ -48,14 +57,14 @@ static struct camu_search *get_search_by_id(struct camu_portal_bridge *bridge, s
return NULL;
}
-static aki_thread_result AKI_THREADCALL queue_thread(void *userdata)
+static nn_thread_result NNWT_THREADCALL queue_thread(void *userdata)
{
struct camu_portal_bridge *bridge = (struct camu_portal_bridge *)userdata;
- aki_thread_setcanceltype(AKI_THREAD_CANCEL_ASYNCHRONOUS);
+ nn_thread_setcanceltype(NNWT_THREAD_CANCEL_ASYNCHRONOUS);
bool have_python = false;
- aki_mutex_lock(&bridge->mutex);
+ nn_mutex_lock(&bridge->mutex);
do {
- aki_cond_wait(&bridge->cond, &bridge->mutex);
+ nn_cond_wait(&bridge->cond, &bridge->mutex);
if (bridge->quit) break;
if (!have_python) {
// Defer python init.
@@ -117,9 +126,9 @@ static aki_thread_result AKI_THREADCALL queue_thread(void *userdata)
camu_queue_push(bridge->results, result);
}
bridge->queue.size = 0;
- aki_signal_send(&bridge->results_signal);
+ nn_signal_send(&bridge->results_signal);
} while (1);
- aki_mutex_unlock(&bridge->mutex);
+ nn_mutex_unlock(&bridge->mutex);
if (have_python) camu_python_close();
return 0;
}
@@ -137,19 +146,19 @@ static void results_signal_callback(void *userdata)
}
void camu_portal_init(struct camu_portal_bridge *bridge, struct camu_post_cache *cache,
- struct aki_event_loop *loop, void *userdata)
+ struct nn_event_loop *loop, void *userdata)
{
al_array_init(bridge->searches);
bridge->cache = cache;
bridge->quit = 0;
- aki_mutex_init(&bridge->mutex);
- aki_cond_init(&bridge->cond);
+ nn_mutex_init(&bridge->mutex);
+ nn_cond_init(&bridge->cond);
al_array_init(bridge->queue);
camu_queue_init(bridge->results);
- aki_signal_init(&bridge->results_signal, loop, results_signal_callback, bridge);
- aki_signal_start(&bridge->results_signal);
+ nn_signal_init(&bridge->results_signal, loop, results_signal_callback, bridge);
+ nn_signal_start(&bridge->results_signal);
bridge->userdata = userdata;
- aki_thread_create(&bridge->thread, queue_thread, bridge);
+ nn_thread_create(&bridge->thread, queue_thread, bridge);
}
void camu_portal_create_search(struct camu_portal_bridge *bridge, str *module, str *query,
@@ -161,12 +170,12 @@ void camu_portal_create_search(struct camu_portal_bridge *bridge, str *module, s
al_str_clone(&cmd.query, query);
cmd.callback = callback;
cmd.userdata = userdata;
- aki_mutex_lock(&bridge->mutex);
+ nn_mutex_lock(&bridge->mutex);
al_array_push(bridge->queue, cmd);
- if (aki_cond_is_waiting(&bridge->cond)) {
- aki_cond_signal(&bridge->cond);
+ if (nn_cond_is_waiting(&bridge->cond)) {
+ nn_cond_signal(&bridge->cond);
}
- aki_mutex_unlock(&bridge->mutex);
+ nn_mutex_unlock(&bridge->mutex);
}
void camu_portal_get_page(struct camu_portal_bridge *bridge, s32 id, u32 num,
@@ -178,28 +187,28 @@ void camu_portal_get_page(struct camu_portal_bridge *bridge, s32 id, u32 num,
cmd.num = num;
cmd.callback = callback;
cmd.userdata = userdata;
- aki_mutex_lock(&bridge->mutex);
+ nn_mutex_lock(&bridge->mutex);
al_array_push(bridge->queue, cmd);
- if (aki_cond_is_waiting(&bridge->cond)) {
- aki_cond_signal(&bridge->cond);
+ if (nn_cond_is_waiting(&bridge->cond)) {
+ nn_cond_signal(&bridge->cond);
}
- aki_mutex_unlock(&bridge->mutex);
+ nn_mutex_unlock(&bridge->mutex);
}
void camu_portal_close(struct camu_portal_bridge *bridge)
{
- aki_mutex_lock(&bridge->mutex);
+ nn_mutex_lock(&bridge->mutex);
bridge->quit = 1;
- if (aki_cond_is_waiting(&bridge->cond)) {
- aki_cond_signal(&bridge->cond);
+ if (nn_cond_is_waiting(&bridge->cond)) {
+ nn_cond_signal(&bridge->cond);
}
- aki_mutex_unlock(&bridge->mutex);
- aki_thread_join(&bridge->thread);
- aki_signal_stop(&bridge->results_signal);
+ nn_mutex_unlock(&bridge->mutex);
+ nn_thread_join(&bridge->thread);
+ nn_signal_stop(&bridge->results_signal);
camu_queue_free(bridge->results);
al_array_free(bridge->queue);
- aki_cond_destroy(&bridge->cond);
- aki_mutex_destroy(&bridge->mutex);
+ nn_cond_destroy(&bridge->cond);
+ nn_mutex_destroy(&bridge->mutex);
}
/*
diff --git a/src/portal/src/search.h b/src/portal/src/search.h
index 199f491..f870522 100644
--- a/src/portal/src/search.h
+++ b/src/portal/src/search.h
@@ -1,7 +1,7 @@
#pragma once
-#include <aki/thread.h>
-#include <aki/signal.h>
+#include <nnwt/thread.h>
+#include <nnwt/signal.h>
#include "post.h"
#include "post_cache.h"
@@ -45,12 +45,12 @@ struct camu_portal_bridge {
array(struct camu_search *) searches;
struct camu_post_cache *cache;
u8 quit;
- struct aki_thread thread;
- struct aki_mutex mutex;
- struct aki_cond cond;
+ struct nn_thread thread;
+ struct nn_mutex mutex;
+ struct nn_cond cond;
array(struct camu_portal_cmd) queue;
queue(struct camu_portal_result) results;
- struct aki_signal results_signal;
+ struct nn_signal results_signal;
void *userdata;
};
@@ -58,7 +58,7 @@ bool camu_python_init(void);
void camu_python_close(void);
void camu_portal_init(struct camu_portal_bridge *bridge, struct camu_post_cache *cache,
- struct aki_event_loop *loop, void *userdata);
+ struct nn_event_loop *loop, void *userdata);
void camu_portal_create_search(struct camu_portal_bridge *bridge, str *module, str *query,
void (*callback)(void *, void *, struct camu_portal_result *), void *userdata);