[Ttssh2-commit] [8470] CheckUpdateプラグインを修正

scmno****@osdn***** scmno****@osdn*****
2020年 1月 11日 (土) 00:50:04 JST


Revision: 8470
          https://osdn.net/projects/ttssh2/scm/svn/commits/8470
Author:   zmatsuo
Date:     2020-01-11 00:50:02 +0900 (Sat, 11 Jan 2020)
Log Message:
-----------
CheckUpdateプラグインを修正

- check updateメニューをhelpに移動
- メニューIDを変更
- m18n, (日本語のみ)追加

Modified Paths:
--------------
    trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt
    trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c
    trunk/installer/release/lang_utf8/Japanese.lng
    trunk/teraterm/common/i18n.c

-------------- next part --------------
Modified: trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt
===================================================================
--- trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt	2020-01-10 13:14:28 UTC (rev 8469)
+++ trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt	2020-01-10 15:50:02 UTC (rev 8470)
@@ -49,3 +49,9 @@
   ttpcmn
   Wininet.lib
   )
+
+install(
+  TARGETS TTXCheckUpdate
+  RUNTIME
+  DESTINATION .
+  )

Modified: trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c
===================================================================
--- trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c	2020-01-10 13:14:28 UTC (rev 8469)
+++ trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c	2020-01-10 15:50:02 UTC (rev 8470)
@@ -1,4 +1,3 @@
-/* -*- coding: utf-8-with-signature-dos -*- */
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -13,6 +12,7 @@
 #include "codeconv.h"
 #include "compat_w95.h"
 #include "dlglib.h"
+#include "i18n.h"
 
 #include "resource.h"
 #include "parse.h"
@@ -19,7 +19,7 @@
 #include "getcontent.h"
 
 #define ORDER 4000
-#define ID_MENUITEM 6000
+#define ID_MENUITEM 55900	// see reference/develop.txt
 
 typedef struct {
 	HANDLE hInst;
@@ -129,17 +129,21 @@
 	BOOL result_bool;
 	size_t json_size;
 	char *json_ptr;
+	const char *UILanguageFile = pvar->ts->UILanguageFile;
+	wchar_t UIMsg[MAX_UIMSG];
 
-	swprintf(buf, _countof(buf),
-			 L"ネットワークにアクセスします\n"
-			 L"  %s\n"
-			 L"よろしいですか?",
-			 update_info_url);
+	/* \x83t\x83@\x83C\x83\x8B\x82\xF0\x8E擾\x82\xB5\x82Ă\xE0ok? */
+	GetI18nStrW("TTXCheckUpdate", "MSG_CHECKUPDATE", UIMsg, _countof(UIMsg),
+				L"Do you want to check update?\n"
+				L"  %s\n",
+				UILanguageFile);
+	swprintf(buf, _countof(buf), UIMsg, update_info_url);
 	result_mb = MessageBoxW(hWnd, buf, L"Tera Term", MB_YESNO | MB_ICONEXCLAMATION);
 	if (result_mb == IDNO) {
 		return;
 	}
 
+	/* \x83t\x83@\x83C\x83\x8B\x8E擾\x81A'\0'\x82\xF0\x92lj\xC1\x82\xB7\x82遨 json\x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x8D쐬 */
 	swprintf(agent, _countof(agent), L"%s_%d", agent_base, pvar->ts->RunningVersion);
 	result_bool = GetContent(update_info_url, agent, (void**)&json_raw_ptr, &json_raw_size);
 	if (!result_bool) {
@@ -155,6 +159,7 @@
 	json_raw_ptr = NULL;
 	json_ptr[json_size - 1] = '\0';
 
+	/* json\x82\xF0\x83p\x81[\x83X\x82\xB7\x82\xE9 */
 	pvar->versions = ParseJson(json_ptr, &pvar->versions_count);
 	if (pvar->versions == NULL) {
 		MessageBoxW(hWnd, L"parse error?", L"Tera Term", MB_OK | MB_ICONEXCLAMATION);
@@ -161,10 +166,12 @@
 		return;
 	}
 
+	/* \x83_\x83C\x83A\x83\x8D\x83O\x82\xF0\x8Fo\x82\xB7 */
 	SetDialogFont(pvar->ts->DialogFontName, pvar->ts->DialogFontPoint, pvar->ts->DialogFontCharSet,
 				  pvar->ts->UILanguageFile, "Tera Term", "DLG_TAHOMA_FONT");
 	TTDialogBoxParam(pvar->hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, DlgProc, (LPARAM)pvar);
 
+	/* \x8FI\x97\xB9 */
 	free(json_ptr);
 	ParseFree(pvar->versions, pvar->versions_count);
 	pvar->versions = NULL;
@@ -176,10 +183,45 @@
 	pvar->cv = cv;
 }
 
+/**
+ *	\x83\x81\x83j\x83\x85\x81[\x82\xF0\x92lj\xC1\x82\xB7\x82\xE9
+ *
+ *	@param[in]	menu			\x83\x81\x83j\x83\x85\x81[\x83n\x83\x93\x83h\x83\x8B
+ *	@param[in]	beforeItemID	\x82\xB1\x82\xCCID\x82̃\x81\x83j\x83\x85\x81[\x82̑O\x82Ƀ\x81\x83j\x83\x85\x81[\x82\xF0\x92lj\xC1
+ *	@param[in]	flags			\x83\x81\x83j\x83\x85\x81[flag (InsertMenu\x82̑\xE63\x88\xF8\x90\x94)
+ *	@param[in]	newItemID		\x83\x81\x83j\x83\x85\x81[ID (InsertMenu\x82̑\xE64\x88\xF8\x90\x94)
+ *	@param[in]	text			\x83\x81\x83j\x83\x85\x81[\x95\xB6\x8E\x9A\x97\xF1 (InsertMenu\x82̑\xE65\x88\xF8\x90\x94)
+ *
+ *	TODO: ttlib\x82Ɉړ\xAE
+ */
+static void insertMenuBeforeItem(HMENU menu, WORD beforeItemID, WORD flags,
+                                 WORD newItemID, char *text)
+{
+	int i, j;
+
+	for (i = GetMenuItemCount(menu) - 1; i >= 0; i--) {
+		HMENU submenu = GetSubMenu(menu, i);
+
+		for (j = GetMenuItemCount(submenu) - 1; j >= 0; j--) {
+			if (GetMenuItemID(submenu, j) == beforeItemID) {
+				InsertMenu(submenu, j, MF_BYPOSITION | flags, newItemID, text);
+				return;
+			}
+		}
+	}
+}
+
 static void WINAPI TTXModifyMenu(HMENU menu)
 {
-	HMENU SetupMenu = GetSubMenu(menu, 0);
-	AppendMenu(SetupMenu, MF_ENABLED, ID_MENUITEM, "Check Update");
+	static const DlgTextInfo MenuTextInfo[] = {
+		{ ID_MENUITEM, "MENU_CHECKUPDATE" },
+	};
+	const UINT ID_HELP_ABOUT = 50990;
+	const char *UILanguageFile = pvar->ts->UILanguageFile;
+
+	insertMenuBeforeItem(menu, ID_HELP_ABOUT, MF_ENABLED, ID_MENUITEM, "Check &Update...");
+
+	SetI18MenuStrs("TTXCheckUpdate", menu, MenuTextInfo, _countof(MenuTextInfo), UILanguageFile);
 }
 
 static int WINAPI TTXProcessCommand(HWND hWin, WORD cmd)
@@ -219,7 +261,7 @@
 	}
 
 	if (!IsWindowsNTKernel()) {
-		// TODO Windows10以外、未検証
+		// TODO Windows10\x88ȊO\x81A\x96\xA2\x8C\x9F\x8F\xD8
 		return FALSE;
 	}
 

