Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package fcitx5-rime for openSUSE:Factory 
checked in at 2023-08-21 11:44:45
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/fcitx5-rime (Old)
 and      /work/SRC/openSUSE:Factory/.fcitx5-rime.new.1766 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "fcitx5-rime"

Mon Aug 21 11:44:45 2023 rev:7 rq:1104886 version:5.1.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/fcitx5-rime/fcitx5-rime.changes  2023-05-23 
14:54:20.990414419 +0200
+++ /work/SRC/openSUSE:Factory/.fcitx5-rime.new.1766/fcitx5-rime.changes        
2023-08-21 11:44:57.971618096 +0200
@@ -1,0 +2,7 @@
+Sun Aug 20 06:23:58 UTC 2023 - Marguerite Su <[email protected]>
+
+- update to 5.1.1
+  * recreate all rime sessions when auto saving data
+  * rime session now follows the global shared state option. 
+
+-------------------------------------------------------------------

Old:
----
  fcitx5-rime-5.0.16.tar.xz

New:
----
  fcitx5-rime-5.1.1.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ fcitx5-rime.spec ++++++
--- /var/tmp/diff_new_pack.39CTrY/_old  2023-08-21 11:44:58.739619568 +0200
+++ /var/tmp/diff_new_pack.39CTrY/_new  2023-08-21 11:44:58.747619583 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           fcitx5-rime
-Version:        5.0.16
+Version:        5.1.1
 Release:        0
 Summary:        RIME support for Fcitx5
 License:        LGPL-2.1-or-later

++++++ fcitx5-rime-5.0.16.tar.xz -> fcitx5-rime-5.1.1.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/fcitx5-rime-5.0.16/CMakeLists.txt 
new/fcitx5-rime-5.1.1/CMakeLists.txt
--- old/fcitx5-rime-5.0.16/CMakeLists.txt       2023-03-11 05:02:07.759109500 
+0100
+++ new/fcitx5-rime-5.1.1/CMakeLists.txt        2023-08-20 03:40:12.512012500 
+0200
@@ -1,6 +1,6 @@
-cmake_minimum_required(VERSION 3.4.0)
+cmake_minimum_required(VERSION 3.6.0)
 
-project(fcitx5-rime VERSION 5.0.16)
+project(fcitx5-rime VERSION 5.1.1)
 
 find_package(ECM 1.0.0 REQUIRED)
 set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" 
${CMAKE_MODULE_PATH})
@@ -10,13 +10,16 @@
 include(ECMUninstallTarget)
 
 find_package(Gettext REQUIRED)
-find_package(Fcitx5Core 5.0.6 REQUIRED)
+find_package(Fcitx5Core 5.1.0 REQUIRED)
 find_package(Fcitx5Module REQUIRED COMPONENTS Notifications DBus)
 find_package(PkgConfig REQUIRED)
 pkg_check_modules(Rime REQUIRED IMPORTED_TARGET "rime>=1.0.0")
 if ("${Rime_VERSION}" VERSION_LESS "1.7.0")
     add_definitions(-DFCITX_RIME_LOAD_PLUGIN)
 endif()
+if ("${Rime_VERSION}" VERSION_LESS "1.6.0")
+    add_definitions(-DFCITX_RIME_NO_LOG_LEVEL)
+endif()
 
 if(NOT DEFINED RIME_DATA_DIR)
   find_package(RimeData REQUIRED)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/fcitx5-rime-5.0.16/org.fcitx.Fcitx5.Addon.Rime.metainfo.xml.in 
new/fcitx5-rime-5.1.1/org.fcitx.Fcitx5.Addon.Rime.metainfo.xml.in
--- old/fcitx5-rime-5.0.16/org.fcitx.Fcitx5.Addon.Rime.metainfo.xml.in  
2023-03-11 05:02:07.849110000 +0100
+++ new/fcitx5-rime-5.1.1/org.fcitx.Fcitx5.Addon.Rime.metainfo.xml.in   
2023-08-20 03:40:12.575346700 +0200
@@ -10,6 +10,8 @@
   <url type="bugtracker">https://github.com/fcitx/fcitx5-rime/issues</url>
   <project_group>Fcitx</project_group>
   <releases>
+    <release version="5.1.1" date="2023-08-19"/>
+    <release version="5.1.0" date="2023-08-14"/>
     <release version="5.0.16" date="2023-03-10"/>
     <release version="5.0.15" date="2022-11-19"/>
     <release version="5.0.14" date="2022-07-03"/>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/fcitx5-rime-5.0.16/po/he.po 
new/fcitx5-rime-5.1.1/po/he.po
--- old/fcitx5-rime-5.0.16/po/he.po     2023-03-11 02:43:47.937597000 +0100
+++ new/fcitx5-rime-5.1.1/po/he.po      2023-08-05 19:35:24.730569400 +0200
@@ -3,16 +3,17 @@
 # This file is distributed under the same license as the fcitx5-rime package.
 #
 # Translators:
-# עומר א״ש <[email protected]>, 2020
+# 63f334ffc0709ba0fc2361b80bf3c0f0_00ffd1e 
<ab96c93ca0ac55ba7fa06385427e60dd_878890>, 2020
 #
 msgid ""
 msgstr ""
 "Project-Id-Version: fcitx5-rime\n"
 "Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2023-03-10 20:24+0000\n"
+"POT-Creation-Date: 2023-04-12 14:26+0000\n"
 "PO-Revision-Date: 2017-11-23 05:02+0000\n"
-"Last-Translator: עומר א״ש <[email protected]>, 2020\n"
-"Language-Team: Hebrew (https://www.transifex.com/fcitx/teams/12005/he/)\n"
+"Last-Translator: 63f334ffc0709ba0fc2361b80bf3c0f0_00ffd1e "
+"<ab96c93ca0ac55ba7fa06385427e60dd_878890>, 2020\n"
+"Language-Team: Hebrew (https://app.transifex.com/fcitx/teams/12005/he/)\n"
 "Language: he\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/fcitx5-rime-5.0.16/po/ru.po 
new/fcitx5-rime-5.1.1/po/ru.po
--- old/fcitx5-rime-5.0.16/po/ru.po     2023-03-11 02:43:47.937597000 +0100
+++ new/fcitx5-rime-5.1.1/po/ru.po      2023-08-05 19:35:24.730569400 +0200
@@ -4,15 +4,15 @@
 #
 # Translators:
 # csslayer <[email protected]>, 2017
-# Dmitry <[email protected]>, 2022
+# Dmitry <[email protected]>, 2023
 #
 msgid ""
 msgstr ""
 "Project-Id-Version: fcitx5-rime\n"
 "Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2023-03-10 20:24+0000\n"
+"POT-Creation-Date: 2023-03-11 20:24+0000\n"
 "PO-Revision-Date: 2017-11-23 05:02+0000\n"
-"Last-Translator: Dmitry <[email protected]>, 2022\n"
+"Last-Translator: Dmitry <[email protected]>, 2023\n"
 "Language-Team: Russian (https://www.transifex.com/fcitx/teams/12005/ru/)\n"
 "Language: ru\n"
 "MIME-Version: 1.0\n"
@@ -62,11 +62,11 @@
 
 #: src/rimeengine.cpp:375
 msgid "Punctuation conversion is disabled."
-msgstr ""
+msgstr "Преобразование знаков препинания 
отключено."
 
 #: src/rimeengine.cpp:372
 msgid "Punctuation conversion is enabled."
-msgstr ""
+msgstr "Преобразование знаков препинания 
включено."
 
 #: src/rimeengine.cpp:387 src/rimeengine.cpp:388 src/rime.conf.in:3
 #: src/rime-addon.conf.in.in:3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/fcitx5-rime-5.0.16/po/zh_TW.po 
new/fcitx5-rime-5.1.1/po/zh_TW.po
--- old/fcitx5-rime-5.0.16/po/zh_TW.po  2023-03-11 02:43:47.940930400 +0100
+++ new/fcitx5-rime-5.1.1/po/zh_TW.po   2023-08-14 19:33:36.357578000 +0200
@@ -3,20 +3,21 @@
 # This file is distributed under the same license as the fcitx5-rime package.
 #
 # Translators:
-# csslayer <[email protected]>, 2017
 # pan93412 <[email protected]>, 2019
 # bruh, 2020
 # 菘菘 <[email protected]>, 2022
 # Neko ◣ 0xFF, 2022
+# Lau YeeYu, 2023
+# csslayer <[email protected]>, 2023
 #
 msgid ""
 msgstr ""
 "Project-Id-Version: fcitx5-rime\n"
 "Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2023-03-10 20:24+0000\n"
+"POT-Creation-Date: 2023-08-05 20:24+0000\n"
 "PO-Revision-Date: 2017-11-23 05:02+0000\n"
-"Last-Translator: Neko ◣ 0xFF, 2022\n"
-"Language-Team: Chinese (Taiwan) (https://www.transifex.com/fcitx/teams/12005/";
+"Last-Translator: csslayer <[email protected]>, 2023\n"
+"Language-Team: Chinese (Taiwan) (https://app.transifex.com/fcitx/teams/12005/";
 "zh_TW/)\n"
 "Language: zh_TW\n"
 "MIME-Version: 1.0\n"
@@ -24,51 +25,51 @@
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=1; plural=0;\n"
 
-#: src/rimeengine.h:42
+#: src/rimeengine.h:45
 msgid "Commit current text when deactivating"
 msgstr "取消啟用輸入法時提交目前文字"
 
-#: src/rimeengine.cpp:117
+#: src/rimeengine.cpp:118
 msgid "Deploy"
 msgstr "重新部署"
 
-#: src/rimeengine.h:39
+#: src/rimeengine.h:42
 msgid "Fix embedded preedit cursor at the beginning of the preedit"
-msgstr "在預編輯的開頭修復嵌入的預編輯光標"
+msgstr "將預編輯光標位置固定在預編輯的開頭"
 
