aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--system/keyboardlayouts/chinese.xml21
-rw-r--r--xbmc/input/CMakeLists.txt2
-rw-r--r--xbmc/input/InputCodingTableBaiduPY.cpp157
-rw-r--r--xbmc/input/InputCodingTableBaiduPY.h49
-rw-r--r--xbmc/input/InputCodingTableFactory.cpp11
5 files changed, 0 insertions, 240 deletions
diff --git a/system/keyboardlayouts/chinese.xml b/system/keyboardlayouts/chinese.xml
index c712b11010..2bd6f12658 100644
--- a/system/keyboardlayouts/chinese.xml
+++ b/system/keyboardlayouts/chinese.xml
@@ -24,25 +24,4 @@ Default font lacks support for all characters
<row>`~</row>
</keyboard>
</layout>
- <layout language="Chinese" layout="BaiduPY" codingtable="BaiduPY"
- apiurl="http://olime.baidu.com/py?input=%s&inputtype=py&bg=%d&ed=%d&result=hanzi&resultcoding=unicode&ch_en=0&clientinfo=web">
- <keyboard>
- <row>0123456789</row>
- <row>qwertyuiop</row>
- <row>asdfghjkl</row>
- <row>zxcvbnm</row>
- </keyboard>
- <keyboard modifiers="shift">
- <row>0123456789</row>
- <row>QWERTYUIOP</row>
- <row>ASDFGHJKL</row>
- <row>ZXCVBNM</row>
- </keyboard>
- <keyboard modifiers="symbol,shift+symbol">
- <row>)!@#$%^&amp;*(</row>
- <row>[]{}-_=+;:</row>
- <row>'",.&lt;&gt;/?\|</row>
- <row>`~</row>
- </keyboard>
- </layout>
</keyboardlayouts>
diff --git a/xbmc/input/CMakeLists.txt b/xbmc/input/CMakeLists.txt
index c835a29eca..3408cf003a 100644
--- a/xbmc/input/CMakeLists.txt
+++ b/xbmc/input/CMakeLists.txt
@@ -3,7 +3,6 @@ set(SOURCES AppTranslator.cpp
CustomControllerTranslator.cpp
GamepadTranslator.cpp
InertialScrollingHandler.cpp
- InputCodingTableBaiduPY.cpp
InputCodingTableBasePY.cpp
InputCodingTableFactory.cpp
InputCodingTableKorean.cpp
@@ -34,7 +33,6 @@ set(HEADERS hardware/IHardwareInput.h
IKeymapEnvironment.h
InertialScrollingHandler.h
InputCodingTable.h
- InputCodingTableBaiduPY.h
InputCodingTableBasePY.h
InputCodingTableFactory.h
InputCodingTableKorean.h
diff --git a/xbmc/input/InputCodingTableBaiduPY.cpp b/xbmc/input/InputCodingTableBaiduPY.cpp
deleted file mode 100644
index 600d8e6f4f..0000000000
--- a/xbmc/input/InputCodingTableBaiduPY.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2005-2018 Team Kodi
- * This file is part of Kodi - https://kodi.tv
- *
- * SPDX-License-Identifier: GPL-2.0-or-later
- * See LICENSES/README.md for more information.
- */
-
-#include "InputCodingTableBaiduPY.h"
-
-#include "ServiceBroker.h"
-#include "filesystem/CurlFile.h"
-#include "guilib/GUIComponent.h"
-#include "guilib/GUIMessage.h"
-#include "guilib/GUIWindowManager.h"
-#include "utils/RegExp.h"
-#include "utils/StringUtils.h"
-
-#include <stdlib.h>
-#include <utility>
-
-CInputCodingTableBaiduPY::CInputCodingTableBaiduPY(const std::string& strUrl)
- : CThread("BaiduPYApi"),
- m_messageCounter{0},
- m_api_begin{0},
- m_api_end{20},
- m_api_nomore{false},
- m_initialized{false}
-{
- m_url = strUrl;
- m_codechars = "abcdefghijklmnopqrstuvwxyz";
- m_code = "";
-}
-
-void CInputCodingTableBaiduPY::Process()
-{
- m_initialized = true;
- while (!m_bStop) // Make sure we don't exit the thread
- {
- AbortableWait(m_Event); // Wait for work to appear
- while (!m_bStop) // Process all queued work before going back to wait on the event
- {
- CSingleLock lock(m_CS);
- if (m_work.empty())
- break;
-
- auto work = m_work.front();
- m_work.pop_front();
- lock.Leave();
-
- std::string data;
- XFILE::CCurlFile http;
- std::string strUrl;
- strUrl = StringUtils::Format(m_url, work, m_api_begin, m_api_end);
-
- if (http.Get(strUrl, data))
- HandleResponse(work, data);
- }
- }
-}
-
-void CInputCodingTableBaiduPY::HandleResponse(const std::string& strCode,
- const std::string& response)
-{
- if (strCode != m_code) // don't handle obsolete response
- return;
-
- std::vector<std::wstring> words;
- CRegExp reg;
- reg.RegComp("\\[\"(.+?)\",[^\\]]+\\]");
- int pos = 0;
- int num = 0;
- while ((pos = reg.RegFind(response.c_str(), pos)) >= 0)
- {
- num++;
- std::string full = reg.GetMatch(0);
- std::string word = reg.GetMatch(1);
- pos += full.length();
- words.push_back(UnicodeToWString(word));
- }
- if (words.size() < 20)
- m_api_nomore = true;
- else
- {
- m_api_begin += 20;
- m_api_end += 20;
- }
- CSingleLock lock(m_CS);
- m_responses.insert(std::make_pair(++m_messageCounter, words));
- CGUIMessage msg(GUI_MSG_CODINGTABLE_LOOKUP_COMPLETED, 0, 0, m_messageCounter);
- msg.SetStringParam(strCode);
- lock.Leave();
- CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(
- msg, CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindowOrDialog());
-}
-
-std::wstring CInputCodingTableBaiduPY::UnicodeToWString(const std::string& unicode)
-{
- std::wstring result = L"";
- for (unsigned int i = 0; i < unicode.length(); i += 6)
- {
- int c;
- sscanf(unicode.c_str() + i, "\\u%x", &c);
- result += (wchar_t)c;
- }
- return result;
-}
-
-std::vector<std::wstring> CInputCodingTableBaiduPY::GetResponse(int response)
-{
- CSingleLock lock(m_CS);
- auto words = m_responses.at(response);
- m_responses.erase(response);
- return words;
-}
-
-void CInputCodingTableBaiduPY::Initialize()
-{
- CSingleLock lock(m_CS);
- if (!IsRunning())
- Create();
-}
-
-void CInputCodingTableBaiduPY::Deinitialize()
-{
- m_Event.Set();
- StopThread(true);
- m_initialized = false;
-}
-
-bool CInputCodingTableBaiduPY::IsInitialized() const
-{
- return m_initialized;
-}
-
-bool CInputCodingTableBaiduPY::GetWordListPage(const std::string& strCode, bool isFirstPage)
-{
- if (strCode.empty())
- return false;
- if (isFirstPage || m_code != strCode)
- {
- m_api_begin = 0;
- m_api_end = 20;
- m_code = strCode;
- m_api_nomore = false;
- }
- else
- {
- if (m_api_nomore)
- return false;
- }
-
- CSingleLock lock(m_CS);
- m_work.push_back(strCode);
- m_Event.Set();
- return true;
-}
diff --git a/xbmc/input/InputCodingTableBaiduPY.h b/xbmc/input/InputCodingTableBaiduPY.h
deleted file mode 100644
index 0b78cf4ba8..0000000000
--- a/xbmc/input/InputCodingTableBaiduPY.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2005-2018 Team Kodi
- * This file is part of Kodi - https://kodi.tv
- *
- * SPDX-License-Identifier: GPL-2.0-or-later
- * See LICENSES/README.md for more information.
- */
-
-#pragma once
-
-#include "InputCodingTable.h"
-#include "threads/Thread.h"
-
-#include <deque>
-#include <map>
-#include <string>
-#include <vector>
-
-class CInputCodingTableBaiduPY : public IInputCodingTable, public CThread
-{
-public:
- explicit CInputCodingTableBaiduPY(const std::string& strUrl);
- ~CInputCodingTableBaiduPY() override = default;
-
- void Initialize() override;
- void Deinitialize() override;
- bool IsInitialized() const override;
- bool GetWordListPage(const std::string& strCode, bool isFirstPage) override;
- void Process() override;
-
- std::vector<std::wstring> GetResponse(int response) override;
-
-private:
- std::wstring UnicodeToWString(const std::string& unicode);
- void HandleResponse(const std::string& strCode, const std::string& response);
-
- std::string m_url;
- std::string m_code;
- int m_messageCounter;
- int m_api_begin; // baidu api begin num
- int m_api_end; // baidu api end num
- bool m_api_nomore;
- bool m_initialized;
-
- std::deque<std::string> m_work;
- std::map<int, std::vector<std::wstring>> m_responses;
- CEvent m_Event;
- CCriticalSection m_CS;
-};
diff --git a/xbmc/input/InputCodingTableFactory.cpp b/xbmc/input/InputCodingTableFactory.cpp
index e43616cbd2..9dbcfd25bb 100644
--- a/xbmc/input/InputCodingTableFactory.cpp
+++ b/xbmc/input/InputCodingTableFactory.cpp
@@ -8,7 +8,6 @@
#include "InputCodingTableFactory.h"
-#include "InputCodingTableBaiduPY.h"
#include "InputCodingTableBasePY.h"
#include "InputCodingTableKorean.h"
#include "utils/XBMCTinyXML.h"
@@ -17,16 +16,6 @@
IInputCodingTable* CInputCodingTableFactory::CreateCodingTable(const std::string& strTableName,
const TiXmlElement* element)
{
- if (strTableName == "BaiduPY")
- {
- const char* apiurl = element->Attribute("apiurl");
- if (apiurl == nullptr)
- {
- CLog::Log(LOGWARNING, "CInputCodingTableFactory: invalid \"apiurl\" attribute");
- return nullptr;
- }
- return new CInputCodingTableBaiduPY(apiurl);
- }
if (strTableName == "BasePY")
return new CInputCodingTableBasePY();
if (strTableName == "Korean")