Modified: trunk/installer/release/lang_utf8/Japanese.lng
===================================================================
--- trunk/installer/release/lang_utf8/Japanese.lng	2020-01-10 13:14:28 UTC (rev 8469)
+++ trunk/installer/release/lang_utf8/Japanese.lng	2020-01-10 15:50:02 UTC (rev 8470)
@@ -1,4 +1,4 @@
-; Updated by TeraTerm Project (2020-01-09)
+; Updated by TeraTerm Project (2020-01-11)
 
 [Tera Term]
 DLG_SYSTEM_FONT=MS Pゴシック,12,128
@@ -1151,3 +1151,7 @@
 DLG_INTERVAL=間隔(秒)(&I)
 DLG_COMMAND=コマンド(&C)
 DLG_ADD_NEWLINE=改行を追加(&A)
+
+[TTXCheckUpdate]
+MSG_CHECKUPDATE=アップデートの確認を行いますか?\n  %s
+MENU_CHECKUPDATE=更新の確認(&U)...

Modified: trunk/teraterm/common/i18n.c
===================================================================
--- trunk/teraterm/common/i18n.c	2020-01-10 13:14:28 UTC (rev 8469)
+++ trunk/teraterm/common/i18n.c	2020-01-10 15:50:02 UTC (rev 8470)
@@ -211,12 +211,8 @@
 			char uimsg[MAX_UIMSG];
 			GetI18nStr(section, key, uimsg, sizeof(uimsg), NULL, UILanguageFile);
 			if (uimsg[0] != '\0') {
-				if (nIDDlgItem < id_position_threshold) {
-					ModifyMenuA(hMenu, nIDDlgItem, MF_BYPOSITION, nIDDlgItem, uimsg);
-				}
-				else {
-					ModifyMenuA(hMenu, nIDDlgItem, MF_BYCOMMAND, nIDDlgItem, uimsg);
-				}
+				UINT uFlags = (nIDDlgItem < id_position_threshold) ? MF_BYPOSITION : MF_BYCOMMAND;
+				ModifyMenuA(hMenu, nIDDlgItem, uFlags, nIDDlgItem, uimsg);
 			}
 			else {
 				if (nIDDlgItem < id_position_threshold) {
@@ -231,12 +227,8 @@
 			wchar_t uimsg[MAX_UIMSG];
 			GetI18nStrW(section, key, uimsg, _countof(uimsg), NULL, UILanguageFile);
 			if (uimsg[0] != '\0') {
-				if (nIDDlgItem < id_position_threshold) {
-					pModifyMenuW(hMenu, nIDDlgItem, MF_BYPOSITION, nIDDlgItem, uimsg);
-				}
-				else {
-					pModifyMenuW(hMenu, nIDDlgItem, MF_BYCOMMAND, nIDDlgItem, uimsg);
-				}
+				UINT uFlags = (nIDDlgItem < id_position_threshold) ? MF_BYPOSITION : MF_BYCOMMAND;
+				pModifyMenuW(hMenu, nIDDlgItem, uFlags, nIDDlgItem, uimsg);
 			}
 			else {
 				if (nIDDlgItem < id_position_threshold) {


Ttssh2-commit メーリングリストの案内