-#: src/rimeengine.cpp:369
+#: src/rimeengine.cpp:415
 msgid "Full Shape is enabled."
-msgstr ""
+msgstr "已啟用全形字符。"
 
-#: src/rimeengine.cpp:366
+#: src/rimeengine.cpp:412
 msgid "Half Shape is enabled."
-msgstr ""
+msgstr "已啟用半形字符。"
 
-#: src/rimestate.cpp:54 src/rimeengine.cpp:469
+#: src/rimestate.cpp:55 src/rimeengine.cpp:519
 msgid "Latin Mode"
 msgstr "羅馬拼音模式"
 
-#: src/rimeengine.h:55
+#: src/rimeengine.h:58
 msgid "Load available plugins automatically"
 msgstr "自動載入可用插件"
 
-#: src/rimeengine.h:59
+#: src/rimeengine.h:62
 msgid "Modules"
 msgstr "模組"
 
-#: src/rimeengine.h:57
+#: src/rimeengine.h:60
 msgid "Plugins"
 msgstr "插件"
 
-#: src/rimeengine.cpp:375
+#: src/rimeengine.cpp:421
 msgid "Punctuation conversion is disabled."
-msgstr ""
+msgstr "已禁用標點轉換。"
 
-#: src/rimeengine.cpp:372
+#: src/rimeengine.cpp:418
 msgid "Punctuation conversion is enabled."
-msgstr ""
+msgstr "已啟用標點轉換。"
 
-#: src/rimeengine.cpp:387 src/rimeengine.cpp:388 src/rime.conf.in:3
+#: src/rimeengine.cpp:433 src/rimeengine.cpp:434 src/rime.conf.in:3
 #: src/rime-addon.conf.in.in:3
 msgid "Rime"
 msgstr "中州韻"
@@ -81,7 +82,7 @@
 msgid "Rime for Fcitx 5"
 msgstr "Fcitx 5 的中州韻支援"
 
-#: src/rimeengine.cpp:359
+#: src/rimeengine.cpp:405
 msgid "Rime has encountered an error. See /tmp/rime.fcitx.ERROR for details."
 msgstr "Rime 遇到了一個錯誤。見 /tmp/rime.fcitx.ERROR 
以取得更多資訊。"
 
@@ -89,32 +90,32 @@
 msgid "Rime input method"
 msgstr "Rime 輸入法"
 
-#: src/rimeengine.cpp:356
+#: src/rimeengine.cpp:397
 msgid "Rime is ready."
 msgstr "Rime 準備好了。"
 
-#: src/rimeengine.cpp:353
+#: src/rimeengine.cpp:394
 msgid ""
 "Rime is under maintenance. It may take a few seconds. Please wait until it "
 "is finished..."
 msgstr "Rime 正在維護中。這可能需要幾秒鐘。請等待完成…"
 
-#: src/rimeengine.h:35
+#: src/rimeengine.h:38
 msgid "Show preedit within application"
 msgstr "在程式中顯示預編輯字串"
 
-#: src/rimeengine.cpp:381
+#: src/rimeengine.cpp:427
 msgid "Simplified Chinese is enabled."
 msgstr "已啟用簡體中文。"
 
-#: src/rimeengine.cpp:129
+#: src/rimeengine.cpp:130
 msgid "Synchronize"
 msgstr "同步"
 
-#: src/rimeengine.cpp:378
+#: src/rimeengine.cpp:424
 msgid "Traditional Chinese is enabled."
 msgstr "已啟用繁體中文。"
 
-#: src/rimeengine.h:44
+#: src/rimeengine.h:47
 msgid "User data dir"
 msgstr "使用者資料夾"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/fcitx5-rime-5.0.16/src/CMakeLists.txt 
new/fcitx5-rime-5.1.1/src/CMakeLists.txt
--- old/fcitx5-rime-5.0.16/src/CMakeLists.txt   2021-11-02 00:50:20.516405300 
+0100
+++ new/fcitx5-rime-5.1.1/src/CMakeLists.txt    2023-08-05 19:35:24.730569400 
+0200
@@ -3,6 +3,7 @@
     rimeengine.cpp
     rimecandidate.cpp
     rimeservice.cpp
+    rimesession.cpp
 )
 add_library(rime MODULE ${RIME_SOURCES})
 target_link_libraries(rime Fcitx5::Core Fcitx5::Config PkgConfig::Rime 
Fcitx5::Module::Notifications Fcitx5::Module::DBus)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/fcitx5-rime-5.0.16/src/rime-addon.conf.in.in 
new/fcitx5-rime-5.1.1/src/rime-addon.conf.in.in
--- old/fcitx5-rime-5.0.16/src/rime-addon.conf.in.in    2021-11-02 
00:57:02.755905600 +0100
+++ new/fcitx5-rime-5.1.1/src/rime-addon.conf.in.in     2023-08-05 
19:35:24.730569400 +0200
@@ -9,7 +9,7 @@
 Configurable=True
 
 [Addon/Dependencies]
