* COMMENT -*- mode: org -*- #+Date: 2019-04-05 Time-stamp: <2023-08-15> #+STARTUP: content * notes :entry: ** 2020-02-02 documents - Wrap best practices and tips https://mesonbuild.com/Wrap-best-practices-and-tips.html - meson build Reference manual https://mesonbuild.com/Reference-manual.html - ** 2019-08-31 ibus-pinyin userdb inference notice. zero-pinyin-service reuse ibus-pinyin's userdb at ~/.cache/ibus/pinyin/user-1.0.db This is generally not a problem. But if ibus-pinyin changed their table schema in the future, zero-pinyin-service may require update. zero-pinyin-service also store user phrase in this db. So user phrases are shared between zero-pinyin and ibus-pinyin. ** 2019-04-05 zero-pinyin-service file structure :doc: - zero-pinyin-service - main.c a console application based on glib and gio. provides dbus service. see the zero-pinyin-service spec at ~/c/gtk-im-module/operational :id001: - zero-pinyin-service.h zero-pinyin-service.c zero-pinyin-service-test.c contains the zero-pinyin-service dbus method C based implementation. - parse-pinyin.h parse-pinyin.cpp parse-pinyin-test.cpp contains utility functions based on code from libpyzyz. This should be replaced eventually. I don't want to depend on libpyzy source code. - utilities - test-sql.sh a shell script to experiment SQL commands - data files - meson.build build script. used to create executable. - com.emacsos.zero.ZeroPinyinService.service dbus service definition file. Should be copied to dbus service file dir /usr/share/dbus-1/services/ When dbus client try to talk to service, dbus session bus will start the service app automatically. ** 2019-08-31 how to format C code? do it before git commit. see ~/c/gtk-im-module/, it uses myastyle-pre-commit-check in git pre-commit ~/bin/myastyle-pre-commit-check ** 2023-08-15 how to build from source :doc: - dependencies - RHEL sudo dnf install -y gcc-c++ libuuid-devel sqlite-devel gtk3-devel python3-pip - Debian sudo apt install -y g++ uuid-dev libsqlite3-dev libgtk-3-dev python3-pip - meson build tool python3 -m pip install --user meson ninja - do a debug/release build get source code. This project requires libpyzy. mkdir ~/fromsource/ git clone git@gitlab.emacsos.com:sylecn/libpyzy.git cd libpyzy/src/ git clone git@gitlab.emacsos.com:sylecn/zero-pinyin-service.git cd zero-pinyin-service/ This is project root dir. in project root dir, # for debug build, do not include "--buildtype release" param meson setup --buildtype release build/ cd build && ninja - to run the built binary get phrases db, they are available in libpyzy in debian. you can download the deb and unpack it https://packages.debian.org/bookworm/libpyzy-1.0-0v5 put your main phrase database at any of these position: /usr/share/pyzy/db/open-phrase.db ~/.cache/ibus/pinyin/main.db put your user phrase database at: ~/.cache/ibus/pinyin/user-1.0.db now it's ready to run zero-pinyin-service. in project root dir, ./build/zero-pinyin-service ** 2020-02-16 how to create deb for distribution on apt repo? - on dev node, test deb, make sure it works. git push - on debian 9 x86 and x64 build server, git pull ./create-deb.sh - upload deb to aptly node using scp. - create aptly distribution, snapshot and publish snapshot. on aptly node, aptly repo add d [FILE|DIR]... aptly snapshot list version=0.1 aptly snapshot create d-$version from repo d # initial snapshot publish # aptly publish snapshot \ # -batch -gpg-key=apt@emacsos.com -passphrase-file=/etc/aptly_pass \ # d-$version # future publishes, switch publish to new snapshot aptly publish switch \ -batch -gpg-key=apt@emacsos.com -passphrase-file=/etc/aptly_pass \ debian d-$version * later :entry: * current :entry: ** ** 2023-08-15 try build zero-pinyin-service for RHEL9 - problems - maindb is empty. I need libpyzy's db. on rh901, mkdir -p ~/.cache/ibus/pinyin/ on lat21, scp ~/.cache/ibus/pinyin/main.db rh901:.cache/ibus/pinyin/ also copy my user db. now that I am here. scp ~/.cache/ibus/pinyin/user-1.0.db rh901:.cache/ibus/pinyin/ yes. it only needs the phrases db. libpyzy lib is not needed at runtime. - I should really get an alternative panel using emacs facility. it's easier to test when I don't have access to GUI env. ** 2019-08-31 honor XDG cache dir. ~/.cache/ibus ** 2019-04-17 make flags configurable at runtime. - add dbus method to set flags. - make the method work. use gobject property maybe. - set default flags to my flags. reflect this in UI/config file. * done :entry: ** 2020-02-16 aptly publish fails - ERROR: prefix/distribution already used by another published repo #+BEGIN_SRC sh root@gcpsgp01:~/d# aptly publish snapshot \ > -batch -gpg-key=apt@emacsos.com -passphrase-file=/etc/aptly_pass \ > d-$version ERROR: prefix/distribution already used by another published repo: ./debian [amd64, i386] publishes {main: [d-0.1]: Snapshot from local repo [d]} #+END_SRC try unpublish old snapshot aptly publish drop debian? aptly publish switch -batch -gpg-key=apt@emacsos.com -passphrase-file=/etc/aptly_pass debian d-$version ** 2019-10-22 handle a an o en etc differently. only match exactly the character. no fuzzy matching or incomplete pinyin matching. if shengmu is 0, always strict match it. do not allow omit shengmu in zero. ao men 澳门 e nuo 婀娜 - DONE use different FLAGS for them. FLAGS doesn't affect pinyin parsing. if flag support is to be added, just add it in appdata, as property. then use the property when building SQL. - DONE test in bogon VM. - DONE git push - build on debian 9 and release deb. later. - problems - result = parse_pinyin("an", 15, PINYIN_FUZZY_ALL); this only return 1 result. not an and ang. why? - maybe flag is not used when parsing pinyin string. only used when building the SQL statement. build_sql_for_n_pinyin() build_where_clause(pylist, n); yes. here. I should pass the flags around. - ** 2020-02-02 how to use zero-pinyin-service dbus service using C client? see example in ~/c/gtk-im-module/zero-pinyin.c #include - WONTFIX make zero-pinyin-generated a library. - I choose to include the dbus xml in the project, and generated new header/C files there. Still need to define a few const for object name etc though. - problems - only an so (libzero-pinyin-generated.so) is generated. how to install header files? search: meson library() how to install headers? install_headers() - search: meson install_headers from generated source file Generated headers cannot be installed directly · Issue #705 · mesonbuild/meson https://github.com/mesonbuild/meson/issues/705 foo.vapi files generated by Vala library() should be installed · Issue #891 · mesonbuild/meson https://github.com/mesonbuild/meson/issues/891 use install_data to install header files myself. #+BEGIN_SRC sh install_data(meson.current_build_dir() + '/foo.vapi', install_dir: 'share/vala/vapi') install_data(meson.current_build_dir() + '/foo@sha/Foo-1.0.gir', install_dir: 'share/gir-1.0') #+END_SRC ** 2019-10-22 support fuzzy pinyin. - 0 no fuzzy - 1 (0b1) z <-> zh c <-> ch s <-> sh - 2 (0b10) l <-> n - I won't implement other flags at this time. - default is no fuzzy. - test case: ru chi 如此 ci di 此地 e nuo 婀娜 e luo ci yu 词语 song 宋 shong - implementation - WONTFIX add a property in appdata. use a guint flag. only support 0b0 and 0b10 for now. Not necessary. - DONE add dbus interface to allow change the property at run time. property is added in dbus interface directly. app just read the property there. there is no network round trip. data is stored in the dbus service server side. not in dbus daemon. - DONE add flags in zero-el. this flag is NOT buffer local. (setq zero-pinyin-fuzzy-flag 3) it will set fuzzy mode when zero-pinyin-reset or zero-pinyin-init. (zero-pinyin-service-set-fuzzy-flag 3) it works. - problems - can I make this change backward compatible? DONE what will happen when zero asks dbus to set FuzzyFlag property, if running an old zero-pinyin-service? dbus-set-property returns nil if the property doesn't exist. I will show a warning. - property generated code is okay. - how to access that property in zero-pinyin-service.c? guint zero_pinyin_service_get_fuzzy_flag (ZeroPinyinService *object); this is not the right way. because flag doesn't change much. should query once at start up, then listen to change event and update in-ram data. do not query dbus every time FuzzyFlag is needed. WONTFIX add event handler to update appdata->fuzzy_flag when property is changed. // generated code handle set event and update g_object data in RAM automatically. signal org.freedesktop.DBus.Properties.PropertiesChanged see example in https://developer.gnome.org/gio/2.26/GDBusProxy.html - how to set the property in zero-el? call some dbus built-in service. (zero-pinyin-service-quit) run zero-pinyin-service in console (dbus-set-property :session "com.emacsos.zero.ZeroPinyinService1" "/com/emacsos/zero/ZeroPinyinService1" "com.emacsos.zero.ZeroPinyinService1.ZeroPinyinServiceInterface" "FuzzyFlag" 3) (dbus-set-property :session "com.emacsos.zero.ZeroPinyinService1" "/com/emacsos/zero/ZeroPinyinService1" "com.emacsos.zero.ZeroPinyinService1.ZeroPinyinServiceInterface" "FuzzyFlag" 0) I think generated code will handle set/get call. maybe just always get the value from zero_pinyin_service_get_fuzzy_flag(ZeroPinyinService *object) https://developer.gnome.org/gio/2.60/gdbus-codegen.html Server-side usage just use g_object_get() in server side. it will not talk to dbus. property change should be handled by generated code. - set property from emacs and read property in zero-pinyin-service.c works. but the fuzzy SQL logic is not working. when set to 3, shong can't produce 宋. enabled debug log. I see the problem. shong is not a valid py if fuzzy flag is not used during parsing. use correct parsing flag from FuzzyFlag when parsing. - now it works. ** 2019-08-31 choose maindb like my patched libpyzy. - here is patched libpyzy maindb logic: files.push_back (m_user_data_dir + "/main.db"); files.push_back (PKGDATADIR"/db/local.db"); files.push_back (PKGDATADIR"/db/open-phrase.db"); files.push_back (PKGDATADIR"/db/android.db"); return first_existing_file (files); m_user_data_dir default is ~/.cache/ibus/pinyin/ PKGDATADIR default is /usr/share/pyzy/ in zero-pinyin-service, just use the first existing file: ~/.cache/ibus/pinyin/main.db /usr/share/pyzy/db/open-phrase.db /usr/share/pyzy/db/android.db - should I reuse the ibus-pinyin userdb file? ~/.cache/ibus/pinyin/user-1.0.db yes. ibus-pinyin is not going away. DONE document this behavior in zero-el and zero-pinyin-service. - init_userdb() sqlite3_mprintf() https://www.sqlite.org/c3ref/mprintf.html additional non-standard formats (%q, %Q, %w, and %z). | | in | out | used for | |----+------+---------+----------------------------------------------------------| | %q | ab'c | ab''c | SQL string literal | | %Q | ab'c | 'ab''c' | SQL string literal | | %w | ab"c | ab""c | SQL identifier name | | %z | abc | abc | like %s, but sqlite3_free() is called on param after use | * wontfix :entry: ** 2019-10-23 bug: type "zhey" doesn't show 这样 candidate. :invalid: - 2020-02-16 can't reproduce this.