-0=core:5.0.6
+0=core:5.1.0
 
 [Addon/OptionalDependencies]
 0=notifications
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/fcitx5-rime-5.0.16/src/rimeengine.cpp 
new/fcitx5-rime-5.1.1/src/rimeengine.cpp
--- old/fcitx5-rime-5.0.16/src/rimeengine.cpp   2023-03-10 19:45:53.018296700 
+0100
+++ new/fcitx5-rime-5.1.1/src/rimeengine.cpp    2023-08-20 03:37:49.890091400 
+0200
@@ -107,7 +107,8 @@
 
 RimeEngine::RimeEngine(Instance *instance)
     : instance_(instance), api_(rime_get_api()),
-      factory_([this](InputContext &ic) { return new RimeState(this, ic); }) {
+      factory_([this](InputContext &ic) { return new RimeState(this, ic); }),
+      sessionPool_(this, instance_->globalConfig().shareInputState()) {
     imAction_ = std::make_unique<IMAction>(this);
     instance_->userInterfaceManager().registerAction("fcitx-rime-im",
                                                      imAction_.get());
@@ -137,6 +138,13 @@
     });
     instance_->userInterfaceManager().registerAction("fcitx-rime-sync",
                                                      &syncAction_);
+    globalConfigReloadHandle_ = instance_->watchEvent(
+        EventType::GlobalConfigReloaded, EventWatcherPhase::Default,
+        [this](Event &) {
+            releaseAllSession();
+            sessionPool_.setPropertyPropagatePolicy(
+                instance_->globalConfig().shareInputState());
+        });
     reloadConfig();
 }
 
@@ -161,6 +169,7 @@
     auto userDir = stringutils::joinPath(
         StandardPath::global().userDirectory(StandardPath::Type::PkgData),
         "rime");
+    RIME_DEBUG() << "Rime data directory: " << userDir;
     if (!fs::makePath(userDir)) {
         if (!fs::isdir(userDir)) {
             RIME_ERROR() << "Failed to create user directory: " << userDir;
@@ -175,6 +184,26 @@
     fcitx_rime_traits.distribution_name = "Rime";
     fcitx_rime_traits.distribution_code_name = "fcitx-rime";
     fcitx_rime_traits.distribution_version = FCITX_RIME_VERSION;
+#ifndef FCITX_RIME_NO_LOG_LEVEL
+    switch (rime().logLevel()) {
+    case NoLog:
+        fcitx_rime_traits.min_log_level = 4;
+        break;
+    case Fatal:
+        fcitx_rime_traits.min_log_level = 3;
+        break;
+    case Error:
+    case Warn:
+    case Info:
+        fcitx_rime_traits.min_log_level = 2;
+        break;
+    case Debug:
+    default:
+        // Rime info is too noisy.
+        fcitx_rime_traits.min_log_level = 0;
+        break;
+    }
+#endif
 
 #ifdef FCITX_RIME_LOAD_PLUGIN
     std::vector<const char *> modules;
@@ -200,10 +229,14 @@
     }
     api_->initialize(&fcitx_rime_traits);
     api_->set_notification_handler(&rimeNotificationHandler, this);
-    if (api_->start_maintenance(fullcheck)) {
-        api_->deploy_config_file("fcitx5.yaml", "config_version");
+    api_->start_maintenance(fullcheck);
+
+    if (!api_->is_maintenance_mode()) {
+        updateAppOptions();
     }
+}
 
+void RimeEngine::updateAppOptions() {
     appOptions_.clear();
     RimeConfig config = {NULL};
     if (api_->config_open("fcitx5", &config)) {
@@ -211,6 +244,7 @@
         api_->config_close(&config);
     }
     RIME_DEBUG() << "App options are " << appOptions_;
+    releaseAllSession();
 }
 
 void RimeEngine::reloadConfig() {
@@ -326,7 +360,11 @@
     inputContext->updateUserInterface(UserInterfaceComponent::InputPanel);
 }
 
-void RimeEngine::save() {}
+void RimeEngine::save() {
+    // Block notification for 5 sec.
+    blockNotificationBefore_ = now(CLOCK_MONOTONIC) + 5000000;
+    sync();
+}
 
 void RimeEngine::rimeNotificationHandler(void *context, RimeSessionId session,
                                          const char *messageType,
@@ -343,6 +381,9 @@
 
 void RimeEngine::notify(const std::string &messageType,
                         const std::string &messageValue) {
+    if (now(CLOCK_MONOTONIC) < blockNotificationBefore_) {
+        return;
+    }
     const char *message = nullptr;
     const char *icon = "";
     const char *tipId = "";
@@ -355,6 +396,11 @@
         } else if (messageValue == "success") {
             message = _("Rime is ready.");
             updateSchemaMenu();
+            if (!api_->is_maintenance_mode()) {
+                api_->deploy_config_file("fcitx5.yaml", "config_version");
+                updateAppOptions();
+                releaseAllSession();
+            }
         } else if (messageValue == "failure") {
             message = _("Rime has encountered an error. "
                         "See /tmp/rime.fcitx.ERROR for details.");
@@ -441,19 +487,27 @@
     return result;
 }
 
-void RimeEngine::deploy() {
-    RIME_DEBUG() << "Rime Deploy";
+void RimeEngine::releaseAllSession() {
     instance_->inputContextManager().foreach([this](InputContext *ic) {
         if (auto state = this->state(ic)) {
             state->release();
         }
         return true;
     });
+}
+
+void RimeEngine::deploy() {
+    RIME_DEBUG() << "Rime Deploy";
+    releaseAllSession();
     api_->finalize();
     rimeStart(true);
 }
 
-void RimeEngine::sync() { api_->sync_user_data(); }
+void RimeEngine::sync() {
+    RIME_DEBUG() << "Rime Sync user data";
+    api_->sync_user_data();
+    releaseAllSession();
+}
 
 void RimeEngine::updateSchemaMenu() {
     if (!api_) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/fcitx5-rime-5.0.16/src/rimeengine.h 
new/fcitx5-rime-5.1.1/src/rimeengine.h
--- old/fcitx5-rime-5.0.16/src/rimeengine.h     2022-04-13 08:28:49.271104800 
+0200
+++ new/fcitx5-rime-5.1.1/src/rimeengine.h      2023-08-05 20:08:59.091996000 
+0200
@@ -7,10 +7,13 @@
 #define _FCITX_RIMEENGINE_H_
 
 #include "rimeservice.h"
+#include "rimesession.h"
+#include "rimestate.h"
 #include <fcitx-config/configuration.h>
 #include <fcitx-config/iniparser.h>
 #include <fcitx-utils/event.h>
 #include <fcitx-utils/eventdispatcher.h>
+#include <fcitx-utils/handlertable_details.h>
 #include <fcitx-utils/i18n.h>
 #include <fcitx-utils/library.h>
 #include <fcitx-utils/log.h>
@@ -103,6 +106,7 @@
     void rimeStart(bool fullcheck);
 
     RimeState *state(InputContext *ic);
+    RimeSessionPool &sessionPool() { return sessionPool_; }
 
     FCITX_ADDON_DEPENDENCY_LOADER(dbus, instance_->addonManager());
 
@@ -116,12 +120,15 @@
     void sync();
     void updateSchemaMenu();
     void notify(const std::string &type, const std::string &value);
+    void releaseAllSession();
+    void updateAppOptions();
 
     IconTheme theme_;
     Instance *instance_;
     EventDispatcher eventDispatcher_;
     rime_api_t *api_;
     bool firstRun_ = true;
+    uint64_t blockNotificationBefore_ = 0;
     FactoryFor<RimeState> factory_;
 
     std::unique_ptr<Action> imAction_;
@@ -140,8 +147,10 @@
     std::unordered_map<std::string, Library> pluginPool_;
 #endif
     std::unique_ptr<EventSourceTime> timeEvent_;
+    std::unique_ptr<HandlerTableEntry<EventHandler>> globalConfigReloadHandle_;
 
     RimeService service_{this};
+    RimeSessionPool sessionPool_;
 };
 
 class RimeEngineFactory : public AddonFactory {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/fcitx5-rime-5.0.16/src/rimeservice.cpp 
new/fcitx5-rime-5.1.1/src/rimeservice.cpp
--- old/fcitx5-rime-5.0.16/src/rimeservice.cpp  2022-11-08 04:58:12.999984300 
+0100
+++ new/fcitx5-rime-5.1.1/src/rimeservice.cpp   2023-08-05 19:35:24.730569400 
+0200
@@ -6,6 +6,7 @@
  */
 #include "rimeservice.h"
 #include "dbus_public.h"
+#include "rimeengine.h"
 #include "rimestate.h"
 
 namespace fcitx {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/fcitx5-rime-5.0.16/src/rimesession.cpp 
new/fcitx5-rime-5.1.1/src/rimesession.cpp
--- old/fcitx5-rime-5.0.16/src/rimesession.cpp  1970-01-01 01:00:00.000000000 
+0100
+++ new/fcitx5-rime-5.1.1/src/rimesession.cpp   2023-08-05 19:35:24.730569400 
+0200
@@ -0,0 +1,139 @@
+/*
+ * SPDX-FileCopyrightText: 2021~2021 CSSlayer <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ */
+#include "rimesession.h"
+#include "rimeengine.h"
+#include <fcitx-utils/charutils.h>
+#include <fcitx-utils/log.h>
+#include <fcitx-utils/stringutils.h>
+#include <fcitx/inputcontext.h>
+#include <fcitx/inputcontextmanager.h>
+#include <memory>
+#include <rime_api.h>
+#include <stdexcept>
+#include <string>
+#include <tuple>
+#include <utility>
+
+namespace fcitx {
+
+RimeSessionHolder::RimeSessionHolder(RimeSessionPool *pool,
+                                     const std::string &program)
+    : pool_(pool) {
+    auto *api = pool_->engine()->api();
+    id_ = api->create_session();
+
+    if (!id_) {
+        throw std::runtime_error("Failed to create session.");
+    }
+
+    if (program.empty()) {
+        return;
+    }
+
+    const auto &appOptions = pool_->engine()->appOptions();
+    if (auto iter = appOptions.find(program); iter != appOptions.end()) {
+        RIME_DEBUG() << "Apply app options to " << program << ": "
+                     << iter->second;
+        for (const auto &[key, value] : iter->second) {
+            api->set_option(id_, key.data(), value);
+        }
+    }
+}
+
+RimeSessionHolder::~RimeSessionHolder() {
+    if (id_) {
+        pool_->engine()->api()->destroy_session(id_);
+    }
+    if (!key_.empty()) {
+        pool_->unregisterSession(key_);
+    }
+}
+
+#if 0
+LogMessageBuilder &operator<<(LogMessageBuilder &log, const 
std::weak_ptr<RimeSessionHolder> &session) {
+    auto sessionPtr = session.lock();
+    log << "RimeSession("<< (sessionPtr ? std::to_string(sessionPtr->id()) : 
"null")  << ")";
+    return log;
+}
+#endif
+
+RimeSessionPool::RimeSessionPool(RimeEngine *engine,
+                                 PropertyPropagatePolicy initialPolicy)
+    : engine_(engine), policy_(initialPolicy) {}
+
+void RimeSessionPool::setPropertyPropagatePolicy(
+    PropertyPropagatePolicy policy) {
+    if (policy_ == policy) {
+        return;
+    }
+
+    assert(sessions_.empty());
+    policy_ = policy;
+}
+
+std::string uuidKey(InputContext *ic) {
+    std::string key = "u:";
+    for (auto v : ic->uuid()) {
+        auto lower = v % 16;
+        auto upper = v / 16;
+        key.push_back(charutils::toHex(upper));
+        key.push_back(charutils::toHex(lower));
+    }
+    return key;
+}
+
+std::shared_ptr<RimeSessionHolder>
+RimeSessionPool::requestSession(InputContext *ic) {
+    if (!engine_->api()) {
+        return nullptr;
+    }
+    std::string key;
+    switch (policy_) {
+    case PropertyPropagatePolicy::No:
+        key = uuidKey(ic);
+        break;
+    case PropertyPropagatePolicy::Program:
+        if (!ic->program().empty()) {
+            key = stringutils::concat("p:", ic->program());
+        } else {
+            key = uuidKey(ic);
+        }
+        break;
+    case PropertyPropagatePolicy::All:
+        key = "g:";
+        break;
+    }
+    auto iter = sessions_.find(key);
+    if (iter != sessions_.end()) {
+        return iter->second.lock();
+    }
+    try {
+        auto newSession =
+            std::make_shared<RimeSessionHolder>(this, ic->program());
+        registerSession(key, newSession);
+        return newSession;
+    } catch (...) {
+    }
+    return nullptr;
+}
+
+void RimeSessionPool::registerSession(
+    const std::string &key, std::shared_ptr<RimeSessionHolder> session) {
+    assert(!key.empty());
+    session->key_ = key;
+    auto [_, success] = sessions_.emplace(key, session);
+    FCITX_UNUSED(success);
+    assert(success);
+}
+
+void RimeSessionPool::unregisterSession(const std::string &key) {
+    auto count = sessions_.erase(key);
+    FCITX_UNUSED(count);
+    assert(count > 0);
+}
+
+} // namespace fcitx
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/fcitx5-rime-5.0.16/src/rimesession.h 
new/fcitx5-rime-5.1.1/src/rimesession.h
--- old/fcitx5-rime-5.0.16/src/rimesession.h    1970-01-01 01:00:00.000000000 
+0100
+++ new/fcitx5-rime-5.1.1/src/rimesession.h     2023-08-05 19:35:24.730569400 
+0200
@@ -0,0 +1,63 @@
+/*
+ * SPDX-FileCopyrightText: 2021~2021 CSSlayer <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ */
+#ifndef _FCITX5_RIME_RIMESESSION_H_
+#define _FCITX5_RIME_RIMESESSION_H_
+
+#include <fcitx-utils/log.h>
+#include <fcitx-utils/macros.h>
+#include <fcitx/inputcontextmanager.h>
+#include <memory>
+#include <rime_api.h>
+#include <string>
+
+namespace fcitx {
+
+class RimeEngine;
+class RimeSessionPool;
+
+class RimeSessionHolder {
+    friend class RimeSessionPool;
+
+public:
+    RimeSessionHolder(RimeSessionPool *pool, const std::string &program);
+
+    RimeSessionHolder(RimeSessionHolder &&) = delete;
+
+    ~RimeSessionHolder();
+
+    RimeSessionId id() const { return id_; }
+
+private:
+    RimeSessionPool *pool_;
+    RimeSessionId id_ = 0;
+    std::string key_;
+};
+
+class RimeSessionPool {
+    friend class RimeSessionHolder;
+
+public:
+    RimeSessionPool(RimeEngine *engine, PropertyPropagatePolicy initialPolicy);
+
+    void setPropertyPropagatePolicy(PropertyPropagatePolicy policy);
+
+    std::shared_ptr<RimeSessionHolder> requestSession(InputContext *ic);
+
+    RimeEngine *engine() const { return engine_; }
+
+private:
+    void registerSession(const std::string &key,
+                         std::shared_ptr<RimeSessionHolder> session);
+    void unregisterSession(const std::string &key);
+    RimeEngine *engine_;
+    PropertyPropagatePolicy policy_;
+    std::unordered_map<std::string, std::weak_ptr<RimeSessionHolder>> 
sessions_;
+};
+
+} // namespace fcitx
+
+#endif
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/fcitx5-rime-5.0.16/src/rimestate.cpp 
new/fcitx5-rime-5.1.1/src/rimestate.cpp
--- old/fcitx5-rime-5.0.16/src/rimestate.cpp    2022-11-08 05:01:15.195166800 
+0100
+++ new/fcitx5-rime-5.1.1/src/rimestate.cpp     2023-08-05 19:35:24.730569400 
+0200
@@ -10,6 +10,7 @@
 #include <fcitx/candidatelist.h>
 #include <fcitx/inputcontext.h>
 #include <fcitx/inputpanel.h>
+#include <rime_api.h>
 
 namespace fcitx {
 
@@ -25,23 +26,23 @@
 } // namespace
 
 RimeState::RimeState(RimeEngine *engine, InputContext &ic)
-    : engine_(engine), ic_(ic) {
-    createSession();
-}
+    : engine_(engine), ic_(ic) {}
 
-RimeState::~RimeState() {
-    if (auto api = engine_->api()) {
-        if (session_) {
-            api->destroy_session(session_);
-        }
+RimeState::~RimeState() {}
+
+RimeSessionId RimeState::session() {
+    if (!session_) {
+        session_ = engine_->sessionPool().requestSession(&ic_);
     }
+    if (!session_) {
+        return 0;
+    }
+    return session_->id();
 }
 
 void RimeState::clear() {
-    if (auto api = engine_->api()) {
-        if (session_) {
-            api->clear_composition(session_);
-        }
+    if (auto session = this->session()) {
+        engine_->api()->clear_composition(session);
     }
 }
 
@@ -61,7 +62,7 @@
 
 std::string RimeState::subModeLabel() {
     std::string result;
-    getStatus([this, &result](const RimeStatus &status) {
+    getStatus([&result](const RimeStatus &status) {
         if (status.is_disabled) {
             result = "";
         } else if (status.is_ascii_mode) {
@@ -84,7 +85,7 @@
     if (!api || api->is_maintenance_mode()) {
         return;
     }
-    api->set_option(session_, "ascii_mode", latin);
+    api->set_option(session(), "ascii_mode", latin);
 }
 
 void RimeState::selectSchema(const std::string &schema) {
@@ -92,8 +93,8 @@
     if (!api || api->is_maintenance_mode()) {
         return;
     }
-    api->set_option(session_, "ascii_mode", false);
-    api->select_schema(session_, schema.data());
+    api->set_option(session(), "ascii_mode", false);
+    api->select_schema(session(), schema.data());
 }
 
 void RimeState::keyEvent(KeyEvent &event) {
@@ -101,10 +102,8 @@
     if (!api || api->is_maintenance_mode()) {
         return;
     }
-    if (!api->find_session(session_)) {
-        createSession();
-    }
-    if (!session_) {
+    auto session = this->session();
+    if (!session) {
         return;
     }
 
@@ -121,11 +120,11 @@
         // IBUS_RELEASE_MASK
         intStates |= (1 << 30);
     }
-    auto result = api->process_key(session_, event.rawKey().sym(), intStates);
+    auto result = api->process_key(session, event.rawKey().sym(), intStates);
 
     auto ic = event.inputContext();
     RIME_STRUCT(RimeCommit, commit);
-    if (api->get_commit(session_, &commit)) {
+    if (api->get_commit(session, &commit)) {
         ic->commitString(commit.text);
         api->free_commit(&commit);
     }
@@ -143,14 +142,12 @@
     if (!api) {
         return false;
     }
-    if (!api->find_session(session_)) {
-        createSession();
-    }
-    if (!session_) {
+    auto session = this->session();
+    if (!session) {
         return false;
     }
     RIME_STRUCT(RimeStatus, status);
-    if (!api->get_status(session_, &status)) {
+    if (!api->get_status(session, &status)) {
         return false;
     }
     callback(status);
@@ -243,12 +240,13 @@
         if (!api || api->is_maintenance_mode()) {
             return;
         }
-        if (!api->find_session(session_)) {
+        auto session = this->session();
+        if (!api->find_session(session)) {
             return;
         }
 
         RIME_STRUCT(RimeContext, context);
-        if (!api->get_context(session_, &context)) {
+        if (!api->get_context(session, &context)) {
             break;
         }
 
@@ -284,19 +282,13 @@
     }
 }
 
-void RimeState::release() {
-    if (auto api = engine_->api()) {
-        if (session_) {
-            api->destroy_session(session_);
-        }
-        session_ = 0;
-    }
-}
+void RimeState::release() { session_.reset(); }
 
 void RimeState::commitPreedit(InputContext *ic) {
     if (auto api = engine_->api()) {
         RIME_STRUCT(RimeContext, context);
-        if (!api->get_context(session_, &context)) {
+        auto session = this->session();
+        if (!api->get_context(session, &context)) {
             return;
         }
         if (context.commit_text_preview) {
@@ -305,29 +297,4 @@
         api->free_context(&context);
     }
 }
-
-void RimeState::createSession() {
-    auto api = engine_->api();
-    if (!api) {
-        return;
-    }
-    session_ = api->create_session();
-    if (!session_) {
-        return;
-    }
-
-    if (ic_.program().empty()) {
-        return;
-    }
-
-    const auto &appOptions = engine_->appOptions();
-    if (auto iter = appOptions.find(ic_.program()); iter != appOptions.end()) {
-        RIME_DEBUG() << "Apply app options to " << ic_.program() << ": "
-                     << iter->second;
-        for (const auto &[key, value] : iter->second) {
-            api->set_option(session_, key.data(), value);
-        }
-    }
-}
-
 } // namespace fcitx
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/fcitx5-rime-5.0.16/src/rimestate.h 
new/fcitx5-rime-5.1.1/src/rimestate.h
--- old/fcitx5-rime-5.0.16/src/rimestate.h      2022-11-08 04:59:34.529011700 
+0100
+++ new/fcitx5-rime-5.1.1/src/rimestate.h       2023-08-05 19:35:24.730569400 
+0200
@@ -6,11 +6,17 @@
 #ifndef _FCITX_RIMESTATE_H_
 #define _FCITX_RIMESTATE_H_
 
-#include "rimeengine.h"
+#include "rimesession.h"
+#include <fcitx/globalconfig.h>
+#include <fcitx/inputcontextmanager.h>
 #include <fcitx/inputcontextproperty.h>
+#include <memory>
+#include <rime_api.h>
 
 namespace fcitx {
 
+class RimeEngine;
+
 class RimeState : public InputContextProperty {
 public:
     RimeState(RimeEngine *engine, InputContext &ic);
@@ -28,14 +34,13 @@
     std::string subModeLabel();
     void setLatinMode(bool latin);
     void selectSchema(const std::string &schemaId);
+    RimeSessionId session();
 
 private:
-    void createSession();
-
     std::string lastMode_;
     RimeEngine *engine_;
-    RimeSessionId session_ = 0;
     InputContext &ic_;
+    std::shared_ptr<RimeSessionHolder> session_;
 };
 } // namespace fcitx
 

++++++ fcitx5-rime-cmake-3.10.patch ++++++
--- /var/tmp/diff_new_pack.39CTrY/_old  2023-08-21 11:44:59.191620434 +0200
+++ /var/tmp/diff_new_pack.39CTrY/_new  2023-08-21 11:44:59.195620441 +0200
@@ -1,17 +1,18 @@
-Index: fcitx5-rime-5.0.6/CMakeLists.txt
+Index: fcitx5-rime-5.1.1/CMakeLists.txt
 ===================================================================
---- fcitx5-rime-5.0.6.orig/CMakeLists.txt
-+++ fcitx5-rime-5.0.6/CMakeLists.txt
-@@ -17,6 +17,11 @@ pkg_check_modules(Rime REQUIRED IMPORTED
- if ("${Rime_VERSION}" VERSION_LESS "1.7.0")
-     add_definitions(-DFCITX_RIME_LOAD_PLUGIN)
+--- fcitx5-rime-5.1.1.orig/CMakeLists.txt
++++ fcitx5-rime-5.1.1/CMakeLists.txt
+@@ -21,6 +21,12 @@ if ("${Rime_VERSION}" VERSION_LESS "1.6.
+     add_definitions(-DFCITX_RIME_NO_LOG_LEVEL)
  endif()
+ 
 +if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
 +add_library(PkgConfig::Rime INTERFACE IMPORTED GLOBAL)
 +set_property(TARGET PkgConfig::Rime PROPERTY INTERFACE_INCLUDE_DIRECTORIES 
"${Rime_INCLUDE_DIR}")
 +set_property(TARGET PkgConfig::Rime PROPERTY INTERFACE_LINK_LIBRARIES 
"${LIB_INSTALL_DIR}/lib${Rime_LIBRARIES}.so")
 +endif()
- 
++
  if(NOT DEFINED RIME_DATA_DIR)
    find_package(RimeData REQUIRED)
+ endif(NOT DEFINED RIME_DATA_DIR)
 

Reply via email to